fix: reparenting UAF crash on macOS (#38603)

This commit is contained in:
Shelley Vohr 2023-06-08 12:18:37 +02:00 committed by GitHub
parent 9a9d8ae5ea
commit 5ee890fb6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 10 deletions

View file

@ -4677,6 +4677,21 @@ describe('BrowserWindow module', () => {
expect(w.getChildWindows().length).to.equal(0);
});
it('can handle child window close and reparent multiple times', async () => {
const w = new BrowserWindow({ show: false });
let c: BrowserWindow | null;
for (let i = 0; i < 5; i++) {
c = new BrowserWindow({ show: false, parent: w });
const closed = once(c, 'closed');
c.close();
await closed;
}
await setTimeout();
expect(w.getChildWindows().length).to.equal(0);
});
ifit(process.platform === 'darwin')('child window matches visibility when visibility changes', async () => {
const w = new BrowserWindow({ show: false });
const c = new BrowserWindow({ show: false, parent: w });