Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/browsercontext-cookies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,31 @@ it('should return secure cookies based on HTTP(S) protocol', async ({ context, b
sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax',
}]);
});

it('should add cookies with an expiration', async ({ context, browserName, platform }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/12226' });
it.fixme(browserName === 'webkit' && platform === 'linux', 'Protocol error');
Comment thread
mxschmitt marked this conversation as resolved.
const expires = Date.now() + 3600;
await context.addCookies([{
url: 'https://foo.com',
name: 'doggo',
value: 'woofs',
sameSite: 'None',
expires,
}]);
const cookies = await context.cookies(['https://foo.com']);
expect(cookies.length).toBe(1);
if (browserName === 'chromium')
// Chromium returns them sometimes as floats: https://crbug.com/1300178
cookies[0].expires = Math.round(cookies[0].expires);
expect(cookies).toEqual([{
name: 'doggo',
value: 'woofs',
domain: 'foo.com',
path: '/',
expires,
httpOnly: false,
secure: true,
sameSite: 'None',
}]);
});