test: remove module.export.describe wrapper (#1716)
This commit is contained in:
parent
2ef8e26602
commit
ade9d23c28
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Accessibility', function() {
|
||||
describe('Accessibility', function() {
|
||||
it('should work', async function({page}) {
|
||||
await page.setContent(`
|
||||
<head>
|
||||
|
|
@ -350,5 +347,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ function traceAPICoverage(apiCoverage, events, className, classType) {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports.describe = function({browserType}) {
|
||||
describe('**API COVERAGE**', () => {
|
||||
describe.skip(!process.env.COVERAGE)('**API COVERAGE**', () => {
|
||||
const BROWSER_CONFIGS = [
|
||||
{
|
||||
name: 'Firefox',
|
||||
|
|
@ -99,5 +98,4 @@ module.exports.describe = function({browserType}) {
|
|||
if (missingMethods.length)
|
||||
throw new Error('Certain API Methods are not called: ' + missingMethods.join(', '));
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Auto waiting', () => {
|
||||
describe('Auto waiting', () => {
|
||||
it('should await navigation when clicking anchor', async({page, server}) => {
|
||||
const messages = [];
|
||||
server.setRoute('/empty.html', async (req, res) => {
|
||||
|
|
@ -184,9 +181,9 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
]);
|
||||
expect(messages.join('|')).toBe('route|domcontentloaded|load|click');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Auto waiting should not hang when', () => {
|
||||
describe('Auto waiting should not hang when', () => {
|
||||
it('clicking on links which do not commit navigation', async({page, server, httpsServer}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent(`<a href='${httpsServer.EMPTY_PAGE}'>foobar</a>`);
|
||||
|
|
@ -225,6 +222,5 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
popup.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {BrowserTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Browser.newPage', function() {
|
||||
describe('Browser.newPage', function() {
|
||||
it('should create new page', async function({browser}) {
|
||||
const page1 = await browser.newPage();
|
||||
expect(browser.contexts().length).toBe(1);
|
||||
|
|
@ -40,5 +37,4 @@ module.exports.describe = function({playwright, CHROMIUM, WEBKIT}) {
|
|||
await page.close();
|
||||
expect(error.message).toContain('Please use browser.newContext()');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,13 +16,9 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {BrowserTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX}) {
|
||||
|
||||
describe('BrowserContext', function() {
|
||||
describe('BrowserContext', function() {
|
||||
it('should create new context', async function({browser}) {
|
||||
expect(browser.contexts().length).toBe(0);
|
||||
const context = await browser.newContext();
|
||||
|
|
@ -117,9 +113,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
let error = await promise;
|
||||
expect(error.message).toContain('Context closed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext({userAgent})', function() {
|
||||
describe('BrowserContext({userAgent})', function() {
|
||||
it('should work', async({browser, server}) => {
|
||||
{
|
||||
const context = await browser.newContext();
|
||||
|
|
@ -184,9 +180,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
expect(request.headers['user-agent']).toBe('foobar');
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext({bypassCSP})', function() {
|
||||
describe('BrowserContext({bypassCSP})', function() {
|
||||
it('should bypass CSP meta tag', async({browser, server}) => {
|
||||
// Make sure CSP prohibits addScriptTag.
|
||||
{
|
||||
|
|
@ -268,9 +264,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
await context.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext({javaScriptEnabled})', function() {
|
||||
describe('BrowserContext({javaScriptEnabled})', function() {
|
||||
it('should work', async({browser}) => {
|
||||
{
|
||||
const context = await browser.newContext({ javaScriptEnabled: false });
|
||||
|
|
@ -299,9 +295,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
await page.goto(server.EMPTY_PAGE);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext.pages()', function() {
|
||||
describe('BrowserContext.pages()', function() {
|
||||
it('should return all of the pages', async({browser, server}) => {
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
|
@ -320,9 +316,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
await context.close();
|
||||
expect(context.pages().length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext.exposeFunction', () => {
|
||||
describe('BrowserContext.exposeFunction', () => {
|
||||
it('should work', async({browser, server}) => {
|
||||
const context = await browser.newContext();
|
||||
await context.exposeFunction('add', (a, b) => a + b);
|
||||
|
|
@ -362,9 +358,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
expect(args).toEqual(['context', 'page']);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext.route', () => {
|
||||
describe('BrowserContext.route', () => {
|
||||
it('should intercept', async({browser, server}) => {
|
||||
const context = await browser.newContext();
|
||||
let intercepted = false;
|
||||
|
|
@ -401,9 +397,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
expect(await response.text()).toBe('page');
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext.setHTTPCredentials', function() {
|
||||
describe('BrowserContext.setHTTPCredentials', function() {
|
||||
it('should work', async({browser, server}) => {
|
||||
server.setAuth('/empty.html', 'user', 'pass');
|
||||
const context = await browser.newContext();
|
||||
|
|
@ -460,9 +456,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
expect((await response.body()).toString()).toContain("Playground");
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext.setOffline', function() {
|
||||
describe('BrowserContext.setOffline', function() {
|
||||
it('should work with initial option', async({browser, server}) => {
|
||||
const context = await browser.newContext({offline: true});
|
||||
const page = await context.newPage();
|
||||
|
|
@ -484,9 +480,9 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
expect(await page.evaluate(() => window.navigator.onLine)).toBe(true);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Events.BrowserContext.Page', function() {
|
||||
describe('Events.BrowserContext.Page', function() {
|
||||
it('should have url', async({browser, server}) => {
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
|
@ -619,5 +615,4 @@ module.exports.describe = function({playwright, CHROMIUM, FFOX, WEBKIT, LINUX})
|
|||
]);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,15 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({WIN, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Capabilities', function() {
|
||||
describe('Capabilities', function() {
|
||||
it.fail(WEBKIT && WIN)('Web Assembly should work', async function({page, server}) {
|
||||
await page.goto(server.PREFIX + '/wasm/table2.html');
|
||||
expect(await page.evaluate(() => loadTable())).toBe('42, 83');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,12 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('../utils').testOptions(browserType);
|
||||
|
||||
describe('ChromiumBrowserContext', function() {
|
||||
describe('ChromiumBrowserContext', function() {
|
||||
it('should create a worker from a service worker', async({browser, page, server, context}) => {
|
||||
const [worker] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
|
|
@ -53,9 +50,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
});
|
||||
expect(serviceWorkerCreated).not.toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Chromium-Specific Page Tests', function() {
|
||||
describe('Chromium-Specific Page Tests', function() {
|
||||
it('Page.route should work with intervention headers', async({server, page}) => {
|
||||
server.setRoute('/intervention', (req, res) => res.end(`
|
||||
<script>
|
||||
|
|
@ -75,6 +72,4 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
// make it work with Edgium.
|
||||
expect(serverRequest.headers.intervention).toContain('feature/5718547946799104');
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,12 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('../utils').testOptions(browserType);
|
||||
|
||||
describe('JSCoverage', function() {
|
||||
describe('JSCoverage', function() {
|
||||
it('should work', async function({page, server}) {
|
||||
await page.coverage.startJSCoverage();
|
||||
await page.goto(server.PREFIX + '/jscoverage/simple.html', { waitUntil: 'load' });
|
||||
|
|
@ -89,9 +86,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
});
|
||||
await page.coverage.stopJSCoverage();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('CSSCoverage', function() {
|
||||
describe('CSSCoverage', function() {
|
||||
it('should work', async function({page, server}) {
|
||||
await page.coverage.startCSSCoverage();
|
||||
await page.goto(server.PREFIX + '/csscoverage/simple.html');
|
||||
|
|
@ -184,5 +181,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
const coverage = await page.coverage.stopCSSCoverage();
|
||||
expect(coverage.length).toBe(1);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,43 +14,37 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const util = require('util');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const { makeUserDataDir, removeUserDataDir } = require('../utils');
|
||||
const utils = require('../utils');
|
||||
const {makeUserDataDir, removeUserDataDir} = utils;
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, defaultBrowserOptions} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
||||
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
headless: false
|
||||
});
|
||||
const extensionPath = path.join(__dirname, '..', 'assets', 'simple-extension');
|
||||
const extensionOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
});
|
||||
const extensionPath = path.join(__dirname, '..', 'assets', 'simple-extension');
|
||||
const extensionOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
headless: false,
|
||||
args: [
|
||||
`--disable-extensions-except=${extensionPath}`,
|
||||
`--load-extension=${extensionPath}`,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
describe('launcher', function() {
|
||||
it('should throw with remote-debugging-pipe argument', async() => {
|
||||
describe('launcher', function() {
|
||||
it('should throw with remote-debugging-pipe argument', async({browserType}) => {
|
||||
const options = Object.assign({}, defaultBrowserOptions);
|
||||
options.args = ['--remote-debugging-pipe'].concat(options.args || []);
|
||||
const error = await browserType.launchServer(options).catch(e => e);
|
||||
expect(error.message).toContain('Playwright manages remote debugging connection itself');
|
||||
});
|
||||
it('should throw with remote-debugging-port argument', async() => {
|
||||
it('should throw with remote-debugging-port argument', async({browserType}) => {
|
||||
const options = Object.assign({}, defaultBrowserOptions);
|
||||
options.args = ['--remote-debugging-port=9222'].concat(options.args || []);
|
||||
const error = await browserType.launchServer(options).catch(e => e);
|
||||
expect(error.message).toContain('Playwright manages remote debugging connection itself');
|
||||
});
|
||||
it('should open devtools when "devtools: true" option is given', async({server}) => {
|
||||
it('should open devtools when "devtools: true" option is given', async({browserType}) => {
|
||||
const browser = await browserType.launch(Object.assign({devtools: true}, headfulOptions));
|
||||
const context = await browser.newContext();
|
||||
const browserSession = await browser.newBrowserCDPSession();
|
||||
|
|
@ -65,10 +59,10 @@ module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
|||
]);
|
||||
await browser.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('extensions', () => {
|
||||
it('should return background pages', async() => {
|
||||
describe('extensions', () => {
|
||||
it('should return background pages', async({browserType}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const context = await browserType.launchPersistentContext(userDataDir, extensionOptions);
|
||||
const backgroundPages = context.backgroundPages();
|
||||
|
|
@ -80,10 +74,10 @@ module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
|||
expect(context.pages()).not.toContain(backgroundPage);
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext', function() {
|
||||
it('should not create pages automatically', async function() {
|
||||
describe('BrowserContext', function() {
|
||||
it('should not create pages automatically', async ({browserType}) => {
|
||||
const browser = await browserType.launch();
|
||||
const browserSession = await browser.newBrowserCDPSession();
|
||||
const targets = [];
|
||||
|
|
@ -96,5 +90,4 @@ module.exports.describe = function({defaultBrowserOptions, browserType, WIN}) {
|
|||
await browser.close();
|
||||
expect(targets.length).toBe(0);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,18 +14,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, defaultBrowserOptions} = require('../utils').testOptions(browserType);
|
||||
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
headless: false
|
||||
});
|
||||
});
|
||||
|
||||
describe('OOPIF', function() {
|
||||
describe('OOPIF', function() {
|
||||
beforeAll(async function(state) {
|
||||
state.browser = await browserType.launch(Object.assign({}, defaultBrowserOptions, {
|
||||
state.browser = await state.browserType.launch(Object.assign({}, defaultBrowserOptions, {
|
||||
args: (defaultBrowserOptions.args || []).concat(['--site-per-process']),
|
||||
}));
|
||||
});
|
||||
|
|
@ -75,7 +72,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
await page.click('button');
|
||||
expect(await page.evaluate(() => window.BUTTON_CLICKED)).toBe(true);
|
||||
});
|
||||
it('should report google.com frame with headful', async({server}) => {
|
||||
it('should report google.com frame with headful', async({browserType, server}) => {
|
||||
// TODO: Support OOOPIF. @see https://github.com/GoogleChrome/puppeteer/issues/2548
|
||||
// https://google.com is isolated by default in Chromium embedder.
|
||||
const browser = await browserType.launch(headfulOptions);
|
||||
|
|
@ -98,8 +95,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
]);
|
||||
await browser.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
async function countOOPIFs(browser) {
|
||||
const browserSession = await browser.newBrowserCDPSession();
|
||||
|
|
|
|||
|
|
@ -16,19 +16,14 @@
|
|||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {FFOX, CHROMIUM, WEBKIT, headless, OUTPUT_DIR} = require('../utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({headless, OUTPUT_DIR}) {
|
||||
|
||||
// Printing to pdf is currently only supported in headless
|
||||
describe.fail(!headless)('Page.pdf', function() {
|
||||
// Printing to pdf is currently only supported in headless
|
||||
describe.fail(!headless)('Page.pdf', function() {
|
||||
it('should be able to save file', async({page, server}) => {
|
||||
const outputFile = path.join(OUTPUT_DIR, 'output.pdf');
|
||||
await page.pdf({path: outputFile});
|
||||
expect(fs.readFileSync(outputFile).byteLength).toBeGreaterThan(0);
|
||||
fs.unlinkSync(outputFile);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,12 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('../utils').testOptions(browserType);
|
||||
|
||||
describe('ChromiumBrowserContext.createSession', function() {
|
||||
describe('ChromiumBrowserContext.createSession', function() {
|
||||
it('should work', async function({page, browser, server}) {
|
||||
const client = await page.context().newCDPSession(page);
|
||||
|
||||
|
|
@ -95,13 +92,12 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(error).toBeTruthy('Calling detach on a closed page\'s session should throw');
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
describe('ChromiumBrowser.newBrowserCDPSession', function() {
|
||||
});
|
||||
describe('ChromiumBrowser.newBrowserCDPSession', function() {
|
||||
it('should work', async function({page, browser, server}) {
|
||||
const session = await browser.newBrowserCDPSession();
|
||||
const version = await session.send('Browser.getVersion');
|
||||
expect(version.userAgent).toBeTruthy();
|
||||
await session.detach();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,16 +16,12 @@
|
|||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {FFOX, CHROMIUM, WEBKIT, OUTPUT_DIR, defaultBrowserOptions} = require('../utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {ChromiumTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, browserType, OUTPUT_DIR}) {
|
||||
|
||||
describe('Chromium.startTracing', function() {
|
||||
describe('Chromium.startTracing', function() {
|
||||
beforeEach(async function(state) {
|
||||
state.outputFile = path.join(OUTPUT_DIR, `trace-${state.parallelIndex}.json`);
|
||||
state.browser = await browserType.launch(defaultBrowserOptions);
|
||||
state.browser = await state.browserType.launch(defaultBrowserOptions);
|
||||
state.page = await state.browser.newPage();
|
||||
});
|
||||
afterEach(async function(state) {
|
||||
|
|
@ -78,5 +74,4 @@ module.exports.describe = function({defaultBrowserOptions, browserType, OUTPUT_D
|
|||
const trace = await browser.stopTracing();
|
||||
expect(trace.toString()).toContain('screenshot', 'Does not contain screenshot');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,13 +16,9 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('Page.click', function() {
|
||||
describe('Page.click', function() {
|
||||
it('should click the button', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
await page.click('button');
|
||||
|
|
@ -558,9 +554,9 @@ const utils = require('./utils');
|
|||
if (error2)
|
||||
expect(error2.message).toContain('timeout exceeded');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.check', function() {
|
||||
describe('Page.check', function() {
|
||||
it('should check the box', async({page}) => {
|
||||
await page.setContent(`<input id='checkbox' type='checkbox'></input>`);
|
||||
await page.check('input');
|
||||
|
|
@ -612,5 +608,4 @@ const utils = require('./utils');
|
|||
await page.check('div');
|
||||
expect(await page.evaluate(() => checkbox.getAttribute('aria-checked'))).toBe('true');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, defaultBrowserOptions} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('BrowserContext.cookies', function() {
|
||||
describe('BrowserContext.cookies', function() {
|
||||
it('should return no cookies in pristine browser context', async({context, page, server}) => {
|
||||
expect(await context.cookies()).toEqual([]);
|
||||
});
|
||||
|
|
@ -156,9 +153,9 @@ module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFO
|
|||
sameSite: 'None',
|
||||
}]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext.addCookies', function() {
|
||||
describe('BrowserContext.addCookies', function() {
|
||||
it('should work', async({context, page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await context.addCookies([{
|
||||
|
|
@ -272,7 +269,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFO
|
|||
await context.close();
|
||||
}
|
||||
});
|
||||
it.slow()('should isolate cookies between launches', async({server}) => {
|
||||
it.slow()('should isolate cookies between launches', async({browserType, server}) => {
|
||||
const browser1 = await browserType.launch(defaultBrowserOptions);
|
||||
const context1 = await browser1.newContext();
|
||||
await context1.addCookies([{url: server.EMPTY_PAGE, name: 'cookie-in-context-1', value: 'value', expires: Date.now() / 1000 + 10000}]);
|
||||
|
|
@ -435,9 +432,9 @@ module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFO
|
|||
|
||||
expect(await page.frames()[1].evaluate('document.cookie')).toBe('frame-cookie=value');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext.clearCookies', function() {
|
||||
describe('BrowserContext.clearCookies', function() {
|
||||
it('should clear cookies', async({context, page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await context.addCookies([{
|
||||
|
|
@ -468,5 +465,4 @@ module.exports.describe = function({browserType, defaultBrowserOptions, MAC, FFO
|
|||
expect((await anotherContext.cookies()).length).toBe(0);
|
||||
await anotherContext.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,17 +15,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const { makeUserDataDir, removeUserDataDir } = require('./utils');
|
||||
const utils = require('./utils');
|
||||
const {makeUserDataDir, removeUserDataDir} = utils;
|
||||
const {FFOX, CHROMIUM, WEBKIT, defaultBrowserOptions} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function ({ defaultBrowserOptions, browserType, WEBKIT }) {
|
||||
|
||||
describe('launchPersistentContext()', function() {
|
||||
describe('launchPersistentContext()', function() {
|
||||
beforeEach(async state => {
|
||||
state.userDataDir = await makeUserDataDir();
|
||||
state.browserContext = await browserType.launchPersistentContext(state.userDataDir, defaultBrowserOptions);
|
||||
state.browserContext = await state.browserType.launchPersistentContext(state.userDataDir, defaultBrowserOptions);
|
||||
state.page = await state.browserContext.newPage();
|
||||
});
|
||||
afterEach(async state => {
|
||||
|
|
@ -86,5 +83,4 @@ module.exports.describe = function ({ defaultBrowserOptions, browserType, WEBKIT
|
|||
expect(await page.context().cookies([])).toEqual([]);
|
||||
expect(await page.evaluate('document.cookie')).toBe('');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.Events.Dialog', function() {
|
||||
describe('Page.Events.Dialog', function() {
|
||||
it('should fire', async({page, server}) => {
|
||||
page.on('dialog', dialog => {
|
||||
expect(dialog.type()).toBe('alert');
|
||||
|
|
@ -61,5 +58,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
const result = await page.evaluate(() => confirm('boolean?'));
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,10 +16,9 @@
|
|||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {FFOX, CHROMIUM, WEBKIT, defaultBrowserOptions} = require('./utils').testOptions(browserType);
|
||||
|
||||
module.exports.describe = function({browserType, defaultBrowserOptions, CHROMIUM, WEBKIT, FFOX, WIN, MAC}) {
|
||||
|
||||
describe('Download', function() {
|
||||
describe('Download', function() {
|
||||
beforeEach(async(state) => {
|
||||
state.server.setRoute('/download', (req, res) => {
|
||||
res.setHeader('Content-Type', 'application/octet-stream');
|
||||
|
|
@ -97,7 +96,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, CHROMIUM
|
|||
expect(fs.existsSync(path1)).toBeFalsy();
|
||||
expect(fs.existsSync(path2)).toBeFalsy();
|
||||
});
|
||||
it('should delete downloads on browser gone', async ({ server }) => {
|
||||
it('should delete downloads on browser gone', async ({ server, browserType }) => {
|
||||
const browser = await browserType.launch(defaultBrowserOptions);
|
||||
const page = await browser.newPage({ acceptDownloads: true });
|
||||
await page.setContent(`<a download=true href="${server.PREFIX}/download">download</a>`);
|
||||
|
|
@ -118,5 +117,4 @@ module.exports.describe = function({browserType, defaultBrowserOptions, CHROMIUM
|
|||
expect(fs.existsSync(path2)).toBeFalsy();
|
||||
expect(fs.existsSync(path.join(path1, '..'))).toBeFalsy();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,13 +16,9 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('ElementHandle.boundingBox', function() {
|
||||
describe('ElementHandle.boundingBox', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.setViewportSize({width: 500, height: 500});
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
|
|
@ -113,9 +109,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
});
|
||||
expect(round(box)).toEqual(round(webBoundingBox));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.contentFrame', function() {
|
||||
describe('ElementHandle.contentFrame', function() {
|
||||
it('should work', async({page,server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
|
||||
|
|
@ -151,9 +147,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
const elementHandle = await frame.evaluateHandle(() => document.documentElement);
|
||||
expect(await elementHandle.contentFrame()).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.ownerFrame', function() {
|
||||
describe('ElementHandle.ownerFrame', function() {
|
||||
it('should work', async({page,server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
|
||||
|
|
@ -222,9 +218,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
});
|
||||
expect(await divHandle.ownerFrame()).toBe(popup.mainFrame());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.click', function() {
|
||||
describe('ElementHandle.click', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
const button = await page.$('button');
|
||||
|
|
@ -278,9 +274,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
const error = await br.click({ force: true }).catch(err => err);
|
||||
expect(error.message).toBe('Node is either not visible or not an HTMLElement');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.hover', function() {
|
||||
describe('ElementHandle.hover', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/scrollable.html');
|
||||
const button = await page.$('#button-6');
|
||||
|
|
@ -294,9 +290,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
await button.hover();
|
||||
expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.scrollIntoViewIfNeeded', function() {
|
||||
describe('ElementHandle.scrollIntoViewIfNeeded', function() {
|
||||
it.fail(FFOX)('should work', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/offscreenbuttons.html');
|
||||
for (let i = 0; i < 11; ++i) {
|
||||
|
|
@ -313,9 +309,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
await page.evaluate(() => window.scrollTo(0, 0));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.fill', function() {
|
||||
describe('ElementHandle.fill', function() {
|
||||
it('should fill input', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/textarea.html');
|
||||
const handle = await page.$('input');
|
||||
|
|
@ -329,5 +325,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
await handle.fill('some value');
|
||||
expect(await page.evaluate(() => result)).toBe('some value');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,15 +16,11 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT, headless} = utils.testOptions(browserType);
|
||||
const iPhone = playwright.devices['iPhone 6'];
|
||||
const iPhoneLandscape = playwright.devices['iPhone 6 landscape'];
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT, MAC, WIN}) {
|
||||
const iPhone = playwright.devices['iPhone 6'];
|
||||
const iPhoneLandscape = playwright.devices['iPhone 6 landscape'];
|
||||
|
||||
describe('BrowserContext({viewport})', function() {
|
||||
describe('BrowserContext({viewport})', function() {
|
||||
it('should get the proper viewport size', async({page, server}) => {
|
||||
expect(page.viewportSize()).toEqual({width: 1280, height: 720});
|
||||
expect(await page.evaluate(() => window.innerWidth)).toBe(1280);
|
||||
|
|
@ -81,9 +77,9 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
await page.goto(server.PREFIX + '/detect-touch.html');
|
||||
expect(await page.evaluate(() => document.body.textContent.trim())).toBe('NO');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip(FFOX)('viewport.isMobile', () => {
|
||||
describe.skip(FFOX)('viewport.isMobile', () => {
|
||||
// Firefox does not support isMobile.
|
||||
it('should support mobile emulation', async({browser, server}) => {
|
||||
const context = await browser.newContext({ ...iPhone });
|
||||
|
|
@ -173,9 +169,9 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
expect(await page.evaluate(() => window.innerWidth)).toBe(320);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip(FFOX)('Page.emulate', function() {
|
||||
describe.skip(FFOX)('Page.emulate', function() {
|
||||
it('should work', async({browser, server}) => {
|
||||
const context = await browser.newContext({ ...iPhone });
|
||||
const page = await context.newPage();
|
||||
|
|
@ -194,9 +190,9 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
expect(await page.evaluate(() => result)).toBe('Clicked');
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.emulateMedia type', function() {
|
||||
describe('Page.emulateMedia type', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
expect(await page.evaluate(() => matchMedia('screen').matches)).toBe(true);
|
||||
expect(await page.evaluate(() => matchMedia('print').matches)).toBe(false);
|
||||
|
|
@ -215,9 +211,9 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
await page.emulateMedia({ media: 'bad' }).catch(e => error = e);
|
||||
expect(error.message).toBe('Unsupported media: bad');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.emulateMedia colorScheme', function() {
|
||||
describe('Page.emulateMedia colorScheme', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.emulateMedia({ colorScheme: 'light' });
|
||||
expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(true);
|
||||
|
|
@ -300,9 +296,9 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
expect(await frame.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true);
|
||||
await page.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext({timezoneId})', function() {
|
||||
describe('BrowserContext({timezoneId})', function() {
|
||||
it('should work', async ({ browser }) => {
|
||||
const func = () => new Date(1479579154987).toString();
|
||||
{
|
||||
|
|
@ -354,9 +350,9 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
]);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('BrowserContext({locale})', function() {
|
||||
describe('BrowserContext({locale})', function() {
|
||||
it('should affect accept-language header', async({browser, server}) => {
|
||||
const context = await browser.newContext({ locale: 'fr-CH' });
|
||||
const page = await context.newPage();
|
||||
|
|
@ -448,9 +444,9 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
]);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe.fail(!headless)('focus', function() {
|
||||
describe.fail(!headless)('focus', function() {
|
||||
it('should think that it is focused by default', async({page}) => {
|
||||
expect(await page.evaluate('document.hasFocus()')).toBe(true);
|
||||
});
|
||||
|
|
@ -460,5 +456,4 @@ module.exports.describe = function({playwright, headless, FFOX, CHROMIUM, WEBKIT
|
|||
expect(await page2.evaluate('document.hasFocus()')).toBe(true);
|
||||
await page2.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,13 +17,9 @@
|
|||
|
||||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
||||
|
||||
describe('Page.evaluate', function() {
|
||||
describe('Page.evaluate', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const result = await page.evaluate(() => 7 * 3);
|
||||
expect(result).toBe(21);
|
||||
|
|
@ -286,9 +282,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
|||
await page.goto(server.PREFIX + '/empty.html');
|
||||
expect(await page.evaluate(() => new Function('return true')())).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.addInitScript', function() {
|
||||
describe('Page.addInitScript', function() {
|
||||
it('should evaluate before anything else on the page', async({page, server}) => {
|
||||
await page.addInitScript(function(){
|
||||
window.injected = 123;
|
||||
|
|
@ -367,9 +363,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
|||
await page.goto(server.PREFIX + '/tamperable.html');
|
||||
expect(await page.evaluate(() => window.result)).toBe(123);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.evaluate', function() {
|
||||
describe('Frame.evaluate', function() {
|
||||
it('should have different execution contexts', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
|
||||
|
|
@ -453,5 +449,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
|||
const constructorName = await context.evaluateInternal(node => node.constructor.name, elementHandle);
|
||||
expect(constructorName).toBe('HTMLIFrameElement');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,13 +17,9 @@
|
|||
|
||||
const path = require('path');
|
||||
const {spawn, execSync} = require('child_process');
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, playwrightPath, defaultBrowserOptions} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({browserType, playwrightPath, defaultBrowserOptions, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
async function testSignal(action, exitOnClose) {
|
||||
async function testSignal(browserType, action, exitOnClose) {
|
||||
const options = Object.assign({}, defaultBrowserOptions, {
|
||||
// Disable DUMPIO to cleanly read stdout.
|
||||
dumpio: false,
|
||||
|
|
@ -63,18 +59,18 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
action(res, browserPid);
|
||||
const [, exitCode] = await Promise.all(promises);
|
||||
return { exitCode, browserSignal, browserExitCode, output };
|
||||
}
|
||||
}
|
||||
|
||||
describe('Fixtures', function() {
|
||||
it.slow()('should dump browser process stderr', async({server}) => {
|
||||
describe('Fixtures', function() {
|
||||
it.slow()('should dump browser process stderr', async({browserType}) => {
|
||||
let dumpioData = '';
|
||||
const res = spawn('node', [path.join(__dirname, 'fixtures', 'dumpio.js'), playwrightPath, browserType.name()]);
|
||||
res.stdout.on('data', data => dumpioData += data.toString('utf8'));
|
||||
await new Promise(resolve => res.on('close', resolve));
|
||||
expect(dumpioData).toContain('message from dumpio');
|
||||
});
|
||||
it.slow()('should close the browser when the node process closes', async () => {
|
||||
const result = await testSignal(child => {
|
||||
it.slow()('should close the browser when the node process closes', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => {
|
||||
if (WIN)
|
||||
execSync(`taskkill /pid ${child.pid} /T /F`);
|
||||
else
|
||||
|
|
@ -87,38 +83,38 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
|
||||
describe.skip(WIN)('signals', () => {
|
||||
// Cannot reliably send signals on Windows.
|
||||
it.slow()('should report browser close signal', async () => {
|
||||
const result = await testSignal((child, browserPid) => process.kill(browserPid), true);
|
||||
it.slow()('should report browser close signal', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, (child, browserPid) => process.kill(browserPid), true);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.browserExitCode).toBe('null');
|
||||
expect(result.browserSignal).toBe('SIGTERM');
|
||||
});
|
||||
it.slow()('should report browser close signal 2', async (state, test) => {
|
||||
const result = await testSignal((child, browserPid) => process.kill(browserPid, 'SIGKILL'), true);
|
||||
it.slow()('should report browser close signal 2', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, (child, browserPid) => process.kill(browserPid, 'SIGKILL'), true);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.browserExitCode).toBe('null');
|
||||
expect(result.browserSignal).toBe('SIGKILL');
|
||||
});
|
||||
it.slow()('should close the browser on SIGINT', async () => {
|
||||
const result = await testSignal(child => process.kill(child.pid, 'SIGINT'));
|
||||
it.slow()('should close the browser on SIGINT', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => process.kill(child.pid, 'SIGINT'));
|
||||
expect(result.exitCode).toBe(130);
|
||||
expect(result.browserExitCode).toBe('0');
|
||||
expect(result.browserSignal).toBe('null');
|
||||
});
|
||||
it.slow()('should close the browser on SIGTERM', async () => {
|
||||
const result = await testSignal(child => process.kill(child.pid, 'SIGTERM'));
|
||||
it.slow()('should close the browser on SIGTERM', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => process.kill(child.pid, 'SIGTERM'));
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.browserExitCode).toBe('0');
|
||||
expect(result.browserSignal).toBe('null');
|
||||
});
|
||||
it.slow()('should close the browser on SIGHUP', async () => {
|
||||
const result = await testSignal(child => process.kill(child.pid, 'SIGHUP'));
|
||||
it.slow()('should close the browser on SIGHUP', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => process.kill(child.pid, 'SIGHUP'));
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.browserExitCode).toBe('0');
|
||||
expect(result.browserSignal).toBe('null');
|
||||
});
|
||||
it.slow()('should kill the browser on double SIGINT', async () => {
|
||||
const result = await testSignal(child => {
|
||||
it.slow()('should kill the browser on double SIGINT', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => {
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
});
|
||||
|
|
@ -126,8 +122,8 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
// TODO: ideally, we would expect the SIGKILL on the browser from
|
||||
// force kill, but that's racy with sending two signals.
|
||||
});
|
||||
it.slow()('should kill the browser on SIGINT + SIGTERM', async () => {
|
||||
const result = await testSignal(child => {
|
||||
it.slow()('should kill the browser on SIGINT + SIGTERM', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => {
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
process.kill(child.pid, 'SIGTERM');
|
||||
});
|
||||
|
|
@ -135,8 +131,8 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
// TODO: ideally, we would expect the SIGKILL on the browser from
|
||||
// force kill, but that's racy with sending two signals.
|
||||
});
|
||||
it.slow()('should kill the browser on SIGTERM + SIGINT', async () => {
|
||||
const result = await testSignal(child => {
|
||||
it.slow()('should kill the browser on SIGTERM + SIGINT', async ({browserType}) => {
|
||||
const result = await testSignal(browserType, child => {
|
||||
process.kill(child.pid, 'SIGTERM');
|
||||
process.kill(child.pid, 'SIGINT');
|
||||
});
|
||||
|
|
@ -145,5 +141,4 @@ module.exports.describe = function({browserType, playwrightPath, defaultBrowserO
|
|||
// force kill, but that's racy with sending two signals.
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,12 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.focus', function() {
|
||||
describe('Page.focus', function() {
|
||||
it('should work', async function({page, server}) {
|
||||
await page.setContent(`<div id=d1 tabIndex=0></div>`);
|
||||
expect(await page.evaluate(() => document.activeElement.nodeName)).toBe('BODY');
|
||||
|
|
@ -47,5 +44,4 @@ module.exports.describe = function({}) {
|
|||
expect(focused).toBe(true);
|
||||
expect(blurred).toBe(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,22 +16,18 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('Frame.evaluateHandle', function() {
|
||||
describe('Frame.evaluateHandle', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const mainFrame = page.mainFrame();
|
||||
const windowHandle = await mainFrame.evaluateHandle(() => window);
|
||||
expect(windowHandle).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.frameElement', function() {
|
||||
describe('Frame.frameElement', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const frame1 = await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
|
||||
|
|
@ -59,9 +55,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
const error = await frame1.frameElement().catch(e => e);
|
||||
expect(error.message).toBe('Frame has been detached.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.evaluate', function() {
|
||||
describe('Frame.evaluate', function() {
|
||||
it('should throw for detached frames', async({page, server}) => {
|
||||
const frame1 = await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
|
||||
await utils.detachFrame(page, 'frame1');
|
||||
|
|
@ -87,9 +83,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(a1).toBe(1);
|
||||
expect(a2).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame Management', function() {
|
||||
describe('Frame Management', function() {
|
||||
it('should handle nested frames', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/frames/nested-frames.html');
|
||||
expect(utils.dumpFrames(page.mainFrame())).toEqual([
|
||||
|
|
@ -233,5 +229,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(frame2.isDetached()).toBe(false);
|
||||
expect(frame1).not.toBe(frame2);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function ({ FFOX, WEBKIT }) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Overrides.setGeolocation', function() {
|
||||
describe('Overrides.setGeolocation', function() {
|
||||
it('should work', async({page, server, context}) => {
|
||||
await context.grantPermissions(['geolocation']);
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
|
@ -120,5 +117,4 @@ module.exports.describe = function ({ FFOX, WEBKIT }) {
|
|||
const geolocation = await popup.evaluate(() => window.geolocationPromise);
|
||||
expect(geolocation).toEqual({ longitude: 10, latitude: 10 });
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,22 +14,19 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const { makeUserDataDir, removeUserDataDir } = require('./utils');
|
||||
const utils = require('./utils');
|
||||
const { makeUserDataDir, removeUserDataDir } = utils;
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, defaultBrowserOptions} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CHROMIUM, WEBKIT, WIN}) {
|
||||
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
const headfulOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
headless: false
|
||||
});
|
||||
const headlessOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
});
|
||||
const headlessOptions = Object.assign({}, defaultBrowserOptions, {
|
||||
headless: true
|
||||
});
|
||||
});
|
||||
|
||||
describe('Headful', function() {
|
||||
it('should have default url when launching browser', async function() {
|
||||
describe('Headful', function() {
|
||||
it('should have default url when launching browser', async ({browserType}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, headfulOptions);
|
||||
const urls = browserContext.pages().map(page => page.url());
|
||||
|
|
@ -37,7 +34,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CH
|
|||
await browserContext.close();
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
it.slow().fail(WIN && CHROMIUM)('headless should be able to read cookies written by headful', async({server}) => {
|
||||
it.slow().fail(WIN && CHROMIUM)('headless should be able to read cookies written by headful', async({browserType, server}) => {
|
||||
// see https://github.com/microsoft/playwright/issues/717
|
||||
const userDataDir = await makeUserDataDir();
|
||||
// Write a cookie in headful chrome
|
||||
|
|
@ -56,7 +53,7 @@ module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CH
|
|||
await removeUserDataDir(userDataDir);
|
||||
expect(cookie).toBe('foo=true');
|
||||
});
|
||||
it.slow()('should close browser with beforeunload page', async({server}) => {
|
||||
it.slow()('should close browser with beforeunload page', async({browserType, server}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, headfulOptions);
|
||||
const page = await browserContext.newPage();
|
||||
|
|
@ -67,5 +64,4 @@ module.exports.describe = function({browserType, defaultBrowserOptions, FFOX, CH
|
|||
await browserContext.close();
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {BrowserTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('ignoreHTTPSErrors', function() {
|
||||
describe('ignoreHTTPSErrors', function() {
|
||||
it('should work', async({browser, httpsServer}) => {
|
||||
let error = null;
|
||||
const context = await browser.newContext({ ignoreHTTPSErrors: true });
|
||||
|
|
@ -63,5 +60,4 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
expect(await page.frames()[1].evaluate('2 + 3')).toBe(5);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,13 +20,9 @@ const fs = require('fs');
|
|||
const formidable = require('formidable');
|
||||
|
||||
const FILE_TO_UPLOAD = path.join(__dirname, '/assets/file-to-upload.txt');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('input', function() {
|
||||
describe('input', function() {
|
||||
it('should upload the file', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/fileupload.html');
|
||||
const filePath = path.relative(process.cwd(), FILE_TO_UPLOAD);
|
||||
|
|
@ -40,9 +36,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
return promise.then(() => reader.result);
|
||||
}, input)).toBe('contents of the file');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.waitForFileChooser', function() {
|
||||
describe('Page.waitForFileChooser', function() {
|
||||
it('should emit event', async({page, server}) => {
|
||||
await page.setContent(`<input type=file>`);
|
||||
const [chooser] = await Promise.all([
|
||||
|
|
@ -215,9 +211,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(events[0].type).toBe('input');
|
||||
expect(events[1].type).toBe('change');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.waitForFileChooser isMultiple', () => {
|
||||
describe('Page.waitForFileChooser isMultiple', () => {
|
||||
it('should work for single file pick', async({page, server}) => {
|
||||
await page.setContent(`<input type=file>`);
|
||||
const [{ multiple }] = await Promise.all([
|
||||
|
|
@ -242,5 +238,4 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
]);
|
||||
expect(multiple).toBe(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,15 +18,10 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { helper } = require('../lib/helper');
|
||||
const utils = require('./utils');
|
||||
const vm = require('vm');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('Page.route', function() {
|
||||
describe('Page.route', function() {
|
||||
it('should intercept', async({page, server}) => {
|
||||
let intercepted = false;
|
||||
await page.route('**/empty.html', (route, request) => {
|
||||
|
|
@ -341,9 +336,9 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
expect(response.ok()).toBe(true);
|
||||
expect(intercepted).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.continue', function() {
|
||||
describe('Request.continue', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.route('**/*', route => route.continue());
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
|
@ -389,9 +384,9 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
]);
|
||||
expect(await serverRequest.postBody).toBe('doggo');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.fulfill', function() {
|
||||
describe('Request.fulfill', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.route('**/*', route => {
|
||||
route.fulfill({
|
||||
|
|
@ -464,9 +459,9 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
expect(headers.foo).toBe('true');
|
||||
expect(await page.evaluate(() => document.body.textContent)).toBe('Yo, page!');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Interception vs isNavigationRequest', () => {
|
||||
describe('Interception vs isNavigationRequest', () => {
|
||||
it('should work with request interception', async({page, server}) => {
|
||||
const requests = new Map();
|
||||
await page.route('**/*', route => {
|
||||
|
|
@ -481,9 +476,9 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
expect(requests.get('script.js').isNavigationRequest()).toBe(false);
|
||||
expect(requests.get('style.css').isNavigationRequest()).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ignoreHTTPSErrors', function() {
|
||||
describe('ignoreHTTPSErrors', function() {
|
||||
it('should work with request interception', async({browser, httpsServer}) => {
|
||||
const context = await browser.newContext({ ignoreHTTPSErrors: true });
|
||||
const page = await context.newPage();
|
||||
|
|
@ -493,9 +488,9 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
expect(response.status()).toBe(200);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('service worker', function() {
|
||||
describe('service worker', function() {
|
||||
it('should intercept after a service worker', async({browser, page, server, context}) => {
|
||||
await page.goto(server.PREFIX + '/serviceworkers/fetchdummy/sw.html');
|
||||
await page.evaluate(() => window.activationPromise);
|
||||
|
|
@ -522,9 +517,9 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
const nonInterceptedResponse = await page.evaluate(() => fetchDummy('passthrough'));
|
||||
expect(nonInterceptedResponse).toBe('FAILURE: Not Found');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('glob', function() {
|
||||
describe('glob', function() {
|
||||
it('should work with glob', async({newPage, httpsServer}) => {
|
||||
expect(helper.globToRegex('**/*.js').test('https://localhost:8080/foo.js')).toBeTruthy();
|
||||
expect(helper.globToRegex('**/*.css').test('https://localhost:8080/foo.js')).toBeFalsy();
|
||||
|
|
@ -541,9 +536,9 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
expect(helper.globToRegex('**/*.{png,jpg,jpeg}').test('https://localhost:8080/c.png')).toBeTruthy();
|
||||
expect(helper.globToRegex('**/*.{png,jpg,jpeg}').test('https://localhost:8080/c.css')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('regexp', function() {
|
||||
describe('regexp', function() {
|
||||
it('should work with regular expression passed from a different context', async({page, server}) => {
|
||||
const ctx = vm.createContext();
|
||||
const regexp = vm.runInContext('new RegExp("empty\\.html")', ctx);
|
||||
|
|
@ -567,5 +562,4 @@ module.exports.describe = function({defaultBrowserOptions, playwright, FFOX, CHR
|
|||
expect(response.ok()).toBe(true);
|
||||
expect(intercepted).toBe(true);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.evaluateHandle', function() {
|
||||
describe('Page.evaluateHandle', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const windowHandle = await page.evaluateHandle(() => window);
|
||||
expect(windowHandle).toBeTruthy();
|
||||
|
|
@ -117,9 +114,9 @@ module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
|||
});
|
||||
expect(await page.evaluate(e => e.FOO, aHandle)).toBe(123);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('JSHandle.getProperty', function() {
|
||||
describe('JSHandle.getProperty', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const aHandle = await page.evaluateHandle(() => ({
|
||||
one: 1,
|
||||
|
|
@ -141,9 +138,9 @@ module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
|||
const emptyhandle = await aHandle.getProperty('empty');
|
||||
expect(String(await emptyhandle.jsonValue())).toEqual('undefined');
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('JSHandle.jsonValue', function() {
|
||||
describe('JSHandle.jsonValue', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const aHandle = await page.evaluateHandle(() => ({foo: 'bar'}));
|
||||
const json = await aHandle.jsonValue();
|
||||
|
|
@ -170,9 +167,9 @@ module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
|||
const json = await aHandle.jsonValue();
|
||||
expect(json).toEqual({a: 1});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('JSHandle.getProperties', function() {
|
||||
describe('JSHandle.getProperties', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const aHandle = await page.evaluateHandle(() => ({
|
||||
foo: 'bar'
|
||||
|
|
@ -206,9 +203,9 @@ module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
|||
expect(await properties.get('a').jsonValue()).toBe('1');
|
||||
expect(await properties.get('b').jsonValue()).toBe('2');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('JSHandle.asElement', function() {
|
||||
describe('JSHandle.asElement', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const aHandle = await page.evaluateHandle(() => document.body);
|
||||
const element = aHandle.asElement();
|
||||
|
|
@ -233,9 +230,9 @@ module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
|||
const element = handle.asElement();
|
||||
expect(element).not.toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('JSHandle.toString', function() {
|
||||
describe('JSHandle.toString', function() {
|
||||
it('should work for primitives', async({page, server}) => {
|
||||
const numberHandle = await page.evaluateHandle(() => 2);
|
||||
expect(numberHandle.toString()).toBe('JSHandle:2');
|
||||
|
|
@ -273,5 +270,4 @@ module.exports.describe = function({CHROMIUM, FFOX, WEBKIT}) {
|
|||
expect((await page.evaluateHandle('new Int32Array()')).toString()).toBe(WEBKIT ? 'JSHandle@array' : 'JSHandle@typedarray');
|
||||
expect((await page.evaluateHandle('new Proxy({}, {})')).toString()).toBe('JSHandle@proxy');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,14 +16,9 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const os = require('os');
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
||||
|
||||
describe('Keyboard', function() {
|
||||
describe('Keyboard', function() {
|
||||
it('should type into a textarea', async({page, server}) => {
|
||||
await page.evaluate(() => {
|
||||
const textarea = document.createElement('textarea');
|
||||
|
|
@ -308,5 +303,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
|||
await page.keyboard.press('a');
|
||||
expect(await page.evaluate('lastKey.key')).toBe('a');
|
||||
})
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,16 +18,12 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const utils = require('./utils');
|
||||
const { makeUserDataDir, removeUserDataDir } = require('./utils');
|
||||
const { makeUserDataDir, removeUserDataDir } = utils;
|
||||
const {FFOX, CHROMIUM, WEBKIT, WIN, defaultBrowserOptions, playwrightPath} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, playwright, browserType, playwrightPath, CHROMIUM, FFOX, WEBKIT, WIN}) {
|
||||
|
||||
describe('Playwright', function() {
|
||||
describe('Playwright', function() {
|
||||
describe('browserType.launch', function() {
|
||||
it('should reject all promises when browser is closed', async() => {
|
||||
it('should reject all promises when browser is closed', async({browserType}) => {
|
||||
const browser = await browserType.launch(defaultBrowserOptions);
|
||||
const page = await (await browser.newContext()).newPage();
|
||||
let error = null;
|
||||
|
|
@ -36,19 +32,19 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await neverResolves;
|
||||
expect(error.message).toContain('Protocol error');
|
||||
});
|
||||
it('should throw if userDataDir option is passed', async() => {
|
||||
it('should throw if userDataDir option is passed', async({browserType}) => {
|
||||
let waitError = null;
|
||||
const options = Object.assign({}, defaultBrowserOptions, {userDataDir: 'random-path'});
|
||||
await browserType.launch(options).catch(e => waitError = e);
|
||||
expect(waitError.message).toContain('launchPersistentContext');
|
||||
});
|
||||
it('should throw if page argument is passed', async() => {
|
||||
it('should throw if page argument is passed', async({browserType}) => {
|
||||
let waitError = null;
|
||||
const options = Object.assign({}, defaultBrowserOptions, { args: ['http://example.com'] });
|
||||
await browserType.launch(options).catch(e => waitError = e);
|
||||
expect(waitError.message).toContain('can not specify page');
|
||||
});
|
||||
it('should reject if executable path is invalid', async({server}) => {
|
||||
it('should reject if executable path is invalid', async({browserType}) => {
|
||||
let waitError = null;
|
||||
const options = Object.assign({}, defaultBrowserOptions, {executablePath: 'random-invalid-path'});
|
||||
await browserType.launch(options).catch(e => waitError = e);
|
||||
|
|
@ -57,7 +53,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.launchPersistentContext', function() {
|
||||
it('should have default URL when launching browser', async function() {
|
||||
it('should have default URL when launching browser', async ({browserType}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
|
||||
const urls = browserContext.pages().map(page => page.url());
|
||||
|
|
@ -65,7 +61,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserContext.close();
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
it('should have custom URL when launching browser', async function({server}) {
|
||||
it('should have custom URL when launching browser', async ({browserType, server}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const options = Object.assign({}, defaultBrowserOptions);
|
||||
options.args = [server.EMPTY_PAGE].concat(options.args || []);
|
||||
|
|
@ -83,12 +79,12 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.launchServer', function() {
|
||||
it('should return child_process instance', async () => {
|
||||
it('should return child_process instance', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
expect(browserServer.process().pid).toBeGreaterThan(0);
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should fire close event', async () => {
|
||||
it('should fire close event', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
await Promise.all([
|
||||
new Promise(f => browserServer.on('close', f)),
|
||||
|
|
@ -98,7 +94,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.executablePath', function() {
|
||||
it('should work', async({server}) => {
|
||||
it('should work', async({browserType}) => {
|
||||
const executablePath = browserType.executablePath();
|
||||
expect(fs.existsSync(executablePath)).toBe(true);
|
||||
expect(fs.realpathSync(executablePath)).toBe(executablePath);
|
||||
|
|
@ -106,7 +102,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
});
|
||||
|
||||
describe('browserType.name', function() {
|
||||
it('should work', async({server}) => {
|
||||
it('should work', async({browserType}) => {
|
||||
if (WEBKIT)
|
||||
expect(browserType.name()).toBe('webkit');
|
||||
else if (FFOX)
|
||||
|
|
@ -117,9 +113,9 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
throw new Error('Unknown browser');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Top-level requires', function() {
|
||||
describe('Top-level requires', function() {
|
||||
it('should require top-level Errors', async() => {
|
||||
const Errors = require(path.join(utils.projectRoot(), '/lib/errors.js'));
|
||||
expect(Errors.TimeoutError).toBe(playwright.errors.TimeoutError);
|
||||
|
|
@ -130,10 +126,10 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
expect(Devices['iPhone 6']).toBe(playwright.devices['iPhone 6']);
|
||||
expect(Devices['iPhone 6']).toBe(require(playwrightPath).devices['iPhone 6']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Browser.isConnected', () => {
|
||||
it('should set the browser connected state', async () => {
|
||||
describe('Browser.isConnected', () => {
|
||||
it('should set the browser connected state', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
expect(remote.isConnected()).toBe(true);
|
||||
|
|
@ -142,7 +138,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should throw when used after isConnected returns false', async({server}) => {
|
||||
it('should throw when used after isConnected returns false', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const page = await remote.newPage();
|
||||
|
|
@ -154,10 +150,10 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
const error = await page.evaluate('1 + 1').catch(e => e);
|
||||
expect(error.message).toContain('has been closed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Browser.disconnect', function() {
|
||||
it('should reject navigation when browser closes', async({server}) => {
|
||||
describe('Browser.disconnect', function() {
|
||||
it('should reject navigation when browser closes', async({browserType, server}) => {
|
||||
server.setRoute('/one-style.css', () => {});
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -170,7 +166,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should reject waitForSelector when browser closes', async({server}) => {
|
||||
it('should reject waitForSelector when browser closes', async({browserType, server}) => {
|
||||
server.setRoute('/empty.html', () => {});
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -186,7 +182,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should throw if used after disconnect', async({server}) => {
|
||||
it('should throw if used after disconnect', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const page = await remote.newPage();
|
||||
|
|
@ -196,7 +192,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should emit close events on pages and contexts', async({server}) => {
|
||||
it('should emit close events on pages and contexts', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const context = await remote.newContext();
|
||||
|
|
@ -209,10 +205,10 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
]);
|
||||
expect(pageClosed).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Browser.close', function() {
|
||||
it('should terminate network waiters', async({server}) => {
|
||||
describe('Browser.close', function() {
|
||||
it('should terminate network waiters', async({browserType, server}) => {
|
||||
const browserServer = await browserType.launchServer({...defaultBrowserOptions });
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const newPage = await remote.newPage();
|
||||
|
|
@ -227,7 +223,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
expect(message).not.toContain('Timeout');
|
||||
}
|
||||
});
|
||||
it('should fire close event for all contexts', async(state, test) => {
|
||||
it('should fire close event for all contexts', async({browserType}) => {
|
||||
const browser = await browserType.launch(defaultBrowserOptions);
|
||||
const context = await browser.newContext();
|
||||
let closed = false;
|
||||
|
|
@ -235,10 +231,10 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browser.close();
|
||||
expect(closed).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('browserType.launch |webSocket| option', function() {
|
||||
it('should support the webSocket option', async() => {
|
||||
describe('browserType.launch |webSocket| option', function() {
|
||||
it('should support the webSocket option', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const browserContext = await browser.newContext();
|
||||
|
|
@ -251,17 +247,17 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should fire "disconnected" when closing with webSocket', async() => {
|
||||
it('should fire "disconnected" when closing with webSocket', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const disconnectedEventPromise = new Promise(resolve => browser.once('disconnected', resolve));
|
||||
browserServer.kill();
|
||||
await disconnectedEventPromise;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('browserType.connect', function() {
|
||||
it.slow()('should be able to reconnect to a browser', async({server}) => {
|
||||
describe('browserType.connect', function() {
|
||||
it.slow()('should be able to reconnect to a browser', async({browserType, server}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
{
|
||||
const browser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -280,10 +276,10 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('browserType.launchPersistentContext', function() {
|
||||
it('userDataDir option', async({server}) => {
|
||||
describe('browserType.launchPersistentContext', function() {
|
||||
it('userDataDir option', async({browserType}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const options = Object.assign(defaultBrowserOptions);
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, options);
|
||||
|
|
@ -295,7 +291,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
// This might throw. See https://github.com/GoogleChrome/puppeteer/issues/2778
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
it.slow()('userDataDir option should restore state', async({server}) => {
|
||||
it.slow()('userDataDir option should restore state', async({browserType, server}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
|
||||
const page = await browserContext.newPage();
|
||||
|
|
@ -321,7 +317,7 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await removeUserDataDir(userDataDir2);
|
||||
});
|
||||
// See https://github.com/microsoft/playwright/issues/717
|
||||
it.slow().fail(WIN && CHROMIUM)('userDataDir option should restore cookies', async({server}) => {
|
||||
it.slow().fail(WIN && CHROMIUM)('userDataDir option should restore cookies', async({browserType, server}) => {
|
||||
const userDataDir = await makeUserDataDir();
|
||||
const browserContext = await browserType.launchPersistentContext(userDataDir, defaultBrowserOptions);
|
||||
const page = await browserContext.newPage();
|
||||
|
|
@ -346,5 +342,4 @@ module.exports.describe = function({defaultBrowserOptions, playwright, browserTy
|
|||
await removeUserDataDir(userDataDir);
|
||||
await removeUserDataDir(userDataDir2);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);
|
||||
|
||||
function dimensions() {
|
||||
const rect = document.querySelector('textarea').getBoundingClientRect();
|
||||
return {
|
||||
|
|
@ -25,12 +27,7 @@ function dimensions() {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
||||
|
||||
describe('Mouse', function() {
|
||||
describe('Mouse', function() {
|
||||
it('should click the document', async({page, server}) => {
|
||||
await page.evaluate(() => {
|
||||
window.clickPromise = new Promise(resolve => {
|
||||
|
|
@ -155,5 +152,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, MAC}) {
|
|||
expect(await page.$eval('#target', target => target.contains(document.querySelector('#source')))).toBe(true, 'could not find source in target');
|
||||
})
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,15 +15,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT, defaultBrowserOptions} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {TestSuite}
|
||||
*/
|
||||
module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('BrowserContext', function() {
|
||||
it('should work across sessions', async () => {
|
||||
describe('BrowserContext', function() {
|
||||
it('should work across sessions', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const browser1 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
expect(browser1.contexts().length).toBe(0);
|
||||
|
|
@ -43,10 +38,10 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Browser.Events.disconnected', function() {
|
||||
it.slow()('should be emitted when: browser gets closed, disconnected or underlying websocket gets closed', async () => {
|
||||
describe('Browser.Events.disconnected', function() {
|
||||
it.slow()('should be emitted when: browser gets closed, disconnected or underlying websocket gets closed', async ({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const originalBrowser = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const wsEndpoint = browserServer.wsEndpoint();
|
||||
|
|
@ -79,10 +74,10 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
expect(disconnectedRemote1).toBe(1);
|
||||
expect(disconnectedRemote2).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('browserType.connect', function() {
|
||||
it('should be able to connect multiple times to the same browser', async({server}) => {
|
||||
describe('browserType.connect', function() {
|
||||
it('should be able to connect multiple times to the same browser', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
const browser1 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
const browser2 = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -96,7 +91,7 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
it('should not be able to close remote browser', async() => {
|
||||
it('should not be able to close remote browser', async({browserType}) => {
|
||||
const browserServer = await browserType.launchServer(defaultBrowserOptions);
|
||||
{
|
||||
const remote = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() });
|
||||
|
|
@ -111,5 +106,4 @@ module.exports.describe = function({defaultBrowserOptions, browserType, FFOX, CH
|
|||
await browserServer._checkLeaks();
|
||||
await browserServer.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,13 +18,9 @@
|
|||
const utils = require('./utils');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('Page.goto', function() {
|
||||
describe('Page.goto', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(page.url()).toBe(server.EMPTY_PAGE);
|
||||
|
|
@ -614,9 +610,9 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.waitForNavigation', function() {
|
||||
describe('Page.waitForNavigation', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const [response] = await Promise.all([
|
||||
|
|
@ -799,9 +795,9 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
expect(await page.evaluate('document.location.href')).toBe(url);
|
||||
await gotoPromise;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.waitForLoadState', () => {
|
||||
describe('Page.waitForLoadState', () => {
|
||||
it('should pick up ongoing navigation', async({page, server}) => {
|
||||
let response = null;
|
||||
server.setRoute('/one-style.css', (req, res) => response = res);
|
||||
|
|
@ -931,7 +927,7 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
});
|
||||
});
|
||||
|
||||
describe('Page.goBack', function() {
|
||||
describe('Page.goBack', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
|
|
@ -962,9 +958,9 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
await page.goForward();
|
||||
expect(page.url()).toBe(server.PREFIX + '/first.html');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.goto', function() {
|
||||
describe('Frame.goto', function() {
|
||||
it('should navigate subframes', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
||||
expect(page.frames()[0].url()).toContain('/frames/one-frame.html');
|
||||
|
|
@ -1011,9 +1007,9 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
expect(await response.text()).toBe(serverResponseTexts[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.waitForNavigation', function() {
|
||||
describe('Frame.waitForNavigation', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
||||
const frame = page.frames()[1];
|
||||
|
|
@ -1038,9 +1034,9 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
]).catch(e => error = e);
|
||||
expect(error.message).toContain('frame was detached');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame._waitForLodState', function() {
|
||||
describe('Frame._waitForLodState', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
||||
const frame = page.frames()[1];
|
||||
|
|
@ -1056,18 +1052,18 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
request.continue();
|
||||
await loadPromise;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.reload', function() {
|
||||
describe('Page.reload', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.evaluate(() => window._foo = 10);
|
||||
await page.reload();
|
||||
expect(await page.evaluate(() => window._foo)).toBe(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function expectSSLError(errorMessage) {
|
||||
function expectSSLError(errorMessage) {
|
||||
if (CHROMIUM) {
|
||||
expect(errorMessage).toContain('net::ERR_CERT_AUTHORITY_INVALID');
|
||||
} else if (WEBKIT) {
|
||||
|
|
@ -1080,6 +1076,4 @@ module.exports.describe = function({playwright, MAC, WIN, FFOX, CHROMIUM, WEBKIT
|
|||
} else {
|
||||
expect(errorMessage).toContain('SSL_ERROR_UNKNOWN');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,9 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT, MAC, WIN} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('Page.Events.Request', function() {
|
||||
describe('Page.Events.Request', function() {
|
||||
it('should fire for navigation requests', async({page, server}) => {
|
||||
const requests = [];
|
||||
page.on('request', request => requests.push(request));
|
||||
|
|
@ -45,9 +41,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await page.evaluate(() => fetch('/empty.html'));
|
||||
expect(requests.length).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.frame', function() {
|
||||
describe('Request.frame', function() {
|
||||
it('should work for main frame navigation request', async({page, server}) => {
|
||||
const requests = [];
|
||||
page.on('request', request => requests.push(request));
|
||||
|
|
@ -72,9 +68,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(requests.length).toBe(1);
|
||||
expect(requests[0].frame()).toBe(page.mainFrame());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.headers', function() {
|
||||
describe('Request.headers', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
if (CHROMIUM)
|
||||
|
|
@ -84,9 +80,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
else if (WEBKIT)
|
||||
expect(response.request().headers()['user-agent']).toContain('WebKit');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Response.headers', function() {
|
||||
describe('Response.headers', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
server.setRoute('/empty.html', (req, res) => {
|
||||
res.setHeader('foo', 'bar');
|
||||
|
|
@ -95,9 +91,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response.headers()['foo']).toBe('bar');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.postData', function() {
|
||||
describe('Request.postData', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
server.setRoute('/post', (req, res) => res.end());
|
||||
|
|
@ -111,9 +107,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const response = await page.goto(server.EMPTY_PAGE);
|
||||
expect(response.request().postData()).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Response.text', function() {
|
||||
describe('Response.text', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const response = await page.goto(server.PREFIX + '/simple.json');
|
||||
expect(await response.text()).toBe('{"foo": "bar"}\n');
|
||||
|
|
@ -168,16 +164,16 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await new Promise(x => serverResponse.end('ld!', x));
|
||||
expect(await responseText).toBe('hello world!');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Response.json', function() {
|
||||
describe('Response.json', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const response = await page.goto(server.PREFIX + '/simple.json');
|
||||
expect(await response.json()).toEqual({foo: 'bar'});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Response.body', function() {
|
||||
describe('Response.body', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
const response = await page.goto(server.PREFIX + '/pptr.png');
|
||||
const imageBuffer = fs.readFileSync(path.join(__dirname, 'assets', 'pptr.png'));
|
||||
|
|
@ -191,9 +187,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const responseBuffer = await response.body();
|
||||
expect(responseBuffer.equals(imageBuffer)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Response.statusText', function() {
|
||||
describe('Response.statusText', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
server.setRoute('/cool', (req, res) => {
|
||||
res.writeHead(200, 'cool!');
|
||||
|
|
@ -202,9 +198,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const response = await page.goto(server.PREFIX + '/cool');
|
||||
expect(response.statusText()).toBe('cool!');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Network Events', function() {
|
||||
describe('Network Events', function() {
|
||||
it('Page.Events.Request', async({page, server}) => {
|
||||
const requests = [];
|
||||
page.on('request', request => requests.push(request));
|
||||
|
|
@ -297,9 +293,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(redirectedFrom.redirectedFrom()).toBe(null);
|
||||
expect(redirectedFrom.redirectedTo()).toBe(response.request());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Request.isNavigationRequest', () => {
|
||||
describe('Request.isNavigationRequest', () => {
|
||||
it('should work', async({page, server}) => {
|
||||
const requests = new Map();
|
||||
page.on('request', request => requests.set(request.url().split('/').pop(), request));
|
||||
|
|
@ -317,9 +313,9 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await page.goto(server.PREFIX + '/pptr.png');
|
||||
expect(requests[0].isNavigationRequest()).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.setExtraHTTPHeaders', function() {
|
||||
describe('Page.setExtraHTTPHeaders', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.setExtraHTTPHeaders({
|
||||
foo: 'bar'
|
||||
|
|
@ -368,5 +364,4 @@ module.exports.describe = function({MAC, WIN, FFOX, CHROMIUM, WEBKIT}) {
|
|||
}
|
||||
expect(error.message).toBe('Expected value of header "foo" to be String, but "number" is found.');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,13 +17,9 @@
|
|||
|
||||
const path = require('path');
|
||||
const vm = require('vm');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('Page.close', function() {
|
||||
describe('Page.close', function() {
|
||||
it('should reject all promises when page is closed', async({context}) => {
|
||||
const newPage = await context.newPage();
|
||||
let error = null;
|
||||
|
|
@ -85,18 +81,18 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(message).not.toContain('Timeout');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.Events.Load', function() {
|
||||
describe('Page.Events.Load', function() {
|
||||
it('should fire when expected', async({page, server}) => {
|
||||
await Promise.all([
|
||||
page.goto('about:blank'),
|
||||
page.waitForEvent('load'),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Async stacks', () => {
|
||||
describe('Async stacks', () => {
|
||||
it('should work', async({page, server}) => {
|
||||
server.setRoute('/empty.html', (req, res) => {
|
||||
req.socket.end();
|
||||
|
|
@ -106,9 +102,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(error).not.toBe(null);
|
||||
expect(error.stack).toContain(__filename);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.Events.error', function() {
|
||||
describe('Page.Events.error', function() {
|
||||
it('should throw when page crashes', async({page}) => {
|
||||
await page.setContent(`<div>This page should crash</div>`);
|
||||
let error = null;
|
||||
|
|
@ -122,9 +118,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await new Promise(f => page.on('error', f));
|
||||
expect(error.message).toBe('Page crashed!');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.opener', function() {
|
||||
describe('Page.opener', function() {
|
||||
it('should provide access to the opener page', async({page}) => {
|
||||
const [popup] = await Promise.all([
|
||||
page.waitForEvent('popup'),
|
||||
|
|
@ -142,9 +138,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const opener = await popup.opener();
|
||||
expect(opener).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.Events.Console', function() {
|
||||
describe('Page.Events.Console', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
let message = null;
|
||||
page.once('console', m => message = m);
|
||||
|
|
@ -241,17 +237,17 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
// 4. Connect to the popup and make sure it doesn't throw.
|
||||
expect(await popup.evaluate('1 + 1')).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.Events.DOMContentLoaded', function() {
|
||||
describe('Page.Events.DOMContentLoaded', function() {
|
||||
it('should fire when expected', async({page, server}) => {
|
||||
const navigatedPromise = page.goto('about:blank');
|
||||
await page.waitForEvent('domcontentloaded');
|
||||
await navigatedPromise;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.waitForRequest', function() {
|
||||
describe('Page.waitForRequest', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const [request] = await Promise.all([
|
||||
|
|
@ -322,9 +318,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
]);
|
||||
expect(request.url()).toBe(server.PREFIX + '/digits/1.png');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.waitForResponse', function() {
|
||||
describe('Page.waitForResponse', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const [response] = await Promise.all([
|
||||
|
|
@ -372,9 +368,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
]);
|
||||
expect(response.url()).toBe(server.PREFIX + '/digits/2.png');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.exposeFunction', function() {
|
||||
describe('Page.exposeFunction', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.exposeFunction('compute', function(a, b) {
|
||||
return a * b;
|
||||
|
|
@ -484,9 +480,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const result = await page.evaluate(async() => complexObject({x: 5}, {x: 2}));
|
||||
expect(result.x).toBe(7);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.Events.PageError', function() {
|
||||
describe('Page.Events.PageError', function() {
|
||||
it('should fire', async({page, server}) => {
|
||||
let error = null;
|
||||
page.once('pageerror', e => error = e);
|
||||
|
|
@ -496,9 +492,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
]);
|
||||
expect(error.message).toContain('Fancy');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.setContent', function() {
|
||||
describe('Page.setContent', function() {
|
||||
const expectedOutput = '<html><head></head><body><div>hello</div></body></html>';
|
||||
it('should work', async({page, server}) => {
|
||||
await page.setContent('<div>hello</div>');
|
||||
|
|
@ -571,10 +567,10 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await page.setContent('<div>\n</div>');
|
||||
expect(await page.$eval('div', div => div.textContent)).toBe('\n');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Page.addScriptTag', function() {
|
||||
describe('Page.addScriptTag', function() {
|
||||
it('should throw an error if no options are provided', async({page, server}) => {
|
||||
let error = null;
|
||||
try {
|
||||
|
|
@ -658,9 +654,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await page.addScriptTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedfile.js' }).catch(e => error = e);
|
||||
expect(error).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.addStyleTag', function() {
|
||||
describe('Page.addStyleTag', function() {
|
||||
it('should throw an error if no options are provided', async({page, server}) => {
|
||||
let error = null;
|
||||
try {
|
||||
|
|
@ -724,24 +720,24 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await page.addStyleTag({ url: server.CROSS_PROCESS_PREFIX + '/injectedstyle.css' }).catch(e => error = e);
|
||||
expect(error).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.url', function() {
|
||||
describe('Page.url', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
expect(page.url()).toBe('about:blank');
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
expect(page.url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.title', function() {
|
||||
describe('Page.title', function() {
|
||||
it('should return the page title', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/title.html');
|
||||
expect(await page.title()).toBe('Woof-Woof');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.select', function() {
|
||||
describe('Page.select', function() {
|
||||
it('should select single option', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
await page.selectOption('select', 'blue');
|
||||
|
|
@ -901,9 +897,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(await page.evaluate(() => result.onInput)).toEqual(['blue']);
|
||||
expect(await page.evaluate(() => result.onChange)).toEqual(['blue']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.fill', function() {
|
||||
describe('Page.fill', function() {
|
||||
it('should fill textarea', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/textarea.html');
|
||||
await page.fill('textarea', 'some value');
|
||||
|
|
@ -1074,9 +1070,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await page.fill('input', '');
|
||||
expect(await page.evaluate(() => result)).toBe('');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.Events.Close', function() {
|
||||
describe('Page.Events.Close', function() {
|
||||
it('should work with window.close', async function({ page, context, server }) {
|
||||
const newPagePromise = page.waitForEvent('popup');
|
||||
await page.evaluate(() => window['newPage'] = window.open('about:blank'));
|
||||
|
|
@ -1091,15 +1087,15 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await newPage.close();
|
||||
await closedPromise;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.browserContext', function() {
|
||||
describe('Page.browserContext', function() {
|
||||
it('should return the correct browser instance', async function({page, context}) {
|
||||
expect(page.context()).toBe(context);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.frame', function() {
|
||||
describe('Page.frame', function() {
|
||||
it('should respect name', async function({page, server}) {
|
||||
await page.setContent(`<iframe name=target></iframe>`);
|
||||
expect(page.frame({ name: 'bogus' })).toBe(null);
|
||||
|
|
@ -1112,9 +1108,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(page.frame({ url: /bogus/ })).toBe(null);
|
||||
expect(page.frame({ url: /empty/ }).url()).toBe(server.EMPTY_PAGE);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page api coverage', function() {
|
||||
describe('Page api coverage', function() {
|
||||
it('Page.press should work', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/input/textarea.html');
|
||||
await page.press('textarea', 'a');
|
||||
|
|
@ -1126,5 +1122,4 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await frame.press('textarea', 'a');
|
||||
expect(await frame.evaluate(() => document.querySelector('textarea').value)).toBe('a');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,13 +15,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({WEBKIT, FFOX}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
// Permissions API is not implemented in WebKit (see https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API)
|
||||
describe.skip(WEBKIT)('Permissions', function() {
|
||||
// Permissions API is not implemented in WebKit (see https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API)
|
||||
describe.skip(WEBKIT)('Permissions', function() {
|
||||
function getPermission(page, name) {
|
||||
return page.evaluate(name => navigator.permissions.query({name}).then(result => result.state), name);
|
||||
}
|
||||
|
|
@ -122,5 +119,4 @@ module.exports.describe = function({WEBKIT, FFOX}) {
|
|||
expect(await getPermission(otherPage, 'geolocation')).toBe('granted');
|
||||
await otherContext.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -80,9 +80,11 @@ module.exports.addPlaywrightTests = ({testRunner, products}) => {
|
|||
const playwrightEnvironment = new Environment('Playwright');
|
||||
playwrightEnvironment.beforeAll(async state => {
|
||||
state.playwright = playwright;
|
||||
global.playwright = playwright;
|
||||
});
|
||||
playwrightEnvironment.afterAll(async state => {
|
||||
delete state.playwright;
|
||||
delete global.playwright;
|
||||
});
|
||||
|
||||
for (const product of products) {
|
||||
|
|
@ -143,21 +145,6 @@ module.exports.addPlaywrightTests = ({testRunner, products}) => {
|
|||
state.page = null;
|
||||
});
|
||||
|
||||
function loadTests(modulePath) {
|
||||
const testOptions = {
|
||||
...require('./utils').testOptions(global.browserType),
|
||||
playwright: global.playwright,
|
||||
browserType: global.browserType,
|
||||
};
|
||||
const module = require(modulePath);
|
||||
if (typeof module.describe === 'function')
|
||||
describe('', module.describe, testOptions);
|
||||
if (typeof module.fdescribe === 'function')
|
||||
fdescribe('', module.fdescribe, testOptions);
|
||||
if (typeof module.xdescribe === 'function')
|
||||
xdescribe('', module.xdescribe, testOptions);
|
||||
}
|
||||
|
||||
testRunner.collector().useEnvironment(serverEnvironment); // Custom global environment.
|
||||
testRunner.collector().useEnvironment(playwrightEnvironment);
|
||||
|
||||
|
|
@ -177,71 +164,66 @@ module.exports.addPlaywrightTests = ({testRunner, products}) => {
|
|||
|
||||
// Page-level tests that are given a browser, a context and a page.
|
||||
// Each test is launched in a new browser context.
|
||||
describe('[Accessibility]', () => loadTests('./accessibility.spec.js'));
|
||||
describe('[Driver]', () => {
|
||||
loadTests('./autowaiting.spec.js');
|
||||
loadTests('./click.spec.js');
|
||||
loadTests('./cookies.spec.js');
|
||||
loadTests('./dialog.spec.js');
|
||||
loadTests('./download.spec.js');
|
||||
loadTests('./elementhandle.spec.js');
|
||||
loadTests('./emulation.spec.js');
|
||||
loadTests('./evaluation.spec.js');
|
||||
loadTests('./frame.spec.js');
|
||||
loadTests('./focus.spec.js');
|
||||
loadTests('./input.spec.js');
|
||||
loadTests('./jshandle.spec.js');
|
||||
loadTests('./keyboard.spec.js');
|
||||
loadTests('./mouse.spec.js');
|
||||
loadTests('./navigation.spec.js');
|
||||
loadTests('./network.spec.js');
|
||||
loadTests('./page.spec.js');
|
||||
loadTests('./queryselector.spec.js');
|
||||
loadTests('./screenshot.spec.js');
|
||||
loadTests('./waittask.spec.js');
|
||||
loadTests('./interception.spec.js');
|
||||
loadTests('./geolocation.spec.js');
|
||||
loadTests('./workers.spec.js');
|
||||
loadTests('./capabilities.spec.js');
|
||||
});
|
||||
describe('[Permissions]', () => {
|
||||
loadTests('./permissions.spec.js');
|
||||
});
|
||||
require('./accessibility.spec.js');
|
||||
require('./autowaiting.spec.js');
|
||||
require('./click.spec.js');
|
||||
require('./cookies.spec.js');
|
||||
require('./dialog.spec.js');
|
||||
require('./download.spec.js');
|
||||
require('./elementhandle.spec.js');
|
||||
require('./emulation.spec.js');
|
||||
require('./evaluation.spec.js');
|
||||
require('./frame.spec.js');
|
||||
require('./focus.spec.js');
|
||||
require('./input.spec.js');
|
||||
require('./jshandle.spec.js');
|
||||
require('./keyboard.spec.js');
|
||||
require('./mouse.spec.js');
|
||||
require('./navigation.spec.js');
|
||||
require('./network.spec.js');
|
||||
require('./page.spec.js');
|
||||
require('./queryselector.spec.js');
|
||||
require('./screenshot.spec.js');
|
||||
require('./waittask.spec.js');
|
||||
require('./interception.spec.js');
|
||||
require('./geolocation.spec.js');
|
||||
require('./workers.spec.js');
|
||||
require('./capabilities.spec.js');
|
||||
require('./permissions.spec.js');
|
||||
|
||||
describe.skip(product !== 'Chromium')('[Chromium]', () => {
|
||||
loadTests('./chromium/chromium.spec.js');
|
||||
loadTests('./chromium/coverage.spec.js');
|
||||
loadTests('./chromium/pdf.spec.js');
|
||||
loadTests('./chromium/session.spec.js');
|
||||
require('./chromium/chromium.spec.js');
|
||||
require('./chromium/coverage.spec.js');
|
||||
require('./chromium/pdf.spec.js');
|
||||
require('./chromium/session.spec.js');
|
||||
});
|
||||
});
|
||||
|
||||
// Browser-level tests that are given a browser.
|
||||
describe('[Driver]', () => {
|
||||
loadTests('./browser.spec.js');
|
||||
loadTests('./browsercontext.spec.js');
|
||||
loadTests('./ignorehttpserrors.spec.js');
|
||||
loadTests('./popup.spec.js');
|
||||
require('./browser.spec.js');
|
||||
require('./browsercontext.spec.js');
|
||||
require('./ignorehttpserrors.spec.js');
|
||||
require('./popup.spec.js');
|
||||
});
|
||||
});
|
||||
|
||||
// Top-level tests that launch Browser themselves.
|
||||
describe('[Driver]', () => {
|
||||
loadTests('./defaultbrowsercontext.spec.js');
|
||||
loadTests('./fixtures.spec.js');
|
||||
loadTests('./launcher.spec.js');
|
||||
loadTests('./headful.spec.js');
|
||||
loadTests('./multiclient.spec.js');
|
||||
require('./defaultbrowsercontext.spec.js');
|
||||
require('./fixtures.spec.js');
|
||||
require('./launcher.spec.js');
|
||||
require('./headful.spec.js');
|
||||
require('./multiclient.spec.js');
|
||||
});
|
||||
|
||||
describe.skip(product !== 'Chromium')('[Chromium]', () => {
|
||||
loadTests('./chromium/launcher.spec.js');
|
||||
loadTests('./chromium/oopif.spec.js');
|
||||
loadTests('./chromium/tracing.spec.js');
|
||||
require('./chromium/launcher.spec.js');
|
||||
require('./chromium/oopif.spec.js');
|
||||
require('./chromium/tracing.spec.js');
|
||||
});
|
||||
|
||||
if (process.env.COVERAGE)
|
||||
loadTests('./apicoverage.spec.js');
|
||||
require('./apicoverage.spec.js');
|
||||
|
||||
delete global.browserType;
|
||||
delete global.playwright;
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports.describe = function({playwright, CHROMIUM, WEBKIT, FFOX}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Link navigation', function() {
|
||||
describe('Link navigation', function() {
|
||||
it('should inherit user agent from browser context', async function({browser, server}) {
|
||||
const context = await browser.newContext({
|
||||
userAgent: 'hey'
|
||||
|
|
@ -53,9 +53,9 @@ module.exports.describe = function({playwright, CHROMIUM, WEBKIT, FFOX}) {
|
|||
await context.close();
|
||||
expect(intercepted).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('window.open', function() {
|
||||
describe('window.open', function() {
|
||||
it('should inherit user agent from browser context', async function({browser, server}) {
|
||||
const context = await browser.newContext({
|
||||
userAgent: 'hey'
|
||||
|
|
@ -178,9 +178,9 @@ module.exports.describe = function({playwright, CHROMIUM, WEBKIT, FFOX}) {
|
|||
await context.close();
|
||||
expect(added).toBe(13);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.Events.Popup', function() {
|
||||
describe('Page.Events.Popup', function() {
|
||||
it('should work', async({browser}) => {
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
|
@ -332,6 +332,4 @@ module.exports.describe = function({playwright, CHROMIUM, WEBKIT, FFOX}) {
|
|||
await context.close();
|
||||
expect(badSecondPopup).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,13 +17,9 @@
|
|||
|
||||
const path = require('path');
|
||||
const zsSelectorEngineSource = require('../lib/generated/zsSelectorEngineSource');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('Page.$eval', function() {
|
||||
describe('Page.$eval', function() {
|
||||
it('should work with css selector', async({page, server}) => {
|
||||
await page.setContent('<section id="testAttribute">43543</section>');
|
||||
const idAttribute = await page.$eval('css=section', e => e.id);
|
||||
|
|
@ -128,9 +124,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const html = await page.$eval('button >> "Next"', e => e.outerHTML);
|
||||
expect(html).toBe('<button>Next</button>');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.$$eval', function() {
|
||||
describe('Page.$$eval', function() {
|
||||
it('should work with css selector', async({page, server}) => {
|
||||
await page.setContent('<div>hello</div><div>beautiful</div><div>world!</div>');
|
||||
const divsCount = await page.$$eval('css=div', divs => divs.length);
|
||||
|
|
@ -161,9 +157,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const spansCount = await page.$$eval('css=div >> css=div >> css=span', spans => spans.length);
|
||||
expect(spansCount).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.$', function() {
|
||||
describe('Page.$', function() {
|
||||
it('should query existing element with css selector', async({page, server}) => {
|
||||
await page.setContent('<section>test</section>');
|
||||
const element = await page.$('css=section');
|
||||
|
|
@ -208,9 +204,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const element = await page.$('css=section >> css=div');
|
||||
expect(element).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.$$', function() {
|
||||
describe('Page.$$', function() {
|
||||
it('should query existing elements', async({page, server}) => {
|
||||
await page.setContent('<div>A</div><br/><div>B</div>');
|
||||
const elements = await page.$$('div');
|
||||
|
|
@ -223,9 +219,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const elements = await page.$$('div');
|
||||
expect(elements.length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.$$ xpath', function() {
|
||||
describe('Page.$$ xpath', function() {
|
||||
it('should query existing element', async({page, server}) => {
|
||||
await page.setContent('<section>test</section>');
|
||||
const elements = await page.$$('xpath=/html/body/section');
|
||||
|
|
@ -241,9 +237,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const elements = await page.$$('xpath=/html/body/div');
|
||||
expect(elements.length).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.$', function() {
|
||||
describe('ElementHandle.$', function() {
|
||||
it('should query existing element', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/playground.html');
|
||||
await page.setContent('<html><body><div class="second"><div class="inner">A</div></div></body></html>');
|
||||
|
|
@ -260,8 +256,8 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const second = await html.$('.third');
|
||||
expect(second).toBe(null);
|
||||
});
|
||||
});
|
||||
describe('ElementHandle.$eval', function() {
|
||||
});
|
||||
describe('ElementHandle.$eval', function() {
|
||||
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>');
|
||||
const tweet = await page.$('.tweet');
|
||||
|
|
@ -284,8 +280,8 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const errorMessage = await elementHandle.$eval('.a', node => node.innerText).catch(error => error.message);
|
||||
expect(errorMessage).toBe(`Error: failed to find element matching selector ".a"`);
|
||||
});
|
||||
});
|
||||
describe('ElementHandle.$$eval', function() {
|
||||
});
|
||||
describe('ElementHandle.$$eval', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.setContent('<html><body><div class="tweet"><div class="like">100</div><div class="like">10</div></div></body></html>');
|
||||
const tweet = await page.$('.tweet');
|
||||
|
|
@ -309,9 +305,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(nodesLength).toBe(0);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.$$', function() {
|
||||
describe('ElementHandle.$$', function() {
|
||||
it('should query existing elements', async({page, server}) => {
|
||||
await page.setContent('<html><body><div>A</div><br/><div>B</div></body></html>');
|
||||
const html = await page.$('html');
|
||||
|
|
@ -327,10 +323,10 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const elements = await html.$$('div');
|
||||
expect(elements.length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('ElementHandle.$$ xpath', function() {
|
||||
describe('ElementHandle.$$ xpath', function() {
|
||||
it('should query existing element', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/playground.html');
|
||||
await page.setContent('<html><body><div class="second"><div class="inner">A</div></div></body></html>');
|
||||
|
|
@ -347,9 +343,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const second = await html.$$(`xpath=/div[contains(@class, 'third')]`);
|
||||
expect(second).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('zselector', () => {
|
||||
describe('zselector', () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await playwright.selectors.register('z', zsSelectorEngineSource.source);
|
||||
|
|
@ -484,9 +480,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const content = await page.evaluate(e => e.textContent, inner);
|
||||
expect(content).toBe('A');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('text selector', () => {
|
||||
describe('text selector', () => {
|
||||
it('query', async ({page}) => {
|
||||
await page.setContent(`<div>yo</div><div>ya</div><div>\nye </div>`);
|
||||
expect(await page.$eval(`text=ya`, e => e.outerHTML)).toBe('<div>ya</div>');
|
||||
|
|
@ -550,18 +546,18 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(await page.$eval(`text=root2`, e => e.textContent)).toBe('Hello from root2');
|
||||
expect(await page.$eval(`text=root3`, e => e.textContent)).toBe('Hello from root3');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('attribute selector', () => {
|
||||
describe('attribute selector', () => {
|
||||
it('should work for open shadow roots', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/deep-shadow.html');
|
||||
expect(await page.$eval(`id=target`, e => e.textContent)).toBe('Hello from root2');
|
||||
expect(await page.$eval(`data-testid=foo`, e => e.textContent)).toBe('Hello from root1');
|
||||
expect(await page.$$eval(`data-testid=foo`, els => els.length)).toBe(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('selectors.register', () => {
|
||||
describe('selectors.register', () => {
|
||||
it('should work', async ({page}) => {
|
||||
const createTagSelector = () => ({
|
||||
create(root, target) {
|
||||
|
|
@ -649,5 +645,4 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
error = await playwright.selectors.register('css', createDummySelector).catch(e => e);
|
||||
expect(error.message).toBe('"css" is a predefined selector engine');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX }) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Page.screenshot', function() {
|
||||
describe('Page.screenshot', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.setViewportSize({width: 500, height: 500});
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
|
|
@ -222,9 +219,9 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX }) {
|
|||
expect(screenshot).toBeGolden('screenshot-device-scale-factor.png');
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementHandle.screenshot', function() {
|
||||
describe('ElementHandle.screenshot', function() {
|
||||
it('should work', async({page, server}) => {
|
||||
await page.setViewportSize({width: 500, height: 500});
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
|
|
@ -479,5 +476,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX }) {
|
|||
expect(sizeBefore.height).toBe(sizeAfter.height);
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,13 +16,9 @@
|
|||
*/
|
||||
|
||||
const utils = require('./utils');
|
||||
const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
||||
|
||||
describe('Page.waitFor', function() {
|
||||
describe('Page.waitFor', function() {
|
||||
it('should wait for selector', async({page, server}) => {
|
||||
let found = false;
|
||||
const waitFor = page.waitFor('div').then(() => found = true);
|
||||
|
|
@ -73,9 +69,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
it('should wait for predicate with arguments', async({page, server}) => {
|
||||
await page.waitFor(({arg1, arg2}) => arg1 + arg2 === 3, {}, { arg1: 1, arg2: 2});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.waitForFunction', function() {
|
||||
describe('Frame.waitForFunction', function() {
|
||||
it('should accept a string', async({page, server}) => {
|
||||
const watchdog = page.waitForFunction('window.__FOO === 1');
|
||||
await page.evaluate(() => window.__FOO = 1);
|
||||
|
|
@ -202,9 +198,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
await page.evaluate(() => window.__done = true);
|
||||
await watchdog;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.waitForSelector', function() {
|
||||
describe('Frame.waitForSelector', function() {
|
||||
const addElement = tag => document.body.appendChild(document.createElement(tag));
|
||||
it('should immediately resolve promise if node exists', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
|
@ -414,9 +410,9 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
expect(await waitFor).toBe(true);
|
||||
expect(done).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Frame.waitForSelector xpath', function() {
|
||||
describe('Frame.waitForSelector xpath', function() {
|
||||
const addElement = tag => document.body.appendChild(document.createElement(tag));
|
||||
|
||||
it('should support some fancy xpath', async({page, server}) => {
|
||||
|
|
@ -462,6 +458,4 @@ module.exports.describe = function({playwright, FFOX, CHROMIUM, WEBKIT}) {
|
|||
const waitForXPath = page.waitForSelector('//html/body/div');
|
||||
expect(await page.evaluate(x => x.textContent, await waitForXPath)).toBe('some text');
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,12 +15,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {PageTestSuite}
|
||||
*/
|
||||
module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
||||
const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);
|
||||
|
||||
describe('Workers', function() {
|
||||
describe('Workers', function() {
|
||||
it('Page.workers', async function({page, server}) {
|
||||
await Promise.all([
|
||||
page.waitForEvent('worker'),
|
||||
|
|
@ -136,5 +133,4 @@ module.exports.describe = function({FFOX, CHROMIUM, WEBKIT, LINUX}) {
|
|||
expect(await worker.evaluate(() => (10000.20).toLocaleString())).toBe('10\u00A0000,2');
|
||||
await context.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue