mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(target): add support for target.page for 'backgroud_page' (#2600)
This patch teaches `target.page()` method to attach to extension background pages. Fixes #2438
This commit is contained in:
committed by
Andrey Lushnikov
parent
cd8d750628
commit
38f112f395
@@ -51,6 +51,14 @@ module.exports.addTests = function({testRunner, expect, PROJECT_ROOT, defaultBro
|
||||
await browserWithExtension.close();
|
||||
expect(backgroundPageTarget).toBeTruthy();
|
||||
});
|
||||
it('target.page() should return a background_page', async({browser}) => {
|
||||
const browserWithExtension = await puppeteer.launch(extensionOptions);
|
||||
const targets = await browserWithExtension.targets();
|
||||
const backgroundPageTarget = targets.find(target => target.type() === 'background_page');
|
||||
const page = await backgroundPageTarget.page();
|
||||
expect(await page.evaluate(() => 2 * 3)).toBe(6);
|
||||
await browserWithExtension.close();
|
||||
});
|
||||
it('should have default url when launching browser', async function() {
|
||||
const browser = await puppeteer.launch(extensionOptions);
|
||||
const pages = (await browser.pages()).map(page => page.url());
|
||||
|
||||
Reference in New Issue
Block a user