fix: crash loading non-standard schemes in iframes (#35485)
This commit is contained in:
parent
bfced8cbfe
commit
e0fb5cbe1f
4 changed files with 112 additions and 1 deletions
|
@ -9,7 +9,7 @@ import * as fs from 'fs';
|
|||
import * as qs from 'querystring';
|
||||
import * as stream from 'stream';
|
||||
import { EventEmitter } from 'events';
|
||||
import { closeWindow } from './window-helpers';
|
||||
import { closeAllWindows, closeWindow } from './window-helpers';
|
||||
import { emittedOnce } from './events-helpers';
|
||||
import { WebmGenerator } from './video-helpers';
|
||||
import { delay } from './spec-helpers';
|
||||
|
@ -216,6 +216,8 @@ describe('protocol module', () => {
|
|||
const normalPath = path.join(fixturesPath, 'pages', 'a.html');
|
||||
const normalContent = fs.readFileSync(normalPath);
|
||||
|
||||
afterEach(closeAllWindows);
|
||||
|
||||
it('sends file path as response', async () => {
|
||||
registerFileProtocol(protocolName, (request, callback) => callback(filePath));
|
||||
const r = await ajax(protocolName + '://fake-host');
|
||||
|
@ -239,6 +241,25 @@ describe('protocol module', () => {
|
|||
expect(r.headers).to.have.property('x-great-header', 'sogreat');
|
||||
});
|
||||
|
||||
it('can load iframes with custom protocols', (done) => {
|
||||
registerFileProtocol('custom', (request, callback) => {
|
||||
const filename = request.url.substring(9);
|
||||
const p = path.join(__dirname, 'fixtures', 'pages', filename);
|
||||
callback({ path: p });
|
||||
});
|
||||
|
||||
const w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
|
||||
w.loadFile(path.join(__dirname, 'fixtures', 'pages', 'iframe-protocol.html'));
|
||||
ipcMain.once('loaded-iframe-custom-protocol', () => done());
|
||||
});
|
||||
|
||||
it.skip('throws an error when custom headers are invalid', (done) => {
|
||||
registerFileProtocol(protocolName, (request, callback) => {
|
||||
expect(() => callback({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue