webFrame: support fetch api for schemes that are privileged.

This commit is contained in:
Robo 2015-12-29 15:56:19 +05:30
parent 5f3c6107d5
commit 2e78aba090
3 changed files with 22 additions and 2 deletions

View file

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

View file

@ -87,7 +87,7 @@ Content Security Policy.
* `scheme` String
Registers the `scheme` as secure, bypasses content security policy for resources and
allows registering ServiceWorker.
Registers the `scheme` as secure, bypasses content security policy for resources,
allows registering ServiceWorker and supports fetch API.
[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)