Skip to content

Commit

Permalink
fixup! fix: window.open doesn't work correctly in child window
Browse files Browse the repository at this point in the history
  • Loading branch information
CezaryKulakowski committed Aug 27, 2020
1 parent f66eba4 commit 2172d07
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions spec-main/api-web-contents-spec.ts
Expand Up @@ -1195,21 +1195,25 @@ describe('webContents module', () => {
expect(currentRenderViewDeletedEmitted).to.be.false('current-render-view-deleted was emitted');
});

it('does not destroy child window when wrong url and nativeWindowOpen set to true', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nativeWindowOpen: true } });
let childWindowWasDestroyed = false;
const destroyed = emittedOnce(w.webContents, 'destroyed');
app.on('browser-window-created', (event, window) => {
window.webContents.on('destroyed', () => {
childWindowWasDestroyed = true;
});
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;
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);
});
w.loadURL(`${serverUrl}/first-window-open`);
parentWindow.loadURL(`${serverUrl}/first-window-open`);
setTimeout(() => {
w.close();
childWindow.webContents.removeListener('current-render-view-deleted' as any, renderViewDeletedHandler);
parentWindow.close();
}, 500);
await destroyed;
expect(childWindowWasDestroyed).to.be.false('child window was destroyed');
expect(currentRenderViewDeletedEmitted).to.be.false('child window was destroyed');
});

it('emits current-render-view-deleted if the current RVHs are deleted', async () => {
Expand Down

0 comments on commit 2172d07

Please sign in to comment.