feat(firefox): support page.setExtraHTTPHeaders (#4035)
This commit is contained in:
parent
c118b208fa
commit
719ee5af3d
@ -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});
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -9,7 +9,7 @@
|
||||
"node": ">=8.9.4"
|
||||
},
|
||||
"puppeteer": {
|
||||
"firefox_revision": "98116977b3f0c936c92e917bdd571c340167a536"
|
||||
"firefox_revision": "e78e4cefab9d40e70bb80b3e649dcba7a7c8ee8f"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "node install.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'
|
||||
|
Loading…
Reference in New Issue
Block a user