test: cannot override cookie header in continue (#16774)

Repro for #16773.
This commit is contained in:
Ross Wollman 2022-08-23 14:06:25 -07:00 committed by GitHub
parent aa23914659
commit f91e41ef40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,6 +140,28 @@ it('should properly return navigation response when URL has cookies', async ({ p
expect(response.status()).toBe(200);
});
it('should override cookie header', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/16773' });
it.fail(browserName !== 'firefox');
await page.goto(server.EMPTY_PAGE);
await page.evaluate(() => document.cookie = 'original=value');
let cookieValueInRoute;
await page.route('**', async route => {
const headers = await route.request().allHeaders();
cookieValueInRoute = headers['cookie'];
headers['cookie'] = 'overridden=value';
route.continue({ headers });
});
const [serverReq] = await Promise.all([
server.waitForRequest('/empty.html'),
page.goto(server.EMPTY_PAGE),
]);
expect(cookieValueInRoute).toBe('original=value');
expect(serverReq.headers['cookie']).toBe('overridden=value');
});
it('should show custom HTTP headers', async ({ page, server }) => {
await page.setExtraHTTPHeaders({
foo: 'bar'