diff --git a/.eslintignore b/.eslintignore index 954cfdbd30..ab8f474661 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,7 +11,7 @@ src/server/webkit/protocol.ts /electron-types.d.ts utils/generate_types/overrides.d.ts utils/generate_types/test/test.ts -/test/ node_modules/ browser_patches/*/checkout/ packages/**/*.d.ts +output/ diff --git a/test/accessibility.spec.ts b/test/accessibility.spec.ts index 4981b6ef64..57078ab52b 100644 --- a/test/accessibility.spec.ts +++ b/test/accessibility.spec.ts @@ -78,7 +78,7 @@ it('should work', async function({page}) { expect(await page.accessibility.snapshot()).toEqual(golden); }); -it('should work with regular text', async({page}) => { +it('should work with regular text', async ({page}) => { await page.setContent(`
Hello World
`); const snapshot = await page.accessibility.snapshot(); expect(snapshot.children[0]).toEqual({ @@ -87,31 +87,31 @@ it('should work with regular text', async({page}) => { }); }); -it('roledescription', async({page}) => { +it('roledescription', async ({page}) => { await page.setContent('
Hi
'); const snapshot = await page.accessibility.snapshot(); expect(snapshot.children[0].roledescription).toEqual('foo'); }); -it('orientation', async({page}) => { +it('orientation', async ({page}) => { await page.setContent('11'); const snapshot = await page.accessibility.snapshot(); expect(snapshot.children[0].orientation).toEqual('vertical'); }); -it('autocomplete', async({page}) => { +it('autocomplete', async ({page}) => { await page.setContent('
hi
'); const snapshot = await page.accessibility.snapshot(); expect(snapshot.children[0].autocomplete).toEqual('list'); }); -it('multiselectable', async({page}) => { +it('multiselectable', async ({page}) => { await page.setContent('
hey
'); const snapshot = await page.accessibility.snapshot(); expect(snapshot.children[0].multiselectable).toEqual(true); }); -it('keyshortcuts', async({page}) => { +it('keyshortcuts', async ({page}) => { await page.setContent('
hey
'); const snapshot = await page.accessibility.snapshot(); expect(snapshot.children[0].keyshortcuts).toEqual('foo'); @@ -204,12 +204,12 @@ it.skip(options.FIREFOX || options.WEBKIT)('plain text field with role should no // WebKit rich text accessibility is iffy await page.setContent(`
Edit this image:my fake image
`); - const snapshot = await page.accessibility.snapshot(); - expect(snapshot.children[0]).toEqual({ - role: 'textbox', - name: '', - value: 'Edit this image:' - }); + const snapshot = await page.accessibility.snapshot(); + expect(snapshot.children[0]).toEqual({ + role: 'textbox', + name: '', + value: 'Edit this image:' + }); }); it.skip(options.FIREFOX || options.WEBKIT)('plain text field without role should not have content', async function({page}) { @@ -289,7 +289,7 @@ it('checkbox without label should not have children', async function({page}) { expect(snapshot.children[0]).toEqual(golden); }); -it('should work a button', async({page}) => { +it('should work a button', async ({page}) => { await page.setContent(``); const button = await page.$('button'); @@ -299,7 +299,7 @@ it('should work a button', async({page}) => { }); }); -it('should work an input', async({page}) => { +it('should work an input', async ({page}) => { await page.setContent(``); const input = await page.$('input'); @@ -310,7 +310,7 @@ it('should work an input', async({page}) => { }); }); -it('should work on a menu', async({page}) => { +it('should work on a menu', async ({page}) => { await page.setContent(`
First Item
@@ -331,14 +331,14 @@ it('should work on a menu', async({page}) => { }); }); -it('should return null when the element is no longer in DOM', async({page}) => { +it('should return null when the element is no longer in DOM', async ({page}) => { await page.setContent(``); const button = await page.$('button'); await page.$eval('button', button => button.remove()); expect(await page.accessibility.snapshot({root: button})).toEqual(null); }); -it('should show uninteresting nodes', async({page}) => { +it('should show uninteresting nodes', async ({page}) => { await page.setContent(`
diff --git a/test/autowaiting-basic.spec.ts b/test/autowaiting-basic.spec.ts index 13a47a941b..b8eefe371e 100644 --- a/test/autowaiting-basic.spec.ts +++ b/test/autowaiting-basic.spec.ts @@ -16,7 +16,7 @@ */ import { options } from './playwright.fixtures'; -it('should await navigation when clicking anchor', async({page, server}) => { +it('should await navigation when clicking anchor', async ({page, server}) => { const messages = []; server.setRoute('/empty.html', async (req, res) => { messages.push('route'); @@ -33,7 +33,7 @@ it('should await navigation when clicking anchor', async({page, server}) => { expect(messages.join('|')).toBe('route|navigated|click'); }); -it('should await cross-process navigation when clicking anchor', async({page, server}) => { +it('should await cross-process navigation when clicking anchor', async ({page, server}) => { const messages = []; server.setRoute('/empty.html', async (req, res) => { messages.push('route'); @@ -50,7 +50,7 @@ it('should await cross-process navigation when clicking anchor', async({page, se expect(messages.join('|')).toBe('route|navigated|click'); }); -it('should await form-get on click', async({page, server}) => { +it('should await form-get on click', async ({page, server}) => { const messages = []; server.setRoute('/empty.html?foo=bar', async (req, res) => { messages.push('route'); @@ -71,7 +71,7 @@ it('should await form-get on click', async({page, server}) => { expect(messages.join('|')).toBe('route|navigated|click'); }); -it('should await form-post on click', async({page, server}) => { +it('should await form-post on click', async ({page, server}) => { const messages = []; server.setRoute('/empty.html', async (req, res) => { messages.push('route'); @@ -92,7 +92,7 @@ it('should await form-post on click', async({page, server}) => { expect(messages.join('|')).toBe('route|navigated|click'); }); -it('should await navigation when assigning location', async({page, server}) => { +it('should await navigation when assigning location', async ({page, server}) => { const messages = []; server.setRoute('/empty.html', async (req, res) => { messages.push('route'); @@ -106,7 +106,7 @@ it('should await navigation when assigning location', async({page, server}) => { expect(messages.join('|')).toBe('route|navigated|evaluate'); }); -it('should await navigation when assigning location twice', async({page, server}) => { +it('should await navigation when assigning location twice', async ({page, server}) => { const messages = []; server.setRoute('/empty.html?cancel', async (req, res) => { res.end('done'); }); server.setRoute('/empty.html?override', async (req, res) => { messages.push('routeoverride'); res.end('done'); }); @@ -118,7 +118,7 @@ it('should await navigation when assigning location twice', async({page, server} expect(messages.join('|')).toBe('routeoverride|evaluate'); }); -it('should await navigation when evaluating reload', async({page, server}) => { +it('should await navigation when evaluating reload', async ({page, server}) => { const messages = []; await page.goto(server.EMPTY_PAGE); server.setRoute('/empty.html', async (req, res) => { @@ -134,7 +134,7 @@ it('should await navigation when evaluating reload', async({page, server}) => { expect(messages.join('|')).toBe('route|navigated|evaluate'); }); -it('should await navigating specified target', async({page, server}) => { +it('should await navigating specified target', async ({page, server}) => { const messages = []; server.setRoute('/empty.html', async (req, res) => { messages.push('route'); @@ -155,19 +155,19 @@ it('should await navigating specified target', async({page, server}) => { expect(messages.join('|')).toBe('route|navigated|click'); }); -it('should work with noWaitAfter: true', async({page, server}) => { +it('should work with noWaitAfter: true', async ({page, server}) => { server.setRoute('/empty.html', async () => {}); await page.setContent(`empty.html`); await page.click('a', { noWaitAfter: true }); }); -it('should work with dblclick noWaitAfter: true', async({page, server}) => { +it('should work with dblclick noWaitAfter: true', async ({page, server}) => { server.setRoute('/empty.html', async () => {}); await page.setContent(`empty.html`); await page.dblclick('a', { noWaitAfter: true }); }); -it('should work with waitForLoadState(load)', async({page, server}) => { +it('should work with waitForLoadState(load)', async ({page, server}) => { const messages = []; server.setRoute('/empty.html', async (req, res) => { messages.push('route'); @@ -183,7 +183,7 @@ it('should work with waitForLoadState(load)', async({page, server}) => { expect(messages.join('|')).toBe('route|domcontentloaded|clickload'); }); -it('should work with goto following click', async({page, server}) => { +it('should work with goto following click', async ({page, server}) => { server.setRoute('/login.html', async (req, res) => { res.setHeader('Content-Type', 'text/html'); res.end(`You are logged in`); @@ -200,7 +200,7 @@ it('should work with goto following click', async({page, server}) => { await page.goto(server.EMPTY_PAGE); }); -it.skip(options.WIRE)('should report navigation in the log when clicking anchor', async({page, server}) => { +it.skip(options.WIRE)('should report navigation in the log when clicking anchor', async ({page, server}) => { await page.setContent(`click me`); const __testHookAfterPointerAction = () => new Promise(f => setTimeout(f, 6000)); const error = await page.click('a', { timeout: 5000, __testHookAfterPointerAction } as any).catch(e => e); diff --git a/test/autowaiting-no-hang.spec.ts b/test/autowaiting-no-hang.spec.ts index 10d1a964de..d2b5f57a09 100644 --- a/test/autowaiting-no-hang.spec.ts +++ b/test/autowaiting-no-hang.spec.ts @@ -16,33 +16,33 @@ */ import './playwright.fixtures'; -it('clicking on links which do not commit navigation', async({page, server, httpsServer}) => { +it('clicking on links which do not commit navigation', async ({page, server, httpsServer}) => { await page.goto(server.EMPTY_PAGE); await page.setContent(`foobar`); await page.click('a'); }); -it('calling window.stop async', async({page, server}) => { +it('calling window.stop async', async ({page, server}) => { server.setRoute('/empty.html', async (req, res) => {}); - await page.evaluate((url) => { - window.location.href = url; - setTimeout(() => window.stop(), 100); - }, server.EMPTY_PAGE); + await page.evaluate(url => { + window.location.href = url; + setTimeout(() => window.stop(), 100); + }, server.EMPTY_PAGE); }); -it('calling window.stop sync', async({page, server}) => { - await page.evaluate((url) => { - window.location.href = url; - window.stop(); - }, server.EMPTY_PAGE); +it('calling window.stop sync', async ({page, server}) => { + await page.evaluate(url => { + window.location.href = url; + window.stop(); + }, server.EMPTY_PAGE); }); -it('assigning location to about:blank', async({page, server}) => { +it('assigning location to about:blank', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); await page.evaluate(`window.location.href = "about:blank";`); }); -it('assigning location to about:blank after non-about:blank', async({page, server}) => { +it('assigning location to about:blank after non-about:blank', async ({page, server}) => { server.setRoute('/empty.html', async (req, res) => {}); await page.evaluate(` window.location.href = "${server.EMPTY_PAGE}"; diff --git a/test/browsercontext-add-cookies.spec.ts b/test/browsercontext-add-cookies.spec.ts index 750f5a7566..990f121099 100644 --- a/test/browsercontext-add-cookies.spec.ts +++ b/test/browsercontext-add-cookies.spec.ts @@ -16,7 +16,7 @@ */ import { options } from './playwright.fixtures'; -it('should work', async({context, page, server}) => { +it('should work', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: server.EMPTY_PAGE, @@ -26,7 +26,7 @@ it('should work', async({context, page, server}) => { expect(await page.evaluate(() => document.cookie)).toEqual('password=123456'); }); -it('should roundtrip cookie', async({context, page, server}) => { +it('should roundtrip cookie', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); // @see https://en.wikipedia.org/wiki/Year_2038_problem const date = +(new Date('1/1/2038')); @@ -43,7 +43,7 @@ it('should roundtrip cookie', async({context, page, server}) => { expect(await context.cookies()).toEqual(cookies); }); -it('should send cookie header', async({server, context}) => { +it('should send cookie header', async ({server, context}) => { let cookie = ''; server.setRoute('/empty.html', (req, res) => { cookie = req.headers.cookie; @@ -55,7 +55,7 @@ it('should send cookie header', async({server, context}) => { expect(cookie).toBe('cookie=value'); }); -it('should isolate cookies in browser contexts', async({context, server, browser}) => { +it('should isolate cookies in browser contexts', async ({context, server, browser}) => { const anotherContext = await browser.newContext(); await context.addCookies([{url: server.EMPTY_PAGE, name: 'isolatecookie', value: 'page1value'}]); await anotherContext.addCookies([{url: server.EMPTY_PAGE, name: 'isolatecookie', value: 'page2value'}]); @@ -71,7 +71,7 @@ it('should isolate cookies in browser contexts', async({context, server, browser await anotherContext.close(); }); -it('should isolate session cookies', async({context, server, browser}) => { +it('should isolate session cookies', async ({context, server, browser}) => { server.setRoute('/setcookie.html', (req, res) => { res.setHeader('Set-Cookie', 'session=value'); res.end(); @@ -97,7 +97,7 @@ it('should isolate session cookies', async({context, server, browser}) => { } }); -it('should isolate persistent cookies', async({context, server, browser}) => { +it('should isolate persistent cookies', async ({context, server, browser}) => { server.setRoute('/setcookie.html', (req, res) => { res.setHeader('Set-Cookie', 'persistent=persistent-value; max-age=3600'); res.end(); @@ -117,7 +117,7 @@ it('should isolate persistent cookies', async({context, server, browser}) => { await context2.close(); }); -it('should isolate send cookie header', async({server, context, browser}) => { +it('should isolate send cookie header', async ({server, context, browser}) => { let cookie = ''; server.setRoute('/empty.html', (req, res) => { cookie = req.headers.cookie || ''; @@ -138,7 +138,7 @@ it('should isolate send cookie header', async({server, context, browser}) => { } }); -it.slow()('should isolate cookies between launches', async({browserType, server, defaultBrowserOptions}) => { +it.slow()('should isolate cookies between launches', async ({browserType, server, defaultBrowserOptions}) => { const browser1 = await browserType.launch(defaultBrowserOptions); const context1 = await browser1.newContext(); await context1.addCookies([{url: server.EMPTY_PAGE, name: 'cookie-in-context-1', value: 'value', expires: Date.now() / 1000 + 10000}]); @@ -151,7 +151,7 @@ it.slow()('should isolate cookies between launches', async({browserType, server, await browser2.close(); }); -it('should set multiple cookies', async({context, page, server}) => { +it('should set multiple cookies', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: server.EMPTY_PAGE, @@ -171,7 +171,7 @@ it('should set multiple cookies', async({context, page, server}) => { ]); }); -it('should have |expires| set to |-1| for session cookies', async({context, server}) => { +it('should have |expires| set to |-1| for session cookies', async ({context, server}) => { await context.addCookies([{ url: server.EMPTY_PAGE, name: 'expires', @@ -181,7 +181,7 @@ it('should have |expires| set to |-1| for session cookies', async({context, serv expect(cookies[0].expires).toBe(-1); }); -it('should set cookie with reasonable defaults', async({context, server}) => { +it('should set cookie with reasonable defaults', async ({context, server}) => { await context.addCookies([{ url: server.EMPTY_PAGE, name: 'defaults', @@ -200,7 +200,7 @@ it('should set cookie with reasonable defaults', async({context, server}) => { }]); }); -it('should set a cookie with a path', async({context, page, server}) => { +it('should set a cookie with a path', async ({context, page, server}) => { await page.goto(server.PREFIX + '/grid.html'); await context.addCookies([{ domain: 'localhost', @@ -229,8 +229,8 @@ it('should not set a cookie with blank page URL', async function({context, serve let error = null; try { await context.addCookies([ - {url: server.EMPTY_PAGE, name: 'example-cookie', value: 'best'}, - {url: 'about:blank', name: 'example-cookie-blank', value: 'best'} + {url: server.EMPTY_PAGE, name: 'example-cookie', value: 'best'}, + {url: 'about:blank', name: 'example-cookie-blank', value: 'best'} ]); } catch (e) { error = e; @@ -250,7 +250,7 @@ it('should not set a cookie on a data URL page', async function({context}) { expect(error.message).toContain('Data URL page can not have cookie "example-cookie"'); }); -it('should default to setting secure cookie for HTTPS websites', async({context, page, server}) => { +it('should default to setting secure cookie for HTTPS websites', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); const SECURE_URL = 'https://example.com'; await context.addCookies([{ @@ -262,7 +262,7 @@ it('should default to setting secure cookie for HTTPS websites', async({context, expect(cookie.secure).toBe(true); }); -it('should be able to set unsecure cookie for HTTP website', async({context, page, server}) => { +it('should be able to set unsecure cookie for HTTP website', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); const HTTP_URL = 'http://example.com'; await context.addCookies([{ @@ -274,7 +274,7 @@ it('should be able to set unsecure cookie for HTTP website', async({context, pag 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}) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: 'https://www.example.com', @@ -294,7 +294,7 @@ it('should set a cookie on a different domain', async({context, page, server}) = }]); }); -it('should set cookies for a frame', async({context, page, server}) => { +it('should set cookies for a frame', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([ {url: server.PREFIX, name: 'frame-cookie', value: 'value'} @@ -312,7 +312,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}) => { +it('should(not) block third party cookies', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); await page.evaluate(src => { let fulfill; @@ -330,14 +330,14 @@ it('should(not) block third party cookies', async({context, page, server}) => { if (allowsThirdParty) { expect(cookies).toEqual([ { - "domain": "127.0.0.1", - "expires": -1, - "httpOnly": false, - "name": "username", - "path": "/", - "sameSite": "None", - "secure": false, - "value": "John Doe" + 'domain': '127.0.0.1', + 'expires': -1, + 'httpOnly': false, + 'name': 'username', + 'path': '/', + 'sameSite': 'None', + 'secure': false, + 'value': 'John Doe' } ]); } else { diff --git a/test/browsercontext-basic.spec.ts b/test/browsercontext-basic.spec.ts index 21553f1e5b..380719ffdf 100644 --- a/test/browsercontext-basic.spec.ts +++ b/test/browsercontext-basic.spec.ts @@ -84,14 +84,14 @@ it('should isolate localStorage and cookies', async function({browser, server}) expect(browser.contexts().length).toBe(0); }); -it('should propagate default viewport to the page', async({ browser }) => { +it('should propagate default viewport to the page', async ({ browser }) => { const context = await browser.newContext({ viewport: { width: 456, height: 789 } }); const page = await context.newPage(); await utils.verifyViewport(page, 456, 789); await context.close(); }); -it('should make a copy of default viewport', async({ browser }) => { +it('should make a copy of default viewport', async ({ browser }) => { const viewport = { width: 456, height: 789 }; const context = await browser.newContext({ viewport }); viewport.width = 567; @@ -100,37 +100,37 @@ it('should make a copy of default viewport', async({ browser }) => { await context.close(); }); -it('should respect deviceScaleFactor', async({ browser }) => { +it('should respect deviceScaleFactor', async ({ browser }) => { const context = await browser.newContext({ deviceScaleFactor: 3 }); const page = await context.newPage(); expect(await page.evaluate('window.devicePixelRatio')).toBe(3); await context.close(); }); -it('should not allow deviceScaleFactor with null viewport', async({ browser }) => { +it('should not allow deviceScaleFactor with null viewport', async ({ browser }) => { const error = await browser.newContext({ viewport: null, deviceScaleFactor: 1 }).catch(e => e); expect(error.message).toContain('"deviceScaleFactor" option is not supported with null "viewport"'); }); -it('should not allow isMobile with null viewport', async({ browser }) => { +it('should not allow isMobile with null viewport', async ({ browser }) => { const error = await browser.newContext({ viewport: null, isMobile: true }).catch(e => e); expect(error.message).toContain('"isMobile" option is not supported with null "viewport"'); }); -it('close() should work for empty context', async({ browser }) => { +it('close() should work for empty context', async ({ browser }) => { const context = await browser.newContext(); await context.close(); }); -it('close() should abort waitForEvent', async({ browser }) => { +it('close() should abort waitForEvent', async ({ browser }) => { const context = await browser.newContext(); const promise = context.waitForEvent('page').catch(e => e); await context.close(); - let error = await promise; + const error = await promise; expect(error.message).toContain('Context closed'); }); -it('close() should be callable twice', async({browser}) => { +it('close() should be callable twice', async ({browser}) => { const context = await browser.newContext(); await Promise.all([ context.close(), @@ -139,7 +139,7 @@ it('close() should be callable twice', async({browser}) => { await context.close(); }); -it('should not report frameless pages on error', async({browser, server}) => { +it('should not report frameless pages on error', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); server.setRoute('/empty.html', (req, res) => { @@ -157,7 +157,7 @@ it('should not report frameless pages on error', async({browser, server}) => { } }); -it('should return all of the pages', async({browser, server}) => { +it('should return all of the pages', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); const second = await context.newPage(); @@ -177,7 +177,7 @@ it('should close all belonging pages once closing context', async function({brow expect(context.pages().length).toBe(0); }); -it('should disable javascript', async({browser}) => { +it('should disable javascript', async ({browser}) => { { const context = await browser.newContext({ javaScriptEnabled: false }); const page = await context.newPage(); @@ -200,14 +200,14 @@ it('should disable javascript', async({browser}) => { } }); -it('should be able to navigate after disabling javascript', async({browser, server}) => { +it('should be able to navigate after disabling javascript', async ({browser, server}) => { const context = await browser.newContext({ javaScriptEnabled: false }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); await context.close(); }); -it('should work with offline option', async({browser, server}) => { +it('should work with offline option', async ({browser, server}) => { const context = await browser.newContext({offline: true}); const page = await context.newPage(); let error = null; @@ -219,7 +219,7 @@ it('should work with offline option', async({browser, server}) => { await context.close(); }); -it('should emulate navigator.onLine', async({browser, server}) => { +it('should emulate navigator.onLine', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); expect(await page.evaluate(() => window.navigator.onLine)).toBe(true); diff --git a/test/browsercontext-clearcookies.spec.ts b/test/browsercontext-clearcookies.spec.ts index 10441460b2..2cd7d86184 100644 --- a/test/browsercontext-clearcookies.spec.ts +++ b/test/browsercontext-clearcookies.spec.ts @@ -17,7 +17,7 @@ import './playwright.fixtures'; -it('should clear cookies', async({context, page, server}) => { +it('should clear cookies', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: server.EMPTY_PAGE, @@ -31,7 +31,7 @@ it('should clear cookies', async({context, page, server}) => { expect(await page.evaluate('document.cookie')).toBe(''); }); -it('should isolate cookies when clearing', async({context, server, browser}) => { +it('should isolate cookies when clearing', async ({context, server, browser}) => { const anotherContext = await browser.newContext(); await context.addCookies([{url: server.EMPTY_PAGE, name: 'page1cookie', value: 'page1value'}]); await anotherContext.addCookies([{url: server.EMPTY_PAGE, name: 'page2cookie', value: 'page2value'}]); diff --git a/test/browsercontext-cookies.spec.ts b/test/browsercontext-cookies.spec.ts index 05c1e4c88b..7c01d72645 100644 --- a/test/browsercontext-cookies.spec.ts +++ b/test/browsercontext-cookies.spec.ts @@ -16,11 +16,11 @@ */ import { options } from './playwright.fixtures'; -it('should return no cookies in pristine browser context', async({context, page, server}) => { +it('should return no cookies in pristine browser context', async ({context, page, server}) => { expect(await context.cookies()).toEqual([]); }); -it('should get a cookie', async({context, page, server}) => { +it('should get a cookie', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); const documentCookie = await page.evaluate(() => { document.cookie = 'username=John Doe'; @@ -39,7 +39,7 @@ it('should get a cookie', async({context, page, server}) => { }]); }); -it('should get a non-session cookie', async({context, page, server}) => { +it('should get a non-session cookie', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); // @see https://en.wikipedia.org/wiki/Year_2038_problem const date = +(new Date('1/1/2038')); @@ -61,7 +61,7 @@ it('should get a non-session cookie', async({context, page, server}) => { }]); }); -it('should properly report httpOnly cookie', async({context, page, server}) => { +it('should properly report httpOnly cookie', async ({context, page, server}) => { server.setRoute('/empty.html', (req, res) => { res.setHeader('Set-Cookie', 'name=value;HttpOnly; Path=/'); res.end(); @@ -72,7 +72,7 @@ it('should properly report httpOnly cookie', async({context, page, server}) => { expect(cookies[0].httpOnly).toBe(true); }); -it.fail(options.WEBKIT && WIN)('should properly report "Strict" sameSite cookie', async({context, page, server}) => { +it.fail(options.WEBKIT && WIN)('should properly report "Strict" sameSite cookie', async ({context, page, server}) => { server.setRoute('/empty.html', (req, res) => { res.setHeader('Set-Cookie', 'name=value;SameSite=Strict'); res.end(); @@ -83,7 +83,7 @@ it.fail(options.WEBKIT && WIN)('should properly report "Strict" sameSite cookie' expect(cookies[0].sameSite).toBe('Strict'); }); -it.fail(options.WEBKIT && WIN)('should properly report "Lax" sameSite cookie', async({context, page, server}) => { +it.fail(options.WEBKIT && WIN)('should properly report "Lax" sameSite cookie', async ({context, page, server}) => { server.setRoute('/empty.html', (req, res) => { res.setHeader('Set-Cookie', 'name=value;SameSite=Lax'); res.end(); @@ -94,7 +94,7 @@ it.fail(options.WEBKIT && WIN)('should properly report "Lax" sameSite cookie', a expect(cookies[0].sameSite).toBe('Lax'); }); -it('should get multiple cookies', async({context, page, server}) => { +it('should get multiple cookies', async ({context, page, server}) => { await page.goto(server.EMPTY_PAGE); const documentCookie = await page.evaluate(() => { document.cookie = 'username=John Doe'; @@ -128,7 +128,7 @@ it('should get multiple cookies', async({context, page, server}) => { ]); }); -it('should get cookies from multiple urls', async({context}) => { +it('should get cookies from multiple urls', async ({context}) => { await context.addCookies([{ url: 'https://foo.com', name: 'doggo', diff --git a/test/browsercontext-credentials.spec.ts b/test/browsercontext-credentials.spec.ts index a3a8341209..2ea2013caf 100644 --- a/test/browsercontext-credentials.spec.ts +++ b/test/browsercontext-credentials.spec.ts @@ -16,7 +16,7 @@ */ import { options } from './playwright.fixtures'; -it.fail(options.CHROMIUM && !options.HEADLESS)('should fail without credentials', async({browser, server}) => { +it.fail(options.CHROMIUM && !options.HEADLESS)('should fail without credentials', async ({browser, server}) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext(); const page = await context.newPage(); @@ -25,7 +25,7 @@ it.fail(options.CHROMIUM && !options.HEADLESS)('should fail without credentials' await context.close(); }); -it.fail(options.CHROMIUM && !options.HEADLESS)('should work with setHTTPCredentials', async({browser, server}) => { +it.fail(options.CHROMIUM && !options.HEADLESS)('should work with setHTTPCredentials', async ({browser, server}) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext(); const page = await context.newPage(); @@ -37,7 +37,7 @@ it.fail(options.CHROMIUM && !options.HEADLESS)('should work with setHTTPCredenti await context.close(); }); -it('should work with correct credentials', async({browser, server}) => { +it('should work with correct credentials', async ({browser, server}) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext({ httpCredentials: { username: 'user', password: 'pass' } @@ -48,7 +48,7 @@ it('should work with correct credentials', async({browser, server}) => { await context.close(); }); -it('should fail with wrong credentials', async({browser, server}) => { +it('should fail with wrong credentials', async ({browser, server}) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext({ httpCredentials: { username: 'foo', password: 'bar' } @@ -59,7 +59,7 @@ it('should fail with wrong credentials', async({browser, server}) => { await context.close(); }); -it('should return resource body', async({browser, server}) => { +it('should return resource body', async ({browser, server}) => { server.setAuth('/playground.html', 'user', 'pass'); const context = await browser.newContext({ httpCredentials: { username: 'user', password: 'pass' } @@ -67,7 +67,7 @@ it('should return resource body', async({browser, server}) => { const page = await context.newPage(); const response = await page.goto(server.PREFIX + '/playground.html'); expect(response.status()).toBe(200); - expect(await page.title()).toBe("Playground"); - expect((await response.body()).toString()).toContain("Playground"); + expect(await page.title()).toBe('Playground'); + expect((await response.body()).toString()).toContain('Playground'); await context.close(); }); diff --git a/test/browsercontext-csp.spec.ts b/test/browsercontext-csp.spec.ts index cdc67a4207..d92e117e38 100644 --- a/test/browsercontext-csp.spec.ts +++ b/test/browsercontext-csp.spec.ts @@ -18,7 +18,7 @@ import './playwright.fixtures'; import * as utils from './utils'; -it('should bypass CSP meta tag', async({browser, server}) => { +it('should bypass CSP meta tag', async ({browser, server}) => { // Make sure CSP prohibits addScriptTag. { const context = await browser.newContext(); @@ -40,7 +40,7 @@ it('should bypass CSP meta tag', async({browser, server}) => { } }); -it('should bypass CSP header', async({browser, server}) => { +it('should bypass CSP header', async ({browser, server}) => { // Make sure CSP prohibits addScriptTag. server.setCSP('/empty.html', 'default-src "self"'); @@ -64,7 +64,7 @@ it('should bypass CSP header', async({browser, server}) => { } }); -it('should bypass after cross-process navigation', async({browser, server}) => { +it('should bypass after cross-process navigation', async ({browser, server}) => { const context = await browser.newContext({ bypassCSP: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/csp.html'); @@ -77,7 +77,7 @@ it('should bypass after cross-process navigation', async({browser, server}) => { await context.close(); }); -it('should bypass CSP in iframes as well', async({browser, server}) => { +it('should bypass CSP in iframes as well', async ({browser, server}) => { // Make sure CSP prohibits addScriptTag in an iframe. { const context = await browser.newContext(); diff --git a/test/browsercontext-device.spec.ts b/test/browsercontext-device.spec.ts index 7d48c5e14e..63c4073951 100644 --- a/test/browsercontext-device.spec.ts +++ b/test/browsercontext-device.spec.ts @@ -16,7 +16,7 @@ */ import { options } from './playwright.fixtures'; -it.skip(options.FIREFOX)('should work', async({playwright, browser, server}) => { +it.skip(options.FIREFOX)('should work', async ({playwright, browser, server}) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -26,7 +26,7 @@ it.skip(options.FIREFOX)('should work', async({playwright, browser, server}) => await context.close(); }); -it.skip(options.FIREFOX)('should support clicking', async({playwright, browser, server}) => { +it.skip(options.FIREFOX)('should support clicking', async ({playwright, browser, server}) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -38,7 +38,7 @@ it.skip(options.FIREFOX)('should support clicking', async({playwright, browser, await context.close(); }); -it.skip(options.FIREFOX)('should scroll to click', async({browser, server}) => { +it.skip(options.FIREFOX)('should scroll to click', async ({browser, server}) => { const context = await browser.newContext({ viewport: { width: 400, diff --git a/test/browsercontext-expose-function.spec.ts b/test/browsercontext-expose-function.spec.ts index f506fe9a49..0329521476 100644 --- a/test/browsercontext-expose-function.spec.ts +++ b/test/browsercontext-expose-function.spec.ts @@ -16,7 +16,7 @@ */ import './playwright.fixtures'; -it('expose binding should work', async({browser}) => { +it('expose binding should work', async ({browser}) => { const context = await browser.newContext(); let bindingSource; await context.exposeBinding('add', (source, a, b) => { @@ -32,7 +32,7 @@ it('expose binding should work', async({browser}) => { await context.close(); }); -it('should work', async({browser, server}) => { +it('should work', async ({browser, server}) => { const context = await browser.newContext(); await context.exposeFunction('add', (a, b) => a + b); const page = await context.newPage(); @@ -47,7 +47,7 @@ it('should work', async({browser, server}) => { await context.close(); }); -it('should throw for duplicate registrations', async({browser, server}) => { +it('should throw for duplicate registrations', async ({browser, server}) => { const context = await browser.newContext(); await context.exposeFunction('foo', () => {}); await context.exposeFunction('bar', () => {}); @@ -62,7 +62,7 @@ it('should throw for duplicate registrations', async({browser, server}) => { await context.close(); }); -it('should be callable from-inside addInitScript', async({browser, server}) => { +it('should be callable from-inside addInitScript', async ({browser, server}) => { const context = await browser.newContext(); let args = []; await context.exposeFunction('woof', function(arg) { diff --git a/test/browsercontext-locale.spec.ts b/test/browsercontext-locale.spec.ts index e7974c5a76..27646c60bb 100644 --- a/test/browsercontext-locale.spec.ts +++ b/test/browsercontext-locale.spec.ts @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { options } from './playwright.fixtures'; +import './playwright.fixtures'; -it('should affect accept-language header', async({browser, server}) => { +it('should affect accept-language header', async ({browser, server}) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); const [request] = await Promise.all([ @@ -27,14 +27,14 @@ it('should affect accept-language header', async({browser, server}) => { await context.close(); }); -it('should affect navigator.language', async({browser, server}) => { +it('should affect navigator.language', async ({browser, server}) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); expect(await page.evaluate(() => navigator.language)).toBe('fr-CH'); await context.close(); }); -it('should format number', async({browser, server}) => { +it('should format number', async ({browser, server}) => { { const context = await browser.newContext({ locale: 'en-US' }); const page = await context.newPage(); @@ -51,7 +51,7 @@ it('should format number', async({browser, server}) => { } }); -it('should format date', async({browser, server}) => { +it('should format date', async ({browser, server}) => { { const context = await browser.newContext({ locale: 'en-US', timezoneId: 'America/Los_Angeles' }); const page = await context.newPage(); @@ -70,7 +70,7 @@ it('should format date', async({browser, server}) => { } }); -it('should format number in popups', async({browser, server}) => { +it('should format number in popups', async ({browser, server}) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -85,7 +85,7 @@ it('should format number in popups', async({browser, server}) => { await context.close(); }); -it('should affect navigator.language in popups', async({browser, server}) => { +it('should affect navigator.language in popups', async ({browser, server}) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -99,7 +99,7 @@ it('should affect navigator.language in popups', async({browser, server}) => { await context.close(); }); -it('should work for multiple pages sharing same process', async({browser, server}) => { +it('should work for multiple pages sharing same process', async ({browser, server}) => { const context = await browser.newContext({ locale: 'ru-RU' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -114,11 +114,11 @@ it('should work for multiple pages sharing same process', async({browser, server await context.close(); }); -it('should be isolated between contexts', async({browser, server}) => { +it('should be isolated between contexts', async ({browser, server}) => { const context1 = await browser.newContext({ locale: 'en-US' }); const promises = []; // By default firefox limits number of child web processes to 8. - for (let i = 0; i< 8; i++) + for (let i = 0; i < 8; i++) promises.push(context1.newPage()); await Promise.all(promises); @@ -137,7 +137,7 @@ it('should be isolated between contexts', async({browser, server}) => { ]); }); -it('should not change default locale in another context', async({browser, server}) => { +it('should not change default locale in another context', async ({browser, server}) => { async function getContextLocale(context) { const page = await context.newPage(); return await page.evaluate(() => (new Intl.NumberFormat()).resolvedOptions().locale); diff --git a/test/browsercontext-page-event.spec.ts b/test/browsercontext-page-event.spec.ts index e8aa8c7657..d64f3b06ed 100644 --- a/test/browsercontext-page-event.spec.ts +++ b/test/browsercontext-page-event.spec.ts @@ -16,7 +16,7 @@ */ import { options } from './playwright.fixtures'; -it('should have url', async({browser, server}) => { +it('should have url', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -27,7 +27,7 @@ it('should have url', async({browser, server}) => { await context.close(); }); -it('should have url after domcontentloaded', async({browser, server}) => { +it('should have url after domcontentloaded', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -39,7 +39,7 @@ it('should have url after domcontentloaded', async({browser, server}) => { await context.close(); }); -it('should have about:blank url with domcontentloaded', async({browser, server}) => { +it('should have about:blank url with domcontentloaded', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -51,7 +51,7 @@ it('should have about:blank url with domcontentloaded', async({browser, server}) await context.close(); }); -it('should have about:blank for empty url with domcontentloaded', async({browser, server}) => { +it('should have about:blank for empty url with domcontentloaded', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -63,7 +63,7 @@ it('should have about:blank for empty url with domcontentloaded', async({browser await context.close(); }); -it('should report when a new page is created and closed', async({browser, server}) => { +it('should report when a new page is created and closed', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -90,7 +90,7 @@ it('should report when a new page is created and closed', async({browser, server await context.close(); }); -it('should report initialized pages', async({browser, server}) => { +it('should report initialized pages', async ({browser, server}) => { const context = await browser.newContext(); const pagePromise = context.waitForEvent('page'); context.newPage(); @@ -105,7 +105,7 @@ it('should report initialized pages', async({browser, server}) => { await context.close(); }); -it('should not crash while redirecting of original request was missed', async({browser, server}) => { +it('should not crash while redirecting of original request was missed', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); let serverResponse = null; @@ -125,7 +125,7 @@ it('should not crash while redirecting of original request was missed', async({b await context.close(); }); -it('should have an opener', async({browser, server}) => { +it('should have an opener', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -156,7 +156,7 @@ it('should fire page lifecycle events', async function({browser, server}) { await context.close(); }); -it.fixme(options.WEBKIT)('should work with Shift-clicking', async({browser, server}) => { +it.fixme(options.WEBKIT)('should work with Shift-clicking', async ({browser, server}) => { // WebKit: Shift+Click does not open a new window. const context = await browser.newContext(); const page = await context.newPage(); @@ -170,7 +170,7 @@ it.fixme(options.WEBKIT)('should work with Shift-clicking', async({browser, serv await context.close(); }); -it.fixme(options.WEBKIT || options.FIREFOX)('should work with Ctrl-clicking', async({browser, server}) => { +it.fixme(options.WEBKIT || options.FIREFOX)('should work with Ctrl-clicking', async ({browser, server}) => { // Firefox: reports an opener in this case. // WebKit: Ctrl+Click does not open a new tab. const context = await browser.newContext(); diff --git a/test/browsercontext-route.spec.ts b/test/browsercontext-route.spec.ts index 0fbbd2e8d0..47b73dacaa 100644 --- a/test/browsercontext-route.spec.ts +++ b/test/browsercontext-route.spec.ts @@ -16,7 +16,7 @@ */ import './playwright.fixtures'; -it('should intercept', async({browser, server}) => { +it('should intercept', async ({browser, server}) => { const context = await browser.newContext(); let intercepted = false; await context.route('**/empty.html', route => { @@ -39,7 +39,7 @@ it('should intercept', async({browser, server}) => { await context.close(); }); -it('should unroute', async({browser, server}) => { +it('should unroute', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); @@ -77,7 +77,7 @@ it('should unroute', async({browser, server}) => { await context.close(); }); -it('should yield to page.route', async({browser, server}) => { +it('should yield to page.route', async ({browser, server}) => { const context = await browser.newContext(); await context.route('**/empty.html', route => { route.fulfill({ status: 200, body: 'context' }); @@ -92,7 +92,7 @@ it('should yield to page.route', async({browser, server}) => { await context.close(); }); -it('should fall back to context.route', async({browser, server}) => { +it('should fall back to context.route', async ({browser, server}) => { const context = await browser.newContext(); await context.route('**/empty.html', route => { route.fulfill({ status: 200, body: 'context' }); diff --git a/test/browsercontext-timezone-id.spec.ts b/test/browsercontext-timezone-id.spec.ts index 7bc4c71b8b..84b61fc393 100644 --- a/test/browsercontext-timezone-id.spec.ts +++ b/test/browsercontext-timezone-id.spec.ts @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { options } from './playwright.fixtures'; +import './playwright.fixtures'; it('should work', async ({ browser }) => { const func = () => new Date(1479579154987).toString(); @@ -44,17 +44,17 @@ it('should work', async ({ browser }) => { } }); -it('should throw for invalid timezone IDs when creating pages', async({browser}) => { +it('should throw for invalid timezone IDs when creating pages', async ({browser}) => { for (const timezoneId of ['Foo/Bar', 'Baz/Qux']) { let error = null; const context = await browser.newContext({ timezoneId }); - const page = await context.newPage().catch(e => error = e); + await context.newPage().catch(e => error = e); expect(error.message).toContain(`Invalid timezone ID: ${timezoneId}`); await context.close(); } }); -it('should work for multiple pages sharing same process', async({browser, server}) => { +it('should work for multiple pages sharing same process', async ({browser, server}) => { const context = await browser.newContext({ timezoneId: 'Europe/Moscow' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -69,7 +69,7 @@ it('should work for multiple pages sharing same process', async({browser, server await context.close(); }); -it('should not change default timezone in another context', async({browser, server}) => { +it('should not change default timezone in another context', async ({browser, server}) => { async function getContextTimezone(context) { const page = await context.newPage(); return await page.evaluate(() => Intl.DateTimeFormat().resolvedOptions().timeZone); diff --git a/test/browsercontext-user-agent.spec.ts b/test/browsercontext-user-agent.spec.ts index 22dd11b63f..e964eb3693 100644 --- a/test/browsercontext-user-agent.spec.ts +++ b/test/browsercontext-user-agent.spec.ts @@ -18,7 +18,7 @@ import './playwright.fixtures'; import utils from './utils'; -it('should work', async({browser, server}) => { +it('should work', async ({browser, server}) => { { const context = await browser.newContext(); const page = await context.newPage(); @@ -37,7 +37,7 @@ it('should work', async({browser, server}) => { } }); -it('should work for subframes', async({browser, server}) => { +it('should work for subframes', async ({browser, server}) => { { const context = await browser.newContext(); const page = await context.newPage(); @@ -56,7 +56,7 @@ it('should work for subframes', async({browser, server}) => { } }); -it('should emulate device user-agent', async({browser, server, playwright}) => { +it('should emulate device user-agent', async ({browser, server, playwright}) => { { const context = await browser.newContext(); const page = await context.newPage(); @@ -73,7 +73,7 @@ it('should emulate device user-agent', async({browser, server, playwright}) => { } }); -it('should make a copy of default options', async({browser, server}) => { +it('should make a copy of default options', async ({browser, server}) => { const options = { userAgent: 'foobar' }; const context = await browser.newContext(options); options.userAgent = 'wrong'; diff --git a/test/browsercontext-viewport-mobile.spec.ts b/test/browsercontext-viewport-mobile.spec.ts index 736e465e83..dd14e29b25 100644 --- a/test/browsercontext-viewport-mobile.spec.ts +++ b/test/browsercontext-viewport-mobile.spec.ts @@ -17,7 +17,7 @@ import { options } from './playwright.fixtures'; -it.skip(options.FIREFOX)('should support mobile emulation', async({playwright, browser, server}) => { +it.skip(options.FIREFOX)('should support mobile emulation', async ({playwright, browser, server}) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -28,7 +28,7 @@ it.skip(options.FIREFOX)('should support mobile emulation', async({playwright, b await context.close(); }); -it.skip(options.FIREFOX)('should support touch emulation', async({playwright, browser, server}) => { +it.skip(options.FIREFOX)('should support touch emulation', async ({playwright, browser, server}) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -51,7 +51,7 @@ it.skip(options.FIREFOX)('should support touch emulation', async({playwright, br } }); -it.skip(options.FIREFOX)('should be detectable by Modernizr', async({playwright, browser, server}) => { +it.skip(options.FIREFOX)('should be detectable by Modernizr', async ({playwright, browser, server}) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -60,7 +60,7 @@ it.skip(options.FIREFOX)('should be detectable by Modernizr', async({playwright, await context.close(); }); -it.skip(options.FIREFOX)('should detect touch when applying viewport with touches', async({browser, server}) => { +it.skip(options.FIREFOX)('should detect touch when applying viewport with touches', async ({browser, server}) => { const context = await browser.newContext({ viewport: { width: 800, height: 600 }, hasTouch: true }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -69,7 +69,7 @@ it.skip(options.FIREFOX)('should detect touch when applying viewport with touche await context.close(); }); -it.skip(options.FIREFOX)('should support landscape emulation', async({playwright, browser, server}) => { +it.skip(options.FIREFOX)('should support landscape emulation', async ({playwright, browser, server}) => { const iPhone = playwright.devices['iPhone 6']; const iPhoneLandscape = playwright.devices['iPhone 6 landscape']; const context1 = await browser.newContext({ ...iPhone }); @@ -83,7 +83,7 @@ it.skip(options.FIREFOX)('should support landscape emulation', async({playwright await context2.close(); }); -it.skip(options.FIREFOX)('should support window.orientation emulation', async({browser, server}) => { +it.skip(options.FIREFOX)('should support window.orientation emulation', async ({browser, server}) => { const context = await browser.newContext({ viewport: { width: 300, height: 400 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); @@ -93,7 +93,7 @@ it.skip(options.FIREFOX)('should support window.orientation emulation', async({b await context.close(); }); -it.skip(options.FIREFOX)('should fire orientationchange event', async({browser, server}) => { +it.skip(options.FIREFOX)('should fire orientationchange event', async ({browser, server}) => { const context = await browser.newContext({ viewport: { width: 300, height: 400 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); @@ -112,7 +112,7 @@ it.skip(options.FIREFOX)('should fire orientationchange event', async({browser, await context.close(); }); -it.skip(options.FIREFOX)('default mobile viewports to 980 width', async({browser, server}) => { +it.skip(options.FIREFOX)('default mobile viewports to 980 width', async ({browser, server}) => { const context = await browser.newContext({ viewport: {width: 320, height: 480 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/empty.html'); @@ -120,7 +120,7 @@ it.skip(options.FIREFOX)('default mobile viewports to 980 width', async({browser await context.close(); }); -it.skip(options.FIREFOX)('respect meta viewport tag', async({browser, server}) => { +it.skip(options.FIREFOX)('respect meta viewport tag', async ({browser, server}) => { const context = await browser.newContext({ viewport: {width: 320, height: 480 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); diff --git a/test/browsercontext-viewport.spec.ts b/test/browsercontext-viewport.spec.ts index 0bb42bc3a3..dcf175b7a7 100644 --- a/test/browsercontext-viewport.spec.ts +++ b/test/browsercontext-viewport.spec.ts @@ -18,17 +18,17 @@ import './playwright.fixtures'; import utils from './utils'; -it('should get the proper default viewport size', async({page, server}) => { +it('should get the proper default viewport size', async ({page, server}) => { await utils.verifyViewport(page, 1280, 720); }); -it('should set the proper viewport size', async({page, server}) => { +it('should set the proper viewport size', async ({page, server}) => { await utils.verifyViewport(page, 1280, 720); await page.setViewportSize({width: 123, height: 456}); await utils.verifyViewport(page, 123, 456); }); -it('should return correct outerWidth and outerHeight', async({page}) => { +it('should return correct outerWidth and outerHeight', async ({page}) => { const size = await page.evaluate(() => { return { innerWidth: window.innerWidth, @@ -43,7 +43,7 @@ it('should return correct outerWidth and outerHeight', async({page}) => { expect(size.outerHeight >= size.innerHeight).toBeTruthy(); }); -it('should emulate device width', async({page, server}) => { +it('should emulate device width', async ({page, server}) => { expect(page.viewportSize()).toEqual({width: 1280, height: 720}); await page.setViewportSize({width: 200, height: 200}); expect(await page.evaluate(() => window.screen.width)).toBe(200); @@ -63,7 +63,7 @@ it('should emulate device width', async({page, server}) => { expect(await page.evaluate(() => matchMedia('(device-width: 500px)').matches)).toBe(true); }); -it('should emulate device height', async({page, server}) => { +it('should emulate device height', async ({page, server}) => { expect(page.viewportSize()).toEqual({width: 1280, height: 720}); await page.setViewportSize({width: 200, height: 200}); expect(await page.evaluate(() => window.screen.height)).toBe(200); @@ -83,14 +83,14 @@ it('should emulate device height', async({page, server}) => { expect(await page.evaluate(() => matchMedia('(device-height: 500px)').matches)).toBe(true); }); -it('should not have touch by default', async({page, server}) => { +it('should not have touch by default', async ({page, server}) => { await page.goto(server.PREFIX + '/mobile.html'); expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false); await page.goto(server.PREFIX + '/detect-touch.html'); expect(await page.evaluate(() => document.body.textContent.trim())).toBe('NO'); }); -it('should support touch with null viewport', async({browser, server}) => { +it('should support touch with null viewport', async ({browser, server}) => { const context = await browser.newContext({ viewport: null, hasTouch: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); @@ -98,7 +98,7 @@ it('should support touch with null viewport', async({browser, server}) => { await context.close(); }); -it('should report null viewportSize when given null viewport', async({browser, server}) => { +it('should report null viewportSize when given null viewport', async ({browser, server}) => { const context = await browser.newContext({ viewport: null }); const page = await context.newPage(); expect(page.viewportSize()).toBe(null); diff --git a/test/browsertype-basic.spec.ts b/test/browsertype-basic.spec.ts index 73229bc990..258b5e8e05 100644 --- a/test/browsertype-basic.spec.ts +++ b/test/browsertype-basic.spec.ts @@ -18,13 +18,13 @@ import fs from 'fs'; import { options } from './playwright.fixtures'; -it.skip(Boolean(process.env.CRPATH || process.env.FFPATH || process.env.WKPATH))('browserType.executablePath should work', async({browserType}) => { +it.skip(Boolean(process.env.CRPATH || process.env.FFPATH || process.env.WKPATH))('browserType.executablePath should work', async ({browserType}) => { const executablePath = browserType.executablePath(); expect(fs.existsSync(executablePath)).toBe(true); expect(fs.realpathSync(executablePath)).toBe(executablePath); }); -it('browserType.name should work', async({browserType}) => { +it('browserType.name should work', async ({browserType}) => { if (options.WEBKIT) expect(browserType.name()).toBe('webkit'); else if (options.FIREFOX) diff --git a/test/browsertype-connect.spec.ts b/test/browsertype-connect.spec.ts index 8bd117dc83..bc4a8b0783 100644 --- a/test/browsertype-connect.spec.ts +++ b/test/browsertype-connect.spec.ts @@ -19,7 +19,7 @@ import { options } from './playwright.fixtures'; import utils from './utils'; import './remoteServer.fixture'; -it.skip(options.WIRE).slow()('should be able to reconnect to a browser', async({browserType, remoteServer, server}) => { +it.skip(options.WIRE).slow()('should be able to reconnect to a browser', async ({browserType, remoteServer, server}) => { { const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const browserContext = await browser.newContext(); @@ -81,8 +81,8 @@ it.skip(options.WIRE).slow()('disconnected event should be emitted when browser expect(disconnected2).toBe(1); }); -it.skip(options.WIRE).slow()('should handle exceptions during connect', async({browserType, remoteServer}) => { - const __testHookBeforeCreateBrowser = () => { throw new Error('Dummy') }; +it.skip(options.WIRE).slow()('should handle exceptions during connect', async ({browserType, remoteServer}) => { + const __testHookBeforeCreateBrowser = () => { throw new Error('Dummy'); }; const error = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint(), __testHookBeforeCreateBrowser } as any).catch(e => e); expect(error.message).toContain('Dummy'); }); @@ -94,7 +94,7 @@ it.skip(options.WIRE).slow()('should set the browser connected state', async ({b expect(remote.isConnected()).toBe(false); }); -it.skip(options.WIRE).slow()('should throw when used after isConnected returns false', async({browserType, remoteServer}) => { +it.skip(options.WIRE).slow()('should throw when used after isConnected returns false', async ({browserType, remoteServer}) => { const remote = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await remote.newPage(); await Promise.all([ @@ -106,7 +106,7 @@ it.skip(options.WIRE).slow()('should throw when used after isConnected returns f expect(error.message).toContain('has been closed'); }); -it.skip(options.WIRE).slow()('should reject navigation when browser closes', async({browserType, remoteServer, server}) => { +it.skip(options.WIRE).slow()('should reject navigation when browser closes', async ({browserType, remoteServer, server}) => { server.setRoute('/one-style.css', () => {}); const remote = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await remote.newPage(); @@ -117,7 +117,7 @@ it.skip(options.WIRE).slow()('should reject navigation when browser closes', asy expect(error.message).toContain('Navigation failed because page was closed!'); }); -it.skip(options.WIRE).slow()('should reject waitForSelector when browser closes', async({browserType, remoteServer, server}) => { +it.skip(options.WIRE).slow()('should reject waitForSelector when browser closes', async ({browserType, remoteServer, server}) => { server.setRoute('/empty.html', () => {}); const remote = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await remote.newPage(); @@ -131,7 +131,7 @@ it.skip(options.WIRE).slow()('should reject waitForSelector when browser closes' expect(error.message).toContain('Protocol error'); }); -it.skip(options.WIRE).slow()('should emit close events on pages and contexts', async({browserType, remoteServer}) => { +it.skip(options.WIRE).slow()('should emit close events on pages and contexts', async ({browserType, remoteServer}) => { const remote = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const context = await remote.newContext(); const page = await context.newPage(); @@ -144,7 +144,7 @@ it.skip(options.WIRE).slow()('should emit close events on pages and contexts', a expect(pageClosed).toBeTruthy(); }); -it.skip(options.WIRE).slow()('should terminate network waiters', async({browserType, remoteServer, server}) => { +it.skip(options.WIRE).slow()('should terminate network waiters', async ({browserType, remoteServer, server}) => { const remote = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const newPage = await remote.newPage(); const results = await Promise.all([ @@ -159,7 +159,7 @@ it.skip(options.WIRE).slow()('should terminate network waiters', async({browserT } }); -it.skip(options.WIRE).fail(true).slow()('should respect selectors', async({ playwright, browserType, remoteServer }) => { +it.skip(options.WIRE).fail(true).slow()('should respect selectors', async ({ playwright, browserType, remoteServer }) => { const mycss = () => ({ create(root, target) {}, query(root, selector) { diff --git a/test/browsertype-launch-server.spec.ts b/test/browsertype-launch-server.spec.ts index 98c23f790e..399b10ee6d 100644 --- a/test/browsertype-launch-server.spec.ts +++ b/test/browsertype-launch-server.spec.ts @@ -17,13 +17,13 @@ import { options } from './playwright.fixtures'; -it.skip(options.WIRE)('should work', async({browserType, defaultBrowserOptions}) => { +it.skip(options.WIRE)('should work', async ({browserType, defaultBrowserOptions}) => { const browserServer = await browserType.launchServer(defaultBrowserOptions); expect(browserServer.wsEndpoint()).not.toBe(null); await browserServer.close(); }); -it.skip(options.WIRE)('should fire "close" event during kill', async({browserType, defaultBrowserOptions}) => { +it.skip(options.WIRE)('should fire "close" event during kill', async ({browserType, defaultBrowserOptions}) => { const order = []; const browserServer = await browserType.launchServer(defaultBrowserOptions); const closedPromise = new Promise(f => browserServer.on('close', () => { diff --git a/test/browsertype-launch.spec.ts b/test/browsertype-launch.spec.ts index 6d69b46aae..007d790a7d 100644 --- a/test/browsertype-launch.spec.ts +++ b/test/browsertype-launch.spec.ts @@ -18,7 +18,7 @@ import path from 'path'; import { options } from './playwright.fixtures'; -it('should reject all promises when browser is closed', async({browserType, defaultBrowserOptions}) => { +it('should reject all promises when browser is closed', async ({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch(defaultBrowserOptions); const page = await (await browser.newContext()).newPage(); let error = null; @@ -29,21 +29,21 @@ it('should reject all promises when browser is closed', async({browserType, defa expect(error.message).toContain('Protocol error'); }); -it('should throw if userDataDir option is passed', async({browserType, defaultBrowserOptions}) => { +it('should throw if userDataDir option is passed', async ({browserType, defaultBrowserOptions}) => { let waitError = null; const options = Object.assign({}, defaultBrowserOptions, {userDataDir: 'random-path'}); await browserType.launch(options).catch(e => waitError = e); expect(waitError.message).toContain('launchPersistentContext'); }); -it.skip(options.FIREFOX)('should throw if page argument is passed', async({browserType, defaultBrowserOptions}) => { +it.skip(options.FIREFOX)('should throw if page argument is passed', async ({browserType, defaultBrowserOptions}) => { let waitError = null; const options = Object.assign({}, defaultBrowserOptions, { args: ['http://example.com'] }); await browserType.launch(options).catch(e => waitError = e); expect(waitError.message).toContain('can not specify page'); }); -it.fixme(true)('should reject if launched browser fails immediately', async({browserType, defaultBrowserOptions}) => { +it.fixme(true)('should reject if launched browser fails immediately', async ({browserType, defaultBrowserOptions}) => { // I'm getting ENCONRESET on this one. const options = Object.assign({}, defaultBrowserOptions, {executablePath: path.join(__dirname, 'assets', 'dummy_bad_browser_executable.js')}); let waitError = null; @@ -51,14 +51,14 @@ it.fixme(true)('should reject if launched browser fails immediately', async({bro expect(waitError.message).toContain('== logs =='); }); -it('should reject if executable path is invalid', async({browserType, defaultBrowserOptions}) => { +it('should reject if executable path is invalid', async ({browserType, defaultBrowserOptions}) => { let waitError = null; const options = Object.assign({}, defaultBrowserOptions, {executablePath: 'random-invalid-path'}); await browserType.launch(options).catch(e => waitError = e); expect(waitError.message).toContain('Failed to launch'); }); -it.skip(options.WIRE)('should handle timeout', async({browserType, defaultBrowserOptions}) => { +it.skip(options.WIRE)('should handle timeout', async ({browserType, defaultBrowserOptions}) => { const options = { ...defaultBrowserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) }; const error = await browserType.launch(options).catch(e => e); expect(error.message).toContain(`browserType.launch: Timeout 5000ms exceeded.`); @@ -66,26 +66,26 @@ it.skip(options.WIRE)('should handle timeout', async({browserType, defaultBrowse expect(error.message).toContain(` pid=`); }); -it.skip(options.WIRE)('should handle exception', async({browserType, defaultBrowserOptions}) => { +it.skip(options.WIRE)('should handle exception', async ({browserType, defaultBrowserOptions}) => { const e = new Error('Dummy'); const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 }; const error = await browserType.launch(options).catch(e => e); expect(error.message).toContain('Dummy'); }); -it.skip(options.WIRE)('should report launch log', async({browserType, defaultBrowserOptions}) => { +it.skip(options.WIRE)('should report launch log', async ({browserType, defaultBrowserOptions}) => { const e = new Error('Dummy'); const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 }; const error = await browserType.launch(options).catch(e => e); expect(error.message).toContain(''); }); -it.slow()('should accept objects as options', async({browserType, defaultBrowserOptions}) => { +it.slow()('should accept objects as options', async ({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch({ ...defaultBrowserOptions, process } as any); await browser.close(); }); -it('should fire close event for all contexts', async({browserType, defaultBrowserOptions}) => { +it('should fire close event for all contexts', async ({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch(defaultBrowserOptions); const context = await browser.newContext(); let closed = false; @@ -94,7 +94,7 @@ it('should fire close event for all contexts', async({browserType, defaultBrowse expect(closed).toBe(true); }); -it('should be callable twice', async({browserType, defaultBrowserOptions}) => { +it('should be callable twice', async ({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch(defaultBrowserOptions); await Promise.all([ browser.close(), diff --git a/test/capabilities.spec.ts b/test/capabilities.spec.ts index 4a631d41b0..83b082a3ba 100644 --- a/test/capabilities.spec.ts +++ b/test/capabilities.spec.ts @@ -22,8 +22,8 @@ it.fail(options.WEBKIT && WIN)('Web Assembly should work', async function({page, expect(await page.evaluate('loadTable()')).toBe('42, 83'); }); -it('WebSocket should work', async({page, server}) => { - const value = await page.evaluate((port) => { +it('WebSocket should work', async ({page, server}) => { + const value = await page.evaluate(port => { let cb; const result = new Promise(f => cb = f); const ws = new WebSocket('ws://localhost:' + port + '/ws'); @@ -34,7 +34,7 @@ it('WebSocket should work', async({page, server}) => { expect(value).toBe('incoming'); }); -it('should respect CSP', async({page, server}) => { +it('should respect CSP', async ({page, server}) => { server.setRoute('/empty.html', async (req, res) => { res.setHeader('Content-Security-Policy', `script-src 'unsafe-inline';`); res.end(` @@ -48,7 +48,7 @@ it('should respect CSP', async({page, server}) => { expect(await page.evaluate(() => window['testStatus'])).toBe('SUCCESS'); }); -it.fixme(options.WEBKIT && (WIN || LINUX))('should play video', async({page, asset}) => { +it.fixme(options.WEBKIT && (WIN || LINUX))('should play video', async ({page, asset}) => { // TODO: the test passes on Windows locally but fails on GitHub Action bot, // apparently due to a Media Pack issue in the Windows Server. // Also the test is very flaky on Linux WebKit. diff --git a/test/channels.spec.ts b/test/channels.spec.ts index 4cbc5d202f..eb9c01a7dc 100644 --- a/test/channels.spec.ts +++ b/test/channels.spec.ts @@ -17,11 +17,11 @@ import { options } from './playwright.fixtures'; import type { ChromiumBrowser } from '..'; -it('should work', async({browser}) => { +it('should work', async ({browser}) => { expect(!!browser['_connection']).toBeTruthy(); }); -it('should scope context handles', async({browserType, browser, server}) => { +it('should scope context handles', async ({browserType, browser, server}) => { const GOLDEN_PRECONDITION = { _guid: '', objects: [ @@ -65,7 +65,7 @@ it('should scope context handles', async({browserType, browser, server}) => { await expectScopeState(browser, GOLDEN_PRECONDITION); }); -it.skip(!options.CHROMIUM)('should scope CDPSession handles', async({browserType, browser, server}) => { +it.skip(!options.CHROMIUM)('should scope CDPSession handles', async ({browserType, browser, server}) => { const GOLDEN_PRECONDITION = { _guid: '', objects: [ @@ -102,7 +102,7 @@ it.skip(!options.CHROMIUM)('should scope CDPSession handles', async({browserType await expectScopeState(browserType, GOLDEN_PRECONDITION); }); -it('should scope browser handles', async({browserType, defaultBrowserOptions}) => { +it('should scope browser handles', async ({browserType, defaultBrowserOptions}) => { const GOLDEN_PRECONDITION = { _guid: '', objects: [ diff --git a/test/check.spec.ts b/test/check.spec.ts index 902ff3e7bd..05f4b1afd1 100644 --- a/test/check.spec.ts +++ b/test/check.spec.ts @@ -16,49 +16,49 @@ */ import './playwright.fixtures'; -it('should check the box', async({page}) => { +it('should check the box', async ({page}) => { await page.setContent(``); await page.check('input'); expect(await page.evaluate(() => window['checkbox'].checked)).toBe(true); }); -it('should not check the checked box', async({page}) => { +it('should not check the checked box', async ({page}) => { await page.setContent(``); await page.check('input'); expect(await page.evaluate(() => window['checkbox'].checked)).toBe(true); }); -it('should uncheck the box', async({page}) => { +it('should uncheck the box', async ({page}) => { await page.setContent(``); await page.uncheck('input'); expect(await page.evaluate(() => window['checkbox'].checked)).toBe(false); }); -it('should not uncheck the unchecked box', async({page}) => { +it('should not uncheck the unchecked box', async ({page}) => { await page.setContent(``); await page.uncheck('input'); expect(await page.evaluate(() => window['checkbox'].checked)).toBe(false); }); -it('should check the box by label', async({page}) => { +it('should check the box by label', async ({page}) => { await page.setContent(``); await page.check('label'); expect(await page.evaluate(() => window['checkbox'].checked)).toBe(true); }); -it('should check the box outside label', async({page}) => { +it('should check the box outside label', async ({page}) => { await page.setContent(`
`); await page.check('label'); expect(await page.evaluate(() => window['checkbox'].checked)).toBe(true); }); -it('should check the box inside label w/o id', async({page}) => { +it('should check the box inside label w/o id', async ({page}) => { await page.setContent(``); await page.check('label'); expect(await page.evaluate(() => window['checkbox'].checked)).toBe(true); }); -it('should check radio', async({page}) => { +it('should check radio', async ({page}) => { await page.setContent(` one two @@ -67,7 +67,7 @@ it('should check radio', async({page}) => { expect(await page.evaluate(() => window['two'].checked)).toBe(true); }); -it('should check the box by aria role', async({page}) => { +it('should check the box by aria role', async ({page}) => { await page.setContent(` '); let error = null; await page.evaluate('something').catch(e => error = e); @@ -158,21 +158,21 @@ it('should support javascriptEnabled option', async ({launchPersistent}) => { }); it('should support httpCredentials option', async ({server, launchPersistent}) => { - const {page, context} = await launchPersistent({httpCredentials: { username: 'user', password: 'pass' }}); + const {page} = await launchPersistent({httpCredentials: { username: 'user', password: 'pass' }}); server.setAuth('/playground.html', 'user', 'pass'); const response = await page.goto(server.PREFIX + '/playground.html'); expect(response.status()).toBe(200); }); it('should support offline option', async ({server, launchPersistent}) => { - const {page, context} = await launchPersistent({offline: true}); + const {page} = await launchPersistent({offline: true}); const error = await page.goto(server.EMPTY_PAGE).catch(e => e); expect(error).toBeTruthy(); }); it.skip(true)('should support acceptDownloads option', async ({server, launchPersistent}) => { // TODO: unskip once we support downloads in persistent context. - const {page, context} = await launchPersistent({acceptDownloads: true}); + const {page} = await launchPersistent({acceptDownloads: true}); server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Disposition', 'attachment'); diff --git a/test/defaultbrowsercontext-2.spec.ts b/test/defaultbrowsercontext-2.spec.ts index a7d709536e..f9352ebd25 100644 --- a/test/defaultbrowsercontext-2.spec.ts +++ b/test/defaultbrowsercontext-2.spec.ts @@ -21,36 +21,36 @@ import utils from './utils'; const { removeUserDataDir, makeUserDataDir } = utils; it('should support hasTouch option', async ({server, launchPersistent}) => { - const {page, context} = await launchPersistent({hasTouch: true}); + const {page} = await launchPersistent({hasTouch: true}); await page.goto(server.PREFIX + '/mobile.html'); expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true); }); it.skip(options.FIREFOX)('should work in persistent context', async ({server, launchPersistent}) => { // Firefox does not support mobile. - const {page, context} = await launchPersistent({viewport: {width: 320, height: 480}, isMobile: true}); + const {page} = await launchPersistent({viewport: {width: 320, height: 480}, isMobile: true}); await page.goto(server.PREFIX + '/empty.html'); expect(await page.evaluate(() => window.innerWidth)).toBe(980); }); it('should support colorScheme option', async ({launchPersistent}) => { - const {page, context} = await launchPersistent({colorScheme: 'dark'}); + const {page} = await launchPersistent({colorScheme: 'dark'}); expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(false); expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true); }); it('should support timezoneId option', async ({launchPersistent}) => { - const {page, context} = await launchPersistent({timezoneId: 'America/Jamaica'}); + const {page} = await launchPersistent({timezoneId: 'America/Jamaica'}); expect(await page.evaluate(() => new Date(1479579154987).toString())).toBe('Sat Nov 19 2016 13:12:34 GMT-0500 (Eastern Standard Time)'); }); it('should support locale option', async ({launchPersistent}) => { - const {page, context} = await launchPersistent({locale: 'fr-CH'}); + const {page} = await launchPersistent({locale: 'fr-CH'}); expect(await page.evaluate(() => navigator.language)).toBe('fr-CH'); }); it('should support geolocation and permissions options', async ({server, launchPersistent}) => { - const {page, context} = await launchPersistent({geolocation: {longitude: 10, latitude: 10}, permissions: ['geolocation']}); + const {page} = await launchPersistent({geolocation: {longitude: 10, latitude: 10}, permissions: ['geolocation']}); await page.goto(server.EMPTY_PAGE); const geolocation = await page.evaluate(() => new Promise(resolve => navigator.geolocation.getCurrentPosition(position => { resolve({latitude: position.coords.latitude, longitude: position.coords.longitude}); @@ -59,7 +59,7 @@ it('should support geolocation and permissions options', async ({server, launchP }); it('should support ignoreHTTPSErrors option', async ({httpsServer, launchPersistent}) => { - const {page, context} = await launchPersistent({ignoreHTTPSErrors: true}); + const {page} = await launchPersistent({ignoreHTTPSErrors: true}); let error = null; const response = await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e); expect(error).toBe(null); @@ -67,7 +67,7 @@ it('should support ignoreHTTPSErrors option', async ({httpsServer, launchPersist }); it('should support extraHTTPHeaders option', async ({server, launchPersistent}) => { - const {page, context} = await launchPersistent({extraHTTPHeaders: { foo: 'bar' }}); + const {page} = await launchPersistent({extraHTTPHeaders: { foo: 'bar' }}); const [request] = await Promise.all([ server.waitForRequest('/empty.html'), page.goto(server.EMPTY_PAGE), @@ -76,7 +76,7 @@ it('should support extraHTTPHeaders option', async ({server, launchPersistent}) }); it.flaky(options.CHROMIUM)('should accept userDataDir', async ({launchPersistent, tmpDir}) => { - const {page, context} = await launchPersistent(); + const {context} = await launchPersistent(); // Note: we need an open page to make sure its functional. expect(fs.readdirSync(tmpDir).length).toBeGreaterThan(0); await context.close(); @@ -85,7 +85,7 @@ it.flaky(options.CHROMIUM)('should accept userDataDir', async ({launchPersistent await removeUserDataDir(tmpDir); }); -it.slow()('should restore state from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => { +it.slow()('should restore state from userDataDir', async ({browserType, defaultBrowserOptions, server, launchPersistent}) => { const userDataDir = await makeUserDataDir(); const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions); const page = await browserContext.newPage(); @@ -111,7 +111,7 @@ it.slow()('should restore state from userDataDir', async({browserType, defaultBr await removeUserDataDir(userDataDir2); }); -it.slow()('should restore cookies from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => { +it.slow()('should restore cookies from userDataDir', async ({browserType, defaultBrowserOptions, server, launchPersistent}) => { const userDataDir = await makeUserDataDir(); const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions); const page = await browserContext.newPage(); @@ -142,7 +142,7 @@ it.slow()('should restore cookies from userDataDir', async({browserType, default }); it('should have default URL when launching browser', async ({launchPersistent}) => { - const {page, context} = await launchPersistent(); + const {context} = await launchPersistent(); const urls = context.pages().map(page => page.url()); expect(urls).toEqual(['about:blank']); }); @@ -169,21 +169,21 @@ it.skip(options.WIRE)('should have passed URL when launching with ignoreDefaultA await browserContext.close(); }); -it.skip(options.WIRE)('should handle timeout', async({browserType, defaultBrowserOptions, tmpDir}) => { +it.skip(options.WIRE)('should handle timeout', async ({browserType, defaultBrowserOptions, tmpDir}) => { const options = { ...defaultBrowserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) }; const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e); expect(error.message).toContain(`browserType.launchPersistentContext: Timeout 5000ms exceeded.`); }); -it.skip(options.WIRE)('should handle exception', async({browserType, defaultBrowserOptions, tmpDir}) => { +it.skip(options.WIRE)('should handle exception', async ({browserType, defaultBrowserOptions, tmpDir}) => { const e = new Error('Dummy'); const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; } }; const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e); expect(error.message).toContain('Dummy'); }); -it('should fire close event for a persistent context', async({launchPersistent}) => { - const {page, context} = await launchPersistent(); +it('should fire close event for a persistent context', async ({launchPersistent}) => { + const {context} = await launchPersistent(); let closed = false; context.on('close', () => closed = true); await context.close(); @@ -191,7 +191,7 @@ it('should fire close event for a persistent context', async({launchPersistent}) }); it.skip(!options.CHROMIUM)('coverage should work', async ({server, launchPersistent}) => { - const {page, context} = await launchPersistent(); + const {page} = await launchPersistent(); await page.coverage.startJSCoverage(); await page.goto(server.PREFIX + '/jscoverage/simple.html', { waitUntil: 'load' }); const coverage = await page.coverage.stopJSCoverage(); @@ -201,6 +201,6 @@ it.skip(!options.CHROMIUM)('coverage should work', async ({server, launchPersist }); it.skip(options.CHROMIUM)('coverage should be missing', async ({launchPersistent}) => { - const {page, context} = await launchPersistent(); + const {page} = await launchPersistent(); expect(page.coverage).toBe(null); }); diff --git a/test/dialog.spec.ts b/test/dialog.spec.ts index d5e18e2afd..f5b3e84759 100644 --- a/test/dialog.spec.ts +++ b/test/dialog.spec.ts @@ -17,7 +17,7 @@ import { options } from './playwright.fixtures'; -it('should fire', async({page, server}) => { +it('should fire', async ({page, server}) => { page.on('dialog', dialog => { expect(dialog.type()).toBe('alert'); expect(dialog.defaultValue()).toBe(''); @@ -27,7 +27,7 @@ it('should fire', async({page, server}) => { await page.evaluate(() => alert('yo')); }); -it('should allow accepting prompts', async({page}) => { +it('should allow accepting prompts', async ({page}) => { page.on('dialog', dialog => { expect(dialog.type()).toBe('prompt'); expect(dialog.defaultValue()).toBe('yes.'); @@ -38,7 +38,7 @@ it('should allow accepting prompts', async({page}) => { expect(result).toBe('answer!'); }); -it('should dismiss the prompt', async({page}) => { +it('should dismiss the prompt', async ({page}) => { page.on('dialog', dialog => { dialog.dismiss(); }); @@ -46,7 +46,7 @@ it('should dismiss the prompt', async({page}) => { expect(result).toBe(null); }); -it('should accept the confirm prompt', async({page}) => { +it('should accept the confirm prompt', async ({page}) => { page.on('dialog', dialog => { dialog.accept(); }); @@ -54,7 +54,7 @@ it('should accept the confirm prompt', async({page}) => { expect(result).toBe(true); }); -it('should dismiss the confirm prompt', async({page}) => { +it('should dismiss the confirm prompt', async ({page}) => { page.on('dialog', dialog => { dialog.dismiss(); }); @@ -62,7 +62,7 @@ it('should dismiss the confirm prompt', async({page}) => { expect(result).toBe(false); }); -it.fixme(options.WEBKIT && MAC)('should be able to close context with open alert', async({browser}) => { +it.fixme(options.WEBKIT && MAC)('should be able to close context with open alert', async ({browser}) => { const context = await browser.newContext(); const page = await context.newPage(); const alertPromise = page.waitForEvent('dialog'); diff --git a/test/dispatchevent.spec.ts b/test/dispatchevent.spec.ts index 5698f5e510..d7a5459a0a 100644 --- a/test/dispatchevent.spec.ts +++ b/test/dispatchevent.spec.ts @@ -17,13 +17,13 @@ import { options } from './playwright.fixtures'; import utils from './utils'; -it('should dispatch click event', async({page, server}) => { +it('should dispatch click event', async ({page, server}) => { await page.goto(server.PREFIX + '/input/button.html'); await page.dispatchEvent('button', 'click'); expect(await page.evaluate(() => window['result'])).toBe('Clicked'); }); -it('should dispatch click event properties', async({page, server}) => { +it('should dispatch click event properties', async ({page, server}) => { await page.goto(server.PREFIX + '/input/button.html'); await page.dispatchEvent('button', 'click'); expect(await page.evaluate('bubbles')).toBeTruthy(); @@ -31,7 +31,7 @@ it('should dispatch click event properties', async({page, server}) => { expect(await page.evaluate('composed')).toBeTruthy(); }); -it('should dispatch click svg', async({page}) => { +it('should dispatch click svg', async ({page}) => { await page.setContent(` @@ -41,7 +41,7 @@ it('should dispatch click svg', async({page}) => { expect(await page.evaluate(() => window['__CLICKED'])).toBe(42); }); -it('should dispatch click on a span with an inline element inside', async({page, server}) => { +it('should dispatch click on a span with an inline element inside', async ({page, server}) => { await page.setContent(`
10
'); const tweet = await page.$('.tweet'); const content = await tweet.$eval('.like', node => (node as HTMLElement).innerText); expect(content).toBe('100'); }); -it('should retrieve content from subtree', async({page, server}) => { +it('should retrieve content from subtree', async ({page, server}) => { const htmlContent = '
not-a-child-div
a-child-div
'; await page.setContent(htmlContent); const elementHandle = await page.$('#myId'); @@ -32,7 +32,7 @@ it('should retrieve content from subtree', async({page, server}) => { expect(content).toBe('a-child-div'); }); -it('should throw in case of missing selector', async({page, server}) => { +it('should throw in case of missing selector', async ({page, server}) => { const htmlContent = '
not-a-child-div
'; await page.setContent(htmlContent); const elementHandle = await page.$('#myId'); @@ -40,14 +40,14 @@ it('should throw in case of missing selector', async({page, server}) => { expect(errorMessage).toContain(`Error: failed to find element matching selector ".a"`); }); -it('should work for all', async({page, server}) => { +it('should work for all', async ({page, server}) => { await page.setContent('
'); const tweet = await page.$('.tweet'); const content = await tweet.$$eval('.like', nodes => nodes.map(n => (n as HTMLElement).innerText)); expect(content).toEqual(['100', '10']); }); -it('should retrieve content from subtree for all', async({page, server}) => { +it('should retrieve content from subtree for all', async ({page, server}) => { const htmlContent = '
not-a-child-div
a1-child-div
a2-child-div
'; await page.setContent(htmlContent); const elementHandle = await page.$('#myId'); @@ -55,7 +55,7 @@ it('should retrieve content from subtree for all', async({page, server}) => { expect(content).toEqual(['a1-child-div', 'a2-child-div']); }); -it('should not throw in case of missing selector for all', async({page, server}) => { +it('should not throw in case of missing selector for all', async ({page, server}) => { const htmlContent = '
not-a-child-div
'; await page.setContent(htmlContent); const elementHandle = await page.$('#myId'); diff --git a/test/elementhandle-owner-frame.spec.ts b/test/elementhandle-owner-frame.spec.ts index 7d4ae67148..0dc05f66bf 100644 --- a/test/elementhandle-owner-frame.spec.ts +++ b/test/elementhandle-owner-frame.spec.ts @@ -78,7 +78,7 @@ it('should work for adopted elements', async ({ page, server }) => { await page.goto(server.EMPTY_PAGE); const [popup] = await Promise.all([ page.waitForEvent('popup'), - page.evaluate(url => window["__popup"] = window.open(url), server.EMPTY_PAGE), + page.evaluate(url => window['__popup'] = window.open(url), server.EMPTY_PAGE), ]); const divHandle = await page.evaluateHandle(() => { const div = document.createElement('div'); @@ -89,7 +89,7 @@ it('should work for adopted elements', async ({ page, server }) => { await popup.waitForLoadState('domcontentloaded'); await page.evaluate(() => { const div = document.querySelector('div'); - window["__popup"].document.body.appendChild(div); + window['__popup'].document.body.appendChild(div); }); expect(await divHandle.ownerFrame()).toBe(popup.mainFrame()); }); diff --git a/test/elementhandle-query-selector.spec.ts b/test/elementhandle-query-selector.spec.ts index 32fca4ee6c..19fe10d453 100644 --- a/test/elementhandle-query-selector.spec.ts +++ b/test/elementhandle-query-selector.spec.ts @@ -17,7 +17,7 @@ import './playwright.fixtures'; -it('should query existing element', async({page, server}) => { +it('should query existing element', async ({page, server}) => { await page.goto(server.PREFIX + '/playground.html'); await page.setContent('
A
'); const html = await page.$('html'); @@ -27,18 +27,18 @@ it('should query existing element', async({page, server}) => { expect(content).toBe('A'); }); -it('should return null for non-existing element', async({page, server}) => { +it('should return null for non-existing element', async ({page, server}) => { await page.setContent('
B
'); const html = await page.$('html'); const second = await html.$('.third'); expect(second).toBe(null); }); -it('should work for adopted elements', async({page,server}) => { +it('should work for adopted elements', async ({page,server}) => { await page.goto(server.EMPTY_PAGE); const [popup] = await Promise.all([ page.waitForEvent('popup'), - page.evaluate(url => window["__popup"] = window.open(url), server.EMPTY_PAGE), + page.evaluate(url => window['__popup'] = window.open(url), server.EMPTY_PAGE), ]); const divHandle = await page.evaluateHandle(() => { const div = document.createElement('div'); @@ -54,13 +54,13 @@ it('should work for adopted elements', async({page,server}) => { await popup.waitForLoadState('domcontentloaded'); await page.evaluate(() => { const div = document.querySelector('div'); - window["__popup"].document.body.appendChild(div); + window['__popup'].document.body.appendChild(div); }); expect(await divHandle.$('span')).toBeTruthy(); expect(await divHandle.$eval('span', e => e.textContent)).toBe('hello'); }); -it('should query existing elements', async({page, server}) => { +it('should query existing elements', async ({page, server}) => { await page.setContent('
A

B
'); const html = await page.$('html'); const elements = await html.$$('div'); @@ -69,7 +69,7 @@ it('should query existing elements', async({page, server}) => { expect(await Promise.all(promises)).toEqual(['A', 'B']); }); -it('should return empty array for non-existing elements', async({page, server}) => { +it('should return empty array for non-existing elements', async ({page, server}) => { await page.setContent('A
B'); const html = await page.$('html'); const elements = await html.$$('div'); @@ -77,7 +77,7 @@ it('should return empty array for non-existing elements', async({page, server}) }); -it('xpath should query existing element', async({page, server}) => { +it('xpath should query existing element', async ({page, server}) => { await page.goto(server.PREFIX + '/playground.html'); await page.setContent('
A
'); const html = await page.$('html'); @@ -87,7 +87,7 @@ it('xpath should query existing element', async({page, server}) => { expect(content).toBe('A'); }); -it('xpath should return null for non-existing element', async({page, server}) => { +it('xpath should return null for non-existing element', async ({page, server}) => { await page.setContent('
B
'); const html = await page.$('html'); const second = await html.$$(`xpath=/div[contains(@class, 'third')]`); diff --git a/test/elementhandle-screenshot.spec.ts b/test/elementhandle-screenshot.spec.ts index 90659839e5..0a6916541e 100644 --- a/test/elementhandle-screenshot.spec.ts +++ b/test/elementhandle-screenshot.spec.ts @@ -24,7 +24,7 @@ import fs from 'fs'; // Firefox headful produces a different image. const ffheadful = options.FIREFOX && !options.HEADLESS; -it.skip(ffheadful)('should work', async({page, server, golden}) => { +it.skip(ffheadful)('should work', async ({page, server, golden}) => { await page.setViewportSize({width: 500, height: 500}); await page.goto(server.PREFIX + '/grid.html'); await page.evaluate(() => window.scrollBy(50, 100)); @@ -33,7 +33,7 @@ it.skip(ffheadful)('should work', async({page, server, golden}) => { expect(screenshot).toMatchImage(golden('screenshot-element-bounding-box.png')); }); -it.skip(ffheadful)('should take into account padding and border', async({page, golden}) => { +it.skip(ffheadful)('should take into account padding and border', async ({page, golden}) => { await page.setViewportSize({width: 500, height: 500}); await page.setContent(`
oooo
@@ -51,7 +51,7 @@ it.skip(ffheadful)('should take into account padding and border', async({page, g expect(screenshot).toMatchImage(golden('screenshot-element-padding-border.png')); }); -it.skip(ffheadful)('should capture full element when larger than viewport in parallel', async({page, golden}) => { +it.skip(ffheadful)('should capture full element when larger than viewport in parallel', async ({page, golden}) => { await page.setViewportSize({width: 500, height: 500}); await page.setContent(` @@ -79,7 +79,7 @@ it.skip(ffheadful)('should capture full element when larger than viewport in par await utils.verifyViewport(page, 500, 500); }); -it.skip(ffheadful)('should capture full element when larger than viewport', async({page, golden}) => { +it.skip(ffheadful)('should capture full element when larger than viewport', async ({page, golden}) => { await page.setViewportSize({width: 500, height: 500}); await page.setContent(` @@ -106,7 +106,7 @@ it.skip(ffheadful)('should capture full element when larger than viewport', asyn await utils.verifyViewport(page, 500, 500); }); -it.skip(ffheadful)('should scroll element into view', async({page, golden}) => { +it.skip(ffheadful)('should scroll element into view', async ({page, golden}) => { await page.setViewportSize({width: 500, height: 500}); await page.setContent(`
oooo
@@ -130,7 +130,7 @@ it.skip(ffheadful)('should scroll element into view', async({page, golden}) => { expect(screenshot).toMatchImage(golden('screenshot-element-scrolled-into-view.png')); }); -it.skip(ffheadful)('should scroll 15000px into view', async({page, golden}) => { +it.skip(ffheadful)('should scroll 15000px into view', async ({page, golden}) => { await page.setViewportSize({width: 500, height: 500}); await page.setContent(`
oooo
@@ -154,7 +154,7 @@ it.skip(ffheadful)('should scroll 15000px into view', async({page, golden}) => { expect(screenshot).toMatchImage(golden('screenshot-element-scrolled-into-view.png')); }); -it.skip(ffheadful)('should work with a rotated element', async({page, golden}) => { +it.skip(ffheadful)('should work with a rotated element', async ({page, golden}) => { await page.setViewportSize({width: 500, height: 500}); await page.setContent(`
'); const div = await page.$('div'); const error = await div.screenshot({ timeout: 3000 }).catch(e => e); @@ -184,7 +184,7 @@ it.skip(ffheadful)('should timeout waiting for visible', async({page, server}) = expect(error.message).toContain('element is not visible'); }); -it.skip(ffheadful)('should wait for visible', async({page, server, golden}) => { +it.skip(ffheadful)('should wait for visible', async ({page, server, golden}) => { await page.setViewportSize({width: 500, height: 500}); await page.goto(server.PREFIX + '/grid.html'); await page.evaluate(() => window.scrollBy(50, 100)); @@ -203,14 +203,14 @@ it.skip(ffheadful)('should wait for visible', async({page, server, golden}) => { expect(screenshot).toMatchImage(golden('screenshot-element-bounding-box.png')); }); -it.skip(ffheadful)('should work for an element with fractional dimensions', async({page, golden}) => { +it.skip(ffheadful)('should work for an element with fractional dimensions', async ({page, golden}) => { await page.setContent('
'); const elementHandle = await page.$('div'); const screenshot = await elementHandle.screenshot(); expect(screenshot).toMatchImage(golden('screenshot-element-fractional.png')); }); -it.skip(options.FIREFOX)('should work with a mobile viewport', async({browser, server, golden}) => { +it.skip(options.FIREFOX)('should work with a mobile viewport', async ({browser, server, golden}) => { const context = await browser.newContext({viewport: { width: 320, height: 480 }, isMobile: true}); const page = await context.newPage(); await page.goto(server.PREFIX + '/grid.html'); @@ -221,7 +221,7 @@ it.skip(options.FIREFOX)('should work with a mobile viewport', async({browser, s await context.close(); }); -it.skip(options.FIREFOX)('should work with device scale factor', async({browser, server, golden}) => { +it.skip(options.FIREFOX)('should work with device scale factor', async ({browser, server, golden}) => { const context = await browser.newContext({ viewport: { width: 320, height: 480 }, deviceScaleFactor: 2 }); const page = await context.newPage(); await page.goto(server.PREFIX + '/grid.html'); @@ -232,14 +232,14 @@ it.skip(options.FIREFOX)('should work with device scale factor', async({browser, await context.close(); }); -it.skip(ffheadful)('should work for an element with an offset', async({page, golden}) => { +it.skip(ffheadful)('should work for an element with an offset', async ({page, golden}) => { await page.setContent('
'); const elementHandle = await page.$('div'); const screenshot = await elementHandle.screenshot(); expect(screenshot).toMatchImage(golden('screenshot-element-fractional-offset.png')); }); -it.skip(ffheadful)('should take screenshots when default viewport is null', async({server, browser}) => { +it.skip(ffheadful)('should take screenshots when default viewport is null', async ({server, browser}) => { const context = await browser.newContext({ viewport: null }); const page = await context.newPage(); await page.setContent(`
`); @@ -258,7 +258,7 @@ it.skip(ffheadful)('should take screenshots when default viewport is null', asyn await context.close(); }); -it.skip(ffheadful)('should take fullPage screenshots when default viewport is null', async({server, browser}) => { +it.skip(ffheadful)('should take fullPage screenshots when default viewport is null', async ({server, browser}) => { const context = await browser.newContext({ viewport: null }); const page = await context.newPage(); await page.goto(server.PREFIX + '/grid.html'); @@ -274,7 +274,7 @@ it.skip(ffheadful)('should take fullPage screenshots when default viewport is nu await context.close(); }); -it.skip(ffheadful)('should restore default viewport after fullPage screenshot', async({ browser }) => { +it.skip(ffheadful)('should restore default viewport after fullPage screenshot', async ({ browser }) => { const context = await browser.newContext({ viewport: { width: 456, height: 789 } }); const page = await context.newPage(); await utils.verifyViewport(page, 456, 789); @@ -284,18 +284,18 @@ it.skip(ffheadful)('should restore default viewport after fullPage screenshot', await context.close(); }); -it.skip(ffheadful || options.WIRE)('should restore viewport after page screenshot and exception', async({ browser, server }) => { +it.skip(ffheadful || options.WIRE)('should restore viewport after page screenshot and exception', async ({ browser, server }) => { const context = await browser.newContext({ viewport: { width: 350, height: 360 } }); const page = await context.newPage(); await page.goto(server.PREFIX + '/grid.html'); - const __testHookBeforeScreenshot = () => { throw new Error('oh my') }; + const __testHookBeforeScreenshot = () => { throw new Error('oh my'); }; const error = await page.screenshot({ fullPage: true, __testHookBeforeScreenshot } as any).catch(e => e); expect(error.message).toContain('oh my'); await utils.verifyViewport(page, 350, 360); await context.close(); }); -it.skip(ffheadful || options.WIRE)('should restore viewport after page screenshot and timeout', async({ browser, server }) => { +it.skip(ffheadful || options.WIRE)('should restore viewport after page screenshot and timeout', async ({ browser, server }) => { const context = await browser.newContext({ viewport: { width: 350, height: 360 } }); const page = await context.newPage(); await page.goto(server.PREFIX + '/grid.html'); @@ -309,7 +309,7 @@ it.skip(ffheadful || options.WIRE)('should restore viewport after page screensho await context.close(); }); -it.skip(ffheadful)('should take element screenshot when default viewport is null and restore back', async({server, browser}) => { +it.skip(ffheadful)('should take element screenshot when default viewport is null and restore back', async ({server, browser}) => { const context = await browser.newContext({viewport: null}); const page = await context.newPage(); await page.setContent(` @@ -339,12 +339,12 @@ it.skip(ffheadful)('should take element screenshot when default viewport is null await context.close(); }); -it.skip(ffheadful || options.WIRE)('should restore viewport after element screenshot and exception', async({server, browser}) => { +it.skip(ffheadful || options.WIRE)('should restore viewport after element screenshot and exception', async ({server, browser}) => { const context = await browser.newContext({ viewport: { width: 350, height: 360 } }); const page = await context.newPage(); await page.setContent(`
`); const elementHandle = await page.$('div'); - const __testHookBeforeScreenshot = () => { throw new Error('oh my') }; + const __testHookBeforeScreenshot = () => { throw new Error('oh my'); }; const error = await elementHandle.screenshot({ __testHookBeforeScreenshot } as any).catch(e => e); expect(error.message).toContain('oh my'); await utils.verifyViewport(page, 350, 360); @@ -363,7 +363,7 @@ it.skip(ffheadful).flaky(options.WEBKIT && !options.HEADLESS && LINUX)('should w expect(screenshot).toMatchImage(golden('screenshot-element-bounding-box.png')); }); -it.skip(ffheadful)('should take screenshot of disabled button', async({page}) => { +it.skip(ffheadful)('should take screenshot of disabled button', async ({page}) => { await page.setViewportSize({ width: 500, height: 500 }); await page.setContent(``); const button = await page.$('button'); @@ -371,7 +371,7 @@ it.skip(ffheadful)('should take screenshot of disabled button', async({page}) => expect(screenshot).toBeInstanceOf(Buffer); }); -it.skip(ffheadful)('path option should create subdirectories', async({page, server, golden, tmpDir}) => { +it.skip(ffheadful)('path option should create subdirectories', async ({page, server, golden, tmpDir}) => { await page.setViewportSize({width: 500, height: 500}); await page.goto(server.PREFIX + '/grid.html'); await page.evaluate(() => window.scrollBy(50, 100)); diff --git a/test/elementhandle-wait-for-element-state.spec.ts b/test/elementhandle-wait-for-element-state.spec.ts index 1c860f8493..5cea794946 100644 --- a/test/elementhandle-wait-for-element-state.spec.ts +++ b/test/elementhandle-wait-for-element-state.spec.ts @@ -16,7 +16,6 @@ */ import './playwright.fixtures'; -import { options } from './playwright.fixtures'; async function giveItAChanceToResolve(page) { for (let i = 0; i < 5; i++) @@ -84,7 +83,7 @@ it('should wait for hidden when detached', async ({ page }) => { await promise; }); -it('should wait for enabled button', async({page, server}) => { +it('should wait for enabled button', async ({page, server}) => { await page.setContent(''); const span = await page.$('text=Target'); let done = false; @@ -104,7 +103,7 @@ it('should throw waiting for enabled when detached', async ({ page }) => { expect(error.message).toContain('Element is not attached to the DOM'); }); -it('should wait for disabled button', async({page}) => { +it('should wait for disabled button', async ({page}) => { await page.setContent(''); const span = await page.$('text=Target'); let done = false; @@ -115,7 +114,7 @@ it('should wait for disabled button', async({page}) => { await promise; }); -it('should wait for stable position', async({page, server}) => { +it('should wait for stable position', async ({page, server}) => { await page.goto(server.PREFIX + '/input/button.html'); const button = await page.$('button'); await page.$eval('button', button => { diff --git a/test/emulation-focus.spec.ts b/test/emulation-focus.spec.ts index 5f174dff7d..a3974f27d1 100644 --- a/test/emulation-focus.spec.ts +++ b/test/emulation-focus.spec.ts @@ -18,18 +18,18 @@ import { options } from './playwright.fixtures'; import utils from './utils'; -it('should think that it is focused by default', async({page}) => { +it('should think that it is focused by default', async ({page}) => { expect(await page.evaluate('document.hasFocus()')).toBe(true); }); -it('should think that all pages are focused', async({page}) => { +it('should think that all pages are focused', async ({page}) => { const page2 = await page.context().newPage(); expect(await page.evaluate('document.hasFocus()')).toBe(true); expect(await page2.evaluate('document.hasFocus()')).toBe(true); await page2.close(); }); -it('should focus popups by default', async({page, server}) => { +it('should focus popups by default', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const [popup] = await Promise.all([ page.waitForEvent('popup'), @@ -39,7 +39,7 @@ it('should focus popups by default', async({page, server}) => { expect(await page.evaluate('document.hasFocus()')).toBe(true); }); -it('should provide target for keyboard events', async({page, server}) => { +it('should provide target for keyboard events', async ({page, server}) => { const page2 = await page.context().newPage(); await Promise.all([ page.goto(server.PREFIX + '/input/textarea.html'), @@ -62,7 +62,7 @@ it('should provide target for keyboard events', async({page, server}) => { expect(results).toEqual([text, text2]); }); -it('should not affect mouse event target page', async({page, server}) => { +it('should not affect mouse event target page', async ({page, server}) => { const page2 = await page.context().newPage(); function clickCounter() { document.onclick = () => window['clickCount'] = (window['clickCount'] || 0) + 1; @@ -81,10 +81,10 @@ it('should not affect mouse event target page', async({page, server}) => { page.evaluate('window.clickCount'), page2.evaluate('window.clickCount'), ]); - expect(counters ).toEqual([1,1]); + expect(counters).toEqual([1,1]); }); -it('should change document.activeElement', async({page, server}) => { +it('should change document.activeElement', async ({page, server}) => { const page2 = await page.context().newPage(); await Promise.all([ page.goto(server.PREFIX + '/input/textarea.html'), @@ -101,7 +101,7 @@ it('should change document.activeElement', async({page, server}) => { expect(active).toEqual(['INPUT', 'TEXTAREA']); }); -it.skip(options.FIREFOX && !options.HEADLESS)('should not affect screenshots', async({page, server, golden}) => { +it.skip(options.FIREFOX && !options.HEADLESS)('should not affect screenshots', async ({page, server, golden}) => { // Firefox headful produces a different image. const page2 = await page.context().newPage(); await Promise.all([ @@ -122,7 +122,7 @@ it.skip(options.FIREFOX && !options.HEADLESS)('should not affect screenshots', a expect(screenshots[1]).toMatchImage(golden('grid-cell-0.png')); }); -it('should change focused iframe', async({page, server}) => { +it('should change focused iframe', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const [frame1, frame2] = await Promise.all([ utils.attachFrame(page, 'frame1', server.PREFIX + '/input/textarea.html'), @@ -131,7 +131,7 @@ it('should change focused iframe', async({page, server}) => { function logger() { self['_events'] = []; const element = document.querySelector('input'); - element.onfocus = element.onblur = (e) => self['_events'].push(e.type); + element.onfocus = element.onblur = e => self['_events'].push(e.type); } await Promise.all([ frame1.evaluate(logger), diff --git a/test/eval-on-selector-all.spec.ts b/test/eval-on-selector-all.spec.ts index a743e640a7..f0519d42d8 100644 --- a/test/eval-on-selector-all.spec.ts +++ b/test/eval-on-selector-all.spec.ts @@ -17,37 +17,37 @@ import './playwright.fixtures'; -it('should work with css selector', async({page, server}) => { +it('should work with css selector', async ({page, server}) => { await page.setContent('
hello
beautiful
world!
'); const divsCount = await page.$$eval('css=div', divs => divs.length); expect(divsCount).toBe(3); }); -it('should work with text selector', async({page, server}) => { +it('should work with text selector', async ({page, server}) => { await page.setContent('
hello
beautiful
beautiful
world!
'); const divsCount = await page.$$eval('text="beautiful"', divs => divs.length); expect(divsCount).toBe(2); }); -it('should work with xpath selector', async({page, server}) => { +it('should work with xpath selector', async ({page, server}) => { await page.setContent('
hello
beautiful
world!
'); const divsCount = await page.$$eval('xpath=/html/body/div', divs => divs.length); expect(divsCount).toBe(3); }); -it('should auto-detect css selector', async({page, server}) => { +it('should auto-detect css selector', async ({page, server}) => { await page.setContent('
hello
beautiful
world!
'); const divsCount = await page.$$eval('div', divs => divs.length); expect(divsCount).toBe(3); }); -it('should support >> syntax', async({page, server}) => { +it('should support >> syntax', async ({page, server}) => { await page.setContent('
hello
beautiful
world!
Not this one'); const spansCount = await page.$$eval('css=div >> css=span', spans => spans.length); expect(spansCount).toBe(3); }); -it('should support * capture', async({page, server}) => { +it('should support * capture', async ({page, server}) => { await page.setContent('
a
b
'); expect(await page.$$eval('*css=div >> "b"', els => els.length)).toBe(1); expect(await page.$$eval('section >> *css=div >> "b"', els => els.length)).toBe(1); @@ -62,14 +62,14 @@ it('should support * capture', async({page, server}) => { expect(await page.$$eval('section >> *css=div >> "a"', els => els.length)).toBe(1); }); -it('should support * capture when multiple paths match', async({page, server}) => { +it('should support * capture when multiple paths match', async ({page, server}) => { await page.setContent('
'); expect(await page.$$eval('*css=div >> span', els => els.length)).toBe(2); await page.setContent('
'); expect(await page.$$eval('*css=div >> span', els => els.length)).toBe(2); }); -it('should return complex values', async({page, server}) => { +it('should return complex values', async ({page, server}) => { await page.setContent('
hello
beautiful
world!
'); const texts = await page.$$eval('css=div', divs => divs.map(div => div.textContent)); expect(texts).toEqual(['hello', 'beautiful', 'world!']); diff --git a/test/eval-on-selector.spec.ts b/test/eval-on-selector.spec.ts index 4dfe69afcc..11aec2084a 100644 --- a/test/eval-on-selector.spec.ts +++ b/test/eval-on-selector.spec.ts @@ -17,116 +17,116 @@ import './playwright.fixtures'; -it('should work with css selector', async({page, server}) => { +it('should work with css selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('css=section', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should work with id selector', async({page, server}) => { +it('should work with id selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('id=testAttribute', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should work with data-test selector', async({page, server}) => { +it('should work with data-test selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('data-test=foo', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should work with data-testid selector', async({page, server}) => { +it('should work with data-testid selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('data-testid=foo', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should work with data-test-id selector', async({page, server}) => { +it('should work with data-test-id selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('data-test-id=foo', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should work with text selector', async({page, server}) => { +it('should work with text selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('text="43543"', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should work with xpath selector', async({page, server}) => { +it('should work with xpath selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('xpath=/html/body/section', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should work with text selector', async({page, server}) => { +it('should work with text selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('text=43543', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should auto-detect css selector', async({page, server}) => { +it('should auto-detect css selector', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('section', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should auto-detect css selector with attributes', async({page, server}) => { +it('should auto-detect css selector with attributes', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('section[id="testAttribute"]', e => e.id); expect(idAttribute).toBe('testAttribute'); }); -it('should auto-detect nested selectors', async({page, server}) => { +it('should auto-detect nested selectors', async ({page, server}) => { await page.setContent('
43543Hello
'); const idAttribute = await page.$eval('div[foo=bar] > section >> "Hello" >> div', e => e.id); expect(idAttribute).toBe('target'); }); -it('should accept arguments', async({page, server}) => { +it('should accept arguments', async ({page, server}) => { await page.setContent('
hello
'); const text = await page.$eval('section', (e, suffix) => e.textContent + suffix, ' world!'); expect(text).toBe('hello world!'); }); -it('should accept ElementHandles as arguments', async({page, server}) => { +it('should accept ElementHandles as arguments', async ({page, server}) => { await page.setContent('
hello
world
'); const divHandle = await page.$('div'); const text = await page.$eval('section', (e, div) => e.textContent + div.textContent, divHandle); expect(text).toBe('hello world'); }); -it('should throw error if no element is found', async({page, server}) => { +it('should throw error if no element is found', async ({page, server}) => { let error = null; await page.$eval('section', e => e.id).catch(e => error = e); expect(error.message).toContain('failed to find element matching selector "section"'); }); -it('should support >> syntax', async({page, server}) => { +it('should support >> syntax', async ({page, server}) => { await page.setContent('
hello
'); const text = await page.$eval('css=section >> css=div', (e, suffix) => e.textContent + suffix, ' world!'); expect(text).toBe('hello world!'); }); -it('should support >> syntax with different engines', async({page, server}) => { +it('should support >> syntax with different engines', async ({page, server}) => { await page.setContent('
hello
'); const text = await page.$eval('xpath=/html/body/section >> css=div >> text="hello"', (e, suffix) => e.textContent + suffix, ' world!'); expect(text).toBe('hello world!'); }); -it('should support spaces with >> syntax', async({page, server}) => { +it('should support spaces with >> syntax', async ({page, server}) => { await page.goto(server.PREFIX + '/deep-shadow.html'); const text = await page.$eval(' css = div >>css=div>>css = span ', e => e.textContent); expect(text).toBe('Hello from root2'); }); -it('should not stop at first failure with >> syntax', async({page, server}) => { +it('should not stop at first failure with >> syntax', async ({page, server}) => { await page.setContent('
Next
'); const html = await page.$eval('button >> "Next"', e => e.outerHTML); expect(html).toBe(''); }); -it('should support * capture', async({page, server}) => { +it('should support * capture', async ({page, server}) => { await page.setContent('
a
b
'); expect(await page.$eval('*css=div >> "b"', e => e.outerHTML)).toBe('
b
'); expect(await page.$eval('section >> *css=div >> "b"', e => e.outerHTML)).toBe('
b
'); @@ -134,17 +134,17 @@ it('should support * capture', async({page, server}) => { expect(await page.$('*')).toBeTruthy(); }); -it('should throw on multiple * captures', async({page, server}) => { +it('should throw on multiple * captures', async ({page, server}) => { const error = await page.$eval('*css=div >> *css=span', e => e.outerHTML).catch(e => e); expect(error.message).toContain('Only one of the selectors can capture using * modifier'); }); -it('should throw on malformed * capture', async({page, server}) => { +it('should throw on malformed * capture', async ({page, server}) => { const error = await page.$eval('*=div', e => e.outerHTML).catch(e => e); expect(error.message).toContain('Unknown engine "" while parsing selector *=div'); }); -it('should work with spaces in css attributes', async({page, server}) => { +it('should work with spaces in css attributes', async ({page, server}) => { await page.setContent('
'); expect(await page.waitForSelector(`[placeholder="Select date"]`)).toBeTruthy(); expect(await page.waitForSelector(`[placeholder='Select date']`)).toBeTruthy(); @@ -166,7 +166,7 @@ it('should work with spaces in css attributes', async({page, server}) => { expect(await page.$eval(`div >> [placeholder='Select date']`, e => e.outerHTML)).toBe(''); }); -it('should work with quotes in css attributes', async({page, server}) => { +it('should work with quotes in css attributes', async ({page, server}) => { await page.setContent('
'); expect(await page.$(`[placeholder="Select\\"date"]`)).toBeTruthy(); expect(await page.$(`[placeholder='Select"date']`)).toBeTruthy(); @@ -181,21 +181,21 @@ it('should work with quotes in css attributes', async({page, server}) => { expect(await page.$(`[placeholder='Select \\' date']`)).toBeTruthy(); }); -it('should work with spaces in css attributes when missing', async({page, server}) => { +it('should work with spaces in css attributes when missing', async ({page, server}) => { const inputPromise = page.waitForSelector(`[placeholder="Select date"]`); expect(await page.$(`[placeholder="Select date"]`)).toBe(null); await page.setContent('
'); await inputPromise; }); -it('should work with quotes in css attributes when missing', async({page, server}) => { +it('should work with quotes in css attributes when missing', async ({page, server}) => { const inputPromise = page.waitForSelector(`[placeholder="Select\\"date"]`); expect(await page.$(`[placeholder="Select\\"date"]`)).toBe(null); await page.setContent('
'); await inputPromise; }); -it('should return complex values', async({page, server}) => { +it('should return complex values', async ({page, server}) => { await page.setContent('
43543
'); const idAttribute = await page.$eval('css=section', e => [{ id: e.id }]); expect(idAttribute).toEqual([{ id: 'testAttribute' }]); diff --git a/test/firefox/launcher.spec.ts b/test/firefox/launcher.spec.ts index 3e758686c4..0ba764b249 100644 --- a/test/firefox/launcher.spec.ts +++ b/test/firefox/launcher.spec.ts @@ -15,7 +15,7 @@ */ import { options } from '../playwright.fixtures'; -it.skip(!options.FIREFOX)('should pass firefox user preferences', async({browserType, defaultBrowserOptions}) => { +it.skip(!options.FIREFOX)('should pass firefox user preferences', async ({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch({ ...defaultBrowserOptions, firefoxUserPrefs: { diff --git a/test/focus.spec.ts b/test/focus.spec.ts index 921b66aaca..44a446ee2b 100644 --- a/test/focus.spec.ts +++ b/test/focus.spec.ts @@ -52,9 +52,9 @@ it('should traverse focus', async function({page}) { await page.$eval('#i2', i2 => (i2 as HTMLInputElement).addEventListener('focus', window['focusEvent'])); await page.focus('#i1'); - await page.keyboard.type("First"); - await page.keyboard.press("Tab"); - await page.keyboard.type("Last"); + await page.keyboard.type('First'); + await page.keyboard.press('Tab'); + await page.keyboard.type('Last'); expect(focused).toBe(true); expect(await page.$eval('#i1', e => (e as HTMLInputElement).value)).toBe('First'); @@ -75,7 +75,7 @@ it('should traverse focus in all directions', async function({page}) { expect(await page.evaluate(() => (document.activeElement as HTMLInputElement).value)).toBe('1'); }); -// Chromium and WebKit both have settings for tab traversing all links, but +// Chromium and WebKit both have settings for tab traversing all links, but // it is only on by default in WebKit. it.skip(!MAC || !options.WEBKIT)('should traverse only form elements', async function({page}) { await page.setContent(` diff --git a/test/frame-evaluate.spec.ts b/test/frame-evaluate.spec.ts index 2ca0423bbb..dc251107c7 100644 --- a/test/frame-evaluate.spec.ts +++ b/test/frame-evaluate.spec.ts @@ -22,10 +22,10 @@ it('should have different execution contexts', async ({ page, server }) => { await page.goto(server.EMPTY_PAGE); await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); expect(page.frames().length).toBe(2); - await page.frames()[0].evaluate(() => window["FOO"] = 'foo'); - await page.frames()[1].evaluate(() => window["FOO"] = 'bar'); - expect(await page.frames()[0].evaluate(() => window["FOO"])).toBe('foo'); - expect(await page.frames()[1].evaluate(() => window["FOO"])).toBe('bar'); + await page.frames()[0].evaluate(() => window['FOO'] = 'foo'); + await page.frames()[1].evaluate(() => window['FOO'] = 'bar'); + expect(await page.frames()[0].evaluate(() => window['FOO'])).toBe('foo'); + expect(await page.frames()[1].evaluate(() => window['FOO'])).toBe('bar'); }); it('should have correct execution contexts', async ({ page, server }) => { @@ -99,7 +99,7 @@ it('should not allow cross-frame element handles when frames do not script each expect(error.message).toContain('Unable to adopt element handle from a different document'); }); -it('should throw for detached frames', async({page, server}) => { +it('should throw for detached frames', async ({page, server}) => { const frame1 = await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); await utils.detachFrame(page, 'frame1'); let error = null; @@ -107,7 +107,7 @@ it('should throw for detached frames', async({page, server}) => { expect(error.message).toContain('Execution Context is not available in detached frame'); }); -it('should be isolated between frames', async({page, server}) => { +it('should be isolated between frames', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); expect(page.frames().length).toBe(2); @@ -115,8 +115,8 @@ it('should be isolated between frames', async({page, server}) => { expect(frame1 !== frame2).toBeTruthy(); await Promise.all([ - frame1.evaluate(() => window["a"] = 1), - frame2.evaluate(() => window["a"] = 2) + frame1.evaluate(() => window['a'] = 1), + frame2.evaluate(() => window['a'] = 2) ]); const [a1, a2] = await Promise.all([ frame1.evaluate(() => window['a']), @@ -126,7 +126,7 @@ it('should be isolated between frames', async({page, server}) => { expect(a2).toBe(2); }); -it.fail(options.CHROMIUM || options.FIREFOX)('should work in iframes that failed initial navigation', async({page, server}) => { +it.fail(options.CHROMIUM || options.FIREFOX)('should work in iframes that failed initial navigation', async ({page, server}) => { // - Firefox does not report domcontentloaded for the iframe. // - Chromium and Firefox report empty url. // - Chromium does not report main/utility worlds for the iframe. @@ -147,7 +147,7 @@ it.fail(options.CHROMIUM || options.FIREFOX)('should work in iframes that failed expect(await page.frames()[1].$('div')).toBeTruthy(); }); -it.fixme(options.CHROMIUM)('should work in iframes that interrupted initial javascript url navigation', async({page, server}) => { +it.fixme(options.CHROMIUM)('should work in iframes that interrupted initial javascript url navigation', async ({page, server}) => { // Chromium does not report isolated world for the iframe. await page.goto(server.EMPTY_PAGE); await page.evaluate(() => { @@ -164,7 +164,7 @@ it.fixme(options.CHROMIUM)('should work in iframes that interrupted initial java expect(await page.frames()[1].$('div')).toBeTruthy(); }); -it('evaluateHandle should work', async({page, server}) => { +it('evaluateHandle should work', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const mainFrame = page.mainFrame(); const windowHandle = await mainFrame.evaluateHandle(() => window); diff --git a/test/frame-frame-element.spec.ts b/test/frame-frame-element.spec.ts index 12f9677c19..ae48d66c9a 100644 --- a/test/frame-frame-element.spec.ts +++ b/test/frame-frame-element.spec.ts @@ -19,10 +19,10 @@ import './playwright.fixtures'; import utils from './utils'; -it('should work', async({page, server}) => { +it('should work', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const frame1 = await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); - const frame2 = await utils.attachFrame(page, 'frame2', server.EMPTY_PAGE); + await utils.attachFrame(page, 'frame2', server.EMPTY_PAGE); const frame3 = await utils.attachFrame(page, 'frame3', server.EMPTY_PAGE); const frame1handle1 = await page.$('#frame1'); const frame1handle2 = await frame1.frameElement(); @@ -33,7 +33,7 @@ it('should work', async({page, server}) => { expect(await frame1handle1.evaluate((a, b) => a === b, frame3handle1)).toBe(false); }); -it('should work with contentFrame', async({page, server}) => { +it('should work with contentFrame', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const frame = await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); const handle = await frame.frameElement(); @@ -41,7 +41,7 @@ it('should work with contentFrame', async({page, server}) => { expect(contentFrame).toBe(frame); }); -it('should throw when detached', async({page, server}) => { +it('should throw when detached', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const frame1 = await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); await page.$eval('#frame1', e => e.remove()); diff --git a/test/frame-goto.spec.ts b/test/frame-goto.spec.ts index c724ccbdfa..be83951234 100644 --- a/test/frame-goto.spec.ts +++ b/test/frame-goto.spec.ts @@ -19,7 +19,7 @@ import './playwright.fixtures'; import utils from './utils'; -it('should navigate subframes', async({page, server}) => { +it('should navigate subframes', async ({page, server}) => { await page.goto(server.PREFIX + '/frames/one-frame.html'); expect(page.frames()[0].url()).toContain('/frames/one-frame.html'); expect(page.frames()[1].url()).toContain('/frames/frame.html'); @@ -29,7 +29,7 @@ it('should navigate subframes', async({page, server}) => { expect(response.frame()).toBe(page.frames()[1]); }); -it('should reject when frame detaches', async({page, server}) => { +it('should reject when frame detaches', async ({page, server}) => { await page.goto(server.PREFIX + '/frames/one-frame.html'); server.setRoute('/empty.html', () => {}); @@ -41,7 +41,7 @@ it('should reject when frame detaches', async({page, server}) => { expect(error.message).toContain('frame was detached'); }); -it('should continue after client redirect', async({page, server}) => { +it('should continue after client redirect', async ({page, server}) => { server.setRoute('/frames/script.js', () => {}); const url = server.PREFIX + '/frames/child-redirect.html'; const error = await page.goto(url, { timeout: 5000, waitUntil: 'networkidle' }).catch(e => e); @@ -49,7 +49,7 @@ it('should continue after client redirect', async({page, server}) => { expect(error.message).toContain(`navigating to "${url}", waiting until "networkidle"`); }); -it('should return matching responses', async({page, server}) => { +it('should return matching responses', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); // Attach three frames. const frames = [ diff --git a/test/frame-hierarchy.spec.ts b/test/frame-hierarchy.spec.ts index 29ba88eda6..d34fb6c7cb 100644 --- a/test/frame-hierarchy.spec.ts +++ b/test/frame-hierarchy.spec.ts @@ -17,7 +17,7 @@ import { options } from './playwright.fixtures'; import utils from './utils'; -it('should handle nested frames', async({page, server}) => { +it('should handle nested frames', async ({page, server}) => { await page.goto(server.PREFIX + '/frames/nested-frames.html'); expect(utils.dumpFrames(page.mainFrame())).toEqual([ 'http://localhost:/frames/nested-frames.html', @@ -28,7 +28,7 @@ it('should handle nested frames', async({page, server}) => { ]); }); -it('should send events when frames are manipulated dynamically', async({page, server}) => { +it('should send events when frames are manipulated dynamically', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); // validate frameattached events const attachedFrames = []; @@ -56,7 +56,7 @@ it('should send events when frames are manipulated dynamically', async({page, se expect(detachedFrames[0].isDetached()).toBe(true); }); -it('should send "framenavigated" when navigating on anchor URLs', async({page, server}) => { +it('should send "framenavigated" when navigating on anchor URLs', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); await Promise.all([ page.goto(server.EMPTY_PAGE + '#foo'), @@ -65,14 +65,14 @@ it('should send "framenavigated" when navigating on anchor URLs', async({page, s expect(page.url()).toBe(server.EMPTY_PAGE + '#foo'); }); -it('should persist mainFrame on cross-process navigation', async({page, server}) => { +it('should persist mainFrame on cross-process navigation', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const mainFrame = page.mainFrame(); await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html'); expect(page.mainFrame() === mainFrame).toBeTruthy(); }); -it('should not send attach/detach events for main frame', async({page, server}) => { +it('should not send attach/detach events for main frame', async ({page, server}) => { let hasEvents = false; page.on('frameattached', frame => hasEvents = true); page.on('framedetached', frame => hasEvents = true); @@ -80,7 +80,7 @@ it('should not send attach/detach events for main frame', async({page, server}) expect(hasEvents).toBe(false); }); -it('should detach child frames on navigation', async({page, server}) => { +it('should detach child frames on navigation', async ({page, server}) => { let attachedFrames = []; let detachedFrames = []; let navigatedFrames = []; @@ -101,7 +101,7 @@ it('should detach child frames on navigation', async({page, server}) => { expect(navigatedFrames.length).toBe(1); }); -it('should support framesets', async({page, server}) => { +it('should support framesets', async ({page, server}) => { let attachedFrames = []; let detachedFrames = []; let navigatedFrames = []; @@ -122,7 +122,7 @@ it('should support framesets', async({page, server}) => { expect(navigatedFrames.length).toBe(1); }); -it('should report frame from-inside shadow DOM', async({page, server}) => { +it('should report frame from-inside shadow DOM', async ({page, server}) => { await page.goto(server.PREFIX + '/shadow.html'); await page.evaluate(async url => { const frame = document.createElement('iframe'); @@ -134,7 +134,7 @@ it('should report frame from-inside shadow DOM', async({page, server}) => { expect(page.frames()[1].url()).toBe(server.EMPTY_PAGE); }); -it('should report frame.name()', async({page, server}) => { +it('should report frame.name()', async ({page, server}) => { await utils.attachFrame(page, 'theFrameId', server.EMPTY_PAGE); await page.evaluate(url => { const frame = document.createElement('iframe'); @@ -148,7 +148,7 @@ it('should report frame.name()', async({page, server}) => { expect(page.frames()[2].name()).toBe('theFrameName'); }); -it('should report frame.parent()', async({page, server}) => { +it('should report frame.parent()', async ({page, server}) => { await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); await utils.attachFrame(page, 'frame2', server.EMPTY_PAGE); expect(page.frames()[0].parentFrame()).toBe(null); @@ -156,7 +156,7 @@ it('should report frame.parent()', async({page, server}) => { expect(page.frames()[2].parentFrame()).toBe(page.mainFrame()); }); -it('should report different frame instance when frame re-attaches', async({page, server}) => { +it('should report different frame instance when frame re-attaches', async ({page, server}) => { const frame1 = await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE); await page.evaluate(() => { window['frame'] = document.querySelector('#frame1'); @@ -171,7 +171,7 @@ it('should report different frame instance when frame re-attaches', async({page, expect(frame1).not.toBe(frame2); }); -it.fixme(options.FIREFOX)('should refuse to display x-frame-options:deny iframe', async({page, server}) => { +it.fixme(options.FIREFOX)('should refuse to display x-frame-options:deny iframe', async ({page, server}) => { server.setRoute('/x-frame-options-deny.html', async (req, res) => { res.setHeader('Content-Type', 'text/html'); res.setHeader('X-Frame-Options', 'DENY'); @@ -185,10 +185,10 @@ it.fixme(options.FIREFOX)('should refuse to display x-frame-options:deny iframe' }); }); await page.setContent(``); - expect(await refusalText).toMatch(/Refused to display 'http.*\/x-frame-options-deny\.html' in a frame because it set 'X-Frame-Options' to 'deny'./i) + expect(await refusalText).toMatch(/Refused to display 'http.*\/x-frame-options-deny\.html' in a frame because it set 'X-Frame-Options' to 'deny'./i); }); -it('should return frame.page()', async({page, server}) => { +it('should return frame.page()', async ({page, server}) => { await page.goto(server.PREFIX + '/frames/one-frame.html'); expect(page.mainFrame().page()).toBe(page); expect(page.mainFrame().childFrames()[0].page()).toBe(page); diff --git a/test/geolocation.spec.ts b/test/geolocation.spec.ts index b7b21ce536..caebd57f8d 100644 --- a/test/geolocation.spec.ts +++ b/test/geolocation.spec.ts @@ -17,7 +17,7 @@ import './playwright.fixtures'; -it('should work', async({page, server, context}) => { +it('should work', async ({page, server, context}) => { await context.grantPermissions(['geolocation']); await page.goto(server.EMPTY_PAGE); await context.setGeolocation({longitude: 10, latitude: 10}); @@ -30,7 +30,7 @@ it('should work', async({page, server, context}) => { }); }); -it('should throw when invalid longitude', async({context}) => { +it('should throw when invalid longitude', async ({context}) => { let error = null; try { await context.setGeolocation({longitude: 200, latitude: 10}); @@ -40,7 +40,7 @@ it('should throw when invalid longitude', async({context}) => { expect(error.message).toContain('geolocation.longitude: precondition -180 <= LONGITUDE <= 180 failed.'); }); -it('should isolate contexts', async({page, server, context, browser}) => { +it('should isolate contexts', async ({page, server, context, browser}) => { await context.grantPermissions(['geolocation']); await context.setGeolocation({longitude: 10, latitude: 10}); await page.goto(server.EMPTY_PAGE); @@ -71,7 +71,7 @@ it('should isolate contexts', async({page, server, context, browser}) => { await context2.close(); }); -it('should throw with missing latitude', async({context}) => { +it('should throw with missing latitude', async ({context}) => { let error = null; try { await context.setGeolocation({longitude: 10} as any); @@ -81,7 +81,7 @@ it('should throw with missing latitude', async({context}) => { expect(error.message).toContain('geolocation.latitude: expected number, got undefined'); }); -it('should not modify passed default options object', async({browser}) => { +it('should not modify passed default options object', async ({browser}) => { const geolocation = { longitude: 10, latitude: 10 }; const options = { geolocation }; const context = await browser.newContext(options); @@ -90,7 +90,7 @@ it('should not modify passed default options object', async({browser}) => { await context.close(); }); -it('should throw with missing longitude in default options', async({browser}) => { +it('should throw with missing longitude in default options', async ({browser}) => { let error = null; try { const context = await browser.newContext({ geolocation: {latitude: 10} as any }); @@ -101,7 +101,7 @@ it('should throw with missing longitude in default options', async({browser}) => expect(error.message).toContain('geolocation.longitude: expected number, got undefined'); }); -it('should use context options', async({browser, server}) => { +it('should use context options', async ({browser, server}) => { const options = { geolocation: { longitude: 10, latitude: 10 }, permissions: ['geolocation'] }; const context = await browser.newContext(options); const page = await context.newPage(); @@ -117,7 +117,7 @@ it('should use context options', async({browser, server}) => { await context.close(); }); -it('watchPosition should be notified', async({page, server, context}) => { +it('watchPosition should be notified', async ({page, server, context}) => { await context.grantPermissions(['geolocation']); await page.goto(server.EMPTY_PAGE); const messages = []; @@ -143,12 +143,12 @@ it('watchPosition should be notified', async({page, server, context}) => { expect(allMessages).toContain('lat=40 lng=50'); }); -it('should use context options for popup', async({page, context, server}) => { +it('should use context options for popup', async ({page, context, server}) => { await context.grantPermissions(['geolocation']); await context.setGeolocation({ longitude: 10, latitude: 10 }); const [popup] = await Promise.all([ page.waitForEvent('popup'), - page.evaluate(url => window["_popup"] = window.open(url), server.PREFIX + '/geolocation.html'), + page.evaluate(url => window['_popup'] = window.open(url), server.PREFIX + '/geolocation.html'), ]); await popup.waitForLoadState(); const geolocation = await popup.evaluate(() => window['geolocationPromise']); diff --git a/test/headful.spec.ts b/test/headful.spec.ts index 39ecc6f2ec..aaefa8ef8d 100644 --- a/test/headful.spec.ts +++ b/test/headful.spec.ts @@ -26,7 +26,7 @@ it('should have default url when launching browser', async ({browserType, defaul await browserContext.close(); }); -it.fail(WIN && options.CHROMIUM).slow()('headless should be able to read cookies written by headful', async({browserType, defaultBrowserOptions, server}) => { +it.fail(WIN && options.CHROMIUM).slow()('headless should be able to read cookies written by headful', async ({browserType, defaultBrowserOptions, server}) => { // see https://github.com/microsoft/playwright/issues/717 const userDataDir = await makeUserDataDir(); // Write a cookie in headful chrome @@ -46,7 +46,7 @@ it.fail(WIN && options.CHROMIUM).slow()('headless should be able to read cookies expect(cookie).toBe('foo=true'); }); -it.slow()('should close browser with beforeunload page', async({browserType, defaultBrowserOptions, server, tmpDir}) => { +it.slow()('should close browser with beforeunload page', async ({browserType, defaultBrowserOptions, server, tmpDir}) => { const browserContext = await browserType.launchPersistentContext(tmpDir, {...defaultBrowserOptions, headless: false}); const page = await browserContext.newPage(); await page.goto(server.PREFIX + '/beforeunload.html'); @@ -60,18 +60,18 @@ it('should not crash when creating second context', async ({browserType, default const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); { const browserContext = await browser.newContext(); - const page = await browserContext.newPage(); + await browserContext.newPage(); await browserContext.close(); } { const browserContext = await browser.newContext(); - const page = await browserContext.newPage(); + await browserContext.newPage(); await browserContext.close(); } await browser.close(); }); -it('should click background tab', async({browserType, defaultBrowserOptions, server}) => { +it('should click background tab', async ({browserType, defaultBrowserOptions, server}) => { const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); const page = await browser.newPage(); await page.setContent(`empty.html`); @@ -80,7 +80,7 @@ it('should click background tab', async({browserType, defaultBrowserOptions, ser await browser.close(); }); -it('should close browser after context menu was triggered', async({browserType, defaultBrowserOptions, server}) => { +it('should close browser after context menu was triggered', async ({browserType, defaultBrowserOptions, server}) => { const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); const page = await browser.newPage(); await page.goto(server.PREFIX + '/grid.html'); @@ -88,7 +88,7 @@ it('should close browser after context menu was triggered', async({browserType, await browser.close(); }); -it('should(not) block third party cookies', async({browserType, defaultBrowserOptions, server}) => { +it('should(not) block third party cookies', async ({browserType, defaultBrowserOptions, server}) => { const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); @@ -112,14 +112,14 @@ it('should(not) block third party cookies', async({browserType, defaultBrowserOp if (allowsThirdParty) { expect(cookies).toEqual([ { - "domain": "127.0.0.1", - "expires": -1, - "httpOnly": false, - "name": "username", - "path": "/", - "sameSite": "None", - "secure": false, - "value": "John Doe" + 'domain': '127.0.0.1', + 'expires': -1, + 'httpOnly': false, + 'name': 'username', + 'path': '/', + 'sameSite': 'None', + 'secure': false, + 'value': 'John Doe' } ]); } else { @@ -150,9 +150,9 @@ it.fixme(options.WEBKIT)('should not override viewport size when passed null', a it('Page.bringToFront should work', async ({browserType, defaultBrowserOptions}) => { const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); const page1 = await browser.newPage(); - await page1.setContent('Page1') + await page1.setContent('Page1'); const page2 = await browser.newPage(); - await page2.setContent('Page2') + await page2.setContent('Page2'); await page1.bringToFront(); expect(await page1.evaluate('document.visibilityState')).toBe('visible'); @@ -161,7 +161,7 @@ it('Page.bringToFront should work', async ({browserType, defaultBrowserOptions}) await page2.bringToFront(); expect(await page1.evaluate('document.visibilityState')).toBe('visible'); expect(await page2.evaluate('document.visibilityState')).toBe( - 'visible' + 'visible' ); await browser.close(); }); diff --git a/test/ignorehttpserrors.spec.ts b/test/ignorehttpserrors.spec.ts index 8584c16126..9fcd16c271 100644 --- a/test/ignorehttpserrors.spec.ts +++ b/test/ignorehttpserrors.spec.ts @@ -17,7 +17,7 @@ import './playwright.fixtures'; -it('should work', async({browser, httpsServer}) => { +it('should work', async ({browser, httpsServer}) => { let error = null; const context = await browser.newContext({ ignoreHTTPSErrors: true }); const page = await context.newPage(); @@ -27,7 +27,7 @@ it('should work', async({browser, httpsServer}) => { await context.close(); }); -it('should isolate contexts', async({browser, httpsServer}) => { +it('should isolate contexts', async ({browser, httpsServer}) => { { let error = null; const context = await browser.newContext({ ignoreHTTPSErrors: true }); @@ -47,7 +47,7 @@ it('should isolate contexts', async({browser, httpsServer}) => { } }); -it('should work with mixed content', async({browser, server, httpsServer}) => { +it('should work with mixed content', async ({browser, server, httpsServer}) => { httpsServer.setRoute('/mixedcontent.html', (req, res) => { res.end(``); }); @@ -62,7 +62,7 @@ it('should work with mixed content', async({browser, server, httpsServer}) => { await context.close(); }); -it('should work with WebSocket', async({browser, httpsServer}) => { +it('should work with WebSocket', async ({browser, httpsServer}) => { const context = await browser.newContext({ ignoreHTTPSErrors: true }); const page = await context.newPage(); const value = await page.evaluate(endpoint => { @@ -77,7 +77,7 @@ it('should work with WebSocket', async({browser, httpsServer}) => { await context.close(); }); -it('should fail with WebSocket if not ignored', async({browser, httpsServer}) => { +it('should fail with WebSocket if not ignored', async ({browser, httpsServer}) => { const context = await browser.newContext(); const page = await context.newPage(); const value = await page.evaluate(endpoint => { diff --git a/test/interception.spec.ts b/test/interception.spec.ts index 737e052730..1e62bd1090 100644 --- a/test/interception.spec.ts +++ b/test/interception.spec.ts @@ -20,7 +20,7 @@ import './playwright.fixtures'; import { globToRegex } from '../lib/client/clientHelper'; import vm from 'vm'; -it('should work with navigation', async({page, server}) => { +it('should work with navigation', async ({page, server}) => { const requests = new Map(); await page.route('**/*', route => { requests.set(route.request().url().split('/').pop(), route.request()); @@ -34,7 +34,7 @@ it('should work with navigation', async({page, server}) => { expect(requests.get('style.css').isNavigationRequest()).toBe(false); }); -it('should work with ignoreHTTPSErrors', async({browser, httpsServer}) => { +it('should work with ignoreHTTPSErrors', async ({browser, httpsServer}) => { const context = await browser.newContext({ ignoreHTTPSErrors: true }); const page = await context.newPage(); @@ -44,12 +44,12 @@ it('should work with ignoreHTTPSErrors', async({browser, httpsServer}) => { await context.close(); }); -it('should intercept after a service worker', async({browser, page, server, context}) => { +it('should intercept after a service worker', async ({browser, page, server, context}) => { await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html'); - await page.evaluate(() => window["activationPromise"]); + await page.evaluate(() => window['activationPromise']); // Sanity check. - const swResponse = await page.evaluate(() => window["fetchDummy"]('foo')); + const swResponse = await page.evaluate(() => window['fetchDummy']('foo')); expect(swResponse).toBe('responseFromServiceWorker:foo'); await page.route('**/foo', route => { @@ -63,15 +63,15 @@ it('should intercept after a service worker', async({browser, page, server, cont }); // Page route is applied after service worker fetch event. - const swResponse2 = await page.evaluate(() => window["fetchDummy"]('foo')); + const swResponse2 = await page.evaluate(() => window['fetchDummy']('foo')); expect(swResponse2).toBe('responseFromServiceWorker:foo'); // Page route is not applied to service worker initiated fetch. - const nonInterceptedResponse = await page.evaluate(() => window["fetchDummy"]('passthrough')); + const nonInterceptedResponse = await page.evaluate(() => window['fetchDummy']('passthrough')); expect(nonInterceptedResponse).toBe('FAILURE: Not Found'); }); -it('should work with glob', async() => { +it('should work with glob', async () => { expect(globToRegex('**/*.js').test('https://localhost:8080/foo.js')).toBeTruthy(); expect(globToRegex('**/*.css').test('https://localhost:8080/foo.js')).toBeFalsy(); expect(globToRegex('*.js').test('https://localhost:8080/foo.js')).toBeFalsy(); @@ -88,7 +88,7 @@ it('should work with glob', async() => { expect(globToRegex('**/*.{png,jpg,jpeg}').test('https://localhost:8080/c.css')).toBeFalsy(); }); -it('should work with regular expression passed from a different context', async({page, server}) => { +it('should work with regular expression passed from a different context', async ({page, server}) => { const ctx = vm.createContext(); const regexp = vm.runInContext('new RegExp("empty\\.html")', ctx); let intercepted = false; diff --git a/test/jshandle-as-element.spec.ts b/test/jshandle-as-element.spec.ts index 3f2f4ebdbb..3e18bc301a 100644 --- a/test/jshandle-as-element.spec.ts +++ b/test/jshandle-as-element.spec.ts @@ -17,19 +17,19 @@ import './playwright.fixtures'; -it('should work', async({page}) => { +it('should work', async ({page}) => { const aHandle = await page.evaluateHandle(() => document.body); const element = aHandle.asElement(); expect(element).toBeTruthy(); }); -it('should return null for non-elements', async({page}) => { +it('should return null for non-elements', async ({page}) => { const aHandle = await page.evaluateHandle(() => 2); const element = aHandle.asElement(); expect(element).toBeFalsy(); }); -it('should return ElementHandle for TextNodes', async({page}) => { +it('should return ElementHandle for TextNodes', async ({page}) => { await page.setContent('
ee!
'); const aHandle = await page.evaluateHandle(() => document.querySelector('div').firstChild); const element = aHandle.asElement(); @@ -37,7 +37,7 @@ it('should return ElementHandle for TextNodes', async({page}) => { expect(await page.evaluate(e => e.nodeType === Node.TEXT_NODE, element)).toBeTruthy(); }); -it('should work with nullified Node', async({page}) => { +it('should work with nullified Node', async ({page}) => { await page.setContent('
test
'); await page.evaluate('delete Node'); const handle = await page.evaluateHandle(() => document.querySelector('section')); diff --git a/test/jshandle-evaluate.spec.ts b/test/jshandle-evaluate.spec.ts index 5e5aa102ff..ecf5ba83ea 100644 --- a/test/jshandle-evaluate.spec.ts +++ b/test/jshandle-evaluate.spec.ts @@ -17,7 +17,7 @@ import './playwright.fixtures'; -it('should work with function', async({page}) => { +it('should work with function', async ({page}) => { const windowHandle = await page.evaluateHandle(() => { window['foo'] = [1, 2]; return window; @@ -25,7 +25,7 @@ it('should work with function', async({page}) => { expect(await windowHandle.evaluate(w => w['foo'])).toEqual([1, 2]); }); -it('should work with expression', async({page}) => { +it('should work with expression', async ({page}) => { const windowHandle = await page.evaluateHandle(() => { window['foo'] = [1, 2]; return window; diff --git a/test/jshandle-json-value.spec.ts b/test/jshandle-json-value.spec.ts index c867f83c90..cb76084faa 100644 --- a/test/jshandle-json-value.spec.ts +++ b/test/jshandle-json-value.spec.ts @@ -17,19 +17,19 @@ import './playwright.fixtures'; -it('should work', async({page}) => { +it('should work', async ({page}) => { const aHandle = await page.evaluateHandle(() => ({foo: 'bar'})); const json = await aHandle.jsonValue(); expect(json).toEqual({foo: 'bar'}); }); -it('should work with dates', async({page}) => { +it('should work with dates', async ({page}) => { const dateHandle = await page.evaluateHandle(() => new Date('2017-09-26T00:00:00.000Z')); const date = await dateHandle.jsonValue(); expect(date.toJSON()).toBe('2017-09-26T00:00:00.000Z'); }); -it('should throw for circular objects', async({page}) => { +it('should throw for circular objects', async ({page}) => { const windowHandle = await page.evaluateHandle('window'); let error = null; await windowHandle.jsonValue().catch(e => error = e); diff --git a/test/jshandle-properties.spec.ts b/test/jshandle-properties.spec.ts index d7c557432b..fdc78a7760 100644 --- a/test/jshandle-properties.spec.ts +++ b/test/jshandle-properties.spec.ts @@ -17,7 +17,7 @@ import './playwright.fixtures'; -it('should work', async({page}) => { +it('should work', async ({page}) => { const aHandle = await page.evaluateHandle(() => ({ one: 1, two: 2, @@ -27,7 +27,7 @@ it('should work', async({page}) => { expect(await twoHandle.jsonValue()).toEqual(2); }); -it('should work with undefined, null, and empty', async({page}) => { +it('should work with undefined, null, and empty', async ({page}) => { const aHandle = await page.evaluateHandle(() => ({ undefined: undefined, null: null, @@ -40,7 +40,7 @@ it('should work with undefined, null, and empty', async({page}) => { expect(String(await emptyhandle.jsonValue())).toEqual('undefined'); }); -it('should work with unserializable values', async({page}) => { +it('should work with unserializable values', async ({page}) => { const aHandle = await page.evaluateHandle(() => ({ infinity: Infinity, nInfinity: -Infinity, @@ -57,7 +57,7 @@ it('should work with unserializable values', async({page}) => { expect(await nzeroHandle.jsonValue()).toEqual(-0); }); -it('getProperties should work', async({page}) => { +it('getProperties should work', async ({page}) => { const aHandle = await page.evaluateHandle(() => ({ foo: 'bar' })); @@ -67,13 +67,13 @@ it('getProperties should work', async({page}) => { expect(await foo.jsonValue()).toBe('bar'); }); -it('getProperties should return empty map for non-objects', async({page}) => { +it('getProperties should return empty map for non-objects', async ({page}) => { const aHandle = await page.evaluateHandle(() => 123); const properties = await aHandle.getProperties(); expect(properties.size).toBe(0); }); -it('getProperties should return even non-own properties', async({page}) => { +it('getProperties should return even non-own properties', async ({page}) => { const aHandle = await page.evaluateHandle(() => { class A { a: string; diff --git a/test/jshandle-to-string.spec.ts b/test/jshandle-to-string.spec.ts index a01b6b5951..e946eb4e14 100644 --- a/test/jshandle-to-string.spec.ts +++ b/test/jshandle-to-string.spec.ts @@ -17,26 +17,26 @@ import { options } from './playwright.fixtures'; -it('should work for primitives', async({page}) => { +it('should work for primitives', async ({page}) => { const numberHandle = await page.evaluateHandle(() => 2); expect(numberHandle.toString()).toBe('JSHandle@2'); const stringHandle = await page.evaluateHandle(() => 'a'); expect(stringHandle.toString()).toBe('JSHandle@a'); }); -it('should work for complicated objects', async({page}) => { +it('should work for complicated objects', async ({page}) => { const aHandle = await page.evaluateHandle(() => window); expect(aHandle.toString()).toBe('JSHandle@object'); }); -it('should work for promises', async({page}) => { +it('should work for promises', async ({page}) => { // wrap the promise in an object, otherwise we will await. const wrapperHandle = await page.evaluateHandle(() => ({b: Promise.resolve(123)})); const bHandle = await wrapperHandle.getProperty('b'); expect(bHandle.toString()).toBe('JSHandle@promise'); }); -it('should work with different subtypes', async({page}) => { +it('should work with different subtypes', async ({page}) => { expect((await page.evaluateHandle('(function(){})')).toString()).toBe('JSHandle@function'); expect((await page.evaluateHandle('12')).toString()).toBe('JSHandle@12'); expect((await page.evaluateHandle('true')).toString()).toBe('JSHandle@true'); diff --git a/test/launcher.spec.ts b/test/launcher.spec.ts index 275959bd3a..01c1b4766b 100644 --- a/test/launcher.spec.ts +++ b/test/launcher.spec.ts @@ -19,12 +19,12 @@ import './playwright.fixtures'; import path from 'path'; import utils from './utils'; -it('should require top-level Errors', async({}) => { +it('should require top-level Errors', async ({}) => { const Errors = require(path.join(utils.projectRoot(), '/lib/utils/errors.js')); expect(String(Errors.TimeoutError)).toContain('TimeoutError'); }); -it('should require top-level DeviceDescriptors', async({playwright}) => { +it('should require top-level DeviceDescriptors', async ({playwright}) => { const Devices = require(path.join(utils.projectRoot(), '/lib/server/deviceDescriptors.js')).DeviceDescriptors; expect(Devices['iPhone 6']).toBeTruthy(); expect(Devices['iPhone 6']).toEqual(playwright.devices['iPhone 6']); diff --git a/test/logger.spec.ts b/test/logger.spec.ts index db6029a790..2914936063 100644 --- a/test/logger.spec.ts +++ b/test/logger.spec.ts @@ -16,7 +16,7 @@ import './playwright.fixtures'; -it('should log', async({browserType, defaultBrowserOptions}) => { +it('should log', async ({browserType, defaultBrowserOptions}) => { const log = []; const browser = await browserType.launch({...defaultBrowserOptions, logger: { log: (name, severity, message) => log.push({name, severity, message}), @@ -30,7 +30,7 @@ it('should log', async({browserType, defaultBrowserOptions}) => { expect(log.filter(item => item.message.includes('browserType.launch succeeded')).length > 0).toBeTruthy(); }); -it('should log context-level', async({browserType, defaultBrowserOptions}) => { +it('should log context-level', async ({browserType, defaultBrowserOptions}) => { const log = []; const browser = await browserType.launch(defaultBrowserOptions); const context = await browser.newContext({ diff --git a/test/mouse.spec.ts b/test/mouse.spec.ts index e242054f73..fcd7e28a64 100644 --- a/test/mouse.spec.ts +++ b/test/mouse.spec.ts @@ -27,10 +27,10 @@ function dimensions() { }; } -it.flaky(options.FIREFOX && WIN)('should click the document', async({page, server}) => { +it.flaky(options.FIREFOX && WIN)('should click the document', async ({page, server}) => { // Occasionally times out on options.FIREFOX on Windows: https://github.com/microsoft/playwright/pull/1911/checks?check_run_id=607149016 await page.evaluate(() => { - window["clickPromise"] = new Promise(resolve => { + window['clickPromise'] = new Promise(resolve => { document.addEventListener('click', event => { resolve({ type: event.type, @@ -44,7 +44,7 @@ it.flaky(options.FIREFOX && WIN)('should click the document', async({page, serve }); }); await page.mouse.click(50, 60); - const event = await page.evaluate(() => window["clickPromise"]); + const event = await page.evaluate(() => window['clickPromise']); expect(event.type).toBe('click'); expect(event.detail).toBe(1); expect(event.clientX).toBe(50); @@ -53,10 +53,10 @@ it.flaky(options.FIREFOX && WIN)('should click the document', async({page, serve expect(event.button).toBe(0); }); -it('should dblclick the div', async({page, server}) => { +it('should dblclick the div', async ({page, server}) => { await page.setContent(`
Click me
`); await page.evaluate(() => { - window["dblclickPromise"] = new Promise(resolve => { + window['dblclickPromise'] = new Promise(resolve => { document.querySelector('div').addEventListener('dblclick', event => { resolve({ type: event.type, @@ -70,7 +70,7 @@ it('should dblclick the div', async({page, server}) => { }); }); await page.mouse.dblclick(50, 60); - const event = await page.evaluate(() => window["dblclickPromise"]); + const event = await page.evaluate(() => window['dblclickPromise']); expect(event.type).toBe('dblclick'); expect(event.detail).toBe(2); expect(event.clientX).toBe(50); @@ -79,7 +79,7 @@ it('should dblclick the div', async({page, server}) => { expect(event.button).toBe(0); }); -it('should select the text with mouse', async({page, server}) => { +it('should select the text with mouse', async ({page, server}) => { await page.goto(server.PREFIX + '/input/textarea.html'); await page.focus('textarea'); const text = 'This is the text that we are going to try to select. Let\'s see how it goes.'; @@ -98,7 +98,7 @@ it('should select the text with mouse', async({page, server}) => { })).toBe(text); }); -it('should trigger hover state', async({page, server}) => { +it('should trigger hover state', async ({page, server}) => { await page.goto(server.PREFIX + '/input/scrollable.html'); await page.hover('#button-6'); expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6'); @@ -108,23 +108,23 @@ it('should trigger hover state', async({page, server}) => { expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-91'); }); -it('should trigger hover state on disabled button', async({page, server}) => { +it('should trigger hover state on disabled button', async ({page, server}) => { await page.goto(server.PREFIX + '/input/scrollable.html'); await page.$eval('#button-6', (button: HTMLButtonElement) => button.disabled = true); await page.hover('#button-6', { timeout: 5000 }); expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6'); }); -it('should trigger hover state with removed window.Node', async({page, server}) => { +it('should trigger hover state with removed window.Node', async ({page, server}) => { await page.goto(server.PREFIX + '/input/scrollable.html'); await page.evaluate(() => delete window.Node); await page.hover('#button-6'); expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6'); }); -it('should set modifier keys on click', async({page, server}) => { +it('should set modifier keys on click', async ({page, server}) => { await page.goto(server.PREFIX + '/input/scrollable.html'); - await page.evaluate(() => document.querySelector('#button-3').addEventListener('mousedown', e => window["lastEvent"] = e, true)); + await page.evaluate(() => document.querySelector('#button-3').addEventListener('mousedown', e => window['lastEvent'] = e, true)); const modifiers = {'Shift': 'shiftKey', 'Control': 'ctrlKey', 'Alt': 'altKey', 'Meta': 'metaKey'}; // In Firefox, the Meta modifier only exists on Mac if (options.FIREFOX && !MAC) @@ -132,26 +132,26 @@ it('should set modifier keys on click', async({page, server}) => { for (const modifier in modifiers) { await page.keyboard.down(modifier); await page.click('#button-3'); - if (!(await page.evaluate(mod => window["lastEvent"][mod], modifiers[modifier]))) + if (!(await page.evaluate(mod => window['lastEvent'][mod], modifiers[modifier]))) throw new Error(modifiers[modifier] + ' should be true'); await page.keyboard.up(modifier); } await page.click('#button-3'); for (const modifier in modifiers) { - if ((await page.evaluate(mod => window["lastEvent"][mod], modifiers[modifier]))) + if ((await page.evaluate(mod => window['lastEvent'][mod], modifiers[modifier]))) throw new Error(modifiers[modifier] + ' should be false'); } }); -it('should tween mouse movement', async({page}) => { +it('should tween mouse movement', async ({page}) => { // The test becomes flaky on WebKit without next line. if (options.WEBKIT) await page.evaluate(() => new Promise(requestAnimationFrame)); await page.mouse.move(100, 100); await page.evaluate(() => { - window["result"] = []; + window['result'] = []; document.addEventListener('mousemove', event => { - window["result"].push([event.clientX, event.clientY]); + window['result'].push([event.clientX, event.clientY]); }); }); await page.mouse.move(200, 300, {steps: 5}); @@ -164,7 +164,7 @@ it('should tween mouse movement', async({page}) => { ]); }); -it.skip(options.FIREFOX)('should work with mobile viewports and cross process navigations', async({browser, server}) => { +it.skip(options.FIREFOX)('should work with mobile viewports and cross process navigations', async ({browser, server}) => { // @see https://crbug.com/929806 const context = await browser.newContext({ viewport: {width: 360, height: 640}, isMobile: true }); const page = await context.newPage(); @@ -172,7 +172,7 @@ it.skip(options.FIREFOX)('should work with mobile viewports and cross process na await page.goto(server.CROSS_PROCESS_PREFIX + '/mobile.html'); await page.evaluate(() => { document.addEventListener('click', event => { - window["result"] = {x: event.clientX, y: event.clientY}; + window['result'] = {x: event.clientX, y: event.clientY}; }); }); @@ -183,12 +183,12 @@ it.skip(options.FIREFOX)('should work with mobile viewports and cross process na }); xdescribe('Drag and Drop', function() { - it('should work', async({server, page}) => { + it('should work', async ({server, page}) => { await page.goto(server.PREFIX + '/drag-n-drop.html'); await page.hover('#source'); await page.mouse.down(); await page.hover('#target'); await page.mouse.up(); expect(await page.$eval('#target', target => target.contains(document.querySelector('#source')))).toBe(true); // could not find source in target - }) + }); }); diff --git a/test/navigation.spec.ts b/test/navigation.spec.ts index 97c42a3b1c..065525e680 100644 --- a/test/navigation.spec.ts +++ b/test/navigation.spec.ts @@ -17,7 +17,7 @@ import './playwright.fixtures'; -it('should work with _blank target', async({page, server}) => { +it('should work with _blank target', async ({page, server}) => { server.setRoute('/empty.html', (req, res) => { res.end(`Click me`); }); @@ -25,7 +25,7 @@ it('should work with _blank target', async({page, server}) => { await page.click('"Click me"'); }); -it('should work with cross-process _blank target', async({page, server}) => { +it('should work with cross-process _blank target', async ({page, server}) => { server.setRoute('/empty.html', (req, res) => { res.end(`Click me`); }); diff --git a/test/network-request.spec.ts b/test/network-request.spec.ts index 756a8ec610..967750f595 100644 --- a/test/network-request.spec.ts +++ b/test/network-request.spec.ts @@ -18,7 +18,7 @@ import { options } from './playwright.fixtures'; import utils from './utils'; -it('should work for main frame navigation request', async({page, server}) => { +it('should work for main frame navigation request', async ({page, server}) => { const requests = []; page.on('request', request => requests.push(request)); await page.goto(server.EMPTY_PAGE); @@ -26,7 +26,7 @@ it('should work for main frame navigation request', async({page, server}) => { expect(requests[0].frame()).toBe(page.mainFrame()); }); -it('should work for subframe navigation request', async({page, server}) => { +it('should work for subframe navigation request', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const requests = []; page.on('request', request => requests.push(request)); @@ -35,7 +35,7 @@ it('should work for subframe navigation request', async({page, server}) => { expect(requests[0].frame()).toBe(page.frames()[1]); }); -it('should work for fetch requests', async({page, server}) => { +it('should work for fetch requests', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); let requests = []; page.on('request', request => requests.push(request)); @@ -45,7 +45,7 @@ it('should work for fetch requests', async({page, server}) => { expect(requests[0].frame()).toBe(page.mainFrame()); }); -it('should return headers', async({page, server}) => { +it('should return headers', async ({page, server}) => { const response = await page.goto(server.EMPTY_PAGE); if (options.CHROMIUM) expect(response.request().headers()['user-agent']).toContain('Chrome'); @@ -55,7 +55,7 @@ it('should return headers', async({page, server}) => { expect(response.request().headers()['user-agent']).toContain('WebKit'); }); -it.fail(options.CHROMIUM||options.WEBKIT)('should get the same headers as the server', async({page, server}) => { +it.fail(options.CHROMIUM || options.WEBKIT)('should get the same headers as the server', async ({page, server}) => { await page.goto(server.PREFIX + '/empty.html'); let serverRequest; server.setRoute('/something', (request, response) => { @@ -73,7 +73,7 @@ it.fail(options.CHROMIUM||options.WEBKIT)('should get the same headers as the se expect(request.headers()).toEqual(serverRequest.headers); }); -it('should return postData', async({page, server}) => { +it('should return postData', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); server.setRoute('/post', (req, res) => res.end()); let request = null; @@ -83,13 +83,13 @@ it('should return postData', async({page, server}) => { expect(request.postData()).toBe('{"foo":"bar"}'); }); -it('should work with binary post data', async({page, server}) => { +it('should work with binary post data', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); server.setRoute('/post', (req, res) => res.end()); let request = null; page.on('request', r => request = r); await page.evaluate(async () => { - await fetch('./post', { method: 'POST', body: new Uint8Array(Array.from(Array(256).keys())) }) + await fetch('./post', { method: 'POST', body: new Uint8Array(Array.from(Array(256).keys())) }); }); expect(request).toBeTruthy(); const buffer = request.postDataBuffer(); @@ -98,14 +98,14 @@ it('should work with binary post data', async({page, server}) => { expect(buffer[i]).toBe(i); }); -it('should work with binary post data and interception', async({page, server}) => { +it('should work with binary post data and interception', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); server.setRoute('/post', (req, res) => res.end()); let request = null; await page.route('/post', route => route.continue()); page.on('request', r => request = r); await page.evaluate(async () => { - await fetch('./post', { method: 'POST', body: new Uint8Array(Array.from(Array(256).keys())) }) + await fetch('./post', { method: 'POST', body: new Uint8Array(Array.from(Array(256).keys())) }); }); expect(request).toBeTruthy(); const buffer = request.postDataBuffer(); @@ -114,7 +114,7 @@ it('should work with binary post data and interception', async({page, server}) = expect(buffer[i]).toBe(i); }); -it('should be |undefined| when there is no post data', async({page, server}) => { +it('should be |undefined| when there is no post data', async ({page, server}) => { const response = await page.goto(server.EMPTY_PAGE); expect(response.request().postData()).toBe(null); }); @@ -126,10 +126,10 @@ it('should parse the json post data', async ({ page, server }) => { page.on('request', r => request = r); await page.evaluate(() => fetch('./post', { method: 'POST', body: JSON.stringify({ foo: 'bar' }) })); expect(request).toBeTruthy(); - expect(request.postDataJSON()).toEqual({ "foo": "bar" }); + expect(request.postDataJSON()).toEqual({ 'foo': 'bar' }); }); -it('should parse the data if content-type is application/x-www-form-urlencoded', async({page, server}) => { +it('should parse the data if content-type is application/x-www-form-urlencoded', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); server.setRoute('/post', (req, res) => res.end()); let request = null; @@ -137,8 +137,8 @@ it('should parse the data if content-type is application/x-www-form-urlencoded', await page.setContent(`
`); await page.click('input[type=submit]'); expect(request).toBeTruthy(); - expect(request.postDataJSON()).toEqual({'foo':'bar','baz':'123'}); -}) + expect(request.postDataJSON()).toEqual({'foo': 'bar','baz': '123'}); +}); it('should be |undefined| when there is no post data', async ({ page, server }) => { const response = await page.goto(server.EMPTY_PAGE); @@ -170,7 +170,7 @@ it('should return event source', async ({page, server}) => { expect(requests[0].resourceType()).toBe('eventsource'); }); -it('should return navigation bit', async({page, server}) => { +it('should return navigation bit', async ({page, server}) => { const requests = new Map(); page.on('request', request => requests.set(request.url().split('/').pop(), request)); server.setRedirect('/rrredirect', '/frames/one-frame.html'); @@ -182,7 +182,7 @@ it('should return navigation bit', async({page, server}) => { expect(requests.get('style.css').isNavigationRequest()).toBe(false); }); -it('should return navigation bit when navigating to image', async({page, server}) => { +it('should return navigation bit when navigating to image', async ({page, server}) => { const requests = []; page.on('request', request => requests.push(request)); await page.goto(server.PREFIX + '/pptr.png'); diff --git a/test/network-response.spec.ts b/test/network-response.spec.ts index c16ece1c56..2e7180f696 100644 --- a/test/network-response.spec.ts +++ b/test/network-response.spec.ts @@ -19,7 +19,7 @@ import './playwright.fixtures'; import fs from 'fs'; import path from 'path'; -it('should work', async({page, server}) => { +it('should work', async ({page, server}) => { server.setRoute('/empty.html', (req, res) => { res.setHeader('foo', 'bar'); res.setHeader('BaZ', 'bAz'); @@ -32,19 +32,19 @@ it('should work', async({page, server}) => { }); -it('should return text', async({page, server}) => { +it('should return text', async ({page, server}) => { const response = await page.goto(server.PREFIX + '/simple.json'); expect(await response.text()).toBe('{"foo": "bar"}\n'); }); -it('should return uncompressed text', async({page, server}) => { +it('should return uncompressed text', async ({page, server}) => { server.enableGzip('/simple.json'); const response = await page.goto(server.PREFIX + '/simple.json'); expect(response.headers()['content-encoding']).toBe('gzip'); expect(await response.text()).toBe('{"foo": "bar"}\n'); }); -it('should throw when requesting body of redirected response', async({page, server}) => { +it('should throw when requesting body of redirected response', async ({page, server}) => { server.setRedirect('/foo.html', '/empty.html'); const response = await page.goto(server.PREFIX + '/foo.html'); const redirectedFrom = response.request().redirectedFrom(); @@ -56,7 +56,7 @@ it('should throw when requesting body of redirected response', async({page, serv expect(error.message).toContain('Response body is unavailable for redirect responses'); }); -it('should wait until response completes', async({page, server}) => { +it('should wait until response completes', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); // Setup server to trap request. let serverResponse = null; @@ -90,19 +90,19 @@ it('should wait until response completes', async({page, server}) => { expect(await responseText).toBe('hello world!'); }); -it('should return json', async({page, server}) => { +it('should return json', async ({page, server}) => { const response = await page.goto(server.PREFIX + '/simple.json'); expect(await response.json()).toEqual({foo: 'bar'}); }); -it('should return body', async({page, server}) => { +it('should return body', async ({page, server}) => { const response = await page.goto(server.PREFIX + '/pptr.png'); const imageBuffer = fs.readFileSync(path.join(__dirname, 'assets', 'pptr.png')); const responseBuffer = await response.body(); expect(responseBuffer.equals(imageBuffer)).toBe(true); }); -it('should return body with compression', async({page, server}) => { +it('should return body with compression', async ({page, server}) => { server.enableGzip('/pptr.png'); const response = await page.goto(server.PREFIX + '/pptr.png'); const imageBuffer = fs.readFileSync(path.join(__dirname, 'assets', 'pptr.png')); @@ -110,7 +110,7 @@ it('should return body with compression', async({page, server}) => { expect(responseBuffer.equals(imageBuffer)).toBe(true); }); -it('should return status text', async({page, server}) => { +it('should return status text', async ({page, server}) => { server.setRoute('/cool', (req, res) => { res.writeHead(200, 'cool!'); res.end(); diff --git a/test/page-add-init-script.spec.ts b/test/page-add-init-script.spec.ts index 73bdd64c5c..90f8dc86c8 100644 --- a/test/page-add-init-script.spec.ts +++ b/test/page-add-init-script.spec.ts @@ -19,23 +19,23 @@ import './playwright.fixtures'; import path from 'path'; it('should evaluate before anything else on the page', async ({ page, server }) => { - await page.addInitScript(function () { - window["injected"] = 123; + await page.addInitScript(function() { + window['injected'] = 123; }); await page.goto(server.PREFIX + '/tamperable.html'); - expect(await page.evaluate(() => window["result"])).toBe(123); + expect(await page.evaluate(() => window['result'])).toBe(123); }); it('should work with a path', async ({ page, server }) => { await page.addInitScript({ path: path.join(__dirname, 'assets/injectedfile.js') }); await page.goto(server.PREFIX + '/tamperable.html'); - expect(await page.evaluate(() => window["result"])).toBe(123); + expect(await page.evaluate(() => window['result'])).toBe(123); }); it('should work with content', async ({ page, server }) => { await page.addInitScript({ content: 'window["injected"] = 123' }); await page.goto(server.PREFIX + '/tamperable.html'); - expect(await page.evaluate(() => window["result"])).toBe(123); + expect(await page.evaluate(() => window['result'])).toBe(123); }); it('should throw without path and content', async ({ page, server }) => { @@ -45,11 +45,11 @@ it('should throw without path and content', async ({ page, server }) => { it('should work with browser context scripts', async ({ browser, server }) => { const context = await browser.newContext(); - await context.addInitScript(() => window["temp"] = 123); + await context.addInitScript(() => window['temp'] = 123); const page = await context.newPage(); - await page.addInitScript(() => window["injected"] = window["temp"]); + await page.addInitScript(() => window['injected'] = window['temp']); await page.goto(server.PREFIX + '/tamperable.html'); - expect(await page.evaluate(() => window["result"])).toBe(123); + expect(await page.evaluate(() => window['result'])).toBe(123); await context.close(); }); @@ -58,39 +58,39 @@ it('should work with browser context scripts with a path', async ({ browser, ser await context.addInitScript({ path: path.join(__dirname, 'assets/injectedfile.js') }); const page = await context.newPage(); await page.goto(server.PREFIX + '/tamperable.html'); - expect(await page.evaluate(() => window["result"])).toBe(123); + expect(await page.evaluate(() => window['result'])).toBe(123); await context.close(); }); it('should work with browser context scripts for already created pages', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); - await context.addInitScript(() => window["temp"] = 123); - await page.addInitScript(() => window["injected"] = window["temp"]); + await context.addInitScript(() => window['temp'] = 123); + await page.addInitScript(() => window['injected'] = window['temp']); await page.goto(server.PREFIX + '/tamperable.html'); - expect(await page.evaluate(() => window["result"])).toBe(123); + expect(await page.evaluate(() => window['result'])).toBe(123); await context.close(); }); it('should support multiple scripts', async ({ page, server }) => { - await page.addInitScript(function () { - window["script1"] = 1; + await page.addInitScript(function() { + window['script1'] = 1; }); - await page.addInitScript(function () { - window["script2"] = 2; + await page.addInitScript(function() { + window['script2'] = 2; }); await page.goto(server.PREFIX + '/tamperable.html'); - expect(await page.evaluate(() => window["script1"])).toBe(1); - expect(await page.evaluate(() => window["script2"])).toBe(2); + expect(await page.evaluate(() => window['script1'])).toBe(1); + expect(await page.evaluate(() => window['script2'])).toBe(2); }); it('should work with CSP', async ({ page, server }) => { server.setCSP('/empty.html', 'script-src ' + server.PREFIX); - await page.addInitScript(function () { - window["injected"] = 123; + await page.addInitScript(function() { + window['injected'] = 123; }); await page.goto(server.PREFIX + '/empty.html'); - expect(await page.evaluate(() => window["injected"])).toBe(123); + expect(await page.evaluate(() => window['injected'])).toBe(123); // Make sure CSP works. await page.addScriptTag({ content: 'window.e = 10;' }).catch(e => void e); @@ -99,9 +99,9 @@ it('should work with CSP', async ({ page, server }) => { it('should work after a cross origin navigation', async ({ page, server }) => { await page.goto(server.CROSS_PROCESS_PREFIX); - await page.addInitScript(function () { - window["injected"] = 123; + await page.addInitScript(function() { + window['injected'] = 123; }); await page.goto(server.PREFIX + '/tamperable.html'); - expect(await page.evaluate(() => window["result"])).toBe(123); + expect(await page.evaluate(() => window['result'])).toBe(123); }); diff --git a/test/page-add-script-tag.spec.ts b/test/page-add-script-tag.spec.ts index 99636444f1..78e00387d0 100644 --- a/test/page-add-script-tag.spec.ts +++ b/test/page-add-script-tag.spec.ts @@ -18,10 +18,10 @@ import { options } from './playwright.fixtures'; import path from 'path'; -it('should throw an error if no options are provided', async({page, server}) => { +it('should throw an error if no options are provided', async ({page, server}) => { let error = null; try { - //@ts-ignore + // @ts-ignore await page.addScriptTag('/injectedfile.js'); } catch (e) { error = e; @@ -29,34 +29,34 @@ it('should throw an error if no options are provided', async({page, server}) => expect(error.message).toContain('Provide an object with a `url`, `path` or `content` property'); }); -it('should work with a url', async({page, server}) => { +it('should work with a url', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const scriptHandle = await page.addScriptTag({ url: '/injectedfile.js' }); expect(scriptHandle.asElement()).not.toBeNull(); expect(await page.evaluate(() => window['__injected'])).toBe(42); }); -it('should work with a url and type=module', async({page, server}) => { +it('should work with a url and type=module', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); await page.addScriptTag({ url: '/es6/es6import.js', type: 'module' }); expect(await page.evaluate(() => window['__es6injected'])).toBe(42); }); -it('should work with a path and type=module', async({page, server}) => { +it('should work with a path and type=module', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); await page.addScriptTag({ path: path.join(__dirname, 'assets/es6/es6pathimport.js'), type: 'module' }); await page.waitForFunction('window.__es6injected'); expect(await page.evaluate(() => window['__es6injected'])).toBe(42); }); -it('should work with a content and type=module', async({page, server}) => { +it('should work with a content and type=module', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); await page.addScriptTag({ content: `import num from '/es6/es6module.js';window.__es6injected = num;`, type: 'module' }); await page.waitForFunction('window.__es6injected'); expect(await page.evaluate(() => window['__es6injected'])).toBe(42); }); -it('should throw an error if loading from url fail', async({page, server}) => { +it('should throw an error if loading from url fail', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); let error = null; try { @@ -67,28 +67,28 @@ it('should throw an error if loading from url fail', async({page, server}) => { expect(error).not.toBe(null); }); -it('should work with a path', async({page, server}) => { +it('should work with a path', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const scriptHandle = await page.addScriptTag({ path: path.join(__dirname, 'assets/injectedfile.js') }); expect(scriptHandle.asElement()).not.toBeNull(); expect(await page.evaluate(() => window['__injected'])).toBe(42); }); -it.skip(options.WEBKIT)('should include sourceURL when path is provided', async({page, server}) => { +it.skip(options.WEBKIT)('should include sourceURL when path is provided', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); await page.addScriptTag({ path: path.join(__dirname, 'assets/injectedfile.js') }); const result = await page.evaluate(() => window['__injectedError'].stack); expect(result).toContain(path.join('assets', 'injectedfile.js')); }); -it('should work with content', async({page, server}) => { +it('should work with content', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const scriptHandle = await page.addScriptTag({ content: 'window["__injected"] = 35;' }); expect(scriptHandle.asElement()).not.toBeNull(); expect(await page.evaluate(() => window['__injected'])).toBe(35); }); -it('should throw when added with content to the CSP page', async({page, server}) => { +it('should throw when added with content to the CSP page', async ({page, server}) => { // Firefox fires onload for blocked script before it issues the CSP console error. await page.goto(server.PREFIX + '/csp.html'); let error = null; @@ -96,14 +96,14 @@ it('should throw when added with content to the CSP page', async({page, server}) expect(error).toBeTruthy(); }); -it('should throw when added with URL to the CSP page', async({page, server}) => { +it('should throw when added with URL to the CSP page', async ({page, server}) => { await page.goto(server.PREFIX + '/csp.html'); let error = null; await page.addScriptTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedfile.js' }).catch(e => error = e); expect(error).toBeTruthy(); }); -it('should throw a nice error when the request fails', async({page, server}) => { +it('should throw a nice error when the request fails', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const url = server.PREFIX + '/this_does_not_exist.js'; const error = await page.addScriptTag({url}).catch(e => e); diff --git a/test/page-add-style-tag.spec.ts b/test/page-add-style-tag.spec.ts index b162037bf9..4afb6bb7c0 100644 --- a/test/page-add-style-tag.spec.ts +++ b/test/page-add-style-tag.spec.ts @@ -18,10 +18,10 @@ import './playwright.fixtures'; import path from 'path'; -it('should throw an error if no options are provided', async({page, server}) => { +it('should throw an error if no options are provided', async ({page, server}) => { let error = null; try { - //@ts-ignore + // @ts-ignore await page.addStyleTag('/injectedstyle.css'); } catch (e) { error = e; @@ -29,14 +29,14 @@ it('should throw an error if no options are provided', async({page, server}) => expect(error.message).toContain('Provide an object with a `url`, `path` or `content` property'); }); -it('should work with a url', async({page, server}) => { +it('should work with a url', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const styleHandle = await page.addStyleTag({ url: '/injectedstyle.css' }); expect(styleHandle.asElement()).not.toBeNull(); expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(255, 0, 0)'); }); -it('should throw an error if loading from url fail', async({page, server}) => { +it('should throw an error if loading from url fail', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); let error = null; try { @@ -47,14 +47,14 @@ it('should throw an error if loading from url fail', async({page, server}) => { expect(error).not.toBe(null); }); -it('should work with a path', async({page, server}) => { +it('should work with a path', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const styleHandle = await page.addStyleTag({ path: path.join(__dirname, 'assets/injectedstyle.css') }); expect(styleHandle.asElement()).not.toBeNull(); expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(255, 0, 0)'); }); -it('should include sourceURL when path is provided', async({page, server}) => { +it('should include sourceURL when path is provided', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); await page.addStyleTag({ path: path.join(__dirname, 'assets/injectedstyle.css') }); const styleHandle = await page.$('style'); @@ -62,21 +62,21 @@ it('should include sourceURL when path is provided', async({page, server}) => { expect(styleContent).toContain(path.join('assets', 'injectedstyle.css')); }); -it('should work with content', async({page, server}) => { +it('should work with content', async ({page, server}) => { await page.goto(server.EMPTY_PAGE); const styleHandle = await page.addStyleTag({ content: 'body { background-color: green; }' }); expect(styleHandle.asElement()).not.toBeNull(); expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(0, 128, 0)'); }); -it('should throw when added with content to the CSP page', async({page, server}) => { +it('should throw when added with content to the CSP page', async ({page, server}) => { await page.goto(server.PREFIX + '/csp.html'); let error = null; await page.addStyleTag({ content: 'body { background-color: green; }' }).catch(e => error = e); expect(error).toBeTruthy(); }); -it('should throw when added with URL to the CSP page', async({page, server}) => { +it('should throw when added with URL to the CSP page', async ({page, server}) => { await page.goto(server.PREFIX + '/csp.html'); let error = null; await page.addStyleTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedstyle.css' }).catch(e => error = e); diff --git a/test/page-basic.spec.ts b/test/page-basic.spec.ts index 5c43d9cf0a..e25b9cbd0b 100644 --- a/test/page-basic.spec.ts +++ b/test/page-basic.spec.ts @@ -17,7 +17,7 @@ import { options } from './playwright.fixtures'; -it('should reject all promises when page is closed', async({context}) => { +it('should reject all promises when page is closed', async ({context}) => { const newPage = await context.newPage(); let error = null; await Promise.all([ @@ -27,14 +27,14 @@ it('should reject all promises when page is closed', async({context}) => { expect(error.message).toContain('Protocol error'); }); -it('should not be visible in context.pages', async({context}) => { +it('should not be visible in context.pages', async ({context}) => { const newPage = await context.newPage(); expect(context.pages()).toContain(newPage); await newPage.close(); expect(context.pages()).not.toContain(newPage); }); -it('should run beforeunload if asked for', async({context, server}) => { +it('should run beforeunload if asked for', async ({context, server}) => { const newPage = await context.newPage(); await newPage.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers @@ -54,7 +54,7 @@ it('should run beforeunload if asked for', async({context, server}) => { await pageClosingPromise; }); -it('should *not* run beforeunload by default', async({context, server}) => { +it('should *not* run beforeunload by default', async ({context, server}) => { const newPage = await context.newPage(); await newPage.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers @@ -63,14 +63,14 @@ it('should *not* run beforeunload by default', async({context, server}) => { await newPage.close(); }); -it('should set the page close state', async({context}) => { +it('should set the page close state', async ({context}) => { const newPage = await context.newPage(); expect(newPage.isClosed()).toBe(false); await newPage.close(); expect(newPage.isClosed()).toBe(true); }); -it('should terminate network waiters', async({context, server}) => { +it('should terminate network waiters', async ({context, server}) => { const newPage = await context.newPage(); const results = await Promise.all([ newPage.waitForRequest(server.EMPTY_PAGE).catch(e => e), @@ -84,7 +84,7 @@ it('should terminate network waiters', async({context, server}) => { } }); -it('should be callable twice', async({context}) => { +it('should be callable twice', async ({context}) => { const newPage = await context.newPage(); await Promise.all([ newPage.close(), @@ -93,14 +93,14 @@ it('should be callable twice', async({context}) => { await newPage.close(); }); -it('should fire load when expected', async({page, server}) => { +it('should fire load when expected', async ({page, server}) => { await Promise.all([ page.goto('about:blank'), page.waitForEvent('load'), ]); }); -it('async stacks should work', async({page, server}) => { +it('async stacks should work', async ({page, server}) => { server.setRoute('/empty.html', (req, res) => { req.socket.end(); }); @@ -110,7 +110,7 @@ it('async stacks should work', async({page, server}) => { expect(error.stack).toContain(__filename); }); -it('should provide access to the opener page', async({page}) => { +it('should provide access to the opener page', async ({page}) => { const [popup] = await Promise.all([ page.waitForEvent('popup'), page.evaluate(() => window.open('about:blank')), @@ -119,7 +119,7 @@ it('should provide access to the opener page', async({page}) => { expect(opener).toBe(page); }); -it('should return null if parent page has been closed', async({page}) => { +it('should return null if parent page has been closed', async ({page}) => { const [popup] = await Promise.all([ page.waitForEvent('popup'), page.evaluate(() => window.open('about:blank')), @@ -129,13 +129,13 @@ it('should return null if parent page has been closed', async({page}) => { expect(opener).toBe(null); }); -it('should fire domcontentloaded when expected', async({page, server}) => { +it('should fire domcontentloaded when expected', async ({page, server}) => { const navigatedPromise = page.goto('about:blank'); await page.waitForEvent('domcontentloaded'); await navigatedPromise; }); -it('should fail with error upon disconnect', async({page, server}) => { +it('should fail with error upon disconnect', async ({page, server}) => { let error; const waitForPromise = page.waitForEvent('download').catch(e => error = e); await page.close(); @@ -143,22 +143,22 @@ it('should fail with error upon disconnect', async({page, server}) => { expect(error.message).toContain('Page closed'); }); -it('page.url should work', async({page, server}) => { +it('page.url should work', async ({page, server}) => { expect(page.url()).toBe('about:blank'); await page.goto(server.EMPTY_PAGE); expect(page.url()).toBe(server.EMPTY_PAGE); }); -it('page.url should include hashes', async({page, server}) => { +it('page.url should include hashes', async ({page, server}) => { await page.goto(server.EMPTY_PAGE + '#hash'); expect(page.url()).toBe(server.EMPTY_PAGE + '#hash'); await page.evaluate(() => { - window.location.hash = "dynamic"; + window.location.hash = 'dynamic'; }); expect(page.url()).toBe(server.EMPTY_PAGE + '#dynamic'); }); -it('page.title should return the page title', async({page, server}) => { +it('page.title should return the page title', async ({page, server}) => { await page.goto(server.PREFIX + '/title.html'); expect(await page.title()).toBe('Woof-Woof'); }); @@ -201,7 +201,7 @@ it('should have sane user agent', async ({page}) => { const userAgent = await page.evaluate(() => navigator.userAgent); const [ part1, - part2, + /* part2 */, part3, part4, part5, @@ -231,13 +231,13 @@ it('should have sane user agent', async ({page}) => { expect(engine.startsWith('Version/')).toBe(true); }); -it('page.press should work', async({page, server}) => { +it('page.press should work', async ({page, server}) => { await page.goto(server.PREFIX + '/input/textarea.html'); await page.press('textarea', 'a'); expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('a'); }); -it('frame.press should work', async({page, server}) => { +it('frame.press should work', async ({page, server}) => { await page.setContent(``); const frame = page.frame('inner'); await frame.press('textarea', 'a'); @@ -245,11 +245,11 @@ it('frame.press should work', async({page, server}) => { }); it.fail(options.FIREFOX)('frame.focus should work multiple times', async ({ context, server }) => { - const page1 = await context.newPage() - const page2 = await context.newPage() + const page1 = await context.newPage(); + const page2 = await context.newPage(); for (const page of [page1, page2]) { - await page.setContent(``) - await page.focus("#foo") - expect(await page.evaluate(() => !!window['gotFocus'])).toBe(true) + await page.setContent(``); + await page.focus('#foo'); + expect(await page.evaluate(() => !!window['gotFocus'])).toBe(true); } }); diff --git a/test/page-emulate-media.spec.ts b/test/page-emulate-media.spec.ts index 0a4660727a..e4e9ef5192 100644 --- a/test/page-emulate-media.spec.ts +++ b/test/page-emulate-media.spec.ts @@ -15,10 +15,10 @@ * limitations under the License. */ -import { options } from './playwright.fixtures'; +import './playwright.fixtures'; import utils from './utils'; -it('should emulate type', async({page, server}) => { +it('should emulate type', async ({page, server}) => { expect(await page.evaluate(() => matchMedia('screen').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('print').matches)).toBe(false); await page.emulateMedia({ media: 'print' }); @@ -32,13 +32,13 @@ it('should emulate type', async({page, server}) => { expect(await page.evaluate(() => matchMedia('print').matches)).toBe(false); }); -it('should throw in case of bad type argument', async({page, server}) => { +it('should throw in case of bad type argument', async ({page, server}) => { let error = null; await page.emulateMedia({ media: 'bad' as any}).catch(e => error = e); expect(error.message).toContain('media: expected one of (screen|print|null)'); }); -it('should emulate scheme work', async({page, server}) => { +it('should emulate scheme work', async ({page, server}) => { await page.emulateMedia({ colorScheme: 'light' }); expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(false); @@ -47,7 +47,7 @@ it('should emulate scheme work', async({page, server}) => { expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(false); }); -it('should default to light', async({page, server}) => { +it('should default to light', async ({page, server}) => { expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(false); @@ -60,13 +60,13 @@ it('should default to light', async({page, server}) => { expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(true); }); -it('should throw in case of bad argument', async({page, server}) => { +it('should throw in case of bad argument', async ({page, server}) => { let error = null; await page.emulateMedia({ colorScheme: 'bad' as any}).catch(e => error = e); expect(error.message).toContain('colorScheme: expected one of (dark|light|no-preference|null)'); }); -it('should work during navigation', async({page, server}) => { +it('should work during navigation', async ({page, server}) => { await page.emulateMedia({ colorScheme: 'light' }); const navigated = page.goto(server.EMPTY_PAGE); for (let i = 0; i < 9; i++) { @@ -79,7 +79,7 @@ it('should work during navigation', async({page, server}) => { expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true); }); -it('should work in popup', async({browser, server}) => { +it('should work in popup', async ({browser, server}) => { { const context = await browser.newContext({ colorScheme: 'dark' }); const page = await context.newPage(); @@ -105,7 +105,7 @@ it('should work in popup', async({browser, server}) => { } }); -it('should work in cross-process iframe', async({browser, server}) => { +it('should work in cross-process iframe', async ({browser, server}) => { const page = await browser.newPage({ colorScheme: 'dark' }); await page.goto(server.EMPTY_PAGE); await utils.attachFrame(page, 'frame1', server.CROSS_PROCESS_PREFIX + '/empty.html'); @@ -114,7 +114,7 @@ it('should work in cross-process iframe', async({browser, server}) => { await page.close(); }); -it('should change the actual colors in css', async({page}) => { +it('should change the actual colors in css', async ({page}) => { await page.setContent(`