Merge pull request #3945 from deepak1556/web_frame_api_patch
webFrame: support fetch api for schemes that are privileged.
This commit is contained in:
commit
b392aeb16a
3 changed files with 22 additions and 2 deletions
|
@ -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(
|
||||||
|
|
|
@ -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
|
||||||
|
|
18
spec/api-web-frame-spec.coffee
Normal file
18
spec/api-web-frame-spec.coffee
Normal 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)
|
Loading…
Reference in a new issue