Remove redundant methods from Body class

This patch:
- removes Body.arrayBuffer. This method is redundant since there's
  already a Body.buffer() method
- removes Body.bodyUsed getter.

References #106
This commit is contained in:
Andrey Lushnikov 2017-07-27 14:42:31 -07:00
parent 847504c53e
commit c26d2c8271
3 changed files with 1 additions and 29 deletions

View File

@ -112,8 +112,6 @@
+ [interceptedRequest.postData](#interceptedrequestpostdata)
+ [interceptedRequest.url](#interceptedrequesturl)
* [class: Body](#class-body)
+ [body.arrayBuffer()](#bodyarraybuffer)
+ [body.bodyUsed](#bodybodyused)
+ [body.buffer()](#bodybuffer)
+ [body.json()](#bodyjson)
+ [body.text()](#bodytext)
@ -1031,12 +1029,6 @@ Contains `POST` data for `POST` requests.
If changed, the request url will be modified in a way that's not observable by page. Must not be changed in response to an authChallenge.
### class: Body
#### body.arrayBuffer()
- returns: <Promise<[ArrayBuffer]>>
#### body.bodyUsed
- returns: <[boolean]>
#### body.buffer()
- returns: <Promise<[Buffer]>>
@ -1048,7 +1040,6 @@ If changed, the request url will be modified in a way that's not observable by p
- returns: <Promise<[text]>>
[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array"
[ArrayBuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer "ArrayBuffer"
[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean"
[Buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer "Buffer"
[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function "Function"
@ -1070,4 +1061,4 @@ If changed, the request url will be modified in a way that's not observable by p
[Dialog]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-dialog "Dialog"
[Mouse]: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-mouse "Mouse"
[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map"
[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"
[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"

View File

@ -156,13 +156,6 @@ class Body {
return this._contentPromise;
}
/**
* @return {boolean}
*/
get bodyUsed() {
return !!this._contentPromise;
}
/**
* @return {!Promise<string>}
*/
@ -178,14 +171,6 @@ class Body {
let content = await this.text();
return JSON.parse(content);
}
/**
* @return {!Promise<!ArrayBuffer>}
*/
async arrayBuffer() {
let content = await this.buffer();
return content.buffer;
}
}
helper.tracePublicAPI(Body);

View File

@ -1071,10 +1071,8 @@ describe('Puppeteer', function() {
page.on('request', r => request = r);
await page.evaluate(() => fetch('./post', { method: 'POST', body: JSON.stringify({foo: 'bar'})}));
expect(request).toBeTruthy();
expect(request.bodyUsed).toBe(false);
expect(await request.text()).toBe('{"foo":"bar"}');
expect(await request.json()).toEqual({foo: 'bar'});
expect(request.bodyUsed).toBe(true);
}));
});
describe('Response implements Body', function() {
@ -1083,10 +1081,8 @@ describe('Puppeteer', function() {
page.on('response', r => response = r);
await page.navigate(PREFIX + '/simple.json');
expect(response).toBeTruthy();
expect(response.bodyUsed).toBe(false);
expect(await response.text()).toBe('{"foo": "bar"}\n');
expect(await response.json()).toEqual({foo: 'bar'});
expect(response.bodyUsed).toBe(true);
}));
});
describe('Network Events', function() {