From e9e3349e2f3285b25315c5a1791e21a9a36d7311 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 11 Aug 2021 10:27:41 -0700 Subject: [PATCH] test: update sameSite cookie expectations on WebKit Win (#8138) --- tests/browsercontext-add-cookies.spec.ts | 8 ++++---- tests/browsercontext-cookies.spec.ts | 18 +++++++++--------- tests/defaultbrowsercontext-1.spec.ts | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/browsercontext-add-cookies.spec.ts b/tests/browsercontext-add-cookies.spec.ts index f43a1536dc..c6ed9eeccc 100644 --- a/tests/browsercontext-add-cookies.spec.ts +++ b/tests/browsercontext-add-cookies.spec.ts @@ -221,7 +221,7 @@ it('should set cookie with reasonable defaults', async ({context, server, browse }]); }); -it('should set a cookie with a path', async ({context, page, server}) => { +it('should set a cookie with a path', async ({context, page, server, browserName, isWindows}) => { await page.goto(server.PREFIX + '/grid.html'); await context.addCookies([{ domain: 'localhost', @@ -238,7 +238,7 @@ it('should set a cookie with a path', async ({context, page, server}) => { expires: -1, httpOnly: false, secure: false, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }]); expect(await page.evaluate('document.cookie')).toBe('gridcookie=GRID'); await page.goto(server.EMPTY_PAGE); @@ -296,7 +296,7 @@ it('should be able to set unsecure cookie for HTTP website', async ({context, pa expect(cookie.secure).toBe(false); }); -it('should set a cookie on a different domain', async ({context, page, server}) => { +it('should set a cookie on a different domain', async ({context, page, server, browserName, isWindows}) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: 'https://www.example.com', @@ -313,7 +313,7 @@ it('should set a cookie on a different domain', async ({context, page, server}) expires: -1, httpOnly: false, secure: true, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }]); }); diff --git a/tests/browsercontext-cookies.spec.ts b/tests/browsercontext-cookies.spec.ts index b0fcd551c2..522ad3573d 100644 --- a/tests/browsercontext-cookies.spec.ts +++ b/tests/browsercontext-cookies.spec.ts @@ -132,7 +132,7 @@ it('should get multiple cookies', async ({context, page, server, browserName}) = ])); }); -it('should get cookies from multiple urls', async ({context}) => { +it('should get cookies from multiple urls', async ({context, browserName, isWindows}) => { await context.addCookies([{ url: 'https://foo.com', name: 'doggo', @@ -158,7 +158,7 @@ it('should get cookies from multiple urls', async ({context}) => { expires: -1, httpOnly: false, secure: true, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }, { name: 'doggo', value: 'woofs', @@ -171,7 +171,7 @@ it('should get cookies from multiple urls', async ({context}) => { }])); }); -it('should work with subdomain cookie', async ({context, page, server}) => { +it('should work with subdomain cookie', async ({context, browserName, isWindows}) => { await context.addCookies([{ domain: '.foo.com', path: '/', @@ -188,7 +188,7 @@ it('should work with subdomain cookie', async ({context, page, server}) => { expires: -1, httpOnly: false, secure: true, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }]); expect(await context.cookies('https://sub.foo.com')).toEqual([{ name: 'doggo', @@ -198,7 +198,7 @@ it('should work with subdomain cookie', async ({context, page, server}) => { expires: -1, httpOnly: false, secure: true, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }]); }); @@ -212,7 +212,7 @@ it('should not return cookies with empty value', async ({context, page, server}) expect(cookies.length).toBe(0); }); -it('should return secure cookies based on HTTP(S) protocol', async ({context}) => { +it('should return secure cookies based on HTTP(S) protocol', async ({context, browserName, isWindows}) => { await context.addCookies([{ url: 'https://foo.com', name: 'doggo', @@ -235,7 +235,7 @@ it('should return secure cookies based on HTTP(S) protocol', async ({context}) = expires: -1, httpOnly: false, secure: false, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }, { name: 'doggo', value: 'woofs', @@ -244,7 +244,7 @@ it('should return secure cookies based on HTTP(S) protocol', async ({context}) = expires: -1, httpOnly: false, secure: true, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }])); expect(await context.cookies('http://foo.com/')).toEqual([{ name: 'catto', @@ -254,6 +254,6 @@ it('should return secure cookies based on HTTP(S) protocol', async ({context}) = expires: -1, httpOnly: false, secure: false, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }]); }); diff --git a/tests/defaultbrowsercontext-1.spec.ts b/tests/defaultbrowsercontext-1.spec.ts index 10d5c0b446..4bca18235f 100644 --- a/tests/defaultbrowsercontext-1.spec.ts +++ b/tests/defaultbrowsercontext-1.spec.ts @@ -39,7 +39,7 @@ it('context.cookies() should work', async ({server, launchPersistent, browserNam }]); }); -it('context.addCookies() should work', async ({server, launchPersistent}) => { +it('context.addCookies() should work', async ({server, launchPersistent, browserName, isWindows}) => { const {page} = await launchPersistent(); await page.goto(server.EMPTY_PAGE); await page.context().addCookies([{ @@ -57,7 +57,7 @@ it('context.addCookies() should work', async ({server, launchPersistent}) => { expires: -1, httpOnly: false, secure: false, - sameSite: 'Lax', + sameSite: (browserName === 'webkit' && isWindows) ? 'None' : 'Lax', }]); });