fix: window.open causing occasional Node.js crashes (#38754)

* fix: window.open causing occasional Node.js crashes

* chore: always free isolate data

* chore: clear pending ticks in worker thread

* fix: UAF crash when creating WebWorkerObserver

---------

Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
Shelley Vohr 2023-07-18 10:41:50 +02:00 committed by GitHub
parent 4ab0a5ade4
commit 8874306dc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 41 deletions

View file

@ -1114,6 +1114,28 @@ describe('chromium features', () => {
expect(frameName).to.equal('__proto__');
});
it('works when used in conjunction with the vm module', async () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
await w.loadFile(path.resolve(__dirname, 'fixtures', 'blank.html'));
const { contextObject } = await w.webContents.executeJavaScript(`(async () => {
const vm = require('node:vm');
const contextObject = { count: 1, type: 'gecko' };
window.open('');
vm.runInNewContext('count += 1; type = "chameleon";', contextObject);
return { contextObject };
})()`);
expect(contextObject).to.deep.equal({ count: 2, type: 'chameleon' });
});
// FIXME(nornagon): I'm not sure this ... ever was correct?
xit('inherit options of parent window', async () => {
const w = new BrowserWindow({ show: false, width: 123, height: 456 });