Merge pull request #3945 from deepak1556/web_frame_api_patch

webFrame: support fetch api for schemes that are privileged.
This commit is contained in:
Cheng Zhao 2015-12-29 19:48:50 +08:00
commit b392aeb16a
3 changed files with 22 additions and 2 deletions

View file

@ -112,6 +112,8 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme) {
privileged_scheme); privileged_scheme);
blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers(
privileged_scheme); privileged_scheme);
blink::WebSecurityPolicy::registerURLSchemeAsSupportingFetchAPI(
privileged_scheme);
} }
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder( mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(

View file

@ -87,7 +87,7 @@ Content Security Policy.
* `scheme` String * `scheme` String
Registers the `scheme` as secure, bypasses content security policy for resources and Registers the `scheme` as secure, bypasses content security policy for resources,
allows registering ServiceWorker. allows registering ServiceWorker and supports fetch API.
[spellchecker]: https://github.com/atom/node-spellchecker [spellchecker]: https://github.com/atom/node-spellchecker

View file

@ -0,0 +1,18 @@
assert = require 'assert'
path = require 'path'
{webFrame} = require 'electron'
describe 'webFrame module', ->
fixtures = path.resolve __dirname, 'fixtures'
describe 'webFrame.registerURLSchemeAsPrivileged', ->
it 'supports fetch api', (done) ->
webFrame.registerURLSchemeAsPrivileged 'file'
url = "file://#{fixtures}/assets/logo.png"
fetch(url).then((response) ->
assert response.ok
done()
).catch (err) ->
done('unexpected error : ' + err)