Remove page.httpHeaders() getter

Remove the page.httpHeaders() method since it always returns the last
value of page.setHTTPHeaders().

References #115.
This commit is contained in:
Andrey Lushnikov 2017-07-24 23:35:10 -07:00
parent 5549ad0282
commit efa33c37b3
4 changed files with 3 additions and 14 deletions

View File

@ -38,7 +38,6 @@
+ [page.goBack(options)](#pagegobackoptions)
+ [page.goForward(options)](#pagegoforwardoptions)
+ [page.hover(selector)](#pagehoverselector)
+ [page.httpHeaders()](#pagehttpheaders)
+ [page.injectFile(filePath)](#pageinjectfilefilepath)
+ [page.keyboard](#pagekeyboard)
+ [page.mainFrame()](#pagemainframe)
@ -408,9 +407,6 @@ Navigate to the next page in history.
- `selector` <[string]> A query selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered.
- returns: <[Promise]> Promise which resolves when the element matching `selector` is successfully hovered. Promise gets rejected if there's no element matching `selector`.
#### page.httpHeaders()
- returns: <[Object]> Key-value set of additional http headers which will be sent with every request.
#### page.injectFile(filePath)
- `filePath` <[string]> Path to the javascript file to be injected into page.
- returns: <[Promise]> Promise which resolves when file gets successfully evaluated in page.

View File

@ -189,13 +189,6 @@ class Page extends EventEmitter {
return this._networkManager.setHTTPHeaders(headers);
}
/**
* @return {!Object}
*/
httpHeaders() {
return this._networkManager.httpHeaders();
}
/**
* @param {string} userAgent
* @return {!Promise}

View File

@ -48,6 +48,7 @@ class WebPage {
this.onResourceReceived = null;
this._onInitialized = undefined;
this._deferEvaluate = false;
this._customHeaders = {};
this._currentFrame = this._page.mainFrame();
@ -275,13 +276,14 @@ class WebPage {
* @return {!Object}
*/
get customHeaders() {
return this._page.httpHeaders();
return this._customHeaders;
}
/**
* @param {!Object} value
*/
set customHeaders(value) {
this._customHeaders = value;
await(this._page.setHTTPHeaders(value));
}

View File

@ -1003,9 +1003,7 @@ describe('Puppeteer', function() {
});
describe('Page.setHTTPHeaders', function() {
it('should work', SX(async function() {
expect(page.httpHeaders()).toEqual({});
page.setHTTPHeaders({'foo': 'bar'});
expect(page.httpHeaders()).toEqual({'foo': 'bar'});
page.navigate(EMPTY_PAGE);
let request = await server.waitForRequest('/empty.html');
expect(request.headers['foo']).toBe('bar');