fix: crash when focusing WebView webContents (#43921)

fix: crash when focusing WebView
This commit is contained in:
Shelley Vohr 2024-09-25 01:19:04 +02:00 committed by GitHub
parent 500d4f0d05
commit bcf4095ace
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -1207,6 +1207,22 @@ describe('webContents module', () => {
expect(currentFocused).to.be.true();
expect(childFocused).to.be.false();
});
it('does not crash when focusing a WebView webContents', async () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
webviewTag: true
}
});
w.show();
await w.loadURL('data:text/html,<webview src="data:text/html,hi"></webview>');
const wc = webContents.getAllWebContents().find((wc) => wc.getType() === 'webview')!;
expect(() => wc.focus()).to.not.throw();
});
});
const moveFocusToDevTools = async (win: BrowserWindow) => {