test: update SameSite cookie fetch test (#17797)

This commit is contained in:
Yury Semikhatsky 2022-10-03 20:46:25 -07:00 committed by GitHub
parent 99266e48ec
commit cb6b824119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1027,7 +1027,7 @@ it('should work with connectOverCDP', async ({ browserName, browserType, server
}
});
it('should support SameSite cookie attribute over https', async ({ contextFactory, httpsServer }) => {
it('should support SameSite cookie attribute over https', async ({ contextFactory, httpsServer, browserName, isWindows }) => {
// Cookies with SameSite=None must also specify the Secure attribute. WebKit navigation
// to HTTP url will fail if the response contains a cookie with Secure attribute, so
// we do HTTPS navigation.
@ -1041,12 +1041,15 @@ it('should support SameSite cookie attribute over https', async ({ contextFactor
});
await page.request.get(httpsServer.EMPTY_PAGE);
const [cookie] = await page.context().cookies();
expect(cookie.sameSite).toBe(value);
if (browserName === 'webkit' && isWindows)
expect(cookie.sameSite).toBe('None');
else
expect(cookie.sameSite).toBe(value);
});
}
});
it('should support set-cookie with SameSite and without Secure attribute over HTTP', async ({ page, server, browserName }) => {
it('should support set-cookie with SameSite and without Secure attribute over HTTP', async ({ page, server, browserName, isWindows }) => {
for (const value of ['None', 'Lax', 'Strict']) {
await it.step(`SameSite=${value}`, async () => {
server.setRoute('/empty.html', (req, res) => {
@ -1057,6 +1060,8 @@ it('should support set-cookie with SameSite and without Secure attribute over HT
const [cookie] = await page.context().cookies();
if (browserName === 'chromium' && value === 'None')
expect(cookie).toBeFalsy();
else if (browserName === 'webkit' && isWindows)
expect(cookie.sameSite).toBe('None');
else
expect(cookie.sameSite).toBe(value);
});