Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(firefox): support page.setExtraHTTPHeaders #4035

Merged
merged 1 commit into from Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions experimental/puppeteer-firefox/lib/NetworkManager.js
Expand Up @@ -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});
}
Expand Down
4 changes: 4 additions & 0 deletions experimental/puppeteer-firefox/lib/Page.js
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion experimental/puppeteer-firefox/package.json
Expand Up @@ -9,7 +9,7 @@
"node": ">=8.9.4"
},
"puppeteer": {
"firefox_revision": "98116977b3f0c936c92e917bdd571c340167a536"
"firefox_revision": "e78e4cefab9d40e70bb80b3e649dcba7a7c8ee8f"
},
"scripts": {
"install": "node install.js",
Expand Down
8 changes: 4 additions & 4 deletions test/network.spec.js
Expand Up @@ -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'
});
Expand All @@ -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 => {
Expand Down Expand Up @@ -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/'
});
Expand Down Expand Up @@ -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'
Expand Down