Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/playwright-core/src/server/webkit/wkBrowser.ts
Expand Up @@ -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 });
}
Expand Down
4 changes: 3 additions & 1 deletion tests/config/browserTest.ts
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions tests/library/browsercontext-add-cookies.spec.ts
Expand Up @@ -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',
Expand All @@ -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,
}]);
});

Expand Down
21 changes: 11 additions & 10 deletions tests/library/browsercontext-cookies.spec.ts
Expand Up @@ -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');
Expand All @@ -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')
Expand All @@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/library/browsercontext-fetch.spec.ts
Expand Up @@ -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');
Expand Down