Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: convert rename options to parameters, remove options magic (#3543)

Pavel Feldman86815d70e05f
diff --git a/package.json b/package.json
index c4806f40a1..699f12adeb 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
"tsc": "tsc -p .",
"tsc-installer": "tsc -p ./src/install/tsconfig.json",
"doc": "node utils/doclint/cli.js",
- "test-infra": "node test/runner utils/doclint/check_public_api/test/test.js && node test/runner utils/doclint/preprocessor/test.js",
+ "test-infra": "node test/runner/cli utils/doclint/check_public_api/test/test.js && node test/runner/cli utils/doclint/preprocessor/test.js",
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && npm run generate-channels && npm run test-types && npm run test-infra",
"clean": "rimraf lib && rimraf types",
"prepare": "node install-from-github.js",
diff --git a/test/accessibility.spec.ts b/test/accessibility.spec.ts
index a45855d488..1eac353ec3 100644
--- a/test/accessibility.spec.ts
+++ b/test/accessibility.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it('should work', async function({page}) {
await page.setContent(`
@@ -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 = options.FFOX ? {
+ const golden = options.FIREFOX() ? {
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
]
- } : options.CHROMIUM ? {
+ } : options.CHROMIUM() ? {
role: 'WebArea',
name: 'Accessibility Test',
children: [
@@ -82,7 +82,7 @@ it('should work with regular text', async({page}) => {
await page.setContent(`<div>Hello World</div>`);
const snapshot = await page.accessibility.snapshot();
expect(snapshot.children[0]).toEqual({
- role: options.FFOX ? 'text leaf' : 'text',
+ role: options.FIREFOX() ? 'text leaf' : 'text',
name: 'Hello World',
});
});
@@ -124,7 +124,7 @@ it('should not report text nodes inside controls', async function({page}) {
<div role="tab">Tab2</div>
</div>`);
const golden = {
- role: options.FFOX ? 'document' : 'WebArea',
+ role: options.FIREFOX() ? '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(options.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(`
<div contenteditable="true">
Edit this image: <img src="fakeimage.png" alt="my fake image">
</div>`);
- const golden = options.FFOX ? {
+ const golden = options.FIREFOX() ? {
role: 'section',
name: '',
children: [{
@@ -170,12 +170,12 @@ it.skip(options.WEBKIT)('rich text editable fields should have children', async
expect(snapshot.children[0]).toEqual(golden);
});
// WebKit rich text accessibility is iffy
-it.skip(options.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(`
<div contenteditable="true" role='textbox'>
Edit this image: <img src="fakeimage.png" alt="my fake image">
</div>`);
- const golden = options.FFOX ? {
+ const golden = options.FIREFOX() ? {
role: 'textbox',
name: '',
value: 'Edit this image: my fake image',
@@ -199,7 +199,7 @@ it.skip(options.WEBKIT)('rich text editable fields with role should have childre
expect(snapshot.children[0]).toEqual(golden);
});
-it.skip(options.FFOX || options.WEBKIT)('plain text field with role should not have children', async function({page}) {
+it.skip(options.FIREFOX() || 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(options.FFOX || options.WEBKIT)('plain text field with role should not h
});
});
-it.skip(options.FFOX || options.WEBKIT)('plain text field without role should not have content', async function({page}) {
+it.skip(options.FIREFOX() || options.WEBKIT())('plain text field without role should not have content', async function({page}) {
await page.setContent(`
<div contenteditable="plaintext-only">Edit this image:<img src="fakeimage.png" alt="my fake image"></div>`);
const snapshot = await page.accessibility.snapshot();
@@ -222,7 +222,7 @@ it.skip(options.FFOX || options.WEBKIT)('plain text field without role should no
});
});
-it.skip(options.FFOX || options.WEBKIT)('plain text field with tabindex and without role should not have content', async function({page}) {
+it.skip(options.FIREFOX() || options.WEBKIT())('plain text field with tabindex and without role should not have content', async function({page}) {
await page.setContent(`
<div contenteditable="plaintext-only" tabIndex=0>Edit this image:<img src="fakeimage.png" alt="my fake image"></div>`);
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
<img alt="yo" src="fakeimg.png">
</div>`);
- const golden = options.FFOX ? {
+ const golden = options.FIREFOX() ? {
role: 'textbox',
name: 'my favorite textbox',
value: 'this is the inner content yo'
- } : options.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
<img alt="yo" src="fakeimg.png">
</div>`);
- const golden = options.FFOX ? {
+ const golden = options.FIREFOX() ? {
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: options.WEBKIT ? 'vertical' : undefined
+ orientation: options.WEBKIT() ? 'vertical' : undefined
});
});
diff --git a/test/autowaiting-basic.spec.ts b/test/autowaiting-basic.spec.ts
index a96c2ba321..13a47a941b 100644
--- a/test/autowaiting-basic.spec.ts
+++ b/test/autowaiting-basic.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it('should await navigation when clicking anchor', async({page, server}) => {
const messages = [];
diff --git a/test/autowaiting-no-hang.spec.ts b/test/autowaiting-no-hang.spec.ts
index 43da0fd210..10d1a964de 100644
--- a/test/autowaiting-no-hang.spec.ts
+++ b/test/autowaiting-no-hang.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
it('clicking on links which do not commit navigation', async({page, server, httpsServer}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/browser.spec.ts b/test/browser.spec.ts
index 173bff416f..c9b8209aa0 100644
--- a/test/browser.spec.ts
+++ b/test/browser.spec.ts
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it('should create new page', async function({browser}) {
const page1 = await browser.newPage();
@@ -39,7 +39,7 @@ it('should throw upon second create new page', async function({browser}) {
it('version should work', async function({browser}) {
const version = browser.version();
- if (options.CHROMIUM)
+ if (options.CHROMIUM())
expect(version.match(/^\d+\.\d+\.\d+\.\d+$/)).toBeTruthy();
else
expect(version.match(/^\d+\.\d+/)).toBeTruthy();
diff --git a/test/browsercontext-add-cookies.spec.ts b/test/browsercontext-add-cookies.spec.ts
index 9ba681ba40..f90544f778 100644
--- a/test/browsercontext-add-cookies.spec.ts
+++ b/test/browsercontext-add-cookies.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it('should work', async({context, page, server}) => {
await page.goto(server.EMPTY_PAGE);
@@ -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 = options.CHROMIUM || options.FFOX;
+ const allowsThirdParty = options.CHROMIUM() || options.FIREFOX();
const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) {
expect(cookies).toEqual([
diff --git a/test/browsercontext-basic.spec.ts b/test/browsercontext-basic.spec.ts
index 700f08f093..62ee4658bb 100644
--- a/test/browsercontext-basic.spec.ts
+++ b/test/browsercontext-basic.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import utils from './utils';
@@ -184,7 +184,7 @@ it('should disable javascript', async({browser}) => {
await page.goto('data:text/html, <script>var something = "forbidden"</script>');
let error = null;
await page.evaluate('something').catch(e => error = e);
- if (options.WEBKIT)
+ if (options.WEBKIT())
expect(error.message).toContain('Can\'t find variable: something');
else
expect(error.message).toContain('something is not defined');
diff --git a/test/browsercontext-clearcookies.spec.ts b/test/browsercontext-clearcookies.spec.ts
index 26f48b9703..10441460b2 100644
--- a/test/browsercontext-clearcookies.spec.ts
+++ b/test/browsercontext-clearcookies.spec.ts
@@ -14,9 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
-import utils from './utils';
+import './playwright.fixtures';
it('should clear cookies', async({context, page, server}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/browsercontext-cookies.spec.ts b/test/browsercontext-cookies.spec.ts
index 7eef0d5e73..6415e05e95 100644
--- a/test/browsercontext-cookies.spec.ts
+++ b/test/browsercontext-cookies.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it('should return no cookies in pristine browser context', async({context, page, server}) => {
expect(await context.cookies()).toEqual([]);
@@ -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();
diff --git a/test/browsercontext-credentials.spec.ts b/test/browsercontext-credentials.spec.ts
index 8de0621b39..9de68b5e63 100644
--- a/test/browsercontext-credentials.spec.ts
+++ b/test/browsercontext-credentials.spec.ts
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+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();
@@ -48,7 +48,7 @@ it('should work with correct credentials', async({browser, server}) => {
await context.close();
});
-it.fail(options.CHROMIUM && !options.HEADLESS)('should fail with wrong credentials', async({browser, server}) => {
+it.fail(options.CHROMIUM() && !options.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-csp.spec.ts b/test/browsercontext-csp.spec.ts
index ede92827e2..cdc67a4207 100644
--- a/test/browsercontext-csp.spec.ts
+++ b/test/browsercontext-csp.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import * as utils from './utils';
diff --git a/test/browsercontext-device.spec.ts b/test/browsercontext-device.spec.ts
index b4c88a39eb..4e22c69d3b 100644
--- a/test/browsercontext-device.spec.ts
+++ b/test/browsercontext-device.spec.ts
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
-it.skip(options.FFOX)('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.FFOX)('should work', async({playwright, browser, server}) => {
await context.close();
});
-it.skip(options.FFOX)('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.FFOX)('should support clicking', async({playwright, browser, ser
await context.close();
});
-it.skip(options.FFOX)('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 185c835a27..f506fe9a49 100644
--- a/test/browsercontext-expose-function.spec.ts
+++ b/test/browsercontext-expose-function.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
it('expose binding should work', async({browser}) => {
const context = await browser.newContext();
diff --git a/test/browsercontext-locale.spec.ts b/test/browsercontext-locale.spec.ts
index 5114313273..865a77cd96 100644
--- a/test/browsercontext-locale.spec.ts
+++ b/test/browsercontext-locale.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it('should affect accept-language header', async({browser, server}) => {
const context = await browser.newContext({ locale: 'fr-CH' });
@@ -137,7 +137,7 @@ it('should be isolated between contexts', async({browser, server}) => {
]);
});
-it.fail(options.FFOX)('should not change default locale in another context', async({browser, server}) => {
+it.fail(options.FIREFOX())('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 66dff0a12b..67bd58526e 100644
--- a/test/browsercontext-page-event.spec.ts
+++ b/test/browsercontext-page-event.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it('should have url', async({browser, server}) => {
const context = await browser.newContext();
@@ -156,7 +156,7 @@ it('should fire page lifecycle events', async function({browser, server}) {
await context.close();
});
-it.fail(options.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(options.WEBKIT)('should work with Shift-clicking', async({browser, serve
await context.close();
});
-it.fail(options.WEBKIT || options.FFOX)('should work with Ctrl-clicking', async({browser, server}) => {
+it.fail(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 f21471c685..0fbbd2e8d0 100644
--- a/test/browsercontext-route.spec.ts
+++ b/test/browsercontext-route.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
it('should intercept', async({browser, server}) => {
const context = await browser.newContext();
diff --git a/test/browsercontext-timezone-id.spec.ts b/test/browsercontext-timezone-id.spec.ts
index b934100753..6e726bd538 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 './base.fixture';
+import { options } from './playwright.fixtures';
it('should work', async ({ browser }) => {
const func = () => new Date(1479579154987).toString();
@@ -69,7 +69,7 @@ it('should work for multiple pages sharing same process', async({browser, server
await context.close();
});
-it.fail(options.FFOX)('should not change default timezone in another context', async({browser, server}) => {
+it.fail(options.FIREFOX())('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 5d003c124c..1b293fcb37 100644
--- a/test/browsercontext-user-agent.spec.ts
+++ b/test/browsercontext-user-agent.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import utils from './utils';
const {devices} = require('..');
diff --git a/test/browsercontext-viewport-mobile.spec.ts b/test/browsercontext-viewport-mobile.spec.ts
index ad98171b39..d39562bdc7 100644
--- a/test/browsercontext-viewport-mobile.spec.ts
+++ b/test/browsercontext-viewport-mobile.spec.ts
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
-it.skip(options.FFOX)('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.FFOX)('should support mobile emulation', async({playwright, brow
await context.close();
});
-it.skip(options.FFOX)('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.FFOX)('should support touch emulation', async({playwright, brows
}
});
-it.skip(options.FFOX)('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.FFOX)('should be detectable by Modernizr', async({playwright, br
await context.close();
});
-it.skip(options.FFOX)('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.FFOX)('should detect touch when applying viewport with touches',
await context.close();
});
-it.skip(options.FFOX)('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.FFOX)('should support landscape emulation', async({playwright, b
await context2.close();
});
-it.skip(options.FFOX)('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.FFOX)('should support window.orientation emulation', async({brow
await context.close();
});
-it.skip(options.FFOX)('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.FFOX)('should fire orientationchange event', async({browser, ser
await context.close();
});
-it.skip(options.FFOX)('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.FFOX)('default mobile viewports to 980 width', async({browser, s
await context.close();
});
-it.skip(options.FFOX)('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 676a277ef2..0bb42bc3a3 100644
--- a/test/browsercontext-viewport.spec.ts
+++ b/test/browsercontext-viewport.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import utils from './utils';
diff --git a/test/browsertype-basic.spec.ts b/test/browsertype-basic.spec.ts
index 8510a5ec49..ecefd54604 100644
--- a/test/browsertype-basic.spec.ts
+++ b/test/browsertype-basic.spec.ts
@@ -16,7 +16,7 @@
*/
import fs from 'fs';
-import './base.fixture';
+import { options } from './playwright.fixtures';
it.skip(Boolean(process.env.CRPATH || process.env.FFPATH || process.env.WKPATH))('browserType.executablePath should work', async({browserType}) => {
const executablePath = browserType.executablePath();
@@ -25,11 +25,11 @@ it.skip(Boolean(process.env.CRPATH || process.env.FFPATH || process.env.WKPATH))
});
it('browserType.name should work', async({browserType}) => {
- if (options.WEBKIT)
+ if (options.WEBKIT())
expect(browserType.name()).toBe('webkit');
- else if (options.FFOX)
+ else if (options.FIREFOX())
expect(browserType.name()).toBe('firefox');
- else if (options.CHROMIUM)
+ else if (options.CHROMIUM())
expect(browserType.name()).toBe('chromium');
else
throw new Error('Unknown browser');
diff --git a/test/browsertype-connect.spec.ts b/test/browsertype-connect.spec.ts
index 33049257f5..b1188f2a67 100644
--- a/test/browsertype-connect.spec.ts
+++ b/test/browsertype-connect.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it.skip(options.WIRE).slow()('should be able to reconnect to a browser', async({browserType, defaultBrowserOptions, server}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions);
@@ -36,7 +36,7 @@ it.skip(options.WIRE).slow()('should be able to reconnect to a browser', async({
await browserServer.close();
});
-it.skip(options.WIRE).fail(options.CHROMIUM && WIN).slow()('should handle exceptions during connect', async({browserType, defaultBrowserOptions}) => {
+it.skip(options.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-server.spec.ts b/test/browsertype-launch-server.spec.ts
index 92cc3f44ff..05e17b8920 100644
--- a/test/browsertype-launch-server.spec.ts
+++ b/test/browsertype-launch-server.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it.skip(options.WIRE)('should work', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions);
diff --git a/test/browsertype-launch.spec.ts b/test/browsertype-launch.spec.ts
index 0c27db9a83..87dc19a6ae 100644
--- a/test/browsertype-launch.spec.ts
+++ b/test/browsertype-launch.spec.ts
@@ -16,8 +16,7 @@
*/
import path from 'path';
-import './base.fixture';
-
+import { options } from './playwright.fixtures';
it('should reject all promises when browser is closed', async({browserType, defaultBrowserOptions}) => {
const browser = await browserType.launch(defaultBrowserOptions);
@@ -37,7 +36,7 @@ it('should throw if userDataDir option is passed', async({browserType, defaultBr
expect(waitError.message).toContain('launchPersistentContext');
});
-it.skip(options.FFOX)('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);
diff --git a/test/capabilities.spec.ts b/test/capabilities.spec.ts
index 4a71ca74a4..14093c9a2a 100644
--- a/test/capabilities.spec.ts
+++ b/test/capabilities.spec.ts
@@ -15,9 +15,9 @@
*/
import url from 'url';
-import './base.fixture';
+import { options } from './playwright.fixtures';
-it.fail(options.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(options.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 = options.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 0d77729561..192963aae1 100644
--- a/test/channels.spec.ts
+++ b/test/channels.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import { ChromiumBrowser } from '..';
it('should work', async({browser}) => {
@@ -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: [
diff --git a/test/check.spec.ts b/test/check.spec.ts
index db987757f5..902ff3e7bd 100644
--- a/test/check.spec.ts
+++ b/test/check.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
it('should check the box', async({page}) => {
await page.setContent(`<input id='checkbox' type='checkbox'></input>`);
diff --git a/test/chromium-css-coverage.spec.ts b/test/chromium-css-coverage.spec.ts
index 65f4804cf7..cf64cc91ef 100644
--- a/test/chromium-css-coverage.spec.ts
+++ b/test/chromium-css-coverage.spec.ts
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
-it.skip(!options.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(!options.CHROMIUM)('should work', async function({browserType, page, ser
expect(coverage[0].text.substring(range.start, range.end)).toBe('div { color: green; }');
});
-it.skip(!options.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(!options.CHROMIUM)('should report sourceURLs', async function({page, ser
expect(coverage[0].url).toBe('nicename.css');
});
-it.skip(!options.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(!options.CHROMIUM)('should report multiple stylesheets', async function(
expect(coverage[1].url).toContain('/csscoverage/stylesheet2.css');
});
-it.skip(!options.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(!options.CHROMIUM)('should report stylesheets that have no coverage', as
expect(coverage[0].ranges.length).toBe(0);
});
-it.skip(!options.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(!options.CHROMIUM)('should work with media queries', async function({pag
]);
});
-it.skip(!options.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(!options.CHROMIUM)('should work with complicated usecases', async functi
);
});
-it.skip(!options.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(!options.CHROMIUM)('should ignore injected stylesheets', async function(
expect(coverage.length).toBe(0);
});
-it.skip(!options.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(!options.CHROMIUM)('should report stylesheets across navigations', async
expect(coverage.length).toBe(2);
});
-it.skip(!options.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(!options.CHROMIUM)('should NOT report scripts across navigations', async
expect(coverage.length).toBe(0);
});
-it.skip(!options.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 739afcfba1..1c298fd1d7 100644
--- a/test/chromium-js-coverage.spec.ts
+++ b/test/chromium-js-coverage.spec.ts
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
-it.skip(options.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(!options.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(!options.CHROMIUM)('should work', async function({browserType, page, ser
expect(coverage[0].functions.find(f => f.functionName === 'foo').ranges[0].count).toEqual(1);
});
-it.skip(!options.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(!options.CHROMIUM)('should report sourceURLs', async function({page, ser
expect(coverage[0].url).toBe('nicename.js');
});
-it.skip(!options.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(!options.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(!options.CHROMIUM)('shouldn\'t ignore eval() scripts if reportAnonymousS
expect(coverage.length).toBe(2);
});
-it.skip(!options.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(!options.CHROMIUM)('should ignore playwright internal scripts if reportA
expect(coverage.length).toBe(0);
});
-it.skip(!options.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(!options.CHROMIUM)('should report multiple scripts', async function({pag
expect(coverage[1].url).toContain('/jscoverage/script2.js');
});
-it.skip(!options.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(!options.CHROMIUM)('should report scripts across navigations when disabl
expect(coverage.length).toBe(2);
});
-it.skip(!options.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(!options.CHROMIUM)('should NOT report scripts across navigations when en
expect(coverage.length).toBe(0);
});
-it.skip(!options.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 c6af27b0ab..3e71a27e3e 100644
--- a/test/chromium/chromium.spec.ts
+++ b/test/chromium/chromium.spec.ts
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import '../base.fixture';
+import { options } from '../playwright.fixtures';
import { ChromiumBrowserContext } from '../..';
-it.skip(!options.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(!options.CHROMIUM)('should create a worker from a service worker', async
expect(await worker.evaluate(() => self.toString())).toBe('[object ServiceWorkerGlobalScope]');
});
-it.skip(!options.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(!options.CHROMIUM)('serviceWorkers() should return current workers', asy
expect(workers).toContain(worker2);
});
-it.skip(!options.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(!options.CHROMIUM)('should not create a worker from a shared worker', as
expect(serviceWorkerCreated).not.toBeTruthy();
});
-it.skip(!options.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(!options.CHROMIUM)('should close service worker together with the contex
expect(messages.join('|')).toBe('worker|context');
});
-it.skip(!options.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(`
<script>
document.write('<script src="${server.CROSS_PROCESS_PREFIX}/intervention.js">' + '</scr' + 'ipt>');
diff --git a/test/chromium/launcher.spec.ts b/test/chromium/launcher.spec.ts
index 2758eca624..f490e70747 100644
--- a/test/chromium/launcher.spec.ts
+++ b/test/chromium/launcher.spec.ts
@@ -13,28 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import '../base.fixture';
+import { options } from '../playwright.fixtures';
import path from 'path';
import utils from '../utils';
import { ChromiumBrowser, ChromiumBrowserContext } from '../..';
const { makeUserDataDir, removeUserDataDir } = utils;
-it.skip(options.WIRE || !options.CHROMIUM)('should throw with remote-debugging-pipe argument', async({browserType, defaultBrowserOptions}) => {
+it.skip(options.WIRE || !options.CHROMIUM())('should throw with remote-debugging-pipe argument', async({browserType, defaultBrowserOptions}) => {
const options = Object.assign({}, defaultBrowserOptions);
options.args = ['--remote-debugging-pipe'].concat(options.args || []);
const error = await browserType.launchServer(options).catch(e => e);
expect(error.message).toContain('Playwright manages remote debugging connection itself');
});
-it.skip(options.WIRE || !options.CHROMIUM)('should not throw with remote-debugging-port argument', async({browserType, defaultBrowserOptions}) => {
+it.skip(options.WIRE || !options.CHROMIUM())('should not throw with remote-debugging-port argument', async({browserType, defaultBrowserOptions}) => {
const options = Object.assign({}, defaultBrowserOptions);
options.args = ['--remote-debugging-port=0'].concat(options.args || []);
const browser = await browserType.launchServer(options);
await browser.close();
});
-it.skip(!options.CHROMIUM || options.WIRE || WIN)('should open devtools when "devtools: true" option is given', async({browserType, defaultBrowserOptions}) => {
+it.skip(!options.CHROMIUM() || options.WIRE || WIN)('should open devtools when "devtools: true" option is given', async({browserType, defaultBrowserOptions}) => {
let devtoolsCallback;
const devtoolsPromise = new Promise(f => devtoolsCallback = f);
const __testHookForDevTools = devtools => devtools.__testHookOnBinding = parsed => {
@@ -50,7 +50,7 @@ it.skip(!options.CHROMIUM || options.WIRE || WIN)('should open devtools when "de
await browser.close();
});
-it.skip(!options.CHROMIUM)('should return background pages', async({browserType, defaultBrowserOptions}) => {
+it.skip(!options.CHROMIUM())('should return background pages', async({browserType, defaultBrowserOptions}) => {
const userDataDir = await makeUserDataDir();
const extensionPath = path.join(__dirname, '..', 'assets', 'simple-extension');
const extensionOptions = {...defaultBrowserOptions,
@@ -72,7 +72,7 @@ it.skip(!options.CHROMIUM)('should return background pages', async({browserType,
await removeUserDataDir(userDataDir);
});
-it.skip(!options.CHROMIUM)('should not create pages automatically', async ({browserType, defaultBrowserOptions}) => {
+it.skip(!options.CHROMIUM())('should not create pages automatically', async ({browserType, defaultBrowserOptions}) => {
const browser = await browserType.launch(defaultBrowserOptions);
const browserSession = await (browser as ChromiumBrowser).newBrowserCDPSession();
const targets = [];
diff --git a/test/chromium/oopif.spec.ts b/test/chromium/oopif.spec.ts
index 471cc06429..71aee10e58 100644
--- a/test/chromium/oopif.spec.ts
+++ b/test/chromium/oopif.spec.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import '../base.fixture';
+import { options } from '../playwright.fixtures';
import { registerWorkerFixture } from '../runner';
registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => {
@@ -26,14 +26,14 @@ registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, te
await browser.close();
});
-it.skip(!options.CHROMIUM)('should report oopif frames', async function({browser, page, server}) {
+it.skip(!options.CHROMIUM())('should report oopif frames', async function({browser, page, server}) {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(await countOOPIFs(browser)).toBe(1);
expect(page.frames().length).toBe(2);
expect(await page.frames()[1].evaluate(() => '' + location.href)).toBe(server.CROSS_PROCESS_PREFIX + '/grid.html');
});
-it.skip(!options.CHROMIUM)('should handle oopif detach', async function({browser, page, server}) {
+it.skip(!options.CHROMIUM())('should handle oopif detach', async function({browser, page, server}) {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(await countOOPIFs(browser)).toBe(1);
expect(page.frames().length).toBe(2);
@@ -46,7 +46,7 @@ it.skip(!options.CHROMIUM)('should handle oopif detach', async function({browser
expect(detachedFrame).toBe(frame);
});
-it.skip(!options.CHROMIUM)('should handle remote -> local -> remote transitions', async function({browser, page, server}) {
+it.skip(!options.CHROMIUM())('should handle remote -> local -> remote transitions', async function({browser, page, server}) {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1);
@@ -84,7 +84,7 @@ it.fail(true)('should get the proper viewport', async({browser, page, server}) =
expect(await oopif.evaluate(() => 'ontouchstart' in window)).toBe(false);
});
-it.skip(!options.CHROMIUM)('should expose function', async({browser, page, server}) => {
+it.skip(!options.CHROMIUM())('should expose function', async({browser, page, server}) => {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1);
@@ -96,7 +96,7 @@ it.skip(!options.CHROMIUM)('should expose function', async({browser, page, serve
expect(result).toBe(36);
});
-it.skip(!options.CHROMIUM)('should emulate media', async({browser, page, server}) => {
+it.skip(!options.CHROMIUM())('should emulate media', async({browser, page, server}) => {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1);
@@ -106,7 +106,7 @@ it.skip(!options.CHROMIUM)('should emulate media', async({browser, page, server}
expect(await oopif.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true);
});
-it.skip(!options.CHROMIUM)('should emulate offline', async({browser, page, context, server}) => {
+it.skip(!options.CHROMIUM())('should emulate offline', async({browser, page, context, server}) => {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1);
@@ -116,7 +116,7 @@ it.skip(!options.CHROMIUM)('should emulate offline', async({browser, page, conte
expect(await oopif.evaluate(() => navigator.onLine)).toBe(false);
});
-it.skip(!options.CHROMIUM)('should support context options', async({browser, server, playwright}) => {
+it.skip(!options.CHROMIUM())('should support context options', async({browser, server, playwright}) => {
const iPhone = playwright.devices['iPhone 6']
const context = await browser.newContext({ ...iPhone, timezoneId: 'America/Jamaica', locale: 'fr-CH', userAgent: 'UA' });
const page = await context.newPage();
@@ -138,7 +138,7 @@ it.skip(!options.CHROMIUM)('should support context options', async({browser, ser
await context.close();
});
-it.skip(!options.CHROMIUM)('should respect route', async({browser, page, server}) => {
+it.skip(!options.CHROMIUM())('should respect route', async({browser, page, server}) => {
let intercepted = false;
await page.route('**/digits/0.png', route => {
intercepted = true;
@@ -150,7 +150,7 @@ it.skip(!options.CHROMIUM)('should respect route', async({browser, page, server}
expect(intercepted).toBe(true);
});
-it.skip(!options.CHROMIUM)('should take screenshot', async({browser, page, server, golden}) => {
+it.skip(!options.CHROMIUM())('should take screenshot', async({browser, page, server, golden}) => {
await page.setViewportSize({width: 500, height: 500});
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2);
@@ -158,13 +158,13 @@ it.skip(!options.CHROMIUM)('should take screenshot', async({browser, page, serve
expect(await page.screenshot()).toMatchImage(golden('screenshot-oopif.png'), { threshold: 0.3 });
});
-it.skip(!options.CHROMIUM)('should load oopif iframes with subresources and request interception', async function({browser, page, server, context}) {
+it.skip(!options.CHROMIUM())('should load oopif iframes with subresources and request interception', async function({browser, page, server, context}) {
await page.route('**/*', route => route.continue());
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(await countOOPIFs(browser)).toBe(1);
});
-it.skip(!options.CHROMIUM)('should report main requests', async function({browser, page, server}) {
+it.skip(!options.CHROMIUM())('should report main requests', async function({browser, page, server}) {
const requestFrames = [];
page.on('request', r => requestFrames.push(r.frame()));
const finishedFrames = [];
@@ -202,7 +202,7 @@ it.skip(!options.CHROMIUM)('should report main requests', async function({browse
expect(finishedFrames[2]).toBe(grandChild);
});
-it.skip(!options.CHROMIUM)('should support exposeFunction', async function({browser, context, page, server}) {
+it.skip(!options.CHROMIUM())('should support exposeFunction', async function({browser, context, page, server}) {
await context.exposeFunction('dec', a => a - 1);
await page.exposeFunction('inc', a => a + 1);
await page.goto(server.PREFIX + '/dynamic-oopif.html');
@@ -214,7 +214,7 @@ it.skip(!options.CHROMIUM)('should support exposeFunction', async function({brow
expect(await page.frames()[1].evaluate(() => window['dec'](4))).toBe(3);
});
-it.skip(!options.CHROMIUM)('should support addInitScript', async function({browser, context, page, server}) {
+it.skip(!options.CHROMIUM())('should support addInitScript', async function({browser, context, page, server}) {
await context.addInitScript(() => window['bar'] = 17);
await page.addInitScript(() => window['foo'] = 42);
await page.goto(server.PREFIX + '/dynamic-oopif.html');
@@ -226,14 +226,14 @@ it.skip(!options.CHROMIUM)('should support addInitScript', async function({brows
expect(await page.frames()[1].evaluate(() => window['bar'])).toBe(17);
});
// @see https://github.com/microsoft/playwright/issues/1240
-it.skip(!options.CHROMIUM)('should click a button when it overlays oopif', async function({browser, page, server}) {
+it.skip(!options.CHROMIUM())('should click a button when it overlays oopif', async function({browser, page, server}) {
await page.goto(server.PREFIX + '/button-overlay-oopif.html');
expect(await countOOPIFs(browser)).toBe(1);
await page.click('button');
expect(await page.evaluate(() => window['BUTTON_CLICKED'])).toBe(true);
});
-it.skip(!options.CHROMIUM)('should report google.com frame with headful', async({browserType, defaultBrowserOptions, server}) => {
+it.skip(!options.CHROMIUM())('should report google.com frame with headful', async({browserType, defaultBrowserOptions, server}) => {
// @see https://github.com/GoogleChrome/puppeteer/issues/2548
// https://google.com is isolated by default in Chromium embedder.
const browser = await browserType.launch({...defaultBrowserOptions, headless: false});
@@ -258,7 +258,7 @@ it.skip(!options.CHROMIUM)('should report google.com frame with headful', async(
await browser.close();
});
-it.skip(!options.CHROMIUM)('ElementHandle.boundingBox() should work', async function({browser, page, server}) {
+it.skip(!options.CHROMIUM())('ElementHandle.boundingBox() should work', async function({browser, page, server}) {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
await page.$eval('iframe', iframe => {
iframe.style.width = '500px';
@@ -281,7 +281,7 @@ it.skip(!options.CHROMIUM)('ElementHandle.boundingBox() should work', async func
expect(await handle2.boundingBox()).toEqual({ x: 100 + 42, y: 50 + 17, width: 50, height: 50 });
});
-it.skip(!options.CHROMIUM)('should click', async function({browser, page, server}) {
+it.skip(!options.CHROMIUM())('should click', async function({browser, page, server}) {
await page.goto(server.PREFIX + '/dynamic-oopif.html');
await page.$eval('iframe', iframe => {
iframe.style.width = '500px';
diff --git a/test/chromium/session.spec.ts b/test/chromium/session.spec.ts
index 355a71a71a..cfcf7b1f33 100644
--- a/test/chromium/session.spec.ts
+++ b/test/chromium/session.spec.ts
@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import '../base.fixture';
+import { options } from '../playwright.fixtures';
import { ChromiumBrowserContext, ChromiumBrowser } from "../../types/types";
-it.skip(!options.CHROMIUM)('should work', async function({page}) {
+it.skip(!options.CHROMIUM())('should work', async function({page}) {
const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
await Promise.all([
@@ -27,7 +27,7 @@ it.skip(!options.CHROMIUM)('should work', async function({page}) {
expect(foo).toBe('bar');
});
-it.skip(!options.CHROMIUM)('should send events', async function({page, server}) {
+it.skip(!options.CHROMIUM())('should send events', async function({page, server}) {
const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
await client.send('Network.enable');
const events = [];
@@ -36,12 +36,12 @@ it.skip(!options.CHROMIUM)('should send events', async function({page, server})
expect(events.length).toBe(1);
});
-it.skip(!options.CHROMIUM)('should only accept a page', async function({page}) {
+it.skip(!options.CHROMIUM())('should only accept a page', async function({page}) {
const error = await (page.context() as ChromiumBrowserContext).newCDPSession(page.context() as any).catch(e => e);
expect(error.message).toContain('page: expected Page');
});
-it.skip(!options.CHROMIUM)('should enable and disable domains independently', async function({page}) {
+it.skip(!options.CHROMIUM())('should enable and disable domains independently', async function({page}) {
const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
await client.send('Runtime.enable');
await client.send('Debugger.enable');
@@ -59,7 +59,7 @@ it.skip(!options.CHROMIUM)('should enable and disable domains independently', as
]);
});
-it.skip(!options.CHROMIUM)('should be able to detach session', async function({page}) {
+it.skip(!options.CHROMIUM())('should be able to detach session', async function({page}) {
const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
await client.send('Runtime.enable');
const evalResponse = await client.send('Runtime.evaluate', {expression: '1 + 2', returnByValue: true});
@@ -74,7 +74,7 @@ it.skip(!options.CHROMIUM)('should be able to detach session', async function({p
expect(error.message).toContain('Target browser or context has been closed');
});
-it.skip(!options.CHROMIUM)('should throw nice errors', async function({page}) {
+it.skip(!options.CHROMIUM())('should throw nice errors', async function({page}) {
const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
const error = await theSourceOfTheProblems().catch(error => error);
expect(error.stack).toContain('theSourceOfTheProblems');
@@ -85,7 +85,7 @@ it.skip(!options.CHROMIUM)('should throw nice errors', async function({page}) {
}
});
-it.skip(!options.CHROMIUM)('should not break page.close()', async function({browser}) {
+it.skip(!options.CHROMIUM())('should not break page.close()', async function({browser}) {
const context = await browser.newContext();
const page = await context.newPage();
const session = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
@@ -94,7 +94,7 @@ it.skip(!options.CHROMIUM)('should not break page.close()', async function({brow
await context.close();
});
-it.skip(!options.CHROMIUM)('should detach when page closes', async function({browser}) {
+it.skip(!options.CHROMIUM())('should detach when page closes', async function({browser}) {
const context = await browser.newContext() as ChromiumBrowserContext;
const page = await context.newPage();
const session = await context.newCDPSession(page);
@@ -105,7 +105,7 @@ it.skip(!options.CHROMIUM)('should detach when page closes', async function({bro
await context.close();
});
-it.skip(!options.CHROMIUM)('should work', async function({browser}) {
+it.skip(!options.CHROMIUM())('should work', async function({browser}) {
const session = await (browser as ChromiumBrowser).newBrowserCDPSession();
const version = await session.send('Browser.getVersion');
diff --git a/test/chromium/tracing.spec.ts b/test/chromium/tracing.spec.ts
index f375625751..af10b4c765 100644
--- a/test/chromium/tracing.spec.ts
+++ b/test/chromium/tracing.spec.ts
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-import '../runner/builtin.fixtures';
-import '../base.fixture';
+import { options } from '../playwright.fixtures';
import { registerFixture } from '../runner';
import fs from 'fs';
@@ -35,14 +34,14 @@ registerFixture('outputFile', async ({tmpDir}, test) => {
fs.unlinkSync(outputFile);
});
-it.skip(!options.CHROMIUM)('should output a trace', async({browser, page, server, outputFile}) => {
+it.skip(!options.CHROMIUM())('should output a trace', async({browser, page, server, outputFile}) => {
await (browser as ChromiumBrowser).startTracing(page, {screenshots: true, path: outputFile});
await page.goto(server.PREFIX + '/grid.html');
await (browser as ChromiumBrowser).stopTracing();
expect(fs.existsSync(outputFile)).toBe(true);
});
-it.skip(!options.CHROMIUM)('should create directories as needed', async({browser, page, server, tmpDir}) => {
+it.skip(!options.CHROMIUM())('should create directories as needed', async({browser, page, server, tmpDir}) => {
const filePath = path.join(tmpDir, 'these', 'are', 'directories');
await (browser as ChromiumBrowser).startTracing(page, {screenshots: true, path: filePath});
await page.goto(server.PREFIX + '/grid.html');
@@ -50,7 +49,7 @@ it.skip(!options.CHROMIUM)('should create directories as needed', async({browser
expect(fs.existsSync(filePath)).toBe(true);
});
-it.skip(!options.CHROMIUM)('should run with custom categories if provided', async({browser, page, outputFile}) => {
+it.skip(!options.CHROMIUM())('should run with custom categories if provided', async({browser, page, outputFile}) => {
await (browser as ChromiumBrowser).startTracing(page, {path: outputFile, categories: ['disabled-by-default-v8.cpu_profiler.hires']});
await (browser as ChromiumBrowser).stopTracing();
@@ -58,7 +57,7 @@ it.skip(!options.CHROMIUM)('should run with custom categories if provided', asyn
expect(traceJson.metadata['trace-config']).toContain('disabled-by-default-v8.cpu_profiler.hires');
});
-it.skip(!options.CHROMIUM)('should throw if tracing on two pages', async({browser, page, outputFile}) => {
+it.skip(!options.CHROMIUM())('should throw if tracing on two pages', async({browser, page, outputFile}) => {
await (browser as ChromiumBrowser).startTracing(page, {path: outputFile});
const newPage = await browser.newPage();
let error = null;
@@ -68,7 +67,7 @@ it.skip(!options.CHROMIUM)('should throw if tracing on two pages', async({browse
await (browser as ChromiumBrowser).stopTracing();
});
-it.skip(!options.CHROMIUM)('should return a buffer', async({browser, page, server, outputFile}) => {
+it.skip(!options.CHROMIUM())('should return a buffer', async({browser, page, server, outputFile}) => {
await (browser as ChromiumBrowser).startTracing(page, {screenshots: true, path: outputFile});
await page.goto(server.PREFIX + '/grid.html');
const trace = await (browser as ChromiumBrowser).stopTracing();
@@ -76,14 +75,14 @@ it.skip(!options.CHROMIUM)('should return a buffer', async({browser, page, serve
expect(trace.toString()).toEqual(buf.toString());
});
-it.skip(!options.CHROMIUM)('should work without options', async({browser, page, server}) => {
+it.skip(!options.CHROMIUM())('should work without options', async({browser, page, server}) => {
await (browser as ChromiumBrowser).startTracing(page);
await page.goto(server.PREFIX + '/grid.html');
const trace = await (browser as ChromiumBrowser).stopTracing();
expect(trace).toBeTruthy();
});
-it.skip(!options.CHROMIUM)('should support a buffer without a path', async({browser, page, server}) => {
+it.skip(!options.CHROMIUM())('should support a buffer without a path', async({browser, page, server}) => {
await (browser as ChromiumBrowser).startTracing(page, {screenshots: true});
await page.goto(server.PREFIX + '/grid.html');
const trace = await (browser as ChromiumBrowser).stopTracing();
diff --git a/test/click-react.spec.ts b/test/click-react.spec.ts
index db6f0fb127..4acba5a8e8 100644
--- a/test/click-react.spec.ts
+++ b/test/click-react.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
declare const renderComponent;
declare const e;
diff --git a/test/click-timeout-1.spec.ts b/test/click-timeout-1.spec.ts
index b378f5fb58..07edeaf96f 100644
--- a/test/click-timeout-1.spec.ts
+++ b/test/click-timeout-1.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it.skip(options.WIRE)('should avoid side effects after timeout', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/click-timeout-2.spec.ts b/test/click-timeout-2.spec.ts
index 6c0ebe361f..26885a9823 100644
--- a/test/click-timeout-2.spec.ts
+++ b/test/click-timeout-2.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should timeout waiting for display:none to be gone', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/click-timeout-3.spec.ts b/test/click-timeout-3.spec.ts
index 73792e2bce..99af8a2286 100644
--- a/test/click-timeout-3.spec.ts
+++ b/test/click-timeout-3.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it.skip(options.WIRE)('should fail when element jumps during hit testing', async({page, server}) => {
await page.setContent('<button>Click me</button>');
diff --git a/test/click-timeout-4.spec.ts b/test/click-timeout-4.spec.ts
index d4f27dd9ca..d6747f208d 100644
--- a/test/click-timeout-4.spec.ts
+++ b/test/click-timeout-4.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should timeout waiting for stable position', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/click.spec.ts b/test/click.spec.ts
index afabc30f05..6991c0966c 100644
--- a/test/click.spec.ts
+++ b/test/click.spec.ts
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
-import utils from './utils';
+import { options } from './playwright.fixtures';
+import utils from './utils';
async function giveItAChanceToClick(page) {
for (let i = 0; i < 5; i++)
@@ -316,7 +316,7 @@ it('should click the button inside an iframe', async({page, server}) => {
expect(await frame.evaluate(() => window['result'])).toBe('Clicked');
});
-it.fail(options.CHROMIUM || options.WEBKIT)('should click the button with fixed position inside an iframe', async({page, server}) => {
+it.fail(options.CHROMIUM() || options.WEBKIT())('should click the button with fixed position inside an iframe', async({page, server}) => {
// @see https://github.com/GoogleChrome/puppeteer/issues/4110
// @see https://bugs.chromium.org/p/chromium/issues/detail?id=986390
// @see https://chromium-review.googlesource.com/c/chromium/src/+/1742784
@@ -349,8 +349,8 @@ it('should click the button with px border with offset', async({page, server}) =
await page.click('button', { position: { x: 20, y: 10 } });
expect(await page.evaluate('result')).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
- expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 20 + 8 : 20);
- expect(await page.evaluate('offsetY')).toBe(options.WEBKIT ? 10 + 8 : 10);
+ expect(await page.evaluate('offsetX')).toBe(options.WEBKIT() ? 20 + 8 : 20);
+ expect(await page.evaluate('offsetY')).toBe(options.WEBKIT() ? 10 + 8 : 10);
});
it('should click the button with em border with offset', async({page, server}) => {
@@ -360,8 +360,8 @@ it('should click the button with em border with offset', async({page, server}) =
await page.click('button', { position: { x: 20, y: 10 } });
expect(await page.evaluate('result')).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
- expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 12 * 2 + 20 : 20);
- expect(await page.evaluate('offsetY')).toBe(options.WEBKIT ? 12 * 2 + 10 : 10);
+ expect(await page.evaluate('offsetX')).toBe(options.WEBKIT() ? 12 * 2 + 20 : 20);
+ expect(await page.evaluate('offsetY')).toBe(options.WEBKIT() ? 12 * 2 + 10 : 10);
});
it('should click a very large button with offset', async({page, server}) => {
@@ -371,8 +371,8 @@ it('should click a very large button with offset', async({page, server}) => {
await page.click('button', { position: { x: 1900, y: 1910 } });
expect(await page.evaluate(() => window['result'])).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
- expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 1900 + 8 : 1900);
- expect(await page.evaluate('offsetY')).toBe(options.WEBKIT ? 1910 + 8 : 1910);
+ expect(await page.evaluate('offsetX')).toBe(options.WEBKIT() ? 1900 + 8 : 1900);
+ expect(await page.evaluate('offsetY')).toBe(options.WEBKIT() ? 1910 + 8 : 1910);
});
it('should click a button in scrolling container with offset', async({page, server}) => {
@@ -391,11 +391,11 @@ it('should click a button in scrolling container with offset', async({page, serv
await page.click('button', { position: { x: 1900, y: 1910 } });
expect(await page.evaluate(() => window['result'])).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
- expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 1900 + 8 : 1900);
- expect(await page.evaluate('offsetY')).toBe(options.WEBKIT ? 1910 + 8 : 1910);
+ expect(await page.evaluate('offsetX')).toBe(options.WEBKIT() ? 1900 + 8 : 1900);
+ expect(await page.evaluate('offsetY')).toBe(options.WEBKIT() ? 1910 + 8 : 1910);
});
-it.skip(options.FFOX)('should click the button with offset with page scale', async({browser, server}) => {
+it.skip(options.FIREFOX())('should click the button with offset 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');
@@ -407,10 +407,10 @@ it.skip(options.FFOX)('should click the button with offset with page scale', asy
expect(await page.evaluate('result')).toBe('Clicked');
const round = x => Math.round(x + 0.01);
let expected = { x: 28, y: 18 }; // 20;10 + 8px of border in each direction
- if (options.WEBKIT) {
+ if (options.WEBKIT()) {
// WebKit rounds up during css -> dip -> css conversion.
expected = { x: 29, y: 19 };
- } else if (options.CHROMIUM && options.HEADLESS) {
+ } else if (options.CHROMIUM() && options.HEADLESS) {
// Headless Chromium rounds down during css -> dip -> css conversion.
expected = { x: 27, y: 18 };
}
diff --git a/test/defaultbrowsercontext.spec.ts b/test/defaultbrowsercontext.spec.ts
index 73a1dddc5f..7901f01fc1 100644
--- a/test/defaultbrowsercontext.spec.ts
+++ b/test/defaultbrowsercontext.spec.ts
@@ -15,8 +15,7 @@
* limitations under the License.
*/
-import './runner/builtin.fixtures';
-import './base.fixture';
+import { options } from './playwright.fixtures';
import { registerFixture } from './runner';
import fs from 'fs';
import utils from './utils';
@@ -120,7 +119,7 @@ it('should(not) block third party cookies', async ({server, launchPersistent}) =
return document.cookie;
});
await page.waitForTimeout(2000);
- const allowsThirdParty = options.CHROMIUM || options.FFOX;
+ const allowsThirdParty = options.CHROMIUM() || options.FIREFOX();
expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : '');
const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) {
@@ -175,7 +174,7 @@ it('should support javascriptEnabled option', async ({launchPersistent}) => {
await page.goto('data:text/html, <script>var something = "forbidden"</script>');
let error = null;
await page.evaluate('something').catch(e => error = e);
- if (options.WEBKIT)
+ if (options.WEBKIT())
expect(error.message).toContain('Can\'t find variable: something');
else
expect(error.message).toContain('something is not defined');
@@ -218,7 +217,7 @@ it('should support hasTouch option', async ({server, launchPersistent}) => {
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true);
});
-it.skip(options.FFOX)('should work in persistent context', async ({server, launchPersistent}) => {
+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});
await page.goto(server.PREFIX + '/empty.html');
@@ -303,7 +302,7 @@ it.slow()('should restore state from userDataDir', async({browserType, defaultBr
await removeUserDataDir(userDataDir2);
});
-it.fail(options.CHROMIUM && (WIN || MAC)).slow()('should restore cookies from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => {
+it.fail(options.CHROMIUM() && (WIN || MAC)).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();
@@ -339,7 +338,7 @@ it('should have default URL when launching browser', async ({launchPersistent})
expect(urls).toEqual(['about:blank']);
});
-it.skip(options.FFOX)('should throw if page argument is passed', async ({browserType, defaultBrowserOptions, server, tmpDir}) => {
+it.skip(options.FIREFOX())('should throw if page argument is passed', async ({browserType, defaultBrowserOptions, server, tmpDir}) => {
const options = {...defaultBrowserOptions, args: [server.EMPTY_PAGE] };
const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e);
expect(error.message).toContain('can not specify page');
@@ -382,7 +381,7 @@ it('should fire close event for a persistent context', async({launchPersistent})
expect(closed).toBe(true);
});
-it.skip(!options.CHROMIUM)('coverage should work', async ({server, launchPersistent}) => {
+it.skip(!options.CHROMIUM())('coverage should work', async ({server, launchPersistent}) => {
const {page, context} = await launchPersistent();
await page.coverage.startJSCoverage();
await page.goto(server.PREFIX + '/jscoverage/simple.html', { waitUntil: 'load' });
@@ -392,7 +391,7 @@ it.skip(!options.CHROMIUM)('coverage should work', async ({server, launchPersist
expect(coverage[0].functions.find(f => f.functionName === 'foo').ranges[0].count).toEqual(1);
});
-it.skip(options.CHROMIUM)('coverage should be missing', async ({launchPersistent}) => {
+it.skip(options.CHROMIUM())('coverage should be missing', async ({launchPersistent}) => {
const {page, context} = await launchPersistent();
expect(page.coverage).toBe(null);
});
diff --git a/test/dialog.spec.ts b/test/dialog.spec.ts
index 4d3990b286..8890b5b8b1 100644
--- a/test/dialog.spec.ts
+++ b/test/dialog.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('should fire', async({page, server}) => {
page.on('dialog', dialog => {
@@ -61,7 +62,7 @@ it('should dismiss the confirm prompt', async({page}) => {
expect(result).toBe(false);
});
-it.fail(options.WEBKIT)('should be able to close context with open alert', async({browser}) => {
+it.fail(options.WEBKIT())('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 06250ffa52..ceb8ba5caf 100644
--- a/test/dispatchevent.spec.ts
+++ b/test/dispatchevent.spec.ts
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import utils from './utils';
@@ -126,7 +126,7 @@ it('should be atomic', async({playwright, page}) => {
expect(await page.evaluate(() => window['_clicked'])).toBe(true);
});
-it.fail(options.WEBKIT)('should dispatch drag drop events', async({page, server}) => {
+it.fail(options.WEBKIT())('should dispatch drag drop events', async({page, server}) => {
await page.goto(server.PREFIX + '/drag-n-drop.html');
const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
await page.dispatchEvent('#source', 'dragstart', { dataTransfer });
@@ -138,7 +138,7 @@ it.fail(options.WEBKIT)('should dispatch drag drop events', async({page, server}
}, {source, target})).toBeTruthy();
});
-it.fail(options.WEBKIT)('should dispatch drag drop events', async({page, server}) => {
+it.fail(options.WEBKIT())('should dispatch drag drop events', async({page, server}) => {
await page.goto(server.PREFIX + '/drag-n-drop.html');
const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
const source = await page.$('#source');
diff --git a/test/download.spec.ts b/test/download.spec.ts
index 86b79c3fc3..d6673b37ae 100644
--- a/test/download.spec.ts
+++ b/test/download.spec.ts
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-import './runner/builtin.fixtures';
-import './base.fixture';
+import { options } from './playwright.fixtures';
import fs from 'fs';
import path from 'path';
@@ -218,7 +217,7 @@ it(`should report download path within page.on('download', …) handler for Blob
expect(fs.readFileSync(path).toString()).toBe('Hello world');
await page.close();
})
-it.fail(options.FFOX || options.WEBKIT)('should report alt-click downloads', async({browser, server}) => {
+it.fail(options.FIREFOX() || options.WEBKIT())('should report alt-click downloads', async({browser, server}) => {
// Firefox does not download on alt-click by default.
// Our WebKit embedder does not download on alt-click, although Safari does.
server.setRoute('/download', (req, res) => {
@@ -239,7 +238,7 @@ it.fail(options.FFOX || options.WEBKIT)('should report alt-click downloads', asy
await page.close();
});
-it.fail(options.CHROMIUM && !options.HEADLESS)('should report new window downloads', async({browser, server}) => {
+it.fail(options.CHROMIUM() && !options.HEADLESS)('should report new window downloads', async({browser, server}) => {
// TODO: - the test fails in headful Chromium as the popup page gets closed along
// with the session before download completed event arrives.
// - WebKit doesn't close the popup page
diff --git a/test/downloads-path.spec.ts b/test/downloads-path.spec.ts
index 7a35ebf227..ab2c783889 100644
--- a/test/downloads-path.spec.ts
+++ b/test/downloads-path.spec.ts
@@ -15,8 +15,7 @@
*/
-import './runner/builtin.fixtures';
-import './base.fixture';
+import './playwright.fixtures';
import { registerFixture } from './runner';
diff --git a/test/electron/electron-app.spec.ts b/test/electron/electron-app.spec.ts
index 30e42c8d0a..9da0408db5 100644
--- a/test/electron/electron-app.spec.ts
+++ b/test/electron/electron-app.spec.ts
@@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+import { options } from '../playwright.fixtures';
import './electron.fixture';
import path from 'path';
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';
-it.skip(!options.CHROMIUM)('should fire close event', async ({ playwright }) => {
+it.skip(!options.CHROMIUM())('should fire close event', async ({ playwright }) => {
const electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName);
const application = await playwright.electron.launch(electronPath, {
args: [path.join(__dirname, 'testApp.js')],
@@ -34,12 +36,12 @@ it.skip(!options.CHROMIUM)('should fire close event', async ({ playwright }) =>
expect(events.join('|')).toBe('context|application');
});
-it.skip(!options.CHROMIUM)('should script application', async ({ application }) => {
+it.skip(!options.CHROMIUM())('should script application', async ({ application }) => {
const appPath = await application.evaluate(async ({ app }) => app.getAppPath());
expect(appPath).toContain('electron');
});
-it.skip(!options.CHROMIUM)('should create window', async ({ application }) => {
+it.skip(!options.CHROMIUM())('should create window', async ({ application }) => {
const [ page ] = await Promise.all([
application.waitForEvent('window'),
application.evaluate(({ BrowserWindow }) => {
@@ -51,13 +53,13 @@ it.skip(!options.CHROMIUM)('should create window', async ({ application }) => {
expect(await page.title()).toBe('Hello World 1');
});
-it.skip(!options.CHROMIUM)('should create window 2', async ({ application }) => {
+it.skip(!options.CHROMIUM())('should create window 2', async ({ application }) => {
const page = await application.newBrowserWindow({ width: 800, height: 600 });
await page.goto('data:text/html,<title>Hello World 2</title>');
expect(await page.title()).toBe('Hello World 2');
});
-it.skip(!options.CHROMIUM)('should create multiple windows', async ({ application }) => {
+it.skip(!options.CHROMIUM())('should create multiple windows', async ({ application }) => {
const createPage = async ordinal => {
const page = await application.newBrowserWindow({ width: 800, height: 600 });
await Promise.all([
@@ -78,7 +80,7 @@ it.skip(!options.CHROMIUM)('should create multiple windows', async ({ applicatio
expect(titles).toEqual(['Hello World 2', 'Hello World 3', 'Hello World 4']);
});
-it.skip(!options.CHROMIUM)('should route network', async ({ application }) => {
+it.skip(!options.CHROMIUM())('should route network', async ({ application }) => {
await application.context().route('**/empty.html', (route, request) => {
route.fulfill({
status: 200,
@@ -91,14 +93,14 @@ it.skip(!options.CHROMIUM)('should route network', async ({ application }) => {
expect(await page.title()).toBe('Hello World');
});
-it.skip(!options.CHROMIUM)('should support init script', async ({ application }) => {
+it.skip(!options.CHROMIUM())('should support init script', async ({ application }) => {
await application.context().addInitScript('window.magic = 42;')
const page = await application.newBrowserWindow({ width: 800, height: 600 });
await page.goto('data:text/html,<script>window.copy = magic</script>');
expect(await page.evaluate(() => window['copy'])).toBe(42);
});
-it.skip(!options.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 +108,7 @@ it.skip(!options.CHROMIUM)('should expose function', async ({ application }) =>
expect(await page.evaluate(() => window['result'])).toBe(42);
});
-it.skip(!options.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,<title>Hello World!</title>');
@@ -115,7 +117,7 @@ it.skip(!options.CHROMIUM)('should wait for first window', async ({ application
expect(await window.title()).toBe('Hello World!');
});
-it.skip(!options.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 363bd6d597..5dece6c2d0 100644
--- a/test/electron/electron-window.spec.ts
+++ b/test/electron/electron-window.spec.ts
@@ -13,27 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+import { options } from '../playwright.fixtures';
import './electron.fixture';
-it.skip(!options.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(!options.CHROMIUM)('should check the box', async({window}) => {
+it.skip(!options.CHROMIUM())('should check the box', async({window}) => {
await window.setContent(`<input id='checkbox' type='checkbox'></input>`);
await window.check('input');
expect(await window.evaluate('checkbox.checked')).toBe(true);
});
-it.skip(!options.CHROMIUM)('should not check the checked box', async({window}) => {
+it.skip(!options.CHROMIUM())('should not check the checked box', async({window}) => {
await window.setContent(`<input id='checkbox' type='checkbox' checked></input>`);
await window.check('input');
expect(await window.evaluate('checkbox.checked')).toBe(true);
});
-it.skip(!options.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/electron/electron.fixture.ts b/test/electron/electron.fixture.ts
index 88db32ee33..e64694bf43 100644
--- a/test/electron/electron.fixture.ts
+++ b/test/electron/electron.fixture.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import '../base.fixture';
+import { options } from '../playwright.fixtures';
import { registerFixture } from '../runner';
import {ElectronApplication, ElectronLauncher, ElectronPage} from '../../electron-types';
import path from 'path';
diff --git a/test/elementhandle-bounding-box.spec.ts b/test/elementhandle-bounding-box.spec.ts
index 53960f450d..77dbb4be1f 100644
--- a/test/elementhandle-bounding-box.spec.ts
+++ b/test/elementhandle-bounding-box.spec.ts
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
-it.fail(options.FFOX && !options.HEADLESS)('should work', async ({ page, server }) => {
+it.fail(options.FIREFOX() && !options.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)');
@@ -64,7 +64,7 @@ it('should work with SVG nodes', async ({ page, server }) => {
expect(pwBoundingBox).toEqual(webBoundingBox);
});
-it.skip(options.FFOX)('should work with page scale', async ({ browser, server }) => {
+it.skip(options.FIREFOX())('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-click.spec.ts b/test/elementhandle-click.spec.ts
index 987316f0d4..d5d1fad02b 100644
--- a/test/elementhandle-click.spec.ts
+++ b/test/elementhandle-click.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/button.html');
diff --git a/test/elementhandle-content-frame.spec.ts b/test/elementhandle-content-frame.spec.ts
index 90313ae07e..1461190de4 100644
--- a/test/elementhandle-content-frame.spec.ts
+++ b/test/elementhandle-content-frame.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
import utils from './utils';
diff --git a/test/elementhandle-convenience.spec.ts b/test/elementhandle-convenience.spec.ts
index 22ddf96948..179731e03a 100644
--- a/test/elementhandle-convenience.spec.ts
+++ b/test/elementhandle-convenience.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import utils from './utils';
it('should have a nice preview', async ({ page, server }) => {
diff --git a/test/elementhandle-eval-on-selector.spec.ts b/test/elementhandle-eval-on-selector.spec.ts
index 84c14663a1..ee1a48cd68 100644
--- a/test/elementhandle-eval-on-selector.spec.ts
+++ b/test/elementhandle-eval-on-selector.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page, server}) => {
await page.setContent('<html><body><div class="tweet"><div class="like">100</div><div class="retweets">10</div></div></body></html>');
diff --git a/test/elementhandle-misc.spec.ts b/test/elementhandle-misc.spec.ts
index 9d9966d647..6bb88e8db0 100644
--- a/test/elementhandle-misc.spec.ts
+++ b/test/elementhandle-misc.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should hover', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/scrollable.html');
diff --git a/test/elementhandle-owner-frame.spec.ts b/test/elementhandle-owner-frame.spec.ts
index 88b9dcac80..d81352eff0 100644
--- a/test/elementhandle-owner-frame.spec.ts
+++ b/test/elementhandle-owner-frame.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import utils from './utils';
it('should work', async ({ page, server }) => {
diff --git a/test/elementhandle-press.spec.ts b/test/elementhandle-press.spec.ts
index 101c4e0e3c..5d6ad7409d 100644
--- a/test/elementhandle-press.spec.ts
+++ b/test/elementhandle-press.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`);
diff --git a/test/elementhandle-query-selector.spec.ts b/test/elementhandle-query-selector.spec.ts
index 846bdd8c51..32fca4ee6c 100644
--- a/test/elementhandle-query-selector.spec.ts
+++ b/test/elementhandle-query-selector.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should query existing element', async({page, server}) => {
await page.goto(server.PREFIX + '/playground.html');
diff --git a/test/elementhandle-screenshot.spec.ts b/test/elementhandle-screenshot.spec.ts
index 9dfb7354bc..8c5b17e75b 100644
--- a/test/elementhandle-screenshot.spec.ts
+++ b/test/elementhandle-screenshot.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import utils from './utils';
import {PNG} from 'pngjs';
@@ -22,7 +22,7 @@ import path from 'path';
import fs from 'fs';
// Firefox headful produces a different image.
-const ffheadful = options.FFOX && !options.HEADLESS;
+const ffheadful = options.FIREFOX() && !options.HEADLESS;
it.skip(ffheadful)('should work', async({page, server, golden}) => {
await page.setViewportSize({width: 500, height: 500});
@@ -210,7 +210,7 @@ it.skip(ffheadful)('should work for an element with fractional dimensions', asyn
expect(screenshot).toMatchImage(golden('screenshot-element-fractional.png'));
});
-it.skip(options.FFOX)('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.FFOX)('should work with a mobile viewport', async({browser, serv
await context.close();
});
-it.skip(options.FFOX)('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');
diff --git a/test/elementhandle-scroll-into-view.spec.ts b/test/elementhandle-scroll-into-view.spec.ts
index 231a0fc28c..d949e4623e 100644
--- a/test/elementhandle-scroll-into-view.spec.ts
+++ b/test/elementhandle-scroll-into-view.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async ({ page, server }) => {
await page.goto(server.PREFIX + '/offscreenbuttons.html');
diff --git a/test/elementhandle-select-text.spec.ts b/test/elementhandle-select-text.spec.ts
index 9047eb7d54..e4f3cc7bc9 100644
--- a/test/elementhandle-select-text.spec.ts
+++ b/test/elementhandle-select-text.spec.ts
@@ -14,14 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('should select textarea', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/textarea.html');
const textarea = await page.$('textarea');
await textarea.evaluate(textarea => textarea.value = 'some value');
await textarea.selectText();
- if (options.FFOX) {
+ if (options.FIREFOX()) {
expect(await textarea.evaluate(el => el.selectionStart)).toBe(0);
expect(await textarea.evaluate(el => el.selectionEnd)).toBe(10);
} else {
@@ -34,7 +35,7 @@ it('should select input', async ({ page, server }) => {
const input = await page.$('input');
await input.evaluate(input => input.value = 'some value');
await input.selectText();
- if (options.FFOX) {
+ if (options.FIREFOX()) {
expect(await input.evaluate(el => el.selectionStart)).toBe(0);
expect(await input.evaluate(el => el.selectionEnd)).toBe(10);
} else {
diff --git a/test/elementhandle-type.spec.ts b/test/elementhandle-type.spec.ts
index 7405c21d21..96c3b67b90 100644
--- a/test/elementhandle-type.spec.ts
+++ b/test/elementhandle-type.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`);
diff --git a/test/elementhandle-wait-for-element-state.spec.ts b/test/elementhandle-wait-for-element-state.spec.ts
index 2bcdfd7bce..440ecbdf8b 100644
--- a/test/elementhandle-wait-for-element-state.spec.ts
+++ b/test/elementhandle-wait-for-element-state.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
async function giveItAChanceToResolve(page) {
for (let i = 0; i < 5; i++)
diff --git a/test/emulation-focus.spec.ts b/test/emulation-focus.spec.ts
index f8d323ead0..d8133b01b3 100644
--- a/test/emulation-focus.spec.ts
+++ b/test/emulation-focus.spec.ts
@@ -15,8 +15,7 @@
* limitations under the License.
*/
-import './base.fixture';
-
+import { options } from './playwright.fixtures';
import utils from './utils';
it('should think that it is focused by default', async({page}) => {
@@ -102,7 +101,7 @@ it('should change document.activeElement', async({page, server}) => {
expect(active).toEqual(['INPUT', 'TEXTAREA']);
});
-it.skip(options.FFOX && !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([
diff --git a/test/eval-on-selector-all.spec.ts b/test/eval-on-selector-all.spec.ts
index 1045a900dc..a743e640a7 100644
--- a/test/eval-on-selector-all.spec.ts
+++ b/test/eval-on-selector-all.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work with css selector', async({page, server}) => {
await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>');
diff --git a/test/eval-on-selector.spec.ts b/test/eval-on-selector.spec.ts
index 2d976b6a43..4dfe69afcc 100644
--- a/test/eval-on-selector.spec.ts
+++ b/test/eval-on-selector.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work with css selector', async({page, server}) => {
await page.setContent('<section id="testAttribute">43543</section>');
diff --git a/test/firefox/launcher.spec.ts b/test/firefox/launcher.spec.ts
index 952318ba23..213f532482 100644
--- a/test/firefox/launcher.spec.ts
+++ b/test/firefox/launcher.spec.ts
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import '../base.fixture';
+import { options } from '../playwright.fixtures';
-it.skip(!options.FFOX)('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/fixtures.spec.ts b/test/fixtures.spec.ts
index 5063dd773f..6c6d9b8807 100644
--- a/test/fixtures.spec.ts
+++ b/test/fixtures.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import { registerFixture } from './runner';
import path from 'path';
diff --git a/test/focus.spec.ts b/test/focus.spec.ts
index 1442b06e05..e3fd167552 100644
--- a/test/focus.spec.ts
+++ b/test/focus.spec.ts
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
-it.skip(options.FFOX)('should work', async function({page, server}) {
+it.skip(options.FIREFOX())('should work', async function({page, server}) {
await page.setContent(`<div id=d1 tabIndex=0></div>`);
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 || !options.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(`
<input id="input-1">
<button id="button">buttton</button>
diff --git a/test/frame-evaluate.spec.ts b/test/frame-evaluate.spec.ts
index bba366f4c5..106b4e4241 100644
--- a/test/frame-evaluate.spec.ts
+++ b/test/frame-evaluate.spec.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import utils from './utils';
@@ -36,7 +36,7 @@ it('should have correct execution contexts', async ({ page, server }) => {
});
function expectContexts(pageImpl, count) {
- if (options.CHROMIUM)
+ if (options.CHROMIUM())
expect(pageImpl._delegate._mainFrameSession._contextIdToContext.size).toBe(count);
else
expect(pageImpl._delegate._contextIdToContext.size).toBe(count);
@@ -126,7 +126,7 @@ it('should be isolated between frames', async({page, server}) => {
expect(a2).toBe(2);
});
-it.fail(options.CHROMIUM || options.FFOX)('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.FFOX)('should work in iframes that failed in
expect(await page.frames()[1].$('div')).toBeTruthy();
});
-it.fail(options.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-frame-element.spec.ts b/test/frame-frame-element.spec.ts
index 2f216abc53..12f9677c19 100644
--- a/test/frame-frame-element.spec.ts
+++ b/test/frame-frame-element.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
import utils from './utils';
diff --git a/test/frame-goto.spec.ts b/test/frame-goto.spec.ts
index f76fc6b529..c724ccbdfa 100644
--- a/test/frame-goto.spec.ts
+++ b/test/frame-goto.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
import utils from './utils';
diff --git a/test/frame-hierarchy.spec.ts b/test/frame-hierarchy.spec.ts
index 2a3b90bea7..254b9c1123 100644
--- a/test/frame-hierarchy.spec.ts
+++ b/test/frame-hierarchy.spec.ts
@@ -14,8 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
-
+import { options } from './playwright.fixtures';
import utils from './utils';
it('should handle nested frames', async({page, server}) => {
@@ -172,7 +171,7 @@ it('should report different frame instance when frame re-attaches', async({page,
expect(frame1).not.toBe(frame2);
});
-it.fail(options.FFOX)('should refuse to display x-frame-options:deny iframe', async({page, server}) => {
+it.fail(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');
diff --git a/test/geolocation.spec.ts b/test/geolocation.spec.ts
index 008fe5d957..b7b21ce536 100644
--- a/test/geolocation.spec.ts
+++ b/test/geolocation.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page, server, context}) => {
await context.grantPermissions(['geolocation']);
diff --git a/test/headful.spec.ts b/test/headful.spec.ts
index b4cb897377..ee06253028 100644
--- a/test/headful.spec.ts
+++ b/test/headful.spec.ts
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-import './runner/builtin.fixtures';
-import './base.fixture';
+import { options } from './playwright.fixtures';
import utils from './utils';
const { makeUserDataDir, removeUserDataDir } = utils;
@@ -27,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
@@ -107,7 +106,7 @@ it('should(not) block third party cookies', async({browserType, defaultBrowserOp
return document.cookie;
});
await page.waitForTimeout(2000);
- const allowsThirdParty = options.CHROMIUM || options.FFOX;
+ const allowsThirdParty = options.CHROMIUM() || options.FIREFOX();
expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : '');
const cookies = await page.context().cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) {
@@ -129,7 +128,7 @@ it('should(not) block third party cookies', async({browserType, defaultBrowserOp
await browser.close();
});
-it.fail(options.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/ignorehttpserrors.spec.ts b/test/ignorehttpserrors.spec.ts
index e8aa629e50..8584c16126 100644
--- a/test/ignorehttpserrors.spec.ts
+++ b/test/ignorehttpserrors.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({browser, httpsServer}) => {
let error = null;
diff --git a/test/interception.spec.ts b/test/interception.spec.ts
index d766001557..a82a379bd9 100644
--- a/test/interception.spec.ts
+++ b/test/interception.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
import { globToRegex } from '../lib/rpc/client/clientHelper';
import vm from 'vm';
diff --git a/test/jshandle-as-element.spec.ts b/test/jshandle-as-element.spec.ts
index f0ac3cc0b9..3f2f4ebdbb 100644
--- a/test/jshandle-as-element.spec.ts
+++ b/test/jshandle-as-element.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page}) => {
const aHandle = await page.evaluateHandle(() => document.body);
diff --git a/test/jshandle-evaluate.spec.ts b/test/jshandle-evaluate.spec.ts
index aaccd85d51..5e5aa102ff 100644
--- a/test/jshandle-evaluate.spec.ts
+++ b/test/jshandle-evaluate.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work with function', async({page}) => {
const windowHandle = await page.evaluateHandle(() => {
diff --git a/test/jshandle-json-value.spec.ts b/test/jshandle-json-value.spec.ts
index 21761352b9..c867f83c90 100644
--- a/test/jshandle-json-value.spec.ts
+++ b/test/jshandle-json-value.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page}) => {
const aHandle = await page.evaluateHandle(() => ({foo: 'bar'}));
diff --git a/test/jshandle-properties.spec.ts b/test/jshandle-properties.spec.ts
index a29dfd764a..d7c557432b 100644
--- a/test/jshandle-properties.spec.ts
+++ b/test/jshandle-properties.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page}) => {
const aHandle = await page.evaluateHandle(() => ({
diff --git a/test/jshandle-to-string.spec.ts b/test/jshandle-to-string.spec.ts
index b5d7967450..6c3b12f997 100644
--- a/test/jshandle-to-string.spec.ts
+++ b/test/jshandle-to-string.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('should work for primitives', async({page}) => {
const numberHandle = await page.evaluateHandle(() => 2);
@@ -53,6 +54,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(options.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 4e63916197..f1849161b1 100644
--- a/test/keyboard.spec.ts
+++ b/test/keyboard.spec.ts
@@ -14,8 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
-
+import { options } from './playwright.fixtures';
import utils from './utils';
it('should type into a textarea', async ({page}) => {
@@ -83,7 +82,7 @@ it('insertText should only emit input event', async ({page, server}) => {
expect(await events.jsonValue()).toEqual(['input']);
});
-it.fail(options.FFOX && MAC)('should report shiftKey', async ({page, server}) => {
+it.fail(options.FIREFOX() && 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};
@@ -354,17 +353,17 @@ it('should press the meta key', async ({page}) => {
const lastEvent = await captureLastKeydown(page);
await page.keyboard.press('Meta');
const {key, code, metaKey} = await lastEvent.jsonValue();
- if (options.FFOX && !MAC)
+ if (options.FIREFOX() && !MAC)
expect(key).toBe('OS');
else
expect(key).toBe('Meta');
- if (options.FFOX)
+ if (options.FIREFOX())
expect(code).toBe('OSLeft');
else
expect(code).toBe('MetaLeft');
- if (options.FFOX && !MAC)
+ if (options.FIREFOX() && !MAC)
expect(metaKey).toBe(false);
else
expect(metaKey).toBe(true);
@@ -380,7 +379,7 @@ it('should work after a cross origin navigation', async ({page, server}) => {
});
// event.keyIdentifier has been removed from all browsers except WebKit
-it.skip(!options.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/launcher.spec.ts b/test/launcher.spec.ts
index f9e427a2b5..5efa99a071 100644
--- a/test/launcher.spec.ts
+++ b/test/launcher.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import path from 'path';
import utils from './utils';
diff --git a/test/logger.spec.ts b/test/logger.spec.ts
index e053afa7d5..db6029a790 100644
--- a/test/logger.spec.ts
+++ b/test/logger.spec.ts
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should log', async({browserType, defaultBrowserOptions}) => {
const log = [];
diff --git a/test/mouse.spec.ts b/test/mouse.spec.ts
index 47967a83a0..b6c6355e61 100644
--- a/test/mouse.spec.ts
+++ b/test/mouse.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
function dimensions() {
const rect = document.querySelector('textarea').getBoundingClientRect();
@@ -26,8 +27,8 @@ function dimensions() {
};
}
-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
+it.fail(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 => {
document.addEventListener('click', event => {
@@ -126,7 +127,7 @@ it('should set modifier keys on click', async({page, server}) => {
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.FFOX && !MAC)
+ if (options.FIREFOX() && !MAC)
delete modifiers['Meta'];
for (const modifier in modifiers) {
await page.keyboard.down(modifier);
@@ -144,7 +145,7 @@ it('should set modifier keys on click', async({page, server}) => {
it('should tween mouse movement', async({page}) => {
// The test becomes flaky on WebKit without next line.
- if (options.WEBKIT)
+ if (options.WEBKIT())
await page.evaluate(() => new Promise(requestAnimationFrame));
await page.mouse.move(100, 100);
await page.evaluate(() => {
@@ -163,7 +164,7 @@ it('should tween mouse movement', async({page}) => {
]);
});
-it.skip(options.FFOX)('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();
diff --git a/test/multiclient.spec.ts b/test/multiclient.spec.ts
index a7fe2ef28f..7d4c368ce5 100644
--- a/test/multiclient.spec.ts
+++ b/test/multiclient.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it.skip(options.WIRE)('should work across sessions', async ({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions);
diff --git a/test/navigation.spec.ts b/test/navigation.spec.ts
index a511fa59b8..97c42a3b1c 100644
--- a/test/navigation.spec.ts
+++ b/test/navigation.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work with _blank target', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => {
diff --git a/test/network-request.spec.ts b/test/network-request.spec.ts
index 63cf5372f9..3409b4c934 100644
--- a/test/network-request.spec.ts
+++ b/test/network-request.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import utils from './utils';
it('should work for main frame navigation request', async({page, server}) => {
@@ -47,15 +47,15 @@ it('should work for fetch requests', async({page, server}) => {
it('should return headers', async({page, server}) => {
const response = await page.goto(server.EMPTY_PAGE);
- if (options.CHROMIUM)
+ if (options.CHROMIUM())
expect(response.request().headers()['user-agent']).toContain('Chrome');
- else if (options.FFOX)
+ else if (options.FIREFOX())
expect(response.request().headers()['user-agent']).toContain('Firefox');
- else if (options.WEBKIT)
+ else if (options.WEBKIT())
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) => {
diff --git a/test/network-response.spec.ts b/test/network-response.spec.ts
index 8d442f53fd..c16ece1c56 100644
--- a/test/network-response.spec.ts
+++ b/test/network-response.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import fs from 'fs';
import path from 'path';
diff --git a/test/page-add-init-script.spec.ts b/test/page-add-init-script.spec.ts
index 7acfd0db3d..73bdd64c5c 100644
--- a/test/page-add-init-script.spec.ts
+++ b/test/page-add-init-script.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import path from 'path';
it('should evaluate before anything else on the page', async ({ page, server }) => {
diff --git a/test/page-add-script-tag.spec.ts b/test/page-add-script-tag.spec.ts
index 431d028f41..5395167321 100644
--- a/test/page-add-script-tag.spec.ts
+++ b/test/page-add-script-tag.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import path from 'path';
it('should throw an error if no options are provided', async({page, server}) => {
@@ -74,7 +74,7 @@ it('should work with a path', async({page, server}) => {
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);
@@ -88,7 +88,7 @@ it('should work with content', async({page, server}) => {
expect(await page.evaluate(() => window['__injected'])).toBe(35);
});
-it.fail(options.FFOX)('should throw when added with content to the CSP page', async({page, server}) => {
+it.fail(options.FIREFOX())('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-add-style-tag.spec.ts b/test/page-add-style-tag.spec.ts
index 98cf349d03..b162037bf9 100644
--- a/test/page-add-style-tag.spec.ts
+++ b/test/page-add-style-tag.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import path from 'path';
it('should throw an error if no options are provided', async({page, server}) => {
diff --git a/test/page-basic.spec.ts b/test/page-basic.spec.ts
index 5e37f06351..b350d7168b 100644
--- a/test/page-basic.spec.ts
+++ b/test/page-basic.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('should reject all promises when page is closed', async({context}) => {
const newPage = await context.newPage();
@@ -43,9 +44,9 @@ it('should run beforeunload if asked for', async({context, server}) => {
const dialog = await newPage.waitForEvent('dialog');
expect(dialog.type()).toBe('beforeunload');
expect(dialog.defaultValue()).toBe('');
- if (options.CHROMIUM)
+ if (options.CHROMIUM())
expect(dialog.message()).toBe('');
- else if (options.WEBKIT)
+ else if (options.WEBKIT())
expect(dialog.message()).toBe('Leave?');
else
expect(dialog.message()).toBe('This page is asking you to confirm that you want to leave - data you have entered may not be saved.');
@@ -210,7 +211,7 @@ it('should have sane user agent', async ({page}) => {
// Second part in parenthesis is platform - ignore it.
// Third part for Firefox is the last one and encodes engine and browser versions.
- if (options.FFOX) {
+ if (options.FIREFOX()) {
const [engine, browser] = part3.split(' ');
expect(engine.startsWith('Gecko')).toBe(true);
expect(browser.startsWith('Firefox')).toBe(true);
@@ -218,13 +219,13 @@ it('should have sane user agent', async ({page}) => {
expect(part5).toBe(undefined);
return;
}
- // For both options.CHROMIUM and options.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.
const [engine, browser] = part5.split(' ');
expect(browser.startsWith('Safari/')).toBe(true);
- if (options.CHROMIUM)
+ if (options.CHROMIUM())
expect(engine.includes('Chrome/')).toBe(true);
else
expect(engine.startsWith('Version/')).toBe(true);
@@ -243,7 +244,7 @@ it('frame.press should work', async({page, server}) => {
expect(await frame.evaluate(() => document.querySelector('textarea').value)).toBe('a');
});
-it.fail(options.FFOX)('frame.focus should work multiple times', async ({ context, server }) => {
+it.fail(options.FIREFOX())('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 374118e144..7c30633ced 100644
--- a/test/page-emulate-media.spec.ts
+++ b/test/page-emulate-media.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import utils from './utils';
it('should emulate type', async({page, server}) => {
@@ -114,7 +114,7 @@ it('should work in cross-process iframe', async({browser, server}) => {
await page.close();
});
-it.fail(options.FFOX)('should change the actual colors in css', async({page}) => {
+it.fail(options.FIREFOX())('should change the actual colors in css', async({page}) => {
await page.setContent(`
<style>
@media (prefers-color-scheme: dark) {
diff --git a/test/page-evaluate-handle.spec.ts b/test/page-evaluate-handle.spec.ts
index 411dad487a..cefc55a32f 100644
--- a/test/page-evaluate-handle.spec.ts
+++ b/test/page-evaluate-handle.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page, server}) => {
const windowHandle = await page.evaluateHandle(() => window);
diff --git a/test/page-evaluate.spec.ts b/test/page-evaluate.spec.ts
index 7c0b2040c0..88bbed200f 100644
--- a/test/page-evaluate.spec.ts
+++ b/test/page-evaluate.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('should work', async ({ page, server }) => {
const result = await page.evaluate(() => 7 * 3);
@@ -414,7 +415,7 @@ it('should not throw an error when evaluation does a navigation', async ({ page,
expect(result).toEqual([42]);
});
-it.fail(options.WEBKIT)('should not throw an error when evaluation does a synchronous navigation and returns an object', async ({ page, server }) => {
+it.fail(options.WEBKIT())('should not throw an error when evaluation does a synchronous navigation and returns an object', async ({ page, server }) => {
// It is imporant to be on about:blank for sync reload.
const result = await page.evaluate(() => {
window.location.reload();
@@ -452,7 +453,7 @@ it('should work even when JSON is set to null', async ({ page }) => {
expect(result).toEqual({ abc: 123 });
});
-it.fail(options.FFOX)('should await promise from popup', async ({ page, server }) => {
+it.fail(options.FIREFOX())('should await promise from popup', async ({ page, server }) => {
// Something is wrong about the way Firefox waits for the chained promise
await page.goto(server.EMPTY_PAGE);
const result = await page.evaluate(() => {
diff --git a/test/page-event-console.spec.ts b/test/page-event-console.spec.ts
index e970136bc7..098ab7fac1 100644
--- a/test/page-event-console.spec.ts
+++ b/test/page-event-console.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import util from 'util';
it('should work', async({page, server}) => {
diff --git a/test/page-event-crash.spec.ts b/test/page-event-crash.spec.ts
index e260847468..31f002b8a2 100644
--- a/test/page-event-crash.spec.ts
+++ b/test/page-event-crash.spec.ts
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
-const CRASH_FAIL = (options.FFOX && WIN) || options.WIRE;
+const CRASH_FAIL = (options.FIREFOX() && WIN) || options.WIRE;
// Firefox Win: it just doesn't crash sometimes.
function crash(pageImpl, browserName) {
if (browserName === 'chromium')
diff --git a/test/page-event-network.spec.ts b/test/page-event-network.spec.ts
index 80485cefd2..6f7085fa7b 100644
--- a/test/page-event-network.spec.ts
+++ b/test/page-event-network.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('Page.Events.Request', async({page, server}) => {
const requests = [];
@@ -52,9 +53,9 @@ it('Page.Events.RequestFailed', async({page, server}) => {
expect(failedRequests[0].url()).toContain('one-style.css');
expect(await failedRequests[0].response()).toBe(null);
expect(failedRequests[0].resourceType()).toBe('stylesheet');
- if (options.CHROMIUM) {
+ if (options.CHROMIUM()) {
expect(failedRequests[0].failure().errorText).toBe('net::ERR_EMPTY_RESPONSE');
- } else if (options.WEBKIT) {
+ } else if (options.WEBKIT()) {
if (MAC)
expect(failedRequests[0].failure().errorText).toBe('The network connection was lost.');
else if (WIN)
diff --git a/test/page-event-pageerror.spec.ts b/test/page-event-pageerror.spec.ts
index 737fa4a330..19d74b6b6a 100644
--- a/test/page-event-pageerror.spec.ts
+++ b/test/page-event-pageerror.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('should fire', async({page, server}) => {
const [error] = await Promise.all([
@@ -25,12 +26,12 @@ it('should fire', async({page, server}) => {
expect(error.message).toBe('Fancy error!');
let stack = await page.evaluate(() => window['e'].stack);
// Note that WebKit reports the stack of the 'throw' statement instead of the Error constructor call.
- if (options.WEBKIT)
+ if (options.WEBKIT())
stack = stack.replace('14:25', '15:19');
expect(error.stack).toBe(stack);
});
-it.fail(options.WEBKIT)('should contain sourceURL', async({page, server}) => {
+it.fail(options.WEBKIT())('should contain sourceURL', async({page, server}) => {
const [error] = await Promise.all([
page.waitForEvent('pageerror'),
page.goto(server.PREFIX + '/error.html'),
@@ -50,24 +51,24 @@ it('should handle odd values', async ({page}) => {
page.waitForEvent('pageerror'),
page.evaluate(value => setTimeout(() => { throw value; }, 0), value),
]);
- expect(error.message).toBe(options.FFOX ? 'uncaught exception: ' + message : message);
+ expect(error.message).toBe(options.FIREFOX() ? 'uncaught exception: ' + message : message);
}
});
-it.fail(options.FFOX)('should handle object', async ({page}) => {
+it.fail(options.FIREFOX())('should handle object', async ({page}) => {
// Firefox just does not report this error.
const [error] = await Promise.all([
page.waitForEvent('pageerror'),
page.evaluate(() => setTimeout(() => { throw {}; }, 0)),
]);
- expect(error.message).toBe(options.CHROMIUM ? 'Object' : '[object Object]');
+ expect(error.message).toBe(options.CHROMIUM() ? 'Object' : '[object Object]');
});
-it.fail(options.FFOX)('should handle window', async ({page}) => {
+it.fail(options.FIREFOX())('should handle window', async ({page}) => {
// Firefox just does not report this error.
const [error] = await Promise.all([
page.waitForEvent('pageerror'),
page.evaluate(() => setTimeout(() => { throw window; }, 0)),
]);
- expect(error.message).toBe(options.CHROMIUM ? 'Window' : '[object Window]');
+ expect(error.message).toBe(options.CHROMIUM() ? 'Window' : '[object Window]');
});
diff --git a/test/page-event-popup.spec.ts b/test/page-event-popup.spec.ts
index 8930b2c306..f1457fd585 100644
--- a/test/page-event-popup.spec.ts
+++ b/test/page-event-popup.spec.ts
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({browser}) => {
const context = await browser.newContext();
diff --git a/test/page-event-request.spec.ts b/test/page-event-request.spec.ts
index 95d5103524..a45fd3da46 100644
--- a/test/page-event-request.spec.ts
+++ b/test/page-event-request.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import utils from './utils';
it('should fire for navigation requests', async({page, server}) => {
diff --git a/test/page-expose-function.spec.ts b/test/page-expose-function.spec.ts
index afd2838f25..49116d5f40 100644
--- a/test/page-expose-function.spec.ts
+++ b/test/page-expose-function.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('exposeBinding should work', async({browser}) => {
const context = await browser.newContext();
diff --git a/test/page-fill.spec.ts b/test/page-fill.spec.ts
index 0830bf9a6e..ec4a5ac9e9 100644
--- a/test/page-fill.spec.ts
+++ b/test/page-fill.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
async function giveItAChanceToFill(page) {
for (let i = 0; i < 5; i++)
@@ -59,7 +60,7 @@ it('should fill date input after clicking', async({page, server}) => {
expect(await page.$eval('input', input => input.value)).toBe('2020-03-02');
});
-it.skip(options.WEBKIT)('should throw on incorrect date', async({page, server}) => {
+it.skip(options.WEBKIT())('should throw on incorrect date', async({page, server}) => {
await page.setContent('<input type=date>');
const error = await page.fill('input', '2020-13-05').catch(e => e);
expect(error.message).toContain('Malformed value');
@@ -71,7 +72,7 @@ it('should fill time input', async({page, server}) => {
expect(await page.$eval('input', input => input.value)).toBe('13:15');
});
-it.skip(options.WEBKIT)('should throw on incorrect time', async({page, server}) => {
+it.skip(options.WEBKIT())('should throw on incorrect time', async({page, server}) => {
await page.setContent('<input type=time>');
const error = await page.fill('input', '25:05').catch(e => e);
expect(error.message).toContain('Malformed value');
@@ -83,7 +84,7 @@ it('should fill datetime-local input', async({page, server}) => {
expect(await page.$eval('input', input => input.value)).toBe('2020-03-02T05:15');
});
-it.skip(options.WEBKIT || options.FFOX)('should throw on incorrect datetime-local', async({page, server}) => {
+it.skip(options.WEBKIT() || options.FIREFOX())('should throw on incorrect datetime-local', async({page, server}) => {
await page.setContent('<input type=datetime-local>');
const error = await page.fill('input', 'abc').catch(e => e);
expect(error.message).toContain('Malformed value');
diff --git a/test/page-goto.spec.ts b/test/page-goto.spec.ts
index 88651a66ad..68ff203eae 100644
--- a/test/page-goto.spec.ts
+++ b/test/page-goto.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
import utils from './utils';
import path from 'path';
@@ -142,9 +143,9 @@ it('should fail when server returns 204', async({page, server}) => {
let error = null;
await page.goto(server.EMPTY_PAGE).catch(e => error = e);
expect(error).not.toBe(null);
- if (options.CHROMIUM)
+ if (options.CHROMIUM())
expect(error.message).toContain('net::ERR_ABORTED');
- else if (options.WEBKIT)
+ else if (options.WEBKIT())
expect(error.message).toContain('Aborted: 204 No Content');
else
expect(error.message).toContain('NS_BINDING_ABORTED');
@@ -167,7 +168,7 @@ it('should work when page calls history API in beforeunload', async({page, serve
it('should fail when navigating to bad url', async({page}) => {
let error = null;
await page.goto('asdfasdf').catch(e => error = e);
- if (options.CHROMIUM || options.WEBKIT)
+ if (options.CHROMIUM() || options.WEBKIT())
expect(error.message).toContain('Cannot navigate to invalid URL');
else
expect(error.message).toContain('Invalid url');
@@ -211,11 +212,11 @@ it('should throw if networkidle2 is passed as an option', async({page, server})
it('should fail when main resources failed to load', async({page}) => {
let error = null;
await page.goto('http://localhost:44123/non-existing-url').catch(e => error = e);
- if (options.CHROMIUM)
+ if (options.CHROMIUM())
expect(error.message).toContain('net::ERR_CONNECTION_REFUSED');
- else if (options.WEBKIT && WIN)
+ else if (options.WEBKIT() && WIN)
expect(error.message).toContain(`Couldn\'t connect to server`);
- else if (options.WEBKIT)
+ else if (options.WEBKIT())
expect(error.message).toContain('Could not connect');
else
expect(error.message).toContain('NS_ERROR_CONNECTION_REFUSED');
@@ -306,9 +307,9 @@ it('should fail when replaced by another navigation', async({page, server}) => {
});
const error = await page.goto(server.PREFIX + '/empty.html').catch(e => e);
await anotherPromise;
- if (options.CHROMIUM)
+ if (options.CHROMIUM())
expect(error.message).toContain('net::ERR_ABORTED');
- else if (options.WEBKIT)
+ else if (options.WEBKIT())
expect(error.message).toContain('cancelled');
else
expect(error.message).toContain('NS_BINDING_ABORTED');
diff --git a/test/page-history.spec.ts b/test/page-history.spec.ts
index aff79bc621..4894098a3f 100644
--- a/test/page-history.spec.ts
+++ b/test/page-history.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import url from 'url';
it('page.goBack should work', async({page, server}) => {
@@ -52,7 +52,7 @@ it('page.goBack should work with HistoryAPI', async({page, server}) => {
expect(page.url()).toBe(server.PREFIX + '/first.html');
});
-it.fail(options.WEBKIT && MAC)('page.goBack should work for file urls', async ({page, server, asset}) => {
+it.fail(options.WEBKIT() && MAC)('page.goBack should work for file urls', async ({page, server, asset}) => {
// WebKit embedder fails to go back/forward to the file url.
const url1 = url.pathToFileURL(asset('empty.html')).href;
const url2 = server.EMPTY_PAGE;
diff --git a/test/page-network-idle.spec.ts b/test/page-network-idle.spec.ts
index 838dd9d123..7deb985ed4 100644
--- a/test/page-network-idle.spec.ts
+++ b/test/page-network-idle.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import { Frame, Page } from '..';
import { TestServer } from '../utils/testserver';
diff --git a/test/page-route.spec.ts b/test/page-route.spec.ts
index a54d931471..c2dd41d3eb 100644
--- a/test/page-route.spec.ts
+++ b/test/page-route.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('should intercept', async({page, server}) => {
let intercepted = false;
@@ -188,9 +189,9 @@ it('should be abortable with custom error codes', async({page, server}) => {
page.on('requestfailed', request => failedRequest = request);
await page.goto(server.EMPTY_PAGE).catch(e => {});
expect(failedRequest).toBeTruthy();
- if (options.WEBKIT)
+ if (options.WEBKIT())
expect(failedRequest.failure().errorText).toBe('Request intercepted');
- else if (options.FFOX)
+ else if (options.FIREFOX())
expect(failedRequest.failure().errorText).toBe('NS_ERROR_OFFLINE');
else
expect(failedRequest.failure().errorText).toBe('net::ERR_INTERNET_DISCONNECTED');
@@ -213,9 +214,9 @@ it('should fail navigation when aborting main resource', async({page, server}) =
let error = null;
await page.goto(server.EMPTY_PAGE).catch(e => error = e);
expect(error).toBeTruthy();
- if (options.WEBKIT)
+ if (options.WEBKIT())
expect(error.message).toContain('Request intercepted');
- else if (options.FFOX)
+ else if (options.FIREFOX())
expect(error.message).toContain('NS_ERROR_FAILURE');
else
expect(error.message).toContain('net::ERR_FAILED');
diff --git a/test/page-screenshot.spec.ts b/test/page-screenshot.spec.ts
index d3eed9734b..13c5e49060 100644
--- a/test/page-screenshot.spec.ts
+++ b/test/page-screenshot.spec.ts
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
import utils from './utils';
import path from 'path';
import fs from 'fs';
-
// Firefox headful produces a different image.
-const ffheadful = options.FFOX && !options.HEADLESS;
+const ffheadful = options.FIREFOX() && !options.HEADLESS;
it.skip(ffheadful)('should work', async({page, server, golden}) => {
await page.setViewportSize({width: 500, height: 500});
@@ -139,7 +139,7 @@ it.skip(ffheadful)('should run in parallel in multiple pages', async({server, co
await Promise.all(pages.map(page => page.close()));
});
-it.fail(options.FFOX)('should allow transparency', async({page, golden}) => {
+it.fail(options.FIREFOX())('should allow transparency', async({page, golden}) => {
await page.setViewportSize({ width: 50, height: 150 });
await page.setContent(`
<style>
@@ -173,7 +173,7 @@ it.skip(ffheadful)('should work with odd clip size on Retina displays', async({p
expect(screenshot).toMatchImage(golden('screenshot-clip-odd-size.png'));
});
-it.skip(options.FFOX)('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 + '/overflow.html');
@@ -182,7 +182,7 @@ it.skip(options.FFOX)('should work with a mobile viewport', async({browser, serv
await context.close();
});
-it.skip(options.FFOX)('should work with a mobile viewport and clip', async({browser, server, golden}) => {
+it.skip(options.FIREFOX())('should work with a mobile viewport and clip', 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 + '/overflow.html');
@@ -191,7 +191,7 @@ it.skip(options.FFOX)('should work with a mobile viewport and clip', async({brow
await context.close();
});
-it.skip(options.FFOX)('should work with a mobile viewport and fullPage', async({browser, server, golden}) => {
+it.skip(options.FIREFOX())('should work with a mobile viewport and fullPage', 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 + '/overflow-large.html');
@@ -214,7 +214,7 @@ it.skip(ffheadful)('should work for translateZ', async({page, server, golden}) =
expect(screenshot).toMatchImage(golden('screenshot-translateZ.png'));
});
-it.fail(options.FFOX || options.WEBKIT)('should work for webgl', async({page, server, golden}) => {
+it.fail(options.FIREFOX() || options.WEBKIT())('should work for webgl', async({page, server, golden}) => {
await page.setViewportSize({width: 640, height: 480});
await page.goto(server.PREFIX + '/screenshots/webgl.html');
const screenshot = await page.screenshot();
diff --git a/test/page-select-option.spec.ts b/test/page-select-option.spec.ts
index 953c07ea8b..723cf41af2 100644
--- a/test/page-select-option.spec.ts
+++ b/test/page-select-option.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should select single option', async({page, server}) => {
await page.goto(server.PREFIX + '/input/select.html');
diff --git a/test/page-set-content.spec.ts b/test/page-set-content.spec.ts
index ef888881d9..bdb7d0e1e4 100644
--- a/test/page-set-content.spec.ts
+++ b/test/page-set-content.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
const expectedOutput = '<html><head></head><body><div>hello</div></body></html>';
diff --git a/test/page-set-extra-http-headers.spec.ts b/test/page-set-extra-http-headers.spec.ts
index 3c46625ec3..c6c59d9cad 100644
--- a/test/page-set-extra-http-headers.spec.ts
+++ b/test/page-set-extra-http-headers.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page, server}) => {
await page.setExtraHTTPHeaders({
diff --git a/test/page-set-input-files.spec.ts b/test/page-set-input-files.spec.ts
index 511aac59bf..dfc995d375 100644
--- a/test/page-set-input-files.spec.ts
+++ b/test/page-set-input-files.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
import path from 'path';
import fs from 'fs';
diff --git a/test/page-wait-for-load-state.spec.ts b/test/page-wait-for-load-state.spec.ts
index e7e7a6d181..8de70d5cf1 100644
--- a/test/page-wait-for-load-state.spec.ts
+++ b/test/page-wait-for-load-state.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import { Route } from '..';
it('should pick up ongoing navigation', async({page, server}) => {
@@ -77,8 +77,8 @@ it('should wait for load state of empty url popup', async({browser, page}) => {
}),
]);
await popup.waitForLoadState();
- expect(readyState).toBe(options.FFOX ? 'uninitialized' : 'complete');
- expect(await popup.evaluate(() => document.readyState)).toBe(options.FFOX ? 'uninitialized' : 'complete');
+ expect(readyState).toBe(options.FIREFOX() ? 'uninitialized' : 'complete');
+ expect(await popup.evaluate(() => document.readyState)).toBe(options.FIREFOX() ? 'uninitialized' : 'complete');
});
it('should wait for load state of about:blank popup ', async({browser, page}) => {
diff --git a/test/page-wait-for-navigation.spec.ts b/test/page-wait-for-navigation.spec.ts
index 0293fc2db7..4d076e5daf 100644
--- a/test/page-wait-for-navigation.spec.ts
+++ b/test/page-wait-for-navigation.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
import utils from './utils';
import { Frame } from '..';
@@ -140,7 +141,7 @@ it('should work with DOM history.back()/history.forward()', async({page, server}
expect(page.url()).toBe(server.PREFIX + '/second.html');
});
-it.fail(options.FFOX)('should work when subframe issues window.stop()', async({page, server}) => {
+it.fail(options.FIREFOX())('should work when subframe issues window.stop()', async({page, server}) => {
server.setRoute('/frames/style.css', (req, res) => {});
const navigationPromise = page.goto(server.PREFIX + '/frames/one-frame.html');
const frame = await new Promise<Frame>(f => page.once('frameattached', f));
diff --git a/test/page-wait-for-request.spec.ts b/test/page-wait-for-request.spec.ts
index 41d58288c9..1e84af19c1 100644
--- a/test/page-wait-for-request.spec.ts
+++ b/test/page-wait-for-request.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
import vm from 'vm';
diff --git a/test/page-wait-for-response.spec.ts b/test/page-wait-for-response.spec.ts
index 6f8a249f28..c09a43192a 100644
--- a/test/page-wait-for-response.spec.ts
+++ b/test/page-wait-for-response.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page, server}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/test/pdf.spec.ts b/test/pdf.spec.ts
index 9169acba46..70176dc539 100644
--- a/test/pdf.spec.ts
+++ b/test/pdf.spec.ts
@@ -14,21 +14,20 @@
* limitations under the License.
*/
-import './runner/builtin.fixtures';
-import './base.fixture';
+import { options } from './playwright.fixtures';
import fs from 'fs'
import path from 'path'
// Printing to pdf is currently only supported in headless chromium.
-it.skip(!(options.HEADLESS && options.CHROMIUM))('should be able to save file', async({page, tmpDir}) => {
+it.skip(!(options.HEADLESS && options.CHROMIUM()))('should be able to save file', async({page, tmpDir}) => {
const outputFile = path.join(tmpDir, 'output.pdf');
await page.pdf({path: outputFile});
expect(fs.readFileSync(outputFile).byteLength).toBeGreaterThan(0);
fs.unlinkSync(outputFile);
});
-it.skip(options.CHROMIUM)('should be able to save file', async({page}) => {
+it.skip(options.CHROMIUM())('should be able to save file', async({page}) => {
expect(page.pdf).toBe(undefined);
});
diff --git a/test/permissions.spec.ts b/test/permissions.spec.ts
index fa3a75dd8e..bc19021ba2 100644
--- a/test/permissions.spec.ts
+++ b/test/permissions.spec.ts
@@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
function getPermission(page, name) {
return page.evaluate(name => navigator.permissions.query({name}).then(result => result.state), name);
}
-describe.skip(options.WEBKIT)('permissions', () => {
+describe.skip(options.WEBKIT())('permissions', () => {
it('should be prompt by default', async({page, server, context}) => {
// Permissions API is not implemented in WebKit (see https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API)
await page.goto(server.EMPTY_PAGE);
@@ -91,7 +91,7 @@ describe.skip(options.WEBKIT)('permissions', () => {
expect(await getPermission(page, 'geolocation')).toBe('prompt');
});
- it.fail(options.WEBKIT || options.FFOX || (options.CHROMIUM && !options.HEADLESS))('should trigger permission onchange', async({page, server, context}) => {
+ it.fail(options.WEBKIT() || options.FIREFOX() || (options.CHROMIUM() && !options.HEADLESS))('should trigger permission onchange', async({page, server, context}) => {
//TODO: flaky
// - Linux: https://github.com/microsoft/playwright/pull/1790/checks?check_run_id=587327883
// - Win: https://ci.appveyor.com/project/aslushnikov/playwright/builds/32402536
@@ -133,7 +133,7 @@ describe.skip(options.WEBKIT)('permissions', () => {
await otherContext.close();
});
- it.fail(options.WEBKIT || options.FFOX || (options.CHROMIUM && !options.HEADLESS))('should support clipboard read', async({page, server, context, browser}) => {
+ it.fail(options.WEBKIT() || options.FIREFOX() || (options.CHROMIUM() && !options.HEADLESS))('should support clipboard read', async({page, server, context, browser}) => {
// No such permissions (requires flag) in Firefox
await page.goto(server.EMPTY_PAGE);
expect(await getPermission(page, 'clipboard-read')).toBe('prompt');
diff --git a/test/base.fixture.ts b/test/playwright.fixtures.ts
similarity index 89%
rename from test/base.fixture.ts
rename to test/playwright.fixtures.ts
index 6ccb56c1ee..fe8e01aa0f 100644
--- a/test/base.fixture.ts
+++ b/test/playwright.fixtures.ts
@@ -19,13 +19,12 @@ import path from 'path';
import os from 'os';
import childProcess from 'child_process';
import { LaunchOptions, BrowserType, Browser, BrowserContext, Page, BrowserServer } from '../index';
-import { TestServer } from '../utils/testserver/';
+import { TestServer } from '../utils/testserver';
import { Connection } from '../lib/rpc/client/connection';
import { Transport } from '../lib/rpc/transport';
import { setUnderTest } from '../lib/helper';
import { installCoverageHooks } from './coverage';
-import { registerFixture, registerWorkerFixture, registerOption, registerOptionGenerator } from './runner';
-import './runner/builtin.fixtures';
+import { parameters, registerFixture, registerWorkerFixture, registerParameter } from './runner';
import {mkdtempAsync, removeFolderAsync} from './utils';
@@ -51,13 +50,8 @@ declare global {
httpsServer: TestServer;
browserServer: BrowserServer;
}
- interface Options {
+ interface FixtureParameters {
browserName: string;
- CHROMIUM: boolean;
- FFOX: boolean;
- WEBKIT: boolean;
- HEADLESS: boolean;
- WIRE: boolean;
}
}
@@ -69,7 +63,7 @@ registerWorkerFixture('httpService', async ({}, test) => {
const assetsPath = path.join(__dirname, 'assets');
const cachedPath = path.join(__dirname, 'assets', 'cached');
- const port = 8907 + options.parallelIndex * 2;
+ const port = 8907 + parameters.parallelIndex * 2;
const server = await TestServer.create(assetsPath, port);
server.enableHTTPCache(cachedPath);
@@ -137,7 +131,7 @@ registerWorkerFixture('playwright', async({browserName}, test) => {
async function teardownCoverage() {
uninstall();
- const coveragePath = path.join(__dirname, 'coverage-report', options.parallelIndex + '.json');
+ const coveragePath = path.join(__dirname, 'coverage-report', parameters.parallelIndex + '.json');
const coverageJSON = [...coverage.keys()].filter(key => coverage.get(key));
await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });
await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');
@@ -199,17 +193,19 @@ registerWorkerFixture('golden', async ({browserName}, test) => {
await test(p => path.join(browserName, p));
});
-registerOptionGenerator('browserName', () => {
+registerParameter('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');
-registerOption('HEADLESS', ({}) => !!valueFromEnv('HEADLESS', true));
-registerOption('WIRE', ({}) => process.env.PWWIRE);
+export const options = {
+ CHROMIUM: () => parameters.browserName === 'chromium',
+ FIREFOX: () => parameters.browserName === 'firefox',
+ WEBKIT: () => parameters.browserName === 'webkit',
+ HEADLESS : !!valueFromEnv('HEADLESS', true),
+ WIRE: !!process.env.PWWIRE,
+}
function valueFromEnv(name, defaultValue) {
if (!(name in process.env))
diff --git a/test/popup.spec.ts b/test/popup.spec.ts
index f675e6e6db..dbf93dfc91 100644
--- a/test/popup.spec.ts
+++ b/test/popup.spec.ts
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
it('should inherit user agent from browser context', async function({browser, server}) {
const context = await browser.newContext({
@@ -232,7 +232,7 @@ it('should not dispatch binding on a closed page', async function({browser, serv
}),
]);
await context.close();
- if (options.FFOX)
+ if (options.FIREFOX())
expect(messages.join('|')).toBe('alreadyclosed');
else
expect(messages.join('|')).toBe('binding|close');
diff --git a/test/proxy.spec.ts b/test/proxy.spec.ts
index 0eecc0b693..a23083838d 100644
--- a/test/proxy.spec.ts
+++ b/test/proxy.spec.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import './runner/builtin.fixtures';
-import './base.fixture';
+import { parameters } from './runner';
+import { options } from './playwright.fixtures';
import socks from 'socksv5';
@@ -56,7 +56,7 @@ it('should authenticate', async ({browserType, defaultBrowserOptions, server}) =
await browser.close();
});
-it.fail(options.CHROMIUM && !options.HEADLESS)('should exclude patterns', async ({browserType, defaultBrowserOptions, server}) => {
+it.fail(options.CHROMIUM() && !options.HEADLESS)('should exclude patterns', async ({browserType, defaultBrowserOptions, server}) => {
// Chromium headful crashes with CHECK(!in_frame_tree_) in RenderFrameImpl::OnDeleteFrame.
server.setRoute('/target.html', async (req, res) => {
res.end('<html><title>Served by the proxy</title></html>');
@@ -114,7 +114,7 @@ it('should use socks proxy', async ({ browserType, defaultBrowserOptions }) => {
].join('\r\n'));
}
});
- const socksPort = 9107 + options.parallelIndex * 2;
+ const socksPort = 9107 + parameters.parallelIndex * 2;
server.listen(socksPort, 'localhost');
server.useAuth(socks.auth.None());
diff --git a/test/queryselector.spec.ts b/test/queryselector.spec.ts
index 7d9dbc19fb..511f7eaec5 100644
--- a/test/queryselector.spec.ts
+++ b/test/queryselector.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should query existing element with css selector', async({page, server}) => {
await page.setContent('<section>test</section>');
diff --git a/test/request-continue.spec.ts b/test/request-continue.spec.ts
index b2f4d8351a..c0d3891839 100644
--- a/test/request-continue.spec.ts
+++ b/test/request-continue.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work', async({page, server}) => {
await page.route('**/*', route => route.continue());
diff --git a/test/request-fulfill.spec.ts b/test/request-fulfill.spec.ts
index 80a4472701..10a8ad48c6 100644
--- a/test/request-fulfill.spec.ts
+++ b/test/request-fulfill.spec.ts
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import fs from 'fs';
import path from 'path';
@@ -50,7 +50,7 @@ it('should work with status code 422', async({page, server}) => {
expect(await page.evaluate(() => document.body.textContent)).toBe('Yo, page!');
});
-it.skip(options.FFOX && !options.HEADLESS)('should allow mocking binary responses', async({page, server, golden}) => {
+it.skip(options.FIREFOX() && !options.HEADLESS)('should allow mocking binary responses', async({page, server, golden}) => {
// Firefox headful produces a different image.
await page.route('**/*', route => {
const imageBuffer = fs.readFileSync(path.join(__dirname, 'assets', 'pptr.png'));
@@ -69,7 +69,7 @@ it.skip(options.FFOX && !options.HEADLESS)('should allow mocking binary response
expect(await img.screenshot()).toMatchImage(golden('mock-binary-response.png'));
});
-it.skip(options.FFOX && !options.HEADLESS)('should allow mocking svg with charset', async({page, server, golden}) => {
+it.skip(options.FIREFOX() && !options.HEADLESS)('should allow mocking svg with charset', async({page, server, golden}) => {
// Firefox headful produces a different image.
await page.route('**/*', route => {
route.fulfill({
diff --git a/test/run_static_server.js b/test/run_static_server.js
index b256b228c6..b6ac3e8c74 100755
--- a/test/run_static_server.js
+++ b/test/run_static_server.js
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
const path = require('path');
const {TestServer} = require('../utils/testserver/');
diff --git a/test/runner/fixtures.js b/test/runner/fixtures.js
index 23bb3e3ce2..89db9c7b49 100644
--- a/test/runner/fixtures.js
+++ b/test/runner/fixtures.js
@@ -18,28 +18,11 @@ const debug = require('debug');
const registrations = new Map();
const registrationsByFile = new Map();
-const optionRegistrations = new Map();
-const optionsImpl = new Map();
-const options = new Proxy({}, {
- get: (obj, prop) => {
- if (optionsImpl.has(prop))
- return optionsImpl.get(prop);
- const fn = optionRegistrations.get(prop);
- if (!fn)
- return obj[prop];
- const names = optionParameterNames(fn);
- const param = {};
- names.forEach(name => param[name] = options[name]);
- const result = fn.call(null, param);
- optionsImpl.set(prop, result);
- return result;
- }
-});
+let parameters = {};
+const parameterRegistrations = new Map();
-function setOptions(map) {
- optionsImpl.clear();
- for (const [name, value] of map)
- optionsImpl.set(name, value);
+function setParameters(params) {
+ parameters = Object.assign(parameters, params)
}
class Fixture {
@@ -50,12 +33,12 @@ class Fixture {
this.fn = fn;
this.deps = fixtureParameterNames(this.fn);
this.usages = new Set();
- this.generatorValue = optionsImpl.get(name);
- this.value = this.generatorValue || null;
+ this.hasGeneratorValue = name in parameters;
+ this.value = this.hasGeneratorValue ? parameters[name] : null;
}
async setup() {
- if (this.generatorValue)
+ if (this.hasGeneratorValue)
return;
for (const name of this.deps) {
await this.pool.setupFixture(name);
@@ -80,7 +63,7 @@ class Fixture {
}
async teardown() {
- if (this.generatorValue)
+ if (this.hasGeneratorValue)
return;
if (this._teardown)
return;
@@ -203,13 +186,9 @@ function registerWorkerFixture(name, fn) {
innerRegisterFixture(name, 'worker', fn);
};
-function registerOptionGenerator(name, fn) {
- registerWorkerFixture(name, async ({}, test) => await test(options.browserName));
- optionRegistrations.set(name, fn);
-}
-
-function registerOption(name, fn) {
- optionRegistrations.set(name, fn);
+function registerParameter(name, fn) {
+ registerWorkerFixture(name, async ({}, test) => await test(parameters[name]));
+ parameterRegistrations.set(name, fn);
}
function collectRequires(file, result) {
@@ -249,4 +228,4 @@ function rerunRegistrations(file, scope) {
registrations.set(registration.name, registration);
}
-module.exports = { FixturePool, registerFixture, registerWorkerFixture, rerunRegistrations, lookupRegistrations, fixturesForCallback, registerOption, registerOptionGenerator, setOptions, optionRegistrations, options };
+module.exports = { FixturePool, registerFixture, registerWorkerFixture, rerunRegistrations, lookupRegistrations, fixturesForCallback, registerParameter, setParameters, parameterRegistrations, parameters };
diff --git a/test/runner/fixturesUI.js b/test/runner/fixturesUI.js
index 8cb6c7eac2..a37078c4d8 100644
--- a/test/runner/fixturesUI.js
+++ b/test/runner/fixturesUI.js
@@ -14,16 +14,11 @@
* limitations under the License.
*/
-const { registerFixture, registerWorkerFixture, registerOption, options } = require('./fixtures');
const { Test, Suite } = require('mocha');
const { installTransform } = require('./transform');
const commonSuite = require('mocha/lib/interfaces/common');
Error.stackTraceLimit = 15;
-global.options = options;
-global.registerFixture = registerFixture;
-global.registerWorkerFixture = registerWorkerFixture;
-global.registerOption = registerOption;
let revertBabelRequire;
diff --git a/test/runner/index.js b/test/runner/index.js
deleted file mode 100644
index 88ee0c3363..0000000000
--- a/test/runner/index.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright Microsoft Corporation. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-const { options, registerFixture, registerWorkerFixture, registerOption, registerOptionGenerator } = require('./fixtures');
-
-module.exports = { options, registerFixture, registerWorkerFixture, registerOption, registerOptionGenerator };
diff --git a/test/runner/builtin.fixtures.ts b/test/runner/index.ts
similarity index 62%
rename from test/runner/builtin.fixtures.ts
rename to test/runner/index.ts
index 8ae94ae1a8..33fc93a84c 100644
--- a/test/runner/builtin.fixtures.ts
+++ b/test/runner/index.ts
@@ -14,21 +14,31 @@
* limitations under the License.
*/
-import os from 'os';
-import path from 'path';
-import { mkdtempAsync, removeFolderAsync } from '../utils';
-import { registerFixture } from '.';
+const os = require('os');
+const path = require('path');
+const { mkdtempAsync, removeFolderAsync } = require('../utils');
+
+const {
+ parameters: jsParameters,
+ registerFixture: jsRegisterFixture,
+ registerWorkerFixture: jsRegisterWorkerFixture,
+ registerParameter: jsRegisterParameter
+} = require('./fixtures');
declare global {
- interface Options {
+ interface FixtureParameters {
parallelIndex: number;
}
-
interface WorkerState {
tmpDir: string;
}
}
+export const parameters: FixtureParameters = jsParameters;
+export const registerFixture = jsRegisterFixture;
+export const registerWorkerFixture = jsRegisterWorkerFixture
+export const registerParameter = jsRegisterParameter;
+
registerFixture('tmpDir', async ({}, test) => {
const tmpDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-'));
await test(tmpDir);
diff --git a/test/runner/testCollector.js b/test/runner/testCollector.js
index cd28fa62be..822f77dbe6 100644
--- a/test/runner/testCollector.js
+++ b/test/runner/testCollector.js
@@ -16,7 +16,7 @@
const path = require('path');
const Mocha = require('mocha');
-const { fixturesForCallback, optionRegistrations } = require('./fixtures');
+const { fixturesForCallback, parameterRegistrations } = require('./fixtures');
const { fixturesUI } = require('./fixturesUI');
class NullReporter {}
@@ -69,9 +69,9 @@ class TestCollector {
// to build different workers for them.
const generatorConfigurations = [];
for (const name of fixtures) {
- if (!optionRegistrations.has(name))
+ if (!parameterRegistrations.has(name))
continue;
- const values = optionRegistrations.get(name)();
+ const values = parameterRegistrations.get(name)();
let state = generatorConfigurations.length ? generatorConfigurations.slice() : [[]];
generatorConfigurations.length = 0;
for (const gen of state) {
diff --git a/test/runner/testRunner.js b/test/runner/testRunner.js
index 5376ddabc3..0328e68e0f 100644
--- a/test/runner/testRunner.js
+++ b/test/runner/testRunner.js
@@ -16,7 +16,7 @@
const path = require('path');
const Mocha = require('mocha');
-const { FixturePool, rerunRegistrations, setOptions } = require('./fixtures');
+const { FixturePool, rerunRegistrations, setParameters } = require('./fixtures');
const { fixturesUI } = require('./fixturesUI');
const { EventEmitter } = require('events');
@@ -50,10 +50,10 @@ class TestRunner extends EventEmitter {
this._configuredFile = entry.configuredFile;
this._configurationObject = entry.configurationObject;
this._configurationString = entry.configurationString;
- this._parsedGeneratorConfiguration = new Map();
+ this._parsedGeneratorConfiguration = {};
for (const {name, value} of this._configurationObject)
- this._parsedGeneratorConfiguration.set(name, value);
- this._parsedGeneratorConfiguration.set('parallelIndex', workerId);
+ this._parsedGeneratorConfiguration[name] = value;
+ this._parsedGeneratorConfiguration['parallelIndex'] = workerId;
this._relativeTestFile = path.relative(options.testDir, this._file);
this.mocha.addFile(this._file);
}
@@ -67,7 +67,7 @@ class TestRunner extends EventEmitter {
async run() {
let callback;
const result = new Promise(f => callback = f);
- setOptions(this._parsedGeneratorConfiguration);
+ setParameters(this._parsedGeneratorConfiguration);
this.mocha.loadFiles();
rerunRegistrations(this._file, 'test');
this._runner = this.mocha.run(callback);
diff --git a/test/screencast.spec.ts b/test/screencast.spec.ts
index 39c7c01a7a..9a2706173f 100644
--- a/test/screencast.spec.ts
+++ b/test/screencast.spec.ts
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-import './runner/builtin.fixtures';
-import './base.fixture';
+import { options } from './playwright.fixtures';
import { registerFixture } from './runner';
import { Page } from '..';
@@ -32,7 +31,7 @@ declare global {
registerFixture('videoPlayer', async ({playwright, context}, test) => {
let firefox;
- if (options.WEBKIT && !LINUX) {
+ if (options.WEBKIT() && !LINUX) {
// WebKit on Mac & Windows cannot replay webm/vp8 video, so we launch Firefox.
firefox = await playwright.firefox.launch();
context = await firefox.newContext();
@@ -173,7 +172,7 @@ class VideoPlayer {
}
}
-it.fail(options.CHROMIUM)('should capture static page', async({page, tmpDir, videoPlayer, toImpl}) => {
+it.fail(options.CHROMIUM())('should capture static page', async({page, tmpDir, videoPlayer, toImpl}) => {
if (!toImpl)
return;
const videoFile = path.join(tmpDir, 'v.webm');
@@ -181,7 +180,7 @@ it.fail(options.CHROMIUM)('should capture static page', async({page, tmpDir, vid
await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480});
// TODO: in WebKit figure out why video size is not reported correctly for
// static pictures.
- if (options.HEADLESS && options.WEBKIT)
+ if (options.HEADLESS && options.WEBKIT())
await page.setViewportSize({width: 1270, height: 950});
await new Promise(r => setTimeout(r, 300));
await toImpl(page)._delegate.stopScreencast();
@@ -199,7 +198,7 @@ it.fail(options.CHROMIUM)('should capture static page', async({page, tmpDir, vid
expectAll(pixels, almostRed);
});
-it.fail(options.CHROMIUM)('should capture navigation', async({page, tmpDir, server, videoPlayer, toImpl}) => {
+it.fail(options.CHROMIUM())('should capture navigation', async({page, tmpDir, server, videoPlayer, toImpl}) => {
if (!toImpl)
return;
const videoFile = path.join(tmpDir, 'v.webm');
@@ -207,7 +206,7 @@ it.fail(options.CHROMIUM)('should capture navigation', async({page, tmpDir, serv
await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480});
// TODO: in WebKit figure out why video size is not reported correctly for
// static pictures.
- if (options.HEADLESS && options.WEBKIT)
+ if (options.HEADLESS && options.WEBKIT())
await page.setViewportSize({width: 1270, height: 950});
await new Promise(r => setTimeout(r, 300));
await page.goto(server.CROSS_PROCESS_PREFIX + '/background-color.html#rgb(100,100,100)');
@@ -233,7 +232,7 @@ it.fail(options.CHROMIUM)('should capture navigation', async({page, tmpDir, serv
});
// Accelerated compositing is disabled in WebKit on Windows.
-it.fail(options.CHROMIUM || (options.WEBKIT && WIN))('should capture css transformation', async({page, tmpDir, server, videoPlayer, toImpl}) => {
+it.fail(options.CHROMIUM() || (options.WEBKIT() && WIN))('should capture css transformation', async({page, tmpDir, server, videoPlayer, toImpl}) => {
if (!toImpl)
return;
const videoFile = path.join(tmpDir, 'v.webm');
@@ -241,7 +240,7 @@ it.fail(options.CHROMIUM || (options.WEBKIT && WIN))('should capture css transfo
await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480});
// TODO: in WebKit figure out why video size is not reported correctly for
// static pictures.
- if (options.HEADLESS && options.WEBKIT)
+ if (options.HEADLESS && options.WEBKIT())
await page.setViewportSize({width: 1270, height: 950});
await new Promise(r => setTimeout(r, 300));
await toImpl(page)._delegate.stopScreencast();
@@ -258,7 +257,7 @@ it.fail(options.CHROMIUM || (options.WEBKIT && WIN))('should capture css transfo
}
});
-it.fail(options.CHROMIUM || options.FFOX)('should fire start/stop events when page created/closed', async({browser, tmpDir, server, toImpl}) => {
+it.fail(options.CHROMIUM() || options.FIREFOX())('should fire start/stop events when page created/closed', async({browser, tmpDir, server, toImpl}) => {
if (!toImpl)
return;
// Use server side of the context. All the code below also uses server side APIs.
diff --git a/test/selectors-css.spec.ts b/test/selectors-css.spec.ts
index 178122ef6a..4f7e163ce3 100644
--- a/test/selectors-css.spec.ts
+++ b/test/selectors-css.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work for open shadow roots', async({page, server}) => {
await page.goto(server.PREFIX + '/deep-shadow.html');
diff --git a/test/selectors-misc.spec.ts b/test/selectors-misc.spec.ts
index 8a76a61f5d..5c165eb78e 100644
--- a/test/selectors-misc.spec.ts
+++ b/test/selectors-misc.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should work for open shadow roots', async({page, server}) => {
await page.goto(server.PREFIX + '/deep-shadow.html');
diff --git a/test/selectors-register.spec.ts b/test/selectors-register.spec.ts
index 0a47cff677..e12dc27ca1 100644
--- a/test/selectors-register.spec.ts
+++ b/test/selectors-register.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
import path from 'path';
import utils from './utils';
diff --git a/test/selectors-text.spec.ts b/test/selectors-text.spec.ts
index ff31ac58ed..168608249f 100644
--- a/test/selectors-text.spec.ts
+++ b/test/selectors-text.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import { options } from './playwright.fixtures';
it('query', async ({page}) => {
await page.setContent(`<div>yo</div><div>ya</div><div>\nye </div>`);
@@ -58,9 +59,9 @@ it('query', async ({page}) => {
expect(await page.$eval(`"x"`, e => e.outerHTML)).toBe('<div>x</div>');
expect(await page.$eval(`'x'`, e => e.outerHTML)).toBe('<div>x</div>');
let error = await page.$(`"`).catch(e => e);
- expect(error.message).toContain(options.WEBKIT ? 'SyntaxError' : 'querySelector');
+ expect(error.message).toContain(options.WEBKIT() ? 'SyntaxError' : 'querySelector');
error = await page.$(`'`).catch(e => e);
- expect(error.message).toContain(options.WEBKIT ? 'SyntaxError' : 'querySelector');
+ expect(error.message).toContain(options.WEBKIT() ? 'SyntaxError' : 'querySelector');
await page.setContent(`<div> ' </div><div> " </div>`);
expect(await page.$eval(`text="`, e => e.outerHTML)).toBe('<div> " </div>');
diff --git a/test/slowmo.spec.ts b/test/slowmo.spec.ts
index efe7a249f4..428d27e4d0 100644
--- a/test/slowmo.spec.ts
+++ b/test/slowmo.spec.ts
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+import { options } from './playwright.fixtures';
import { attachFrame } from './utils';
async function checkSlowMo(toImpl, page, task) {
diff --git a/test/types.d.ts b/test/types.d.ts
index c4f1abf45d..23c25ebc84 100644
--- a/test/types.d.ts
+++ b/test/types.d.ts
@@ -37,9 +37,6 @@ interface WorkerState {
interface FixtureState {
}
-interface Options {
-}
-
declare module '' {
module 'expect/build/types' {
interface Matchers<R> {
@@ -50,7 +47,6 @@ declare module '' {
declare const expect: typeof import('expect');
-declare const options: Options;
declare const describe: DescribeFunction;
declare const fdescribe: DescribeFunction;
declare const xdescribe: DescribeFunction;
diff --git a/test/wait-for-function.spec.ts b/test/wait-for-function.spec.ts
index 113a96b737..93abeb5c0e 100644
--- a/test/wait-for-function.spec.ts
+++ b/test/wait-for-function.spec.ts
@@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import './base.fixture';
+
+import './playwright.fixtures';
it('should timeout', async({page}) => {
const startTime = Date.now();
diff --git a/test/wait-for-selector.spec.ts b/test/wait-for-selector.spec.ts
index be7c6d1ce9..fd97ce1532 100644
--- a/test/wait-for-selector.spec.ts
+++ b/test/wait-for-selector.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import utils from './utils';
async function giveItTimeToLog(frame) {
diff --git a/test/workers.spec.ts b/test/workers.spec.ts
index 0fcf71e773..fd89dd282b 100644
--- a/test/workers.spec.ts
+++ b/test/workers.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import './base.fixture';
+import './playwright.fixtures';
import { ConsoleMessage } from '..';
it('Page.workers', async function({page, server}) {
diff --git a/utils/doclint/check_public_api/test/test.js b/utils/doclint/check_public_api/test/test.js
index 7e41c97ffe..4614c35a08 100644
--- a/utils/doclint/check_public_api/test/test.js
+++ b/utils/doclint/check_public_api/test/test.js
@@ -20,6 +20,7 @@ const checkPublicAPI = require('..');
const Source = require('../../Source');
const mdBuilder = require('../MDBuilder');
const jsBuilder = require('../JSBuilder');
+const { registerWorkerFixture } = require('../../../../test/runner');
registerWorkerFixture('page', async({}, test) => {
const browser = await playwright.chromium.launch();