test: use webContents.setWindowOpenHandler() in specs (#34514)
* test: use webContents.setWindowOpenHandler() in specs * test: use browser-window-created instead of new-window for visibility spec
This commit is contained in:
parent
954fd72500
commit
16cd22ff6a
3 changed files with 15 additions and 11 deletions
|
@ -3265,9 +3265,6 @@ describe('BrowserWindow module', () => {
|
||||||
action: 'allow',
|
action: 'allow',
|
||||||
overrideBrowserWindowOptions: { show: false, webPreferences: { contextIsolation: false, webviewTag: true, nodeIntegrationInSubFrames: true } }
|
overrideBrowserWindowOptions: { show: false, webPreferences: { contextIsolation: false, webviewTag: true, nodeIntegrationInSubFrames: true } }
|
||||||
}));
|
}));
|
||||||
w.webContents.once('new-window', (event, url, frameName, disposition, options) => {
|
|
||||||
options.show = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
const webviewLoaded = emittedOnce(ipcMain, 'webview-loaded');
|
const webviewLoaded = emittedOnce(ipcMain, 'webview-loaded');
|
||||||
w.loadFile(path.join(fixtures, 'api', 'new-window-webview.html'));
|
w.loadFile(path.join(fixtures, 'api', 'new-window-webview.html'));
|
||||||
|
|
|
@ -788,10 +788,10 @@ describe('chromium features', () => {
|
||||||
|
|
||||||
defer(() => { w.close(); });
|
defer(() => { w.close(); });
|
||||||
|
|
||||||
const newWindow = emittedOnce(w.webContents, 'new-window');
|
const promise = emittedOnce(app, 'browser-window-created');
|
||||||
w.loadFile(path.join(fixturesPath, 'pages', 'window-open.html'));
|
w.loadFile(path.join(fixturesPath, 'pages', 'window-open.html'));
|
||||||
const [,,,, options] = await newWindow;
|
const [, newWindow] = await promise;
|
||||||
expect(options.show).to.equal(true);
|
expect(newWindow.isVisible()).to.equal(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,8 +900,12 @@ describe('chromium features', () => {
|
||||||
const w = new BrowserWindow({ show: false });
|
const w = new BrowserWindow({ show: false });
|
||||||
w.loadURL('about:blank');
|
w.loadURL('about:blank');
|
||||||
w.webContents.executeJavaScript('{ b = window.open(\'\', \'__proto__\'); null }');
|
w.webContents.executeJavaScript('{ b = window.open(\'\', \'__proto__\'); null }');
|
||||||
const [, , frameName] = await emittedOnce(w.webContents, 'new-window');
|
const frameName = await new Promise((resolve) => {
|
||||||
|
w.webContents.setWindowOpenHandler(details => {
|
||||||
|
setImmediate(() => resolve(details.frameName));
|
||||||
|
return { action: 'allow' };
|
||||||
|
});
|
||||||
|
});
|
||||||
expect(frameName).to.equal('__proto__');
|
expect(frameName).to.equal('__proto__');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,9 +32,12 @@ describe('<webview> tag', function () {
|
||||||
afterEach(closeAllWindows);
|
afterEach(closeAllWindows);
|
||||||
|
|
||||||
function hideChildWindows (e: any, wc: WebContents) {
|
function hideChildWindows (e: any, wc: WebContents) {
|
||||||
wc.on('new-window', (event, url, frameName, disposition, options) => {
|
wc.setWindowOpenHandler(() => ({
|
||||||
options.show = false;
|
action: 'allow',
|
||||||
});
|
overrideBrowserWindowOptions: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue