fix(extensions): devtools now open for background pages (#22217)
refactor(extensions): remove unused InitWithBrowserContext method fix(extensions): release background page WebContents to avoid crash The background page WebContents instance is managed by the ExtensionHost. fix(extensions): open background page devtools detached by default test(extensions): add background page devtools test chore: test fix for null web_contents() fix: close background page devtools in test after opening
This commit is contained in:
parent
ae5776041e
commit
5a8046c994
4 changed files with 103 additions and 24 deletions
|
@ -317,16 +317,28 @@ describe('chrome extensions', () => {
|
|||
const receivedMessage = await w.webContents.executeJavaScript('window.completionPromise');
|
||||
expect(receivedMessage).to.deep.equal({ some: 'message' });
|
||||
});
|
||||
});
|
||||
|
||||
it('has session in background page', async () => {
|
||||
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`);
|
||||
await customSession.loadExtension(path.join(fixtures, 'extensions', 'persistent-background-page'));
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession } });
|
||||
const promise = emittedOnce(app, 'web-contents-created');
|
||||
await w.loadURL('about:blank');
|
||||
const [, bgPageContents] = await promise;
|
||||
expect(bgPageContents.session).to.not.equal(undefined);
|
||||
it('has session in background page', async () => {
|
||||
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`);
|
||||
await customSession.loadExtension(path.join(fixtures, 'extensions', 'persistent-background-page'));
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession } });
|
||||
const promise = emittedOnce(app, 'web-contents-created');
|
||||
await w.loadURL('about:blank');
|
||||
const [, bgPageContents] = await promise;
|
||||
expect(bgPageContents.session).to.not.equal(undefined);
|
||||
});
|
||||
|
||||
it('can open devtools of background page', async () => {
|
||||
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`);
|
||||
await customSession.loadExtension(path.join(fixtures, 'extensions', 'persistent-background-page'));
|
||||
const w = new BrowserWindow({ show: false, webPreferences: { session: customSession } });
|
||||
const promise = emittedOnce(app, 'web-contents-created');
|
||||
await w.loadURL('about:blank');
|
||||
const [, bgPageContents] = await promise;
|
||||
expect(bgPageContents.getType()).to.equal('backgroundPage');
|
||||
bgPageContents.openDevTools();
|
||||
bgPageContents.closeDevTools();
|
||||
});
|
||||
});
|
||||
|
||||
describe('devtools extensions', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue