fix: enable workaround for nativeWindowOpen hang (#22825)
This commit is contained in:
parent
21c839578f
commit
5154e8ff75
3 changed files with 61 additions and 0 deletions
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue