@@ -214,7 +214,7 @@ it('should return postData', async ({ page, server }) => {
214214page . on ( 'request' , r => request = r ) ;
215215await page . evaluate ( ( ) => fetch ( './post' , { method :'POST' , body :JSON . stringify ( { foo :'bar' } ) } ) ) ;
216216expect ( request ) . toBeTruthy ( ) ;
217- expect ( request . postData ( ) ) . toBe ( '{"foo":"bar"}' ) ;
217+ expect ( await request . body ( ) ) . toBe ( '{"foo":"bar"}' ) ;
218218} ) ;
219219
220220it ( 'should work with binary post data' , async ( { page, server} ) => {
@@ -226,7 +226,7 @@ it('should work with binary post data', async ({ page, server }) => {
226226await fetch ( './post' , { method :'POST' , body :new Uint8Array ( Array . from ( Array ( 256 ) . keys ( ) ) ) } ) ;
227227} ) ;
228228expect ( request ) . toBeTruthy ( ) ;
229- const buffer = request . postDataBuffer ( ) ;
229+ const buffer = await request . bodyBuffer ( ) ;
230230expect ( buffer . length ) . toBe ( 256 ) ;
231231for ( let i = 0 ; i < 256 ; ++ i )
232232expect ( buffer [ i ] ) . toBe ( i ) ;
@@ -242,7 +242,7 @@ it('should work with binary post data and interception', async ({ page, server }
242242await fetch ( './post' , { method :'POST' , body :new Uint8Array ( Array . from ( Array ( 256 ) . keys ( ) ) ) } ) ;
243243} ) ;
244244expect ( request ) . toBeTruthy ( ) ;
245- const buffer = request . postDataBuffer ( ) ;
245+ const buffer = await request . bodyBuffer ( ) ;
246246expect ( buffer . length ) . toBe ( 256 ) ;
247247for ( let i = 0 ; i < 256 ; ++ i )
248248expect ( buffer [ i ] ) . toBe ( i ) ;
@@ -255,12 +255,12 @@ it('should override post data content type', async ({ page, server }) => {
255255request = req ;
256256res . end ( ) ;
257257} ) ;
258- await page . route ( '**/post' , ( route , request ) => {
258+ await page . route ( '**/post' , async ( route , request ) => {
259259const headers = request . headers ( ) ;
260260headers [ 'content-type' ] = 'application/x-www-form-urlencoded; charset=UTF-8' ;
261261void route . continue ( {
262262 headers,
263- postData :request . postData ( )
263+ postData :await request . body ( )
264264} ) ;
265265} ) ;
266266await page . evaluate ( async ( ) => {
@@ -270,9 +270,9 @@ it('should override post data content type', async ({ page, server }) => {
270270expect ( request . headers [ 'content-type' ] ) . toBe ( 'application/x-www-form-urlencoded; charset=UTF-8' ) ;
271271} ) ;
272272
273- it ( 'should get |undefined| withpostData () when there is no post data' , async ( { page, server} ) => {
273+ it ( 'should get |undefined| withbody () when there is no post data' , async ( { page, server} ) => {
274274const response = await page . goto ( server . EMPTY_PAGE ) ;
275- expect ( response . request ( ) . postData ( ) ) . toBe ( null ) ;
275+ expect ( await response . request ( ) . body ( ) ) . toBe ( null ) ;
276276} ) ;
277277
278278it ( 'should parse the json post data' , async ( { page, server} ) => {
@@ -282,7 +282,7 @@ it('should parse the json post data', async ({ page, server }) => {
282282page . on ( 'request' , r => request = r ) ;
283283await page . evaluate ( ( ) => fetch ( './post' , { method :'POST' , body :JSON . stringify ( { foo :'bar' } ) } ) ) ;
284284expect ( request ) . toBeTruthy ( ) ;
285- expect ( request . postDataJSON ( ) ) . toEqual ( { 'foo' :'bar' } ) ;
285+ expect ( await request . bodyJSON ( ) ) . toEqual ( { 'foo' :'bar' } ) ;
286286} ) ;
287287
288288it ( 'should parse the data if content-type is application/x-www-form-urlencoded' , async ( { page, server} ) => {
@@ -293,7 +293,7 @@ it('should parse the data if content-type is application/x-www-form-urlencoded',
293293await page . setContent ( `<form method='POST' action='/post'><input type='text' name='foo' value='bar'><input type='number' name='baz' value='123'><input type='submit'></form>` ) ;
294294await page . click ( 'input[type=submit]' ) ;
295295expect ( request ) . toBeTruthy ( ) ;
296- expect ( request . postDataJSON ( ) ) . toEqual ( { 'foo' :'bar' , 'baz' :'123' } ) ;
296+ expect ( await request . bodyJSON ( ) ) . toEqual ( { 'foo' :'bar' , 'baz' :'123' } ) ;
297297} ) ;
298298
299299it ( 'should parse the data if content-type is application/x-www-form-urlencoded; charset=UTF-8' , async ( { page, server} ) => {
@@ -307,12 +307,12 @@ it('should parse the data if content-type is application/x-www-form-urlencoded;
307307} ,
308308body :'foo=bar&baz=123'
309309} ) ) ;
310- expect ( ( await requestPromise ) . postDataJSON ( ) ) . toEqual ( { 'foo' :'bar' , 'baz' :'123' } ) ;
310+ expect ( await ( await requestPromise ) . bodyJSON ( ) ) . toEqual ( { 'foo' :'bar' , 'baz' :'123' } ) ;
311311} ) ;
312312
313- it ( 'should get |undefined| withpostDataJSON () when there is no post data' , async ( { page, server} ) => {
313+ it ( 'should get |undefined| withbodyJSON () when there is no post data' , async ( { page, server} ) => {
314314const response = await page . goto ( server . EMPTY_PAGE ) ;
315- expect ( response . request ( ) . postDataJSON ( ) ) . toBe ( null ) ;
315+ expect ( await response . request ( ) . bodyJSON ( ) ) . toBe ( null ) ;
316316} ) ;
317317
318318it ( 'should return multipart/form-data' , async ( { page, server, browserName, browserMajorVersion} ) => {
@@ -337,7 +337,7 @@ it('should return multipart/form-data', async ({ page, server, browserName, brow
337337expect ( contentType ) . toMatch ( re ) ;
338338const b = contentType . match ( re ) [ 1 ] ! ;
339339const expected = `--${ b } \r\nContent-Disposition: form-data; name=\"name1\"\r\n\r\nvalue1\r\n--${ b } \r\nContent-Disposition: form-data; name=\"file\"; filename=\"foo.txt\"\r\nContent-Type: application/octet-stream\r\n\r\nfile-value\r\n--${ b } \r\nContent-Disposition: form-data; name=\"name2\"\r\n\r\nvalue2\r\n--${ b } \r\nContent-Disposition: form-data; name=\"name2\"\r\n\r\nanother-value2\r\n--${ b } --\r\n` ;
340- expect ( request . postDataBuffer ( ) . toString ( 'utf8' ) ) . toEqual ( expected ) ;
340+ expect ( ( await request . bodyBuffer ( ) ) . toString ( 'utf8' ) ) . toEqual ( expected ) ;
341341} ) ;
342342
343343it ( 'should return event source' , async ( { page, server} ) => {