From 8989d66bda325546b9c82a3edb7f6f83b434d1d2 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Tue, 18 Aug 2020 23:00:45 -0700 Subject: [PATCH] test: introduce options (#3525) --- test/accessibility.spec.ts | 30 +++++++------- test/base.fixture.ts | 40 ++++++++++-------- test/browsercontext-add-cookies.spec.ts | 2 +- test/browsercontext-cookies.spec.ts | 4 +- test/browsercontext-credentials.spec.ts | 6 +-- test/browsercontext-device.spec.ts | 6 +-- test/browsercontext-locale.spec.ts | 2 +- test/browsercontext-page-event.spec.ts | 4 +- test/browsercontext-timezone-id.spec.ts | 2 +- test/browsercontext-viewport-mobile.spec.ts | 19 ++++----- test/browsertype-connect.spec.ts | 2 +- test/browsertype-launch.spec.ts | 2 +- test/capabilities.spec.ts | 6 +-- test/channels.spec.ts | 2 +- test/chromium-css-coverage.spec.ts | 20 ++++----- test/chromium-js-coverage.spec.ts | 20 ++++----- test/chromium/chromium.spec.ts | 10 ++--- test/chromium/launcher.spec.ts | 10 ++--- test/chromium/oopif.spec.ts | 34 ++++++++-------- test/chromium/session.spec.ts | 18 ++++----- test/chromium/tracing.spec.ts | 14 +++---- test/click.spec.ts | 4 +- test/defaultbrowsercontext.spec.ts | 12 +++--- test/dialog.spec.ts | 2 +- test/dispatchevent.spec.ts | 4 +- test/download.spec.ts | 4 +- test/electron/electron-app.spec.ts | 20 ++++----- test/electron/electron-window.spec.ts | 8 ++-- test/elementhandle-bounding-box.spec.ts | 4 +- test/elementhandle-screenshot.spec.ts | 6 +-- test/emulation-focus.spec.ts | 3 +- test/firefox/launcher.spec.ts | 2 +- test/focus.spec.ts | 4 +- test/frame-evaluate.spec.ts | 4 +- test/frame-hierarchy.spec.ts | 2 +- test/headful.spec.ts | 6 +-- test/jshandle-to-string.spec.ts | 2 +- test/keyboard.spec.ts | 4 +- test/mouse.spec.ts | 6 +-- test/network-request.spec.ts | 2 +- test/page-add-script-tag.spec.ts | 4 +- test/page-basic.spec.ts | 4 +- test/page-emulate-media.spec.ts | 2 +- test/page-evaluate.spec.ts | 4 +- test/page-event-crash.spec.ts | 2 +- test/page-event-pageerror.spec.ts | 12 +++--- test/page-fill.spec.ts | 6 +-- test/page-history.spec.ts | 2 +- test/page-screenshot.spec.ts | 12 +++--- test/page-wait-for-load-state.spec.ts | 4 +- test/page-wait-for-navigation.spec.ts | 2 +- test/pdf.spec.ts | 4 +- test/permissions.spec.ts | 6 +-- test/proxy.spec.ts | 2 +- test/request-fulfill.spec.ts | 4 +- test/runner/fixtures.js | 45 +++++++++++++++++---- test/runner/fixturesUI.js | 5 ++- test/runner/testCollector.js | 6 +-- test/runner/testRunner.js | 8 ++-- test/screencast.spec.ts | 14 +++---- test/selectors-text.spec.ts | 4 +- test/types.d.ts | 7 ++-- 62 files changed, 276 insertions(+), 235 deletions(-) diff --git a/test/accessibility.spec.ts b/test/accessibility.spec.ts index c9a464edf0..a45855d488 100644 --- a/test/accessibility.spec.ts +++ b/test/accessibility.spec.ts @@ -35,7 +35,7 @@ it('should work', async function({page}) { // autofocus happens after a delay in chrome these days await page.waitForFunction(() => document.activeElement.hasAttribute('autofocus')); - const golden = FFOX ? { + const golden = options.FFOX ? { role: 'document', name: 'Accessibility Test', children: [ @@ -48,7 +48,7 @@ it('should work', async function({page}) { {role: 'textbox', name: '', value: 'and a value'}, // firefox doesn't use aria-placeholder for the name {role: 'textbox', name: '', value: 'and a value', description: 'This is a description!'}, // and here ] - } : CHROMIUM ? { + } : options.CHROMIUM ? { role: 'WebArea', name: 'Accessibility Test', children: [ @@ -82,7 +82,7 @@ it('should work with regular text', async({page}) => { await page.setContent(`
Hello World
`); const snapshot = await page.accessibility.snapshot(); expect(snapshot.children[0]).toEqual({ - role: FFOX ? 'text leaf' : 'text', + role: options.FFOX ? 'text leaf' : 'text', name: 'Hello World', }); }); @@ -124,7 +124,7 @@ it('should not report text nodes inside controls', async function({page}) {
Tab2
`); const golden = { - role: FFOX ? 'document' : 'WebArea', + role: options.FFOX ? 'document' : 'WebArea', name: '', children: [{ role: 'tab', @@ -139,12 +139,12 @@ it('should not report text nodes inside controls', async function({page}) { }); // WebKit rich text accessibility is iffy -it.skip(WEBKIT)('rich text editable fields should have children', async function({page}) { +it.skip(options.WEBKIT)('rich text editable fields should have children', async function({page}) { await page.setContent(`
Edit this image: my fake image
`); - const golden = FFOX ? { + const golden = options.FFOX ? { role: 'section', name: '', children: [{ @@ -170,12 +170,12 @@ it.skip(WEBKIT)('rich text editable fields should have children', async function expect(snapshot.children[0]).toEqual(golden); }); // WebKit rich text accessibility is iffy -it.skip(WEBKIT)('rich text editable fields with role should have children', async function({page}) { +it.skip(options.WEBKIT)('rich text editable fields with role should have children', async function({page}) { await page.setContent(`
Edit this image: my fake image
`); - const golden = FFOX ? { + const golden = options.FFOX ? { role: 'textbox', name: '', value: 'Edit this image: my fake image', @@ -199,7 +199,7 @@ it.skip(WEBKIT)('rich text editable fields with role should have children', asyn expect(snapshot.children[0]).toEqual(golden); }); -it.skip(FFOX || WEBKIT)('plain text field with role should not have children', async function({page}) { +it.skip(options.FFOX || options.WEBKIT)('plain text field with role should not have children', async function({page}) { // Firefox does not support contenteditable="plaintext-only". // WebKit rich text accessibility is iffy await page.setContent(` @@ -212,7 +212,7 @@ it.skip(FFOX || WEBKIT)('plain text field with role should not have children', a }); }); -it.skip(FFOX || WEBKIT)('plain text field without role should not have content', async function({page}) { +it.skip(options.FFOX || options.WEBKIT)('plain text field without role should not have content', async function({page}) { await page.setContent(`
Edit this image:my fake image
`); const snapshot = await page.accessibility.snapshot(); @@ -222,7 +222,7 @@ it.skip(FFOX || WEBKIT)('plain text field without role should not have content', }); }); -it.skip(FFOX || WEBKIT)('plain text field with tabindex and without role should not have content', async function({page}) { +it.skip(options.FFOX || options.WEBKIT)('plain text field with tabindex and without role should not have content', async function({page}) { await page.setContent(`
Edit this image:my fake image
`); const snapshot = await page.accessibility.snapshot(); @@ -238,11 +238,11 @@ it('non editable textbox with role and tabIndex and label should not have childr this is the inner content yo `); - const golden = FFOX ? { + const golden = options.FFOX ? { role: 'textbox', name: 'my favorite textbox', value: 'this is the inner content yo' - } : CHROMIUM ? { + } : options.CHROMIUM ? { role: 'textbox', name: 'my favorite textbox', value: 'this is the inner content ' @@ -276,7 +276,7 @@ it('checkbox without label should not have children', async function({page}) { this is the inner content yo `); - const golden = FFOX ? { + const golden = options.FFOX ? { role: 'checkbox', name: 'this is the inner content yo', checked: true @@ -327,7 +327,7 @@ it('should work on a menu', async({page}) => { [ { role: 'menuitem', name: 'First Item' }, { role: 'menuitem', name: 'Second Item' }, { role: 'menuitem', name: 'Third Item' } ], - orientation: WEBKIT ? 'vertical' : undefined + orientation: options.WEBKIT ? 'vertical' : undefined }); }); diff --git a/test/base.fixture.ts b/test/base.fixture.ts index b63f6d6815..d2f592b3d7 100644 --- a/test/base.fixture.ts +++ b/test/base.fixture.ts @@ -25,7 +25,7 @@ import { Transport } from '../lib/rpc/transport'; import { setUnderTest } from '../lib/helper'; import { installCoverageHooks } from './runner/coverage'; import { valueFromEnv } from './runner/utils'; -import { registerFixture, registerWorkerFixture, registerWorkerGenerator } from './runner/fixtures'; +import { registerFixture, registerWorkerFixture, registerOption } from './runner/fixtures'; import './runner/builtin.fixtures'; import {mkdtempAsync, removeFolderAsync} from './utils'; @@ -55,16 +55,17 @@ declare global { httpsServer: TestServer; browserServer: BrowserServer; } + interface Options { + browserName: string; + CHROMIUM: boolean; + FFOX: boolean; + WEBKIT: boolean; + } } -const browserName = process.env.BROWSER; - (global as any).MAC = platform === 'darwin'; (global as any).LINUX = platform === 'linux'; (global as any).WIN = platform === 'win32'; -(global as any).CHROMIUM = browserName === 'chromium'; -(global as any).FFOX = browserName === 'firefox'; -(global as any).WEBKIT = browserName === 'webkit'; registerWorkerFixture('httpService', async ({parallelIndex}, test) => { const assetsPath = path.join(__dirname, 'assets'); @@ -184,22 +185,20 @@ registerFixture('server', async ({httpService}, test) => { await test(httpService.server); }); -registerWorkerGenerator('browserName', () => { - if (process.env.BROWSER) - return [process.env.BROWSER]; - return ['chromium', 'webkit', 'firefox']; +registerWorkerFixture('browserName', async ({}, test) => { + await test(options.browserName); }); -registerWorkerFixture('isChromium', async ({browserName}, test) => { - await test(browserName === 'chromium'); +registerWorkerFixture('isChromium', async ({}, test) => { + await test(options.browserName === 'chromium'); }); -registerWorkerFixture('isFirefox', async ({browserName}, test) => { - await test(browserName === 'firefox'); +registerWorkerFixture('isFirefox', async ({}, test) => { + await test(options.browserName === 'firefox'); }); -registerWorkerFixture('isWebKit', async ({browserName}, test) => { - await test(browserName === 'webkit'); +registerWorkerFixture('isWebKit', async ({}, test) => { + await test(options.browserName === 'webkit'); }); registerFixture('httpsServer', async ({httpService}, test) => { @@ -220,3 +219,12 @@ registerWorkerFixture('asset', async ({}, test) => { registerWorkerFixture('golden', async ({browserName}, test) => { await test(p => path.join(browserName, p)); }); + +registerOption('browserName', () => { + if (process.env.BROWSER) + return [process.env.BROWSER]; + return ['chromium', 'webkit', 'firefox']; +}); +registerOption('CHROMIUM', ({browserName}) => browserName === 'chromium'); +registerOption('FFOX', ({browserName}) => browserName === 'firefox'); +registerOption('WEBKIT', ({browserName}) => browserName === 'webkit'); diff --git a/test/browsercontext-add-cookies.spec.ts b/test/browsercontext-add-cookies.spec.ts index 27bf5fe8af..9ba681ba40 100644 --- a/test/browsercontext-add-cookies.spec.ts +++ b/test/browsercontext-add-cookies.spec.ts @@ -325,7 +325,7 @@ it('should(not) block third party cookies', async({context, page, server}) => { }, server.CROSS_PROCESS_PREFIX + '/grid.html'); await page.frames()[1].evaluate(`document.cookie = 'username=John Doe'`); await page.waitForTimeout(2000); - const allowsThirdParty = CHROMIUM || FFOX; + const allowsThirdParty = options.CHROMIUM || options.FFOX; const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html'); if (allowsThirdParty) { expect(cookies).toEqual([ diff --git a/test/browsercontext-cookies.spec.ts b/test/browsercontext-cookies.spec.ts index 61d940a282..7eef0d5e73 100644 --- a/test/browsercontext-cookies.spec.ts +++ b/test/browsercontext-cookies.spec.ts @@ -72,7 +72,7 @@ it('should properly report httpOnly cookie', async({context, page, server}) => { expect(cookies[0].httpOnly).toBe(true); }); -it.fail(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(WEBKIT && WIN)('should properly report "Strict" sameSite cookie', async( expect(cookies[0].sameSite).toBe('Strict'); }); -it.fail(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(); diff --git a/test/browsercontext-credentials.spec.ts b/test/browsercontext-credentials.spec.ts index 53f648ad14..95e61221ca 100644 --- a/test/browsercontext-credentials.spec.ts +++ b/test/browsercontext-credentials.spec.ts @@ -18,7 +18,7 @@ import './base.fixture'; const { HEADLESS } = testOptions; -it.fail(CHROMIUM && !HEADLESS)('should fail without credentials', async({browser, server}) => { +it.fail(options.CHROMIUM && !HEADLESS)('should fail without credentials', async({browser, server}) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext(); const page = await context.newPage(); @@ -27,7 +27,7 @@ it.fail(CHROMIUM && !HEADLESS)('should fail without credentials', async({browser await context.close(); }); -it.fail(CHROMIUM && !HEADLESS)('should work with setHTTPCredentials', async({browser, server}) => { +it.fail(options.CHROMIUM && !HEADLESS)('should work with setHTTPCredentials', async({browser, server}) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext(); const page = await context.newPage(); @@ -50,7 +50,7 @@ it('should work with correct credentials', async({browser, server}) => { await context.close(); }); -it.fail(CHROMIUM && !HEADLESS)('should fail with wrong credentials', async({browser, server}) => { +it.fail(options.CHROMIUM && !HEADLESS)('should fail with wrong credentials', async({browser, server}) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext({ httpCredentials: { username: 'foo', password: 'bar' } diff --git a/test/browsercontext-device.spec.ts b/test/browsercontext-device.spec.ts index e448d8a92b..b4c88a39eb 100644 --- a/test/browsercontext-device.spec.ts +++ b/test/browsercontext-device.spec.ts @@ -16,7 +16,7 @@ */ import './base.fixture'; -it.skip(FFOX)('should work', async({playwright, browser, server}) => { +it.skip(options.FFOX)('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(FFOX)('should work', async({playwright, browser, server}) => { await context.close(); }); -it.skip(FFOX)('should support clicking', async({playwright, browser, server}) => { +it.skip(options.FFOX)('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(FFOX)('should support clicking', async({playwright, browser, server}) => await context.close(); }); -it.skip(FFOX)('should scroll to click', async({browser, server}) => { +it.skip(options.FFOX)('should scroll to click', async({browser, server}) => { const context = await browser.newContext({ viewport: { width: 400, diff --git a/test/browsercontext-locale.spec.ts b/test/browsercontext-locale.spec.ts index f37ed462c6..5114313273 100644 --- a/test/browsercontext-locale.spec.ts +++ b/test/browsercontext-locale.spec.ts @@ -137,7 +137,7 @@ it('should be isolated between contexts', async({browser, server}) => { ]); }); -it.fail(FFOX)('should not change default locale in another context', async({browser, server}) => { +it.fail(options.FFOX)('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 09ad98763a..66dff0a12b 100644 --- a/test/browsercontext-page-event.spec.ts +++ b/test/browsercontext-page-event.spec.ts @@ -156,7 +156,7 @@ it('should fire page lifecycle events', async function({browser, server}) { await context.close(); }); -it.fail(WEBKIT)('should work with Shift-clicking', async({browser, server}) => { +it.fail(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.fail(WEBKIT)('should work with Shift-clicking', async({browser, server}) => { await context.close(); }); -it.fail(WEBKIT || FFOX)('should work with Ctrl-clicking', async({browser, server}) => { +it.fail(options.WEBKIT || options.FFOX)('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-timezone-id.spec.ts b/test/browsercontext-timezone-id.spec.ts index d377408860..b934100753 100644 --- a/test/browsercontext-timezone-id.spec.ts +++ b/test/browsercontext-timezone-id.spec.ts @@ -69,7 +69,7 @@ it('should work for multiple pages sharing same process', async({browser, server await context.close(); }); -it.fail(FFOX)('should not change default timezone in another context', async({browser, server}) => { +it.fail(options.FFOX)('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-viewport-mobile.spec.ts b/test/browsercontext-viewport-mobile.spec.ts index f364a8f984..ad98171b39 100644 --- a/test/browsercontext-viewport-mobile.spec.ts +++ b/test/browsercontext-viewport-mobile.spec.ts @@ -14,9 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import './base.fixture'; -it.skip(FFOX)('should support mobile emulation', async({playwright, browser, server}) => { +it.skip(options.FFOX)('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(); @@ -27,7 +28,7 @@ it.skip(FFOX)('should support mobile emulation', async({playwright, browser, ser await context.close(); }); -it.skip(FFOX)('should support touch emulation', async({playwright, browser, server}) => { +it.skip(options.FFOX)('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(); @@ -50,7 +51,7 @@ it.skip(FFOX)('should support touch emulation', async({playwright, browser, serv } }); -it.skip(FFOX)('should be detectable by Modernizr', async({playwright, browser, server}) => { +it.skip(options.FFOX)('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(); @@ -59,7 +60,7 @@ it.skip(FFOX)('should be detectable by Modernizr', async({playwright, browser, s await context.close(); }); -it.skip(FFOX)('should detect touch when applying viewport with touches', async({browser, server}) => { +it.skip(options.FFOX)('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); @@ -68,7 +69,7 @@ it.skip(FFOX)('should detect touch when applying viewport with touches', async({ await context.close(); }); -it.skip(FFOX)('should support landscape emulation', async({playwright, browser, server}) => { +it.skip(options.FFOX)('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 }); @@ -82,7 +83,7 @@ it.skip(FFOX)('should support landscape emulation', async({playwright, browser, await context2.close(); }); -it.skip(FFOX)('should support window.orientation emulation', async({browser, server}) => { +it.skip(options.FFOX)('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'); @@ -92,7 +93,7 @@ it.skip(FFOX)('should support window.orientation emulation', async({browser, ser await context.close(); }); -it.skip(FFOX)('should fire orientationchange event', async({browser, server}) => { +it.skip(options.FFOX)('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'); @@ -111,7 +112,7 @@ it.skip(FFOX)('should fire orientationchange event', async({browser, server}) => await context.close(); }); -it.skip(FFOX)('default mobile viewports to 980 width', async({browser, server}) => { +it.skip(options.FFOX)('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'); @@ -119,7 +120,7 @@ it.skip(FFOX)('default mobile viewports to 980 width', async({browser, server}) await context.close(); }); -it.skip(FFOX)('respect meta viewport tag', async({browser, server}) => { +it.skip(options.FFOX)('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/browsertype-connect.spec.ts b/test/browsertype-connect.spec.ts index a861f7bc13..41e3208067 100644 --- a/test/browsertype-connect.spec.ts +++ b/test/browsertype-connect.spec.ts @@ -37,7 +37,7 @@ it.skip(WIRE).slow()('should be able to reconnect to a browser', async({browserT await browserServer.close(); }); -it.skip(WIRE).fail(CHROMIUM && WIN).slow()('should handle exceptions during connect', async({browserType, defaultBrowserOptions}) => { +it.skip(WIRE).fail(options.CHROMIUM && WIN).slow()('should handle exceptions during connect', async({browserType, defaultBrowserOptions}) => { const browserServer = await browserType.launchServer(defaultBrowserOptions); const __testHookBeforeCreateBrowser = () => { throw new Error('Dummy') }; const error = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint(), __testHookBeforeCreateBrowser } as any).catch(e => e); diff --git a/test/browsertype-launch.spec.ts b/test/browsertype-launch.spec.ts index 5fa364c0b6..97449a2a0a 100644 --- a/test/browsertype-launch.spec.ts +++ b/test/browsertype-launch.spec.ts @@ -38,7 +38,7 @@ it('should throw if userDataDir option is passed', async({browserType, defaultBr expect(waitError.message).toContain('launchPersistentContext'); }); -it.skip(FFOX)('should throw if page argument is passed', async({browserType, defaultBrowserOptions}) => { +it.skip(options.FFOX)('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); diff --git a/test/capabilities.spec.ts b/test/capabilities.spec.ts index 916bdd9040..4a71ca74a4 100644 --- a/test/capabilities.spec.ts +++ b/test/capabilities.spec.ts @@ -17,7 +17,7 @@ import url from 'url'; import './base.fixture'; -it.fail(WEBKIT && WIN)('Web Assembly should work', async function({page, server}) { +it.fail(options.WEBKIT && WIN)('Web Assembly should work', async function({page, server}) { await page.goto(server.PREFIX + '/wasm/table2.html'); expect(await page.evaluate('loadTable()')).toBe('42, 83'); }); @@ -48,13 +48,13 @@ it('should respect CSP', async({page, server}) => { expect(await page.evaluate(() => window['testStatus'])).toBe('SUCCESS'); }); -it.fail(WEBKIT && (WIN || LINUX))('should play video', async({page, asset}) => { +it.fail(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. // // Safari only plays mp4 so we test WebKit with an .mp4 clip. - const fileName = WEBKIT ? 'video_mp4.html' : 'video.html'; + const fileName = options.WEBKIT ? 'video_mp4.html' : 'video.html'; const absolutePath = asset(fileName); // Our test server doesn't support range requests required to play on Mac, // so we load the page using a file url. diff --git a/test/channels.spec.ts b/test/channels.spec.ts index e7a620ee6b..0d77729561 100644 --- a/test/channels.spec.ts +++ b/test/channels.spec.ts @@ -65,7 +65,7 @@ it('should scope context handles', async({browserType, browser, server}) => { await expectScopeState(browser, GOLDEN_PRECONDITION); }); -it.skip(!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: [ diff --git a/test/chromium-css-coverage.spec.ts b/test/chromium-css-coverage.spec.ts index 64c0b302dc..65f4804cf7 100644 --- a/test/chromium-css-coverage.spec.ts +++ b/test/chromium-css-coverage.spec.ts @@ -15,7 +15,7 @@ */ import './base.fixture'; -it.skip(!CHROMIUM)('should work', async function({browserType, page, server}) { +it.skip(!options.CHROMIUM)('should work', async function({browserType, page, server}) { await page.coverage.startCSSCoverage(); await page.goto(server.PREFIX + '/csscoverage/simple.html'); const coverage = await page.coverage.stopCSSCoverage(); @@ -28,7 +28,7 @@ it.skip(!CHROMIUM)('should work', async function({browserType, page, server}) { expect(coverage[0].text.substring(range.start, range.end)).toBe('div { color: green; }'); }); -it.skip(!CHROMIUM)('should report sourceURLs', async function({page, server}) { +it.skip(!options.CHROMIUM)('should report sourceURLs', async function({page, server}) { await page.coverage.startCSSCoverage(); await page.goto(server.PREFIX + '/csscoverage/sourceurl.html'); const coverage = await page.coverage.stopCSSCoverage(); @@ -36,7 +36,7 @@ it.skip(!CHROMIUM)('should report sourceURLs', async function({page, server}) { expect(coverage[0].url).toBe('nicename.css'); }); -it.skip(!CHROMIUM)('should report multiple stylesheets', async function({page, server}) { +it.skip(!options.CHROMIUM)('should report multiple stylesheets', async function({page, server}) { await page.coverage.startCSSCoverage(); await page.goto(server.PREFIX + '/csscoverage/multiple.html'); const coverage = await page.coverage.stopCSSCoverage(); @@ -46,7 +46,7 @@ it.skip(!CHROMIUM)('should report multiple stylesheets', async function({page, s expect(coverage[1].url).toContain('/csscoverage/stylesheet2.css'); }); -it.skip(!CHROMIUM)('should report stylesheets that have no coverage', async function({page, server}) { +it.skip(!options.CHROMIUM)('should report stylesheets that have no coverage', async function({page, server}) { await page.coverage.startCSSCoverage(); await page.goto(server.PREFIX + '/csscoverage/unused.html'); const coverage = await page.coverage.stopCSSCoverage(); @@ -55,7 +55,7 @@ it.skip(!CHROMIUM)('should report stylesheets that have no coverage', async func expect(coverage[0].ranges.length).toBe(0); }); -it.skip(!CHROMIUM)('should work with media queries', async function({page, server}) { +it.skip(!options.CHROMIUM)('should work with media queries', async function({page, server}) { await page.coverage.startCSSCoverage(); await page.goto(server.PREFIX + '/csscoverage/media.html'); const coverage = await page.coverage.stopCSSCoverage(); @@ -66,7 +66,7 @@ it.skip(!CHROMIUM)('should work with media queries', async function({page, serve ]); }); -it.skip(!CHROMIUM)('should work with complicated usecases', async function({page, server}) { +it.skip(!options.CHROMIUM)('should work with complicated usecases', async function({page, server}) { await page.coverage.startCSSCoverage(); await page.goto(server.PREFIX + '/csscoverage/involved.html'); const coverage: any = await page.coverage.stopCSSCoverage(); @@ -90,7 +90,7 @@ it.skip(!CHROMIUM)('should work with complicated usecases', async function({page ); }); -it.skip(!CHROMIUM)('should ignore injected stylesheets', async function({page, server}) { +it.skip(!options.CHROMIUM)('should ignore injected stylesheets', async function({page, server}) { await page.coverage.startCSSCoverage(); await page.addStyleTag({content: 'body { margin: 10px;}'}); // trigger style recalc @@ -100,7 +100,7 @@ it.skip(!CHROMIUM)('should ignore injected stylesheets', async function({page, s expect(coverage.length).toBe(0); }); -it.skip(!CHROMIUM)('should report stylesheets across navigations', async function({page, server}) { +it.skip(!options.CHROMIUM)('should report stylesheets across navigations', async function({page, server}) { await page.coverage.startCSSCoverage({resetOnNavigation: false}); await page.goto(server.PREFIX + '/csscoverage/multiple.html'); await page.goto(server.EMPTY_PAGE); @@ -108,7 +108,7 @@ it.skip(!CHROMIUM)('should report stylesheets across navigations', async functio expect(coverage.length).toBe(2); }); -it.skip(!CHROMIUM)('should NOT report scripts across navigations', async function({page, server}) { +it.skip(!options.CHROMIUM)('should NOT report scripts across navigations', async function({page, server}) { await page.coverage.startCSSCoverage(); // Enabled by default. await page.goto(server.PREFIX + '/csscoverage/multiple.html'); await page.goto(server.EMPTY_PAGE); @@ -116,7 +116,7 @@ it.skip(!CHROMIUM)('should NOT report scripts across navigations', async functio expect(coverage.length).toBe(0); }); -it.skip(!CHROMIUM)('should work with a recently loaded stylesheet', async function({page, server}) { +it.skip(!options.CHROMIUM)('should work with a recently loaded stylesheet', async function({page, server}) { await page.coverage.startCSSCoverage(); await page.evaluate(async url => { document.body.textContent = 'hello, world'; diff --git a/test/chromium-js-coverage.spec.ts b/test/chromium-js-coverage.spec.ts index 49fed712f7..739afcfba1 100644 --- a/test/chromium-js-coverage.spec.ts +++ b/test/chromium-js-coverage.spec.ts @@ -15,11 +15,11 @@ */ import './base.fixture'; -it.skip(CHROMIUM)('should be missing', async function({page, server}) { +it.skip(options.CHROMIUM)('should be missing', async function({page, server}) { expect(page.coverage).toBe(null); }); -it.skip(!CHROMIUM)('should work', async function({browserType, page, server}) { +it.skip(!options.CHROMIUM)('should work', async function({browserType, page, server}) { await page.coverage.startJSCoverage(); await page.goto(server.PREFIX + '/jscoverage/simple.html', { waitUntil: 'load' }); const coverage = await page.coverage.stopJSCoverage(); @@ -28,7 +28,7 @@ it.skip(!CHROMIUM)('should work', async function({browserType, page, server}) { expect(coverage[0].functions.find(f => f.functionName === 'foo').ranges[0].count).toEqual(1); }); -it.skip(!CHROMIUM)('should report sourceURLs', async function({page, server}) { +it.skip(!options.CHROMIUM)('should report sourceURLs', async function({page, server}) { await page.coverage.startJSCoverage(); await page.goto(server.PREFIX + '/jscoverage/sourceurl.html'); const coverage = await page.coverage.stopJSCoverage(); @@ -36,14 +36,14 @@ it.skip(!CHROMIUM)('should report sourceURLs', async function({page, server}) { expect(coverage[0].url).toBe('nicename.js'); }); -it.skip(!CHROMIUM)('should ignore eval() scripts by default', async function({page, server}) { +it.skip(!options.CHROMIUM)('should ignore eval() scripts by default', async function({page, server}) { await page.coverage.startJSCoverage(); await page.goto(server.PREFIX + '/jscoverage/eval.html'); const coverage = await page.coverage.stopJSCoverage(); expect(coverage.length).toBe(1); }); -it.skip(!CHROMIUM)('shouldn\'t ignore eval() scripts if reportAnonymousScripts is true', async function({page, server}) { +it.skip(!options.CHROMIUM)('shouldn\'t ignore eval() scripts if reportAnonymousScripts is true', async function({page, server}) { await page.coverage.startJSCoverage({reportAnonymousScripts: true}); await page.goto(server.PREFIX + '/jscoverage/eval.html'); const coverage = await page.coverage.stopJSCoverage(); @@ -51,7 +51,7 @@ it.skip(!CHROMIUM)('shouldn\'t ignore eval() scripts if reportAnonymousScripts i expect(coverage.length).toBe(2); }); -it.skip(!CHROMIUM)('should ignore playwright internal scripts if reportAnonymousScripts is true', async function({page, server}) { +it.skip(!options.CHROMIUM)('should ignore playwright internal scripts if reportAnonymousScripts is true', async function({page, server}) { await page.coverage.startJSCoverage({reportAnonymousScripts: true}); await page.goto(server.EMPTY_PAGE); await page.evaluate('console.log("foo")'); @@ -60,7 +60,7 @@ it.skip(!CHROMIUM)('should ignore playwright internal scripts if reportAnonymous expect(coverage.length).toBe(0); }); -it.skip(!CHROMIUM)('should report multiple scripts', async function({page, server}) { +it.skip(!options.CHROMIUM)('should report multiple scripts', async function({page, server}) { await page.coverage.startJSCoverage(); await page.goto(server.PREFIX + '/jscoverage/multiple.html'); const coverage = await page.coverage.stopJSCoverage(); @@ -70,7 +70,7 @@ it.skip(!CHROMIUM)('should report multiple scripts', async function({page, serve expect(coverage[1].url).toContain('/jscoverage/script2.js'); }); -it.skip(!CHROMIUM)('should report scripts across navigations when disabled', async function({page, server}) { +it.skip(!options.CHROMIUM)('should report scripts across navigations when disabled', async function({page, server}) { await page.coverage.startJSCoverage({resetOnNavigation: false}); await page.goto(server.PREFIX + '/jscoverage/multiple.html'); await page.goto(server.EMPTY_PAGE); @@ -78,7 +78,7 @@ it.skip(!CHROMIUM)('should report scripts across navigations when disabled', asy expect(coverage.length).toBe(2); }); -it.skip(!CHROMIUM)('should NOT report scripts across navigations when enabled', async function({page, server}) { +it.skip(!options.CHROMIUM)('should NOT report scripts across navigations when enabled', async function({page, server}) { await page.coverage.startJSCoverage(); // Enabled by default. await page.goto(server.PREFIX + '/jscoverage/multiple.html'); await page.goto(server.EMPTY_PAGE); @@ -86,7 +86,7 @@ it.skip(!CHROMIUM)('should NOT report scripts across navigations when enabled', expect(coverage.length).toBe(0); }); -it.skip(!CHROMIUM)('should not hang when there is a debugger statement', async function({page, server}) { +it.skip(!options.CHROMIUM)('should not hang when there is a debugger statement', async function({page, server}) { await page.coverage.startJSCoverage(); await page.goto(server.EMPTY_PAGE); await page.evaluate(() => { diff --git a/test/chromium/chromium.spec.ts b/test/chromium/chromium.spec.ts index 29f1189392..c6af27b0ab 100644 --- a/test/chromium/chromium.spec.ts +++ b/test/chromium/chromium.spec.ts @@ -16,7 +16,7 @@ import '../base.fixture'; import { ChromiumBrowserContext } from '../..'; -it.skip(!CHROMIUM)('should create a worker from a service worker', async({page, server, context}) => { +it.skip(!options.CHROMIUM)('should create a worker from a service worker', async({page, server, context}) => { const [worker] = await Promise.all([ (context as ChromiumBrowserContext).waitForEvent('serviceworker'), page.goto(server.PREFIX + '/serviceworkers/empty/sw.html') @@ -24,7 +24,7 @@ it.skip(!CHROMIUM)('should create a worker from a service worker', async({page, expect(await worker.evaluate(() => self.toString())).toBe('[object ServiceWorkerGlobalScope]'); }); -it.skip(!CHROMIUM)('serviceWorkers() should return current workers', async({page, server, context}) => { +it.skip(!options.CHROMIUM)('serviceWorkers() should return current workers', async({page, server, context}) => { const [worker1] = await Promise.all([ (context as ChromiumBrowserContext).waitForEvent('serviceworker'), page.goto(server.PREFIX + '/serviceworkers/empty/sw.html') @@ -42,7 +42,7 @@ it.skip(!CHROMIUM)('serviceWorkers() should return current workers', async({page expect(workers).toContain(worker2); }); -it.skip(!CHROMIUM)('should not create a worker from a shared worker', async({page, server, context}) => { +it.skip(!options.CHROMIUM)('should not create a worker from a shared worker', async({page, server, context}) => { await page.goto(server.EMPTY_PAGE); let serviceWorkerCreated; (context as ChromiumBrowserContext).once('serviceworker', () => serviceWorkerCreated = true); @@ -52,7 +52,7 @@ it.skip(!CHROMIUM)('should not create a worker from a shared worker', async({pag expect(serviceWorkerCreated).not.toBeTruthy(); }); -it.skip(!CHROMIUM)('should close service worker together with the context', async({browser, server}) => { +it.skip(!options.CHROMIUM)('should close service worker together with the context', async({browser, server}) => { const context = await browser.newContext() as ChromiumBrowserContext; const page = await context.newPage(); const [worker] = await Promise.all([ @@ -66,7 +66,7 @@ it.skip(!CHROMIUM)('should close service worker together with the context', asyn expect(messages.join('|')).toBe('worker|context'); }); -it.skip(!CHROMIUM)('Page.route should work with intervention headers', async({server, page}) => { +it.skip(!options.CHROMIUM)('Page.route should work with intervention headers', async({server, page}) => { server.setRoute('/intervention', (req, res) => res.end(` '); expect(await page.evaluate(() => window['copy'])).toBe(42); }); -it.skip(!CHROMIUM)('should expose function', async ({ application }) => { +it.skip(!options.CHROMIUM)('should expose function', async ({ application }) => { const t = Date.now(); await application.context().exposeFunction('add', (a, b) => a + b); const page = await application.newBrowserWindow({ width: 800, height: 600 }); @@ -106,7 +106,7 @@ it.skip(!CHROMIUM)('should expose function', async ({ application }) => { expect(await page.evaluate(() => window['result'])).toBe(42); }); -it.skip(!CHROMIUM)('should wait for first window', async ({ application }) => { +it.skip(!options.CHROMIUM)('should wait for first window', async ({ application }) => { application.evaluate(({ BrowserWindow }) => { const window = new BrowserWindow({ width: 800, height: 600 }); window.loadURL('data:text/html,Hello World!'); @@ -115,7 +115,7 @@ it.skip(!CHROMIUM)('should wait for first window', async ({ application }) => { expect(await window.title()).toBe('Hello World!'); }); -it.skip(!CHROMIUM)('should have a clipboard instance', async ({ application }) => { +it.skip(!options.CHROMIUM)('should have a clipboard instance', async ({ application }) => { const clipboardContentToWrite = 'Hello from Playwright'; await application.evaluate(async ({clipboard}, text) => clipboard.writeText(text), clipboardContentToWrite); const clipboardContentRead = await application.evaluate(async ({clipboard}) => clipboard.readText()); diff --git a/test/electron/electron-window.spec.ts b/test/electron/electron-window.spec.ts index 8bb7f7fdef..363bd6d597 100644 --- a/test/electron/electron-window.spec.ts +++ b/test/electron/electron-window.spec.ts @@ -15,25 +15,25 @@ */ import './electron.fixture'; -it.skip(!CHROMIUM)('should click the button', async({window, server}) => { +it.skip(!options.CHROMIUM)('should click the button', async({window, server}) => { await window.goto(server.PREFIX + '/input/button.html'); await window.click('button'); expect(await window.evaluate('result')).toBe('Clicked'); }); -it.skip(!CHROMIUM)('should check the box', async({window}) => { +it.skip(!options.CHROMIUM)('should check the box', async({window}) => { await window.setContent(``); await window.check('input'); expect(await window.evaluate('checkbox.checked')).toBe(true); }); -it.skip(!CHROMIUM)('should not check the checked box', async({window}) => { +it.skip(!options.CHROMIUM)('should not check the checked box', async({window}) => { await window.setContent(``); await window.check('input'); expect(await window.evaluate('checkbox.checked')).toBe(true); }); -it.skip(!CHROMIUM)('should type into a textarea', async({window, server}) => { +it.skip(!options.CHROMIUM)('should type into a textarea', async({window, server}) => { await window.evaluate(() => { const textarea = document.createElement('textarea'); document.body.appendChild(textarea); diff --git a/test/elementhandle-bounding-box.spec.ts b/test/elementhandle-bounding-box.spec.ts index 89da20bd94..6cb36ab132 100644 --- a/test/elementhandle-bounding-box.spec.ts +++ b/test/elementhandle-bounding-box.spec.ts @@ -18,7 +18,7 @@ import './base.fixture'; const { HEADLESS } = testOptions; -it.fail(FFOX && !HEADLESS)('should work', async ({ page, server }) => { +it.fail(options.FFOX && !HEADLESS)('should work', async ({ page, server }) => { await page.setViewportSize({ width: 500, height: 500 }); await page.goto(server.PREFIX + '/grid.html'); const elementHandle = await page.$('.box:nth-of-type(13)'); @@ -65,7 +65,7 @@ it('should work with SVG nodes', async ({ page, server }) => { expect(pwBoundingBox).toEqual(webBoundingBox); }); -it.skip(FFOX)('should work with page scale', async ({ browser, server }) => { +it.skip(options.FFOX)('should work with page scale', async ({ browser, server }) => { const context = await browser.newContext({ viewport: { width: 400, height: 400 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/input/button.html'); diff --git a/test/elementhandle-screenshot.spec.ts b/test/elementhandle-screenshot.spec.ts index 50521363d3..8dd4a7afd8 100644 --- a/test/elementhandle-screenshot.spec.ts +++ b/test/elementhandle-screenshot.spec.ts @@ -23,7 +23,7 @@ import path from 'path'; import fs from 'fs'; // Firefox headful produces a different image. -const ffheadful = FFOX && !HEADLESS; +const ffheadful = options.FFOX && !HEADLESS; it.skip(ffheadful)('should work', async({page, server, golden}) => { await page.setViewportSize({width: 500, height: 500}); @@ -211,7 +211,7 @@ it.skip(ffheadful)('should work for an element with fractional dimensions', asyn expect(screenshot).toMatchImage(golden('screenshot-element-fractional.png')); }); -it.skip(FFOX)('should work with a mobile viewport', async({browser, server, golden}) => { +it.skip(options.FFOX)('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'); @@ -222,7 +222,7 @@ it.skip(FFOX)('should work with a mobile viewport', async({browser, server, gold await context.close(); }); -it.skip(FFOX)('should work with device scale factor', async({browser, server, golden}) => { +it.skip(options.FFOX)('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'); diff --git a/test/emulation-focus.spec.ts b/test/emulation-focus.spec.ts index ae2dd8e1d5..5f8d6d3d41 100644 --- a/test/emulation-focus.spec.ts +++ b/test/emulation-focus.spec.ts @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import './base.fixture'; import utils from './utils'; @@ -102,7 +103,7 @@ it('should change document.activeElement', async({page, server}) => { expect(active).toEqual(['INPUT', 'TEXTAREA']); }); -it.skip(FFOX && !HEADLESS)('should not affect screenshots', async({page, server, golden}) => { +it.skip(options.FFOX && !HEADLESS)('should not affect screenshots', async({page, server, golden}) => { // Firefox headful produces a different image. const page2 = await page.context().newPage(); await Promise.all([ diff --git a/test/firefox/launcher.spec.ts b/test/firefox/launcher.spec.ts index 609a5f0c9c..952318ba23 100644 --- a/test/firefox/launcher.spec.ts +++ b/test/firefox/launcher.spec.ts @@ -15,7 +15,7 @@ */ import '../base.fixture'; -it.skip(!FFOX)('should pass firefox user preferences', async({browserType, defaultBrowserOptions}) => { +it.skip(!options.FFOX)('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 17f468b1bc..1442b06e05 100644 --- a/test/focus.spec.ts +++ b/test/focus.spec.ts @@ -15,7 +15,7 @@ */ import './base.fixture'; -it('should work', async function({page, server}) { +it.skip(options.FFOX)('should work', async function({page, server}) { await page.setContent(`
`); expect(await page.evaluate(() => document.activeElement.nodeName)).toBe('BODY'); await page.focus('#d1'); @@ -77,7 +77,7 @@ it('should traverse focus in all directions', async function({page}) { // Chromium and WebKit both have settings for tab traversing all links, but // it is only on by default in WebKit. -it.skip(!MAC || !WEBKIT)('should traverse only form elements', async function({page}) { +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 6a47f0ed19..bf109bbd2b 100644 --- a/test/frame-evaluate.spec.ts +++ b/test/frame-evaluate.spec.ts @@ -127,7 +127,7 @@ it('should be isolated between frames', async({page, server}) => { expect(a2).toBe(2); }); -it.fail(CHROMIUM || FFOX)('should work in iframes that failed initial navigation', async({page, server}) => { +it.fail(options.CHROMIUM || options.FFOX)('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. @@ -148,7 +148,7 @@ it.fail(CHROMIUM || FFOX)('should work in iframes that failed initial navigation expect(await page.frames()[1].$('div')).toBeTruthy(); }); -it.fail(CHROMIUM)('should work in iframes that interrupted initial javascript url navigation', async({page, server}) => { +it.fail(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(() => { diff --git a/test/frame-hierarchy.spec.ts b/test/frame-hierarchy.spec.ts index b332b9eb72..2a3b90bea7 100644 --- a/test/frame-hierarchy.spec.ts +++ b/test/frame-hierarchy.spec.ts @@ -172,7 +172,7 @@ it('should report different frame instance when frame re-attaches', async({page, expect(frame1).not.toBe(frame2); }); -it.fail(FFOX)('should refuse to display x-frame-options:deny iframe', async({page, server}) => { +it.fail(options.FFOX)('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'); diff --git a/test/headful.spec.ts b/test/headful.spec.ts index 169fbe0feb..b4cb897377 100644 --- a/test/headful.spec.ts +++ b/test/headful.spec.ts @@ -27,7 +27,7 @@ it('should have default url when launching browser', async ({browserType, defaul await browserContext.close(); }); -it.fail(WIN && 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 @@ -107,7 +107,7 @@ it('should(not) block third party cookies', async({browserType, defaultBrowserOp return document.cookie; }); await page.waitForTimeout(2000); - const allowsThirdParty = CHROMIUM || FFOX; + const allowsThirdParty = options.CHROMIUM || options.FFOX; expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : ''); const cookies = await page.context().cookies(server.CROSS_PROCESS_PREFIX + '/grid.html'); if (allowsThirdParty) { @@ -129,7 +129,7 @@ it('should(not) block third party cookies', async({browserType, defaultBrowserOp await browser.close(); }); -it.fail(WEBKIT)('should not override viewport size when passed null', async function({browserType, defaultBrowserOptions, server}) { +it.fail(options.WEBKIT)('should not override viewport size when passed null', async function({browserType, defaultBrowserOptions, server}) { // Our WebKit embedder does not respect window features. const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); const context = await browser.newContext({ viewport: null }); diff --git a/test/jshandle-to-string.spec.ts b/test/jshandle-to-string.spec.ts index 448cd61588..b5d7967450 100644 --- a/test/jshandle-to-string.spec.ts +++ b/test/jshandle-to-string.spec.ts @@ -53,6 +53,6 @@ it('should work with different subtypes', async({page}) => { expect((await page.evaluateHandle('new WeakSet()')).toString()).toBe('JSHandle@weakset'); expect((await page.evaluateHandle('new Error()')).toString()).toBe('JSHandle@error'); // TODO(yurys): change subtype from array to typedarray in WebKit. - expect((await page.evaluateHandle('new Int32Array()')).toString()).toBe(WEBKIT ? 'JSHandle@array' : 'JSHandle@typedarray'); + expect((await page.evaluateHandle('new Int32Array()')).toString()).toBe(options.WEBKIT ? 'JSHandle@array' : 'JSHandle@typedarray'); expect((await page.evaluateHandle('new Proxy({}, {})')).toString()).toBe('JSHandle@proxy'); }); diff --git a/test/keyboard.spec.ts b/test/keyboard.spec.ts index 0ec51c665d..2fa00d2784 100644 --- a/test/keyboard.spec.ts +++ b/test/keyboard.spec.ts @@ -83,7 +83,7 @@ it('insertText should only emit input event', async ({page, server}) => { expect(await events.jsonValue()).toEqual(['input']); }); -it.fail(FFOX && MAC)('should report shiftKey', async ({page, server}) => { +it.fail(options.FFOX && MAC)('should report shiftKey', async ({page, server}) => { await page.goto(server.PREFIX + '/input/keyboard.html'); const keyboard = page.keyboard; const codeForKey = {'Shift': 16, 'Alt': 18, 'Control': 17}; @@ -380,7 +380,7 @@ it('should work after a cross origin navigation', async ({page, server}) => { }); // event.keyIdentifier has been removed from all browsers except WebKit -it.skip(!WEBKIT)('should expose keyIdentifier in webkit', async ({page, server}) => { +it.skip(!options.WEBKIT)('should expose keyIdentifier in webkit', async ({page, server}) => { const lastEvent = await captureLastKeydown(page); const keyMap = { 'ArrowUp': 'Up', diff --git a/test/mouse.spec.ts b/test/mouse.spec.ts index 0b6d9bbe70..088fe664d3 100644 --- a/test/mouse.spec.ts +++ b/test/mouse.spec.ts @@ -26,8 +26,8 @@ function dimensions() { }; } -it.fail(FFOX && WIN)('should click the document', async({page, server}) => { - // Occasionally times out on FFOX on Windows: https://github.com/microsoft/playwright/pull/1911/checks?check_run_id=607149016 +it.fail(options.FFOX && WIN)('should click the document', async({page, server}) => { + // Occasionally times out on options.FFOX on Windows: https://github.com/microsoft/playwright/pull/1911/checks?check_run_id=607149016 await page.evaluate(() => { window["clickPromise"] = new Promise(resolve => { document.addEventListener('click', event => { @@ -163,7 +163,7 @@ it('should tween mouse movement', async({page, isWebKit}) => { ]); }); -it.skip(FFOX)('should work with mobile viewports and cross process navigations', async({browser, server}) => { +it.skip(options.FFOX)('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(); diff --git a/test/network-request.spec.ts b/test/network-request.spec.ts index 22438120d1..a4e121134c 100644 --- a/test/network-request.spec.ts +++ b/test/network-request.spec.ts @@ -55,7 +55,7 @@ it('should return headers', async({page, server, isChromium, isFirefox, isWebKit expect(response.request().headers()['user-agent']).toContain('WebKit'); }); -it.fail(CHROMIUM||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) => { diff --git a/test/page-add-script-tag.spec.ts b/test/page-add-script-tag.spec.ts index 9a60192913..431d028f41 100644 --- a/test/page-add-script-tag.spec.ts +++ b/test/page-add-script-tag.spec.ts @@ -74,7 +74,7 @@ it('should work with a path', async({page, server}) => { expect(await page.evaluate(() => window['__injected'])).toBe(42); }); -it.skip(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); @@ -88,7 +88,7 @@ it('should work with content', async({page, server}) => { expect(await page.evaluate(() => window['__injected'])).toBe(35); }); -it.fail(FFOX)('should throw when added with content to the CSP page', async({page, server}) => { +it.fail(options.FFOX)('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; diff --git a/test/page-basic.spec.ts b/test/page-basic.spec.ts index 30997c549e..a6748a8e63 100644 --- a/test/page-basic.spec.ts +++ b/test/page-basic.spec.ts @@ -218,7 +218,7 @@ it('should have sane user agent', async ({page, isChromium, isFirefox}) => { expect(part5).toBe(undefined); return; } - // For both CHROMIUM and WEBKIT, third part is the AppleWebKit version. + // For both options.CHROMIUM and options.WEBKIT, third part is the AppleWebKit version. expect(part3.startsWith('AppleWebKit/')).toBe(true); expect(part4).toBe('KHTML, like Gecko'); // 5th part encodes real browser name and engine version. @@ -243,7 +243,7 @@ it('frame.press should work', async({page, server}) => { expect(await frame.evaluate(() => document.querySelector('textarea').value)).toBe('a'); }); -it.fail(FFOX)('frame.focus should work multiple times', async ({ context, server }) => { +it.fail(options.FFOX)('frame.focus should work multiple times', async ({ context, server }) => { const page1 = await context.newPage() const page2 = await context.newPage() for (const page of [page1, page2]) { diff --git a/test/page-emulate-media.spec.ts b/test/page-emulate-media.spec.ts index d673826d38..374118e144 100644 --- a/test/page-emulate-media.spec.ts +++ b/test/page-emulate-media.spec.ts @@ -114,7 +114,7 @@ it('should work in cross-process iframe', async({browser, server}) => { await page.close(); }); -it.fail(FFOX)('should change the actual colors in css', async({page}) => { +it.fail(options.FFOX)('should change the actual colors in css', async({page}) => { await page.setContent(`