test: request cookie order is same as in set-cookie (#24194)

This commit is contained in:
Yury Semikhatsky 2023-07-12 17:40:53 -07:00 committed by GitHub
parent 53feeaf270
commit cc51d13c36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,6 +218,33 @@ it('should add cookies from Set-Cookie header', async ({ context, page, server }
expect((await page.evaluate(() => document.cookie)).split(';').map(s => s.trim()).sort()).toEqual(['foo=bar', 'session=value']);
});
it('should preserve cookie order from Set-Cookie header', async ({ context, page, server, browserName, isLinux }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/23390' });
it.fixme(browserName === 'webkit' && isLinux);
server.setRoute('/setcookie.html', (req, res) => {
res.setHeader('Set-Cookie', ['cookie.0=foo', 'cookie.1=bar']);
res.end();
});
await page.request.get(server.PREFIX + '/setcookie.html');
const cookies = await context.cookies();
expect(cookies.map(c => ({ name: c.name, value: c.value }))).toEqual([
{
name: 'cookie.0',
value: 'foo'
},
{
name: 'cookie.1',
value: 'bar'
},
]);
await page.goto(server.EMPTY_PAGE);
expect(await page.evaluate(() => document.cookie)).toEqual('cookie.0=foo; cookie.1=bar');
const requestPromise = server.waitForRequest('/empty.html');
await page.request.get(server.EMPTY_PAGE);
const request = await requestPromise;
expect(request.headers.cookie).toEqual('cookie.0=foo; cookie.1=bar');
});
it('should support cookie with empty value', async ({ context, page, server }) => {
server.setRoute('/setcookie.html', (req, res) => {
res.setHeader('Set-Cookie', ['first=']);