mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-28 09:23:42 +03:00
chore: align more ESLint rules with VSCode formatting (#16647)
This commit is contained in:
parent
d2a950c8d6
commit
7e2aec7454
@ -79,6 +79,9 @@ module.exports = {
|
||||
// spacing details
|
||||
"space-infix-ops": 2,
|
||||
"space-in-parens": [2, "never"],
|
||||
"array-bracket-spacing": [2, "never"],
|
||||
"comma-spacing": [2, { "before": false, "after": true }],
|
||||
"keyword-spacing": [2, "always"],
|
||||
"space-before-function-paren": [2, {
|
||||
"anonymous": "never",
|
||||
"named": "never",
|
||||
|
@ -27,7 +27,7 @@ const config: PlaywrightTestConfig = {
|
||||
ctPort: 3101,
|
||||
trace: 'on-first-retry',
|
||||
},
|
||||
projects: [ ],
|
||||
projects: [],
|
||||
};
|
||||
|
||||
if (process.env.REBASE) {
|
||||
|
@ -76,7 +76,7 @@ export const TestResultView: React.FC<{
|
||||
[...screenshots, ...videos, ...traces].forEach(a => otherAttachments.delete(a));
|
||||
const diffs = groupImageDiffs(screenshots);
|
||||
return { screenshots: [...screenshots], videos, traces, otherAttachments, diffs };
|
||||
}, [ result ]);
|
||||
}, [result]);
|
||||
|
||||
const videoRef = React.useRef<HTMLDivElement>(null);
|
||||
const imageDiffRef = React.useRef<HTMLDivElement>(null);
|
||||
|
@ -432,7 +432,7 @@ async function launchContext(options: Options, headless: boolean, executablePath
|
||||
// Viewport size
|
||||
if (options.viewportSize) {
|
||||
try {
|
||||
const [ width, height ] = options.viewportSize.split(',').map(n => parseInt(n, 10));
|
||||
const [width, height] = options.viewportSize.split(',').map(n => parseInt(n, 10));
|
||||
contextOptions.viewport = { width, height };
|
||||
} catch (e) {
|
||||
console.log('Invalid window size format: use "width, height", for example --window-size=800,600');
|
||||
|
@ -202,7 +202,7 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
|
||||
if (!urls)
|
||||
urls = [];
|
||||
if (urls && typeof urls === 'string')
|
||||
urls = [ urls ];
|
||||
urls = [urls];
|
||||
return (await this._channel.cookies({ urls: urls as string[] })).cookies;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ export function convertSelectOptionValues(values: string | api.ElementHandle | S
|
||||
if (values === null)
|
||||
return {};
|
||||
if (!Array.isArray(values))
|
||||
values = [ values as any ];
|
||||
values = [values as any];
|
||||
if (!values.length)
|
||||
return {};
|
||||
for (let i = 0; i < values.length; i++)
|
||||
@ -263,7 +263,7 @@ type InputFilesList = {
|
||||
streams?: channels.WritableStreamChannel[];
|
||||
};
|
||||
export async function convertInputFiles(files: string | FilePayload | string[] | FilePayload[], context: BrowserContext): Promise<InputFilesList> {
|
||||
const items: (string | FilePayload)[] = Array.isArray(files) ? files.slice() : [ files ];
|
||||
const items: (string | FilePayload)[] = Array.isArray(files) ? files.slice() : [files];
|
||||
|
||||
const sizeLimit = 50 * 1024 * 1024;
|
||||
const hasLargeBuffer = items.find(item => typeof item === 'object' && item.buffer && item.buffer.byteLength > sizeLimit);
|
||||
|
@ -245,7 +245,7 @@ export abstract class BrowserContext extends SdkObject {
|
||||
|
||||
async cookies(urls: string | string[] | undefined = []): Promise<channels.NetworkCookie[]> {
|
||||
if (urls && !Array.isArray(urls))
|
||||
urls = [ urls ];
|
||||
urls = [urls];
|
||||
return await this.doGetCookies(urls as string[]);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ export class Chromium extends BrowserType {
|
||||
const chromeTransport = await WebSocketTransport.connect(progress, wsEndpoint, headersMap);
|
||||
const cleanedUp = new ManualPromise<void>();
|
||||
const doCleanup = async () => {
|
||||
await removeFolders([ artifactsDir ]);
|
||||
await removeFolders([artifactsDir]);
|
||||
await onClose?.();
|
||||
cleanedUp.resolve();
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ import { Browser } from '../browser';
|
||||
import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext';
|
||||
import { assert } from '../../utils';
|
||||
import * as network from '../network';
|
||||
import type { PageBinding, PageDelegate , Worker } from '../page';
|
||||
import type { PageBinding, PageDelegate, Worker } from '../page';
|
||||
import { Page } from '../page';
|
||||
import { Frame } from '../frames';
|
||||
import type { Dialog } from '../dialog';
|
||||
@ -322,7 +322,7 @@ export class CRBrowserContext extends BrowserContext {
|
||||
|
||||
override async _initialize() {
|
||||
assert(!Array.from(this._browser._crPages.values()).some(page => page._browserContext === this));
|
||||
const promises: Promise<any>[] = [ super._initialize() ];
|
||||
const promises: Promise<any>[] = [super._initialize()];
|
||||
if (this._browser.options.name !== 'electron' && this._browser.options.name !== 'clank') {
|
||||
promises.push(this._browser._session.send('Browser.setDownloadBehavior', {
|
||||
behavior: this._options.acceptDownloads ? 'allowAndName' : 'deny',
|
||||
@ -364,7 +364,7 @@ export class CRBrowserContext extends BrowserContext {
|
||||
newKeys.delete(key);
|
||||
}
|
||||
assert(newKeys.size === 1);
|
||||
[ targetId ] = [...newKeys];
|
||||
[targetId] = [...newKeys];
|
||||
}
|
||||
return this._browser._crPages.get(targetId)!;
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ class FrameSession {
|
||||
this._handleFrameTree(frameTree);
|
||||
this._addRendererListeners();
|
||||
}
|
||||
const localFrames = this._isMainFrame() ? this._page.frames() : [ this._page._frameManager.frame(this._targetId)! ];
|
||||
const localFrames = this._isMainFrame() ? this._page.frames() : [this._page._frameManager.frame(this._targetId)!];
|
||||
for (const frame of localFrames) {
|
||||
// Note: frames might be removed before we send these.
|
||||
this._client._sendMayFail('Page.createIsolatedWorld', {
|
||||
@ -822,7 +822,7 @@ class FrameSession {
|
||||
}
|
||||
|
||||
async _initBinding(binding: PageBinding) {
|
||||
const [ , response ] = await Promise.all([
|
||||
const [, response] = await Promise.all([
|
||||
this._client.send('Runtime.addBinding', { name: binding.name }),
|
||||
this._client.send('Page.addScriptToEvaluateOnNewDocument', { source: binding.source })
|
||||
]);
|
||||
|
@ -171,7 +171,7 @@ export class Electron extends SdkObject {
|
||||
},
|
||||
stdio: 'pipe',
|
||||
cwd: options.cwd,
|
||||
tempDirectories: [ artifactsDir ],
|
||||
tempDirectories: [artifactsDir],
|
||||
attemptToGracefullyClose: () => app!.close(),
|
||||
handleSIGINT: true,
|
||||
handleSIGTERM: true,
|
||||
|
@ -163,7 +163,7 @@ export class FFBrowserContext extends BrowserContext {
|
||||
override async _initialize() {
|
||||
assert(!this._ffPages().length);
|
||||
const browserContextId = this._browserContextId;
|
||||
const promises: Promise<any>[] = [ super._initialize() ];
|
||||
const promises: Promise<any>[] = [super._initialize()];
|
||||
promises.push(this._browser._connection.send('Browser.setDownloadOptions', {
|
||||
browserContextId,
|
||||
downloadOptions: {
|
||||
|
@ -529,7 +529,7 @@ export class FFPage implements PageDelegate {
|
||||
});
|
||||
if (!result)
|
||||
return null;
|
||||
return result.quads.map(quad => [ quad.p1, quad.p2, quad.p3, quad.p4 ]);
|
||||
return result.quads.map(quad => [quad.p1, quad.p2, quad.p3, quad.p4]);
|
||||
}
|
||||
|
||||
async setInputFiles(handle: dom.ElementHandle<HTMLInputElement>, files: types.FilePayload[]): Promise<void> {
|
||||
|
@ -159,7 +159,7 @@ function buildCandidates(injectedScript: InjectedScript, element: Element): Sele
|
||||
candidates.push({ engine: 'css', selector: `${cssEscape(element.nodeName.toLowerCase())}[alt=${quoteAttributeValue(element.getAttribute('alt')!)}]`, score: 10 });
|
||||
|
||||
if (element.getAttribute('role'))
|
||||
candidates.push({ engine: 'css', selector: `${cssEscape(element.nodeName.toLowerCase())}[role=${quoteAttributeValue(element.getAttribute('role')!)}]` , score: 50 });
|
||||
candidates.push({ engine: 'css', selector: `${cssEscape(element.nodeName.toLowerCase())}[role=${quoteAttributeValue(element.getAttribute('role')!)}]`, score: 50 });
|
||||
|
||||
if (element.getAttribute('name') && ['BUTTON', 'FORM', 'FIELDSET', 'FRAME', 'IFRAME', 'INPUT', 'KEYGEN', 'OBJECT', 'OUTPUT', 'SELECT', 'TEXTAREA', 'MAP', 'META', 'PARAM'].includes(element.nodeName))
|
||||
candidates.push({ engine: 'css', selector: `${cssEscape(element.nodeName.toLowerCase())}[name=${quoteAttributeValue(element.getAttribute('name')!)}]`, score: 50 });
|
||||
|
@ -229,7 +229,7 @@ export class Route extends SdkObject {
|
||||
private _handled = false;
|
||||
|
||||
constructor(request: Request, delegate: RouteDelegate) {
|
||||
super(request._frame || request._context , 'route');
|
||||
super(request._frame || request._context, 'route');
|
||||
this._request = request;
|
||||
this._delegate = delegate;
|
||||
this._request._context.addRouteInFlight(this);
|
||||
|
@ -334,7 +334,7 @@ export function frameSnapshotStreamer(snapshotStreamer: string) {
|
||||
const checkAndReturn = (n: NodeSnapshot): { equals: boolean, n: NodeSnapshot } => {
|
||||
data.attributesCached = true;
|
||||
if (equals)
|
||||
return { equals: true, n: [[ snapshotNumber - data.ref![0], data.ref![1] ]] };
|
||||
return { equals: true, n: [[snapshotNumber - data.ref![0], data.ref![1]]] };
|
||||
nodeCounter += extraNodes;
|
||||
data.ref = [snapshotNumber, nodeCounter++];
|
||||
data.cached = values;
|
||||
@ -498,7 +498,7 @@ export function frameSnapshotStreamer(snapshotStreamer: string) {
|
||||
const oldCSSText = data.cssText;
|
||||
const cssText = this._updateStyleElementStyleSheetTextIfNeeded(sheet, true /* forceText */)!;
|
||||
if (cssText === oldCSSText)
|
||||
return { equals: true, n: [[ snapshotNumber - data.ref![0], data.ref![1] ]] };
|
||||
return { equals: true, n: [[snapshotNumber - data.ref![0], data.ref![1]]] };
|
||||
data.ref = [snapshotNumber, nodeCounter++];
|
||||
return {
|
||||
equals: false,
|
||||
|
@ -215,7 +215,7 @@ export class WKBrowserContext extends BrowserContext {
|
||||
override async _initialize() {
|
||||
assert(!this._wkPages().length);
|
||||
const browserContextId = this._browserContextId;
|
||||
const promises: Promise<any>[] = [ super._initialize() ];
|
||||
const promises: Promise<any>[] = [super._initialize()];
|
||||
promises.push(this._browser._browserSession.send('Playwright.setDownloadBehavior', {
|
||||
behavior: this._options.acceptDownloads ? 'allow' : 'deny',
|
||||
downloadPath: this._browser.options.downloadsPath,
|
||||
|
@ -123,7 +123,7 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
|
||||
cleanup().then(fulfillCleanup);
|
||||
});
|
||||
|
||||
const listeners = [ eventsHelper.addEventListener(process, 'exit', killProcessAndCleanup) ];
|
||||
const listeners = [eventsHelper.addEventListener(process, 'exit', killProcessAndCleanup)];
|
||||
if (options.handleSIGINT) {
|
||||
listeners.push(eventsHelper.addEventListener(process, 'SIGINT', () => {
|
||||
gracefullyClose().then(() => {
|
||||
|
@ -225,7 +225,7 @@ function resolveReporter(id: string) {
|
||||
const localPath = path.resolve(process.cwd(), id);
|
||||
if (fs.existsSync(localPath))
|
||||
return localPath;
|
||||
return require.resolve(id, { paths: [ process.cwd() ] });
|
||||
return require.resolve(id, { paths: [process.cwd()] });
|
||||
}
|
||||
|
||||
function restartWithExperimentalTsEsm(configFile: string | null): boolean {
|
||||
|
@ -185,7 +185,7 @@ export class Dispatcher {
|
||||
doneCallback();
|
||||
};
|
||||
|
||||
const remainingByTestId = new Map(testGroup.tests.map(e => [ e.id, e ]));
|
||||
const remainingByTestId = new Map(testGroup.tests.map(e => [e.id, e]));
|
||||
const failedTestIds = new Set<string>();
|
||||
|
||||
const onWatchTestResolved = (params: WatchTestResolvedPayload) => {
|
||||
|
@ -54,8 +54,8 @@ type WorkerFixtures = PlaywrightWorkerArgs & PlaywrightWorkerOptions & {
|
||||
};
|
||||
|
||||
export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
||||
defaultBrowserType: [ 'chromium', { scope: 'worker', option: true } ],
|
||||
browserName: [ ({ defaultBrowserType }, use) => use(defaultBrowserType), { scope: 'worker', option: true } ],
|
||||
defaultBrowserType: ['chromium', { scope: 'worker', option: true }],
|
||||
browserName: [({ defaultBrowserType }, use) => use(defaultBrowserType), { scope: 'worker', option: true }],
|
||||
playwright: [async ({ }, use) => {
|
||||
if (process.env.PW_OUT_OF_PROCESS_DRIVER) {
|
||||
const impl = await outOfProcess.start({
|
||||
@ -66,14 +66,14 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
||||
} else {
|
||||
await use(require('playwright-core'));
|
||||
}
|
||||
}, { scope: 'worker' } ],
|
||||
headless: [ ({ launchOptions }, use) => use(launchOptions.headless ?? true), { scope: 'worker', option: true } ],
|
||||
channel: [ ({ launchOptions }, use) => use(launchOptions.channel), { scope: 'worker', option: true } ],
|
||||
launchOptions: [ {}, { scope: 'worker', option: true } ],
|
||||
connectOptions: [ process.env.PW_TEST_CONNECT_WS_ENDPOINT ? { wsEndpoint: process.env.PW_TEST_CONNECT_WS_ENDPOINT } : undefined, { scope: 'worker', option: true } ],
|
||||
screenshot: [ 'off', { scope: 'worker', option: true } ],
|
||||
video: [ 'off', { scope: 'worker', option: true } ],
|
||||
trace: [ 'off', { scope: 'worker', option: true } ],
|
||||
}, { scope: 'worker' }],
|
||||
headless: [({ launchOptions }, use) => use(launchOptions.headless ?? true), { scope: 'worker', option: true }],
|
||||
channel: [({ launchOptions }, use) => use(launchOptions.channel), { scope: 'worker', option: true }],
|
||||
launchOptions: [{}, { scope: 'worker', option: true }],
|
||||
connectOptions: [process.env.PW_TEST_CONNECT_WS_ENDPOINT ? { wsEndpoint: process.env.PW_TEST_CONNECT_WS_ENDPOINT } : undefined, { scope: 'worker', option: true }],
|
||||
screenshot: ['off', { scope: 'worker', option: true }],
|
||||
video: ['off', { scope: 'worker', option: true }],
|
||||
trace: ['off', { scope: 'worker', option: true }],
|
||||
|
||||
_artifactsDir: [async ({}, use, workerInfo) => {
|
||||
let dir: string | undefined;
|
||||
@ -136,34 +136,34 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
|
||||
const browser = await playwright[browserName].launch();
|
||||
await use(browser);
|
||||
await browser.close();
|
||||
}, { scope: 'worker', timeout: 0 } ],
|
||||
}, { scope: 'worker', timeout: 0 }],
|
||||
|
||||
acceptDownloads: [ ({ contextOptions }, use) => use(contextOptions.acceptDownloads ?? true), { option: true } ],
|
||||
bypassCSP: [ ({ contextOptions }, use) => use(contextOptions.bypassCSP), { option: true } ],
|
||||
colorScheme: [ ({ contextOptions }, use) => use(contextOptions.colorScheme), { option: true } ],
|
||||
deviceScaleFactor: [ ({ contextOptions }, use) => use(contextOptions.deviceScaleFactor), { option: true } ],
|
||||
extraHTTPHeaders: [ ({ contextOptions }, use) => use(contextOptions.extraHTTPHeaders), { option: true } ],
|
||||
geolocation: [ ({ contextOptions }, use) => use(contextOptions.geolocation), { option: true } ],
|
||||
hasTouch: [ ({ contextOptions }, use) => use(contextOptions.hasTouch), { option: true } ],
|
||||
httpCredentials: [ ({ contextOptions }, use) => use(contextOptions.httpCredentials), { option: true } ],
|
||||
ignoreHTTPSErrors: [ ({ contextOptions }, use) => use(contextOptions.ignoreHTTPSErrors), { option: true } ],
|
||||
isMobile: [ ({ contextOptions }, use) => use(contextOptions.isMobile), { option: true } ],
|
||||
javaScriptEnabled: [ ({ contextOptions }, use) => use(contextOptions.javaScriptEnabled ?? true), { option: true } ],
|
||||
locale: [ ({ contextOptions }, use) => use(contextOptions.locale ?? 'en-US'), { option: true } ],
|
||||
offline: [ ({ contextOptions }, use) => use(contextOptions.offline), { option: true } ],
|
||||
permissions: [ ({ contextOptions }, use) => use(contextOptions.permissions), { option: true } ],
|
||||
proxy: [ ({ contextOptions }, use) => use(contextOptions.proxy), { option: true } ],
|
||||
storageState: [ ({ contextOptions }, use) => use(contextOptions.storageState), { option: true } ],
|
||||
timezoneId: [ ({ contextOptions }, use) => use(contextOptions.timezoneId), { option: true } ],
|
||||
userAgent: [ ({ contextOptions }, use) => use(contextOptions.userAgent), { option: true } ],
|
||||
acceptDownloads: [({ contextOptions }, use) => use(contextOptions.acceptDownloads ?? true), { option: true }],
|
||||
bypassCSP: [({ contextOptions }, use) => use(contextOptions.bypassCSP), { option: true }],
|
||||
colorScheme: [({ contextOptions }, use) => use(contextOptions.colorScheme), { option: true }],
|
||||
deviceScaleFactor: [({ contextOptions }, use) => use(contextOptions.deviceScaleFactor), { option: true }],
|
||||
extraHTTPHeaders: [({ contextOptions }, use) => use(contextOptions.extraHTTPHeaders), { option: true }],
|
||||
geolocation: [({ contextOptions }, use) => use(contextOptions.geolocation), { option: true }],
|
||||
hasTouch: [({ contextOptions }, use) => use(contextOptions.hasTouch), { option: true }],
|
||||
httpCredentials: [({ contextOptions }, use) => use(contextOptions.httpCredentials), { option: true }],
|
||||
ignoreHTTPSErrors: [({ contextOptions }, use) => use(contextOptions.ignoreHTTPSErrors), { option: true }],
|
||||
isMobile: [({ contextOptions }, use) => use(contextOptions.isMobile), { option: true }],
|
||||
javaScriptEnabled: [({ contextOptions }, use) => use(contextOptions.javaScriptEnabled ?? true), { option: true }],
|
||||
locale: [({ contextOptions }, use) => use(contextOptions.locale ?? 'en-US'), { option: true }],
|
||||
offline: [({ contextOptions }, use) => use(contextOptions.offline), { option: true }],
|
||||
permissions: [({ contextOptions }, use) => use(contextOptions.permissions), { option: true }],
|
||||
proxy: [({ contextOptions }, use) => use(contextOptions.proxy), { option: true }],
|
||||
storageState: [({ contextOptions }, use) => use(contextOptions.storageState), { option: true }],
|
||||
timezoneId: [({ contextOptions }, use) => use(contextOptions.timezoneId), { option: true }],
|
||||
userAgent: [({ contextOptions }, use) => use(contextOptions.userAgent), { option: true }],
|
||||
viewport: [({ contextOptions }, use) => use(contextOptions.viewport === undefined ? { width: 1280, height: 720 } : contextOptions.viewport), { option: true }],
|
||||
actionTimeout: [ 0, { option: true } ],
|
||||
navigationTimeout: [ 0, { option: true } ],
|
||||
baseURL: [ async ({ }, use) => {
|
||||
actionTimeout: [0, { option: true }],
|
||||
navigationTimeout: [0, { option: true }],
|
||||
baseURL: [async ({ }, use) => {
|
||||
await use(process.env.PLAYWRIGHT_TEST_BASE_URL);
|
||||
}, { option: true } ],
|
||||
serviceWorkers: [ ({ contextOptions }, use) => use(contextOptions.serviceWorkers ?? 'allow'), { option: true } ],
|
||||
contextOptions: [ {}, { option: true } ],
|
||||
}, { option: true }],
|
||||
serviceWorkers: [({ contextOptions }, use) => use(contextOptions.serviceWorkers ?? 'allow'), { option: true }],
|
||||
contextOptions: [{}, { option: true }],
|
||||
|
||||
_combinedContextOptions: async ({
|
||||
acceptDownloads,
|
||||
|
@ -447,7 +447,7 @@ function toReporters(reporters: BuiltInReporter | ReporterDescription[] | undefi
|
||||
if (!reporters)
|
||||
return;
|
||||
if (typeof reporters === 'string')
|
||||
return [ [reporters] ];
|
||||
return [[reporters]];
|
||||
return reporters;
|
||||
}
|
||||
|
||||
@ -631,7 +631,7 @@ export const baseFullConfig: FullConfigInternal = {
|
||||
metadata: {},
|
||||
preserveOutput: 'always',
|
||||
projects: [],
|
||||
reporter: [ [process.env.CI ? 'dot' : 'list'] ],
|
||||
reporter: [[process.env.CI ? 'dot' : 'list']],
|
||||
reportSlowTests: { max: 5, threshold: 15000 },
|
||||
rootDir: path.resolve(process.cwd()),
|
||||
quiet: false,
|
||||
@ -652,7 +652,7 @@ function resolveReporters(reporters: Config['reporter'], rootDir: string): Repor
|
||||
return toReporters(reporters as any)?.map(([id, arg]) => {
|
||||
if (builtInReporters.includes(id as any))
|
||||
return [id, arg];
|
||||
return [require.resolve(id, { paths: [ rootDir ] }), arg];
|
||||
return [require.resolve(id, { paths: [rootDir] }), arg];
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ export class BaseReporter implements ReporterInternal {
|
||||
fileDurations.sort((a, b) => b[1] - a[1]);
|
||||
const count = Math.min(fileDurations.length, this.config.reportSlowTests.max || Number.POSITIVE_INFINITY);
|
||||
const threshold = this.config.reportSlowTests.threshold;
|
||||
return fileDurations.filter(([,duration]) => duration > threshold).slice(0, count);
|
||||
return fileDurations.filter(([, duration]) => duration > threshold).slice(0, count);
|
||||
}
|
||||
|
||||
protected generateSummaryMessage({ skipped, expected, interrupted, unexpected, flaky, fatalErrors }: TestSummary) {
|
||||
|
@ -149,7 +149,7 @@ class JSONReporter implements Reporter {
|
||||
title: test.title,
|
||||
ok: test.ok(),
|
||||
tags: (test.title.match(/@[\S]+/g) || []).map(t => t.substring(1)),
|
||||
tests: [ this._serializeTest(test) ],
|
||||
tests: [this._serializeTest(test)],
|
||||
id: test.id,
|
||||
...this._relativeLocation(test.location),
|
||||
};
|
||||
|
@ -46,8 +46,8 @@ if (!process.env.PW_RUNNER_DEBUG) {
|
||||
}
|
||||
|
||||
process.on('disconnect', gracefullyCloseAndExit);
|
||||
process.on('SIGINT',() => {});
|
||||
process.on('SIGTERM',() => {});
|
||||
process.on('SIGINT', () => {});
|
||||
process.on('SIGTERM', () => {});
|
||||
|
||||
let workerRunner: WorkerRunner;
|
||||
let workerIndex: number | undefined;
|
||||
|
@ -165,7 +165,7 @@ export class WorkerRunner extends EventEmitter {
|
||||
|
||||
async runTestGroup(runPayload: RunPayload) {
|
||||
this._runFinished = new ManualPromise<void>();
|
||||
const entries = new Map(runPayload.entries.map(e => [ e.testId, e ]));
|
||||
const entries = new Map(runPayload.entries.map(e => [e.testId, e]));
|
||||
let fatalUnknownTestIds;
|
||||
try {
|
||||
await this._loadIfNeeded();
|
||||
|
@ -286,7 +286,7 @@ function snapshotScript() {
|
||||
* Best-effort Electron support: rewrite custom protocol in DOM.
|
||||
* vscode-file://vscode-app/ -> https://pw-vscode-file--vscode-app/
|
||||
*/
|
||||
const schemas = ['about:', 'blob:', 'data:', 'file:', 'ftp:', 'http:', 'https:', 'mailto:', 'sftp:', 'ws:', 'wss:' ];
|
||||
const schemas = ['about:', 'blob:', 'data:', 'file:', 'ftp:', 'http:', 'https:', 'mailto:', 'sftp:', 'ws:', 'wss:'];
|
||||
const kLegacyBlobPrefix = 'http://playwright.bloburl/#';
|
||||
|
||||
export function rewriteURLForCustomProtocol(href: string): string {
|
||||
|
@ -35,8 +35,8 @@ const config: Config<ServerWorkerOptions & PlaywrightWorkerOptions & PlaywrightT
|
||||
preserveOutput: process.env.CI ? 'failures-only' : 'always',
|
||||
retries: process.env.CI ? 1 : 0,
|
||||
reporter: process.env.CI ? [
|
||||
[ 'dot' ],
|
||||
[ 'json', { outputFile: path.join(outputDir, 'report.json') } ],
|
||||
['dot'],
|
||||
['json', { outputFile: path.join(outputDir, 'report.json') }],
|
||||
] : 'line',
|
||||
projects: [],
|
||||
};
|
||||
|
@ -47,11 +47,11 @@ type BrowserTestTestFixtures = PageTestFixtures & {
|
||||
const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>({
|
||||
browserVersion: [async ({ browser }, run) => {
|
||||
await run(browser.version());
|
||||
}, { scope: 'worker' } ],
|
||||
}, { scope: 'worker' }],
|
||||
|
||||
browserType: [async ({ playwright, browserName }, run) => {
|
||||
await run(playwright[browserName]);
|
||||
}, { scope: 'worker' } ],
|
||||
}, { scope: 'worker' }],
|
||||
|
||||
allowsThirdParty: [async ({ browserName, browserMajorVersion, channel }, run) => {
|
||||
if (browserName === 'firefox' && !channel)
|
||||
@ -60,7 +60,7 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
|
||||
await run(browserMajorVersion >= 97 && browserMajorVersion < 103);
|
||||
else
|
||||
await run(false);
|
||||
}, { scope: 'worker' } ],
|
||||
}, { scope: 'worker' }],
|
||||
|
||||
defaultSameSiteCookieValue: [async ({ browserName, browserMajorVersion, channel }, run) => {
|
||||
if (browserName === 'chromium')
|
||||
@ -73,14 +73,14 @@ const test = baseTest.extend<BrowserTestTestFixtures, BrowserTestWorkerFixtures>
|
||||
await run(browserMajorVersion >= 103 ? 'None' : 'Lax');
|
||||
else
|
||||
throw new Error('unknown browser - ' + browserName);
|
||||
}, { scope: 'worker' } ],
|
||||
}, { scope: 'worker' }],
|
||||
|
||||
browserMajorVersion: [async ({ browserVersion }, run) => {
|
||||
await run(Number(browserVersion.split('.')[0]));
|
||||
}, { scope: 'worker' } ],
|
||||
}, { scope: 'worker' }],
|
||||
|
||||
isAndroid: [false, { scope: 'worker' } ],
|
||||
isElectron: [false, { scope: 'worker' } ],
|
||||
isAndroid: [false, { scope: 'worker' }],
|
||||
isElectron: [false, { scope: 'worker' }],
|
||||
|
||||
contextFactory: async ({ _contextFactory }: any, run) => {
|
||||
await run(_contextFactory);
|
||||
|
@ -24,8 +24,8 @@ export type CoverageWorkerOptions = {
|
||||
};
|
||||
|
||||
export const coverageTest = test.extend<{}, { __collectCoverage: void } & CoverageWorkerOptions>({
|
||||
coverageName: [ undefined, { scope: 'worker', option: true } ],
|
||||
__collectCoverage: [ async ({ coverageName }, run, workerInfo) => {
|
||||
coverageName: [undefined, { scope: 'worker', option: true }],
|
||||
__collectCoverage: [async ({ coverageName }, run, workerInfo) => {
|
||||
if (!coverageName) {
|
||||
await run();
|
||||
return;
|
||||
@ -38,5 +38,5 @@ export const coverageTest = test.extend<{}, { __collectCoverage: void } & Covera
|
||||
const coverageJSON = Array.from(coverage.keys()).filter(key => coverage.get(key));
|
||||
await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });
|
||||
await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');
|
||||
}, { scope: 'worker', auto: true } ],
|
||||
}, { scope: 'worker', auto: true }],
|
||||
});
|
||||
|
@ -24,8 +24,8 @@ export type PlatformWorkerFixtures = {
|
||||
};
|
||||
|
||||
export const platformTest = test.extend<{}, PlatformWorkerFixtures>({
|
||||
platform: [ process.platform as 'win32' | 'darwin' | 'linux', { scope: 'worker' } ],
|
||||
isWindows: [ process.platform === 'win32', { scope: 'worker' } ],
|
||||
isMac: [ process.platform === 'darwin', { scope: 'worker' } ],
|
||||
isLinux: [ process.platform === 'linux', { scope: 'worker' } ],
|
||||
platform: [process.platform as 'win32' | 'darwin' | 'linux', { scope: 'worker' }],
|
||||
isWindows: [process.platform === 'win32', { scope: 'worker' }],
|
||||
isMac: [process.platform === 'darwin', { scope: 'worker' }],
|
||||
isLinux: [process.platform === 'linux', { scope: 'worker' }],
|
||||
});
|
||||
|
@ -34,8 +34,8 @@ export type ServerFixtures = {
|
||||
};
|
||||
|
||||
export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
|
||||
loopback: [ undefined, { scope: 'worker', option: true } ],
|
||||
__servers: [ async ({ loopback }, run, workerInfo) => {
|
||||
loopback: [undefined, { scope: 'worker', option: true }],
|
||||
__servers: [async ({ loopback }, run, workerInfo) => {
|
||||
const assetsPath = path.join(__dirname, '..', 'assets');
|
||||
const cachedPath = path.join(__dirname, '..', 'assets', 'cached');
|
||||
|
||||
@ -85,7 +85,7 @@ export const serverFixtures: Fixtures<ServerFixtures, ServerWorkerOptions> = {
|
||||
socksServer.close(),
|
||||
proxyServer.stop(),
|
||||
]);
|
||||
}, { scope: 'worker' } ],
|
||||
}, { scope: 'worker' }],
|
||||
|
||||
server: async ({ __servers }, run) => {
|
||||
__servers.server.reset();
|
||||
|
@ -32,8 +32,8 @@ export type TestModeWorkerFixtures = {
|
||||
};
|
||||
|
||||
export const testModeTest = test.extend<TestModeTestFixtures, TestModeWorkerOptions & TestModeWorkerFixtures>({
|
||||
mode: [ 'default', { scope: 'worker', option: true } ],
|
||||
playwright: [ async ({ mode }, run) => {
|
||||
mode: ['default', { scope: 'worker', option: true }],
|
||||
playwright: [async ({ mode }, run) => {
|
||||
const testMode = {
|
||||
default: new DefaultTestMode(),
|
||||
service: new DefaultTestMode(),
|
||||
@ -44,7 +44,7 @@ export const testModeTest = test.extend<TestModeTestFixtures, TestModeWorkerOpti
|
||||
const playwright = await testMode.setup();
|
||||
await run(playwright);
|
||||
await testMode.teardown();
|
||||
}, { scope: 'worker' } ],
|
||||
}, { scope: 'worker' }],
|
||||
|
||||
toImplInWorkerScope: [async ({ playwright }, use) => {
|
||||
await use((playwright as any)._toImpl);
|
||||
|
@ -52,7 +52,7 @@ export const electronTest = baseTest.extend<TraceViewerFixtures>(traceViewerFixt
|
||||
newWindow: async ({ electronApp }, run) => {
|
||||
const windows: Page[] = [];
|
||||
await run(async () => {
|
||||
const [ window ] = await Promise.all([
|
||||
const [window] = await Promise.all([
|
||||
electronApp.waitForEvent('window'),
|
||||
electronApp.evaluate(async electron => {
|
||||
// Avoid "Error: Cannot create BrowserWindow before app is ready".
|
||||
|
@ -35,8 +35,8 @@ const config: Config<CoverageWorkerOptions & PlaywrightWorkerOptions & Playwrigh
|
||||
preserveOutput: process.env.CI ? 'failures-only' : 'always',
|
||||
retries: process.env.CI ? 3 : 0,
|
||||
reporter: process.env.CI ? [
|
||||
[ 'dot' ],
|
||||
[ 'json', { outputFile: path.join(outputDir, 'report.json') } ],
|
||||
['dot'],
|
||||
['json', { outputFile: path.join(outputDir, 'report.json') }],
|
||||
] : 'line',
|
||||
projects: [],
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ it('should fetch lodpi assets @smoke', async ({ contextFactory, server }) => {
|
||||
deviceScaleFactor: 1
|
||||
});
|
||||
const page = await context.newPage();
|
||||
const [ request ] = await Promise.all([
|
||||
const [request] = await Promise.all([
|
||||
page.waitForRequest('**/image*'),
|
||||
page.goto(server.PREFIX + '/highdpi.html'),
|
||||
]);
|
||||
@ -33,7 +33,7 @@ it('should fetch hidpi assets', async ({ contextFactory, server }) => {
|
||||
deviceScaleFactor: 2
|
||||
});
|
||||
const page = await context.newPage();
|
||||
const [ request ] = await Promise.all([
|
||||
const [request] = await Promise.all([
|
||||
page.waitForRequest('**/image*'),
|
||||
page.goto(server.PREFIX + '/highdpi.html'),
|
||||
]);
|
||||
|
@ -946,7 +946,7 @@ it('should abort requests when browser context closes', async ({ contextFactory,
|
||||
});
|
||||
});
|
||||
const context = await contextFactory();
|
||||
const [ error ] = await Promise.all([
|
||||
const [error] = await Promise.all([
|
||||
context.request.get(server.EMPTY_PAGE).catch(e => e),
|
||||
context.request.post(server.EMPTY_PAGE).catch(e => e),
|
||||
server.waitForRequest('/empty.html').then(() => context.close())
|
||||
|
@ -179,7 +179,7 @@ it('should work with Ctrl-clicking', async ({ browser, server, isMac, browserNam
|
||||
await page.setContent('<a href="/one-style.html">yo</a>');
|
||||
const [popup] = await Promise.all([
|
||||
context.waitForEvent('page'),
|
||||
page.click('a', { modifiers: [ isMac ? 'Meta' : 'Control'] }),
|
||||
page.click('a', { modifiers: [isMac ? 'Meta' : 'Control'] }),
|
||||
]);
|
||||
expect(await popup.opener()).toBe(null);
|
||||
await context.close();
|
||||
@ -194,7 +194,7 @@ it('should not hang on ctrl-click during provisional load', async ({ context, pa
|
||||
server.setRoute('/slow.html', () => {});
|
||||
const [popup] = await Promise.all([
|
||||
context.waitForEvent('page'),
|
||||
server.waitForRequest('/slow.html').then(() => page.click('a', { modifiers: [ isMac ? 'Meta' : 'Control'] })),
|
||||
server.waitForRequest('/slow.html').then(() => page.click('a', { modifiers: [isMac ? 'Meta' : 'Control'] })),
|
||||
page.evaluate(url => setTimeout(() => location.href = url, 0), server.CROSS_PROCESS_PREFIX + '/slow.html'),
|
||||
]);
|
||||
expect(popup).toBeTruthy();
|
||||
|
@ -26,7 +26,7 @@ import formidable from 'formidable';
|
||||
|
||||
test.slow(true, 'All connect tests are slow');
|
||||
|
||||
test('should connect over wss', async ({ browserType , startRemoteServer, httpsServer, mode }) => {
|
||||
test('should connect over wss', async ({ browserType, startRemoteServer, httpsServer, mode }) => {
|
||||
test.skip(mode !== 'default'); // Out of process transport does not allow us to set env vars dynamically.
|
||||
const remoteServer = await startRemoteServer();
|
||||
|
||||
@ -422,7 +422,7 @@ test('should save download', async ({ server, browserType, startRemoteServer },
|
||||
const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() });
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -446,7 +446,7 @@ test('should error when saving download after deletion', async ({ server, browse
|
||||
const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() });
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
|
@ -21,7 +21,7 @@ import { playwrightTest, expect } from '../config/browserTest';
|
||||
// Use something worker-scoped (e.g. expectScopeState) forces a new worker for this file.
|
||||
// Otherwise, a browser launched for other tests in this worker will affect the expectations.
|
||||
const it = playwrightTest.extend<{}, { expectScopeState: (object: any, golden: any) => void }>({
|
||||
expectScopeState: [ async ({ toImplInWorkerScope }, use) => {
|
||||
expectScopeState: [async ({ toImplInWorkerScope }, use) => {
|
||||
await use((object, golden) => {
|
||||
golden = trimGuids(golden);
|
||||
const remoteRoot = toImplInWorkerScope();
|
||||
|
@ -72,14 +72,14 @@ test('should emit new service worker on update', async ({ context, page, server
|
||||
res.end();
|
||||
});
|
||||
|
||||
const [ sw ] = await Promise.all([
|
||||
const [sw] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
page.goto(server.PREFIX + '/home'),
|
||||
]);
|
||||
|
||||
await expect.poll(() => sw.evaluate(() => self['PW_VERSION'])).toBe(0);
|
||||
|
||||
const [ updatedSW ] = await Promise.all([
|
||||
const [updatedSW] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
page.click('#update'),
|
||||
]);
|
||||
@ -223,7 +223,7 @@ playwrightTest('should connectOverCDP and manage downloads in default context',
|
||||
const page = await browser.contexts()[0].newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/downloadWithFilename">download</a>`);
|
||||
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -692,7 +692,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
})
|
||||
);
|
||||
|
||||
const [ sw ] = await Promise.all([
|
||||
const [sw] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
context.waitForEvent('response', r => r.url().endsWith('/request-from-within-worker')),
|
||||
context.waitForEvent('request', r => r.url().endsWith('sw.js') && !!r.serviceWorker()),
|
||||
@ -752,7 +752,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
})
|
||||
);
|
||||
|
||||
const [ sw ] = await Promise.all([
|
||||
const [sw] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
context.waitForEvent('response', r => r.url().endsWith('/import.js')),
|
||||
page.goto(server.PREFIX + '/serviceworkers/empty/sw.html'),
|
||||
@ -787,7 +787,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
})
|
||||
);
|
||||
|
||||
const [ sw ] = await Promise.all([
|
||||
const [sw] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
context.waitForEvent('response', r => r.url().endsWith('/request-from-within-worker')),
|
||||
page.goto(server.PREFIX + '/serviceworkers/empty/sw.html'),
|
||||
@ -822,13 +822,13 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const [ sw ] = await Promise.all([
|
||||
const [sw] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
page.goto(server.PREFIX + '/serviceworkers/fetch/sw.html'),
|
||||
]);
|
||||
await page.evaluate(() => window['activationPromise']);
|
||||
const response = await page.evaluate(() => fetch('/data.json').then(r => r.text()));
|
||||
const [ url ] = await sw.evaluate(() => self['intercepted']);
|
||||
const [url] = await sw.evaluate(() => self['intercepted']);
|
||||
expect(url).toMatch(/\/data\.json$/);
|
||||
expect(response).toBe('from sw');
|
||||
});
|
||||
@ -873,7 +873,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
page.on('request', r => requests.push(['page', r]));
|
||||
context.on('request', r => requests.push(['context', r]));
|
||||
|
||||
const [ sw ] = await Promise.all([
|
||||
const [sw] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
page.goto(server.PREFIX + '/index.html'),
|
||||
]);
|
||||
@ -966,7 +966,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
page.on('request', r => requests.push(['page', r]));
|
||||
context.on('request', r => requests.push(['context', r]));
|
||||
|
||||
const [ sw ] = await Promise.all([
|
||||
const [sw] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
page.goto(server.PREFIX + '/index.html'),
|
||||
]);
|
||||
@ -996,7 +996,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
'| [`event: Page.request`] | [Frame] | tracker.js | | Yes |',
|
||||
'| [`event: BrowserContext.request`] | Service [Worker] | fallthrough.txt | Yes | |',
|
||||
'| [`event: BrowserContext.request`] | [Frame] | fallthrough.txt | | Yes |',
|
||||
'| [`event: Page.request`] | [Frame] | fallthrough.txt | | Yes |' ]);
|
||||
'| [`event: Page.request`] | [Frame] | fallthrough.txt | | Yes |']);
|
||||
});
|
||||
|
||||
test('should intercept service worker update requests', async ({ context, page, server }) => {
|
||||
@ -1035,7 +1035,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
res.end();
|
||||
});
|
||||
|
||||
const [ sw ] = await Promise.all([
|
||||
const [sw] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
page.goto(server.PREFIX + '/home'),
|
||||
]);
|
||||
@ -1051,7 +1051,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
});
|
||||
});
|
||||
|
||||
const [ updatedSW ] = await Promise.all([
|
||||
const [updatedSW] = await Promise.all([
|
||||
context.waitForEvent('serviceworker'),
|
||||
// currently times out here
|
||||
context.waitForEvent('request', r => r.url().endsWith('worker.js')),
|
||||
@ -1069,7 +1069,7 @@ test.describe('PW_EXPERIMENTAL_SERVICE_WORKER_NETWORK_EVENTS=1', () => {
|
||||
|
||||
await page.evaluate(() => window['activationPromise']);
|
||||
await context.setOffline(true);
|
||||
const [,error] = await Promise.all([
|
||||
const [, error] = await Promise.all([
|
||||
context.waitForEvent('request', r => r.url().endsWith('/inner.txt') && !!r.serviceWorker()),
|
||||
worker.evaluate(() => fetch('/inner.txt').catch(e => `REJECTED: ${e}`)),
|
||||
]);
|
||||
|
@ -180,7 +180,7 @@ it('should support acceptDownloads option', async ({ server, launchPersistent, m
|
||||
res.end(`Hello world`);
|
||||
});
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
|
@ -160,7 +160,7 @@ it('should have passed URL when launching with ignoreDefaultArgs: true', async (
|
||||
await browserContext.close();
|
||||
});
|
||||
|
||||
it('should handle timeout', async ({ browserType,createUserDataDir, mode }) => {
|
||||
it('should handle timeout', async ({ browserType, createUserDataDir, mode }) => {
|
||||
it.skip(mode !== 'default');
|
||||
|
||||
const options: any = { timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) };
|
||||
@ -168,7 +168,7 @@ it('should handle timeout', async ({ browserType,createUserDataDir, mode }) => {
|
||||
expect(error.message).toContain(`browserType.launchPersistentContext: Timeout 5000ms exceeded.`);
|
||||
});
|
||||
|
||||
it('should handle exception', async ({ browserType,createUserDataDir, mode }) => {
|
||||
it('should handle exception', async ({ browserType, createUserDataDir, mode }) => {
|
||||
it.skip(mode !== 'default');
|
||||
|
||||
const e = new Error('Dummy');
|
||||
@ -215,7 +215,7 @@ it('should respect selectors', async ({ playwright, launchPersistent }) => {
|
||||
expect(await page.innerHTML('defaultContextCSS=div')).toBe('hello');
|
||||
});
|
||||
|
||||
it('should connect to a browser with the default page', async ({ browserType,createUserDataDir, mode }) => {
|
||||
it('should connect to a browser with the default page', async ({ browserType, createUserDataDir, mode }) => {
|
||||
it.skip(mode !== 'default');
|
||||
|
||||
const options: any = { __testHookOnConnectToBrowser: () => new Promise(f => setTimeout(f, 3000)) };
|
||||
|
@ -52,7 +52,7 @@ it.describe('download event', () => {
|
||||
|
||||
it('should report download when navigation turns into download @smoke', async ({ browser, server, browserName }) => {
|
||||
const page = await browser.newPage();
|
||||
const [ download, responseOrError ] = await Promise.all([
|
||||
const [download, responseOrError] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.goto(server.PREFIX + '/download').catch(e => e)
|
||||
]);
|
||||
@ -78,7 +78,7 @@ it.describe('download event', () => {
|
||||
|
||||
it('should work with Cross-Origin-Opener-Policy', async ({ browser, server, browserName }) => {
|
||||
const page = await browser.newPage();
|
||||
const [ download, responseOrError ] = await Promise.all([
|
||||
const [download, responseOrError] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.goto(server.PREFIX + '/downloadWithCOOP').catch(e => e)
|
||||
]);
|
||||
@ -105,7 +105,7 @@ it.describe('download event', () => {
|
||||
it('should report downloads with acceptDownloads: false', async ({ browser, server }) => {
|
||||
const page = await browser.newPage({ acceptDownloads: false });
|
||||
await page.setContent(`<a href="${server.PREFIX}/downloadWithFilename">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -122,7 +122,7 @@ it.describe('download event', () => {
|
||||
it('should report downloads with acceptDownloads: true', async ({ browser, server }) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -136,7 +136,7 @@ it.describe('download event', () => {
|
||||
const page = await browser.newPage();
|
||||
await page.goto(server.PREFIX + '/empty.html');
|
||||
await page.setContent(`<a href="${server.PREFIX}/chromium-linux.zip" download="foo.zip">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -148,7 +148,7 @@ it.describe('download event', () => {
|
||||
const page = await browser.newPage();
|
||||
await page.goto(server.PREFIX + '/empty.html');
|
||||
await page.setContent(`<a href="${server.PREFIX}/chromium-linux.zip" download="foo.zip">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -161,7 +161,7 @@ it.describe('download event', () => {
|
||||
it('should save to user-specified path without updating original path', async ({ browser, server }, testInfo) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -179,7 +179,7 @@ it.describe('download event', () => {
|
||||
it('should save to two different paths with multiple saveAs calls', async ({ browser, server }, testInfo) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -198,7 +198,7 @@ it.describe('download event', () => {
|
||||
it('should save to overwritten filepath', async ({ browser, server }, testInfo) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -216,7 +216,7 @@ it.describe('download event', () => {
|
||||
it('should create subdirectories when saving to non-existent user-specified path', async ({ browser, server }, testInfo) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -230,7 +230,7 @@ it.describe('download event', () => {
|
||||
it('should error when saving with downloads disabled', async ({ browser, server }, testInfo) => {
|
||||
const page = await browser.newPage({ acceptDownloads: false });
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -243,7 +243,7 @@ it.describe('download event', () => {
|
||||
it('should error when saving after deletion', async ({ browser, server }, testInfo) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -264,7 +264,7 @@ it.describe('download event', () => {
|
||||
const page = await browser.newPage();
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent(`<a download="file.txt" href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -316,7 +316,7 @@ it.describe('download event', () => {
|
||||
const page = await browser.newPage();
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a', { modifiers: ['Alt'] })
|
||||
]);
|
||||
@ -329,7 +329,7 @@ it.describe('download event', () => {
|
||||
it('should report new window downloads', async ({ browser, server }) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a target=_blank href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -341,7 +341,7 @@ it.describe('download event', () => {
|
||||
it('should delete file', async ({ browser, server }) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -355,7 +355,7 @@ it.describe('download event', () => {
|
||||
it('should expose stream', async ({ browser, server }) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -370,11 +370,11 @@ it.describe('download event', () => {
|
||||
it('should delete downloads on context destruction', async ({ browser, server }) => {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download1 ] = await Promise.all([
|
||||
const [download1] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
const [ download2 ] = await Promise.all([
|
||||
const [download2] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -391,11 +391,11 @@ it.describe('download event', () => {
|
||||
const browser = await browserType.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download1 ] = await Promise.all([
|
||||
const [download1] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
const [ download2 ] = await Promise.all([
|
||||
const [download2] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -501,7 +501,7 @@ it.describe('download event', () => {
|
||||
const page = await browser.newPage();
|
||||
await page.goto(server.PREFIX + '/empty.html');
|
||||
await page.setContent(`<a href="${server.PREFIX}/binary.zip" download="binary.zip">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -527,7 +527,7 @@ it.describe('download event', () => {
|
||||
it.fixme(browserName === 'chromium' && Number(browserVersion.split('.')[0]) < 91, 'The upstream Browser.cancelDownload command is not available before Chrome 91');
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/downloadWithDelay">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -542,7 +542,7 @@ it.describe('download event', () => {
|
||||
it.fixme(browserName === 'chromium' && Number(browserVersion.split('.')[0]) < 91, 'The upstream Browser.cancelDownload command is not available before Chrome 91');
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -559,7 +559,7 @@ it.describe('download event', () => {
|
||||
const page = await browser.newPage();
|
||||
await page.route(/.*/, r => r.continue());
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -647,7 +647,7 @@ it('should save to user-specified path', async ({ browser, server, mode }, testI
|
||||
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
|
@ -33,7 +33,7 @@ it.describe('downloads path', () => {
|
||||
const downloadsBrowser = await browserType.launch({ downloadsPath: testInfo.outputPath('') });
|
||||
const page = await downloadsBrowser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -49,7 +49,7 @@ it.describe('downloads path', () => {
|
||||
const downloadsBrowser = await browserType.launch({ downloadsPath: testInfo.outputPath('') });
|
||||
const page = await downloadsBrowser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -64,7 +64,7 @@ it.describe('downloads path', () => {
|
||||
const downloadsBrowser = await browserType.launch({ downloadsPath: testInfo.outputPath('') });
|
||||
const page = await downloadsBrowser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -78,7 +78,7 @@ it.describe('downloads path', () => {
|
||||
const downloadsBrowser = await browserType.launch({ downloadsPath: path.relative(process.cwd(), testInfo.outputPath('')) });
|
||||
const page = await downloadsBrowser.newPage();
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a')
|
||||
]);
|
||||
@ -91,7 +91,7 @@ it.describe('downloads path', () => {
|
||||
it('should accept downloads in persistent context', async ({ launchPersistent, server }, testInfo) => {
|
||||
const { context, page } = await launchPersistent({ downloadsPath: testInfo.outputPath('') });
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a'),
|
||||
]);
|
||||
@ -105,7 +105,7 @@ it.describe('downloads path', () => {
|
||||
it('should delete downloads when persistent context closes', async ({ launchPersistent, server }, testInfo) => {
|
||||
const { context, page } = await launchPersistent({ downloadsPath: testInfo.outputPath('') });
|
||||
await page.setContent(`<a href="${server.PREFIX}/download">download</a>`);
|
||||
const [ download ] = await Promise.all([
|
||||
const [download] = await Promise.all([
|
||||
page.waitForEvent('download'),
|
||||
page.click('a'),
|
||||
]);
|
||||
|
@ -81,7 +81,7 @@ it('should not affect mouse event target page', async ({ page, server }) => {
|
||||
page.evaluate('window.clickCount'),
|
||||
page2.evaluate('window.clickCount'),
|
||||
]);
|
||||
expect(counters).toEqual([1,1]);
|
||||
expect(counters).toEqual([1, 1]);
|
||||
});
|
||||
|
||||
it('should change document.activeElement', async ({ page, server }) => {
|
||||
|
@ -370,7 +370,7 @@ test.describe('cli codegen', () => {
|
||||
const selector = await recorder.hoverOverElement('a');
|
||||
expect(selector).toBe('text=link');
|
||||
|
||||
await page.click('a', { modifiers: [ platform === 'darwin' ? 'Meta' : 'Control'] });
|
||||
await page.click('a', { modifiers: [platform === 'darwin' ? 'Meta' : 'Control'] });
|
||||
const sources = await recorder.waitForOutput('JavaScript', 'page1');
|
||||
|
||||
if (browserName !== 'firefox') {
|
||||
@ -465,7 +465,7 @@ test.describe('cli codegen', () => {
|
||||
const recorder = await openRecorder();
|
||||
|
||||
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="checkbox.name='updated'"></input>`);
|
||||
const [ models ] = await Promise.all([
|
||||
const [models] = await Promise.all([
|
||||
recorder.waitForActionPerformed(),
|
||||
page.click('input')
|
||||
]);
|
||||
@ -477,7 +477,7 @@ test.describe('cli codegen', () => {
|
||||
|
||||
const recorder = await openRecorder();
|
||||
await recorder.setContentAndWait(`<input id="checkbox" type="checkbox" name="accept" onchange="checkbox.name='updated'"></input>`);
|
||||
const [ models ] = await Promise.all([
|
||||
const [models] = await Promise.all([
|
||||
recorder.waitForActionPerformed(),
|
||||
page.click('input')
|
||||
]);
|
||||
|
@ -74,7 +74,7 @@ it('should work @smoke', async ({ page, browserName }) => {
|
||||
{ role: 'textbox', name: 'Input with whitespace', value: ' ' },
|
||||
{ role: 'textbox', name: '', value: 'value only' },
|
||||
{ role: 'textbox', name: 'placeholder', value: 'and a value' },
|
||||
{ role: 'textbox', name: 'This is a description!',value: 'and a value' }, // webkit uses the description over placeholder for the name
|
||||
{ role: 'textbox', name: 'This is a description!', value: 'and a value' }, // webkit uses the description over placeholder for the name
|
||||
]
|
||||
};
|
||||
expect(await page.accessibility.snapshot()).toEqual(golden);
|
||||
@ -301,9 +301,9 @@ it('should work on a menu', async ({ page, browserName, browserVersion }) => {
|
||||
role: 'menu',
|
||||
name: 'My Menu',
|
||||
children:
|
||||
[ { role: 'menuitem', name: 'First Item' },
|
||||
[{ role: 'menuitem', name: 'First Item' },
|
||||
{ role: 'menuitem', name: 'Second Item' },
|
||||
{ role: 'menuitem', name: 'Third Item' } ],
|
||||
{ role: 'menuitem', name: 'Third Item' }],
|
||||
orientation: (browserName === 'webkit' || (browserName === 'chromium' && !chromiumVersionLessThan(browserVersion, '98.0.1089'))) ? 'vertical' : undefined
|
||||
});
|
||||
});
|
||||
|
@ -75,7 +75,7 @@ it.describe('Drag and drop', () => {
|
||||
|
||||
it('should drag into an iframe', async ({ server, page, browserName }) => {
|
||||
await page.goto(server.PREFIX + '/drag-n-drop.html');
|
||||
const frame = await attachFrame(page, 'oopif',server.PREFIX + '/drag-n-drop.html');
|
||||
const frame = await attachFrame(page, 'oopif', server.PREFIX + '/drag-n-drop.html');
|
||||
const pageEvents = await trackEvents(await page.$('body'));
|
||||
const frameEvents = await trackEvents(await frame.$('body'));
|
||||
await page.pause();
|
||||
@ -99,7 +99,7 @@ it.describe('Drag and drop', () => {
|
||||
|
||||
it('should drag out of an iframe', async ({ server, page }) => {
|
||||
await page.goto(server.PREFIX + '/drag-n-drop.html');
|
||||
const frame = await attachFrame(page, 'oopif',server.PREFIX + '/drag-n-drop.html');
|
||||
const frame = await attachFrame(page, 'oopif', server.PREFIX + '/drag-n-drop.html');
|
||||
const pageEvents = await trackEvents(await page.$('body'));
|
||||
const frameEvents = await trackEvents(await frame.$('body'));
|
||||
await frame.hover('#source');
|
||||
|
@ -635,7 +635,7 @@ it('should not use Array.prototype.toJSON when evaluating', async ({ page }) =>
|
||||
(Array.prototype as any).toJSON = () => 'busted';
|
||||
return [1, 2, 3];
|
||||
});
|
||||
expect(result).toEqual([1,2,3]);
|
||||
expect(result).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('should not add a toJSON property to newly created Arrays after evaluation', async ({ page, browserName }) => {
|
||||
|
@ -129,12 +129,12 @@ it('should send proper codes while typing', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/keyboard.html');
|
||||
await page.keyboard.type('!');
|
||||
expect(await page.evaluate('getResult()')).toBe(
|
||||
[ 'Keydown: ! Digit1 49 []',
|
||||
['Keydown: ! Digit1 49 []',
|
||||
'Keypress: ! Digit1 33 33 []',
|
||||
'Keyup: ! Digit1 49 []'].join('\n'));
|
||||
await page.keyboard.type('^');
|
||||
expect(await page.evaluate('getResult()')).toBe(
|
||||
[ 'Keydown: ^ Digit6 54 []',
|
||||
['Keydown: ^ Digit6 54 []',
|
||||
'Keypress: ^ Digit6 94 94 []',
|
||||
'Keyup: ^ Digit6 54 []'].join('\n'));
|
||||
});
|
||||
@ -145,7 +145,7 @@ it('should send proper codes while typing with shift', async ({ page, server })
|
||||
await keyboard.down('Shift');
|
||||
await page.keyboard.type('~');
|
||||
expect(await page.evaluate('getResult()')).toBe(
|
||||
[ 'Keydown: Shift ShiftLeft 16 [Shift]',
|
||||
['Keydown: Shift ShiftLeft 16 [Shift]',
|
||||
'Keydown: ~ Backquote 192 [Shift]', // 192 is ` keyCode
|
||||
'Keypress: ~ Backquote 126 126 [Shift]', // 126 is ~ charCode
|
||||
'Keyup: ~ Backquote 192 [Shift]'].join('\n'));
|
||||
@ -173,7 +173,7 @@ it('should press plus', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/keyboard.html');
|
||||
await page.keyboard.press('+');
|
||||
expect(await page.evaluate('getResult()')).toBe(
|
||||
[ 'Keydown: + Equal 187 []', // 192 is ` keyCode
|
||||
['Keydown: + Equal 187 []', // 192 is ` keyCode
|
||||
'Keypress: + Equal 43 43 []', // 126 is ~ charCode
|
||||
'Keyup: + Equal 187 []'].join('\n'));
|
||||
});
|
||||
@ -182,7 +182,7 @@ it('should press shift plus', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/keyboard.html');
|
||||
await page.keyboard.press('Shift++');
|
||||
expect(await page.evaluate('getResult()')).toBe(
|
||||
[ 'Keydown: Shift ShiftLeft 16 [Shift]',
|
||||
['Keydown: Shift ShiftLeft 16 [Shift]',
|
||||
'Keydown: + Equal 187 [Shift]', // 192 is ` keyCode
|
||||
'Keypress: + Equal 43 43 [Shift]', // 126 is ~ charCode
|
||||
'Keyup: + Equal 187 [Shift]',
|
||||
@ -193,7 +193,7 @@ it('should support plus-separated modifiers', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/keyboard.html');
|
||||
await page.keyboard.press('Shift+~');
|
||||
expect(await page.evaluate('getResult()')).toBe(
|
||||
[ 'Keydown: Shift ShiftLeft 16 [Shift]',
|
||||
['Keydown: Shift ShiftLeft 16 [Shift]',
|
||||
'Keydown: ~ Backquote 192 [Shift]', // 192 is ` keyCode
|
||||
'Keypress: ~ Backquote 126 126 [Shift]', // 126 is ~ charCode
|
||||
'Keyup: ~ Backquote 192 [Shift]',
|
||||
@ -204,7 +204,7 @@ it('should support multiple plus-separated modifiers', async ({ page, server })
|
||||
await page.goto(server.PREFIX + '/input/keyboard.html');
|
||||
await page.keyboard.press('Control+Shift+~');
|
||||
expect(await page.evaluate('getResult()')).toBe(
|
||||
[ 'Keydown: Control ControlLeft 17 [Control]',
|
||||
['Keydown: Control ControlLeft 17 [Control]',
|
||||
'Keydown: Shift ShiftLeft 16 [Control Shift]',
|
||||
'Keydown: ~ Backquote 192 [Control Shift]', // 192 is ` keyCode
|
||||
'Keyup: ~ Backquote 192 [Control Shift]',
|
||||
@ -216,7 +216,7 @@ it('should shift raw codes', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/keyboard.html');
|
||||
await page.keyboard.press('Shift+Digit3');
|
||||
expect(await page.evaluate('getResult()')).toBe(
|
||||
[ 'Keydown: Shift ShiftLeft 16 [Shift]',
|
||||
['Keydown: Shift ShiftLeft 16 [Shift]',
|
||||
'Keydown: # Digit3 51 [Shift]', // 51 is # keyCode
|
||||
'Keypress: # Digit3 35 35 [Shift]', // 35 is # charCode
|
||||
'Keyup: # Digit3 51 [Shift]',
|
||||
|
@ -153,9 +153,9 @@ it('should select the text with mouse', async ({ page, server }) => {
|
||||
await page.evaluate(() => new Promise(requestAnimationFrame));
|
||||
await page.evaluate(() => document.querySelector('textarea').scrollTop = 0);
|
||||
const { x, y } = await page.evaluate(dimensions);
|
||||
await page.mouse.move(x + 2,y + 2);
|
||||
await page.mouse.move(x + 2, y + 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(200,200);
|
||||
await page.mouse.move(200, 200);
|
||||
await page.mouse.up();
|
||||
expect(await page.evaluate(() => {
|
||||
const textarea = document.querySelector('textarea');
|
||||
|
@ -286,7 +286,7 @@ it('should parse the data if content-type is application/x-www-form-urlencoded',
|
||||
await page.setContent(`<form method='POST' action='/post'><input type='text' name='foo' value='bar'><input type='number' name='baz' value='123'><input type='submit'></form>`);
|
||||
await page.click('input[type=submit]');
|
||||
expect(request).toBeTruthy();
|
||||
expect(request.postDataJSON()).toEqual({ 'foo': 'bar','baz': '123' });
|
||||
expect(request.postDataJSON()).toEqual({ 'foo': 'bar', 'baz': '123' });
|
||||
});
|
||||
|
||||
it('should get |undefined| with postDataJSON() when there is no post data', async ({ page, server }) => {
|
||||
|
@ -386,7 +386,7 @@ it.describe('page screenshot', () => {
|
||||
await page.setViewportSize({ width: 500, height: 500 });
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
expect(await page.screenshot({
|
||||
mask: [ page.locator('div').nth(5) ],
|
||||
mask: [page.locator('div').nth(5)],
|
||||
})).toMatchSnapshot('mask-should-work.png');
|
||||
});
|
||||
|
||||
@ -395,7 +395,7 @@ it.describe('page screenshot', () => {
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
const bodyLocator = page.locator('body');
|
||||
expect(await bodyLocator.screenshot({
|
||||
mask: [ page.locator('div').nth(5) ],
|
||||
mask: [page.locator('div').nth(5)],
|
||||
})).toMatchSnapshot('mask-should-work-with-locator.png');
|
||||
});
|
||||
|
||||
@ -404,7 +404,7 @@ it.describe('page screenshot', () => {
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
const bodyHandle = await page.$('body');
|
||||
expect(await bodyHandle.screenshot({
|
||||
mask: [ page.locator('div').nth(5) ],
|
||||
mask: [page.locator('div').nth(5)],
|
||||
})).toMatchSnapshot('mask-should-work-with-elementhandle.png');
|
||||
});
|
||||
|
||||
@ -439,10 +439,10 @@ it.describe('page screenshot', () => {
|
||||
await page.addStyleTag({ content: 'iframe { border: none; }' });
|
||||
const screenshots = await Promise.all([
|
||||
page.screenshot({
|
||||
mask: [ page.frameLocator('#frame1').locator('div').nth(1) ],
|
||||
mask: [page.frameLocator('#frame1').locator('div').nth(1)],
|
||||
}),
|
||||
page.screenshot({
|
||||
mask: [ page.frameLocator('#frame2').locator('div').nth(3) ],
|
||||
mask: [page.frameLocator('#frame2').locator('div').nth(3)],
|
||||
}),
|
||||
]);
|
||||
expect(screenshots[0]).toMatchSnapshot('should-mask-in-parallel-1.png');
|
||||
@ -454,7 +454,7 @@ it.describe('page screenshot', () => {
|
||||
await page.goto(server.PREFIX + '/grid.html');
|
||||
const screenshot1 = await page.screenshot();
|
||||
await page.screenshot({
|
||||
mask: [ page.locator('div').nth(1) ],
|
||||
mask: [page.locator('div').nth(1)],
|
||||
});
|
||||
const screenshot2 = await page.screenshot();
|
||||
expect(screenshot1.equals(screenshot2)).toBe(true);
|
||||
@ -469,7 +469,7 @@ it.describe('page screenshot', () => {
|
||||
const done = page.setContent(`<iframe src='/subframe.html'></iframe>`);
|
||||
const route = await routeReady;
|
||||
|
||||
await page.screenshot({ mask: [ page.locator('non-existent') ] });
|
||||
await page.screenshot({ mask: [page.locator('non-existent')] });
|
||||
await route.fulfill({ body: '' });
|
||||
await done;
|
||||
});
|
||||
@ -484,7 +484,7 @@ it.describe('page screenshot', () => {
|
||||
iframe.contentDocument.write('Hello');
|
||||
iframe.contentDocument.close();
|
||||
});
|
||||
await page.screenshot({ mask: [ page.locator('non-existent') ] });
|
||||
await page.screenshot({ mask: [page.locator('non-existent')] });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -131,50 +131,50 @@ it('should return [] on no matched values', async ({ page, server }) => {
|
||||
it('should return an array of matched values', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
await page.evaluate(() => window['makeMultiple']());
|
||||
const result = await page.selectOption('select', ['blue','black','magenta']);
|
||||
expect(result.reduce((accumulator,current) => ['blue', 'black', 'magenta'].includes(current) && accumulator, true)).toEqual(true);
|
||||
const result = await page.selectOption('select', ['blue', 'black', 'magenta']);
|
||||
expect(result.reduce((accumulator, current) => ['blue', 'black', 'magenta'].includes(current) && accumulator, true)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should return an array of one element when multiple is not set', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
const result = await page.selectOption('select',['42','blue','black','magenta']);
|
||||
const result = await page.selectOption('select', ['42', 'blue', 'black', 'magenta']);
|
||||
expect(result.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return [] on no values',async ({ page, server }) => {
|
||||
it('should return [] on no values', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
const result = await page.selectOption('select', []);
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('should not allow null items',async ({ page, server }) => {
|
||||
it('should not allow null items', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
await page.evaluate(() => window['makeMultiple']());
|
||||
let error = null;
|
||||
await page.selectOption('select', ['blue', null, 'black','magenta']).catch(e => error = e);
|
||||
await page.selectOption('select', ['blue', null, 'black', 'magenta']).catch(e => error = e);
|
||||
expect(error.message).toContain('options[1]: expected object, got null');
|
||||
});
|
||||
|
||||
it('should unselect with null',async ({ page, server }) => {
|
||||
it('should unselect with null', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
await page.evaluate(() => window['makeMultiple']());
|
||||
const result = await page.selectOption('select', ['blue', 'black','magenta']);
|
||||
expect(result.reduce((accumulator,current) => ['blue', 'black', 'magenta'].includes(current) && accumulator, true)).toEqual(true);
|
||||
const result = await page.selectOption('select', ['blue', 'black', 'magenta']);
|
||||
expect(result.reduce((accumulator, current) => ['blue', 'black', 'magenta'].includes(current) && accumulator, true)).toEqual(true);
|
||||
await page.selectOption('select', null);
|
||||
expect(await page.$eval('select', select => Array.from(select.options).every(option => !option.selected))).toEqual(true);
|
||||
});
|
||||
|
||||
it('should deselect all options when passed no values for a multiple select',async ({ page, server }) => {
|
||||
it('should deselect all options when passed no values for a multiple select', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
await page.evaluate(() => window['makeMultiple']());
|
||||
await page.selectOption('select', ['blue','black','magenta']);
|
||||
await page.selectOption('select', ['blue', 'black', 'magenta']);
|
||||
await page.selectOption('select', []);
|
||||
expect(await page.$eval('select', select => Array.from(select.options).every(option => !option.selected))).toEqual(true);
|
||||
});
|
||||
|
||||
it('should deselect all options when passed no values for a select without multiple',async ({ page, server }) => {
|
||||
it('should deselect all options when passed no values for a select without multiple', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
await page.selectOption('select', ['blue','black','magenta']);
|
||||
await page.selectOption('select', ['blue', 'black', 'magenta']);
|
||||
await page.selectOption('select', []);
|
||||
expect(await page.$eval('select', select => Array.from(select.options).every(option => !option.selected))).toEqual(true);
|
||||
});
|
||||
@ -228,7 +228,7 @@ it('should work when re-defining top-level Event class', async ({ page, server }
|
||||
expect(await page.evaluate(() => window['result'].onChange)).toEqual(['blue']);
|
||||
});
|
||||
|
||||
it('should wait for option to be present',async ({ page, server }) => {
|
||||
it('should wait for option to be present', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
const selectPromise = page.selectOption('select', 'scarlet');
|
||||
let didSelect = false;
|
||||
@ -245,7 +245,7 @@ it('should wait for option to be present',async ({ page, server }) => {
|
||||
expect(items).toStrictEqual(['scarlet']);
|
||||
});
|
||||
|
||||
it('should wait for option index to be present',async ({ page, server }) => {
|
||||
it('should wait for option index to be present', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
const len = await page.$eval('select', select => select.options.length);
|
||||
const selectPromise = page.selectOption('select', { index: len });
|
||||
@ -263,7 +263,7 @@ it('should wait for option index to be present',async ({ page, server }) => {
|
||||
expect(items).toStrictEqual(['scarlet']);
|
||||
});
|
||||
|
||||
it('should wait for multiple options to be present',async ({ page, server }) => {
|
||||
it('should wait for multiple options to be present', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/input/select.html');
|
||||
await page.evaluate(() => window['makeMultiple']());
|
||||
const selectPromise = page.selectOption('select', ['green', 'scarlet']);
|
||||
|
@ -222,7 +222,7 @@ it('should work when file input is attached to DOM', async ({ page, server }) =>
|
||||
});
|
||||
|
||||
it('should work when file input is not attached to DOM', async ({ page, asset }) => {
|
||||
const [,content] = await Promise.all([
|
||||
const [, content] = await Promise.all([
|
||||
page.waitForEvent('filechooser').then(chooser => chooser.setFiles(asset('file-to-upload.txt'))),
|
||||
page.evaluate(async () => {
|
||||
const el = document.createElement('input');
|
||||
|
@ -169,7 +169,7 @@ it('should work for frame', async ({ page, server }) => {
|
||||
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
||||
const frame = page.frames()[1];
|
||||
|
||||
const requestPromise = new Promise<Route>(resolve => page.route(server.PREFIX + '/one-style.css',resolve));
|
||||
const requestPromise = new Promise<Route>(resolve => page.route(server.PREFIX + '/one-style.css', resolve));
|
||||
await frame.goto(server.PREFIX + '/one-style.html', { waitUntil: 'domcontentloaded' });
|
||||
const request = await requestPromise;
|
||||
let resolved = false;
|
||||
|
@ -58,7 +58,7 @@ test('should access annotations in fixture', async ({ runInlineTest }) => {
|
||||
});
|
||||
expect(exitCode).toBe(0);
|
||||
const test = report.suites[0].specs[0].tests[0];
|
||||
expect(test.annotations).toEqual([ { type: 'slow', description: 'just slow' }, { type: 'myname', description: 'hello' } ]);
|
||||
expect(test.annotations).toEqual([{ type: 'slow', description: 'just slow' }, { type: 'myname', description: 'hello' }]);
|
||||
expect(test.results[0].stdout).toEqual([{ text: 'console.log\n' }]);
|
||||
expect(test.results[0].stderr).toEqual([{ text: 'console.error\n' }]);
|
||||
});
|
||||
|
@ -118,7 +118,7 @@ test('should not throw when attachment is missing', async ({ runInlineTest, page
|
||||
await showReport();
|
||||
await page.click('text=passes');
|
||||
await page.locator('text=Missing attachment "screenshot"').click();
|
||||
const screenshotFile = testInfo.outputPath('test-results' , 'a-passes', 'screenshot.png');
|
||||
const screenshotFile = testInfo.outputPath('test-results', 'a-passes', 'screenshot.png');
|
||||
await expect(page.locator('.attachment-body')).toHaveText(`Attachment file ${screenshotFile} is missing`);
|
||||
});
|
||||
|
||||
|
@ -104,7 +104,7 @@ test('should save attachments', async ({ runInlineTest }, testInfo) => {
|
||||
const json = JSON.parse(fs.readFileSync(testInfo.outputPath('test-results', 'report', 'project.report'), 'utf-8'));
|
||||
const result = json.suites[0].tests[0].results[0];
|
||||
expect(result.attachments[0].name).toBe('binary');
|
||||
expect(Buffer.from(result.attachments[0].body, 'base64')).toEqual(Buffer.from([1,2,3]));
|
||||
expect(Buffer.from(result.attachments[0].body, 'base64')).toEqual(Buffer.from([1, 2, 3]));
|
||||
expect(result.attachments[1].name).toBe('text');
|
||||
const path2 = result.attachments[1].path;
|
||||
expect(path2).toBe('dummy-path');
|
||||
|
@ -186,7 +186,7 @@ test.describe('test modifier annotations', () => {
|
||||
expectTest('no marker', 'skipped', 'skipped', ['fixme']);
|
||||
expectTest('skip wrap', 'skipped', 'skipped', ['skip', 'fixme']);
|
||||
expectTest('skip inner', 'skipped', 'skipped', ['fixme']);
|
||||
expectTest('fixme wrap', 'skipped', 'skipped', ['fixme','fixme']);
|
||||
expectTest('fixme wrap', 'skipped', 'skipped', ['fixme', 'fixme']);
|
||||
expectTest('fixme inner', 'skipped', 'skipped', ['fixme']);
|
||||
expectTest('example', 'skipped', 'skipped', ['fixme']);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user