Skip to content

Commit

Permalink
feat(firefox): support ElementHandle.contentFrame() (#3917)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Feb 5, 2019
1 parent dd8bd6d commit 28087c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions experimental/puppeteer-firefox/lib/firefox/Page.js
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion experimental/puppeteer-firefox/package.json
Expand Up @@ -8,7 +8,7 @@
"node": ">=8.9.4"
},
"puppeteer": {
"firefox_revision": "ca4758c475a9c05dc88b7b8811fbbb7e5acf95b4"
"firefox_revision": "d026cf7a14cb7dbe65acc4a4188c570da10a501c"
},
"scripts": {
"install": "node install.js",
Expand Down
2 changes: 1 addition & 1 deletion test/elementhandle.spec.js
Expand Up @@ -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]);
Expand Down

0 comments on commit 28087c2

Please sign in to comment.