diff --git a/experimental/puppeteer-firefox/lib/NetworkManager.js b/experimental/puppeteer-firefox/lib/NetworkManager.js index df134e9c654..19997545646 100644 --- a/experimental/puppeteer-firefox/lib/NetworkManager.js +++ b/experimental/puppeteer-firefox/lib/NetworkManager.js @@ -27,6 +27,15 @@ class NetworkManager extends EventEmitter { this._frameManager = frameManager; } + async setExtraHTTPHeaders(headers) { + const array = []; + for (const [name, value] of Object.entries(headers)) { + assert(helper.isString(value), `Expected value of header "${name}" to be String, but "${typeof value}" is found.`); + array.push({name, value}); + } + await this._session.send('Network.setExtraHTTPHeaders', {headers: array}); + } + async setRequestInterception(enabled) { await this._session.send('Network.setRequestInterception', {enabled}); } diff --git a/experimental/puppeteer-firefox/lib/Page.js b/experimental/puppeteer-firefox/lib/Page.js index 1e7e1665c53..8bcd4009810 100644 --- a/experimental/puppeteer-firefox/lib/Page.js +++ b/experimental/puppeteer-firefox/lib/Page.js @@ -77,6 +77,10 @@ class Page extends EventEmitter { await this._networkManager.setRequestInterception(enabled); } + async setExtraHTTPHeaders(headers) { + await this._networkManager.setExtraHTTPHeaders(headers); + } + /** * @param {(string|Function)} urlOrPredicate * @param {!{timeout?: number}=} options diff --git a/experimental/puppeteer-firefox/package.json b/experimental/puppeteer-firefox/package.json index 745f28a2a31..0dd0e9749b1 100644 --- a/experimental/puppeteer-firefox/package.json +++ b/experimental/puppeteer-firefox/package.json @@ -9,7 +9,7 @@ "node": ">=8.9.4" }, "puppeteer": { - "firefox_revision": "98116977b3f0c936c92e917bdd571c340167a536" + "firefox_revision": "e78e4cefab9d40e70bb80b3e649dcba7a7c8ee8f" }, "scripts": { "install": "node install.js", diff --git a/test/network.spec.js b/test/network.spec.js index 0753cd7b3a2..d024d3ce4b7 100644 --- a/test/network.spec.js +++ b/test/network.spec.js @@ -429,7 +429,7 @@ module.exports.addTests = function({testRunner, expect, CHROME}) { await page.setRequestInterception(false); await page.goto(server.EMPTY_PAGE); }); - it_fails_ffox('should show custom HTTP headers', async({page, server}) => { + it('should show custom HTTP headers', async({page, server}) => { await page.setExtraHTTPHeaders({ foo: 'bar' }); @@ -441,7 +441,7 @@ module.exports.addTests = function({testRunner, expect, CHROME}) { const response = await page.goto(server.EMPTY_PAGE); expect(response.ok()).toBe(true); }); - it_fails_ffox('should works with customizing referer headers', async({page, server}) => { + it('should works with customizing referer headers', async({page, server}) => { await page.setExtraHTTPHeaders({ 'referer': server.EMPTY_PAGE }); await page.setRequestInterception(true); page.on('request', request => { @@ -477,7 +477,7 @@ module.exports.addTests = function({testRunner, expect, CHROME}) { expect(failedRequest).toBeTruthy(); expect(failedRequest.failure().errorText).toBe('net::ERR_INTERNET_DISCONNECTED'); }); - it_fails_ffox('should send referer', async({page, server}) => { + it('should send referer', async({page, server}) => { await page.setExtraHTTPHeaders({ referer: 'http://google.com/' }); @@ -744,7 +744,7 @@ module.exports.addTests = function({testRunner, expect, CHROME}) { }); }); - describe_fails_ffox('Page.setExtraHTTPHeaders', function() { + describe('Page.setExtraHTTPHeaders', function() { it('should work', async({page, server}) => { await page.setExtraHTTPHeaders({ foo: 'bar'