test: slowly removing testOptions (#3464)

This commit is contained in:
Pavel Feldman 2020-08-14 07:22:54 -07:00 committed by GitHub
parent 036cd5ca41
commit 2f5a0a6c07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
128 changed files with 130 additions and 437 deletions

View file

@ -34,6 +34,7 @@ beforeEach(async () => {
afterEach(async () => { afterEach(async () => {
await page.close(); await page.close();
}); });
it('should work', async () => { it('should work', async () => {
await page.goto('https://www.example.com/'); await page.goto('https://www.example.com/');
expect(await page.title()).toBe('Example Domain'); expect(await page.title()).toBe('Example Domain');
@ -90,6 +91,7 @@ beforeEach(async() => {
afterEach(async () => { afterEach(async () => {
await page.close(); await page.close();
}); });
it('should work', async () => { it('should work', async () => {
await page.goto('https://www.example.com/'); await page.goto('https://www.example.com/');
assert.equal(await page.title(), 'Example Domain'); assert.equal(await page.title(), 'Example Domain');

View file

@ -16,8 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it('should work', async function({page}) { it('should work', async function({page}) {
await page.setContent(` await page.setContent(`
<head> <head>

View file

@ -15,10 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
import utils from './utils';
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 = [];

View file

@ -16,8 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
it('clicking on links which do not commit navigation', async({page, server, httpsServer}) => { it('clicking on links which do not commit navigation', async({page, server, httpsServer}) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await page.setContent(`<a href='${httpsServer.EMPTY_PAGE}'>foobar</a>`); await page.setContent(`<a href='${httpsServer.EMPTY_PAGE}'>foobar</a>`);

View file

@ -32,6 +32,7 @@ import {mkdtempAsync, removeFolderAsync} from './utils';
setUnderTest(); // Note: we must call setUnderTest before requiring Playwright setUnderTest(); // Note: we must call setUnderTest before requiring Playwright
const browserName = process.env.BROWSER || 'chromium'; const browserName = process.env.BROWSER || 'chromium';
const platform = os.platform();
declare global { declare global {
interface WorkerState { interface WorkerState {
@ -54,6 +55,13 @@ declare global {
} }
} }
(global as any).MAC = platform === 'darwin';
(global as any).LINUX = platform === 'linux';
(global as any).WIN = platform === 'win32';
(global as any).CHROMIUM = browserName === 'chromium';
(global as any).FFOX = browserName === 'firefox';
(global as any).WEBKIT = browserName === 'webkit';
registerWorkerFixture('parallelIndex', async ({}, test) => { registerWorkerFixture('parallelIndex', async ({}, test) => {
await test(parseInt(process.env.JEST_WORKER_ID, 10) - 1); await test(parseInt(process.env.JEST_WORKER_ID, 10) - 1);
}); });
@ -180,7 +188,7 @@ registerFixture('httpsServer', async ({httpService}, test) => {
registerFixture('tmpDir', async ({}, test) => { registerFixture('tmpDir', async ({}, test) => {
const tmpDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-')); const tmpDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-'));
await test(tmpDir); await test(tmpDir);
await removeFolderAsync(tmpDir); await removeFolderAsync(tmpDir).catch(e => {});
}); });
registerWorkerFixture('asset', async ({}, test) => { registerWorkerFixture('asset', async ({}, test) => {

View file

@ -16,7 +16,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {CHROMIUM} = testOptions;
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();

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {FFOX, CHROMIUM} = testOptions;
it('should work', async({context, page, server}) => { it('should work', async({context, page, server}) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await context.addCookies([{ await context.addCookies([{

View file

@ -18,8 +18,6 @@ import './base.fixture';
import utils from './utils'; import utils from './utils';
const {WEBKIT} = testOptions;
it('should create new context', async function({browser}) { it('should create new context', async function({browser}) {
expect(browser.contexts().length).toBe(0); expect(browser.contexts().length).toBe(0);
const context = await browser.newContext(); const context = await browser.newContext();

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {FFOX, WEBKIT, WIN} = testOptions;
it('should return no cookies in pristine browser context', async({context, page, server}) => { it('should return no cookies in pristine browser context', async({context, page, server}) => {
expect(await context.cookies()).toEqual([]); expect(await context.cookies()).toEqual([]);
}); });

View file

@ -16,8 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils'; const { HEADLESS } = testOptions;
const {CHROMIUM, HEADLESS} = testOptions;
it.fail(CHROMIUM && !HEADLESS)('should fail without credentials', async({browser, server}) => { it.fail(CHROMIUM && !HEADLESS)('should fail without credentials', async({browser, server}) => {
server.setAuth('/empty.html', 'user', 'pass'); server.setAuth('/empty.html', 'user', 'pass');

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {FFOX} = testOptions;
it.skip(FFOX)('should work', async({playwright, browser, server}) => { it.skip(FFOX)('should work', async({playwright, browser, server}) => {
const iPhone = playwright.devices['iPhone 6']; const iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone }); const context = await browser.newContext({ ...iPhone });

View file

@ -16,10 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions;
const {devices} = require('..');
it('expose binding should work', async({browser}) => { it('expose binding should work', async({browser}) => {
const context = await browser.newContext(); const context = await browser.newContext();
let bindingSource; let bindingSource;

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
it('should affect accept-language header', async({browser, server}) => { it('should affect accept-language header', async({browser, server}) => {
const context = await browser.newContext({ locale: 'fr-CH' }); const context = await browser.newContext({ locale: 'fr-CH' });
const page = await context.newPage(); const page = await context.newPage();

View file

@ -15,9 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions;
const {devices} = require('..');
it('should have url', async({browser, server}) => { it('should have url', async({browser, server}) => {
const context = await browser.newContext(); const context = await browser.newContext();

View file

@ -16,10 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions;
const {devices} = require('..');
it('should intercept', async({browser, server}) => { it('should intercept', async({browser, server}) => {
const context = await browser.newContext(); const context = await browser.newContext();
let intercepted = false; let intercepted = false;

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
it('should work', async ({ browser }) => { it('should work', async ({ browser }) => {
const func = () => new Date(1479579154987).toString(); const func = () => new Date(1479579154987).toString();
{ {

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, MAC, HEADLESS} = testOptions;
const {devices} = require('..'); const {devices} = require('..');
it('should work', async({browser, server}) => { it('should work', async({browser, server}) => {

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
it.skip(FFOX)('should support mobile emulation', async({playwright, browser, server}) => { it.skip(FFOX)('should support mobile emulation', async({playwright, browser, server}) => {
const iPhone = playwright.devices['iPhone 6']; const iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone }); const context = await browser.newContext({ ...iPhone });

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
it('should get the proper default viewport size', async({page, server}) => { it('should get the proper default viewport size', async({page, server}) => {
await utils.verifyViewport(page, 1280, 720); await utils.verifyViewport(page, 1280, 720);

View file

@ -14,12 +14,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import path from 'path';
import fs from 'fs'; import fs from 'fs';
import utils from './utils'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('browserType.executablePath should work', async({browserType}) => { it('browserType.executablePath should work', async({browserType}) => {
const executablePath = browserType.executablePath(); const executablePath = browserType.executablePath();

View file

@ -16,8 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils'; const { WIRE } = testOptions;
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it.skip(WIRE).slow()('should be able to reconnect to a browser', async({browserType, defaultBrowserOptions, server}) => { it.skip(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);

View file

@ -16,10 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path'; const { WIRE } = testOptions;
import fs from 'fs';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it.skip(WIRE)('should work', async({browserType, defaultBrowserOptions}) => { it.skip(WIRE)('should work', async({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);

View file

@ -14,12 +14,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import path from 'path'; import path from 'path';
import fs from 'fs'; import './base.fixture';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; 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);

View file

@ -13,12 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture';
import path from 'path';
import url from 'url'; import url from 'url';
import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT, WIN, LINUX} = testOptions;
it.fail(WEBKIT && WIN)('Web Assembly should work', async function({page, server}) { it.fail(WEBKIT && WIN)('Web Assembly should work', async function({page, server}) {
await page.goto(server.PREFIX + '/wasm/table2.html'); await page.goto(server.PREFIX + '/wasm/table2.html');

View file

@ -15,10 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
import { ChromiumBrowser } from '..'; import { ChromiumBrowser } from '..';
const { FFOX, CHROMIUM, WEBKIT, WIN } = testOptions;
it('should work', async({browser}) => { it('should work', async({browser}) => {
expect(!!browser['_connection']).toBeTruthy(); expect(!!browser['_connection']).toBeTruthy();

View file

@ -15,9 +15,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it.skip(!CHROMIUM)('should work', async function({browserType, page, server}) { it.skip(!CHROMIUM)('should work', async function({browserType, page, server}) {
await page.coverage.startCSSCoverage(); await page.coverage.startCSSCoverage();
await page.goto(server.PREFIX + '/csscoverage/simple.html'); await page.goto(server.PREFIX + '/csscoverage/simple.html');

View file

@ -15,9 +15,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it.skip(CHROMIUM)('should be missing', async function({page, server}) { it.skip(CHROMIUM)('should be missing', async function({page, server}) {
expect(page.coverage).toBe(null); expect(page.coverage).toBe(null);
}); });

View file

@ -16,8 +16,6 @@
import '../base.fixture'; import '../base.fixture';
import { ChromiumBrowserContext } from '../..'; import { ChromiumBrowserContext } from '../..';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it.skip(!CHROMIUM)('should create a worker from a service worker', async({page, server, context}) => { it.skip(!CHROMIUM)('should create a worker from a service worker', async({page, server, context}) => {
const [worker] = await Promise.all([ const [worker] = await Promise.all([
(context as ChromiumBrowserContext).waitForEvent('serviceworker'), (context as ChromiumBrowserContext).waitForEvent('serviceworker'),

View file

@ -18,8 +18,8 @@ import '../base.fixture';
import path from 'path'; import path from 'path';
import utils from '../utils'; import utils from '../utils';
import { ChromiumBrowser, ChromiumBrowserContext } from '../..'; import { ChromiumBrowser, ChromiumBrowserContext } from '../..';
const {makeUserDataDir, removeUserDataDir} = utils; const { makeUserDataDir, removeUserDataDir } = utils;
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; const { WIRE } = testOptions;
it.skip(WIRE || !CHROMIUM)('should throw with remote-debugging-pipe argument', async({browserType, defaultBrowserOptions}) => { it.skip(WIRE || !CHROMIUM)('should throw with remote-debugging-pipe argument', async({browserType, defaultBrowserOptions}) => {
const options = Object.assign({}, defaultBrowserOptions); const options = Object.assign({}, defaultBrowserOptions);

View file

@ -17,8 +17,6 @@
import '../base.fixture'; import '../base.fixture';
import { registerWorkerFixture } from '../runner/fixtures'; import { registerWorkerFixture } from '../runner/fixtures';
const {CHROMIUM} = testOptions;
registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => { registerWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => {
const browser = await browserType.launch({ const browser = await browserType.launch({
...defaultBrowserOptions, ...defaultBrowserOptions,

View file

@ -16,8 +16,6 @@
import '../base.fixture'; import '../base.fixture';
import { ChromiumBrowserContext, ChromiumBrowser } from "../../types/types"; import { ChromiumBrowserContext, ChromiumBrowser } from "../../types/types";
const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions;
it.skip(!CHROMIUM)('should work', async function({page}) { it.skip(!CHROMIUM)('should work', async function({page}) {
const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page); const client = await (page.context() as ChromiumBrowserContext).newCDPSession(page);

View file

@ -19,12 +19,13 @@ import { registerFixture } from '../runner/fixtures';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { ChromiumBrowser } from '../..'; import { ChromiumBrowser } from '../..';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
declare global { declare global {
interface FixtureState { interface FixtureState {
outputFile: string; outputFile: string;
} }
} }
registerFixture('outputFile', async ({tmpDir}, test) => { registerFixture('outputFile', async ({tmpDir}, test) => {
const outputFile = path.join(tmpDir, `trace.json`); const outputFile = path.join(tmpDir, `trace.json`);
await test(outputFile); await test(outputFile);

View file

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
declare const renderComponent; declare const renderComponent;
declare const e; declare const e;

View file

@ -16,8 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils'; const { WIRE } = testOptions;
const {WIRE} = testOptions;
it.skip(WIRE)('should avoid side effects after timeout', async({page, server}) => { it.skip(WIRE)('should avoid side effects after timeout', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const {WIRE} = testOptions;
it('should timeout waiting for display:none to be gone', async({page, server}) => { it('should timeout waiting for display:none to be gone', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', b => b.style.display = 'none'); await page.$eval('button', b => b.style.display = 'none');

View file

@ -16,8 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils'; const { WIRE } = testOptions;
const {WIRE} = testOptions;
it.skip(WIRE)('should fail when element jumps during hit testing', async({page, server}) => { it.skip(WIRE)('should fail when element jumps during hit testing', async({page, server}) => {
await page.setContent('<button>Click me</button>'); await page.setContent('<button>Click me</button>');

View file

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
it('should timeout waiting for stable position', async({page, server}) => { it('should timeout waiting for stable position', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');

View file

@ -15,9 +15,9 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, HEADLESS, WIRE} = testOptions;
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++)

View file

@ -16,33 +16,24 @@
*/ */
import './base.fixture'; import './base.fixture';
import { registerFixture } from './runner/fixtures'; import { registerFixture } from './runner/fixtures';
import fs from 'fs'; import fs from 'fs';
import path from 'path';
import utils from './utils'; import utils from './utils';
import os from 'os';
import { BrowserType, Browser, BrowserContext, Page } from '..'; import { BrowserType, Browser, BrowserContext, Page } from '..';
const {removeFolderAsync, mkdtempAsync, removeUserDataDir, makeUserDataDir} = utils; const { removeUserDataDir, makeUserDataDir } = utils;
const {FFOX, MAC, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions; const { WIRE } = testOptions;
declare global { declare global {
interface FixtureState { interface FixtureState {
userDataDir: string;
launchPersistent: (options?: Parameters<BrowserType<Browser>['launchPersistentContext']>[1]) => Promise<{context: BrowserContext, page: Page}>; launchPersistent: (options?: Parameters<BrowserType<Browser>['launchPersistentContext']>[1]) => Promise<{context: BrowserContext, page: Page}>;
} }
} }
registerFixture('userDataDir', async ({}, test) => {
const userDataDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright_dev_profile-'));
await test(userDataDir);
removeFolderAsync(userDataDir).catch(e => {});
});
registerFixture('launchPersistent', async ({userDataDir, defaultBrowserOptions, browserType}, test) => { registerFixture('launchPersistent', async ({tmpDir, defaultBrowserOptions, browserType}, test) => {
let context; let context;
async function launchPersistent(options) { async function launchPersistent(options) {
if (context) if (context)
throw new Error('can only launch one persitent context'); throw new Error('can only launch one persitent context');
context = await browserType.launchPersistentContext(userDataDir, {...defaultBrowserOptions, ...options}); context = await browserType.launchPersistentContext(tmpDir, {...defaultBrowserOptions, ...options});
const page = context.pages()[0]; const page = context.pages()[0];
return {context, page}; return {context, page};
} }
@ -275,14 +266,14 @@ it('should support extraHTTPHeaders option', async ({server, launchPersistent})
expect(request.headers['foo']).toBe('bar'); expect(request.headers['foo']).toBe('bar');
}); });
it('should accept userDataDir', async ({launchPersistent, userDataDir}) => { it('should accept userDataDir', async ({launchPersistent, tmpDir}) => {
const {page, context} = await launchPersistent(); const {page, context} = await launchPersistent();
// Note: we need an open page to make sure its functional. // Note: we need an open page to make sure its functional.
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); expect(fs.readdirSync(tmpDir).length).toBeGreaterThan(0);
await context.close(); await context.close();
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); expect(fs.readdirSync(tmpDir).length).toBeGreaterThan(0);
// This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778 // This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
await removeUserDataDir(userDataDir); await removeUserDataDir(tmpDir);
}); });
it.slow()('should restore state from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => { it.slow()('should restore state from userDataDir', async({browserType, defaultBrowserOptions, server, launchPersistent}) => {
@ -347,20 +338,20 @@ it('should have default URL when launching browser', async ({launchPersistent})
expect(urls).toEqual(['about:blank']); expect(urls).toEqual(['about:blank']);
}); });
it.skip(FFOX)('should throw if page argument is passed', async ({browserType, defaultBrowserOptions, server, userDataDir}) => { it.skip(FFOX)('should throw if page argument is passed', async ({browserType, defaultBrowserOptions, server, tmpDir}) => {
const options = {...defaultBrowserOptions, args: [server.EMPTY_PAGE] }; const options = {...defaultBrowserOptions, args: [server.EMPTY_PAGE] };
const error = await browserType.launchPersistentContext(userDataDir, options).catch(e => e); const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e);
expect(error.message).toContain('can not specify page'); expect(error.message).toContain('can not specify page');
}); });
it.skip(WIRE)('should have passed URL when launching with ignoreDefaultArgs: true', async ({browserType, defaultBrowserOptions, server, userDataDir, toImpl}) => { it.skip(WIRE)('should have passed URL when launching with ignoreDefaultArgs: true', async ({browserType, defaultBrowserOptions, server, tmpDir, toImpl}) => {
const args = toImpl(browserType)._defaultArgs(defaultBrowserOptions, 'persistent', userDataDir, 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,
args: [...args, server.EMPTY_PAGE], args: [...args, server.EMPTY_PAGE],
ignoreDefaultArgs: true, ignoreDefaultArgs: true,
}; };
const browserContext = await browserType.launchPersistentContext(userDataDir, options); const browserContext = await browserType.launchPersistentContext(tmpDir, options);
if (!browserContext.pages().length) if (!browserContext.pages().length)
await browserContext.waitForEvent('page'); await browserContext.waitForEvent('page');
await browserContext.pages()[0].waitForLoadState(); await browserContext.pages()[0].waitForLoadState();
@ -369,16 +360,16 @@ 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, userDataDir}) => { it.skip(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(userDataDir, 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, userDataDir}) => { it.skip(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(userDataDir, options).catch(e => e); const error = await browserType.launchPersistentContext(tmpDir, options).catch(e => e);
expect(error.message).toContain('Dummy'); expect(error.message).toContain('Dummy');
}); });

View file

@ -16,8 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it('should fire', async({page, server}) => { it('should fire', async({page, server}) => {
page.on('dialog', dialog => { page.on('dialog', dialog => {
expect(dialog.type()).toBe('alert'); expect(dialog.type()).toBe('alert');
@ -28,7 +26,7 @@ it('should fire', async({page, server}) => {
await page.evaluate(() => alert('yo')); await page.evaluate(() => alert('yo'));
}); });
it('should allow accepting prompts', async({page, server}) => { it('should allow accepting prompts', async({page}) => {
page.on('dialog', dialog => { page.on('dialog', dialog => {
expect(dialog.type()).toBe('prompt'); expect(dialog.type()).toBe('prompt');
expect(dialog.defaultValue()).toBe('yes.'); expect(dialog.defaultValue()).toBe('yes.');
@ -39,7 +37,7 @@ it('should allow accepting prompts', async({page, server}) => {
expect(result).toBe('answer!'); expect(result).toBe('answer!');
}); });
it('should dismiss the prompt', async({page, server}) => { it('should dismiss the prompt', async({page}) => {
page.on('dialog', dialog => { page.on('dialog', dialog => {
dialog.dismiss(); dialog.dismiss();
}); });
@ -47,7 +45,7 @@ it('should dismiss the prompt', async({page, server}) => {
expect(result).toBe(null); expect(result).toBe(null);
}); });
it('should accept the confirm prompt', async({page, server}) => { it('should accept the confirm prompt', async({page}) => {
page.on('dialog', dialog => { page.on('dialog', dialog => {
dialog.accept(); dialog.accept();
}); });
@ -55,7 +53,7 @@ it('should accept the confirm prompt', async({page, server}) => {
expect(result).toBe(true); expect(result).toBe(true);
}); });
it('should dismiss the confirm prompt', async({page, server}) => { it('should dismiss the confirm prompt', async({page}) => {
page.on('dialog', dialog => { page.on('dialog', dialog => {
dialog.dismiss(); dialog.dismiss();
}); });

View file

@ -16,7 +16,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('should dispatch click event', async({page, server}) => { it('should dispatch click event', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');
@ -32,7 +31,7 @@ it('should dispatch click event properties', async({page, server}) => {
expect(await page.evaluate('composed')).toBeTruthy(); expect(await page.evaluate('composed')).toBeTruthy();
}); });
it('should dispatch click svg', async({page, server}) => { it('should dispatch click svg', async({page}) => {
await page.setContent(` await page.setContent(`
<svg height="100" width="100"> <svg height="100" width="100">
<circle onclick="javascript:window.__CLICKED=42" cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /> <circle onclick="javascript:window.__CLICKED=42" cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />

View file

@ -19,7 +19,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import util from 'util'; import util from 'util';
const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions; const { HEADLESS } = testOptions;
beforeEach(async ({server}) => { beforeEach(async ({server}) => {
server.setRoute('/download', (req, res) => { server.setRoute('/download', (req, res) => {

View file

@ -24,18 +24,12 @@ import { Browser, BrowserContext } from '..';
declare global { declare global {
interface FixtureState { interface FixtureState {
downloadsPath: string;
downloadsBrowser: Browser; downloadsBrowser: Browser;
persistentDownloadsContext: BrowserContext; persistentDownloadsContext: BrowserContext;
} }
} }
registerFixture('downloadsPath', async ({}, test) => {
const downloadsPath = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-'));
await test(downloadsPath);
await removeFolderAsync(downloadsPath);
});
registerFixture('downloadsBrowser', async ({server, browserType, defaultBrowserOptions, downloadsPath}, test) => { registerFixture('downloadsBrowser', async ({server, browserType, defaultBrowserOptions, tmpDir}, test) => {
server.setRoute('/download', (req, res) => { server.setRoute('/download', (req, res) => {
res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Type', 'application/octet-stream');
res.setHeader('Content-Disposition', 'attachment; filename=file.txt'); res.setHeader('Content-Disposition', 'attachment; filename=file.txt');
@ -43,13 +37,13 @@ registerFixture('downloadsBrowser', async ({server, browserType, defaultBrowserO
}); });
const browser = await browserType.launch({ const browser = await browserType.launch({
...defaultBrowserOptions, ...defaultBrowserOptions,
downloadsPath: downloadsPath, downloadsPath: tmpDir,
}); });
await test(browser); await test(browser);
await browser.close(); await browser.close();
}); });
registerFixture('persistentDownloadsContext', async ({server, browserType, defaultBrowserOptions, downloadsPath}, test) => { registerFixture('persistentDownloadsContext', async ({server, browserType, defaultBrowserOptions, tmpDir}, test) => {
const userDataDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-')); const userDataDir = await mkdtempAsync(path.join(os.tmpdir(), 'playwright-test-'));
server.setRoute('/download', (req, res) => { server.setRoute('/download', (req, res) => {
res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Type', 'application/octet-stream');
@ -60,7 +54,7 @@ registerFixture('persistentDownloadsContext', async ({server, browserType, defau
userDataDir, userDataDir,
{ {
...defaultBrowserOptions, ...defaultBrowserOptions,
downloadsPath, downloadsPath: tmpDir,
acceptDownloads: true acceptDownloads: true
} }
); );
@ -71,7 +65,7 @@ registerFixture('persistentDownloadsContext', async ({server, browserType, defau
await removeFolderAsync(userDataDir); await removeFolderAsync(userDataDir);
}); });
it('should keep downloadsPath folder', async({downloadsBrowser, downloadsPath, server}) => { it('should keep downloadsPath folder', async({downloadsBrowser, tmpDir, server}) => {
const page = await downloadsBrowser.newPage(); const page = await downloadsBrowser.newPage();
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`); await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([ const [ download ] = await Promise.all([
@ -83,10 +77,10 @@ it('should keep downloadsPath folder', async({downloadsBrowser, downloadsPath, s
await download.path().catch(e => void 0); await download.path().catch(e => void 0);
await page.close(); await page.close();
await downloadsBrowser.close(); await downloadsBrowser.close();
expect(fs.existsSync(downloadsPath)).toBeTruthy(); expect(fs.existsSync(tmpDir)).toBeTruthy();
}); });
it('should delete downloads when context closes', async({downloadsBrowser, downloadsPath, server}) => { it('should delete downloads when context closes', async({downloadsBrowser, server}) => {
const page = await downloadsBrowser.newPage({ acceptDownloads: true }); const page = await downloadsBrowser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`); await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([ const [ download ] = await Promise.all([
@ -100,7 +94,7 @@ it('should delete downloads when context closes', async({downloadsBrowser, downl
}); });
it('should report downloads in downloadsPath folder', async({downloadsBrowser, downloadsPath, server}) => { it('should report downloads in downloadsPath folder', async({downloadsBrowser, tmpDir, server}) => {
const page = await downloadsBrowser.newPage({ acceptDownloads: true }); const page = await downloadsBrowser.newPage({ acceptDownloads: true });
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`); await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
const [ download ] = await Promise.all([ const [ download ] = await Promise.all([
@ -108,11 +102,11 @@ it('should report downloads in downloadsPath folder', async({downloadsBrowser, d
page.click('a') page.click('a')
]); ]);
const path = await download.path(); const path = await download.path();
expect(path.startsWith(downloadsPath)).toBeTruthy(); expect(path.startsWith(tmpDir)).toBeTruthy();
await page.close(); await page.close();
}); });
it('should accept downloads', async({persistentDownloadsContext, downloadsPath, server}) => { it('should accept downloads', async({persistentDownloadsContext, tmpDir, server}) => {
const page = persistentDownloadsContext.pages()[0]; const page = persistentDownloadsContext.pages()[0];
const [ download ] = await Promise.all([ const [ download ] = await Promise.all([
page.waitForEvent('download'), page.waitForEvent('download'),
@ -121,7 +115,7 @@ it('should accept downloads', async({persistentDownloadsContext, downloadsPath,
expect(download.url()).toBe(`${server.PREFIX}/download`); expect(download.url()).toBe(`${server.PREFIX}/download`);
expect(download.suggestedFilename()).toBe(`file.txt`); expect(download.suggestedFilename()).toBe(`file.txt`);
const path = await download.path(); const path = await download.path();
expect(path.startsWith(downloadsPath)).toBeTruthy(); expect(path.startsWith(tmpDir)).toBeTruthy();
}); });
it('should not delete downloads when the context closes', async({persistentDownloadsContext}) => { it('should not delete downloads when the context closes', async({persistentDownloadsContext}) => {

View file

@ -18,8 +18,6 @@ import './electron.fixture';
import path from 'path'; import path from 'path';
const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron'; const electronName = process.platform === 'win32' ? 'electron.cmd' : 'electron';
const { CHROMIUM } = testOptions;
it.skip(!CHROMIUM)('should fire close event', async ({ playwright }) => { it.skip(!CHROMIUM)('should fire close event', async ({ playwright }) => {
const electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName); const electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', electronName);

View file

@ -15,8 +15,6 @@
*/ */
import './electron.fixture'; import './electron.fixture';
const { CHROMIUM } = testOptions;
it.skip(!CHROMIUM)('should click the button', async({window, server}) => { it.skip(!CHROMIUM)('should click the button', async({window, server}) => {
await window.goto(server.PREFIX + '/input/button.html'); await window.goto(server.PREFIX + '/input/button.html');
await window.click('button'); await window.click('button');

View file

@ -16,8 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils'; const { HEADLESS } = testOptions;
const { FFOX, HEADLESS } = testOptions;
it.fail(FFOX && !HEADLESS)('should work', async ({ page, server }) => { it.fail(FFOX && !HEADLESS)('should work', async ({ page, server }) => {
await page.setViewportSize({ width: 500, height: 500 }); await page.setViewportSize({ width: 500, height: 500 });

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should work', async ({ page, server }) => { it('should work', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/button.html'); await page.goto(server.PREFIX + '/input/button.html');
const button = await page.$('button'); const button = await page.$('button');

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should work', async ({ page, server }) => { it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should have a nice preview', async ({ page, server }) => { it('should have a nice preview', async ({ page, server }) => {
await page.goto(`${server.PREFIX}/dom.html`); await page.goto(`${server.PREFIX}/dom.html`);

View file

@ -16,10 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions;
it('should work', async({page, server}) => { it('should work', async({page, server}) => {
await page.setContent('<html><body><div class="tweet"><div class="like">100</div><div class="retweets">10</div></div></body></html>'); await page.setContent('<html><body><div class="tweet"><div class="like">100</div><div class="retweets">10</div></div></body></html>');
const tweet = await page.$('.tweet'); const tweet = await page.$('.tweet');

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should hover', async ({ page, server }) => { it('should hover', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/scrollable.html'); await page.goto(server.PREFIX + '/input/scrollable.html');
const button = await page.$('#button-6'); const button = await page.$('#button-6');

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should work', async ({ page, server }) => { it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should work', async ({ page }) => { it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`); await page.setContent(`<input type='text' />`);
await page.press('input', 'h'); await page.press('input', 'h');

View file

@ -16,10 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions;
it('should query existing element', async({page, server}) => { it('should query existing element', async({page, server}) => {
await page.goto(server.PREFIX + '/playground.html'); await page.goto(server.PREFIX + '/playground.html');
await page.setContent('<html><body><div class="second"><div class="inner">A</div></div></body></html>'); await page.setContent('<html><body><div class="second"><div class="inner">A</div></div></body></html>');

View file

@ -17,7 +17,7 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIRE, HEADLESS} = testOptions; const {WIRE, HEADLESS} = testOptions;
import {PNG} from 'pngjs'; import {PNG} from 'pngjs';
// Firefox headful produces a different image. // Firefox headful produces a different image.

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should work', async ({ page, server }) => { it('should work', async ({ page, server }) => {
await page.goto(server.PREFIX + '/offscreenbuttons.html'); await page.goto(server.PREFIX + '/offscreenbuttons.html');
for (let i = 0; i < 11; ++i) { for (let i = 0; i < 11; ++i) {

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should select textarea', async ({ page, server }) => { it('should select textarea', async ({ page, server }) => {
await page.goto(server.PREFIX + '/input/textarea.html'); await page.goto(server.PREFIX + '/input/textarea.html');
const textarea = await page.$('textarea'); const textarea = await page.$('textarea');

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
const { FFOX, HEADLESS } = testOptions;
it('should work', async ({ page }) => { it('should work', async ({ page }) => {
await page.setContent(`<input type='text' />`); await page.setContent(`<input type='text' />`);
await page.type('input', 'hello'); await page.type('input', 'hello');

View file

@ -17,7 +17,7 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions; 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);

View file

@ -16,10 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions;
it('should work with css selector', async({page, server}) => { it('should work with css selector', async({page, server}) => {
await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>'); await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>');
const divsCount = await page.$$eval('css=div', divs => divs.length); const divsCount = await page.$$eval('css=div', divs => divs.length);

View file

@ -16,10 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions;
it('should work with css selector', async({page, server}) => { it('should work with css selector', async({page, server}) => {
await page.setContent('<section id="testAttribute">43543</section>'); await page.setContent('<section id="testAttribute">43543</section>');
const idAttribute = await page.$eval('css=section', e => e.id); const idAttribute = await page.$eval('css=section', e => e.id);

View file

@ -15,8 +15,6 @@
*/ */
import '../base.fixture'; import '../base.fixture';
const { FFOX } = testOptions;
it.skip(!FFOX)('should pass firefox user preferences', async({browserType, defaultBrowserOptions}) => { it.skip(!FFOX)('should pass firefox user preferences', async({browserType, defaultBrowserOptions}) => {
const browser = await browserType.launch({ const browser = await browserType.launch({
...defaultBrowserOptions, ...defaultBrowserOptions,

View file

@ -20,7 +20,7 @@ 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 {FFOX, CHROMIUM, WEBKIT, WIN, LINUX, HEADLESS} = testOptions; const { HEADLESS } = testOptions;
const playwrightPath = path.join(__dirname, '..'); const playwrightPath = path.join(__dirname, '..');

View file

@ -15,8 +15,6 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, LINUX, WEBKIT, MAC} = testOptions;
it('should work', async function({page, server}) { it('should work', async function({page, server}) {
await page.setContent(`<div id=d1 tabIndex=0></div>`); await page.setContent(`<div id=d1 tabIndex=0></div>`);
expect(await page.evaluate(() => document.activeElement.nodeName)).toBe('BODY'); expect(await page.evaluate(() => document.activeElement.nodeName)).toBe('BODY');

View file

@ -17,8 +17,7 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
import path from 'path'; const { WIRE } = testOptions;
const { FFOX, CHROMIUM, WEBKIT, 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);

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it('should work', async({page, server}) => { it('should work', async({page, server}) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);

View file

@ -17,9 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
import path from 'path';
import url from 'url';
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;
it('should navigate subframes', async({page, server}) => { it('should navigate subframes', async({page, server}) => {
await page.goto(server.PREFIX + '/frames/one-frame.html'); await page.goto(server.PREFIX + '/frames/one-frame.html');

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it('should handle nested frames', async({page, server}) => { it('should handle nested frames', async({page, server}) => {
await page.goto(server.PREFIX + '/frames/nested-frames.html'); await page.goto(server.PREFIX + '/frames/nested-frames.html');

View file

@ -16,8 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it('should work', async({page, server, context}) => { it('should work', async({page, server, context}) => {
await context.grantPermissions(['geolocation']); await context.grantPermissions(['geolocation']);
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);

View file

@ -17,15 +17,12 @@ import './base.fixture';
import utils from './utils'; import utils from './utils';
const { makeUserDataDir, removeUserDataDir } = utils; const { makeUserDataDir, removeUserDataDir } = utils;
const {FFOX, CHROMIUM, WEBKIT, WIN, MAC} = testOptions;
it('should have default url when launching browser', async ({browserType, defaultBrowserOptions}) => { it('should have default url when launching browser', async ({browserType, defaultBrowserOptions, tmpDir}) => {
const userDataDir = await makeUserDataDir(); const browserContext = await browserType.launchPersistentContext(tmpDir, {...defaultBrowserOptions, headless: false });
const browserContext = await browserType.launchPersistentContext(userDataDir, {...defaultBrowserOptions, headless: false });
const urls = browserContext.pages().map(page => page.url()); const urls = browserContext.pages().map(page => page.url());
expect(urls).toEqual(['about:blank']); expect(urls).toEqual(['about:blank']);
await browserContext.close(); await browserContext.close();
await removeUserDataDir(userDataDir);
}); });
it.fail(WIN && CHROMIUM).slow()('headless should be able to read cookies written by headful', async({browserType, defaultBrowserOptions, server}) => { it.fail(WIN && CHROMIUM).slow()('headless should be able to read cookies written by headful', async({browserType, defaultBrowserOptions, server}) => {
@ -48,19 +45,17 @@ it.fail(WIN && CHROMIUM).slow()('headless should be able to read cookies written
expect(cookie).toBe('foo=true'); expect(cookie).toBe('foo=true');
}); });
it.slow()('should close browser with beforeunload page', async({browserType, defaultBrowserOptions, server}) => { it.slow()('should close browser with beforeunload page', async({browserType, defaultBrowserOptions, server, tmpDir}) => {
const userDataDir = await makeUserDataDir(); const browserContext = await browserType.launchPersistentContext(tmpDir, {...defaultBrowserOptions, headless: false});
const browserContext = await browserType.launchPersistentContext(userDataDir, {...defaultBrowserOptions, headless: false});
const page = await browserContext.newPage(); const page = await browserContext.newPage();
await page.goto(server.PREFIX + '/beforeunload.html'); await page.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
// fire. // fire.
await page.click('body'); await page.click('body');
await browserContext.close(); await browserContext.close();
await removeUserDataDir(userDataDir);
}); });
it('should not crash when creating second context', async ({browserType, defaultBrowserOptions, server}) => { it('should not crash when creating second context', async ({browserType, defaultBrowserOptions}) => {
const browser = await browserType.launch({...defaultBrowserOptions, headless: false }); const browser = await browserType.launch({...defaultBrowserOptions, headless: false });
{ {
const browserContext = await browser.newContext(); const browserContext = await browser.newContext();

View file

@ -16,8 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;
it('should work', async({browser, httpsServer}) => { it('should work', async({browser, httpsServer}) => {
let error = null; let error = null;
const context = await browser.newContext({ ignoreHTTPSErrors: true }); const context = await browser.newContext({ ignoreHTTPSErrors: true });

View file

@ -16,11 +16,8 @@
*/ */
import './base.fixture'; import './base.fixture';
import fs from 'fs';
import path from 'path';
import { helper } from '../lib/helper'; import { helper } from '../lib/helper';
import vm from 'vm'; import vm from 'vm';
const {FFOX, CHROMIUM, WEBKIT, HEADLESS} = testOptions;
it('should work with navigation', async({page, server}) => { it('should work with navigation', async({page, server}) => {
const requests = new Map(); const requests = new Map();

View file

@ -16,21 +16,19 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions; it('should work', async({page}) => {
it('should work', async({page, server}) => {
const aHandle = await page.evaluateHandle(() => document.body); const aHandle = await page.evaluateHandle(() => document.body);
const element = aHandle.asElement(); const element = aHandle.asElement();
expect(element).toBeTruthy(); expect(element).toBeTruthy();
}); });
it('should return null for non-elements', async({page, server}) => { it('should return null for non-elements', async({page}) => {
const aHandle = await page.evaluateHandle(() => 2); const aHandle = await page.evaluateHandle(() => 2);
const element = aHandle.asElement(); const element = aHandle.asElement();
expect(element).toBeFalsy(); expect(element).toBeFalsy();
}); });
it('should return ElementHandle for TextNodes', async({page, server}) => { it('should return ElementHandle for TextNodes', async({page}) => {
await page.setContent('<div>ee!</div>'); await page.setContent('<div>ee!</div>');
const aHandle = await page.evaluateHandle(() => document.querySelector('div').firstChild); const aHandle = await page.evaluateHandle(() => document.querySelector('div').firstChild);
const element = aHandle.asElement(); const element = aHandle.asElement();
@ -38,7 +36,7 @@ it('should return ElementHandle for TextNodes', async({page, server}) => {
expect(await page.evaluate(e => e.nodeType === Node.TEXT_NODE, element)).toBeTruthy(); expect(await page.evaluate(e => e.nodeType === Node.TEXT_NODE, element)).toBeTruthy();
}); });
it('should work with nullified Node', async({page, server}) => { it('should work with nullified Node', async({page}) => {
await page.setContent('<section>test</section>'); await page.setContent('<section>test</section>');
await page.evaluate('delete Node'); await page.evaluate('delete Node');
const handle = await page.evaluateHandle(() => document.querySelector('section')); const handle = await page.evaluateHandle(() => document.querySelector('section'));

View file

@ -16,9 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions; it('should work with function', async({page}) => {
it('should work with function', async({page, server}) => {
const windowHandle = await page.evaluateHandle(() => { const windowHandle = await page.evaluateHandle(() => {
window['foo'] = [1, 2]; window['foo'] = [1, 2];
return window; return window;
@ -26,7 +24,7 @@ it('should work with function', async({page, server}) => {
expect(await windowHandle.evaluate(w => w['foo'])).toEqual([1, 2]); expect(await windowHandle.evaluate(w => w['foo'])).toEqual([1, 2]);
}); });
it('should work with expression', async({page, server}) => { it('should work with expression', async({page}) => {
const windowHandle = await page.evaluateHandle(() => { const windowHandle = await page.evaluateHandle(() => {
window['foo'] = [1, 2]; window['foo'] = [1, 2];
return window; return window;

View file

@ -16,21 +16,19 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions; it('should work', async({page}) => {
it('should work', async({page, server}) => {
const aHandle = await page.evaluateHandle(() => ({foo: 'bar'})); const aHandle = await page.evaluateHandle(() => ({foo: 'bar'}));
const json = await aHandle.jsonValue(); const json = await aHandle.jsonValue();
expect(json).toEqual({foo: 'bar'}); expect(json).toEqual({foo: 'bar'});
}); });
it('should work with dates', async({page, server}) => { it('should work with dates', async({page}) => {
const dateHandle = await page.evaluateHandle(() => new Date('2017-09-26T00:00:00.000Z')); const dateHandle = await page.evaluateHandle(() => new Date('2017-09-26T00:00:00.000Z'));
const date = await dateHandle.jsonValue(); const date = await dateHandle.jsonValue();
expect(date.toJSON()).toBe('2017-09-26T00:00:00.000Z'); expect(date.toJSON()).toBe('2017-09-26T00:00:00.000Z');
}); });
it('should throw for circular objects', async({page, server}) => { it('should throw for circular objects', async({page}) => {
const windowHandle = await page.evaluateHandle('window'); const windowHandle = await page.evaluateHandle('window');
let error = null; let error = null;
await windowHandle.jsonValue().catch(e => error = e); await windowHandle.jsonValue().catch(e => error = e);

View file

@ -16,9 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions; it('should work', async({page}) => {
it('should work', async({page, server}) => {
const aHandle = await page.evaluateHandle(() => ({ const aHandle = await page.evaluateHandle(() => ({
one: 1, one: 1,
two: 2, two: 2,
@ -28,7 +26,7 @@ it('should work', async({page, server}) => {
expect(await twoHandle.jsonValue()).toEqual(2); expect(await twoHandle.jsonValue()).toEqual(2);
}); });
it('should work with undefined, null, and empty', async({page, server}) => { it('should work with undefined, null, and empty', async({page}) => {
const aHandle = await page.evaluateHandle(() => ({ const aHandle = await page.evaluateHandle(() => ({
undefined: undefined, undefined: undefined,
null: null, null: null,
@ -41,7 +39,7 @@ it('should work with undefined, null, and empty', async({page, server}) => {
expect(String(await emptyhandle.jsonValue())).toEqual('undefined'); expect(String(await emptyhandle.jsonValue())).toEqual('undefined');
}); });
it('should work with unserializable values', async({page, server}) => { it('should work with unserializable values', async({page}) => {
const aHandle = await page.evaluateHandle(() => ({ const aHandle = await page.evaluateHandle(() => ({
infinity: Infinity, infinity: Infinity,
nInfinity: -Infinity, nInfinity: -Infinity,
@ -58,7 +56,7 @@ it('should work with unserializable values', async({page, server}) => {
expect(await nzeroHandle.jsonValue()).toEqual(-0); expect(await nzeroHandle.jsonValue()).toEqual(-0);
}); });
it('getProperties should work', async({page, server}) => { it('getProperties should work', async({page}) => {
const aHandle = await page.evaluateHandle(() => ({ const aHandle = await page.evaluateHandle(() => ({
foo: 'bar' foo: 'bar'
})); }));
@ -68,13 +66,13 @@ it('getProperties should work', async({page, server}) => {
expect(await foo.jsonValue()).toBe('bar'); expect(await foo.jsonValue()).toBe('bar');
}); });
it('getProperties should return empty map for non-objects', async({page, server}) => { it('getProperties should return empty map for non-objects', async({page}) => {
const aHandle = await page.evaluateHandle(() => 123); const aHandle = await page.evaluateHandle(() => 123);
const properties = await aHandle.getProperties(); const properties = await aHandle.getProperties();
expect(properties.size).toBe(0); expect(properties.size).toBe(0);
}); });
it('getProperties should return even non-own properties', async({page, server}) => { it('getProperties should return even non-own properties', async({page}) => {
const aHandle = await page.evaluateHandle(() => { const aHandle = await page.evaluateHandle(() => {
class A { class A {
a: string; a: string;

View file

@ -16,28 +16,26 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions; it('should work for primitives', async({page}) => {
it('should work for primitives', async({page, server}) => {
const numberHandle = await page.evaluateHandle(() => 2); const numberHandle = await page.evaluateHandle(() => 2);
expect(numberHandle.toString()).toBe('JSHandle@2'); expect(numberHandle.toString()).toBe('JSHandle@2');
const stringHandle = await page.evaluateHandle(() => 'a'); const stringHandle = await page.evaluateHandle(() => 'a');
expect(stringHandle.toString()).toBe('JSHandle@a'); expect(stringHandle.toString()).toBe('JSHandle@a');
}); });
it('should work for complicated objects', async({page, server}) => { it('should work for complicated objects', async({page}) => {
const aHandle = await page.evaluateHandle(() => window); const aHandle = await page.evaluateHandle(() => window);
expect(aHandle.toString()).toBe('JSHandle@object'); expect(aHandle.toString()).toBe('JSHandle@object');
}); });
it('should work for promises', async({page, server}) => { it('should work for promises', async({page}) => {
// wrap the promise in an object, otherwise we will await. // wrap the promise in an object, otherwise we will await.
const wrapperHandle = await page.evaluateHandle(() => ({b: Promise.resolve(123)})); const wrapperHandle = await page.evaluateHandle(() => ({b: Promise.resolve(123)}));
const bHandle = await wrapperHandle.getProperty('b'); const bHandle = await wrapperHandle.getProperty('b');
expect(bHandle.toString()).toBe('JSHandle@promise'); expect(bHandle.toString()).toBe('JSHandle@promise');
}); });
it('should work with different subtypes', async({page, server}) => { it('should work with different subtypes', async({page}) => {
expect((await page.evaluateHandle('(function(){})')).toString()).toBe('JSHandle@function'); expect((await page.evaluateHandle('(function(){})')).toString()).toBe('JSHandle@function');
expect((await page.evaluateHandle('12')).toString()).toBe('JSHandle@12'); expect((await page.evaluateHandle('12')).toString()).toBe('JSHandle@12');
expect((await page.evaluateHandle('true')).toString()).toBe('JSHandle@true'); expect((await page.evaluateHandle('true')).toString()).toBe('JSHandle@true');

View file

@ -18,9 +18,7 @@ import './base.fixture';
import utils from './utils'; import utils from './utils';
const {FFOX, WEBKIT, CHROMIUM, MAC} = testOptions; it('should type into a textarea', async ({page}) => {
it('should type into a textarea', async ({page, server}) => {
await page.evaluate(() => { await page.evaluate(() => {
const textarea = document.createElement('textarea'); const textarea = document.createElement('textarea');
document.body.appendChild(textarea); document.body.appendChild(textarea);

View file

@ -17,11 +17,9 @@
import './base.fixture'; import './base.fixture';
import path from 'path'; import path from 'path';
import fs from 'fs';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('should require top-level Errors', async({playwright}) => { it('should require top-level Errors', async({}) => {
const Errors = require(path.join(utils.projectRoot(), '/lib/errors.js')); const Errors = require(path.join(utils.projectRoot(), '/lib/errors.js'));
expect(String(Errors.TimeoutError)).toContain('TimeoutError'); expect(String(Errors.TimeoutError)).toContain('TimeoutError');
}); });

View file

@ -15,10 +15,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import fs from 'fs';
import path from 'path';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it('should log', async({browserType, defaultBrowserOptions}) => { it('should log', async({browserType, defaultBrowserOptions}) => {
const log = []; const log = [];
const browser = await browserType.launch({...defaultBrowserOptions, logger: { const browser = await browserType.launch({...defaultBrowserOptions, logger: {

View file

@ -16,8 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;
function dimensions() { function dimensions() {
const rect = document.querySelector('textarea').getBoundingClientRect(); const rect = document.querySelector('textarea').getBoundingClientRect();
return { return {

View file

@ -16,7 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT, WIRE} = testOptions; const { WIRE } = testOptions;
it.skip(WIRE)('should work across sessions', async ({browserType, defaultBrowserOptions}) => { it.skip(WIRE)('should work across sessions', async ({browserType, defaultBrowserOptions}) => {
const browserServer = await browserType.launchServer(defaultBrowserOptions); const browserServer = await browserType.launchServer(defaultBrowserOptions);

View file

@ -16,10 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import fs from 'fs';
import path from 'path';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;
it('should work for main frame navigation request', async({page, server}) => { it('should work for main frame navigation request', async({page, server}) => {
const requests = []; const requests = [];

View file

@ -18,8 +18,6 @@ import './base.fixture';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;
it('should work', async({page, server}) => { it('should work', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => { server.setRoute('/empty.html', (req, res) => {

View file

@ -16,9 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import utils from './utils';
import path from 'path'; import path from 'path';
const { FFOX, CHROMIUM, WEBKIT, WIRE } = testOptions;
it('should evaluate before anything else on the page', async ({ page, server }) => { it('should evaluate before anything else on the page', async ({ page, server }) => {
await page.addInitScript(function () { await page.addInitScript(function () {

View file

@ -17,9 +17,6 @@
import './base.fixture'; import './base.fixture';
import path from 'path'; import path from 'path';
import util from 'util';
import vm from 'vm';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('should throw an error if no options are provided', async({page, server}) => { it('should throw an error if no options are provided', async({page, server}) => {
let error = null; let error = null;

View file

@ -17,9 +17,6 @@
import './base.fixture'; import './base.fixture';
import path from 'path'; import path from 'path';
import util from 'util';
import vm from 'vm';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('should throw an error if no options are provided', async({page, server}) => { it('should throw an error if no options are provided', async({page, server}) => {
let error = null; let error = null;

View file

@ -16,11 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
import util from 'util';
import vm from 'vm';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('should reject all promises when page is closed', async({context}) => { it('should reject all promises when page is closed', async({context}) => {
const newPage = await context.newPage(); const newPage = await context.newPage();
let error = null; let error = null;

View file

@ -17,7 +17,6 @@
import './base.fixture'; import './base.fixture';
import utils from './utils'; import utils from './utils';
const {CHROMIUM, FFOX, MAC, HEADLESS} = testOptions;
it('should emulate type', async({page, server}) => { it('should emulate type', async({page, server}) => {
expect(await page.evaluate(() => matchMedia('screen').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('screen').matches)).toBe(true);

View file

@ -16,8 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT} = testOptions;
it('should work', async({page, server}) => { it('should work', async({page, server}) => {
const windowHandle = await page.evaluateHandle(() => window); const windowHandle = await page.evaluateHandle(() => window);
expect(windowHandle).toBeTruthy(); expect(windowHandle).toBeTruthy();

View file

@ -15,8 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import './base.fixture'; import './base.fixture';
const { WIRE } = testOptions;
const {WEBKIT, WIRE, FFOX} = 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);

View file

@ -16,10 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
import util from 'util'; import util from 'util';
import vm from 'vm';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('should work', async({page, server}) => { it('should work', async({page, server}) => {
let message = null; let message = null;

View file

@ -16,10 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path'; const { WIRE } = testOptions;
import util from 'util';
import vm from 'vm';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
const CRASH_FAIL = (FFOX && WIN) || WIRE; const CRASH_FAIL = (FFOX && WIN) || WIRE;
// Firefox Win: it just doesn't crash sometimes. // Firefox Win: it just doesn't crash sometimes.

View file

@ -16,11 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import fs from 'fs';
import path from 'path';
import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;
it('Page.Events.Request', async({page, server}) => { it('Page.Events.Request', async({page, server}) => {
const requests = []; const requests = [];
page.on('request', request => requests.push(request)); page.on('request', request => requests.push(request));

View file

@ -16,9 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('should fire', async({page, server}) => { it('should fire', async({page, server}) => {
const [error] = await Promise.all([ const [error] = await Promise.all([
page.waitForEvent('pageerror'), page.waitForEvent('pageerror'),

View file

@ -15,8 +15,6 @@
*/ */
import './base.fixture'; import './base.fixture';
const {FFOX, CHROMIUM, WEBKIT, MAC} = testOptions;
it('should work', async({browser}) => { it('should work', async({browser}) => {
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();

View file

@ -16,10 +16,7 @@
*/ */
import './base.fixture'; import './base.fixture';
import fs from 'fs';
import path from 'path';
import utils from './utils'; import utils from './utils';
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;
it('should fire for navigation requests', async({page, server}) => { it('should fire for navigation requests', async({page, server}) => {
const requests = []; const requests = [];

View file

@ -16,11 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
import util from 'util';
import vm from 'vm';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
it('exposeBinding should work', async({browser}) => { it('exposeBinding should work', async({browser}) => {
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();

View file

@ -16,11 +16,6 @@
*/ */
import './base.fixture'; import './base.fixture';
import path from 'path';
import util from 'util';
import vm from 'vm';
const {FFOX, CHROMIUM, WEBKIT, WIN, WIRE} = testOptions;
async function giveItAChanceToFill(page) { async function giveItAChanceToFill(page) {
for (let i = 0; i < 5; i++) for (let i = 0; i < 5; i++)
await page.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f)))); await page.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f))));

View file

@ -19,7 +19,6 @@ import './base.fixture';
import utils from './utils'; import utils from './utils';
import path from 'path'; import path from 'path';
import url from 'url'; import url from 'url';
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = testOptions;
it('should work', async({page, server}) => { it('should work', async({page, server}) => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);

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