Skip to content

Commit 80df3f5

Browse files
committed
do not preserve original cookie, mark some tests as failing in FF
1 parent 46ab37a commit 80df3f5

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

packages/playwright-core/src/server/chromium/crNetworkManager.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ export class CRNetworkManager {
339339
// We do not support intercepting redirects.
340340
if (redirectedFrom || (!this._userRequestInterceptionEnabled && this._protocolRequestInterceptionEnabled)) {
341341
// Chromium does not preserve header overrides between redirects, so we have to do it ourselves.
342-
headersOverride = redirectedFrom?._originalRequestRoute?._alreadyContinuedParams?.headers?.
343-
filter(header => header.name.toLowerCase() !== 'cookie');
342+
headersOverride = redirectedFrom?._originalRequestRoute?._alreadyContinuedParams?.headers;
344343
requestPausedSessionInfo!.session._sendMayFail('Fetch.continueRequest', { requestId: requestPausedEvent.requestId, headers: headersOverride });
345344
} else {
346345
route = new RouteImpl(requestPausedSessionInfo!.session, requestPausedEvent.requestId);

packages/playwright-core/src/server/network.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,8 @@ export class Route extends SdkObject {
329329
if (oldUrl.protocol !== newUrl.protocol)
330330
throw new Error('New URL must have same protocol as overridden URL');
331331
}
332-
if (overrides.headers) {
332+
if (overrides.headers)
333333
overrides.headers = overrides.headers?.filter(header => header.name.toLowerCase() !== 'cookie');
334-
const originalCookie = this._request.headers().filter(header => header.name.toLowerCase() === 'cookie');
335-
overrides.headers.push(...originalCookie);
336-
}
337334
this._request._setOverrides(overrides);
338335
if (!overrides.isFallback)
339336
this._request._context.emit(BrowserContext.Events.RequestContinued, this._request);

tests/page/page-request-continue.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ it('continue should not propagate cookie override to redirects', {
456456
annotation: [
457457
{ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/35168' },
458458
]
459-
}, async ({ page, server }) => {
459+
}, async ({ page, server, browserName }) => {
460+
it.fixme(browserName === 'firefox', 'We currently clear all headers during interception in firefox');
460461
server.setRoute('/set-cookie', (request, response) => {
461462
response.writeHead(200, { 'Set-Cookie': 'foo=bar;' });
462463
response.end();
@@ -483,7 +484,8 @@ it('continue should not override cookie', {
483484
annotation: [
484485
{ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/35168' },
485486
]
486-
}, async ({ page, server }) => {
487+
}, async ({ page, server, browserName }) => {
488+
it.fixme(browserName === 'firefox', 'We currently clear all headers during interception in firefox');
487489
server.setRoute('/set-cookie', (request, response) => {
488490
response.writeHead(200, { 'Set-Cookie': 'foo=bar;' });
489491
response.end();
@@ -817,9 +819,7 @@ it('propagate headers cross origin redirect after interception', {
817819
expect.soft(serverRequest.headers['authorization']).toBeFalsy();
818820
else
819821
expect.soft(serverRequest.headers['authorization']).toBe('credentials');
820-
// TODO: fix this in juggler.
821-
if (browserName !== 'firefox')
822-
expect.soft(serverRequest.headers['cookie']).toBeFalsy();
822+
expect.soft(serverRequest.headers['cookie']).toBeFalsy();
823823
expect.soft(serverRequest.headers['custom']).toBe('foo');
824824
});
825825

tests/page/page-route.spec.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ it('should properly return navigation response when URL has cookies', async ({ p
166166
expect(response.status()).toBe(200);
167167
});
168168

169-
it('should override cookie header', async ({ page, server, browserName }) => {
169+
it('should not override cookie header', async ({ page, server, browserName }) => {
170170
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/16773' });
171-
it.fail(browserName !== 'firefox' && !browserName.includes('bidi'));
171+
it.fixme(browserName === 'firefox', 'We currently clear all headers during interception in firefox');
172172

173173
await page.goto(server.EMPTY_PAGE);
174174
await page.evaluate(() => document.cookie = 'original=value');
@@ -184,8 +184,9 @@ it('should override cookie header', async ({ page, server, browserName }) => {
184184
page.goto(server.EMPTY_PAGE),
185185
]);
186186

187-
expect(cookieValueInRoute).toBe('original=value');
188-
expect(serverReq.headers['cookie']).toBe('overridden=value');
187+
if (browserName !== 'webkit')
188+
expect.soft(cookieValueInRoute).toBe('original=value');
189+
expect.soft(serverReq.headers['cookie']).toBe('original=value');
189190
});
190191

191192
it('should show custom HTTP headers', async ({ page, server }) => {

0 commit comments

Comments
 (0)