Skip to content

Commit

Permalink
fix: stop window.open from hanging when prevented (#29851)
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon committed Jun 24, 2021
1 parent 9de8e67 commit 0f16575
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/browser/guest-window-proxy.ts
Expand Up @@ -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({
Expand Down
6 changes: 6 additions & 0 deletions spec-main/guest-window-manager-spec.ts
Expand Up @@ -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);
});
});
}
});
Expand Down

0 comments on commit 0f16575

Please sign in to comment.