From ff46d8ce8a72b8b60968c32c07b35974a9b3beee Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 23 Aug 2022 08:28:35 -0700 Subject: [PATCH] test: postBody content-type is inherited from original request (#16738) --- tests/page/page-request-continue.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/page/page-request-continue.spec.ts b/tests/page/page-request-continue.spec.ts index d4cc4a6e9a..3373ea2551 100644 --- a/tests/page/page-request-continue.spec.ts +++ b/tests/page/page-request-continue.spec.ts @@ -246,6 +246,25 @@ it.describe('post data', () => { for (let i = 0; i < arr.length; ++i) expect(arr[i]).toBe(buffer[i]); }); + + it('should use content-type from original request', async ({ page, server, browserName }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/16736' }); + it.fixme(browserName === 'firefox'); + await page.goto(server.EMPTY_PAGE); + await page.route(`${server.PREFIX}/title.html`, route => route.continue({ postData: '{"b":2}' })); + const [request] = await Promise.all([ + server.waitForRequest('/title.html'), + page.evaluate(async url => { + await fetch(url, { + method: 'POST', + body: '{"a":1}', + headers: { 'content-type': 'application/json' }, + }); + }, `${server.PREFIX}/title.html`) + ]); + expect(request.headers['content-type']).toBe('application/json'); + expect((await request.postBody).toString('utf-8')).toBe('{"b":2}'); + }); }); it('should work with Cross-Origin-Opener-Policy', async ({ page, server, browserName }) => {