|
@@ -72,6 +72,36 @@ describe('reporting api', () => {
|
|
|
server.close()
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ describe('window.open', () => {
|
|
|
+ it('denies custom open when nativeWindowOpen: true', async () => {
|
|
|
+ const w = new BrowserWindow({
|
|
|
+ show: false,
|
|
|
+ webPreferences: {
|
|
|
+ contextIsolation: false,
|
|
|
+ nodeIntegration: true,
|
|
|
+ nativeWindowOpen: true
|
|
|
+ }
|
|
|
+ });
|
|
|
+ w.loadURL('about:blank');
|
|
|
+
|
|
|
+ const previousListeners = process.listeners('uncaughtException');
|
|
|
+ process.removeAllListeners('uncaughtException');
|
|
|
+ try {
|
|
|
+ const uncaughtException = new Promise<Error>(resolve => {
|
|
|
+ process.once('uncaughtException', resolve);
|
|
|
+ });
|
|
|
+ expect(await w.webContents.executeJavaScript(`(${function () {
|
|
|
+ const ipc = process.electronBinding('ipc').ipc;
|
|
|
+ return ipc.sendSync(true, 'ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', ['', '', ''])[0];
|
|
|
+ }})()`)).to.be.null('null');
|
|
|
+ const exception = await uncaughtException;
|
|
|
+ expect(exception.message).to.match(/denied: expected native window\.open/);
|
|
|
+ } finally {
|
|
|
+ previousListeners.forEach(l => process.on('uncaughtException', l));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
})
|
|
|
|
|
|
describe('window.postMessage', () => {
|