fix: crash on window.close() with webContents on blur (#47933)

fix: crash on window.close with WebContentsView on blur
This commit is contained in:
Shelley Vohr 2025-08-04 10:35:29 +02:00 committed by GitHub
commit 4232ed2814
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 8 deletions

View file

@ -167,6 +167,26 @@ describe('WebContentsView', () => {
});
});
it('does not crash when closed via window.close()', async () => {
const bw = new BrowserWindow();
const wcv = new WebContentsView();
await bw.loadURL('data:text/html,<h1>Main Window</h1>');
bw.contentView.addChildView(wcv);
const dto = new Promise<boolean>((resolve) => {
wcv.webContents.on('blur', () => {
const devToolsOpen = wcv.webContents.isDevToolsOpened();
resolve(devToolsOpen);
});
});
wcv.webContents.loadURL('data:text/html,<script>window.close()</script>');
const open = await dto;
expect(open).to.be.false();
});
it('can be fullscreened', async () => {
const w = new BaseWindow();
const v = new WebContentsView();