feat: partially support chrome.tabs.update (#30069)
This commit is contained in:
parent
cce27a0961
commit
ceebae170e
7 changed files with 315 additions and 7 deletions
|
@ -337,9 +337,13 @@ describe('chrome extensions', () => {
|
|||
});
|
||||
|
||||
describe('chrome.tabs', () => {
|
||||
it('executeScript', async () => {
|
||||
const customSession = session.fromPartition(`persist:${uuid.v4()}`);
|
||||
let customSession: Session;
|
||||
before(async () => {
|
||||
customSession = session.fromPartition(`persist:${uuid.v4()}`);
|
||||
await customSession.loadExtension(path.join(fixtures, 'extensions', 'chrome-api'));
|
||||
});
|
||||
|
||||
it('executeScript', async () => {
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession, nodeIntegration: true } });
|
||||
await w.loadURL(url);
|
||||
|
||||
|
@ -353,8 +357,6 @@ describe('chrome extensions', () => {
|
|||
});
|
||||
|
||||
it('connect', async () => {
|
||||
const customSession = session.fromPartition(`persist:${uuid.v4()}`);
|
||||
await customSession.loadExtension(path.join(fixtures, 'extensions', 'chrome-api'));
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession, nodeIntegration: true } });
|
||||
await w.loadURL(url);
|
||||
|
||||
|
@ -368,9 +370,7 @@ describe('chrome extensions', () => {
|
|||
expect(response[1]).to.equal('howdy');
|
||||
});
|
||||
|
||||
it('sendMessage receives the response', async function () {
|
||||
const customSession = session.fromPartition(`persist:${uuid.v4()}`);
|
||||
await customSession.loadExtension(path.join(fixtures, 'extensions', 'chrome-api'));
|
||||
it('sendMessage receives the response', async () => {
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession, nodeIntegration: true } });
|
||||
await w.loadURL(url);
|
||||
|
||||
|
@ -383,6 +383,28 @@ describe('chrome extensions', () => {
|
|||
expect(response.message).to.equal('Hello World!');
|
||||
expect(response.tabId).to.equal(w.webContents.id);
|
||||
});
|
||||
|
||||
it('update', async () => {
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession, nodeIntegration: true } });
|
||||
await w.loadURL(url);
|
||||
|
||||
const w2 = new BrowserWindow({ show: false, webPreferences: { session: customSession } });
|
||||
await w2.loadURL('about:blank');
|
||||
|
||||
const w2Navigated = emittedOnce(w2.webContents, 'did-navigate');
|
||||
|
||||
const message = { method: 'update', args: [w2.webContents.id, { url }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await emittedOnce(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
await w2Navigated;
|
||||
|
||||
expect(new URL(w2.getURL()).toString()).to.equal(new URL(url).toString());
|
||||
|
||||
expect(response.id).to.equal(w2.webContents.id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('background pages', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue