From 28087c291f49b0c8ceec550a57ae3bf1ef8a22db Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 5 Feb 2019 13:29:49 -0800 Subject: [PATCH] feat(firefox): support ElementHandle.contentFrame() (#3917) --- experimental/puppeteer-firefox/lib/firefox/Page.js | 13 +++++++++++++ experimental/puppeteer-firefox/package.json | 2 +- test/elementhandle.spec.js | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/experimental/puppeteer-firefox/lib/firefox/Page.js b/experimental/puppeteer-firefox/lib/firefox/Page.js index d779f36c..312988af 100644 --- a/experimental/puppeteer-firefox/lib/firefox/Page.js +++ b/experimental/puppeteer-firefox/lib/firefox/Page.js @@ -780,6 +780,19 @@ function getScreenshotMimeType(options) { } class ElementHandle extends JSHandle { + /** + * @return {?Frame} + */ + async contentFrame() { + const {frameId} = await this._session.send('Page.contentFrame', { + frameId: this._frameId, + objectId: this._objectId, + }); + if (!frameId) + return null; + const frame = this._frame._page._frames.get(frameId); + return frame; + } /** * @override diff --git a/experimental/puppeteer-firefox/package.json b/experimental/puppeteer-firefox/package.json index 9af6559c..0a990a98 100644 --- a/experimental/puppeteer-firefox/package.json +++ b/experimental/puppeteer-firefox/package.json @@ -8,7 +8,7 @@ "node": ">=8.9.4" }, "puppeteer": { - "firefox_revision": "ca4758c475a9c05dc88b7b8811fbbb7e5acf95b4" + "firefox_revision": "d026cf7a14cb7dbe65acc4a4188c570da10a501c" }, "scripts": { "install": "node install.js", diff --git a/test/elementhandle.spec.js b/test/elementhandle.spec.js index 910bff55..d92d6df0 100644 --- a/test/elementhandle.spec.js +++ b/test/elementhandle.spec.js @@ -132,7 +132,7 @@ module.exports.addTests = function({testRunner, expect}) { describe('ElementHandle.contentFrame', function() { it('should work', async({page,server}) => { await page.goto(server.EMPTY_PAGE); - await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); + await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE2); const elementHandle = await page.$('#frame1'); const frame = await elementHandle.contentFrame(); expect(frame).toBe(page.frames()[1]);