test: merge test options into options (#3531)

This commit is contained in:
Pavel Feldman 2020-08-19 13:30:54 -07:00 committed by GitHub
parent 9ac1bbc2a5
commit a65b0bba5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 210 additions and 283 deletions

View file

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
it('should await navigation when clicking anchor', async({page, server}) => { it('should await navigation when clicking anchor', async({page, server}) => {
const messages = []; const messages = [];
@ -201,7 +200,7 @@ it('should work with goto following click', async({page, server}) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
}); });
it.skip(WIRE)('should report navigation in the log when clicking anchor', async({page, server}) => { it.skip(options.WIRE)('should report navigation in the log when clicking anchor', async({page, server}) => {
await page.setContent(`<a href="${server.PREFIX + '/frames/one-frame.html'}">click me</a>`); await page.setContent(`<a href="${server.PREFIX + '/frames/one-frame.html'}">click me</a>`);
const __testHookAfterPointerAction = () => new Promise(f => setTimeout(f, 6000)); const __testHookAfterPointerAction = () => new Promise(f => setTimeout(f, 6000));
const error = await page.click('a', { timeout: 5000, __testHookAfterPointerAction } as any).catch(e => e); const error = await page.click('a', { timeout: 5000, __testHookAfterPointerAction } as any).catch(e => e);

View file

@ -25,7 +25,7 @@ import { Transport } from '../lib/rpc/transport';
import { setUnderTest } from '../lib/helper'; import { setUnderTest } from '../lib/helper';
import { installCoverageHooks } from './runner/coverage'; import { installCoverageHooks } from './runner/coverage';
import { valueFromEnv } from './runner/utils'; import { valueFromEnv } from './runner/utils';
import { registerFixture, registerWorkerFixture, registerOption } from './runner/fixtures'; import { registerFixture, registerWorkerFixture, registerOption, registerOptionGenerator } from './runner/fixtures';
import './runner/builtin.fixtures'; import './runner/builtin.fixtures';
import {mkdtempAsync, removeFolderAsync} from './utils'; import {mkdtempAsync, removeFolderAsync} from './utils';
@ -43,9 +43,6 @@ declare global {
browserType: BrowserType<Browser>; browserType: BrowserType<Browser>;
browserName: string; browserName: string;
browser: Browser; browser: Browser;
isChromium: boolean;
isFirefox: boolean;
isWebKit: boolean;
} }
interface FixtureState { interface FixtureState {
toImpl: (rpcObject: any) => any; toImpl: (rpcObject: any) => any;
@ -60,6 +57,8 @@ declare global {
CHROMIUM: boolean; CHROMIUM: boolean;
FFOX: boolean; FFOX: boolean;
WEBKIT: boolean; WEBKIT: boolean;
HEADLESS: boolean;
WIRE: boolean;
} }
} }
@ -104,14 +103,14 @@ registerWorkerFixture('defaultBrowserOptions', async({browserName}, test) => {
await test({ await test({
handleSIGINT: false, handleSIGINT: false,
slowMo: valueFromEnv('SLOW_MO', 0), slowMo: valueFromEnv('SLOW_MO', 0),
headless: !!valueFromEnv('HEADLESS', true), headless: options.HEADLESS,
executablePath executablePath
}); });
}); });
registerWorkerFixture('playwright', async({parallelIndex, browserName}, test) => { registerWorkerFixture('playwright', async({parallelIndex, browserName}, test) => {
const {coverage, uninstall} = installCoverageHooks(browserName); const {coverage, uninstall} = installCoverageHooks(browserName);
if (process.env.PWWIRE) { if (options.WIRE) {
const connection = new Connection(); const connection = new Connection();
const spawnedProcess = childProcess.fork(path.join(__dirname, '..', 'lib', 'rpc', 'server'), [], { const spawnedProcess = childProcess.fork(path.join(__dirname, '..', 'lib', 'rpc', 'server'), [], {
stdio: 'pipe', stdio: 'pipe',
@ -185,22 +184,6 @@ registerFixture('server', async ({httpService}, test) => {
await test(httpService.server); await test(httpService.server);
}); });
registerWorkerFixture('browserName', async ({}, test) => {
await test(options.browserName);
});
registerWorkerFixture('isChromium', async ({}, test) => {
await test(options.browserName === 'chromium');
});
registerWorkerFixture('isFirefox', async ({}, test) => {
await test(options.browserName === 'firefox');
});
registerWorkerFixture('isWebKit', async ({}, test) => {
await test(options.browserName === 'webkit');
});
registerFixture('httpsServer', async ({httpService}, test) => { registerFixture('httpsServer', async ({httpService}, test) => {
httpService.httpsServer.reset(); httpService.httpsServer.reset();
await test(httpService.httpsServer); await test(httpService.httpsServer);
@ -220,11 +203,14 @@ registerWorkerFixture('golden', async ({browserName}, test) => {
await test(p => path.join(browserName, p)); await test(p => path.join(browserName, p));
}); });
registerOption('browserName', () => { registerOptionGenerator('browserName', () => {
if (process.env.BROWSER) if (process.env.BROWSER)
return [process.env.BROWSER]; return [process.env.BROWSER];
return ['chromium', 'webkit', 'firefox']; return ['chromium', 'webkit', 'firefox'];
}); });
registerOption('CHROMIUM', ({browserName}) => browserName === 'chromium'); registerOption('CHROMIUM', ({browserName}) => browserName === 'chromium');
registerOption('FFOX', ({browserName}) => browserName === 'firefox'); registerOption('FFOX', ({browserName}) => browserName === 'firefox');
registerOption('WEBKIT', ({browserName}) => browserName === 'webkit'); registerOption('WEBKIT', ({browserName}) => browserName === 'webkit');
registerOption('HEADLESS', ({}) => !!valueFromEnv('HEADLESS', true));
registerOption('WIRE', ({}) => process.env.PWWIRE);

View file

@ -15,8 +15,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
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();
expect(browser.contexts().length).toBe(1); expect(browser.contexts().length).toBe(1);
@ -39,9 +37,9 @@ it('should throw upon second create new page', async function({browser}) {
expect(error.message).toContain('Please use browser.newContext()'); expect(error.message).toContain('Please use browser.newContext()');
}); });
it('version should work', async function({browser, isChromium}) { it('version should work', async function({browser}) {
const version = browser.version(); const version = browser.version();
if (isChromium) 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

@ -177,14 +177,14 @@ it('should close all belonging pages once closing context', async function({brow
expect(context.pages().length).toBe(0); expect(context.pages().length).toBe(0);
}); });
it('should disable javascript', async({browser, isWebKit}) => { it('should disable javascript', async({browser}) => {
{ {
const context = await browser.newContext({ javaScriptEnabled: false }); const context = await browser.newContext({ javaScriptEnabled: false });
const page = await context.newPage(); const page = await context.newPage();
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 (isWebKit) 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

@ -16,9 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
const { HEADLESS } = testOptions; it.fail(options.CHROMIUM && !options.HEADLESS)('should fail without credentials', async({browser, server}) => {
it.fail(options.CHROMIUM && !HEADLESS)('should fail without credentials', async({browser, server}) => {
server.setAuth('/empty.html', 'user', 'pass'); 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();
@ -27,7 +25,7 @@ it.fail(options.CHROMIUM && !HEADLESS)('should fail without credentials', async(
await context.close(); await context.close();
}); });
it.fail(options.CHROMIUM && !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();
@ -50,7 +48,7 @@ it('should work with correct credentials', async({browser, server}) => {
await context.close(); await context.close();
}); });
it.fail(options.CHROMIUM && !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

@ -24,12 +24,12 @@ it('browserType.executablePath should work', async({browserType}) => {
expect(fs.realpathSync(executablePath)).toBe(executablePath); expect(fs.realpathSync(executablePath)).toBe(executablePath);
}); });
it('browserType.name should work', async({browserType, isWebKit, isFirefox, isChromium}) => { it('browserType.name should work', async({browserType}) => {
if (isWebKit) if (options.WEBKIT)
expect(browserType.name()).toBe('webkit'); expect(browserType.name()).toBe('webkit');
else if (isFirefox) else if (options.FFOX)
expect(browserType.name()).toBe('firefox'); expect(browserType.name()).toBe('firefox');
else if (isChromium) 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

@ -16,9 +16,8 @@
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
it.skip(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);
{ {
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
@ -37,7 +36,7 @@ it.skip(WIRE).slow()('should be able to reconnect to a browser', async({browserT
await browserServer.close(); await browserServer.close();
}); });
it.skip(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);
@ -45,7 +44,7 @@ it.skip(WIRE).fail(options.CHROMIUM && WIN).slow()('should handle exceptions dur
expect(error.message).toContain('Dummy'); expect(error.message).toContain('Dummy');
}); });
it.skip(WIRE)('should set the browser connected state', async ({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should set the browser connected state', async ({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
expect(remote.isConnected()).toBe(true); expect(remote.isConnected()).toBe(true);
@ -54,7 +53,7 @@ it.skip(WIRE)('should set the browser connected state', async ({browserType, def
await browserServer.close(); await browserServer.close();
}); });
it.skip(WIRE)('should throw when used after isConnected returns false', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should throw when used after isConnected returns false', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
const page = await remote.newPage(); const page = await remote.newPage();

View file

@ -16,9 +16,8 @@
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
it.skip(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);
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
const browserContext = await browser.newContext(); const browserContext = await browser.newContext();
@ -31,7 +30,7 @@ it.skip(WIRE)('should work', async({browserType, defaultBrowserOptions}) => {
await browserServer.close(); await browserServer.close();
}); });
it.skip(WIRE)('should fire "disconnected" when closing the server', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should fire "disconnected" when closing the server', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
const disconnectedEventPromise = new Promise(resolve => browser.once('disconnected', resolve)); const disconnectedEventPromise = new Promise(resolve => browser.once('disconnected', resolve));
@ -43,7 +42,7 @@ it.skip(WIRE)('should fire "disconnected" when closing the server', async({brows
]); ]);
}); });
it.skip(WIRE)('should fire "close" event during kill', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should fire "close" event during kill', async({browserType, defaultBrowserOptions}) => {
const order = []; const order = [];
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const closedPromise = new Promise(f => browserServer.on('close', () => { const closedPromise = new Promise(f => browserServer.on('close', () => {
@ -57,13 +56,13 @@ it.skip(WIRE)('should fire "close" event during kill', async({browserType, defau
expect(order).toEqual(['closed', 'killed']); expect(order).toEqual(['closed', 'killed']);
}); });
it.skip(WIRE)('should return child_process instance', async ({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should return child_process instance', async ({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
expect(browserServer.process().pid).toBeGreaterThan(0); expect(browserServer.process().pid).toBeGreaterThan(0);
await browserServer.close(); await browserServer.close();
}); });
it.skip(WIRE)('should fire close event', async ({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should fire close event', async ({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const [result] = await Promise.all([ const [result] = await Promise.all([
new Promise(f => (browserServer as any).on('close', (exitCode, signal) => f({ exitCode, signal }))), new Promise(f => (browserServer as any).on('close', (exitCode, signal) => f({ exitCode, signal }))),
@ -73,7 +72,7 @@ it.skip(WIRE)('should fire close event', async ({browserType, defaultBrowserOpti
expect(result['signal']).toBe(null); expect(result['signal']).toBe(null);
}); });
it.skip(WIRE)('should reject navigation when browser closes', async({browserType, defaultBrowserOptions, server}) => { it.skip(options.WIRE)('should reject navigation when browser closes', async({browserType, defaultBrowserOptions, server}) => {
server.setRoute('/one-style.css', () => {}); server.setRoute('/one-style.css', () => {});
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
@ -86,7 +85,7 @@ it.skip(WIRE)('should reject navigation when browser closes', async({browserType
await browserServer.close(); await browserServer.close();
}); });
it.skip(WIRE)('should reject waitForSelector when browser closes', async({browserType, defaultBrowserOptions, server}) => { it.skip(options.WIRE)('should reject waitForSelector when browser closes', async({browserType, defaultBrowserOptions, server}) => {
server.setRoute('/empty.html', () => {}); server.setRoute('/empty.html', () => {});
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
@ -102,7 +101,7 @@ it.skip(WIRE)('should reject waitForSelector when browser closes', async({browse
await browserServer.close(); await browserServer.close();
}); });
it.skip(WIRE)('should throw if used after disconnect', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should throw if used after disconnect', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
const page = await remote.newPage(); const page = await remote.newPage();
@ -112,7 +111,7 @@ it.skip(WIRE)('should throw if used after disconnect', async({browserType, defau
await browserServer.close(); await browserServer.close();
}); });
it.skip(WIRE)('should emit close events on pages and contexts', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should emit close events on pages and contexts', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
const context = await remote.newContext(); const context = await remote.newContext();
@ -126,7 +125,7 @@ it.skip(WIRE)('should emit close events on pages and contexts', async({browserTy
expect(pageClosed).toBeTruthy(); expect(pageClosed).toBeTruthy();
}); });
it.skip(WIRE)('should terminate network waiters', async({browserType, defaultBrowserOptions, server}) => { it.skip(options.WIRE)('should terminate network waiters', async({browserType, defaultBrowserOptions, server}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
const newPage = await remote.newPage(); const newPage = await remote.newPage();

View file

@ -18,7 +18,6 @@
import path from 'path'; import path from 'path';
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
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);
@ -60,7 +59,7 @@ it('should reject if executable path is invalid', async({browserType, defaultBro
expect(waitError.message).toContain('Failed to launch'); expect(waitError.message).toContain('Failed to launch');
}); });
it.skip(WIRE)('should handle timeout', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should handle timeout', async({browserType, defaultBrowserOptions}) => {
const options = { ...defaultBrowserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) }; const options = { ...defaultBrowserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };
const error = await browserType.launch(options).catch(e => e); const error = await browserType.launch(options).catch(e => e);
expect(error.message).toContain(`browserType.launch: Timeout 5000ms exceeded.`); expect(error.message).toContain(`browserType.launch: Timeout 5000ms exceeded.`);
@ -68,14 +67,14 @@ it.skip(WIRE)('should handle timeout', async({browserType, defaultBrowserOptions
expect(error.message).toContain(`<launched> pid=`); expect(error.message).toContain(`<launched> pid=`);
}); });
it.skip(WIRE)('should handle exception', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should handle exception', async({browserType, defaultBrowserOptions}) => {
const e = new Error('Dummy'); const e = new Error('Dummy');
const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 }; const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };
const error = await browserType.launch(options).catch(e => e); const error = await browserType.launch(options).catch(e => e);
expect(error.message).toContain('Dummy'); expect(error.message).toContain('Dummy');
}); });
it.skip(WIRE)('should report launch log', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should report launch log', async({browserType, defaultBrowserOptions}) => {
const e = new Error('Dummy'); const e = new Error('Dummy');
const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 }; const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; }, timeout: 9000 };
const error = await browserType.launch(options).catch(e => e); const error = await browserType.launch(options).catch(e => e);

View file

@ -19,23 +19,22 @@ 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;
const { WIRE } = testOptions;
it.skip(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(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 || 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 => {

View file

@ -16,9 +16,8 @@
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
it.skip(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');
const error = await page.click('button', { timeout: 2000, __testHookBeforePointerAction: () => new Promise(f => setTimeout(f, 2500))} as any).catch(e => e); const error = await page.click('button', { timeout: 2000, __testHookBeforePointerAction: () => new Promise(f => setTimeout(f, 2500))} as any).catch(e => e);
await page.waitForTimeout(5000); // Give it some time to click after the test hook is done waiting. await page.waitForTimeout(5000); // Give it some time to click after the test hook is done waiting.

View file

@ -16,9 +16,8 @@
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
it.skip(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>');
let clicked = false; let clicked = false;
const handle = await page.$('button'); const handle = await page.$('button');

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const { HEADLESS } = testOptions;
async function giveItAChanceToClick(page) { async function giveItAChanceToClick(page) {
for (let i = 0; i < 5; i++) for (let i = 0; i < 5; i++)
@ -344,39 +343,39 @@ it('should click the button with deviceScaleFactor set', async({browser, server}
await context.close(); await context.close();
}); });
it('should click the button with px border with offset', async({page, server, isWebKit}) => { it('should click the button with px border with offset', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '8px'); await page.$eval('button', button => button.style.borderWidth = '8px');
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(isWebKit ? 20 + 8 : 20); expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 20 + 8 : 20);
expect(await page.evaluate('offsetY')).toBe(isWebKit ? 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, isWebKit}) => { it('should click the button with em border with offset', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '2em'); await page.$eval('button', button => button.style.borderWidth = '2em');
await page.$eval('button', button => button.style.fontSize = '12px'); await page.$eval('button', button => button.style.fontSize = '12px');
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(isWebKit ? 12 * 2 + 20 : 20); expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 12 * 2 + 20 : 20);
expect(await page.evaluate('offsetY')).toBe(isWebKit ? 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, isWebKit}) => { it('should click a very large button with offset', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '8px'); await page.$eval('button', button => button.style.borderWidth = '8px');
await page.$eval('button', button => button.style.height = button.style.width = '2000px'); await page.$eval('button', button => button.style.height = button.style.width = '2000px');
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(isWebKit ? 1900 + 8 : 1900); expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 1900 + 8 : 1900);
expect(await page.evaluate('offsetY')).toBe(isWebKit ? 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, isWebKit}) => { it('should click a button in scrolling container with offset', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => { await page.$eval('button', button => {
const container = document.createElement('div'); const container = document.createElement('div');
@ -392,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(isWebKit ? 1900 + 8 : 1900); expect(await page.evaluate('offsetX')).toBe(options.WEBKIT ? 1900 + 8 : 1900);
expect(await page.evaluate('offsetY')).toBe(isWebKit ? 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, isChromium, isWebKit}) => { it.skip(options.FFOX)('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');
@ -408,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 (isWebKit) { 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 (isChromium && 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

@ -22,7 +22,6 @@ import fs from 'fs';
import utils from './utils'; import utils from './utils';
import { BrowserType, Browser, BrowserContext, Page } from '..'; import { BrowserType, Browser, BrowserContext, Page } from '..';
const { removeUserDataDir, makeUserDataDir } = utils; const { removeUserDataDir, makeUserDataDir } = utils;
const { WIRE } = testOptions;
declare global { declare global {
interface FixtureState { interface FixtureState {
@ -171,12 +170,12 @@ it('should support bypassCSP option', async ({server, launchPersistent}) => {
expect(await page.evaluate('__injected')).toBe(42); expect(await page.evaluate('__injected')).toBe(42);
}); });
it('should support javascriptEnabled option', async ({launchPersistent, isWebKit}) => { it('should support javascriptEnabled option', async ({launchPersistent}) => {
const {page, context} = await launchPersistent({javaScriptEnabled: false}); const {page, context} = await launchPersistent({javaScriptEnabled: false});
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 (isWebKit) 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');
@ -346,7 +345,7 @@ it.skip(options.FFOX)('should throw if page argument is passed', async ({browser
expect(error.message).toContain('can not specify page'); expect(error.message).toContain('can not specify page');
}); });
it.skip(WIRE)('should have passed URL when launching with ignoreDefaultArgs: true', async ({browserType, defaultBrowserOptions, server, tmpDir, toImpl}) => { it.skip(options.WIRE)('should have passed URL when launching with ignoreDefaultArgs: true', async ({browserType, defaultBrowserOptions, server, tmpDir, toImpl}) => {
const args = toImpl(browserType)._defaultArgs(defaultBrowserOptions, 'persistent', tmpDir, 0).filter(a => a !== 'about:blank'); const args = toImpl(browserType)._defaultArgs(defaultBrowserOptions, 'persistent', tmpDir, 0).filter(a => a !== 'about:blank');
const options = { const options = {
...defaultBrowserOptions, ...defaultBrowserOptions,
@ -362,13 +361,13 @@ it.skip(WIRE)('should have passed URL when launching with ignoreDefaultArgs: tru
await browserContext.close(); await browserContext.close();
}); });
it.skip(WIRE)('should handle timeout', async({browserType, defaultBrowserOptions, tmpDir}) => { it.skip(options.WIRE)('should handle timeout', async({browserType, defaultBrowserOptions, tmpDir}) => {
const options = { ...defaultBrowserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) }; const options = { ...defaultBrowserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };
const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e); const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e);
expect(error.message).toContain(`browserType.launchPersistentContext: Timeout 5000ms exceeded.`); expect(error.message).toContain(`browserType.launchPersistentContext: Timeout 5000ms exceeded.`);
}); });
it.skip(WIRE)('should handle exception', async({browserType, defaultBrowserOptions, tmpDir}) => { it.skip(options.WIRE)('should handle exception', async({browserType, defaultBrowserOptions, tmpDir}) => {
const e = new Error('Dummy'); const e = new Error('Dummy');
const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; } }; const options = { ...defaultBrowserOptions, __testHookBeforeCreateBrowser: () => { throw e; } };
const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e); const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e);

View file

@ -21,7 +21,6 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import util from 'util'; import util from 'util';
const { HEADLESS } = testOptions;
beforeEach(async ({server}) => { beforeEach(async ({server}) => {
server.setRoute('/download', (req, res) => { server.setRoute('/download', (req, res) => {
@ -240,7 +239,7 @@ it.fail(options.FFOX || options.WEBKIT)('should report alt-click downloads', asy
await page.close(); await page.close();
}); });
it.fail(options.CHROMIUM && !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

@ -16,9 +16,8 @@
*/ */
import './base.fixture'; import './base.fixture';
const { HEADLESS } = testOptions;
it.fail(options.FFOX && !HEADLESS)('should work', async ({ page, server }) => { it.fail(options.FFOX && !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)');

View file

@ -17,13 +17,12 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {WIRE, HEADLESS} = testOptions;
import {PNG} from 'pngjs'; import {PNG} from 'pngjs';
import path from 'path'; 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 && !HEADLESS; const ffheadful = options.FFOX && !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});
@ -285,7 +284,7 @@ it.skip(ffheadful)('should restore default viewport after fullPage screenshot',
await context.close(); await context.close();
}); });
it.skip(ffheadful || WIRE)('should restore viewport after page screenshot and exception', async({ browser, server }) => { it.skip(ffheadful || options.WIRE)('should restore viewport after page screenshot and exception', async({ browser, server }) => {
const context = await browser.newContext({ viewport: { width: 350, height: 360 } }); const context = await browser.newContext({ viewport: { width: 350, height: 360 } });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/grid.html'); await page.goto(server.PREFIX + '/grid.html');
@ -296,7 +295,7 @@ it.skip(ffheadful || WIRE)('should restore viewport after page screenshot and ex
await context.close(); await context.close();
}); });
it.skip(ffheadful || WIRE)('should restore viewport after page screenshot and timeout', async({ browser, server }) => { it.skip(ffheadful || options.WIRE)('should restore viewport after page screenshot and timeout', async({ browser, server }) => {
const context = await browser.newContext({ viewport: { width: 350, height: 360 } }); const context = await browser.newContext({ viewport: { width: 350, height: 360 } });
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/grid.html'); await page.goto(server.PREFIX + '/grid.html');
@ -340,7 +339,7 @@ it.skip(ffheadful)('should take element screenshot when default viewport is null
await context.close(); await context.close();
}); });
it.skip(ffheadful || WIRE)('should restore viewport after element screenshot and exception', async({server, browser}) => { it.skip(ffheadful || options.WIRE)('should restore viewport after element screenshot and exception', async({server, browser}) => {
const context = await browser.newContext({ viewport: { width: 350, height: 360 } }); const context = await browser.newContext({ viewport: { width: 350, height: 360 } });
const page = await context.newPage(); const page = await context.newPage();
await page.setContent(`<div style="width:600px;height:600px;"></div>`); await page.setContent(`<div style="width:600px;height:600px;"></div>`);

View file

@ -16,12 +16,12 @@
*/ */
import './base.fixture'; import './base.fixture';
it('should select textarea', async ({ page, server, isFirefox }) => { 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 (isFirefox) { if (options.FFOX) {
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 {
@ -29,12 +29,12 @@ it('should select textarea', async ({ page, server, isFirefox }) => {
} }
}); });
it('should select input', async ({ page, server, isFirefox }) => { it('should select input', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/textarea.html'); await page.goto(server.PREFIX + '/input/textarea.html');
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 (isFirefox) { if (options.FFOX) {
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

@ -18,7 +18,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const { HEADLESS } = testOptions;
it('should think that it is focused by default', async({page}) => { it('should think that it is focused by default', async({page}) => {
expect(await page.evaluate('document.hasFocus()')).toBe(true); expect(await page.evaluate('document.hasFocus()')).toBe(true);
@ -103,7 +102,7 @@ it('should change document.activeElement', async({page, server}) => {
expect(active).toEqual(['INPUT', 'TEXTAREA']); expect(active).toEqual(['INPUT', 'TEXTAREA']);
}); });
it.skip(options.FFOX && !HEADLESS)('should not affect screenshots', async({page, server, golden}) => { it.skip(options.FFOX && !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

@ -20,7 +20,6 @@ import { registerFixture } from './runner/fixtures';
import path from 'path'; import path from 'path';
import {spawn, execSync} from 'child_process'; import {spawn, execSync} from 'child_process';
import { BrowserType, Browser, LaunchOptions } from '..'; import { BrowserType, Browser, LaunchOptions } from '..';
const { HEADLESS } = testOptions;
const playwrightPath = path.join(__dirname, '..'); const playwrightPath = path.join(__dirname, '..');
@ -129,7 +128,7 @@ it.slow()('should close the browser when the node process closes', async ({wrapp
}); });
// Cannot reliably send signals on Windows. // Cannot reliably send signals on Windows.
it.skip(WIN || !HEADLESS).slow()('should report browser close signal', async ({wrapper}) => { it.skip(WIN || !options.HEADLESS).slow()('should report browser close signal', async ({wrapper}) => {
const pid = await wrapper.out('pid'); const pid = await wrapper.out('pid');
process.kill(-pid, 'SIGTERM'); process.kill(-pid, 'SIGTERM');
expect(await wrapper.out('exitCode')).toBe('null'); expect(await wrapper.out('exitCode')).toBe('null');
@ -138,7 +137,7 @@ it.skip(WIN || !HEADLESS).slow()('should report browser close signal', async ({w
await wrapper.childExitCode(); await wrapper.childExitCode();
}); });
it.skip(WIN || !HEADLESS).slow()('should report browser close signal 2', async ({wrapper}) => { it.skip(WIN || !options.HEADLESS).slow()('should report browser close signal 2', async ({wrapper}) => {
const pid = await wrapper.out('pid'); const pid = await wrapper.out('pid');
process.kill(-pid, 'SIGKILL'); process.kill(-pid, 'SIGKILL');
expect(await wrapper.out('exitCode')).toBe('null'); expect(await wrapper.out('exitCode')).toBe('null');
@ -147,28 +146,28 @@ it.skip(WIN || !HEADLESS).slow()('should report browser close signal 2', async (
await wrapper.childExitCode(); await wrapper.childExitCode();
}); });
it.skip(WIN || !HEADLESS).slow()('should close the browser on SIGINT', async ({wrapper}) => { it.skip(WIN || !options.HEADLESS).slow()('should close the browser on SIGINT', async ({wrapper}) => {
process.kill(wrapper.child().pid, 'SIGINT'); process.kill(wrapper.child().pid, 'SIGINT');
expect(await wrapper.out('exitCode')).toBe('0'); expect(await wrapper.out('exitCode')).toBe('0');
expect(await wrapper.out('signal')).toBe('null'); expect(await wrapper.out('signal')).toBe('null');
expect(await wrapper.childExitCode()).toBe(130); expect(await wrapper.childExitCode()).toBe(130);
}); });
it.skip(WIN || !HEADLESS).slow()('should close the browser on SIGTERM', async ({wrapper}) => { it.skip(WIN || !options.HEADLESS).slow()('should close the browser on SIGTERM', async ({wrapper}) => {
process.kill(wrapper.child().pid, 'SIGTERM'); process.kill(wrapper.child().pid, 'SIGTERM');
expect(await wrapper.out('exitCode')).toBe('0'); expect(await wrapper.out('exitCode')).toBe('0');
expect(await wrapper.out('signal')).toBe('null'); expect(await wrapper.out('signal')).toBe('null');
expect(await wrapper.childExitCode()).toBe(0); expect(await wrapper.childExitCode()).toBe(0);
}); });
it.skip(WIN || !HEADLESS).slow()('should close the browser on SIGHUP', async ({wrapper}) => { it.skip(WIN || !options.HEADLESS).slow()('should close the browser on SIGHUP', async ({wrapper}) => {
process.kill(wrapper.child().pid, 'SIGHUP'); process.kill(wrapper.child().pid, 'SIGHUP');
expect(await wrapper.out('exitCode')).toBe('0'); expect(await wrapper.out('exitCode')).toBe('0');
expect(await wrapper.out('signal')).toBe('null'); expect(await wrapper.out('signal')).toBe('null');
expect(await wrapper.childExitCode()).toBe(0); expect(await wrapper.childExitCode()).toBe(0);
}); });
it.skip(WIN || !HEADLESS).slow()('should kill the browser on double SIGINT', async ({stallingWrapper}) => { it.skip(WIN || !options.HEADLESS).slow()('should kill the browser on double SIGINT', async ({stallingWrapper}) => {
const wrapper = stallingWrapper; const wrapper = stallingWrapper;
process.kill(wrapper.child().pid, 'SIGINT'); process.kill(wrapper.child().pid, 'SIGINT');
await wrapper.out('stalled'); await wrapper.out('stalled');
@ -178,7 +177,7 @@ it.skip(WIN || !HEADLESS).slow()('should kill the browser on double SIGINT', asy
expect(await wrapper.childExitCode()).toBe(130); expect(await wrapper.childExitCode()).toBe(130);
}); });
it.skip(WIN || !HEADLESS).slow()('should kill the browser on SIGINT + SIGTERM', async ({stallingWrapper}) => { it.skip(WIN || !options.HEADLESS).slow()('should kill the browser on SIGINT + SIGTERM', async ({stallingWrapper}) => {
const wrapper = stallingWrapper; const wrapper = stallingWrapper;
process.kill(wrapper.child().pid, 'SIGINT'); process.kill(wrapper.child().pid, 'SIGINT');
await wrapper.out('stalled'); await wrapper.out('stalled');
@ -188,7 +187,7 @@ it.skip(WIN || !HEADLESS).slow()('should kill the browser on SIGINT + SIGTERM',
expect(await wrapper.childExitCode()).toBe(0); expect(await wrapper.childExitCode()).toBe(0);
}); });
it.skip(WIN || !HEADLESS).slow()('should kill the browser on SIGTERM + SIGINT', async ({stallingWrapper}) => { it.skip(WIN || !options.HEADLESS).slow()('should kill the browser on SIGTERM + SIGINT', async ({stallingWrapper}) => {
const wrapper = stallingWrapper; const wrapper = stallingWrapper;
process.kill(wrapper.child().pid, 'SIGTERM'); process.kill(wrapper.child().pid, 'SIGTERM');
await wrapper.out('stalled'); await wrapper.out('stalled');

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const { WIRE } = testOptions;
it('should have different execution contexts', async ({ page, server }) => { it('should have different execution contexts', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
@ -36,27 +35,27 @@ it('should have correct execution contexts', async ({ page, server }) => {
expect(await page.frames()[1].evaluate(() => document.body.textContent.trim())).toBe(`Hi, I'm frame`); expect(await page.frames()[1].evaluate(() => document.body.textContent.trim())).toBe(`Hi, I'm frame`);
}); });
function expectContexts(pageImpl, count, isChromium) { function expectContexts(pageImpl, count) {
if (isChromium) 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);
} }
it.skip(WIRE)('should dispose context on navigation', async ({ page, server, toImpl, isChromium }) => { it.skip(options.WIRE)('should dispose context on navigation', async ({ page, server, toImpl }) => {
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);
expectContexts(toImpl(page), 4, isChromium); expectContexts(toImpl(page), 4);
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
expectContexts(toImpl(page), 2, isChromium); expectContexts(toImpl(page), 2);
}); });
it.skip(WIRE)('should dispose context on cross-origin navigation', async ({ page, server, toImpl, isChromium }) => { it.skip(options.WIRE)('should dispose context on cross-origin navigation', async ({ page, server, toImpl }) => {
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');
expect(page.frames().length).toBe(2); expect(page.frames().length).toBe(2);
expectContexts(toImpl(page), 4, isChromium); expectContexts(toImpl(page), 4);
await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html'); await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html');
expectContexts(toImpl(page), 2, isChromium); expectContexts(toImpl(page), 2);
}); });
it('should execute after cross-site navigation', async ({ page, server }) => { it('should execute after cross-site navigation', async ({ page, server }) => {

View file

@ -350,21 +350,21 @@ it.skip(!MAC)('should support MacOS shortcuts', async ({page, server}) => {
expect(await page.$eval('textarea', textarea => textarea.value)).toBe('some '); expect(await page.$eval('textarea', textarea => textarea.value)).toBe('some ');
}); });
it('should press the meta key', async ({page, isFirefox}) => { 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 (isFirefox && !MAC) if (options.FFOX && !MAC)
expect(key).toBe('OS'); expect(key).toBe('OS');
else else
expect(key).toBe('Meta'); expect(key).toBe('Meta');
if (isFirefox) if (options.FFOX)
expect(code).toBe('OSLeft'); expect(code).toBe('OSLeft');
else else
expect(code).toBe('MetaLeft'); expect(code).toBe('MetaLeft');
if (isFirefox && !MAC) if (options.FFOX && !MAC)
expect(metaKey).toBe(false); expect(metaKey).toBe(false);
else else
expect(metaKey).toBe(true); expect(metaKey).toBe(true);

View file

@ -121,12 +121,12 @@ it('should trigger hover state with removed window.Node', async({page, server})
expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6'); expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6');
}); });
it('should set modifier keys on click', async({page, server, isFirefox}) => { it('should set modifier keys on click', async({page, server}) => {
await page.goto(server.PREFIX + '/input/scrollable.html'); await page.goto(server.PREFIX + '/input/scrollable.html');
await page.evaluate(() => document.querySelector('#button-3').addEventListener('mousedown', e => window["lastEvent"] = e, true)); await page.evaluate(() => document.querySelector('#button-3').addEventListener('mousedown', e => window["lastEvent"] = e, true));
const modifiers = {'Shift': 'shiftKey', 'Control': 'ctrlKey', 'Alt': 'altKey', 'Meta': 'metaKey'}; 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 (isFirefox && !MAC) if (options.FFOX && !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);
@ -142,9 +142,9 @@ it('should set modifier keys on click', async({page, server, isFirefox}) => {
} }
}); });
it('should tween mouse movement', async({page, isWebKit}) => { 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 (isWebKit) 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(() => {

View file

@ -16,9 +16,8 @@
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
it.skip(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);
const browser1 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const browser1 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
expect(browser1.contexts().length).toBe(0); expect(browser1.contexts().length).toBe(0);
@ -38,7 +37,7 @@ it.skip(WIRE)('should work across sessions', async ({browserType, defaultBrowser
await browserServer.close(); await browserServer.close();
}); });
it.skip(WIRE).slow()('should be emitted when: browser gets closed, disconnected or underlying websocket gets closed', async ({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE).slow()('should be emitted when: browser gets closed, disconnected or underlying websocket gets closed', async ({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const originalBrowser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const originalBrowser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
const wsEndpoint = browserServer.wsEndpoint(); const wsEndpoint = browserServer.wsEndpoint();
@ -72,7 +71,7 @@ it.skip(WIRE).slow()('should be emitted when: browser gets closed, disconnected
expect(disconnectedRemote2).toBe(1); expect(disconnectedRemote2).toBe(1);
}); });
it.skip(WIRE)('should be able to connect multiple times to the same browser', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should be able to connect multiple times to the same browser', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
const browser1 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const browser1 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
const browser2 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const browser2 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
@ -86,7 +85,7 @@ it.skip(WIRE)('should be able to connect multiple times to the same browser', as
await browserServer.close(); await browserServer.close();
}); });
it.skip(WIRE)('should not be able to close remote browser', async({browserType, defaultBrowserOptions}) => { it.skip(options.WIRE)('should not be able to close remote browser', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);
{ {
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() }); const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });

View file

@ -45,13 +45,13 @@ it('should work for fetch requests', async({page, server}) => {
expect(requests[0].frame()).toBe(page.mainFrame()); expect(requests[0].frame()).toBe(page.mainFrame());
}); });
it('should return headers', async({page, server, isChromium, isFirefox, isWebKit}) => { it('should return headers', async({page, server}) => {
const response = await page.goto(server.EMPTY_PAGE); const response = await page.goto(server.EMPTY_PAGE);
if (isChromium) if (options.CHROMIUM)
expect(response.request().headers()['user-agent']).toContain('Chrome'); expect(response.request().headers()['user-agent']).toContain('Chrome');
else if (isFirefox) else if (options.FFOX)
expect(response.request().headers()['user-agent']).toContain('Firefox'); expect(response.request().headers()['user-agent']).toContain('Firefox');
else if (isWebKit) else if (options.WEBKIT)
expect(response.request().headers()['user-agent']).toContain('WebKit'); expect(response.request().headers()['user-agent']).toContain('WebKit');
}); });

View file

@ -33,7 +33,7 @@ it('should not be visible in context.pages', async({context}) => {
expect(context.pages()).not.toContain(newPage); expect(context.pages()).not.toContain(newPage);
}); });
it('should run beforeunload if asked for', async({context, server, isChromium, isWebKit}) => { it('should run beforeunload if asked for', async({context, server}) => {
const newPage = await context.newPage(); const newPage = await context.newPage();
await newPage.goto(server.PREFIX + '/beforeunload.html'); await newPage.goto(server.PREFIX + '/beforeunload.html');
// We have to interact with a page so that 'beforeunload' handlers // We have to interact with a page so that 'beforeunload' handlers
@ -43,9 +43,9 @@ it('should run beforeunload if asked for', async({context, server, isChromium, i
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 (isChromium) if (options.CHROMIUM)
expect(dialog.message()).toBe(''); expect(dialog.message()).toBe('');
else if (isWebKit) 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.');
@ -196,7 +196,7 @@ it('page.frame should respect url', async function({page, server}) {
expect(page.frame({ url: /empty/ }).url()).toBe(server.EMPTY_PAGE); expect(page.frame({ url: /empty/ }).url()).toBe(server.EMPTY_PAGE);
}); });
it('should have sane user agent', async ({page, isChromium, isFirefox}) => { it('should have sane user agent', async ({page}) => {
const userAgent = await page.evaluate(() => navigator.userAgent); const userAgent = await page.evaluate(() => navigator.userAgent);
const [ const [
part1, part1,
@ -210,7 +210,7 @@ it('should have sane user agent', async ({page, isChromium, isFirefox}) => {
// 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 (isFirefox) { if (options.FFOX) {
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);
@ -224,7 +224,7 @@ it('should have sane user agent', async ({page, isChromium, isFirefox}) => {
// 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 (isChromium) 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);

View file

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
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);
@ -433,7 +432,7 @@ it('should not throw an error when evaluation does a synchronous navigation and
expect(result).toBe(undefined); expect(result).toBe(undefined);
}); });
it.fail(WIRE)('should transfer 100Mb of data from page to node.js', async ({ page }) => { it.fail(options.WIRE)('should transfer 100Mb of data from page to node.js', async ({ page }) => {
// This is too slow with wire. // This is too slow with wire.
const a = await page.evaluate(() => Array(100 * 1024 * 1024 + 1).join('a')); const a = await page.evaluate(() => Array(100 * 1024 * 1024 + 1).join('a'));
expect(a.length).toBe(100 * 1024 * 1024); expect(a.length).toBe(100 * 1024 * 1024);

View file

@ -16,9 +16,8 @@
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
const CRASH_FAIL = (options.FFOX && WIN) || WIRE; const CRASH_FAIL = (options.FFOX && 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

@ -40,7 +40,7 @@ it('Page.Events.Response', async({page, server}) => {
expect(responses[0].request()).toBeTruthy(); expect(responses[0].request()).toBeTruthy();
}); });
it('Page.Events.RequestFailed', async({page, server, isChromium, isWebKit}) => { it('Page.Events.RequestFailed', async({page, server}) => {
server.setRoute('/one-style.css', (req, res) => { server.setRoute('/one-style.css', (req, res) => {
res.setHeader('Content-Type', 'text/css'); res.setHeader('Content-Type', 'text/css');
res.connection.destroy(); res.connection.destroy();
@ -52,9 +52,9 @@ it('Page.Events.RequestFailed', async({page, server, isChromium, isWebKit}) => {
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 (isChromium) { 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 (isWebKit) { } 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

@ -16,7 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
it('should fire', async({page, server, isWebKit}) => { it('should fire', 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'),
@ -25,7 +25,7 @@ it('should fire', async({page, server, isWebKit}) => {
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 (isWebKit) 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);
}); });

View file

@ -133,7 +133,7 @@ it('should work with subframes return 204 with domcontentloaded', async({page, s
await page.goto(server.PREFIX + '/frames/one-frame.html', { waitUntil: 'domcontentloaded' }); await page.goto(server.PREFIX + '/frames/one-frame.html', { waitUntil: 'domcontentloaded' });
}); });
it('should fail when server returns 204', async({page, server, isChromium, isWebKit}) => { it('should fail when server returns 204', async({page, server}) => {
// Webkit just loads an empty page. // Webkit just loads an empty page.
server.setRoute('/empty.html', (req, res) => { server.setRoute('/empty.html', (req, res) => {
res.statusCode = 204; res.statusCode = 204;
@ -142,9 +142,9 @@ it('should fail when server returns 204', async({page, server, isChromium, isWeb
let error = null; let error = null;
await page.goto(server.EMPTY_PAGE).catch(e => error = e); await page.goto(server.EMPTY_PAGE).catch(e => error = e);
expect(error).not.toBe(null); expect(error).not.toBe(null);
if (isChromium) if (options.CHROMIUM)
expect(error.message).toContain('net::ERR_ABORTED'); expect(error.message).toContain('net::ERR_ABORTED');
else if (isWebKit) else if (options.WEBKIT)
expect(error.message).toContain('Aborted: 204 No Content'); expect(error.message).toContain('Aborted: 204 No Content');
else else
expect(error.message).toContain('NS_BINDING_ABORTED'); expect(error.message).toContain('NS_BINDING_ABORTED');
@ -164,10 +164,10 @@ it('should work when page calls history API in beforeunload', async({page, serve
expect(response.status()).toBe(200); expect(response.status()).toBe(200);
}); });
it('should fail when navigating to bad url', async({page, server, isChromium, isWebKit}) => { it('should fail when navigating to bad url', async({page}) => {
let error = null; let error = null;
await page.goto('asdfasdf').catch(e => error = e); await page.goto('asdfasdf').catch(e => error = e);
if (isChromium || isWebKit) if (options.CHROMIUM || options.WEBKIT)
expect(error.message).toContain('Cannot navigate to invalid URL'); expect(error.message).toContain('Cannot navigate to invalid URL');
else else
expect(error.message).toContain('Invalid url'); expect(error.message).toContain('Invalid url');
@ -208,14 +208,14 @@ it('should throw if networkidle2 is passed as an option', async({page, server})
expect(error.message).toContain(`waitUntil: expected one of (load|domcontentloaded|networkidle)`); expect(error.message).toContain(`waitUntil: expected one of (load|domcontentloaded|networkidle)`);
}); });
it('should fail when main resources failed to load', async({page, server, isChromium, isWebKit}) => { it('should fail when main resources failed to load', async({page}) => {
let error = null; let error = null;
await page.goto('http://localhost:44123/non-existing-url').catch(e => error = e); await page.goto('http://localhost:44123/non-existing-url').catch(e => error = e);
if (isChromium) if (options.CHROMIUM)
expect(error.message).toContain('net::ERR_CONNECTION_REFUSED'); expect(error.message).toContain('net::ERR_CONNECTION_REFUSED');
else if (isWebKit && WIN) else if (options.WEBKIT && WIN)
expect(error.message).toContain(`Couldn\'t connect to server`); expect(error.message).toContain(`Couldn\'t connect to server`);
else if (isWebKit) else if (options.WEBKIT)
expect(error.message).toContain('Could not connect'); expect(error.message).toContain('Could not connect');
else else
expect(error.message).toContain('NS_ERROR_CONNECTION_REFUSED'); expect(error.message).toContain('NS_ERROR_CONNECTION_REFUSED');
@ -298,7 +298,7 @@ it('should disable timeout when its set to 0', async({page, server}) => {
expect(loaded).toBe(true); expect(loaded).toBe(true);
}); });
it('should fail when replaced by another navigation', async({page, server, isChromium, isWebKit}) => { it('should fail when replaced by another navigation', async({page, server}) => {
let anotherPromise; let anotherPromise;
server.setRoute('/empty.html', (req, res) => { server.setRoute('/empty.html', (req, res) => {
anotherPromise = page.goto(server.PREFIX + '/one-style.html'); anotherPromise = page.goto(server.PREFIX + '/one-style.html');
@ -306,9 +306,9 @@ it('should fail when replaced by another navigation', async({page, server, isChr
}); });
const error = await page.goto(server.PREFIX + '/empty.html').catch(e => e); const error = await page.goto(server.PREFIX + '/empty.html').catch(e => e);
await anotherPromise; await anotherPromise;
if (isChromium) if (options.CHROMIUM)
expect(error.message).toContain('net::ERR_ABORTED'); expect(error.message).toContain('net::ERR_ABORTED');
else if (isWebKit) else if (options.WEBKIT)
expect(error.message).toContain('cancelled'); expect(error.message).toContain('cancelled');
else else
expect(error.message).toContain('NS_BINDING_ABORTED'); expect(error.message).toContain('NS_BINDING_ABORTED');

View file

@ -182,15 +182,15 @@ it('should be abortable', async({page, server}) => {
expect(failed).toBe(true); expect(failed).toBe(true);
}); });
it('should be abortable with custom error codes', async({page, server, isWebKit, isFirefox}) => { it('should be abortable with custom error codes', async({page, server}) => {
await page.route('**/*', route => route.abort('internetdisconnected')); await page.route('**/*', route => route.abort('internetdisconnected'));
let failedRequest = null; let failedRequest = null;
page.on('requestfailed', request => failedRequest = request); page.on('requestfailed', request => failedRequest = request);
await page.goto(server.EMPTY_PAGE).catch(e => {}); await page.goto(server.EMPTY_PAGE).catch(e => {});
expect(failedRequest).toBeTruthy(); expect(failedRequest).toBeTruthy();
if (isWebKit) if (options.WEBKIT)
expect(failedRequest.failure().errorText).toBe('Request intercepted'); expect(failedRequest.failure().errorText).toBe('Request intercepted');
else if (isFirefox) else if (options.FFOX)
expect(failedRequest.failure().errorText).toBe('NS_ERROR_OFFLINE'); expect(failedRequest.failure().errorText).toBe('NS_ERROR_OFFLINE');
else else
expect(failedRequest.failure().errorText).toBe('net::ERR_INTERNET_DISCONNECTED'); expect(failedRequest.failure().errorText).toBe('net::ERR_INTERNET_DISCONNECTED');
@ -208,14 +208,14 @@ it('should send referer', async({page, server}) => {
expect(request.headers['referer']).toBe('http://google.com/'); expect(request.headers['referer']).toBe('http://google.com/');
}); });
it('should fail navigation when aborting main resource', async({page, server, isWebKit, isFirefox}) => { it('should fail navigation when aborting main resource', async({page, server}) => {
await page.route('**/*', route => route.abort()); await page.route('**/*', route => route.abort());
let error = null; let error = null;
await page.goto(server.EMPTY_PAGE).catch(e => error = e); await page.goto(server.EMPTY_PAGE).catch(e => error = e);
expect(error).toBeTruthy(); expect(error).toBeTruthy();
if (isWebKit) if (options.WEBKIT)
expect(error.message).toContain('Request intercepted'); expect(error.message).toContain('Request intercepted');
else if (isFirefox) else if (options.FFOX)
expect(error.message).toContain('NS_ERROR_FAILURE'); expect(error.message).toContain('NS_ERROR_FAILURE');
else else
expect(error.message).toContain('net::ERR_FAILED'); expect(error.message).toContain('net::ERR_FAILED');

View file

@ -19,10 +19,9 @@ import utils from './utils';
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
const { HEADLESS } = testOptions;
// Firefox headful produces a different image. // Firefox headful produces a different image.
const ffheadful = options.FFOX && !HEADLESS; const ffheadful = options.FFOX && !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});

View file

@ -20,10 +20,9 @@ import './base.fixture';
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
const { HEADLESS } = testOptions;
// Printing to pdf is currently only supported in headless chromium. // Printing to pdf is currently only supported in headless chromium.
it.skip(!(HEADLESS && options.CHROMIUM))('should be able to save file', async({page, tmpDir}) => { it.skip(!(options.HEADLESS && options.CHROMIUM))('should be able to save file', async({page, tmpDir}) => {
const outputFile = path.join(tmpDir, 'output.pdf'); const outputFile = path.join(tmpDir, 'output.pdf');
await page.pdf({path: outputFile}); await page.pdf({path: outputFile});
expect(fs.readFileSync(outputFile).byteLength).toBeGreaterThan(0); expect(fs.readFileSync(outputFile).byteLength).toBeGreaterThan(0);

View file

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
const { HEADLESS } = testOptions;
function getPermission(page, name) { function getPermission(page, name) {
return page.evaluate(name => navigator.permissions.query({name}).then(result => result.state), name); return page.evaluate(name => navigator.permissions.query({name}).then(result => result.state), name);
@ -92,7 +91,7 @@ describe.skip(options.WEBKIT)('permissions', () => {
expect(await getPermission(page, 'geolocation')).toBe('prompt'); expect(await getPermission(page, 'geolocation')).toBe('prompt');
}); });
it.fail(options.WEBKIT || options.FFOX || (options.CHROMIUM && !HEADLESS))('should trigger permission onchange', async({page, server, context}) => { it.fail(options.WEBKIT || options.FFOX || (options.CHROMIUM && !options.HEADLESS))('should trigger permission onchange', async({page, server, context}) => {
//TODO: flaky //TODO: flaky
// - Linux: https://github.com/microsoft/playwright/pull/1790/checks?check_run_id=587327883 // - Linux: https://github.com/microsoft/playwright/pull/1790/checks?check_run_id=587327883
// - Win: https://ci.appveyor.com/project/aslushnikov/playwright/builds/32402536 // - Win: https://ci.appveyor.com/project/aslushnikov/playwright/builds/32402536
@ -134,7 +133,7 @@ describe.skip(options.WEBKIT)('permissions', () => {
await otherContext.close(); await otherContext.close();
}); });
it.fail(options.WEBKIT || options.FFOX || (options.CHROMIUM && !HEADLESS))('should support clipboard read', async({page, server, context, browser}) => { it.fail(options.WEBKIT || options.FFOX || (options.CHROMIUM && !options.HEADLESS))('should support clipboard read', async({page, server, context, browser}) => {
// No such permissions (requires flag) in Firefox // No such permissions (requires flag) in Firefox
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
expect(await getPermission(page, 'clipboard-read')).toBe('prompt'); expect(await getPermission(page, 'clipboard-read')).toBe('prompt');

View file

@ -209,7 +209,7 @@ it('should expose function from browser context', async function({browser, serve
expect(messages.join('|')).toBe('page|binding'); expect(messages.join('|')).toBe('page|binding');
}); });
it('should not dispatch binding on a closed page', async function({browser, server, isFirefox}) { it('should not dispatch binding on a closed page', async function({browser, server}) {
const context = await browser.newContext(); const context = await browser.newContext();
const messages = []; const messages = [];
await context.exposeFunction('add', (a, b) => { await context.exposeFunction('add', (a, b) => {
@ -232,7 +232,7 @@ it('should not dispatch binding on a closed page', async function({browser, serv
}), }),
]); ]);
await context.close(); await context.close();
if (isFirefox) if (options.FFOX)
expect(messages.join('|')).toBe('alreadyclosed'); expect(messages.join('|')).toBe('alreadyclosed');
else else
expect(messages.join('|')).toBe('binding|close'); expect(messages.join('|')).toBe('binding|close');

View file

@ -19,7 +19,6 @@ import './base.fixture';
import socks from 'socksv5'; import socks from 'socksv5';
const { HEADLESS } = testOptions;
it('should use proxy', async ({browserType, defaultBrowserOptions, server}) => { it('should use proxy', async ({browserType, defaultBrowserOptions, server}) => {
server.setRoute('/target.html', async (req, res) => { server.setRoute('/target.html', async (req, res) => {
@ -57,7 +56,7 @@ it('should authenticate', async ({browserType, defaultBrowserOptions, server}) =
await browser.close(); await browser.close();
}); });
it.fail(options.CHROMIUM && !HEADLESS)('should exclude patterns', async ({browserType, defaultBrowserOptions, server}) => { it.fail(options.CHROMIUM && !options.HEADLESS)('should exclude patterns', async ({browserType, defaultBrowserOptions, server}) => {
// Chromium headful crashes with CHECK(!in_frame_tree_) in RenderFrameImpl::OnDeleteFrame. // Chromium headful crashes with CHECK(!in_frame_tree_) in RenderFrameImpl::OnDeleteFrame.
server.setRoute('/target.html', async (req, res) => { server.setRoute('/target.html', async (req, res) => {
res.end('<html><title>Served by the proxy</title></html>'); res.end('<html><title>Served by the proxy</title></html>');

View file

@ -19,7 +19,6 @@ import './base.fixture';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
const { HEADLESS } = testOptions;
it('should work', async({page, server}) => { it('should work', async({page, server}) => {
await page.route('**/*', route => { await page.route('**/*', route => {
@ -51,7 +50,7 @@ it('should work with status code 422', async({page, server}) => {
expect(await page.evaluate(() => document.body.textContent)).toBe('Yo, page!'); expect(await page.evaluate(() => document.body.textContent)).toBe('Yo, page!');
}); });
it.skip(options.FFOX && !HEADLESS)('should allow mocking binary responses', async({page, server, golden}) => { it.skip(options.FFOX && !options.HEADLESS)('should allow mocking binary responses', async({page, server, golden}) => {
// Firefox headful produces a different image. // Firefox headful produces a different image.
await page.route('**/*', route => { await page.route('**/*', route => {
const imageBuffer = fs.readFileSync(path.join(__dirname, 'assets', 'pptr.png')); const imageBuffer = fs.readFileSync(path.join(__dirname, 'assets', 'pptr.png'));
@ -70,7 +69,7 @@ it.skip(options.FFOX && !HEADLESS)('should allow mocking binary responses', asyn
expect(await img.screenshot()).toMatchImage(golden('mock-binary-response.png')); expect(await img.screenshot()).toMatchImage(golden('mock-binary-response.png'));
}); });
it.skip(options.FFOX && !HEADLESS)('should allow mocking svg with charset', async({page, server, golden}) => { it.skip(options.FFOX && !options.HEADLESS)('should allow mocking svg with charset', async({page, server, golden}) => {
// Firefox headful produces a different image. // Firefox headful produces a different image.
await page.route('**/*', route => { await page.route('**/*', route => {
route.fulfill({ route.fulfill({

View file

@ -204,6 +204,11 @@ function registerWorkerFixture(name, fn) {
innerRegisterFixture(name, 'worker', fn); innerRegisterFixture(name, 'worker', fn);
}; };
function registerOptionGenerator(name, fn) {
registerWorkerFixture(name, async ({}, test) => await test(options.browserName));
optionRegistrations.set(name, fn);
}
function registerOption(name, fn) { function registerOption(name, fn) {
optionRegistrations.set(name, fn); optionRegistrations.set(name, fn);
} }
@ -256,4 +261,4 @@ function computeWorkerHash(file) {
return hash.digest('hex'); return hash.digest('hex');
} }
module.exports = { FixturePool, registerFixture, registerWorkerFixture, computeWorkerHash, rerunRegistrations, lookupRegistrations, fixturesForCallback, registerOption, setOptions, optionRegistrations, options }; module.exports = { FixturePool, registerFixture, registerWorkerFixture, computeWorkerHash, rerunRegistrations, lookupRegistrations, fixturesForCallback, registerOption, registerOptionGenerator, setOptions, optionRegistrations, options };

View file

@ -21,7 +21,6 @@ const commonSuite = require('mocha/lib/interfaces/common');
Error.stackTraceLimit = 15; Error.stackTraceLimit = 15;
global.options = options; global.options = options;
global.testOptions = require('./testOptions');
global.registerFixture = registerFixture; global.registerFixture = registerFixture;
global.registerWorkerFixture = registerWorkerFixture; global.registerWorkerFixture = registerWorkerFixture;
global.registerOption = registerOption; global.registerOption = registerOption;

View file

@ -19,8 +19,6 @@ const Mocha = require('mocha');
const { fixturesForCallback, optionRegistrations } = require('./fixtures'); const { fixturesForCallback, optionRegistrations } = require('./fixtures');
const { fixturesUI } = require('./fixturesUI'); const { fixturesUI } = require('./fixturesUI');
global.testOptions = require('./testOptions');
class NullReporter {} class NullReporter {}
class TestCollector { class TestCollector {

View file

@ -1,24 +0,0 @@
/**
* Copyright Microsoft Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const os = require('os');
const { valueFromEnv } = require('./utils');
const testOptions = {};
testOptions.WIRE = process.env.PWWIRE;
testOptions.HEADLESS = !!valueFromEnv('HEADLESS', true);
module.exports = testOptions;

View file

@ -22,7 +22,6 @@ const { EventEmitter } = require('events');
const fixturePool = new FixturePool(); const fixturePool = new FixturePool();
global.expect = require('expect'); global.expect = require('expect');
global.testOptions = require('./testOptions');
const GoldenUtils = require('./GoldenUtils'); const GoldenUtils = require('./GoldenUtils');
class NullReporter {} class NullReporter {}

View file

@ -23,7 +23,6 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import url from 'url'; import url from 'url';
const { HEADLESS } = testOptions;
declare global { declare global {
interface FixtureState { interface FixtureState {
@ -182,7 +181,7 @@ it.fail(options.CHROMIUM)('should capture static page', async({page, tmpDir, vid
await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480}); await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480});
// TODO: in WebKit figure out why video size is not reported correctly for // TODO: in WebKit figure out why video size is not reported correctly for
// static pictures. // static pictures.
if (HEADLESS && options.WEBKIT) if (options.HEADLESS && options.WEBKIT)
await page.setViewportSize({width: 1270, height: 950}); await page.setViewportSize({width: 1270, height: 950});
await new Promise(r => setTimeout(r, 300)); await new Promise(r => setTimeout(r, 300));
await toImpl(page)._delegate.stopScreencast(); await toImpl(page)._delegate.stopScreencast();
@ -208,7 +207,7 @@ it.fail(options.CHROMIUM)('should capture navigation', async({page, tmpDir, serv
await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480}); await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480});
// TODO: in WebKit figure out why video size is not reported correctly for // TODO: in WebKit figure out why video size is not reported correctly for
// static pictures. // static pictures.
if (HEADLESS && options.WEBKIT) if (options.HEADLESS && options.WEBKIT)
await page.setViewportSize({width: 1270, height: 950}); await page.setViewportSize({width: 1270, height: 950});
await new Promise(r => setTimeout(r, 300)); await new Promise(r => setTimeout(r, 300));
await page.goto(server.CROSS_PROCESS_PREFIX + '/background-color.html#rgb(100,100,100)'); await page.goto(server.CROSS_PROCESS_PREFIX + '/background-color.html#rgb(100,100,100)');
@ -242,7 +241,7 @@ it.fail(options.CHROMIUM || (options.WEBKIT && WIN))('should capture css transfo
await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480}); await toImpl(page)._delegate.startScreencast({outputFile: videoFile, width: 640, height: 480});
// TODO: in WebKit figure out why video size is not reported correctly for // TODO: in WebKit figure out why video size is not reported correctly for
// static pictures. // static pictures.
if (HEADLESS && options.WEBKIT) if (options.HEADLESS && options.WEBKIT)
await page.setViewportSize({width: 1270, height: 950}); await page.setViewportSize({width: 1270, height: 950});
await new Promise(r => setTimeout(r, 300)); await new Promise(r => setTimeout(r, 300));
await toImpl(page)._delegate.stopScreencast(); await toImpl(page)._delegate.stopScreencast();

View file

@ -17,8 +17,6 @@ import './base.fixture';
import { attachFrame } from './utils'; import { attachFrame } from './utils';
const {WIRE} = testOptions;
async function checkSlowMo(toImpl, page, task) { async function checkSlowMo(toImpl, page, task) {
let didSlowMo = false; let didSlowMo = false;
const orig = toImpl(page)._doSlowMo; const orig = toImpl(page)._doSlowMo;
@ -47,67 +45,67 @@ async function checkPageSlowMo(toImpl, page, task) {
await checkSlowMo(toImpl, page, task); await checkSlowMo(toImpl, page, task);
} }
it.skip(WIRE)('Page SlowMo $$eval', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo $$eval', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.$$eval('button', () => void 0)); await checkPageSlowMo(toImpl, page, () => page.$$eval('button', () => void 0));
}); });
it.skip(WIRE)('Page SlowMo $eval', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo $eval', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.$eval('button', () => void 0)); await checkPageSlowMo(toImpl, page, () => page.$eval('button', () => void 0));
}); });
it.skip(WIRE)('Page SlowMo check', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo check', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.check('.check')); await checkPageSlowMo(toImpl, page, () => page.check('.check'));
}); });
it.skip(WIRE)('Page SlowMo click', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo click', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.click('button')); await checkPageSlowMo(toImpl, page, () => page.click('button'));
}); });
it.skip(WIRE)('Page SlowMo dblclick', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo dblclick', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.dblclick('button')); await checkPageSlowMo(toImpl, page, () => page.dblclick('button'));
}); });
it.skip(WIRE)('Page SlowMo dispatchEvent', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo dispatchEvent', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.dispatchEvent('button', 'click')); await checkPageSlowMo(toImpl, page, () => page.dispatchEvent('button', 'click'));
}); });
it.skip(WIRE)('Page SlowMo emulateMedia', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo emulateMedia', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.emulateMedia({media: 'print'})); await checkPageSlowMo(toImpl, page, () => page.emulateMedia({media: 'print'}));
}); });
it.skip(WIRE)('Page SlowMo evaluate', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo evaluate', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.evaluate(() => void 0)); await checkPageSlowMo(toImpl, page, () => page.evaluate(() => void 0));
}); });
it.skip(WIRE)('Page SlowMo evaluateHandle', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo evaluateHandle', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.evaluateHandle(() => window)); await checkPageSlowMo(toImpl, page, () => page.evaluateHandle(() => window));
}); });
it.skip(WIRE)('Page SlowMo fill', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo fill', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.fill('.fill', 'foo')); await checkPageSlowMo(toImpl, page, () => page.fill('.fill', 'foo'));
}); });
it.skip(WIRE)('Page SlowMo focus', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo focus', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.focus('button')); await checkPageSlowMo(toImpl, page, () => page.focus('button'));
}); });
it.skip(WIRE)('Page SlowMo goto', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo goto', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.goto('about:blank')); await checkPageSlowMo(toImpl, page, () => page.goto('about:blank'));
}); });
it.skip(WIRE)('Page SlowMo hover', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo hover', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.hover('button')); await checkPageSlowMo(toImpl, page, () => page.hover('button'));
}); });
it.skip(WIRE)('Page SlowMo press', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo press', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.press('button', 'Enter')); await checkPageSlowMo(toImpl, page, () => page.press('button', 'Enter'));
}); });
it.skip(WIRE)('Page SlowMo reload', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo reload', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.reload()); await checkPageSlowMo(toImpl, page, () => page.reload());
}); });
it.skip(WIRE)('Page SlowMo setContent', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo setContent', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.setContent('hello world')); await checkPageSlowMo(toImpl, page, () => page.setContent('hello world'));
}); });
it.skip(WIRE)('Page SlowMo selectOption', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo selectOption', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.selectOption('select', 'foo')); await checkPageSlowMo(toImpl, page, () => page.selectOption('select', 'foo'));
}); });
it.skip(WIRE)('Page SlowMo setInputFiles', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo setInputFiles', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.setInputFiles('.file', [])); await checkPageSlowMo(toImpl, page, () => page.setInputFiles('.file', []));
}); });
it.skip(WIRE)('Page SlowMo setViewportSize', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo setViewportSize', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.setViewportSize({height: 400, width: 400})); await checkPageSlowMo(toImpl, page, () => page.setViewportSize({height: 400, width: 400}));
}); });
it.skip(WIRE)('Page SlowMo type', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo type', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.type('.fill', 'a')); await checkPageSlowMo(toImpl, page, () => page.type('.fill', 'a'));
}); });
it.skip(WIRE)('Page SlowMo uncheck', async ({page, toImpl}) => { it.skip(options.WIRE)('Page SlowMo uncheck', async ({page, toImpl}) => {
await checkPageSlowMo(toImpl, page, () => page.uncheck('.uncheck')); await checkPageSlowMo(toImpl, page, () => page.uncheck('.uncheck'));
}); });
@ -126,58 +124,58 @@ async function checkFrameSlowMo(toImpl, page, server, task) {
await checkSlowMo(toImpl, page, task.bind(null, frame)); await checkSlowMo(toImpl, page, task.bind(null, frame));
} }
it.skip(WIRE)('Frame SlowMo $$eval', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo $$eval', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.$$eval('button', () => void 0)); await checkFrameSlowMo(toImpl, page, server, frame => frame.$$eval('button', () => void 0));
}); });
it.skip(WIRE)('Frame SlowMo $eval', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo $eval', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.$eval('button', () => void 0)); await checkFrameSlowMo(toImpl, page, server, frame => frame.$eval('button', () => void 0));
}); });
it.skip(WIRE)('Frame SlowMo check', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo check', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.check('.check')); await checkFrameSlowMo(toImpl, page, server, frame => frame.check('.check'));
}); });
it.skip(WIRE)('Frame SlowMo click', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo click', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.click('button')); await checkFrameSlowMo(toImpl, page, server, frame => frame.click('button'));
}); });
it.skip(WIRE)('Frame SlowMo dblclick', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo dblclick', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.dblclick('button')); await checkFrameSlowMo(toImpl, page, server, frame => frame.dblclick('button'));
}); });
it.skip(WIRE)('Frame SlowMo dispatchEvent', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo dispatchEvent', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.dispatchEvent('button', 'click')); await checkFrameSlowMo(toImpl, page, server, frame => frame.dispatchEvent('button', 'click'));
}); });
it.skip(WIRE)('Frame SlowMo evaluate', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo evaluate', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.evaluate(() => void 0)); await checkFrameSlowMo(toImpl, page, server, frame => frame.evaluate(() => void 0));
}); });
it.skip(WIRE)('Frame SlowMo evaluateHandle', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo evaluateHandle', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.evaluateHandle(() => window)); await checkFrameSlowMo(toImpl, page, server, frame => frame.evaluateHandle(() => window));
}); });
it.skip(WIRE)('Frame SlowMo fill', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo fill', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.fill('.fill', 'foo')); await checkFrameSlowMo(toImpl, page, server, frame => frame.fill('.fill', 'foo'));
}); });
it.skip(WIRE)('Frame SlowMo focus', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo focus', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.focus('button')); await checkFrameSlowMo(toImpl, page, server, frame => frame.focus('button'));
}); });
it.skip(WIRE)('Frame SlowMo goto', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo goto', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.goto('about:blank')); await checkFrameSlowMo(toImpl, page, server, frame => frame.goto('about:blank'));
}); });
it.skip(WIRE)('Frame SlowMo hover', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo hover', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.hover('button')); await checkFrameSlowMo(toImpl, page, server, frame => frame.hover('button'));
}); });
it.skip(WIRE)('Frame SlowMo press', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo press', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.press('button', 'Enter')); await checkFrameSlowMo(toImpl, page, server, frame => frame.press('button', 'Enter'));
}); });
it.skip(WIRE)('Frame SlowMo setContent', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo setContent', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.setContent('hello world')); await checkFrameSlowMo(toImpl, page, server, frame => frame.setContent('hello world'));
}); });
it.skip(WIRE)('Frame SlowMo selectOption', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo selectOption', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.selectOption('select', 'foo')); await checkFrameSlowMo(toImpl, page, server, frame => frame.selectOption('select', 'foo'));
}); });
it.skip(WIRE)('Frame SlowMo setInputFiles', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo setInputFiles', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.setInputFiles('.file', [])); await checkFrameSlowMo(toImpl, page, server, frame => frame.setInputFiles('.file', []));
}); });
it.skip(WIRE)('Frame SlowMo type', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo type', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.type('.fill', 'a')); await checkFrameSlowMo(toImpl, page, server, frame => frame.type('.fill', 'a'));
}); });
it.skip(WIRE)('Frame SlowMo uncheck', async({page, server, toImpl}) => { it.skip(options.WIRE)('Frame SlowMo uncheck', async({page, server, toImpl}) => {
await checkFrameSlowMo(toImpl, page, server, frame => frame.uncheck('.uncheck')); await checkFrameSlowMo(toImpl, page, server, frame => frame.uncheck('.uncheck'));
}); });
@ -195,51 +193,51 @@ async function checkElementSlowMo(toImpl, page, selector, task) {
const element = await page.$(selector); const element = await page.$(selector);
await checkSlowMo(toImpl, page, task.bind(null, element)); await checkSlowMo(toImpl, page, task.bind(null, element));
} }
it.skip(WIRE)('ElementHandle SlowMo $$eval', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo $$eval', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'body', element => element.$$eval('button', () => void 0)); await checkElementSlowMo(toImpl, page, 'body', element => element.$$eval('button', () => void 0));
}); });
it.skip(WIRE)('ElementHandle SlowMo $eval', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo $eval', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'body', element => element.$eval('button', () => void 0)); await checkElementSlowMo(toImpl, page, 'body', element => element.$eval('button', () => void 0));
}); });
it.skip(WIRE)('ElementHandle SlowMo check', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo check', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, '.check', element => element.check()); await checkElementSlowMo(toImpl, page, '.check', element => element.check());
}); });
it.skip(WIRE)('ElementHandle SlowMo click', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo click', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'button', element => element.click()); await checkElementSlowMo(toImpl, page, 'button', element => element.click());
}); });
it.skip(WIRE)('ElementHandle SlowMo dblclick', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo dblclick', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'button', element => element.dblclick()); await checkElementSlowMo(toImpl, page, 'button', element => element.dblclick());
}); });
it.skip(WIRE)('ElementHandle SlowMo dispatchEvent', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo dispatchEvent', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'button', element => element.dispatchEvent('click')); await checkElementSlowMo(toImpl, page, 'button', element => element.dispatchEvent('click'));
}); });
it.skip(WIRE)('ElementHandle SlowMo evaluate', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo evaluate', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'button', element => element.evaluate(() => void 0)); await checkElementSlowMo(toImpl, page, 'button', element => element.evaluate(() => void 0));
}); });
it.skip(WIRE)('ElementHandle SlowMo evaluateHandle', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo evaluateHandle', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'button', element => element.evaluateHandle(() => void 0)); await checkElementSlowMo(toImpl, page, 'button', element => element.evaluateHandle(() => void 0));
}); });
it.skip(WIRE)('ElementHandle SlowMo fill', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo fill', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, '.fill', element => element.fill('foo')); await checkElementSlowMo(toImpl, page, '.fill', element => element.fill('foo'));
}); });
it.skip(WIRE)('ElementHandle SlowMo focus', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo focus', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'button', element => element.focus()); await checkElementSlowMo(toImpl, page, 'button', element => element.focus());
}); });
it.skip(WIRE)('ElementHandle SlowMo hover', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo hover', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'button', element => element.hover()); await checkElementSlowMo(toImpl, page, 'button', element => element.hover());
}); });
it.skip(WIRE)('ElementHandle SlowMo press', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo press', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'button', element => element.press('Enter')); await checkElementSlowMo(toImpl, page, 'button', element => element.press('Enter'));
}); });
it.skip(WIRE)('ElementHandle SlowMo selectOption', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo selectOption', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, 'select', element => element.selectOption('foo')); await checkElementSlowMo(toImpl, page, 'select', element => element.selectOption('foo'));
}); });
it.skip(WIRE)('ElementHandle SlowMo setInputFiles', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo setInputFiles', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, '.file', element => element.setInputFiles([])); await checkElementSlowMo(toImpl, page, '.file', element => element.setInputFiles([]));
}); });
it.skip(WIRE)('ElementHandle SlowMo type', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo type', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, '.fill', element => element.type( 'a')); await checkElementSlowMo(toImpl, page, '.fill', element => element.type( 'a'));
}); });
it.skip(WIRE)('ElementHandle SlowMo uncheck', async ({page, toImpl}) => { it.skip(options.WIRE)('ElementHandle SlowMo uncheck', async ({page, toImpl}) => {
await checkElementSlowMo(toImpl, page, '.uncheck', element => element.uncheck()); await checkElementSlowMo(toImpl, page, '.uncheck', element => element.uncheck());
}); });

6
test/types.d.ts vendored
View file

@ -68,12 +68,6 @@ declare const afterAll: (inner: (state: WorkerState) => Promise<void>) => void;
declare const browserType: import('../index').BrowserType<import('../index').Browser>; declare const browserType: import('../index').BrowserType<import('../index').Browser>;
// global variables in assets
declare const testOptions: {
HEADLESS: boolean;
WIRE: boolean;
};
declare var MAC: boolean; declare var MAC: boolean;
declare var LINUX: boolean; declare var LINUX: boolean;
declare var WIN: boolean; declare var WIN: boolean;