From c8e8d8f8bb3a00bd9fa727e10cbab72fc41d5617 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 22 Mar 2024 13:32:28 -0700 Subject: [PATCH] test: fulfilling with gzip should allow to read the body (#30065) Fixes #29261. --- tests/page/page-request-fulfill.spec.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/page/page-request-fulfill.spec.ts b/tests/page/page-request-fulfill.spec.ts index c76fbd2ab7..9a568e8369 100644 --- a/tests/page/page-request-fulfill.spec.ts +++ b/tests/page/page-request-fulfill.spec.ts @@ -438,3 +438,19 @@ it('should fulfill json', async ({ page, server }) => { expect(response.headers()['content-type']).toBe('application/json'); expect(body).toBe(JSON.stringify({ bar: 'baz' })); }); + +it('should fulfill with gzip and readback', { + annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/29261' }, +}, async ({ page, server }) => { + server.enableGzip('/one-style.html'); + await page.route('**/one-style.html', async route => { + const response = await route.fetch(); + expect(response.headers()['content-encoding']).toBe('gzip'); + await route.fulfill({ response }); + }); + + const response = await page.goto(server.PREFIX + '/one-style.html'); + await expect(page.locator('div')).toHaveText('hello, world!'); + await expect(page.locator('body')).toHaveCSS('background-color', 'rgb(255, 192, 203)'); + expect(await response.text()).toContain(`
hello, world!
`); +});