fix: stop window.open from hanging when prevented (#29851)
This commit is contained in:
parent
9de8e676dd
commit
0f16575eee
2 changed files with 7 additions and 0 deletions
|
@ -76,6 +76,7 @@ ipcMainInternal.on(
|
|||
const referrer: Electron.Referrer = { url: '', policy: 'strict-origin-when-cross-origin' };
|
||||
const browserWindowOptions = event.sender._callWindowOpenHandler(event, { url, frameName, features, disposition: 'new-window', referrer });
|
||||
if (event.defaultPrevented) {
|
||||
event.returnValue = null;
|
||||
return;
|
||||
}
|
||||
const guest = openGuestWindow({
|
||||
|
|
|
@ -263,6 +263,12 @@ describe('webContents.setWindowOpenHandler', () => {
|
|||
|
||||
browserWindow.webContents.executeJavaScript("window.open('about:blank', '', 'show=no') && true");
|
||||
});
|
||||
|
||||
it('does not hang parent window when denying window.open', async () => {
|
||||
browserWindow.webContents.setWindowOpenHandler(() => ({ action: 'deny' }));
|
||||
browserWindow.webContents.executeJavaScript("window.open('https://127.0.0.1')");
|
||||
expect(await browserWindow.webContents.executeJavaScript('42')).to.equal(42);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue