diff --git a/experimental/puppeteer-firefox/lib/JSHandle.js b/experimental/puppeteer-firefox/lib/JSHandle.js index a0aa95ff27cdd..c665724ff6170 100644 --- a/experimental/puppeteer-firefox/lib/JSHandle.js +++ b/experimental/puppeteer-firefox/lib/JSHandle.js @@ -1,4 +1,5 @@ const {assert, debugError} = require('./helper'); +const path = require('path'); class JSHandle { @@ -327,6 +328,18 @@ class ElementHandle extends JSHandle { await this._frame._page.mouse.click(x, y, options); } + /** + * @param {!Array} filePaths + */ + async uploadFile(...filePaths) { + const files = filePaths.map(filePath => path.resolve(filePath)); + await this._session.send('Page.setFileInputFiles', { + frameId: this._frameId, + objectId: this._objectId, + files, + }); + } + async hover() { await this._scrollIntoViewIfNeeded(); const {x, y} = await this._clickablePoint(); diff --git a/experimental/puppeteer-firefox/misc/puppeteer.cfg b/experimental/puppeteer-firefox/misc/puppeteer.cfg index 24527c689a16f..d902041c44598 100644 --- a/experimental/puppeteer-firefox/misc/puppeteer.cfg +++ b/experimental/puppeteer-firefox/misc/puppeteer.cfg @@ -26,6 +26,10 @@ pref("browser.newtabpage.activity-stream.feeds.section.topstories", false); // (bug 1176798, bug 1177018, bug 1210465) pref("apz.content_response_timeout", 60000); +// Allow creating files in content process - required for +// |Page.setFileInputFiles| protocol method. +pref("dom.file.createInChild", true); + // Indicate that the download panel has been shown once so that // whichever download test runs first doesn't show the popup // inconsistently. diff --git a/experimental/puppeteer-firefox/package.json b/experimental/puppeteer-firefox/package.json index 08a899694c0d8..d75438e567fdf 100644 --- a/experimental/puppeteer-firefox/package.json +++ b/experimental/puppeteer-firefox/package.json @@ -9,7 +9,7 @@ "node": ">=8.9.4" }, "puppeteer": { - "firefox_revision": "86e93329fd528bd28ff1493f117f126b6f010eac" + "firefox_revision": "e0433ecec0642eca12cba778b0587ab2ae06e833" }, "scripts": { "install": "node install.js", diff --git a/test/input.spec.js b/test/input.spec.js index a27236a62627b..503c25517c813 100644 --- a/test/input.spec.js +++ b/test/input.spec.js @@ -21,7 +21,7 @@ module.exports.addTests = function({testRunner, expect}) { const {it, fit, xit, it_fails_ffox} = testRunner; const {beforeAll, beforeEach, afterAll, afterEach} = testRunner; describe('input', function() { - it_fails_ffox('should upload the file', async({page, server}) => { + it('should upload the file', async({page, server}) => { await page.goto(server.PREFIX + '/input/fileupload.html'); const filePath = path.relative(process.cwd(), __dirname + '/assets/file-to-upload.txt'); const input = await page.$('input');