feat(firefox): support ElementHandle.contentFrame() (#3917)

This commit is contained in:
Andrey Lushnikov 2019-02-05 13:29:49 -08:00 committed by GitHub
parent dd8bd6dcb1
commit 28087c291f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -780,6 +780,19 @@ function getScreenshotMimeType(options) {
} }
class ElementHandle extends JSHandle { 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 * @override

View File

@ -8,7 +8,7 @@
"node": ">=8.9.4" "node": ">=8.9.4"
}, },
"puppeteer": { "puppeteer": {
"firefox_revision": "ca4758c475a9c05dc88b7b8811fbbb7e5acf95b4" "firefox_revision": "d026cf7a14cb7dbe65acc4a4188c570da10a501c"
}, },
"scripts": { "scripts": {
"install": "node install.js", "install": "node install.js",

View File

@ -132,7 +132,7 @@ module.exports.addTests = function({testRunner, expect}) {
describe('ElementHandle.contentFrame', function() { describe('ElementHandle.contentFrame', function() {
it('should work', async({page,server}) => { it('should work', async({page,server}) => {
await page.goto(server.EMPTY_PAGE); 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 elementHandle = await page.$('#frame1');
const frame = await elementHandle.contentFrame(); const frame = await elementHandle.contentFrame();
expect(frame).toBe(page.frames()[1]); expect(frame).toBe(page.frames()[1]);