Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/playwright-core/browsers.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"name": "firefox-beta",
"revision": "1309",
"revision": "1310",
"installByDefault": false
},
{
Expand Down
1 change: 1 addition & 0 deletions tests/assets/empty-standard-mode.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html>
2 changes: 1 addition & 1 deletion tests/assets/error.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<!DOCTYPE html> <script>
console.error('Not a JS error');
a();

Expand Down
4 changes: 2 additions & 2 deletions tests/browsercontext-add-cookies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ it('should set cookies for a frame', async ({ context, page, server }) => {
expect(await page.frames()[1].evaluate('document.cookie')).toBe('frame-cookie=value');
});

it('should(not) block third party cookies', async ({ context, page, server, browserName }) => {
it('should(not) block third party cookies', async ({ context, page, server, browserName, browserMajorVersion }) => {
await page.goto(server.EMPTY_PAGE);
await page.evaluate(src => {
let fulfill;
Expand All @@ -366,7 +366,7 @@ it('should(not) block third party cookies', async ({ context, page, server, brow
}, server.CROSS_PROCESS_PREFIX + '/grid.html');
await page.frames()[1].evaluate(`document.cookie = 'username=John Doe'`);
await page.waitForTimeout(2000);
const allowsThirdParty = browserName === 'firefox';
const allowsThirdParty = browserName === 'firefox' && browserMajorVersion < 96;
const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) {
expect(cookies).toEqual([
Expand Down
17 changes: 10 additions & 7 deletions tests/browsercontext-cookies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ it('should return no cookies in pristine browser context', async ({ context, pag
expect(await context.cookies()).toEqual([]);
});

it('should get a cookie', async ({ context, page, server, browserName }) => {
it('should get a cookie', async ({ context, page, server, browserName, browserMajorVersion }) => {
await page.goto(server.EMPTY_PAGE);
const documentCookie = await page.evaluate(() => {
document.cookie = 'username=John Doe';
return document.cookie;
});
expect(documentCookie).toBe('username=John Doe');
const defaultSameSiteCookieValue = browserName === 'chromium' || (browserName === 'firefox' && browserMajorVersion >= 96) ? 'Lax' : 'None';
expect(await context.cookies()).toEqual([{
name: 'username',
value: 'John Doe',
Expand All @@ -36,11 +37,11 @@ it('should get a cookie', async ({ context, page, server, browserName }) => {
expires: -1,
httpOnly: false,
secure: false,
sameSite: browserName === 'chromium' ? 'Lax' : 'None',
sameSite: defaultSameSiteCookieValue,
}]);
});

it('should get a non-session cookie', async ({ context, page, server, browserName }) => {
it('should get a non-session cookie', async ({ context, page, server, browserName, browserMajorVersion }) => {
await page.goto(server.EMPTY_PAGE);
// @see https://en.wikipedia.org/wiki/Year_2038_problem
const date = +(new Date('1/1/2038'));
Expand All @@ -50,6 +51,7 @@ it('should get a non-session cookie', async ({ context, page, server, browserNam
return document.cookie;
}, date);
expect(documentCookie).toBe('username=John Doe');
const defaultSameSiteCookieValue = browserName === 'chromium' || (browserName === 'firefox' && browserMajorVersion >= 96) ? 'Lax' : 'None';
expect(await context.cookies()).toEqual([{
name: 'username',
value: 'John Doe',
Expand All @@ -58,7 +60,7 @@ it('should get a non-session cookie', async ({ context, page, server, browserNam
expires: date / 1000,
httpOnly: false,
secure: false,
sameSite: browserName === 'chromium' ? 'Lax' : 'None',
sameSite: defaultSameSiteCookieValue,
}]);
});

Expand Down Expand Up @@ -99,14 +101,15 @@ it('should properly report "Lax" sameSite cookie', async ({ context, page, serve
expect(cookies[0].sameSite).toBe('Lax');
});

it('should get multiple cookies', async ({ context, page, server, browserName }) => {
it('should get multiple cookies', async ({ context, page, server, browserName, browserMajorVersion }) => {
await page.goto(server.EMPTY_PAGE);
const documentCookie = await page.evaluate(() => {
document.cookie = 'username=John Doe';
document.cookie = 'password=1234';
return document.cookie.split('; ').sort().join('; ');
});
const cookies = new Set(await context.cookies());
const defaultSameSiteCookieValue = browserName === 'chromium' || (browserName === 'firefox' && browserMajorVersion >= 96) ? 'Lax' : 'None';
expect(documentCookie).toBe('password=1234; username=John Doe');
expect(cookies).toEqual(new Set([
{
Expand All @@ -117,7 +120,7 @@ it('should get multiple cookies', async ({ context, page, server, browserName })
expires: -1,
httpOnly: false,
secure: false,
sameSite: browserName === 'chromium' ? 'Lax' : 'None',
sameSite: defaultSameSiteCookieValue,
},
{
name: 'username',
Expand All @@ -127,7 +130,7 @@ it('should get multiple cookies', async ({ context, page, server, browserName })
expires: -1,
httpOnly: false,
secure: false,
sameSite: browserName === 'chromium' ? 'Lax' : 'None',
sameSite: defaultSameSiteCookieValue,
},
]));
});
Expand Down
10 changes: 6 additions & 4 deletions tests/browsercontext-route.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ it('should fall back to context.route', async ({ browser, server }) => {
await context.close();
});

it('should support Set-Cookie header', async ({ contextFactory, server, browserName }) => {
it('should support Set-Cookie header', async ({ contextFactory, server, browserName, browserMajorVersion }) => {
it.fixme(browserName === 'webkit');

const context = await contextFactory();
Expand All @@ -123,8 +123,9 @@ it('should support Set-Cookie header', async ({ contextFactory, server, browserN
});
});
await page.goto('https://example.com');
const defaultSameSiteCookieValue = browserName === 'chromium' || (browserName === 'firefox' && browserMajorVersion >= 96) ? 'Lax' : 'None';
expect(await context.cookies()).toEqual([{
sameSite: browserName === 'chromium' ? 'Lax' : 'None',
sameSite: defaultSameSiteCookieValue,
name: 'name',
value: 'value',
domain: '.example.com',
Expand Down Expand Up @@ -153,7 +154,7 @@ it('should ignore secure Set-Cookie header for insecure requests', async ({ cont
expect(await context.cookies()).toEqual([]);
});

it('should use Set-Cookie header in future requests', async ({ contextFactory, server, browserName }) => {
it('should use Set-Cookie header in future requests', async ({ contextFactory, server, browserName, browserMajorVersion }) => {
it.fixme(browserName === 'webkit');

const context = await contextFactory();
Expand All @@ -169,8 +170,9 @@ it('should use Set-Cookie header in future requests', async ({ contextFactory, s
});
});
await page.goto(server.EMPTY_PAGE);
const defaultSameSiteCookieValue = browserName === 'chromium' || (browserName === 'firefox' && browserMajorVersion >= 96) ? 'Lax' : 'None';
expect(await context.cookies()).toEqual([{
sameSite: browserName === 'chromium' ? 'Lax' : 'None',
sameSite: defaultSameSiteCookieValue,
name: 'name',
value: 'value',
domain: 'localhost',
Expand Down
4 changes: 3 additions & 1 deletion tests/channels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ it('should scope context handles', async ({ browserType, server }) => {

const context = await browser.newContext();
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
// Firefox Beta 96 yields a console warning for the pages that
// don't use `<!DOCTYPE HTML> tag.
await page.goto(server.PREFIX + '/empty-standard-mode.html');
await expectScopeState(browser, {
_guid: '',
objects: [
Expand Down
9 changes: 5 additions & 4 deletions tests/defaultbrowsercontext-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import { playwrightTest as it, expect } from './config/browserTest';
import { verifyViewport } from './config/utils';
import fs from 'fs';

it('context.cookies() should work', async ({ server, launchPersistent, browserName }) => {
it('context.cookies() should work', async ({ server, launchPersistent, browserName, browserMajorVersion }) => {
const { page } = await launchPersistent();
await page.goto(server.EMPTY_PAGE);
const documentCookie = await page.evaluate(() => {
document.cookie = 'username=John Doe';
return document.cookie;
});
expect(documentCookie).toBe('username=John Doe');
const defaultSameSiteCookieValue = browserName === 'chromium' || (browserName === 'firefox' && browserMajorVersion >= 96) ? 'Lax' : 'None';
expect(await page.context().cookies()).toEqual([{
name: 'username',
value: 'John Doe',
Expand All @@ -35,7 +36,7 @@ it('context.cookies() should work', async ({ server, launchPersistent, browserNa
expires: -1,
httpOnly: false,
secure: false,
sameSite: browserName === 'chromium' ? 'Lax' : 'None',
sameSite: defaultSameSiteCookieValue,
}]);
});

Expand Down Expand Up @@ -80,7 +81,7 @@ it('context.clearCookies() should work', async ({ server, launchPersistent }) =>
expect(await page.evaluate('document.cookie')).toBe('');
});

it('should(not) block third party cookies', async ({ server, launchPersistent, browserName }) => {
it('should(not) block third party cookies', async ({ server, launchPersistent, browserName, browserMajorVersion }) => {
const { page, context } = await launchPersistent();
await page.goto(server.EMPTY_PAGE);
await page.evaluate(src => {
Expand All @@ -97,7 +98,7 @@ it('should(not) block third party cookies', async ({ server, launchPersistent, b
return document.cookie;
});
await page.waitForTimeout(2000);
const allowsThirdParty = browserName === 'firefox';
const allowsThirdParty = browserName === 'firefox' && browserMajorVersion <= 95;
expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : '');
const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) {
Expand Down
4 changes: 2 additions & 2 deletions tests/headful.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ it('should close browser after context menu was triggered', async ({ browserType
await browser.close();
});

it('should(not) block third party cookies', async ({ browserType, server, browserName }) => {
it('should(not) block third party cookies', async ({ browserType, server, browserName, browserMajorVersion }) => {
const browser = await browserType.launch({ headless: false });
const page = await browser.newPage();
await page.goto(server.EMPTY_PAGE);
Expand All @@ -85,7 +85,7 @@ it('should(not) block third party cookies', async ({ browserType, server, browse
return document.cookie;
});
await page.waitForTimeout(2000);
const allowsThirdParty = browserName === 'firefox';
const allowsThirdParty = browserName === 'firefox' && browserMajorVersion <= 95;
expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : '');
const cookies = await page.context().cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) {
Expand Down
4 changes: 2 additions & 2 deletions tests/page/wheel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ it('should work when the event is canceled', async ({ page }) => {
altKey: false,
metaKey: false,
});
// give the page a chacne to scroll
// Give the page a chance to scroll.
await page.waitForTimeout(100);
// ensure that it did not.
// Ensure that it did not.
expect(await page.evaluate('window.scrollY')).toBe(0);
});

Expand Down