@@ -214,7 +214,7 @@ it('should return postData', async ({ page, server }) => {
214214 page . on ( 'request' , r => request = r ) ;
215215 await page . evaluate ( ( ) => fetch ( './post' , { method : 'POST' , body : JSON . stringify ( { foo : 'bar' } ) } ) ) ;
216216 expect ( 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 }) => {
226226 await fetch ( './post' , { method : 'POST' , body : new Uint8Array ( Array . from ( Array ( 256 ) . keys ( ) ) ) } ) ;
227227 } ) ;
228228 expect ( request ) . toBeTruthy ( ) ;
229- const buffer = request . postDataBuffer ( ) ;
229+ const buffer = await request . bodyBuffer ( ) ;
230230 expect ( buffer . length ) . toBe ( 256 ) ;
231231 for ( let i = 0 ; i < 256 ; ++ i )
232232 expect ( buffer [ i ] ) . toBe ( i ) ;
@@ -242,7 +242,7 @@ it('should work with binary post data and interception', async ({ page, server }
242242 await fetch ( './post' , { method : 'POST' , body : new Uint8Array ( Array . from ( Array ( 256 ) . keys ( ) ) ) } ) ;
243243 } ) ;
244244 expect ( request ) . toBeTruthy ( ) ;
245- const buffer = request . postDataBuffer ( ) ;
245+ const buffer = await request . bodyBuffer ( ) ;
246246 expect ( buffer . length ) . toBe ( 256 ) ;
247247 for ( let i = 0 ; i < 256 ; ++ i )
248248 expect ( buffer [ i ] ) . toBe ( i ) ;
@@ -255,12 +255,12 @@ it('should override post data content type', async ({ page, server }) => {
255255 request = req ;
256256 res . end ( ) ;
257257 } ) ;
258- await page . route ( '**/post' , ( route , request ) => {
258+ await page . route ( '**/post' , async ( route , request ) => {
259259 const headers = request . headers ( ) ;
260260 headers [ 'content-type' ] = 'application/x-www-form-urlencoded; charset=UTF-8' ;
261261 void route . continue ( {
262262 headers,
263- postData : request . postData ( )
263+ postData : await request . body ( )
264264 } ) ;
265265 } ) ;
266266 await page . evaluate ( async ( ) => {
@@ -270,9 +270,9 @@ it('should override post data content type', async ({ page, server }) => {
270270 expect ( request . headers [ 'content-type' ] ) . toBe ( 'application/x-www-form-urlencoded; charset=UTF-8' ) ;
271271} ) ;
272272
273- it ( 'should get |undefined| with postData () when there is no post data' , async ( { page, server } ) => {
273+ it ( 'should get |undefined| with body () when there is no post data' , async ( { page, server } ) => {
274274 const 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 }) => {
282282 page . on ( 'request' , r => request = r ) ;
283283 await page . evaluate ( ( ) => fetch ( './post' , { method : 'POST' , body : JSON . stringify ( { foo : 'bar' } ) } ) ) ;
284284 expect ( 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',
293293 await 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>` ) ;
294294 await page . click ( 'input[type=submit]' ) ;
295295 expect ( 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 } ,
308308 body : '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| with postDataJSON () when there is no post data' , async ( { page, server } ) => {
313+ it ( 'should get |undefined| with bodyJSON () when there is no post data' , async ( { page, server } ) => {
314314 const 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
337337 expect ( contentType ) . toMatch ( re ) ;
338338 const b = contentType . match ( re ) [ 1 ] ! ;
339339 const 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 } ) => {
0 commit comments