test: deflake current-render-view-deleted test (#26698)

This commit is contained in:
Jeremy Rose 2020-11-30 17:06:25 -08:00 committed by GitHub
parent 19954126e0
commit 9c26be7b43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1202,24 +1202,25 @@ describe('webContents module', () => {
expect(currentRenderViewDeletedEmitted).to.be.false('current-render-view-deleted was emitted');
});
// TODO (jkleinsc) - this test is very flaky on WOA due to its dependence on a setTimeout; disabling until it can be rewritten
ifit(process.platform !== 'win32' || process.arch !== 'arm64')('does not emit current-render-view-deleted when speculative RVHs are deleted and nativeWindowOpen is set to true', async () => {
it('does not emit current-render-view-deleted when speculative RVHs are deleted and nativeWindowOpen is set to true', async () => {
const parentWindow = new BrowserWindow({ show: false, webPreferences: { nativeWindowOpen: true } });
let currentRenderViewDeletedEmitted = false;
let childWindow:BrowserWindow;
let childWindow: BrowserWindow | null = null;
const destroyed = emittedOnce(parentWindow.webContents, 'destroyed');
const renderViewDeletedHandler = () => {
currentRenderViewDeletedEmitted = true;
};
app.once('browser-window-created', (event, window) => {
childWindow = window;
window.webContents.on('current-render-view-deleted' as any, renderViewDeletedHandler);
const childWindowCreated = new Promise((resolve) => {
app.once('browser-window-created', (event, window) => {
childWindow = window;
window.webContents.on('current-render-view-deleted' as any, renderViewDeletedHandler);
resolve();
});
});
parentWindow.loadURL(`${serverUrl}/first-window-open`);
setTimeout(() => {
childWindow.webContents.removeListener('current-render-view-deleted' as any, renderViewDeletedHandler);
parentWindow.close();
}, 500);
await childWindowCreated;
childWindow!.webContents.removeListener('current-render-view-deleted' as any, renderViewDeletedHandler);
parentWindow.close();
await destroyed;
expect(currentRenderViewDeletedEmitted).to.be.false('child window was destroyed');
});