test: fix for flaky renderer crash test (#34452)

This commit is contained in:
Samuel Maddock 2022-06-06 17:39:58 -04:00 committed by GitHub
parent e56f626b94
commit 882fa36940
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,7 +230,9 @@ describe('webFrameMain module', () => {
// Keep reference to mainFrame alive throughout crash and recovery. // Keep reference to mainFrame alive throughout crash and recovery.
const { mainFrame } = w.webContents; const { mainFrame } = w.webContents;
await w.webContents.loadURL(server.url); await w.webContents.loadURL(server.url);
const crashEvent = emittedOnce(w.webContents, 'render-process-gone');
w.webContents.forcefullyCrashRenderer(); w.webContents.forcefullyCrashRenderer();
await crashEvent;
await w.webContents.loadURL(server.url); await w.webContents.loadURL(server.url);
// Log just to keep mainFrame in scope. // Log just to keep mainFrame in scope.
console.log('mainFrame.url', mainFrame.url); console.log('mainFrame.url', mainFrame.url);
@ -244,7 +246,9 @@ describe('webFrameMain module', () => {
// Keep reference to mainFrame alive throughout crash and recovery. // Keep reference to mainFrame alive throughout crash and recovery.
const { mainFrame } = w.webContents; const { mainFrame } = w.webContents;
await w.webContents.loadURL(server.url); await w.webContents.loadURL(server.url);
const crashEvent = emittedOnce(w.webContents, 'render-process-gone');
w.webContents.forcefullyCrashRenderer(); w.webContents.forcefullyCrashRenderer();
await crashEvent;
// A short wait seems to be required to reproduce the crash. // A short wait seems to be required to reproduce the crash.
await new Promise(resolve => setTimeout(resolve, 100)); await new Promise(resolve => setTimeout(resolve, 100));
await w.webContents.loadURL(crossOriginUrl); await w.webContents.loadURL(crossOriginUrl);