test: update macOS-15 WebKit cookie tests expectations (#33332)

This commit is contained in:
Max Schmitt 2024-10-28 20:34:08 +01:00 committed by GitHub
parent 4b7c8d8a20
commit c9a93486a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 21 deletions

View File

@ -30,7 +30,6 @@ import type { TestInfo } from '@playwright/test';
export type BrowserTestWorkerFixtures = PageWorkerFixtures & { export type BrowserTestWorkerFixtures = PageWorkerFixtures & {
browserVersion: string; browserVersion: string;
defaultSameSiteCookieValue: string; defaultSameSiteCookieValue: string;
sameSiteStoredValueForNone: string;
allowsThirdParty: boolean; allowsThirdParty: boolean;
browserMajorVersion: number; browserMajorVersion: number;
browserType: BrowserType; browserType: BrowserType;
@ -76,8 +75,6 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
await run('Lax'); await run('Lax');
else if (browserName === 'webkit' && platform === 'linux') else if (browserName === 'webkit' && platform === 'linux')
await run('Lax'); await run('Lax');
else if (browserName === 'webkit' && platform === 'darwin' && macVersion >= 15)
await run('Lax');
else if (browserName === 'webkit') else if (browserName === 'webkit')
await run('None'); // Windows + older macOS await run('None'); // Windows + older macOS
else if (browserName === 'firefox' || browserName as any === '_bidiFirefox') else if (browserName === 'firefox' || browserName as any === '_bidiFirefox')
@ -86,13 +83,6 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
throw new Error('unknown browser - ' + browserName); throw new Error('unknown browser - ' + browserName);
}, { scope: 'worker' }], }, { scope: 'worker' }],
sameSiteStoredValueForNone: [async ({ browserName, isMac, macVersion }, run) => {
if (browserName === 'webkit' && isMac && macVersion >= 15)
await run('Lax');
else
await run('None');
}, { scope: 'worker' }],
browserMajorVersion: [async ({ browserVersion }, run) => { browserMajorVersion: [async ({ browserVersion }, run) => {
await run(Number(browserVersion.split('.')[0])); await run(Number(browserVersion.split('.')[0]));
}, { scope: 'worker' }], }, { scope: 'worker' }],

View File

@ -142,7 +142,7 @@ it('should get multiple cookies', async ({ context, page, server, defaultSameSit
])); ]));
}); });
it('should get cookies from multiple urls', async ({ context, browserName, isWindows, sameSiteStoredValueForNone }) => { it('should get cookies from multiple urls', async ({ context, browserName, isWindows }) => {
await context.addCookies([{ await context.addCookies([{
url: 'https://foo.com', url: 'https://foo.com',
name: 'doggo', name: 'doggo',
@ -177,7 +177,7 @@ it('should get cookies from multiple urls', async ({ context, browserName, isWin
expires: -1, expires: -1,
httpOnly: false, httpOnly: false,
secure: true, secure: true,
sameSite: sameSiteStoredValueForNone, sameSite: 'None',
}])); }]));
}); });
@ -273,7 +273,7 @@ it('should return secure cookies based on HTTP(S) protocol', async ({ context, b
}]); }]);
}); });
it('should add cookies with an expiration', async ({ context, sameSiteStoredValueForNone }) => { it('should add cookies with an expiration', async ({ context }) => {
const expires = Math.floor((Date.now() / 1000)) + 3600; const expires = Math.floor((Date.now() / 1000)) + 3600;
await context.addCookies([{ await context.addCookies([{
url: 'https://foo.com', url: 'https://foo.com',
@ -292,7 +292,7 @@ it('should add cookies with an expiration', async ({ context, sameSiteStoredValu
expires, expires,
httpOnly: false, httpOnly: false,
secure: true, secure: true,
sameSite: sameSiteStoredValueForNone, sameSite: 'None',
}]); }]);
{ {
// Rollover to 5-digit year // Rollover to 5-digit year
@ -396,7 +396,7 @@ it('should support requestStorageAccess', async ({ page, server, channel, browse
server.waitForRequest('/title.html'), server.waitForRequest('/title.html'),
frame.evaluate(() => fetch('/title.html')) frame.evaluate(() => fetch('/title.html'))
]); ]);
if ((isLinux || (isMac && macVersion >= 15)) && browserName === 'webkit') if (isLinux && browserName === 'webkit')
expect(serverRequest.headers.cookie).toBe(undefined); expect(serverRequest.headers.cookie).toBe(undefined);
else else
expect(serverRequest.headers.cookie).toBe('name=value'); expect(serverRequest.headers.cookie).toBe('name=value');

View File

@ -1244,7 +1244,7 @@ it('should work with connectOverCDP', async ({ browserName, browserType, server
} }
}); });
it('should support SameSite cookie attribute over https', async ({ contextFactory, httpsServer, browserName, isWindows, sameSiteStoredValueForNone }) => { 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 // 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 // to HTTP url will fail if the response contains a cookie with Secure attribute, so
// we do HTTPS navigation. // we do HTTPS navigation.
@ -1260,8 +1260,6 @@ it('should support SameSite cookie attribute over https', async ({ contextFactor
const [cookie] = await page.context().cookies(); const [cookie] = await page.context().cookies();
if (browserName === 'webkit' && isWindows) if (browserName === 'webkit' && isWindows)
expect(cookie.sameSite).toBe('None'); expect(cookie.sameSite).toBe('None');
else if (value === 'None')
expect(cookie.sameSite).toBe(sameSiteStoredValueForNone);
else else
expect(cookie.sameSite).toBe(value); expect(cookie.sameSite).toBe(value);
}); });
@ -1291,7 +1289,7 @@ it('fetch should not throw on long set-cookie value', async ({ context, server }
expect(cookies.map(c => c.name)).toContain('bar'); expect(cookies.map(c => c.name)).toContain('bar');
}); });
it('should support set-cookie with SameSite and without Secure attribute over HTTP', async ({ page, server, browserName, isWindows, isLinux, sameSiteStoredValueForNone }) => { it('should support set-cookie with SameSite and without Secure attribute over HTTP', async ({ page, server, browserName, isWindows, isLinux }) => {
for (const value of ['None', 'Lax', 'Strict']) { for (const value of ['None', 'Lax', 'Strict']) {
await it.step(`SameSite=${value}`, async () => { await it.step(`SameSite=${value}`, async () => {
server.setRoute('/empty.html', (req, res) => { server.setRoute('/empty.html', (req, res) => {
@ -1306,8 +1304,6 @@ it('should support set-cookie with SameSite and without Secure attribute over HT
expect(cookie).toBeFalsy(); expect(cookie).toBeFalsy();
else if (browserName === 'webkit' && isWindows) else if (browserName === 'webkit' && isWindows)
expect(cookie.sameSite).toBe('None'); expect(cookie.sameSite).toBe('None');
else if (value === 'None')
expect(cookie.sameSite).toBe(sameSiteStoredValueForNone);
else else
expect(cookie.sameSite).toBe(value); expect(cookie.sameSite).toBe(value);
}); });