Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add test for issue #39160 (#40628)

Andrey Lushnikov70e061e07a53
diff --git a/tests/page/page-network-response.spec.ts b/tests/page/page-network-response.spec.ts
index 66b3c5effb..a6057ba481 100644
--- a/tests/page/page-network-response.spec.ts
+++ b/tests/page/page-network-response.spec.ts
@@ -17,6 +17,7 @@
import fs from 'fs';
import url from 'url';
+import zlib from 'zlib';
import { expect, test as it } from './pageTest';
it('should work @smoke', async ({ page, server }) => {
@@ -63,6 +64,22 @@ it('should return uncompressed text', async ({ page, server }) => {
expect(await response.text()).toBe('{"foo": "bar"}\n');
});
+it('should return uncompressed text for brotli encoding', async ({ page, server, browserName }) => {
+ it.fixme(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/39160');
+ const text = '{"foo": "bar"}\n';
+ const compressed = zlib.brotliCompressSync(Buffer.from(text));
+ server.setRoute('/brotli.json', (req, res) => {
+ res.writeHead(200, {
+ 'Content-Type': 'application/json',
+ 'Content-Encoding': 'br',
+ });
+ res.end(compressed);
+ });
+ const response = await page.goto(server.PREFIX + '/brotli.json');
+ expect(response.headers()['content-encoding']).toBe('br');
+ expect(await response.text()).toBe(text);
+});
+
it('should throw when requesting body of redirected response', async ({ page, server }) => {
server.setRedirect('/foo.html', '/empty.html');
const response = await page.goto(server.PREFIX + '/foo.html');