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
@@ -183,7 +183,11 @@ class Browser extends EventEmitter {
|
||||
* @return {!Promise<!Array<!Puppeteer.Page>>}
|
||||
*/
|
||||
async pages() {
|
||||
const pages = await Promise.all(this.targets().map(target => target.page()));
|
||||
const pages = await Promise.all(
|
||||
this.targets()
|
||||
.filter(target => target.type() === 'page')
|
||||
.map(target => target.page())
|
||||
);
|
||||
return pages.filter(page => !!page);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class Target {
|
||||
* @return {!Promise<?Page>}
|
||||
*/
|
||||
async page() {
|
||||
if (this._targetInfo.type === 'page' && !this._pagePromise) {
|
||||
if ((this._targetInfo.type === 'page' || this._targetInfo.type === 'background_page') && !this._pagePromise) {
|
||||
this._pagePromise = this._sessionFactory()
|
||||
.then(client => Page.create(client, this, this._ignoreHTTPSErrors, this._setDefaultViewport, this._screenshotTaskQueue));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user