fix: enable workaround for nativeWindowOpen hang (#22825)

This commit is contained in:
loc 2020-04-13 08:37:41 -07:00 committed by GitHub
parent 21c839578f
commit 5154e8ff75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 0 deletions

View file

@ -1829,4 +1829,26 @@ describe('webContents module', () => {
expect(body).to.equal('401');
});
});
it('emits a cancelable event before creating a child webcontents', async () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
sandbox: true
}
});
w.webContents.on('-will-add-new-contents' as any, (event: any, url: any) => {
expect(url).to.equal('about:blank');
event.preventDefault();
});
let wasCalled = false;
w.webContents.on('new-window' as any, () => {
wasCalled = true;
});
await w.loadURL('about:blank');
await w.webContents.executeJavaScript(`window.open('about:blank')`);
await new Promise((resolve) => { process.nextTick(resolve); });
expect(wasCalled).to.equal(false);
await closeAllWindows();
});
});