fix: prevent crash when keyboard event immediately precedes calling BrowserWindow.close() (#27315)
* fix: prevent crash when destroyed widget receives keyboard event Activating a key to close a window will cause a silent crash. Handling the keyboard event will lead to a nullptr dereferenced in Chromium code if the window widget has already been destroyed. * test: ensure BrowserWindow doesn't crash from keyboard events during close
This commit is contained in:
parent
d7b02e123a
commit
4334110339
3 changed files with 17 additions and 0 deletions
|
@ -110,6 +110,14 @@ describe('BrowserWindow module', () => {
|
|||
await emittedOnce(w.webContents, 'before-unload-fired');
|
||||
});
|
||||
|
||||
it('should not crash when keyboard event is sent before closing', async () => {
|
||||
await w.loadURL('data:text/html,pls no crash');
|
||||
const closed = emittedOnce(w, 'closed');
|
||||
w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Escape' });
|
||||
w.close();
|
||||
await closed;
|
||||
});
|
||||
|
||||
describe('when invoked synchronously inside navigation observer', () => {
|
||||
let server: http.Server = null as unknown as http.Server;
|
||||
let url: string = null as unknown as string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue