Note about incorrect usage of blink::SchemeRegistry methods

This commit is contained in:
deepak1556 2017-12-18 14:59:28 +05:30 committed by Cheng Zhao
parent 73919ea91a
commit fd297722a8
4 changed files with 6 additions and 9 deletions

View file

@ -215,6 +215,10 @@ void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) {
void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
mate::Arguments* args) {
// TODO(deepak1556): blink::SchemeRegistry methods should be called
// before any renderer threads are created. Fixing this would break
// current api. Change it with 2.0.
// Read optional flags
bool secure = true;
bool bypassCSP = true;

View file

@ -116,6 +116,7 @@ void RendererClientBase::RenderThreadStarted() {
// Allow file scheme to handle service worker by default.
// FIXME(zcbenz): Can this be moved elsewhere?
blink::WebSecurityPolicy::RegisterURLSchemeAsAllowingServiceWorkers("file");
blink::SchemeRegistry::RegisterURLSchemeAsSupportingFetchAPI("file");
preferences_manager_.reset(new PreferencesManager);

View file

@ -17,7 +17,6 @@ describe('webFrame module', function () {
describe('webFrame.registerURLSchemeAsPrivileged', function () {
it('supports fetch api by default', function (done) {
webFrame.registerURLSchemeAsPrivileged('file')
var url = 'file://' + fixtures + '/assets/logo.png'
window.fetch(url).then(function (response) {
assert(response.ok)

View file

@ -4,7 +4,7 @@ const http = require('http')
const path = require('path')
const ws = require('ws')
const url = require('url')
const {ipcRenderer, remote, webFrame} = require('electron')
const {ipcRenderer, remote} = require('electron')
const {closeWindow} = require('./window-helpers')
const {app, BrowserWindow, ipcMain, protocol, session, webContents} = remote
@ -1043,13 +1043,6 @@ describe('chromium feature', () => {
})
it('should not open when pdf is requested as sub resource', (done) => {
createBrowserWindow({plugins: true, preload: 'preload-pdf-loaded.js'})
webFrame.registerURLSchemeAsPrivileged('file', {
secure: false,
bypassCSP: false,
allowServiceWorkers: false,
corsEnabled: false
})
fetch(pdfSource).then((res) => {
assert.equal(res.status, 200)
assert.notEqual(document.title, 'cat.pdf')