fix: fetch-dependent interfaces in Web Workers (#42579)

This commit is contained in:
Shelley Vohr 2024-06-20 17:01:50 +02:00 committed by GitHub
parent edb939ae80
commit 37608933ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 101 additions and 13 deletions

View file

@ -1019,12 +1019,35 @@ describe('chromium features', () => {
});
it('Worker has node integration with nodeIntegrationInWorker', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, contextIsolation: false } });
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
contextIsolation: false
}
});
w.loadURL(`file://${fixturesPath}/pages/worker.html`);
const [, data] = await once(ipcMain, 'worker-result');
expect(data).to.equal('object function object function');
});
it('Worker has access to fetch-dependent interfaces with nodeIntegrationInWorker', async () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
contextIsolation: false
}
});
w.loadURL(`file://${fixturesPath}/pages/worker-fetch.html`);
const [, data] = await once(ipcMain, 'worker-fetch-result');
expect(data).to.equal('function function function function function');
});
describe('SharedWorker', () => {
it('can work', async () => {
const w = new BrowserWindow({ show: false });