fix: potential async_hooks crash in NotifyWindowRestore on Windows (#40576)

* fix: potential async_hooks crash in NotifyWindowRestore on Windows

* fix: don't use CallbackScope for Error objects
This commit is contained in:
Shelley Vohr 2024-01-26 19:53:07 +01:00 committed by GitHub
parent db2bf1a0d1
commit 8104c7908a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 60 additions and 10 deletions

View file

@ -14,6 +14,7 @@ import { closeWindow, closeAllWindows } from './lib/window-helpers';
import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib/screen-helpers';
import { once } from 'node:events';
import { setTimeout } from 'node:timers/promises';
import { setTimeout as syncSetTimeout } from 'node:timers';
const fixtures = path.resolve(__dirname, 'fixtures');
const mainFixtures = path.resolve(__dirname, 'fixtures');
@ -1809,6 +1810,36 @@ describe('BrowserWindow module', () => {
expect(w.isFullScreen()).to.equal(true);
});
it('does not crash if maximized, minimized, then restored to maximized state', (done) => {
w.destroy();
w = new BrowserWindow({ show: false });
w.show();
let count = 0;
w.on('maximize', () => {
if (count === 0) syncSetTimeout(() => { w.minimize(); });
count++;
});
w.on('minimize', () => {
if (count === 1) syncSetTimeout(() => { w.restore(); });
count++;
});
w.on('restore', () => {
try {
throw new Error('hey!');
} catch (e: any) {
expect(e.message).to.equal('hey!');
done();
}
});
w.maximize();
});
it('checks normal bounds for maximized transparent window', async () => {
w.destroy();
w = new BrowserWindow({