Skip to content

Commit

Permalink
fix: stop window.open from hanging when prevented (#29881)
Browse files Browse the repository at this point in the history
* fix: stop window.open from hanging when prevented

* add test

Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
  • Loading branch information
trop[bot] and nornagon committed Jun 28, 2021
1 parent a6f26b5 commit 5bef67a
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 @@ -75,6 +75,7 @@ ipcMainInternal.on(

const browserWindowOptions = (event.sender as any)._callWindowOpenHandler(event, url, frameName, features);
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 @@ -224,6 +224,12 @@ describe('webContents.setWindowOpenHandler', () => {

browserWindow.webContents.executeJavaScript("window.open('about:blank') && 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 5bef67a

Please sign in to comment.