Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: adjust headers expectations for firefox-beta (#30520)
Dmitry Gozman6fecf5201674
diff --git a/tests/page/page-network-request.spec.ts b/tests/page/page-network-request.spec.tsindex 624e36abfd..d3679ed14a 100644--- a/tests/page/page-network-request.spec.ts+++ b/tests/page/page-network-request.spec.ts@@ -19,6 +19,14 @@ import { test as it, expect } from './pageTest';import { attachFrame } from '../config/utils';import fs from 'fs';+function adjustServerHeaders(headers: Object, browserName: string, channel: string) {+ if (browserName === 'firefox' && channel === 'firefox-beta') {+ // This is a new experimental feature, only enabled in Firefox Beta for now.+ delete headers['priority'];+ }+ return headers;+}+it('should work for main frame navigation request', async ({ page, server }) => {const requests = [];page.on('request', request => requests.push(request));@@ -82,7 +90,7 @@ it('should return headers', async ({ page, server, browserName }) => {expect(response.request().headers()['user-agent']).toContain('WebKit');});-it('should get the same headers as the server', async ({ page, server, browserName, platform, isElectron, browserMajorVersion }) => {+it('should get the same headers as the server', async ({ page, server, browserName, platform, isElectron, browserMajorVersion, channel }) => {it.skip(isElectron && browserMajorVersion < 99, 'This needs Chromium >= 99');it.fail(browserName === 'webkit' && platform === 'win32', 'Curl does not show accept-encoding and accept-language');let serverRequest;@@ -92,10 +100,10 @@ it('should get the same headers as the server', async ({ page, server, browserNa});const response = await page.goto(server.PREFIX + '/empty.html');const headers = await response.request().allHeaders();- expect(headers).toEqual(serverRequest.headers);+ expect(headers).toEqual(adjustServerHeaders(serverRequest.headers, browserName, channel));});-it('should not return allHeaders() until they are available', async ({ page, server, browserName, platform, isElectron, browserMajorVersion }) => {+it('should not return allHeaders() until they are available', async ({ page, server, browserName, platform, isElectron, browserMajorVersion, channel }) => {it.skip(isElectron && browserMajorVersion < 99, 'This needs Chromium >= 99');it.fail(browserName === 'webkit' && platform === 'win32', 'Curl does not show accept-encoding and accept-language');@@ -114,13 +122,13 @@ it('should not return allHeaders() until they are available', async ({ page, serawait page.goto(server.PREFIX + '/empty.html');const requestHeaders = await requestHeadersPromise;- expect(requestHeaders).toEqual(serverRequest.headers);+ expect(requestHeaders).toEqual(adjustServerHeaders(serverRequest.headers, browserName, channel));const responseHeaders = await responseHeadersPromise;expect(responseHeaders['foo']).toBe('bar');});-it('should get the same headers as the server CORS', async ({ page, server, browserName, platform, isElectron, browserMajorVersion }) => {+it('should get the same headers as the server CORS', async ({ page, server, browserName, platform, isElectron, browserMajorVersion, channel }) => {it.skip(isElectron && browserMajorVersion < 99, 'This needs Chromium >= 99');it.fail(browserName === 'webkit' && platform === 'win32', 'Curl does not show accept-encoding and accept-language');@@ -139,7 +147,7 @@ it('should get the same headers as the server CORS', async ({ page, server, browexpect(text).toBe('done');const response = await responsePromise;const headers = await response.request().allHeaders();- expect(headers).toEqual(serverRequest.headers);+ expect(headers).toEqual(adjustServerHeaders(serverRequest.headers, browserName, channel));});it('should not get preflight CORS requests when intercepting', async ({ page, server, browserName, isAndroid }) => {@@ -353,7 +361,7 @@ it('should return navigation bit when navigating to image', async ({ page, serveexpect(requests[0].isNavigationRequest()).toBe(true);});-it('should report raw headers', async ({ page, server, browserName, platform, isElectron, browserMajorVersion }) => {+it('should report raw headers', async ({ page, server, browserName, platform, isElectron, browserMajorVersion, channel }) => {it.skip(isElectron && browserMajorVersion < 99, 'This needs Chromium >= 99');let expectedHeaders: { name: string, value: string }[];@@ -376,6 +384,10 @@ it('should report raw headers', async ({ page, server, browserName, platform, isreturn { name, value: values[0] };});}+ if (browserName === 'firefox' && channel === 'firefox-beta') {+ // This is a new experimental feature, only enabled in Firefox Beta for now.+ expectedHeaders = expectedHeaders.filter(({ name }) => name.toLowerCase() !== 'priority');+ }res.end();});await page.goto(server.EMPTY_PAGE);