fix: check WebContents before emitting render-process-gone event (#27730)

This commit is contained in:
Cheng Zhao 2021-02-17 21:19:17 +09:00 committed by GitHub
parent 642d6fca91
commit 7a7a27d9bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -2007,6 +2007,17 @@ describe('webContents module', () => {
});
});
describe('crashed event', () => {
it('does not crash main process when destroying WebContents in it', (done) => {
const contents = (webContents as any).create({ nodeIntegration: true });
contents.once('crashed', () => {
contents.destroy();
done();
});
contents.loadURL('about:blank').then(() => contents.forcefullyCrashRenderer());
});
});
it('emits a cancelable event before creating a child webcontents', async () => {
const w = new BrowserWindow({
show: false,