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

This commit is contained in:
Pavel Feldman 2020-08-19 21:32:12 -07:00 committed by GitHub
parent 30f4c0c9fe
commit 86815d70e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
143 changed files with 489 additions and 486 deletions

View file

@ -17,7 +17,7 @@
"tsc": "tsc -p .", "tsc": "tsc -p .",
"tsc-installer": "tsc -p ./src/install/tsconfig.json", "tsc-installer": "tsc -p ./src/install/tsconfig.json",
"doc": "node utils/doclint/cli.js", "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", "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", "clean": "rimraf lib && rimraf types",
"prepare": "node install-from-github.js", "prepare": "node install-from-github.js",

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
it('should work', async function({page}) { it('should work', async function({page}) {
await page.setContent(` await page.setContent(`
@ -35,7 +35,7 @@ it('should work', async function({page}) {
// autofocus happens after a delay in chrome these days // autofocus happens after a delay in chrome these days
await page.waitForFunction(() => document.activeElement.hasAttribute('autofocus')); await page.waitForFunction(() => document.activeElement.hasAttribute('autofocus'));
const golden = options.FFOX ? { const golden = options.FIREFOX() ? {
role: 'document', role: 'document',
name: 'Accessibility Test', name: 'Accessibility Test',
children: [ 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'}, // firefox doesn't use aria-placeholder for the name
{role: 'textbox', name: '', value: 'and a value', description: 'This is a description!'}, // and here {role: 'textbox', name: '', value: 'and a value', description: 'This is a description!'}, // and here
] ]
} : options.CHROMIUM ? { } : options.CHROMIUM() ? {
role: 'WebArea', role: 'WebArea',
name: 'Accessibility Test', name: 'Accessibility Test',
children: [ children: [
@ -82,7 +82,7 @@ it('should work with regular text', async({page}) => {
await page.setContent(`<div>Hello World</div>`); await page.setContent(`<div>Hello World</div>`);
const snapshot = await page.accessibility.snapshot(); const snapshot = await page.accessibility.snapshot();
expect(snapshot.children[0]).toEqual({ expect(snapshot.children[0]).toEqual({
role: options.FFOX ? 'text leaf' : 'text', role: options.FIREFOX() ? 'text leaf' : 'text',
name: 'Hello World', name: 'Hello World',
}); });
}); });
@ -124,7 +124,7 @@ it('should not report text nodes inside controls', async function({page}) {
<div role="tab">Tab2</div> <div role="tab">Tab2</div>
</div>`); </div>`);
const golden = { const golden = {
role: options.FFOX ? 'document' : 'WebArea', role: options.FIREFOX() ? 'document' : 'WebArea',
name: '', name: '',
children: [{ children: [{
role: 'tab', role: 'tab',
@ -139,12 +139,12 @@ it('should not report text nodes inside controls', async function({page}) {
}); });
// WebKit rich text accessibility is iffy // 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(` await page.setContent(`
<div contenteditable="true"> <div contenteditable="true">
Edit this image: <img src="fakeimage.png" alt="my fake image"> Edit this image: <img src="fakeimage.png" alt="my fake image">
</div>`); </div>`);
const golden = options.FFOX ? { const golden = options.FIREFOX() ? {
role: 'section', role: 'section',
name: '', name: '',
children: [{ children: [{
@ -170,12 +170,12 @@ it.skip(options.WEBKIT)('rich text editable fields should have children', async
expect(snapshot.children[0]).toEqual(golden); expect(snapshot.children[0]).toEqual(golden);
}); });
// WebKit rich text accessibility is iffy // 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(` await page.setContent(`
<div contenteditable="true" role='textbox'> <div contenteditable="true" role='textbox'>
Edit this image: <img src="fakeimage.png" alt="my fake image"> Edit this image: <img src="fakeimage.png" alt="my fake image">
</div>`); </div>`);
const golden = options.FFOX ? { const golden = options.FIREFOX() ? {
role: 'textbox', role: 'textbox',
name: '', name: '',
value: 'Edit this image: my fake image', 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); 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". // Firefox does not support contenteditable="plaintext-only".
// WebKit rich text accessibility is iffy // WebKit rich text accessibility is iffy
await page.setContent(` 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(` await page.setContent(`
<div contenteditable="plaintext-only">Edit this image:<img src="fakeimage.png" alt="my fake image"></div>`); <div contenteditable="plaintext-only">Edit this image:<img src="fakeimage.png" alt="my fake image"></div>`);
const snapshot = await page.accessibility.snapshot(); 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(` await page.setContent(`
<div contenteditable="plaintext-only" tabIndex=0>Edit this image:<img src="fakeimage.png" alt="my fake image"></div>`); <div contenteditable="plaintext-only" tabIndex=0>Edit this image:<img src="fakeimage.png" alt="my fake image"></div>`);
const snapshot = await page.accessibility.snapshot(); 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 this is the inner content
<img alt="yo" src="fakeimg.png"> <img alt="yo" src="fakeimg.png">
</div>`); </div>`);
const golden = options.FFOX ? { const golden = options.FIREFOX() ? {
role: 'textbox', role: 'textbox',
name: 'my favorite textbox', name: 'my favorite textbox',
value: 'this is the inner content yo' value: 'this is the inner content yo'
} : options.CHROMIUM ? { } : options.CHROMIUM() ? {
role: 'textbox', role: 'textbox',
name: 'my favorite textbox', name: 'my favorite textbox',
value: 'this is the inner content ' 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 this is the inner content
<img alt="yo" src="fakeimg.png"> <img alt="yo" src="fakeimg.png">
</div>`); </div>`);
const golden = options.FFOX ? { const golden = options.FIREFOX() ? {
role: 'checkbox', role: 'checkbox',
name: 'this is the inner content yo', name: 'this is the inner content yo',
checked: true checked: true
@ -327,7 +327,7 @@ it('should work on a menu', async({page}) => {
[ { role: 'menuitem', name: 'First Item' }, [ { role: 'menuitem', name: 'First Item' },
{ role: 'menuitem', name: 'Second Item' }, { role: 'menuitem', name: 'Second Item' },
{ role: 'menuitem', name: 'Third Item' } ], { role: 'menuitem', name: 'Third Item' } ],
orientation: options.WEBKIT ? 'vertical' : undefined orientation: options.WEBKIT() ? 'vertical' : undefined
}); });
}); });

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
it('should await navigation when clicking anchor', async({page, server}) => { it('should await navigation when clicking anchor', async({page, server}) => {
const messages = []; const messages = [];

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './playwright.fixtures';
it('clicking on links which do not commit navigation', async({page, server, httpsServer}) => { it('clicking on links which do not commit navigation', async({page, server, httpsServer}) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
it('should create new page', async function({browser}) { it('should create new page', async function({browser}) {
const page1 = await browser.newPage(); 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}) { it('version should work', async function({browser}) {
const version = browser.version(); const version = browser.version();
if (options.CHROMIUM) if (options.CHROMIUM())
expect(version.match(/^\d+\.\d+\.\d+\.\d+$/)).toBeTruthy(); expect(version.match(/^\d+\.\d+\.\d+\.\d+$/)).toBeTruthy();
else else
expect(version.match(/^\d+\.\d+/)).toBeTruthy(); expect(version.match(/^\d+\.\d+/)).toBeTruthy();

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
it('should work', async({context, page, server}) => { it('should work', async({context, page, server}) => {
await page.goto(server.EMPTY_PAGE); await 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'); }, server.CROSS_PROCESS_PREFIX + '/grid.html');
await page.frames()[1].evaluate(`document.cookie = 'username=John Doe'`); await page.frames()[1].evaluate(`document.cookie = 'username=John Doe'`);
await page.waitForTimeout(2000); 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'); const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) { if (allowsThirdParty) {
expect(cookies).toEqual([ expect(cookies).toEqual([

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import utils from './utils'; 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>'); await page.goto('data:text/html, <script>var something = "forbidden"</script>');
let error = null; let error = null;
await page.evaluate('something').catch(e => error = e); await page.evaluate('something').catch(e => error = e);
if (options.WEBKIT) if (options.WEBKIT())
expect(error.message).toContain('Can\'t find variable: something'); expect(error.message).toContain('Can\'t find variable: something');
else else
expect(error.message).toContain('something is not defined'); expect(error.message).toContain('something is not defined');

View file

@ -14,9 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import utils from './utils'; import './playwright.fixtures';
it('should clear cookies', async({context, page, server}) => { it('should clear cookies', async({context, page, server}) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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}) => { it('should return no cookies in pristine browser context', async({context, page, server}) => {
expect(await context.cookies()).toEqual([]); 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); 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) => { server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', 'name=value;SameSite=Strict'); res.setHeader('Set-Cookie', 'name=value;SameSite=Strict');
res.end(); res.end();
@ -83,7 +83,7 @@ it.fail(options.WEBKIT && WIN)('should properly report "Strict" sameSite cookie'
expect(cookies[0].sameSite).toBe('Strict'); 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) => { server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', 'name=value;SameSite=Lax'); res.setHeader('Set-Cookie', 'name=value;SameSite=Lax');
res.end(); res.end();

View file

@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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'); server.setAuth('/empty.html', 'user', 'pass');
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();
@ -25,7 +25,7 @@ it.fail(options.CHROMIUM && !options.HEADLESS)('should fail without credentials'
await context.close(); 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'); server.setAuth('/empty.html', 'user', 'pass');
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();
@ -48,7 +48,7 @@ it('should work with correct credentials', async({browser, server}) => {
await context.close(); 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'); server.setAuth('/empty.html', 'user', 'pass');
const context = await browser.newContext({ const context = await browser.newContext({
httpCredentials: { username: 'foo', password: 'bar' } httpCredentials: { username: 'foo', password: 'bar' }

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './playwright.fixtures';
import * as utils from './utils'; import * as utils from './utils';

View file

@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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 iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone }); const context = await browser.newContext({ ...iPhone });
const page = await context.newPage(); const page = await context.newPage();
@ -26,7 +26,7 @@ it.skip(options.FFOX)('should work', async({playwright, browser, server}) => {
await context.close(); 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 iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone }); const context = await browser.newContext({ ...iPhone });
const page = await context.newPage(); const page = await context.newPage();
@ -38,7 +38,7 @@ it.skip(options.FFOX)('should support clicking', async({playwright, browser, ser
await context.close(); 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({ const context = await browser.newContext({
viewport: { viewport: {
width: 400, width: 400,

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './playwright.fixtures';
it('expose binding should work', async({browser}) => { it('expose binding should work', async({browser}) => {
const context = await browser.newContext(); const context = await browser.newContext();

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
it('should affect accept-language header', async({browser, server}) => { it('should affect accept-language header', async({browser, server}) => {
const context = await browser.newContext({ locale: 'fr-CH' }); const 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) { async function getContextLocale(context) {
const page = await context.newPage(); const page = await context.newPage();
return await page.evaluate(() => (new Intl.NumberFormat()).resolvedOptions().locale); return await page.evaluate(() => (new Intl.NumberFormat()).resolvedOptions().locale);

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
it('should have url', async({browser, server}) => { it('should have url', async({browser, server}) => {
const context = await browser.newContext(); const context = await browser.newContext();
@ -156,7 +156,7 @@ it('should fire page lifecycle events', async function({browser, server}) {
await context.close(); 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. // WebKit: Shift+Click does not open a new window.
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();
@ -170,7 +170,7 @@ it.fail(options.WEBKIT)('should work with Shift-clicking', async({browser, serve
await context.close(); 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. // Firefox: reports an opener in this case.
// WebKit: Ctrl+Click does not open a new tab. // WebKit: Ctrl+Click does not open a new tab.
const context = await browser.newContext(); const context = await browser.newContext();

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './playwright.fixtures';
it('should intercept', async({browser, server}) => { it('should intercept', async({browser, server}) => {
const context = await browser.newContext(); const context = await browser.newContext();

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
it('should work', async ({ browser }) => { it('should work', async ({ browser }) => {
const func = () => new Date(1479579154987).toString(); 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(); 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) { async function getContextTimezone(context) {
const page = await context.newPage(); const page = await context.newPage();
return await page.evaluate(() => Intl.DateTimeFormat().resolvedOptions().timeZone); return await page.evaluate(() => Intl.DateTimeFormat().resolvedOptions().timeZone);

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './playwright.fixtures';
import utils from './utils'; import utils from './utils';
const {devices} = require('..'); const {devices} = require('..');

View file

@ -15,9 +15,9 @@
* limitations under the License. * 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 iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone }); const context = await browser.newContext({ ...iPhone });
const page = await context.newPage(); const page = await context.newPage();
@ -28,7 +28,7 @@ it.skip(options.FFOX)('should support mobile emulation', async({playwright, brow
await context.close(); 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 iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone }); const context = await browser.newContext({ ...iPhone });
const page = await context.newPage(); 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 iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone }); const context = await browser.newContext({ ...iPhone });
const page = await context.newPage(); const page = await context.newPage();
@ -60,7 +60,7 @@ it.skip(options.FFOX)('should be detectable by Modernizr', async({playwright, br
await context.close(); 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 context = await browser.newContext({ viewport: { width: 800, height: 600 }, hasTouch: true });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.EMPTY_PAGE); 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(); 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 iPhone = playwright.devices['iPhone 6'];
const iPhoneLandscape = playwright.devices['iPhone 6 landscape']; const iPhoneLandscape = playwright.devices['iPhone 6 landscape'];
const context1 = await browser.newContext({ ...iPhone }); const context1 = await browser.newContext({ ...iPhone });
@ -83,7 +83,7 @@ it.skip(options.FFOX)('should support landscape emulation', async({playwright, b
await context2.close(); 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 context = await browser.newContext({ viewport: { width: 300, height: 400 }, isMobile: true });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/mobile.html'); 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(); 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 context = await browser.newContext({ viewport: { width: 300, height: 400 }, isMobile: true });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/mobile.html'); 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(); 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 context = await browser.newContext({ viewport: {width: 320, height: 480 }, isMobile: true });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/empty.html'); 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(); 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 context = await browser.newContext({ viewport: {width: 320, height: 480 }, isMobile: true });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/mobile.html'); await page.goto(server.PREFIX + '/mobile.html');

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './playwright.fixtures';
import utils from './utils'; import utils from './utils';

View file

@ -16,7 +16,7 @@
*/ */
import fs from 'fs'; 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}) => { it.skip(Boolean(process.env.CRPATH || process.env.FFPATH || process.env.WKPATH))('browserType.executablePath should work', async({browserType}) => {
const executablePath = browserType.executablePath(); 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}) => { it('browserType.name should work', async({browserType}) => {
if (options.WEBKIT) if (options.WEBKIT())
expect(browserType.name()).toBe('webkit'); expect(browserType.name()).toBe('webkit');
else if (options.FFOX) else if (options.FIREFOX())
expect(browserType.name()).toBe('firefox'); expect(browserType.name()).toBe('firefox');
else if (options.CHROMIUM) else if (options.CHROMIUM())
expect(browserType.name()).toBe('chromium'); expect(browserType.name()).toBe('chromium');
else else
throw new Error('Unknown browser'); throw new Error('Unknown browser');

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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}) => { it.skip(options.WIRE).slow()('should be able to reconnect to a browser', async({browserType, defaultBrowserOptions, server}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); 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(); 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 browserServer = await browserType.launchServer(defaultBrowserOptions);
const __testHookBeforeCreateBrowser = () => { throw new Error('Dummy') }; const __testHookBeforeCreateBrowser = () => { throw new Error('Dummy') };
const error = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint(), __testHookBeforeCreateBrowser } as any).catch(e => e); const error = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint(), __testHookBeforeCreateBrowser } as any).catch(e => e);

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it.skip(options.WIRE)('should work', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should work', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);

View file

@ -16,8 +16,7 @@
*/ */
import path from 'path'; import path from 'path';
import './base.fixture'; import { options } from './playwright.fixtures';
it('should reject all promises when browser is closed', async({browserType, defaultBrowserOptions}) => { it('should reject all promises when browser is closed', async({browserType, defaultBrowserOptions}) => {
const browser = await browserType.launch(defaultBrowserOptions); const 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'); 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; let waitError = null;
const options = Object.assign({}, defaultBrowserOptions, { args: ['http://example.com'] }); const options = Object.assign({}, defaultBrowserOptions, { args: ['http://example.com'] });
await browserType.launch(options).catch(e => waitError = e); await browserType.launch(options).catch(e => waitError = e);

View file

@ -15,9 +15,9 @@
*/ */
import url from 'url'; 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'); await page.goto(server.PREFIX + '/wasm/table2.html');
expect(await page.evaluate('loadTable()')).toBe('42, 83'); 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'); 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, // TODO: the test passes on Windows locally but fails on GitHub Action bot,
// apparently due to a Media Pack issue in the Windows Server. // apparently due to a Media Pack issue in the Windows Server.
// Also the test is very flaky on Linux WebKit. // Also the test is very flaky on Linux WebKit.
// //
// Safari only plays mp4 so we test WebKit with an .mp4 clip. // 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); const absolutePath = asset(fileName);
// Our test server doesn't support range requests required to play on Mac, // Our test server doesn't support range requests required to play on Mac,
// so we load the page using a file url. // so we load the page using a file url.

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import { ChromiumBrowser } from '..'; import { ChromiumBrowser } from '..';
it('should work', async({browser}) => { it('should work', async({browser}) => {
@ -65,7 +65,7 @@ it('should scope context handles', async({browserType, browser, server}) => {
await expectScopeState(browser, GOLDEN_PRECONDITION); 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 = { const GOLDEN_PRECONDITION = {
_guid: '', _guid: '',
objects: [ objects: [

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './playwright.fixtures';
it('should check the box', async({page}) => { it('should check the box', async({page}) => {
await page.setContent(`<input id='checkbox' type='checkbox'></input>`); await page.setContent(`<input id='checkbox' type='checkbox'></input>`);

View file

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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.coverage.startCSSCoverage();
await page.goto(server.PREFIX + '/csscoverage/simple.html'); await page.goto(server.PREFIX + '/csscoverage/simple.html');
const coverage = await page.coverage.stopCSSCoverage(); 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; }'); 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.coverage.startCSSCoverage();
await page.goto(server.PREFIX + '/csscoverage/sourceurl.html'); await page.goto(server.PREFIX + '/csscoverage/sourceurl.html');
const coverage = await page.coverage.stopCSSCoverage(); 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'); 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.coverage.startCSSCoverage();
await page.goto(server.PREFIX + '/csscoverage/multiple.html'); await page.goto(server.PREFIX + '/csscoverage/multiple.html');
const coverage = await page.coverage.stopCSSCoverage(); 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'); 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.coverage.startCSSCoverage();
await page.goto(server.PREFIX + '/csscoverage/unused.html'); await page.goto(server.PREFIX + '/csscoverage/unused.html');
const coverage = await page.coverage.stopCSSCoverage(); 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); 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.coverage.startCSSCoverage();
await page.goto(server.PREFIX + '/csscoverage/media.html'); await page.goto(server.PREFIX + '/csscoverage/media.html');
const coverage = await page.coverage.stopCSSCoverage(); 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.coverage.startCSSCoverage();
await page.goto(server.PREFIX + '/csscoverage/involved.html'); await page.goto(server.PREFIX + '/csscoverage/involved.html');
const coverage: any = await page.coverage.stopCSSCoverage(); 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.coverage.startCSSCoverage();
await page.addStyleTag({content: 'body { margin: 10px;}'}); await page.addStyleTag({content: 'body { margin: 10px;}'});
// trigger style recalc // trigger style recalc
@ -100,7 +100,7 @@ it.skip(!options.CHROMIUM)('should ignore injected stylesheets', async function(
expect(coverage.length).toBe(0); 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.coverage.startCSSCoverage({resetOnNavigation: false});
await page.goto(server.PREFIX + '/csscoverage/multiple.html'); await page.goto(server.PREFIX + '/csscoverage/multiple.html');
await page.goto(server.EMPTY_PAGE); 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); 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.coverage.startCSSCoverage(); // Enabled by default.
await page.goto(server.PREFIX + '/csscoverage/multiple.html'); await page.goto(server.PREFIX + '/csscoverage/multiple.html');
await page.goto(server.EMPTY_PAGE); 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); 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.coverage.startCSSCoverage();
await page.evaluate(async url => { await page.evaluate(async url => {
document.body.textContent = 'hello, world'; document.body.textContent = 'hello, world';

View file

@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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); 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.coverage.startJSCoverage();
await page.goto(server.PREFIX + '/jscoverage/simple.html', { waitUntil: 'load' }); await page.goto(server.PREFIX + '/jscoverage/simple.html', { waitUntil: 'load' });
const coverage = await page.coverage.stopJSCoverage(); 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); 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.coverage.startJSCoverage();
await page.goto(server.PREFIX + '/jscoverage/sourceurl.html'); await page.goto(server.PREFIX + '/jscoverage/sourceurl.html');
const coverage = await page.coverage.stopJSCoverage(); 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'); 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.coverage.startJSCoverage();
await page.goto(server.PREFIX + '/jscoverage/eval.html'); await page.goto(server.PREFIX + '/jscoverage/eval.html');
const coverage = await page.coverage.stopJSCoverage(); const coverage = await page.coverage.stopJSCoverage();
expect(coverage.length).toBe(1); 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.coverage.startJSCoverage({reportAnonymousScripts: true});
await page.goto(server.PREFIX + '/jscoverage/eval.html'); await page.goto(server.PREFIX + '/jscoverage/eval.html');
const coverage = await page.coverage.stopJSCoverage(); 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); 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.coverage.startJSCoverage({reportAnonymousScripts: true});
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await page.evaluate('console.log("foo")'); 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); 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.coverage.startJSCoverage();
await page.goto(server.PREFIX + '/jscoverage/multiple.html'); await page.goto(server.PREFIX + '/jscoverage/multiple.html');
const coverage = await page.coverage.stopJSCoverage(); 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'); 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.coverage.startJSCoverage({resetOnNavigation: false});
await page.goto(server.PREFIX + '/jscoverage/multiple.html'); await page.goto(server.PREFIX + '/jscoverage/multiple.html');
await page.goto(server.EMPTY_PAGE); 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); 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.coverage.startJSCoverage(); // Enabled by default.
await page.goto(server.PREFIX + '/jscoverage/multiple.html'); await page.goto(server.PREFIX + '/jscoverage/multiple.html');
await page.goto(server.EMPTY_PAGE); 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); 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.coverage.startJSCoverage();
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await page.evaluate(() => { await page.evaluate(() => {

View file

@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import '../base.fixture'; import { options } from '../playwright.fixtures';
import { ChromiumBrowserContext } from '../..'; 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([ const [worker] = await Promise.all([
(context as ChromiumBrowserContext).waitForEvent('serviceworker'), (context as ChromiumBrowserContext).waitForEvent('serviceworker'),
page.goto(server.PREFIX + '/serviceworkers/empty/sw.html') 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]'); 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([ const [worker1] = await Promise.all([
(context as ChromiumBrowserContext).waitForEvent('serviceworker'), (context as ChromiumBrowserContext).waitForEvent('serviceworker'),
page.goto(server.PREFIX + '/serviceworkers/empty/sw.html') 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); 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); await page.goto(server.EMPTY_PAGE);
let serviceWorkerCreated; let serviceWorkerCreated;
(context as ChromiumBrowserContext).once('serviceworker', () => serviceWorkerCreated = true); (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(); 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 context = await browser.newContext() as ChromiumBrowserContext;
const page = await context.newPage(); const page = await context.newPage();
const [worker] = await Promise.all([ 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'); 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(` server.setRoute('/intervention', (req, res) => res.end(`
<script> <script>
document.write('<script src="${server.CROSS_PROCESS_PREFIX}/intervention.js">' + '</scr' + 'ipt>'); document.write('<script src="${server.CROSS_PROCESS_PREFIX}/intervention.js">' + '</scr' + 'ipt>');

View file

@ -13,28 +13,28 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import '../base.fixture'; import { options } from '../playwright.fixtures';
import path from 'path'; import path from 'path';
import utils from '../utils'; import utils from '../utils';
import { ChromiumBrowser, ChromiumBrowserContext } from '../..'; import { ChromiumBrowser, ChromiumBrowserContext } from '../..';
const { makeUserDataDir, removeUserDataDir } = utils; 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); const options = Object.assign({}, defaultBrowserOptions);
options.args = ['--remote-debugging-pipe'].concat(options.args || []); options.args = ['--remote-debugging-pipe'].concat(options.args || []);
const error = await browserType.launchServer(options).catch(e => e); const error = await browserType.launchServer(options).catch(e => e);
expect(error.message).toContain('Playwright manages remote debugging connection itself'); 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); const options = Object.assign({}, defaultBrowserOptions);
options.args = ['--remote-debugging-port=0'].concat(options.args || []); options.args = ['--remote-debugging-port=0'].concat(options.args || []);
const browser = await browserType.launchServer(options); const browser = await browserType.launchServer(options);
await browser.close(); 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; let devtoolsCallback;
const devtoolsPromise = new Promise(f => devtoolsCallback = f); const devtoolsPromise = new Promise(f => devtoolsCallback = f);
const __testHookForDevTools = devtools => devtools.__testHookOnBinding = parsed => { 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(); 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 userDataDir = await makeUserDataDir();
const extensionPath = path.join(__dirname, '..', 'assets', 'simple-extension'); const extensionPath = path.join(__dirname, '..', 'assets', 'simple-extension');
const extensionOptions = {...defaultBrowserOptions, const extensionOptions = {...defaultBrowserOptions,
@ -72,7 +72,7 @@ it.skip(!options.CHROMIUM)('should return background pages', async({browserType,
await removeUserDataDir(userDataDir); 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 browser = await browserType.launch(defaultBrowserOptions);
const browserSession = await (browser as ChromiumBrowser).newBrowserCDPSession(); const browserSession = await (browser as ChromiumBrowser).newBrowserCDPSession();
const targets = []; const targets = [];

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import '../base.fixture'; import { options } from '../playwright.fixtures';
import { registerWorkerFixture } from '../runner'; import { registerWorkerFixture } from '../runner';
registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => { registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => {
@ -26,14 +26,14 @@ registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, te
await browser.close(); 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'); await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(await countOOPIFs(browser)).toBe(1); expect(await countOOPIFs(browser)).toBe(1);
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);
expect(await page.frames()[1].evaluate(() => '' + location.href)).toBe(server.CROSS_PROCESS_PREFIX + '/grid.html'); 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'); await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(await countOOPIFs(browser)).toBe(1); expect(await countOOPIFs(browser)).toBe(1);
expect(page.frames().length).toBe(2); 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); 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'); await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1); 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); 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'); await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1); 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); 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'); await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1); 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); 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'); await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1); 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); 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 iPhone = playwright.devices['iPhone 6']
const context = await browser.newContext({ ...iPhone, timezoneId: 'America/Jamaica', locale: 'fr-CH', userAgent: 'UA' }); const context = await browser.newContext({ ...iPhone, timezoneId: 'America/Jamaica', locale: 'fr-CH', userAgent: 'UA' });
const page = await context.newPage(); const page = await context.newPage();
@ -138,7 +138,7 @@ it.skip(!options.CHROMIUM)('should support context options', async({browser, ser
await context.close(); 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; let intercepted = false;
await page.route('**/digits/0.png', route => { await page.route('**/digits/0.png', route => {
intercepted = true; intercepted = true;
@ -150,7 +150,7 @@ it.skip(!options.CHROMIUM)('should respect route', async({browser, page, server}
expect(intercepted).toBe(true); 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.setViewportSize({width: 500, height: 500});
await page.goto(server.PREFIX + '/dynamic-oopif.html'); await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2); 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 }); 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.route('**/*', route => route.continue());
await page.goto(server.PREFIX + '/dynamic-oopif.html'); await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(await countOOPIFs(browser)).toBe(1); 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 = []; const requestFrames = [];
page.on('request', r => requestFrames.push(r.frame())); page.on('request', r => requestFrames.push(r.frame()));
const finishedFrames = []; const finishedFrames = [];
@ -202,7 +202,7 @@ it.skip(!options.CHROMIUM)('should report main requests', async function({browse
expect(finishedFrames[2]).toBe(grandChild); 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 context.exposeFunction('dec', a => a - 1);
await page.exposeFunction('inc', a => a + 1); await page.exposeFunction('inc', a => a + 1);
await page.goto(server.PREFIX + '/dynamic-oopif.html'); 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); 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 context.addInitScript(() => window['bar'] = 17);
await page.addInitScript(() => window['foo'] = 42); await page.addInitScript(() => window['foo'] = 42);
await page.goto(server.PREFIX + '/dynamic-oopif.html'); 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); expect(await page.frames()[1].evaluate(() => window['bar'])).toBe(17);
}); });
// @see https://github.com/microsoft/playwright/issues/1240 // @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'); await page.goto(server.PREFIX + '/button-overlay-oopif.html');
expect(await countOOPIFs(browser)).toBe(1); expect(await countOOPIFs(browser)).toBe(1);
await page.click('button'); await page.click('button');
expect(await page.evaluate(() => window['BUTTON_CLICKED'])).toBe(true); 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 // @see https://github.com/GoogleChrome/puppeteer/issues/2548
// https://google.com is isolated by default in Chromium embedder. // https://google.com is isolated by default in Chromium embedder.
const browser = await browserType.launch({...defaultBrowserOptions, headless: false}); 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(); 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.goto(server.PREFIX + '/dynamic-oopif.html');
await page.$eval('iframe', iframe => { await page.$eval('iframe', iframe => {
iframe.style.width = '500px'; 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 }); 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.goto(server.PREFIX + '/dynamic-oopif.html');
await page.$eval('iframe', iframe => { await page.$eval('iframe', iframe => {
iframe.style.width = '500px'; iframe.style.width = '500px';

View file

@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import '../base.fixture'; import { options } from '../playwright.fixtures';
import { ChromiumBrowserContext, ChromiumBrowser } from "../../types/types"; 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); const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
await Promise.all([ await Promise.all([
@ -27,7 +27,7 @@ it.skip(!options.CHROMIUM)('should work', async function({page}) {
expect(foo).toBe('bar'); 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); const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
await client.send('Network.enable'); await client.send('Network.enable');
const events = []; const events = [];
@ -36,12 +36,12 @@ it.skip(!options.CHROMIUM)('should send events', async function({page, server})
expect(events.length).toBe(1); 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); const error = await (page.context() as ChromiumBrowserContext).newCDPSession(page.context() as any).catch(e => e);
expect(error.message).toContain('page: expected Page'); 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); const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
await client.send('Runtime.enable'); await client.send('Runtime.enable');
await client.send('Debugger.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); const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
await client.send('Runtime.enable'); await client.send('Runtime.enable');
const evalResponse = await client.send('Runtime.evaluate', {expression: '1 + 2', returnByValue: true}); 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'); 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 client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);
const error = await theSourceOfTheProblems().catch(error => error); const error = await theSourceOfTheProblems().catch(error => error);
expect(error.stack).toContain('theSourceOfTheProblems'); 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 context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();
const session = await (page.context() as ChromiumBrowserContext).newCDPSession(page); 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(); 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 context = await browser.newContext() as ChromiumBrowserContext;
const page = await context.newPage(); const page = await context.newPage();
const session = await context.newCDPSession(page); 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(); 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 session = await (browser as ChromiumBrowser).newBrowserCDPSession();
const version = await session.send('Browser.getVersion'); const version = await session.send('Browser.getVersion');

View file

@ -14,8 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import '../runner/builtin.fixtures'; import { options } from '../playwright.fixtures';
import '../base.fixture';
import { registerFixture } from '../runner'; import { registerFixture } from '../runner';
import fs from 'fs'; import fs from 'fs';
@ -35,14 +34,14 @@ registerFixture('outputFile', async ({tmpDir}, test) => {
fs.unlinkSync(outputFile); 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 (browser as ChromiumBrowser).startTracing(page, {screenshots: true, path: outputFile});
await page.goto(server.PREFIX + '/grid.html'); await page.goto(server.PREFIX + '/grid.html');
await (browser as ChromiumBrowser).stopTracing(); await (browser as ChromiumBrowser).stopTracing();
expect(fs.existsSync(outputFile)).toBe(true); 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'); const filePath = path.join(tmpDir, 'these', 'are', 'directories');
await (browser as ChromiumBrowser).startTracing(page, {screenshots: true, path: filePath}); await (browser as ChromiumBrowser).startTracing(page, {screenshots: true, path: filePath});
await page.goto(server.PREFIX + '/grid.html'); 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); 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).startTracing(page, {path: outputFile, categories: ['disabled-by-default-v8.cpu_profiler.hires']});
await (browser as ChromiumBrowser).stopTracing(); 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'); 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}); await (browser as ChromiumBrowser).startTracing(page, {path: outputFile});
const newPage = await browser.newPage(); const newPage = await browser.newPage();
let error = null; 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(); 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 (browser as ChromiumBrowser).startTracing(page, {screenshots: true, path: outputFile});
await page.goto(server.PREFIX + '/grid.html'); await page.goto(server.PREFIX + '/grid.html');
const trace = await (browser as ChromiumBrowser).stopTracing(); 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()); 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 (browser as ChromiumBrowser).startTracing(page);
await page.goto(server.PREFIX + '/grid.html'); await page.goto(server.PREFIX + '/grid.html');
const trace = await (browser as ChromiumBrowser).stopTracing(); const trace = await (browser as ChromiumBrowser).stopTracing();
expect(trace).toBeTruthy(); 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 (browser as ChromiumBrowser).startTracing(page, {screenshots: true});
await page.goto(server.PREFIX + '/grid.html'); await page.goto(server.PREFIX + '/grid.html');
const trace = await (browser as ChromiumBrowser).stopTracing(); const trace = await (browser as ChromiumBrowser).stopTracing();

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './playwright.fixtures';
declare const renderComponent; declare const renderComponent;
declare const e; declare const e;

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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}) => { it.skip(options.WIRE)('should avoid side effects after timeout', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should timeout waiting for display:none to be gone', async({page, server}) => { it('should timeout waiting for display:none to be gone', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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}) => { it.skip(options.WIRE)('should fail when element jumps during hit testing', async({page, server}) => {
await page.setContent('<button>Click me</button>'); await page.setContent('<button>Click me</button>');

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should timeout waiting for stable position', async({page, server}) => { it('should timeout waiting for stable position', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');

View file

@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import utils from './utils';
import { options } from './playwright.fixtures';
import utils from './utils';
async function giveItAChanceToClick(page) { async function giveItAChanceToClick(page) {
for (let i = 0; i < 5; i++) 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'); 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://github.com/GoogleChrome/puppeteer/issues/4110
// @see https://bugs.chromium.org/p/chromium/issues/detail?id=986390 // @see https://bugs.chromium.org/p/chromium/issues/detail?id=986390
// @see https://chromium-review.googlesource.com/c/chromium/src/+/1742784 // @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 } }); await page.click('button', { position: { x: 20, y: 10 } });
expect(await page.evaluate('result')).toBe('Clicked'); expect(await page.evaluate('result')).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY. // Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 20 + 8 : 20); 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('offsetY')).toBe(options.WEBKIT() ? 10 + 8 : 10);
}); });
it('should click the button with em border with offset', async({page, server}) => { 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 } }); await page.click('button', { position: { x: 20, y: 10 } });
expect(await page.evaluate('result')).toBe('Clicked'); expect(await page.evaluate('result')).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY. // Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 12 * 2 + 20 : 20); 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('offsetY')).toBe(options.WEBKIT() ? 12 * 2 + 10 : 10);
}); });
it('should click a very large button with offset', async({page, server}) => { 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 } }); await page.click('button', { position: { x: 1900, y: 1910 } });
expect(await page.evaluate(() => window['result'])).toBe('Clicked'); expect(await page.evaluate(() => window['result'])).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY. // Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 1900 + 8 : 1900); 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('offsetY')).toBe(options.WEBKIT() ? 1910 + 8 : 1910);
}); });
it('should click a button in scrolling container with offset', async({page, server}) => { 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 } }); await page.click('button', { position: { x: 1900, y: 1910 } });
expect(await page.evaluate(() => window['result'])).toBe('Clicked'); expect(await page.evaluate(() => window['result'])).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY. // Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 1900 + 8 : 1900); 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('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 context = await browser.newContext({ viewport: { width: 400, height: 400 }, isMobile: true });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/input/button.html'); 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'); expect(await page.evaluate('result')).toBe('Clicked');
const round = x => Math.round(x + 0.01); const round = x => Math.round(x + 0.01);
let expected = { x: 28, y: 18 }; // 20;10 + 8px of border in each direction 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. // WebKit rounds up during css -> dip -> css conversion.
expected = { x: 29, y: 19 }; 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. // Headless Chromium rounds down during css -> dip -> css conversion.
expected = { x: 27, y: 18 }; expected = { x: 27, y: 18 };
} }

View file

@ -15,8 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import './runner/builtin.fixtures'; import { options } from './playwright.fixtures';
import './base.fixture';
import { registerFixture } from './runner'; import { registerFixture } from './runner';
import fs from 'fs'; import fs from 'fs';
import utils from './utils'; import utils from './utils';
@ -120,7 +119,7 @@ it('should(not) block third party cookies', async ({server, launchPersistent}) =
return document.cookie; return document.cookie;
}); });
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
const allowsThirdParty = options.CHROMIUM || options.FFOX; const allowsThirdParty = options.CHROMIUM() || options.FIREFOX();
expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : ''); expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : '');
const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html'); const cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) { if (allowsThirdParty) {
@ -175,7 +174,7 @@ it('should support javascriptEnabled option', async ({launchPersistent}) => {
await page.goto('data:text/html, <script>var something = "forbidden"</script>'); await page.goto('data:text/html, <script>var something = "forbidden"</script>');
let error = null; let error = null;
await page.evaluate('something').catch(e => error = e); await page.evaluate('something').catch(e => error = e);
if (options.WEBKIT) if (options.WEBKIT())
expect(error.message).toContain('Can\'t find variable: something'); expect(error.message).toContain('Can\'t find variable: something');
else else
expect(error.message).toContain('something is not defined'); 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); 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. // Firefox does not support mobile.
const {page, context} = await launchPersistent({viewport: {width: 320, height: 480}, isMobile: true}); const {page, context} = await launchPersistent({viewport: {width: 320, height: 480}, isMobile: true});
await page.goto(server.PREFIX + '/empty.html'); await page.goto(server.PREFIX + '/empty.html');
@ -303,7 +302,7 @@ it.slow()('should restore state from userDataDir', async({browserType, defaultBr
await removeUserDataDir(userDataDir2); 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 userDataDir = await makeUserDataDir();
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions); const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
const page = await browserContext.newPage(); const page = await browserContext.newPage();
@ -339,7 +338,7 @@ it('should have default URL when launching browser', async ({launchPersistent})
expect(urls).toEqual(['about:blank']); 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 options = {...defaultBrowserOptions, args: [server.EMPTY_PAGE] };
const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e); const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e);
expect(error.message).toContain('can not specify page'); 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); 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(); const {page, context} = await launchPersistent();
await page.coverage.startJSCoverage(); await page.coverage.startJSCoverage();
await page.goto(server.PREFIX + '/jscoverage/simple.html', { waitUntil: 'load' }); 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); 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(); const {page, context} = await launchPersistent();
expect(page.coverage).toBe(null); expect(page.coverage).toBe(null);
}); });

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it('should fire', async({page, server}) => { it('should fire', async({page, server}) => {
page.on('dialog', dialog => { page.on('dialog', dialog => {
@ -61,7 +62,7 @@ it('should dismiss the confirm prompt', async({page}) => {
expect(result).toBe(false); 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 context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();
const alertPromise = page.waitForEvent('dialog'); const alertPromise = page.waitForEvent('dialog');

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import utils from './utils'; import utils from './utils';
@ -126,7 +126,7 @@ it('should be atomic', async({playwright, page}) => {
expect(await page.evaluate(() => window['_clicked'])).toBe(true); 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'); await page.goto(server.PREFIX + '/drag-n-drop.html');
const dataTransfer = await page.evaluateHandle(() => new DataTransfer()); const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
await page.dispatchEvent('#source', 'dragstart', { 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(); }, {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'); await page.goto(server.PREFIX + '/drag-n-drop.html');
const dataTransfer = await page.evaluateHandle(() => new DataTransfer()); const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
const source = await page.$('#source'); const source = await page.$('#source');

View file

@ -14,8 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import './runner/builtin.fixtures'; import { options } from './playwright.fixtures';
import './base.fixture';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; 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'); expect(fs.readFileSync(path).toString()).toBe('Hello world');
await page.close(); 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. // Firefox does not download on alt-click by default.
// Our WebKit embedder does not download on alt-click, although Safari does. // Our WebKit embedder does not download on alt-click, although Safari does.
server.setRoute('/download', (req, res) => { server.setRoute('/download', (req, res) => {
@ -239,7 +238,7 @@ it.fail(options.FFOX || options.WEBKIT)('should report alt-click downloads', asy
await page.close(); 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 // TODO: - the test fails in headful Chromium as the popup page gets closed along
// with the session before download completed event arrives. // with the session before download completed event arrives.
// - WebKit doesn't close the popup page // - WebKit doesn't close the popup page

View file

@ -15,8 +15,7 @@
*/ */
import './runner/builtin.fixtures'; import './playwright.fixtures';
import './base.fixture';
import { registerFixture } from './runner'; import { registerFixture } from './runner';

View file

@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { options } from '../playwright.fixtures';
import './electron.fixture'; import './electron.fixture';
import path from 'path'; import path from 'path';
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron'; 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 electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName);
const application = await playwright.electron.launch(electronPath, { const application = await playwright.electron.launch(electronPath, {
args: [path.join(__dirname, 'testApp.js')], 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'); 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()); const appPath = await application.evaluate(async ({ app }) => app.getAppPath());
expect(appPath).toContain('electron'); 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([ const [ page ] = await Promise.all([
application.waitForEvent('window'), application.waitForEvent('window'),
application.evaluate(({ BrowserWindow }) => { application.evaluate(({ BrowserWindow }) => {
@ -51,13 +53,13 @@ it.skip(!options.CHROMIUM)('should create window', async ({ application }) => {
expect(await page.title()).toBe('Hello World 1'); 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 }); const page = await application.newBrowserWindow({ width: 800, height: 600 });
await page.goto('data:text/html,<title>Hello World 2</title>'); await page.goto('data:text/html,<title>Hello World 2</title>');
expect(await page.title()).toBe('Hello World 2'); 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 createPage = async ordinal => {
const page = await application.newBrowserWindow({ width: 800, height: 600 }); const page = await application.newBrowserWindow({ width: 800, height: 600 });
await Promise.all([ 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']); 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) => { await application.context().route('**/empty.html', (route, request) => {
route.fulfill({ route.fulfill({
status: 200, status: 200,
@ -91,14 +93,14 @@ it.skip(!options.CHROMIUM)('should route network', async ({ application }) => {
expect(await page.title()).toBe('Hello World'); 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;') await application.context().addInitScript('window.magic = 42;')
const page = await application.newBrowserWindow({ width: 800, height: 600 }); const page = await application.newBrowserWindow({ width: 800, height: 600 });
await page.goto('data:text/html,<script>window.copy = magic</script>'); await page.goto('data:text/html,<script>window.copy = magic</script>');
expect(await page.evaluate(() => window['copy'])).toBe(42); 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(); const t = Date.now();
await application.context().exposeFunction('add', (a, b) => a + b); await application.context().exposeFunction('add', (a, b) => a + b);
const page = await application.newBrowserWindow({ width: 800, height: 600 }); 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); 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 }) => { application.evaluate(({ BrowserWindow }) => {
const window = new BrowserWindow({ width: 800, height: 600 }); const window = new BrowserWindow({ width: 800, height: 600 });
window.loadURL('data:text/html,<title>Hello World!</title>'); 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!'); 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'; const clipboardContentToWrite = 'Hello from Playwright';
await application.evaluate(async ({clipboard}, text) => clipboard.writeText(text), clipboardContentToWrite); await application.evaluate(async ({clipboard}, text) => clipboard.writeText(text), clipboardContentToWrite);
const clipboardContentRead = await application.evaluate(async ({clipboard}) => clipboard.readText()); const clipboardContentRead = await application.evaluate(async ({clipboard}) => clipboard.readText());

View file

@ -13,27 +13,29 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { options } from '../playwright.fixtures';
import './electron.fixture'; 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.goto(server.PREFIX + '/input/button.html');
await window.click('button'); await window.click('button');
expect(await window.evaluate('result')).toBe('Clicked'); 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.setContent(`<input id='checkbox' type='checkbox'></input>`);
await window.check('input'); await window.check('input');
expect(await window.evaluate('checkbox.checked')).toBe(true); 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.setContent(`<input id='checkbox' type='checkbox' checked></input>`);
await window.check('input'); await window.check('input');
expect(await window.evaluate('checkbox.checked')).toBe(true); 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(() => { await window.evaluate(() => {
const textarea = document.createElement('textarea'); const textarea = document.createElement('textarea');
document.body.appendChild(textarea); document.body.appendChild(textarea);

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import '../base.fixture'; import { options } from '../playwright.fixtures';
import { registerFixture } from '../runner'; import { registerFixture } from '../runner';
import {ElectronApplication, ElectronLauncher, ElectronPage} from '../../electron-types'; import {ElectronApplication, ElectronLauncher, ElectronPage} from '../../electron-types';
import path from 'path'; import path from 'path';

View file

@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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.setViewportSize({ width: 500, height: 500 });
await page.goto(server.PREFIX + '/grid.html'); await page.goto(server.PREFIX + '/grid.html');
const elementHandle = await page.$('.box:nth-of-type(13)'); 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); 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 context = await browser.newContext({ viewport: { width: 400, height: 400 }, isMobile: true });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async ({ page, server }) => { it('should work', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import utils from './utils'; import utils from './utils';

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import utils from './utils'; import utils from './utils';
it('should have a nice preview', async ({ page, server }) => { it('should have a nice preview', async ({ page, server }) => {

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async({page, server}) => { 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>'); await page.setContent('<html><body><div class="tweet"><div class="like">100</div><div class="retweets">10</div></div></body></html>');

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should hover', async ({ page, server }) => { it('should hover', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/scrollable.html'); await page.goto(server.PREFIX + '/input/scrollable.html');

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import utils from './utils'; import utils from './utils';
it('should work', async ({ page, server }) => { it('should work', async ({ page, server }) => {

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async ({ page }) => { it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`); await page.setContent(`<input type='text' />`);

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should query existing element', async({page, server}) => { it('should query existing element', async({page, server}) => {
await page.goto(server.PREFIX + '/playground.html'); await page.goto(server.PREFIX + '/playground.html');

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import utils from './utils'; import utils from './utils';
import {PNG} from 'pngjs'; import {PNG} from 'pngjs';
@ -22,7 +22,7 @@ import path from 'path';
import fs from 'fs'; import fs from 'fs';
// Firefox headful produces a different image. // 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}) => { it.skip(ffheadful)('should work', async({page, server, golden}) => {
await page.setViewportSize({width: 500, height: 500}); 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')); 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 context = await browser.newContext({viewport: { width: 320, height: 480 }, isMobile: true});
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/grid.html'); 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(); 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 context = await browser.newContext({ viewport: { width: 320, height: 480 }, deviceScaleFactor: 2 });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/grid.html'); await page.goto(server.PREFIX + '/grid.html');

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async ({ page, server }) => { it('should work', async ({ page, server }) => {
await page.goto(server.PREFIX + '/offscreenbuttons.html'); await page.goto(server.PREFIX + '/offscreenbuttons.html');

View file

@ -14,14 +14,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it('should select textarea', async ({ page, server }) => { it('should select textarea', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/textarea.html'); await page.goto(server.PREFIX + '/input/textarea.html');
const textarea = await page.$('textarea'); const textarea = await page.$('textarea');
await textarea.evaluate(textarea => textarea.value = 'some value'); await textarea.evaluate(textarea => textarea.value = 'some value');
await textarea.selectText(); await textarea.selectText();
if (options.FFOX) { if (options.FIREFOX()) {
expect(await textarea.evaluate(el => el.selectionStart)).toBe(0); expect(await textarea.evaluate(el => el.selectionStart)).toBe(0);
expect(await textarea.evaluate(el => el.selectionEnd)).toBe(10); expect(await textarea.evaluate(el => el.selectionEnd)).toBe(10);
} else { } else {
@ -34,7 +35,7 @@ it('should select input', async ({ page, server }) => {
const input = await page.$('input'); const input = await page.$('input');
await input.evaluate(input => input.value = 'some value'); await input.evaluate(input => input.value = 'some value');
await input.selectText(); await input.selectText();
if (options.FFOX) { if (options.FIREFOX()) {
expect(await input.evaluate(el => el.selectionStart)).toBe(0); expect(await input.evaluate(el => el.selectionStart)).toBe(0);
expect(await input.evaluate(el => el.selectionEnd)).toBe(10); expect(await input.evaluate(el => el.selectionEnd)).toBe(10);
} else { } else {

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async ({ page }) => { it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`); await page.setContent(`<input type='text' />`);

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
async function giveItAChanceToResolve(page) { async function giveItAChanceToResolve(page) {
for (let i = 0; i < 5; i++) for (let i = 0; i < 5; i++)

View file

@ -15,8 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import utils from './utils'; import utils from './utils';
it('should think that it is focused by default', async({page}) => { it('should think that it is focused by default', async({page}) => {
@ -102,7 +101,7 @@ it('should change document.activeElement', async({page, server}) => {
expect(active).toEqual(['INPUT', 'TEXTAREA']); 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. // Firefox headful produces a different image.
const page2 = await page.context().newPage(); const page2 = await page.context().newPage();
await Promise.all([ await Promise.all([

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work with css selector', async({page, server}) => { it('should work with css selector', async({page, server}) => {
await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>'); await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>');

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work with css selector', async({page, server}) => { it('should work with css selector', async({page, server}) => {
await page.setContent('<section id="testAttribute">43543</section>'); await page.setContent('<section id="testAttribute">43543</section>');

View file

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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({ const browser = await browserType.launch({
...defaultBrowserOptions, ...defaultBrowserOptions,
firefoxUserPrefs: { firefoxUserPrefs: {

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import { registerFixture } from './runner'; import { registerFixture } from './runner';
import path from 'path'; import path from 'path';

View file

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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>`); await page.setContent(`<div id=d1 tabIndex=0></div>`);
expect(await page.evaluate(() => document.activeElement.nodeName)).toBe('BODY'); expect(await page.evaluate(() => document.activeElement.nodeName)).toBe('BODY');
await page.focus('#d1'); 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 // Chromium and WebKit both have settings for tab traversing all links, but
// it is only on by default in WebKit. // 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(` await page.setContent(`
<input id="input-1"> <input id="input-1">
<button id="button">buttton</button> <button id="button">buttton</button>

View file

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import utils from './utils'; import utils from './utils';
@ -36,7 +36,7 @@ it('should have correct execution contexts', async ({ page, server }) => {
}); });
function expectContexts(pageImpl, count) { function expectContexts(pageImpl, count) {
if (options.CHROMIUM) if (options.CHROMIUM())
expect(pageImpl._delegate._mainFrameSession._contextIdToContext.size).toBe(count); expect(pageImpl._delegate._mainFrameSession._contextIdToContext.size).toBe(count);
else else
expect(pageImpl._delegate._contextIdToContext.size).toBe(count); expect(pageImpl._delegate._contextIdToContext.size).toBe(count);
@ -126,7 +126,7 @@ it('should be isolated between frames', async({page, server}) => {
expect(a2).toBe(2); 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. // - Firefox does not report domcontentloaded for the iframe.
// - Chromium and Firefox report empty url. // - Chromium and Firefox report empty url.
// - Chromium does not report main/utility worlds for the iframe. // - 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(); 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. // Chromium does not report isolated world for the iframe.
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await page.evaluate(() => { await page.evaluate(() => {

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import utils from './utils'; import utils from './utils';

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import utils from './utils'; import utils from './utils';

View file

@ -14,8 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import utils from './utils'; import utils from './utils';
it('should handle nested frames', async({page, server}) => { 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); 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) => { server.setRoute('/x-frame-options-deny.html', async (req, res) => {
res.setHeader('Content-Type', 'text/html'); res.setHeader('Content-Type', 'text/html');
res.setHeader('X-Frame-Options', 'DENY'); res.setHeader('X-Frame-Options', 'DENY');

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async({page, server, context}) => { it('should work', async({page, server, context}) => {
await context.grantPermissions(['geolocation']); await context.grantPermissions(['geolocation']);

View file

@ -14,8 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import './runner/builtin.fixtures'; import { options } from './playwright.fixtures';
import './base.fixture';
import utils from './utils'; import utils from './utils';
const { makeUserDataDir, removeUserDataDir } = utils; const { makeUserDataDir, removeUserDataDir } = utils;
@ -27,7 +26,7 @@ it('should have default url when launching browser', async ({browserType, defaul
await browserContext.close(); 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 // see https://github.com/microsoft/playwright/issues/717
const userDataDir = await makeUserDataDir(); const userDataDir = await makeUserDataDir();
// Write a cookie in headful chrome // Write a cookie in headful chrome
@ -107,7 +106,7 @@ it('should(not) block third party cookies', async({browserType, defaultBrowserOp
return document.cookie; return document.cookie;
}); });
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
const allowsThirdParty = options.CHROMIUM || options.FFOX; const allowsThirdParty = options.CHROMIUM() || options.FIREFOX();
expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : ''); expect(documentCookie).toBe(allowsThirdParty ? 'username=John Doe' : '');
const cookies = await page.context().cookies(server.CROSS_PROCESS_PREFIX + '/grid.html'); const cookies = await page.context().cookies(server.CROSS_PROCESS_PREFIX + '/grid.html');
if (allowsThirdParty) { if (allowsThirdParty) {
@ -129,7 +128,7 @@ it('should(not) block third party cookies', async({browserType, defaultBrowserOp
await browser.close(); 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. // Our WebKit embedder does not respect window features.
const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); const browser = await browserType.launch({...defaultBrowserOptions, headless: false });
const context = await browser.newContext({ viewport: null }); const context = await browser.newContext({ viewport: null });

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async({browser, httpsServer}) => { it('should work', async({browser, httpsServer}) => {
let error = null; let error = null;

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import { globToRegex } from '../lib/rpc/client/clientHelper'; import { globToRegex } from '../lib/rpc/client/clientHelper';
import vm from 'vm'; import vm from 'vm';

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async({page}) => { it('should work', async({page}) => {
const aHandle = await page.evaluateHandle(() => document.body); const aHandle = await page.evaluateHandle(() => document.body);

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work with function', async({page}) => { it('should work with function', async({page}) => {
const windowHandle = await page.evaluateHandle(() => { const windowHandle = await page.evaluateHandle(() => {

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async({page}) => { it('should work', async({page}) => {
const aHandle = await page.evaluateHandle(() => ({foo: 'bar'})); const aHandle = await page.evaluateHandle(() => ({foo: 'bar'}));

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async({page}) => { it('should work', async({page}) => {
const aHandle = await page.evaluateHandle(() => ({ const aHandle = await page.evaluateHandle(() => ({

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it('should work for primitives', async({page}) => { it('should work for primitives', async({page}) => {
const numberHandle = await page.evaluateHandle(() => 2); 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 WeakSet()')).toString()).toBe('JSHandle@weakset');
expect((await page.evaluateHandle('new Error()')).toString()).toBe('JSHandle@error'); expect((await page.evaluateHandle('new Error()')).toString()).toBe('JSHandle@error');
// TODO(yurys): change subtype from array to typedarray in WebKit. // 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'); expect((await page.evaluateHandle('new Proxy({}, {})')).toString()).toBe('JSHandle@proxy');
}); });

View file

@ -14,8 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import { options } from './playwright.fixtures';
import utils from './utils'; import utils from './utils';
it('should type into a textarea', async ({page}) => { 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']); 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'); await page.goto(server.PREFIX + '/input/keyboard.html');
const keyboard = page.keyboard; const keyboard = page.keyboard;
const codeForKey = {'Shift': 16, 'Alt': 18, 'Control': 17}; 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); const lastEvent = await captureLastKeydown(page);
await page.keyboard.press('Meta'); await page.keyboard.press('Meta');
const {key, code, metaKey} = await lastEvent.jsonValue(); const {key, code, metaKey} = await lastEvent.jsonValue();
if (options.FFOX && !MAC) if (options.FIREFOX() && !MAC)
expect(key).toBe('OS'); expect(key).toBe('OS');
else else
expect(key).toBe('Meta'); expect(key).toBe('Meta');
if (options.FFOX) if (options.FIREFOX())
expect(code).toBe('OSLeft'); expect(code).toBe('OSLeft');
else else
expect(code).toBe('MetaLeft'); expect(code).toBe('MetaLeft');
if (options.FFOX && !MAC) if (options.FIREFOX() && !MAC)
expect(metaKey).toBe(false); expect(metaKey).toBe(false);
else else
expect(metaKey).toBe(true); 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 // 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 lastEvent = await captureLastKeydown(page);
const keyMap = { const keyMap = {
'ArrowUp': 'Up', 'ArrowUp': 'Up',

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import path from 'path'; import path from 'path';
import utils from './utils'; import utils from './utils';

View file

@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should log', async({browserType, defaultBrowserOptions}) => { it('should log', async({browserType, defaultBrowserOptions}) => {
const log = []; const log = [];

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
function dimensions() { function dimensions() {
const rect = document.querySelector('textarea').getBoundingClientRect(); const rect = document.querySelector('textarea').getBoundingClientRect();
@ -26,8 +27,8 @@ function dimensions() {
}; };
} }
it.fail(options.FFOX && WIN)('should click the document', async({page, server}) => { it.fail(options.FIREFOX() && 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 // Occasionally times out on options.FIREFOX() on Windows: https://github.com/microsoft/playwright/pull/1911/checks?check_run_id=607149016
await page.evaluate(() => { await page.evaluate(() => {
window["clickPromise"] = new Promise(resolve => { window["clickPromise"] = new Promise(resolve => {
document.addEventListener('click', event => { 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)); await page.evaluate(() => document.querySelector('#button-3').addEventListener('mousedown', e => window["lastEvent"] = e, true));
const modifiers = {'Shift': 'shiftKey', 'Control': 'ctrlKey', 'Alt': 'altKey', 'Meta': 'metaKey'}; const modifiers = {'Shift': 'shiftKey', 'Control': 'ctrlKey', 'Alt': 'altKey', 'Meta': 'metaKey'};
// In Firefox, the Meta modifier only exists on Mac // In Firefox, the Meta modifier only exists on Mac
if (options.FFOX && !MAC) if (options.FIREFOX() && !MAC)
delete modifiers['Meta']; delete modifiers['Meta'];
for (const modifier in modifiers) { for (const modifier in modifiers) {
await page.keyboard.down(modifier); 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}) => { it('should tween mouse movement', async({page}) => {
// The test becomes flaky on WebKit without next line. // The test becomes flaky on WebKit without next line.
if (options.WEBKIT) if (options.WEBKIT())
await page.evaluate(() => new Promise(requestAnimationFrame)); await page.evaluate(() => new Promise(requestAnimationFrame));
await page.mouse.move(100, 100); await page.mouse.move(100, 100);
await page.evaluate(() => { 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 // @see https://crbug.com/929806
const context = await browser.newContext({ viewport: {width: 360, height: 640}, isMobile: true }); const context = await browser.newContext({ viewport: {width: 360, height: 640}, isMobile: true });
const page = await context.newPage(); const page = await context.newPage();

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it.skip(options.WIRE)('should work across sessions', async ({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should work across sessions', async ({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work with _blank target', async({page, server}) => { it('should work with _blank target', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => { server.setRoute('/empty.html', (req, res) => {

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
import utils from './utils'; import utils from './utils';
it('should work for main frame navigation request', async({page, server}) => { it('should work for main frame navigation request', async({page, server}) => {
@ -47,15 +47,15 @@ it('should work for fetch requests', async({page, server}) => {
it('should return headers', async({page, server}) => { it('should return headers', async({page, server}) => {
const response = await page.goto(server.EMPTY_PAGE); const response = await page.goto(server.EMPTY_PAGE);
if (options.CHROMIUM) if (options.CHROMIUM())
expect(response.request().headers()['user-agent']).toContain('Chrome'); expect(response.request().headers()['user-agent']).toContain('Chrome');
else if (options.FFOX) else if (options.FIREFOX())
expect(response.request().headers()['user-agent']).toContain('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'); 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'); await page.goto(server.PREFIX + '/empty.html');
let serverRequest; let serverRequest;
server.setRoute('/something', (request, response) => { server.setRoute('/something', (request, response) => {

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import path from 'path'; import path from 'path';
it('should evaluate before anything else on the page', async ({ page, server }) => { it('should evaluate before anything else on the page', async ({ page, server }) => {

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
import path from 'path'; import path from 'path';
it('should throw an error if no options are provided', async({page, server}) => { it('should throw an error if no options are provided', async({page, server}) => {
@ -74,7 +74,7 @@ it('should work with a path', async({page, server}) => {
expect(await page.evaluate(() => window['__injected'])).toBe(42); 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.goto(server.EMPTY_PAGE);
await page.addScriptTag({ path: path.join(__dirname, 'assets/injectedfile.js') }); await page.addScriptTag({ path: path.join(__dirname, 'assets/injectedfile.js') });
const result = await page.evaluate(() => window['__injectedError'].stack); 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); 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. // Firefox fires onload for blocked script before it issues the CSP console error.
await page.goto(server.PREFIX + '/csp.html'); await page.goto(server.PREFIX + '/csp.html');
let error = null; let error = null;

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import path from 'path'; import path from 'path';
it('should throw an error if no options are provided', async({page, server}) => { it('should throw an error if no options are provided', async({page, server}) => {

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it('should reject all promises when page is closed', async({context}) => { it('should reject all promises when page is closed', async({context}) => {
const newPage = await context.newPage(); 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'); const dialog = await newPage.waitForEvent('dialog');
expect(dialog.type()).toBe('beforeunload'); expect(dialog.type()).toBe('beforeunload');
expect(dialog.defaultValue()).toBe(''); expect(dialog.defaultValue()).toBe('');
if (options.CHROMIUM) if (options.CHROMIUM())
expect(dialog.message()).toBe(''); expect(dialog.message()).toBe('');
else if (options.WEBKIT) else if (options.WEBKIT())
expect(dialog.message()).toBe('Leave?'); expect(dialog.message()).toBe('Leave?');
else 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.'); 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. // Second part in parenthesis is platform - ignore it.
// Third part for Firefox is the last one and encodes engine and browser versions. // 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(' '); const [engine, browser] = part3.split(' ');
expect(engine.startsWith('Gecko')).toBe(true); expect(engine.startsWith('Gecko')).toBe(true);
expect(browser.startsWith('Firefox')).toBe(true); expect(browser.startsWith('Firefox')).toBe(true);
@ -218,13 +219,13 @@ it('should have sane user agent', async ({page}) => {
expect(part5).toBe(undefined); expect(part5).toBe(undefined);
return; 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(part3.startsWith('AppleWebKit/')).toBe(true);
expect(part4).toBe('KHTML, like Gecko'); expect(part4).toBe('KHTML, like Gecko');
// 5th part encodes real browser name and engine version. // 5th part encodes real browser name and engine version.
const [engine, browser] = part5.split(' '); const [engine, browser] = part5.split(' ');
expect(browser.startsWith('Safari/')).toBe(true); expect(browser.startsWith('Safari/')).toBe(true);
if (options.CHROMIUM) if (options.CHROMIUM())
expect(engine.includes('Chrome/')).toBe(true); expect(engine.includes('Chrome/')).toBe(true);
else else
expect(engine.startsWith('Version/')).toBe(true); 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'); 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 page1 = await context.newPage()
const page2 = await context.newPage() const page2 = await context.newPage()
for (const page of [page1, page2]) { for (const page of [page1, page2]) {

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
import utils from './utils'; import utils from './utils';
it('should emulate type', async({page, server}) => { it('should emulate type', async({page, server}) => {
@ -114,7 +114,7 @@ it('should work in cross-process iframe', async({browser, server}) => {
await page.close(); 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(` await page.setContent(`
<style> <style>
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
it('should work', async({page, server}) => { it('should work', async({page, server}) => {
const windowHandle = await page.evaluateHandle(() => window); const windowHandle = await page.evaluateHandle(() => window);

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it('should work', async ({ page, server }) => { it('should work', async ({ page, server }) => {
const result = await page.evaluate(() => 7 * 3); 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]); 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. // It is imporant to be on about:blank for sync reload.
const result = await page.evaluate(() => { const result = await page.evaluate(() => {
window.location.reload(); window.location.reload();
@ -452,7 +453,7 @@ it('should work even when JSON is set to null', async ({ page }) => {
expect(result).toEqual({ abc: 123 }); 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 // Something is wrong about the way Firefox waits for the chained promise
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
const result = await page.evaluate(() => { const result = await page.evaluate(() => {

View file

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import './playwright.fixtures';
import util from 'util'; import util from 'util';
it('should work', async({page, server}) => { it('should work', async({page, server}) => {

View file

@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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. // Firefox Win: it just doesn't crash sometimes.
function crash(pageImpl, browserName) { function crash(pageImpl, browserName) {
if (browserName === 'chromium') if (browserName === 'chromium')

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it('Page.Events.Request', async({page, server}) => { it('Page.Events.Request', async({page, server}) => {
const requests = []; const requests = [];
@ -52,9 +53,9 @@ it('Page.Events.RequestFailed', async({page, server}) => {
expect(failedRequests[0].url()).toContain('one-style.css'); expect(failedRequests[0].url()).toContain('one-style.css');
expect(await failedRequests[0].response()).toBe(null); expect(await failedRequests[0].response()).toBe(null);
expect(failedRequests[0].resourceType()).toBe('stylesheet'); expect(failedRequests[0].resourceType()).toBe('stylesheet');
if (options.CHROMIUM) { if (options.CHROMIUM()) {
expect(failedRequests[0].failure().errorText).toBe('net::ERR_EMPTY_RESPONSE'); expect(failedRequests[0].failure().errorText).toBe('net::ERR_EMPTY_RESPONSE');
} else if (options.WEBKIT) { } else if (options.WEBKIT()) {
if (MAC) if (MAC)
expect(failedRequests[0].failure().errorText).toBe('The network connection was lost.'); expect(failedRequests[0].failure().errorText).toBe('The network connection was lost.');
else if (WIN) else if (WIN)

View file

@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import { options } from './playwright.fixtures';
it('should fire', async({page, server}) => { it('should fire', async({page, server}) => {
const [error] = await Promise.all([ const [error] = await Promise.all([
@ -25,12 +26,12 @@ it('should fire', async({page, server}) => {
expect(error.message).toBe('Fancy error!'); expect(error.message).toBe('Fancy error!');
let stack = await page.evaluate(() => window['e'].stack); let stack = await page.evaluate(() => window['e'].stack);
// Note that WebKit reports the stack of the 'throw' statement instead of the Error constructor call. // 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'); stack = stack.replace('14:25', '15:19');
expect(error.stack).toBe(stack); 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([ const [error] = await Promise.all([
page.waitForEvent('pageerror'), page.waitForEvent('pageerror'),
page.goto(server.PREFIX + '/error.html'), page.goto(server.PREFIX + '/error.html'),
@ -50,24 +51,24 @@ it('should handle odd values', async ({page}) => {
page.waitForEvent('pageerror'), page.waitForEvent('pageerror'),
page.evaluate(value => setTimeout(() => { throw value; }, 0), value), 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. // Firefox just does not report this error.
const [error] = await Promise.all([ const [error] = await Promise.all([
page.waitForEvent('pageerror'), page.waitForEvent('pageerror'),
page.evaluate(() => setTimeout(() => { throw {}; }, 0)), 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. // Firefox just does not report this error.
const [error] = await Promise.all([ const [error] = await Promise.all([
page.waitForEvent('pageerror'), page.waitForEvent('pageerror'),
page.evaluate(() => setTimeout(() => { throw window; }, 0)), page.evaluate(() => setTimeout(() => { throw window; }, 0)),
]); ]);
expect(error.message).toBe(options.CHROMIUM ? 'Window' : '[object Window]'); expect(error.message).toBe(options.CHROMIUM() ? 'Window' : '[object Window]');
}); });

Some files were not shown because too many files have changed in this diff Show more