fix: handle closing webContents in BrowserViews (#37420)

* fix: handle closing webContents in BrowserViews

* test: add window.close() test
This commit is contained in:
Shelley Vohr 2023-03-01 11:35:06 +01:00 committed by GitHub
parent 8fb0f43030
commit 5e25d23794
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 5 deletions

View file

@ -345,6 +345,24 @@ describe('BrowserView module', () => {
const [code] = await once(rc.process, 'exit');
expect(code).to.equal(0);
});
it('emits the destroyed event when webContents.close() is called', async () => {
view = new BrowserView();
w.setBrowserView(view);
await view.webContents.loadFile(path.join(fixtures, 'pages', 'a.html'));
view.webContents.close();
await once(view.webContents, 'destroyed');
});
it('emits the destroyed event when window.close() is called', async () => {
view = new BrowserView();
w.setBrowserView(view);
await view.webContents.loadFile(path.join(fixtures, 'pages', 'a.html'));
view.webContents.executeJavaScript('window.close()');
await once(view.webContents, 'destroyed');
});
});
describe('window.open()', () => {