fix: Chrome Extensions service worker host registration (#39290)

This commit is contained in:
Shelley Vohr 2023-08-01 08:04:38 +02:00 committed by GitHub
parent b2c62d6ad1
commit c8f7a0e052
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 1 deletions

View file

@ -711,5 +711,20 @@ describe('chrome extensions', () => {
const scope = await registrationPromise;
expect(scope).equals(extension.url);
});
it('can run chrome extension APIs', async () => {
const customSession = session.fromPartition(`persist:${uuid.v4()}`);
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession, nodeIntegration: true } });
await customSession.loadExtension(path.join(fixtures, 'extensions', 'mv3-service-worker'));
await w.loadURL(url);
w.webContents.executeJavaScript('window.postMessage(\'fetch-confirmation\', \'*\')');
const [, , responseString] = await once(w.webContents, 'console-message');
const { message } = JSON.parse(responseString);
expect(message).to.equal('Hello from background.js');
});
});
});