chore(webkit): update test-expecations for libsoup3.4

This commit is contained in:
Max Schmitt 2024-04-16 12:30:44 +02:00
parent a6a44a07a7
commit 0b6e317a50
5 changed files with 19 additions and 15 deletions

View file

@ -267,7 +267,8 @@ export class WKBrowserContext extends BrowserContext {
const cc = network.rewriteCookies(cookies).map(c => ({
...c,
session: c.expires === -1 || c.expires === undefined,
expires: c.expires && c.expires !== -1 ? c.expires * 1000 : c.expires
expires: c.expires && c.expires !== -1 ? c.expires * 1000 : c.expires,
sameSite: c.sameSite ? c.sameSite : 'Lax',
})) as Protocol.Playwright.SetCookieParam[];
await this._browser._browserSession.send('Playwright.setCookies', { cookies: cc, browserContextId: this._browserContextId });
}

View file

@ -67,9 +67,11 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
await run(false);
}, { scope: 'worker' }],
defaultSameSiteCookieValue: [async ({ browserName, browserMajorVersion, channel }, run) => {
defaultSameSiteCookieValue: [async ({ browserName, browserMajorVersion, channel, platform }, run) => {
if (browserName === 'chromium')
await run('Lax');
else if (browserName === 'webkit' && platform === 'linux')
await run('Lax');
else if (browserName === 'webkit')
await run('None');
else if (browserName === 'firefox' && channel === 'firefox-beta')

View file

@ -224,7 +224,7 @@ it('should have |expires| set to |-1| for session cookies', async ({ context, se
expect(cookies[0].expires).toBe(-1);
});
it('should set cookie with reasonable defaults', async ({ context, server, browserName }) => {
it('should set cookie with reasonable defaults', async ({ context, server, browserName, defaultSameSiteCookieValue }) => {
await context.addCookies([{
url: server.EMPTY_PAGE,
name: 'defaults',
@ -239,7 +239,7 @@ it('should set cookie with reasonable defaults', async ({ context, server, brows
expires: -1,
httpOnly: false,
secure: false,
sameSite: browserName === 'chromium' ? 'Lax' : 'None',
sameSite: defaultSameSiteCookieValue,
}]);
});

View file

@ -350,26 +350,26 @@ it('should be able to send third party cookies via an iframe', async ({ browser,
}
});
it('should support requestStorageAccess', async ({ page, server, channel, browserName, isMac, isLinux, isWindows }) => {
it('should support requestStorageAccess', async ({ browser, httpsServer, channel, browserName, isLinux, isMac }) => {
const page = await browser.newPage({ ignoreHTTPSErrors: true });
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/17285' });
it.skip(browserName === 'chromium', 'requestStorageAccess API is not available in Chromium');
it.skip(channel === 'firefox-beta', 'hasStorageAccess returns true, but no cookie is sent');
server.setRoute('/set-cookie.html', (req, res) => {
res.setHeader('Set-Cookie', 'name=value; Path=/');
httpsServer.setRoute('/set-cookie.html', (req, res) => {
res.setHeader('Set-Cookie', 'name=value; Path=/; SameSite=None; Secure');
res.end();
});
// Navigate once to the domain as top level.
await page.goto(server.CROSS_PROCESS_PREFIX + '/set-cookie.html');
await page.goto(server.EMPTY_PAGE);
await page.setContent(`<iframe src="${server.CROSS_PROCESS_PREFIX + '/empty.html'}"></iframe>`);
await page.goto(httpsServer.CROSS_PROCESS_PREFIX + '/set-cookie.html');
await page.goto(httpsServer.EMPTY_PAGE);
await page.setContent(`<iframe src="${httpsServer.CROSS_PROCESS_PREFIX + '/empty.html'}"></iframe>`);
const frame = page.frames()[1];
if (browserName === 'firefox') {
expect(await frame.evaluate(() => document.hasStorageAccess())).toBeTruthy();
{
const [serverRequest] = await Promise.all([
server.waitForRequest('/title.html'),
httpsServer.waitForRequest('/title.html'),
frame.evaluate(() => fetch('/title.html'))
]);
expect(serverRequest.headers.cookie).toBe('name=value');
@ -381,7 +381,7 @@ it('should support requestStorageAccess', async ({ page, server, channel, browse
expect(await frame.evaluate(() => document.hasStorageAccess())).toBeFalsy();
{
const [serverRequest] = await Promise.all([
server.waitForRequest('/title.html'),
httpsServer.waitForRequest('/title.html'),
frame.evaluate(() => fetch('/title.html'))
]);
if (!isMac && browserName === 'webkit')
@ -393,12 +393,13 @@ it('should support requestStorageAccess', async ({ page, server, channel, browse
expect(await frame.evaluate(() => document.hasStorageAccess())).toBeTruthy();
{
const [serverRequest] = await Promise.all([
server.waitForRequest('/title.html'),
httpsServer.waitForRequest('/title.html'),
frame.evaluate(() => fetch('/title.html'))
]);
expect(serverRequest.headers.cookie).toBe('name=value');
}
}
await page.close();
});
it('should parse cookie with large Max-Age correctly', async ({ server, page, defaultSameSiteCookieValue, browserName, platform }) => {

View file

@ -1155,7 +1155,7 @@ it('should support set-cookie with SameSite and without Secure attribute over HT
});
await page.request.get(server.EMPTY_PAGE);
const [cookie] = await page.context().cookies();
if (browserName === 'chromium' && value === 'None')
if (['chromium', 'webkit'].includes(browserName) && value === 'None')
expect(cookie).toBeFalsy();
else if (browserName === 'webkit' && isWindows)
expect(cookie.sameSite).toBe('None');