diff --git a/.eslintrc.js b/.eslintrc.js index 60c67832b8..efe1dcb39f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -24,6 +24,7 @@ module.exports = { * Enforced rules */ // syntax preferences + "object-curly-spacing": ["error", "always"], "quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true diff --git a/packages/create-playwright/tests/integration.spec.ts b/packages/create-playwright/tests/integration.spec.ts index 7f965a5a35..aa06108a25 100644 --- a/packages/create-playwright/tests/integration.spec.ts +++ b/packages/create-playwright/tests/integration.spec.ts @@ -67,9 +67,9 @@ const test = base.extend({ }, }); -for (const packageManager of ['npm', 'yarn'] as ('npm'|'yarn')[]) { +for (const packageManager of ['npm', 'yarn'] as ('npm' | 'yarn')[]) { test.describe(`Package manager: ${packageManager}`, () => { - test.use({packageManager}); + test.use({ packageManager }); test('should generate a project in the current directory', async ({ run }) => { const { exitCode, dir, stdout } = await run([], { installGitHubActions: true, testDir: 'e2e', language: 'TypeScript' }); diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 87883e1a59..840b538c50 100755 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -167,7 +167,7 @@ const browsers = [ { alias: 'wk', name: 'WebKit', type: 'webkit' }, ]; -for (const {alias, name, type} of browsers) { +for (const { alias, name, type } of browsers) { commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []) .action(function(url, command) { open({ ...command, browser: type }, url, command.target).catch(logErrorAndExit); diff --git a/src/client/android.ts b/src/client/android.ts index 7da0893705..2eee709783 100644 --- a/src/client/android.ts +++ b/src/client/android.ts @@ -360,7 +360,7 @@ function toSelectorChannel(selector: api.AndroidSelector): channels.AndroidSelec focusable, focused, hasChild: hasChild ? { selector: toSelectorChannel(hasChild.selector) } : undefined, - hasDescendant: hasDescendant ? { selector: toSelectorChannel(hasDescendant.selector), maxDepth: hasDescendant.maxDepth} : undefined, + hasDescendant: hasDescendant ? { selector: toSelectorChannel(hasDescendant.selector), maxDepth: hasDescendant.maxDepth } : undefined, longClickable, scrollable, selected, diff --git a/src/client/browserContext.ts b/src/client/browserContext.ts index e7898afa3b..3990c0fa94 100644 --- a/src/client/browserContext.ts +++ b/src/client/browserContext.ts @@ -71,16 +71,16 @@ export class BrowserContext extends ChannelOwner this._onBinding(BindingCall.from(binding))); + this._channel.on('bindingCall', ({ binding }) => this._onBinding(BindingCall.from(binding))); this._channel.on('close', () => this._onClose()); - this._channel.on('page', ({page}) => this._onPage(Page.from(page))); + this._channel.on('page', ({ page }) => this._onPage(Page.from(page))); this._channel.on('route', ({ route, request }) => this._onRoute(network.Route.from(route), network.Request.from(request))); this._channel.on('backgroundPage', ({ page }) => { const backgroundPage = Page.from(page); this._backgroundPages.add(backgroundPage); this.emit(Events.BrowserContext.BackgroundPage, backgroundPage); }); - this._channel.on('serviceWorker', ({worker}) => { + this._channel.on('serviceWorker', ({ worker }) => { const serviceWorker = Worker.from(worker); serviceWorker._context = this; this._serviceWorkers.add(serviceWorker); diff --git a/src/client/browserType.ts b/src/client/browserType.ts index 49860a6c74..b47c99d561 100644 --- a/src/client/browserType.ts +++ b/src/client/browserType.ts @@ -210,7 +210,7 @@ export class BrowserType extends ChannelOwner { - const paramsHeaders = Object.assign({'User-Agent': getUserAgent()}, params.headers); + const paramsHeaders = Object.assign({ 'User-Agent': getUserAgent() }, params.headers); const headers = paramsHeaders ? headersObjectToArray(paramsHeaders) : undefined; const result = await channel.connectOverCDP({ endpointURL, diff --git a/src/client/input.ts b/src/client/input.ts index 3b0c494b93..259a6b8bef 100644 --- a/src/client/input.ts +++ b/src/client/input.ts @@ -108,7 +108,7 @@ export class Touchscreen implements api.Touchscreen { async tap(x: number, y: number) { await this._page._wrapApiCall(async channel => { - await channel.touchscreenTap({x, y}); + await channel.touchscreenTap({ x, y }); }); } } diff --git a/src/client/jsHandle.ts b/src/client/jsHandle.ts index 6bbb8c6e17..cc3da92691 100644 --- a/src/client/jsHandle.ts +++ b/src/client/jsHandle.ts @@ -30,7 +30,7 @@ export class JSHandle extends ChannelOwner this._preview = preview); + this._channel.on('previewUpdated', ({ preview }) => this._preview = preview); } async evaluate(pageFunction: structs.PageFunctionOn, arg?: Arg): Promise { diff --git a/src/client/page.ts b/src/client/page.ts index 8591146ea3..20ee4c9326 100644 --- a/src/client/page.ts +++ b/src/client/page.ts @@ -491,7 +491,7 @@ export class Page extends ChannelOwner { if (this._ownedContext) diff --git a/src/dispatchers/browserContextDispatcher.ts b/src/dispatchers/browserContextDispatcher.ts index 05ea5db256..e009eedd36 100644 --- a/src/dispatchers/browserContextDispatcher.ts +++ b/src/dispatchers/browserContextDispatcher.ts @@ -65,7 +65,7 @@ export class BrowserContextDispatcher extends Dispatcher this._dispatchEvent('backgroundPage', { page: new PageDispatcher(this._scope, page) })); for (const serviceWorker of (context as CRBrowserContext).serviceWorkers()) - this._dispatchEvent('serviceWorker', { worker: new WorkerDispatcher(this._scope, serviceWorker)}); + this._dispatchEvent('serviceWorker', { worker: new WorkerDispatcher(this._scope, serviceWorker) }); context.on(CRBrowserContext.CREvents.ServiceWorker, serviceWorker => this._dispatchEvent('serviceWorker', { worker: new WorkerDispatcher(this._scope, serviceWorker) })); } context.on(BrowserContext.Events.Request, (request: Request) => { @@ -84,7 +84,7 @@ export class BrowserContextDispatcher extends Dispatcher this._dispatchEvent('requestFinished', { + context.on(BrowserContext.Events.RequestFinished, ({ request, response }: { request: Request, response: Response | null }) => this._dispatchEvent('requestFinished', { request: RequestDispatcher.from(scope, request), response: ResponseDispatcher.fromNullable(scope, response), responseEndTiming: request._responseEndTiming, diff --git a/src/dispatchers/browserTypeDispatcher.ts b/src/dispatchers/browserTypeDispatcher.ts index 22c7538c61..d4c8ee3af1 100644 --- a/src/dispatchers/browserTypeDispatcher.ts +++ b/src/dispatchers/browserTypeDispatcher.ts @@ -56,7 +56,7 @@ export class BrowserTypeDispatcher extends Dispatcher any) => setTimeout(cb, params.slowMo) : makeWaitForNextTask(); - const paramsHeaders = Object.assign({'User-Agent': getUserAgent()}, params.headers || {}); + const paramsHeaders = Object.assign({ 'User-Agent': getUserAgent() }, params.headers || {}); const ws = new WebSocket(params.wsEndpoint, [], { perMessageDeflate: false, maxPayload: 256 * 1024 * 1024, // 256Mb, diff --git a/src/server/accessibility.ts b/src/server/accessibility.ts index d6381cfa1d..d3797fb426 100644 --- a/src/server/accessibility.ts +++ b/src/server/accessibility.ts @@ -40,7 +40,7 @@ export class Accessibility { interestingOnly = true, root = null, } = options; - const {tree, needle} = await this._getAXTree(root || undefined); + const { tree, needle } = await this._getAXTree(root || undefined); if (!interestingOnly) { if (root) return needle && serializeTree(needle)[0]; diff --git a/src/server/browserContext.ts b/src/server/browserContext.ts index c7756e580e..82f54eee1a 100644 --- a/src/server/browserContext.ts +++ b/src/server/browserContext.ts @@ -76,7 +76,7 @@ export abstract class BrowserContext extends SdkObject { this._closePromise = new Promise(fulfill => this._closePromiseFulfill = fulfill); if (this._options.recordHar) - this._harRecorder = new HarRecorder(this, {...this._options.recordHar, path: path.join(this._browser.options.artifactsDir, `${createGuid()}.har`)}); + this._harRecorder = new HarRecorder(this, { ...this._options.recordHar, path: path.join(this._browser.options.artifactsDir, `${createGuid()}.har`) }); this.tracing = new Tracing(this); this.fetchRequest = new BrowserContextFetchRequest(this); diff --git a/src/server/chromium/chromium.ts b/src/server/chromium/chromium.ts index 4b0972311a..72d20b2856 100644 --- a/src/server/chromium/chromium.ts +++ b/src/server/chromium/chromium.ts @@ -54,7 +54,7 @@ export class Chromium extends BrowserType { controller.setLogName('browser'); return controller.run(async progress => { return await this._connectOverCDPInternal(progress, endpointURL, options); - }, TimeoutSettings.timeout({timeout})); + }, TimeoutSettings.timeout({ timeout })); } async _connectOverCDPInternal(progress: Progress, endpointURL: string, options: { slowMo?: number, headers?: types.HeadersArray }, onClose?: () => Promise) { diff --git a/src/server/chromium/crAccessibility.ts b/src/server/chromium/crAccessibility.ts index 614adefaa5..6de870c1c6 100644 --- a/src/server/chromium/crAccessibility.ts +++ b/src/server/chromium/crAccessibility.ts @@ -22,7 +22,7 @@ import * as accessibility from '../accessibility'; import * as types from '../types'; export async function getAccessibilityTree(client: CRSession, needle?: dom.ElementHandle): Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}> { - const {nodes} = await client.send('Accessibility.getFullAXTree'); + const { nodes } = await client.send('Accessibility.getFullAXTree'); const tree = CRAXNode.createTree(client, nodes); return { tree, @@ -97,7 +97,7 @@ class CRAXNode implements accessibility.AXNode { async _findElement(element: dom.ElementHandle): Promise { const objectId = element._objectId; - const {node: {backendNodeId}} = await this._client.send('DOM.describeNode', { objectId }); + const { node: { backendNodeId } } = await this._client.send('DOM.describeNode', { objectId }); const needle = this.find(node => node._payload.backendDOMNodeId === backendNodeId); return needle || null; } diff --git a/src/server/chromium/crBrowser.ts b/src/server/chromium/crBrowser.ts index 04ea30e89d..eb5c63f9fb 100644 --- a/src/server/chromium/crBrowser.ts +++ b/src/server/chromium/crBrowser.ts @@ -121,7 +121,7 @@ export class CRBrowser extends Browser { await Promise.all([...this._crPages.values()].map(page => page.pageOrError())); } - _onAttachedToTarget({targetInfo, sessionId, waitingForDebugger}: Protocol.Target.attachedToTargetPayload) { + _onAttachedToTarget({ targetInfo, sessionId, waitingForDebugger }: Protocol.Target.attachedToTargetPayload) { if (targetInfo.type === 'browser') return; const session = this._connection.session(sessionId)!; diff --git a/src/server/chromium/crConnection.ts b/src/server/chromium/crConnection.ts index da508ac536..5c2e00644c 100644 --- a/src/server/chromium/crConnection.ts +++ b/src/server/chromium/crConnection.ts @@ -172,7 +172,7 @@ export class CRSession extends EventEmitter { throw new ProtocolError(true, `Target closed`); const id = this._connection._rawSend(this._sessionId, method, params); return new Promise((resolve, reject) => { - this._callbacks.set(id, {resolve, reject, error: new ProtocolError(false), method}); + this._callbacks.set(id, { resolve, reject, error: new ProtocolError(false), method }); }); } diff --git a/src/server/chromium/crCoverage.ts b/src/server/chromium/crCoverage.ts index 17d4268932..63ba1bb43e 100644 --- a/src/server/chromium/crCoverage.ts +++ b/src/server/chromium/crCoverage.ts @@ -85,7 +85,7 @@ class JSCoverage { this._client.send('Profiler.enable'), this._client.send('Profiler.startPreciseCoverage', { callCount: true, detailed: true }), this._client.send('Debugger.enable'), - this._client.send('Debugger.setSkipAllPauses', {skip: true}) + this._client.send('Debugger.setSkipAllPauses', { skip: true }) ]); } @@ -106,7 +106,7 @@ class JSCoverage { if (!event.url && !this._reportAnonymousScripts) return; // This might fail if the page has already navigated away. - const response = await this._client._sendMayFail('Debugger.getScriptSource', {scriptId: event.scriptId}); + const response = await this._client._sendMayFail('Debugger.getScriptSource', { scriptId: event.scriptId }); if (response) this._scriptSources.set(event.scriptId, response.scriptSource); } @@ -130,7 +130,7 @@ class JSCoverage { continue; const source = this._scriptSources.get(entry.scriptId); if (source) - coverage.push({...entry, source}); + coverage.push({ ...entry, source }); else coverage.push(entry); } @@ -157,7 +157,7 @@ class CSSCoverage { async start(options: types.CSSCoverageOptions = {}) { assert(!this._enabled, 'CSSCoverage is already enabled'); - const {resetOnNavigation = true} = options; + const { resetOnNavigation = true } = options; this._resetOnNavigation = resetOnNavigation; this._enabled = true; this._stylesheetURLs.clear(); @@ -186,7 +186,7 @@ class CSSCoverage { if (!header.sourceURL) return; // This might fail if the page has already navigated away. - const response = await this._client._sendMayFail('CSS.getStyleSheetText', {styleSheetId: header.styleSheetId}); + const response = await this._client._sendMayFail('CSS.getStyleSheetText', { styleSheetId: header.styleSheetId }); if (response) { this._stylesheetURLs.set(header.styleSheetId, header.sourceURL); this._stylesheetSources.set(header.styleSheetId, response.text); @@ -266,7 +266,7 @@ function convertToDisjointRanges(nestedRanges: { if (lastResult && lastResult.end === lastOffset) lastResult.end = point.offset; else - results.push({start: lastOffset, end: point.offset}); + results.push({ start: lastOffset, end: point.offset }); } lastOffset = point.offset; if (point.type === 0) diff --git a/src/server/chromium/crDragDrop.ts b/src/server/chromium/crDragDrop.ts index 7e0e615c15..abec6964f3 100644 --- a/src/server/chromium/crDragDrop.ts +++ b/src/server/chromium/crDragDrop.ts @@ -28,7 +28,7 @@ declare global { export class DragManager { private _crPage: CRPage; private _dragState: Protocol.Input.DragData | null = null; - private _lastPosition = {x: 0, y: 0}; + private _lastPosition = { x: 0, y: 0 }; constructor(page: CRPage) { this._crPage = page; } @@ -50,7 +50,7 @@ export class DragManager { } async interceptDragCausedByMove(x: number, y: number, button: types.MouseButton | 'none', buttons: Set, modifiers: Set, moveCallback: () => Promise): Promise { - this._lastPosition = {x, y}; + this._lastPosition = { x, y }; if (this._dragState) { await this._crPage._mainFrameSession._client.send('Input.dispatchDragEvent', { type: 'dragOver', @@ -75,15 +75,15 @@ export class DragManager { const dragListener = (event: Event) => dragEvent = event; const mouseListener = () => { didStartDrag = new Promise(callback => { - window.addEventListener('dragstart', dragListener, {once: true, capture: true}); + window.addEventListener('dragstart', dragListener, { once: true, capture: true }); setTimeout(() => callback(dragEvent ? !dragEvent.defaultPrevented : false), 0); }); }; - window.addEventListener('mousemove', mouseListener, {once: true, capture: true}); + window.addEventListener('mousemove', mouseListener, { once: true, capture: true }); window.__cleanupDrag = async () => { const val = await didStartDrag; - window.removeEventListener('mousemove', mouseListener, {capture: true}); - window.removeEventListener('dragstart', dragListener, {capture: true}); + window.removeEventListener('mousemove', mouseListener, { capture: true }); + window.removeEventListener('dragstart', dragListener, { capture: true }); return val; }; }).toString(), true, 'utility').catch(() => {}); @@ -91,7 +91,7 @@ export class DragManager { client.on('Input.dragIntercepted', onDragIntercepted!); try { - await client.send('Input.setInterceptDrags', {enabled: true}); + await client.send('Input.setInterceptDrags', { enabled: true }); } catch { // If Input.setInterceptDrags is not supported, just do a regular move. // This can be removed once we stop supporting old Electron. @@ -105,7 +105,7 @@ export class DragManager { }))).some(x => x); this._dragState = expectingDrag ? (await dragInterceptedPromise).data : null; client.off('Input.dragIntercepted', onDragIntercepted!); - await client.send('Input.setInterceptDrags', {enabled: false}); + await client.send('Input.setInterceptDrags', { enabled: false }); if (this._dragState) { diff --git a/src/server/chromium/crExecutionContext.ts b/src/server/chromium/crExecutionContext.ts index 51d68e8d3f..e03e589d71 100644 --- a/src/server/chromium/crExecutionContext.ts +++ b/src/server/chromium/crExecutionContext.ts @@ -106,9 +106,9 @@ export class CRExecutionContext implements js.ExecutionContextDelegate { function rewriteError(error: Error): Protocol.Runtime.evaluateReturnValue { if (error.message.includes('Object reference chain is too long')) - return {result: {type: 'undefined'}}; + return { result: { type: 'undefined' } }; if (error.message.includes('Object couldn\'t be returned by value')) - return {result: {type: 'undefined'}}; + return { result: { type: 'undefined' } }; if (error instanceof TypeError && error.message.startsWith('Converting circular structure to JSON')) rewriteErrorMessage(error, error.message + ' Are you passing a nested JSHandle?'); diff --git a/src/server/chromium/crNetworkManager.ts b/src/server/chromium/crNetworkManager.ts index 0ad5e2f6e0..19246286c0 100644 --- a/src/server/chromium/crNetworkManager.ts +++ b/src/server/chromium/crNetworkManager.ts @@ -105,7 +105,7 @@ export class CRNetworkManager { this._client.send('Network.setCacheDisabled', { cacheDisabled: true }), this._client.send('Fetch.enable', { handleAuthRequests: true, - patterns: [{urlPattern: '*', requestStage: 'Request'}, {urlPattern: '*', requestStage: 'Response'}], + patterns: [{ urlPattern: '*', requestStage: 'Request' }, { urlPattern: '*', requestStage: 'Response' }], }), ]); } else { @@ -146,7 +146,7 @@ export class CRNetworkManager { response = 'ProvideCredentials'; this._attemptedAuthentications.add(event.requestId); } - const {username, password} = this._credentials || {username: undefined, password: undefined}; + const { username, password } = this._credentials || { username: undefined, password: undefined }; this._client._sendMayFail('Fetch.continueWithAuth', { requestId: event.requestId, authChallengeResponse: { response, username, password }, diff --git a/src/server/chromium/crPage.ts b/src/server/chromium/crPage.ts index 546eeb0005..b03a6fa290 100644 --- a/src/server/chromium/crPage.ts +++ b/src/server/chromium/crPage.ts @@ -460,7 +460,7 @@ class FrameSession { this._addBrowserListeners(); const promises: Promise[] = [ this._client.send('Page.enable'), - this._client.send('Page.getFrameTree').then(({frameTree}) => { + this._client.send('Page.getFrameTree').then(({ frameTree }) => { if (this._isMainFrame()) { this._handleFrameTree(frameTree); this._addRendererListeners(); @@ -815,7 +815,7 @@ class FrameSession { } _onLogEntryAdded(event: Protocol.Log.entryAddedPayload) { - const {level, text, args, source, url, lineNumber} = event.entry; + const { level, text, args, source, url, lineNumber } = event.entry; if (args) args.map(arg => releaseObject(this._client, arg.objectId!)); if (source !== 'worker') { @@ -853,7 +853,7 @@ class FrameSession { } _onScreencastFrame(payload: Protocol.Page.screencastFramePayload) { - this._client.send('Page.screencastFrameAck', {sessionId: payload.sessionId}).catch(() => {}); + this._client.send('Page.screencastFrameAck', { sessionId: payload.sessionId }).catch(() => {}); const buffer = Buffer.from(payload.data, 'base64'); this._page.emit(Page.Events.ScreencastFrame, { buffer, diff --git a/src/server/chromium/crPdf.ts b/src/server/chromium/crPdf.ts index ec9186a404..19831822f2 100644 --- a/src/server/chromium/crPdf.ts +++ b/src/server/chromium/crPdf.ts @@ -21,17 +21,17 @@ import { CRSession } from './crConnection'; import { readProtocolStream } from './crProtocolHelper'; const PagePaperFormats: { [key: string]: { width: number, height: number }} = { - letter: {width: 8.5, height: 11}, - legal: {width: 8.5, height: 14}, - tabloid: {width: 11, height: 17}, - ledger: {width: 17, height: 11}, - a0: {width: 33.1, height: 46.8 }, - a1: {width: 23.4, height: 33.1 }, - a2: {width: 16.54, height: 23.4 }, - a3: {width: 11.7, height: 16.54 }, - a4: {width: 8.27, height: 11.7 }, - a5: {width: 5.83, height: 8.27 }, - a6: {width: 4.13, height: 5.83 }, + letter: { width: 8.5, height: 11 }, + legal: { width: 8.5, height: 14 }, + tabloid: { width: 11, height: 17 }, + ledger: { width: 17, height: 11 }, + a0: { width: 33.1, height: 46.8 }, + a1: { width: 23.4, height: 33.1 }, + a2: { width: 16.54, height: 23.4 }, + a3: { width: 11.7, height: 16.54 }, + a4: { width: 8.27, height: 11.7 }, + a5: { width: 5.83, height: 8.27 }, + a6: { width: 4.13, height: 5.83 }, }; const unitToPixels: { [key: string]: number } = { diff --git a/src/server/chromium/crProtocolHelper.ts b/src/server/chromium/crProtocolHelper.ts index 61b97d0be2..42822dcc11 100644 --- a/src/server/chromium/crProtocolHelper.ts +++ b/src/server/chromium/crProtocolHelper.ts @@ -49,7 +49,7 @@ export async function readProtocolStream(client: CRSession, handle: string, path } const bufs = []; while (!eof) { - const response = await client.send('IO.read', {handle}); + const response = await client.send('IO.read', { handle }); eof = response.eof; const buf = Buffer.from(response.data, response.base64Encoded ? 'base64' : undefined); bufs.push(buf); @@ -58,7 +58,7 @@ export async function readProtocolStream(client: CRSession, handle: string, path } if (fd) await fd.close(); - await client.send('IO.close', {handle}); + await client.send('IO.close', { handle }); return Buffer.concat(bufs); } @@ -82,7 +82,7 @@ export function exceptionToError(exceptionDetails: Protocol.Runtime.ExceptionDet messageWithName = lines.slice(0, firstStackTraceLine).join('\n'); stack = messageWithStack; } - const {name, message} = splitErrorMessage(messageWithName); + const { name, message } = splitErrorMessage(messageWithName); const err = new Error(message); err.stack = stack; diff --git a/src/server/common/componentUtils.ts b/src/server/common/componentUtils.ts index 2a349bb352..b624d5a1ca 100644 --- a/src/server/common/componentUtils.ts +++ b/src/server/common/componentUtils.ts @@ -142,7 +142,7 @@ export function parseComponentSelector(selector: string): ParsedComponentSelecto // check property is truthy: [enabled] if (next() === ']') { eat1(); - return {jsonPath, op: '', value: null, caseSensetive: false}; + return { jsonPath, op: '', value: null, caseSensetive: false }; } const operator = readOperator(); @@ -181,7 +181,7 @@ export function parseComponentSelector(selector: string): ParsedComponentSelecto eat1(); if (operator !== '=' && typeof value !== 'string') throw new Error(`Error while parsing selector \`${selector}\` - cannot use ${operator} in attribute with non-string matching value - ${value}`); - return {jsonPath, op: operator, value, caseSensetive}; + return { jsonPath, op: operator, value, caseSensetive }; } const result: ParsedComponentSelector = { diff --git a/src/server/dom.ts b/src/server/dom.ts index a0a1bff37d..ab04530953 100644 --- a/src/server/dom.ts +++ b/src/server/dom.ts @@ -277,7 +277,7 @@ export class ElementHandle extends js.JSHandle { const [quads, metrics] = await Promise.all([ this._page._delegate.getContentQuads(this), - this._page.mainFrame()._utilityContext().then(utility => utility.evaluate(() => ({width: innerWidth, height: innerHeight}))), + this._page.mainFrame()._utilityContext().then(utility => utility.evaluate(() => ({ width: innerWidth, height: innerHeight }))), ] as const); if (!quads || !quads.length) return 'error:notvisible'; diff --git a/src/server/electron/electron.ts b/src/server/electron/electron.ts index 15e987885a..884b0968f1 100644 --- a/src/server/electron/electron.ts +++ b/src/server/electron/electron.ts @@ -26,7 +26,7 @@ import { TimeoutSettings } from '../../utils/timeoutSettings'; import { WebSocketTransport } from '../transport'; import { launchProcess, envArrayToObject } from '../../utils/processLauncher'; import { BrowserContext } from '../browserContext'; -import type {BrowserWindow} from 'electron'; +import type { BrowserWindow } from 'electron'; import { Progress, ProgressController } from '../progress'; import { helper } from '../helper'; import { eventsHelper } from '../../utils/eventsHelper'; diff --git a/src/server/fetch.ts b/src/server/fetch.ts index 4ed476ff0c..23824dd6ba 100644 --- a/src/server/fetch.ts +++ b/src/server/fetch.ts @@ -91,7 +91,7 @@ export abstract class FetchRequest extends SdkObject { headers['accept-encoding'] = 'gzip,deflate,br'; if (defaults.extraHTTPHeaders) { - for (const {name, value} of defaults.extraHTTPHeaders) + for (const { name, value } of defaults.extraHTTPHeaders) headers[name.toLowerCase()] = value; } @@ -235,7 +235,7 @@ export abstract class FetchRequest extends SdkObject { const auth = response.headers['www-authenticate']; const credentials = this._defaultOptions().httpCredentials; if (auth?.trim().startsWith('Basic ') && credentials) { - const {username, password} = credentials; + const { username, password } = credentials; const encoded = Buffer.from(`${username || ''}:${password || ''}`).toString('base64'); options.headers!['authorization'] = `Basic ${encoded}`; fulfill(this._sendRequest(url, options, postData)); diff --git a/src/server/firefox/ffBrowser.ts b/src/server/firefox/ffBrowser.ts index 81c07a6b81..32a5ba2b53 100644 --- a/src/server/firefox/ffBrowser.ts +++ b/src/server/firefox/ffBrowser.ts @@ -106,7 +106,7 @@ export class FFBrowser extends Browser { } _onAttachedToTarget(payload: Protocol.Browser.attachedToTargetPayload) { - const {targetId, browserContextId, openerId, type} = payload.targetInfo; + const { targetId, browserContextId, openerId, type } = payload.targetInfo; assert(type === 'page'); const context = browserContextId ? this._contexts.get(browserContextId)! : this._defaultContext as FFBrowserContext; assert(context, `Unknown context id:${browserContextId}, _defaultContext: ${this._defaultContext}`); @@ -290,7 +290,7 @@ export class FFBrowserContext extends BrowserContext { throw new Error('Unknown permission: ' + permission); return protocolPermission; }); - await this._browser._connection.send('Browser.grantPermissions', { origin: origin, browserContextId: this._browserContextId, permissions: filtered}); + await this._browser._connection.send('Browser.grantPermissions', { origin: origin, browserContextId: this._browserContextId, permissions: filtered }); } async _doClearPermissions() { diff --git a/src/server/firefox/ffConnection.ts b/src/server/firefox/ffConnection.ts index d6de82fb52..181210ea05 100644 --- a/src/server/firefox/ffConnection.ts +++ b/src/server/firefox/ffConnection.ts @@ -75,9 +75,9 @@ export class FFConnection extends EventEmitter { ): Promise { this._checkClosed(method); const id = this.nextMessageId(); - this._rawSend({id, method, params}); + this._rawSend({ id, method, params }); return new Promise((resolve, reject) => { - this._callbacks.set(id, {resolve, reject, error: new ProtocolError(false), method}); + this._callbacks.set(id, { resolve, reject, error: new ProtocolError(false), method }); }); } @@ -141,7 +141,7 @@ export class FFConnection extends EventEmitter { } createSession(sessionId: string): FFSession { - const session = new FFSession(this, sessionId, message => this._rawSend({...message, sessionId})); + const session = new FFSession(this, sessionId, message => this._rawSend({ ...message, sessionId })); this._sessions.set(sessionId, session); return session; } @@ -193,9 +193,9 @@ export class FFSession extends EventEmitter { if (this._disposed) throw new ProtocolError(true, 'Target closed'); const id = this._connection.nextMessageId(); - this._rawSend({method, params, id}); + this._rawSend({ method, params, id }); return new Promise((resolve, reject) => { - this._callbacks.set(id, {resolve, reject, error: new ProtocolError(false), method}); + this._callbacks.set(id, { resolve, reject, error: new ProtocolError(false), method }); }); } diff --git a/src/server/firefox/ffExecutionContext.ts b/src/server/firefox/ffExecutionContext.ts index 90da5d97b7..96f7127a69 100644 --- a/src/server/firefox/ffExecutionContext.ts +++ b/src/server/firefox/ffExecutionContext.ts @@ -111,7 +111,7 @@ function checkException(exceptionDetails?: Protocol.Runtime.ExceptionDetails) { function rewriteError(error: Error): (Protocol.Runtime.evaluateReturnValue | Protocol.Runtime.callFunctionReturnValue) { if (error.message.includes('cyclic object value') || error.message.includes('Object is not serializable')) - return {result: {type: 'undefined', value: undefined}}; + return { result: { type: 'undefined', value: undefined } }; if (error instanceof TypeError && error.message.startsWith('Converting circular structure to JSON')) rewriteErrorMessage(error, error.message + ' Are you passing a nested JSHandle?'); if (!js.isJavaScriptErrorInEvaluate(error) && !isSessionClosedError(error)) diff --git a/src/server/firefox/ffNetworkManager.ts b/src/server/firefox/ffNetworkManager.ts index f4e410b2fe..ee12f5a5a6 100644 --- a/src/server/firefox/ffNetworkManager.ts +++ b/src/server/firefox/ffNetworkManager.ts @@ -50,7 +50,7 @@ export class FFNetworkManager { } async setRequestInterception(enabled: boolean) { - await this._session.send('Network.setRequestInterception', {enabled}); + await this._session.send('Network.setRequestInterception', { enabled }); } _onRequestWillBeSent(event: Protocol.Network.requestWillBeSentPayload) { diff --git a/src/server/firefox/ffPage.ts b/src/server/firefox/ffPage.ts index fcc7a5792e..4a40e3b01d 100644 --- a/src/server/firefox/ffPage.ts +++ b/src/server/firefox/ffPage.ts @@ -152,7 +152,7 @@ export class FFPage implements PageDelegate { } _onExecutionContextCreated(payload: Protocol.Runtime.executionContextCreatedPayload) { - const {executionContextId, auxData} = payload; + const { executionContextId, auxData } = payload; const frame = this._page._frameManager.frame(auxData.frameId!); if (!frame) return; @@ -169,7 +169,7 @@ export class FFPage implements PageDelegate { } _onExecutionContextDestroyed(payload: Protocol.Runtime.executionContextDestroyedPayload) { - const {executionContextId} = payload; + const { executionContextId } = payload; const context = this._contextIdToContext.get(executionContextId); if (!context) return; @@ -220,7 +220,7 @@ export class FFPage implements PageDelegate { } _onEventFired(payload: Protocol.Page.eventFiredPayload) { - const {frameId, name} = payload; + const { frameId, name } = payload; if (name === 'load') this._page._frameManager.frameLifecycleEvent(frameId, 'load'); if (name === 'DOMContentLoaded') @@ -236,7 +236,7 @@ export class FFPage implements PageDelegate { } _onConsole(payload: Protocol.Runtime.consolePayload) { - const {type, args, executionContextId, location} = payload; + const { type, args, executionContextId, location } = payload; const context = this._contextIdToContext.get(executionContextId)!; this._page._addConsoleMessage(type, args.map(arg => context.createHandle(arg)), location); } @@ -260,7 +260,7 @@ export class FFPage implements PageDelegate { } async _onFileChooserOpened(payload: Protocol.Page.fileChooserOpenedPayload) { - const {executionContextId, element} = payload; + const { executionContextId, element } = payload; const context = this._contextIdToContext.get(executionContextId)!; const handle = context.createHandle(element).asElement()!; await this._page._onFileChooserOpened(handle); @@ -284,7 +284,7 @@ export class FFPage implements PageDelegate { worker._createExecutionContext(new FFExecutionContext(workerSession, event.executionContextId)); }); workerSession.on('Runtime.console', event => { - const {type, args, location} = event; + const { type, args, location } = event; const context = worker._existingExecutionContext!; this._page._addConsoleMessage(type, args.map(arg => context.createHandle(arg)), location); }); diff --git a/src/server/frames.ts b/src/server/frames.ts index 4fd2f45b5b..6841cb6eda 100644 --- a/src/server/frames.ts +++ b/src/server/frames.ts @@ -1336,7 +1336,7 @@ export class Frame extends SdkObject { async extendInjectedScript(source: string, arg?: any): Promise { const context = await this._context('main'); const injectedScriptHandle = await context.injectedScript(); - return injectedScriptHandle.evaluateHandle((injectedScript, {source, arg}) => { + return injectedScriptHandle.evaluateHandle((injectedScript, { source, arg }) => { return injectedScript.extend(source, arg); }, { source, arg }); } diff --git a/src/server/injected/reactSelectorEngine.ts b/src/server/injected/reactSelectorEngine.ts index 52a1bfd5db..1c452ea824 100644 --- a/src/server/injected/reactSelectorEngine.ts +++ b/src/server/injected/reactSelectorEngine.ts @@ -155,7 +155,7 @@ function findReactRoots(): ReactVNode[] { export const ReactEngine: SelectorEngine = { queryAll(scope: SelectorRoot, selector: string): Element[] { - const {name, attributes} = parseComponentSelector(selector); + const { name, attributes } = parseComponentSelector(selector); const reactRoots = findReactRoots(); const trees = reactRoots.map(reactRoot => buildComponentsTree(reactRoot)); diff --git a/src/server/injected/vueSelectorEngine.ts b/src/server/injected/vueSelectorEngine.ts index f0034298f1..5baef92938 100644 --- a/src/server/injected/vueSelectorEngine.ts +++ b/src/server/injected/vueSelectorEngine.ts @@ -210,7 +210,7 @@ function findVueRoots(): VueRoot[] { // Vue3 roots are marked with [data-v-app] attribute for (const node of document.querySelectorAll('[data-v-app]')) { if ((node as any)._vnode && (node as any)._vnode.component) - roots.push({root: (node as any)._vnode.component, version: 3}); + roots.push({ root: (node as any)._vnode.component, version: 3 }); } // Vue2 roots are referred to from elements. const walker = document.createTreeWalker(document, NodeFilter.SHOW_ELEMENT); @@ -231,7 +231,7 @@ function findVueRoots(): VueRoot[] { export const VueEngine: SelectorEngine = { queryAll(scope: SelectorRoot, selector: string): Element[] { - const {name, attributes} = parseComponentSelector(selector); + const { name, attributes } = parseComponentSelector(selector); const vueRoots = findVueRoots(); const trees = vueRoots.map(vueRoot => vueRoot.version === 3 ? buildComponentsTreeVue3(vueRoot.root) : buildComponentsTreeVue2(vueRoot.root)); const treeNodes = trees.map(tree => filterComponentsTree(tree, treeNode => { diff --git a/src/server/javascript.ts b/src/server/javascript.ts index 042dd2b80c..339884c5de 100644 --- a/src/server/javascript.ts +++ b/src/server/javascript.ts @@ -132,7 +132,7 @@ export class JSHandle extends SdkObject { async getProperty(propertyName: string): Promise { const objectHandle = await this.evaluateHandle((object: any, propertyName) => { - const result: any = {__proto__: null}; + const result: any = { __proto__: null }; result[propertyName] = object[propertyName]; return result; }, propertyName); diff --git a/src/server/network.ts b/src/server/network.ts index f11d556f5a..9bd1bbb585 100644 --- a/src/server/network.ts +++ b/src/server/network.ts @@ -54,7 +54,7 @@ export function rewriteCookies(cookies: types.SetNetworkCookieParam[]): types.Se assert(c.url || (c.domain && c.path), 'Cookie should have a url or a domain/path pair'); assert(!(c.url && c.domain), 'Cookie should have either url or domain'); assert(!(c.url && c.path), 'Cookie should have either url or path'); - const copy = {...c}; + const copy = { ...c }; if (copy.url) { assert(copy.url !== 'about:blank', `Blank page can not have cookie "${c.name}"`); assert(!copy.url.startsWith('data:'), `Data URL page can not have cookie "${c.name}"`); diff --git a/src/server/page.ts b/src/server/page.ts index a261c8b11c..30ceb6f86f 100644 --- a/src/server/page.ts +++ b/src/server/page.ts @@ -556,7 +556,7 @@ export class PageBinding { } static async dispatch(page: Page, payload: string, context: dom.FrameExecutionContext) { - const {name, seq, args} = JSON.parse(payload); + const { name, seq, args } = JSON.parse(payload); try { assert(context.world); const binding = page.getBinding(name)!; @@ -620,12 +620,12 @@ function addPageBinding(bindingName: string, needsHandle: boolean) { handles = new Map(); me['handles'] = handles; } - const promise = new Promise((resolve, reject) => callbacks.set(seq, {resolve, reject})); + const promise = new Promise((resolve, reject) => callbacks.set(seq, { resolve, reject })); if (needsHandle) { handles.set(seq, args[0]); - binding(JSON.stringify({name: bindingName, seq})); + binding(JSON.stringify({ name: bindingName, seq })); } else { - binding(JSON.stringify({name: bindingName, seq, args})); + binding(JSON.stringify({ name: bindingName, seq, args })); } return promise; }; diff --git a/src/server/screenshotter.ts b/src/server/screenshotter.ts index dfe4b8e995..058185b243 100644 --- a/src/server/screenshotter.ts +++ b/src/server/screenshotter.ts @@ -140,7 +140,7 @@ export class Screenshotter { progress.throwIfAborted(); // Screenshotting is expensive - avoid extra work. const shouldSetDefaultBackground = options.omitBackground && format === 'png'; if (shouldSetDefaultBackground) { - await this._page._delegate.setBackgroundColor({ r: 0, g: 0, b: 0, a: 0}); + await this._page._delegate.setBackgroundColor({ r: 0, g: 0, b: 0, a: 0 }); progress.cleanupWhenAborted(() => this._page._delegate.setBackgroundColor()); } progress.throwIfAborted(); // Avoid extra work. diff --git a/src/server/webkit/webkit.ts b/src/server/webkit/webkit.ts index 7aadddbade..04672f669d 100644 --- a/src/server/webkit/webkit.ts +++ b/src/server/webkit/webkit.ts @@ -42,7 +42,7 @@ export class WebKit extends BrowserType { } _attemptToGracefullyCloseBrowser(transport: ConnectionTransport): void { - transport.send({method: 'Playwright.close', params: {}, id: kBrowserCloseMessageId}); + transport.send({ method: 'Playwright.close', params: {}, id: kBrowserCloseMessageId }); } _defaultArgs(options: types.LaunchOptions, isPersistent: boolean, userDataDir: string): string[] { diff --git a/src/server/webkit/wkAccessibility.ts b/src/server/webkit/wkAccessibility.ts index 320fb16832..1654f3e0c4 100644 --- a/src/server/webkit/wkAccessibility.ts +++ b/src/server/webkit/wkAccessibility.ts @@ -21,7 +21,7 @@ import * as types from '../types'; export async function getAccessibilityTree(session: WKSession, needle?: dom.ElementHandle) { const objectId = needle ? needle._objectId : undefined; - const {axNode} = await session.send('Page.accessibilitySnapshot', { objectId }); + const { axNode } = await session.send('Page.accessibilitySnapshot', { objectId }); const tree = new WKAXNode(axNode); return { tree, @@ -127,7 +127,7 @@ class WKAXNode implements accessibility.AXNode { } isInteresting(insideControl: boolean): boolean { - const {role, focusable} = this._payload; + const { role, focusable } = this._payload; const name = this._name(); if (role === 'ScrollArea') return false; diff --git a/src/server/webkit/wkConnection.ts b/src/server/webkit/wkConnection.ts index 3f5659a1a4..6b86271076 100644 --- a/src/server/webkit/wkConnection.ts +++ b/src/server/webkit/wkConnection.ts @@ -138,7 +138,7 @@ export class WKSession extends EventEmitter { const messageObj = { id, method, params }; this._rawSend(messageObj); return new Promise((resolve, reject) => { - this._callbacks.set(id, {resolve, reject, error: new ProtocolError(false), method}); + this._callbacks.set(id, { resolve, reject, error: new ProtocolError(false), method }); }); } diff --git a/src/server/webkit/wkPage.ts b/src/server/webkit/wkPage.ts index 5d4e1c478e..d278547a56 100644 --- a/src/server/webkit/wkPage.ts +++ b/src/server/webkit/wkPage.ts @@ -308,7 +308,7 @@ export class WKPage implements PageDelegate { this._setSession(session); await Promise.all([ this._initializePageProxySession(), - this._initializeSession(session, false, ({frameTree}) => this._handleFrameTree(frameTree)), + this._initializeSession(session, false, ({ frameTree }) => this._handleFrameTree(frameTree)), ]); pageOrError = this._page; } catch (e) { @@ -552,7 +552,7 @@ export class WKPage implements PageDelegate { columnNumber: (columnNumber || 1) - 1, } }; - this._onConsoleRepeatCountUpdated({ count: 1}); + this._onConsoleRepeatCountUpdated({ count: 1 }); } _onConsoleRepeatCountUpdated(event: Protocol.Console.messageRepeatCountUpdatedPayload) { @@ -983,7 +983,7 @@ export class WKPage implements PageDelegate { _onRequestIntercepted(session: WKSession, event: Protocol.Network.requestInterceptedPayload) { const request = this._requestIdToRequest.get(event.requestId); if (!request) { - session.sendMayFail('Network.interceptRequestWithError', {errorType: 'Cancellation', requestId: event.requestId}); + session.sendMayFail('Network.interceptRequestWithError', { errorType: 'Cancellation', requestId: event.requestId }); return; } if (!request._route) { diff --git a/src/server/webkit/wkProvisionalPage.ts b/src/server/webkit/wkProvisionalPage.ts index 31e79ee0dd..cccb8080ed 100644 --- a/src/server/webkit/wkProvisionalPage.ts +++ b/src/server/webkit/wkProvisionalPage.ts @@ -50,7 +50,7 @@ export class WKProvisionalPage { eventsHelper.addEventListener(session, 'Network.loadingFailed', overrideFrameId(e => wkPage._onLoadingFailed(e))), ]; - this.initializationPromise = this._wkPage._initializeSession(session, true, ({frameTree}) => this._handleFrameTree(frameTree)); + this.initializationPromise = this._wkPage._initializeSession(session, true, ({ frameTree }) => this._handleFrameTree(frameTree)); } dispose() { diff --git a/src/test/dispatcher.ts b/src/test/dispatcher.ts index 648e74b8bb..7f5a2260a9 100644 --- a/src/test/dispatcher.ts +++ b/src/test/dispatcher.ts @@ -364,7 +364,7 @@ export class Dispatcher { pair.result.stderr.push(chunk); this._reporter.onStdErr?.(chunk, pair?.test, pair?.result); }); - worker.on('teardownError', ({error}) => { + worker.on('teardownError', ({ error }) => { this._hasWorkerErrors = true; this._reporter.onError?.(error); }); diff --git a/src/test/reporters/base.ts b/src/test/reporters/base.ts index 18e6ce5d0a..e8e8f5fbe6 100644 --- a/src/test/reporters/base.ts +++ b/src/test/reporters/base.ts @@ -285,7 +285,7 @@ function positionInFile(stackLines: string[], file: string): { column: number; l if (!parsed || !parsed.file) continue; if (path.resolve(process.cwd(), parsed.file) === file) - return {column: parsed.column || 0, line: parsed.line || 0}; + return { column: parsed.column || 0, line: parsed.line || 0 }; } } diff --git a/src/test/reporters/junit.ts b/src/test/reporters/junit.ts index 6997091953..aa4875825e 100644 --- a/src/test/reporters/junit.ts +++ b/src/test/reporters/junit.ts @@ -131,7 +131,7 @@ class JUnitReporter implements Reporter { entries.push(entry); if (test.outcome() === 'skipped') { - entry.children.push({ name: 'skipped'}); + entry.children.push({ name: 'skipped' }); return; } diff --git a/src/test/runner.ts b/src/test/runner.ts index a32ecd83e2..bc2c49ac7f 100644 --- a/src/test/runner.ts +++ b/src/test/runner.ts @@ -338,7 +338,7 @@ function filterOnly(suite: Suite) { } function filterByFocusedLine(suite: Suite, focusedTestFileLines: FilePatternFilter[]) { - const testFileLineMatches = (testFileName: string, testLine: number) => focusedTestFileLines.some(({re, line}) => { + const testFileLineMatches = (testFileName: string, testLine: number) => focusedTestFileLines.some(({ re, line }) => { re.lastIndex = 0; return re.test(testFileName) && (line === testLine || line === null); }); diff --git a/src/test/transform.ts b/src/test/transform.ts index c05f4d9588..ba4266c40b 100644 --- a/src/test/transform.ts +++ b/src/test/transform.ts @@ -92,7 +92,7 @@ export function installTransform(): () => void { sourceMaps: 'both', } as babel.TransformOptions)!; if (result.code) { - fs.mkdirSync(path.dirname(cachePath), {recursive: true}); + fs.mkdirSync(path.dirname(cachePath), { recursive: true }); if (result.map) fs.writeFileSync(sourceMapPath, JSON.stringify(result.map), 'utf8'); fs.writeFileSync(codePath, result.code, 'utf8'); diff --git a/src/utils/browserFetcher.ts b/src/utils/browserFetcher.ts index 254f5d486f..441c971bb5 100644 --- a/src/utils/browserFetcher.ts +++ b/src/utils/browserFetcher.ts @@ -55,7 +55,7 @@ export async function downloadBrowserWithProgressBar(title: string, browserDirec try { for (let attempt = 1, N = 3; attempt <= N; ++attempt) { debugLogger.log('install', `downloading ${progressBarName} - attempt #${attempt}`); - const {error} = await downloadFile(url, zipPath, {progressCallback: progress, log: debugLogger.log.bind(debugLogger, 'install')}); + const { error } = await downloadFile(url, zipPath, { progressCallback: progress, log: debugLogger.log.bind(debugLogger, 'install') }); if (!error) { debugLogger.log('install', `SUCCESS downloading ${progressBarName}`); break; @@ -74,7 +74,7 @@ export async function downloadBrowserWithProgressBar(title: string, browserDirec debugLogger.log('install', `extracting archive`); debugLogger.log('install', `-- zip: ${zipPath}`); debugLogger.log('install', `-- location: ${browserDirectory}`); - await extract(zipPath, { dir: browserDirectory}); + await extract(zipPath, { dir: browserDirectory }); debugLogger.log('install', `fixing permissions at ${executablePath}`); await fs.promises.chmod(executablePath, 0o755); } catch (e) { diff --git a/src/utils/dependencies.ts b/src/utils/dependencies.ts index 1d9a5e67b1..0eaa7b091b 100644 --- a/src/utils/dependencies.ts +++ b/src/utils/dependencies.ts @@ -39,7 +39,7 @@ export type DependencyGroup = 'chromium' | 'firefox' | 'webkit' | 'tools'; export async function installDependenciesWindows(targets: Set) { if (targets.has('chromium')) { - const {code} = await utils.spawnAsync('powershell.exe', [path.join(BIN_DIRECTORY, 'install_media_pack.ps1')], { cwd: BIN_DIRECTORY, stdio: 'inherit' }); + const { code } = await utils.spawnAsync('powershell.exe', [path.join(BIN_DIRECTORY, 'install_media_pack.ps1')], { cwd: BIN_DIRECTORY, stdio: 'inherit' }); if (code !== 0) throw new Error('Failed to install windows dependencies!'); } @@ -255,7 +255,7 @@ async function executablesOrSharedLibraries(directoryPath: string): Promise> { const executable = path.join(__dirname, '..', '..', 'bin', 'PrintDeps.exe'); const dirname = path.dirname(filePath); - const {stdout, code} = await utils.spawnAsync(executable, [filePath], { + const { stdout, code } = await utils.spawnAsync(executable, [filePath], { cwd: dirname, env: { ...process.env, @@ -273,7 +273,7 @@ async function missingFileDependencies(filePath: string, extraLDPaths: string[]) let LD_LIBRARY_PATH = extraLDPaths.join(':'); if (process.env.LD_LIBRARY_PATH) LD_LIBRARY_PATH = `${process.env.LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}`; - const {stdout, code} = await utils.spawnAsync('ldd', [filePath], { + const { stdout, code } = await utils.spawnAsync('ldd', [filePath], { cwd: dirname, env: { ...process.env, @@ -292,7 +292,7 @@ async function missingDLOPENLibraries(libraries: string[]): Promise { // NOTE: Using full-qualified path to `ldconfig` since `/sbin` is not part of the // default PATH in CRON. // @see https://github.com/microsoft/playwright/issues/3397 - const {stdout, code, error} = await utils.spawnAsync('/sbin/ldconfig', ['-p'], {}); + const { stdout, code, error } = await utils.spawnAsync('/sbin/ldconfig', ['-p'], {}); if (code !== 0 || error) return []; const isLibraryAvailable = (library: string) => stdout.toLowerCase().includes(library.toLowerCase()); diff --git a/src/utils/registry.ts b/src/utils/registry.ts index bd9b0346af..cd8f83a928 100644 --- a/src/utils/registry.ts +++ b/src/utils/registry.ts @@ -615,8 +615,8 @@ export class Registry { }[channel]; const product = products.find((product: any) => product.Product === productName); const searchConfig = ({ - darwin: {platform: 'MacOS', arch: 'universal', artifact: 'pkg'}, - win32: {platform: 'Windows', arch: os.arch() === 'x64' ? 'x64' : 'x86', artifact: 'msi'}, + darwin: { platform: 'MacOS', arch: 'universal', artifact: 'pkg' }, + win32: { platform: 'Windows', arch: os.arch() === 'x64' ? 'x64' : 'x86', artifact: 'msi' }, } as any)[process.platform]; const release = searchConfig ? product.Releases.find((release: any) => release.Platform === searchConfig.platform && release.Architecture === searchConfig.arch) : null; const artifact = release ? release.Artifacts.find((artifact: any) => artifact.ArtifactName === searchConfig.artifact) : null; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 2e5ecfc1c4..9fae9a87ed 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -123,7 +123,7 @@ export function downloadFile(url: string, destinationPath: string, options: {pro log(`running download:`); log(`-- from url: ${url}`); log(`-- to location: ${destinationPath}`); - let fulfill: ({error}: {error: any}) => void = ({error}) => {}; + let fulfill: ({ error }: {error: any}) => void = ({ error }) => {}; let downloadedBytes = 0; let totalBytes = 0; @@ -135,18 +135,18 @@ export function downloadFile(url: string, destinationPath: string, options: {pro const error = new Error(`Download failed: server returned code ${response.statusCode}. URL: ${url}`); // consume response data to free up memory response.resume(); - fulfill({error}); + fulfill({ error }); return; } const file = fs.createWriteStream(destinationPath); - file.on('finish', () => fulfill({error: null})); - file.on('error', error => fulfill({error})); + file.on('finish', () => fulfill({ error: null })); + file.on('error', error => fulfill({ error })); response.pipe(file); totalBytes = parseInt(response.headers['content-length'] || '0', 10); log(`-- total bytes: ${totalBytes}`); if (progressCallback) response.on('data', onData); - }, (error: any) => fulfill({error})); + }, (error: any) => fulfill({ error })); return promise; function onData(chunk: string) { @@ -165,8 +165,8 @@ export function spawnAsync(cmd: string, args: string[], options?: SpawnOptions): process.stdout.on('data', data => stdout += data); if (process.stderr) process.stderr.on('data', data => stderr += data); - process.on('close', code => resolve({stdout, stderr, code})); - process.on('error', error => resolve({stdout, stderr, code: 0, error})); + process.on('close', code => resolve({ stdout, stderr, code })); + process.on('error', error => resolve({ stdout, stderr, code: 0, error })); }); } @@ -265,7 +265,7 @@ export function getAsBooleanFromENV(name: string): boolean { export async function mkdirIfNeeded(filePath: string) { // This will harmlessly throw on windows if the dirname is the root directory. - await fs.promises.mkdir(path.dirname(filePath), {recursive: true}).catch(() => {}); + await fs.promises.mkdir(path.dirname(filePath), { recursive: true }).catch(() => {}); } type HeadersArray = { name: string, value: string }[]; @@ -326,7 +326,7 @@ export function arrayToObject(array?: NameValue[]): { [key: string]: string } | if (!array) return undefined; const result: { [key: string]: string } = {}; - for (const {name, value} of array) + for (const { name, value } of array) result[name] = value; return result; } diff --git a/src/web/components/expandable.tsx b/src/web/components/expandable.tsx index 2d67adb661..8aa3a34069 100644 --- a/src/web/components/expandable.tsx +++ b/src/web/components/expandable.tsx @@ -27,7 +27,7 @@ export const Expandable: React.FunctionComponent<{
setExpanded(!expanded)} /> {title}
diff --git a/src/web/components/splitView.tsx b/src/web/components/splitView.tsx index 14ef771599..3600cfe65c 100644 --- a/src/web/components/splitView.tsx +++ b/src/web/components/splitView.tsx @@ -53,7 +53,7 @@ export const SplitView: React.FC = ({ return
{childrenArray[0]}
- { !sidebarHidden &&
{childrenArray[1]}
} + { !sidebarHidden &&
{childrenArray[1]}
} { !sidebarHidden &&
= ({ stats }) => { - return
+ return
{!!stats.expected &&
{stats.expected}
} {!!stats.unexpected &&
{stats.unexpected}
} {!!stats.flaky &&
{stats.flaky}
} diff --git a/src/web/recorder/callLog.tsx b/src/web/recorder/callLog.tsx index defd914210..5c7afed250 100644 --- a/src/web/recorder/callLog.tsx +++ b/src/web/recorder/callLog.tsx @@ -32,7 +32,7 @@ export const CallLogView: React.FC = ({ if (log.find(callLog => callLog.reveal)) messagesEndRef.current?.scrollIntoView({ block: 'center', inline: 'nearest' }); }, [messagesEndRef, log]); - return
+ return
{log.map(callLog => { const expandOverride = expandOverrides.get(callLog.id); const isExpanded = typeof expandOverride === 'boolean' ? expandOverride : callLog.status !== 'done'; diff --git a/src/web/recorder/recorder.tsx b/src/web/recorder/recorder.tsx index dd404f5b07..c7868d4ce5 100644 --- a/src/web/recorder/recorder.tsx +++ b/src/web/recorder/recorder.tsx @@ -81,7 +81,7 @@ export const Recorder: React.FC = ({ return
{ - window.dispatch({ event: 'setMode', params: { mode: mode === 'recording' ? 'none' : 'recording' }}); + window.dispatch({ event: 'setMode', params: { mode: mode === 'recording' ? 'none' : 'recording' } }); }}>Record { copy(source.text); @@ -95,7 +95,7 @@ export const Recorder: React.FC = ({ { window.dispatch({ event: 'step' }); }}> -
+
Target:
{ setSelector(event.target.value); diff --git a/tests/android/browser.spec.ts b/tests/android/browser.spec.ts index 2b2fbe78d8..11e6317c91 100644 --- a/tests/android/browser.spec.ts +++ b/tests/android/browser.spec.ts @@ -52,6 +52,6 @@ test('should be able to send CDP messages', async ({ androidDevice }) => { const [page] = context.pages(); const client = await context.newCDPSession(page); await client.send('Runtime.enable'); - const evalResponse = await client.send('Runtime.evaluate', {expression: '1 + 2', returnByValue: true}); + const evalResponse = await client.send('Runtime.evaluate', { expression: '1 + 2', returnByValue: true }); expect(evalResponse.result.value).toBe(3); }); diff --git a/tests/android/device.spec.ts b/tests/android/device.spec.ts index 242a9896d5..13265c6e3b 100644 --- a/tests/android/device.spec.ts +++ b/tests/android/device.spec.ts @@ -38,7 +38,7 @@ test('androidDevice.screenshot', async function({ androidDevice }, testInfo) { const result = await androidDevice.screenshot({ path }); const buffer = fs.readFileSync(path); expect(result.length).toBe(buffer.length); - const { width, height} = PNG.sync.read(result); + const { width, height } = PNG.sync.read(result); expect(width).toBe(1080); expect(height).toBe(1920); }); diff --git a/tests/beforeunload.spec.ts b/tests/beforeunload.spec.ts index fe75d1f907..cf98a14995 100644 --- a/tests/beforeunload.spec.ts +++ b/tests/beforeunload.spec.ts @@ -17,7 +17,7 @@ import { contextTest as it, expect } from './config/browserTest'; -it('should close browser with beforeunload page', async ({server, browserType, browserOptions }) => { +it('should close browser with beforeunload page', async ({ server, browserType, browserOptions }) => { const browser = await browserType.launch(browserOptions); const page = await browser.newPage(); await page.goto(server.PREFIX + '/beforeunload.html'); @@ -27,7 +27,7 @@ it('should close browser with beforeunload page', async ({server, browserType, b await browser.close(); }); -it('should close browsercontext with beforeunload page', async ({server, page, context }) => { +it('should close browsercontext with beforeunload page', async ({ server, page, context }) => { await page.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers // fire. @@ -35,7 +35,7 @@ it('should close browsercontext with beforeunload page', async ({server, page, c await context.close(); }); -it('should be able to navigate away from page with beforeunload', async ({server, page, context }) => { +it('should be able to navigate away from page with beforeunload', async ({ server, page, context }) => { await page.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers // fire. @@ -43,7 +43,7 @@ it('should be able to navigate away from page with beforeunload', async ({server await page.goto(server.EMPTY_PAGE); }); -it('should close page with beforeunload listener', async ({context, server}) => { +it('should close page with beforeunload listener', async ({ context, server }) => { const newPage = await context.newPage(); await newPage.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers @@ -52,7 +52,7 @@ it('should close page with beforeunload listener', async ({context, server}) => await newPage.close(); }); -it('should run beforeunload if asked for', async ({context, server, browserName}) => { +it('should run beforeunload if asked for', async ({ context, server, browserName }) => { const newPage = await context.newPage(); await newPage.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers @@ -76,7 +76,7 @@ it('should run beforeunload if asked for', async ({context, server, browserName} ]); }); -it('should access page after beforeunload', async ({page, server}) => { +it('should access page after beforeunload', async ({ page, server }) => { await page.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers // fire. diff --git a/tests/browser.spec.ts b/tests/browser.spec.ts index 6149dd8bfc..3e3f6cc0a7 100644 --- a/tests/browser.spec.ts +++ b/tests/browser.spec.ts @@ -16,7 +16,7 @@ import { browserTest as test, expect } from './config/browserTest'; -test('should create new page', async function({browser}) { +test('should create new page', async function({ browser }) { const page1 = await browser.newPage(); expect(browser.contexts().length).toBe(1); @@ -30,7 +30,7 @@ test('should create new page', async function({browser}) { expect(browser.contexts().length).toBe(0); }); -test('should throw upon second create new page', async function({browser}) { +test('should throw upon second create new page', async function({ browser }) { const page = await browser.newPage(); let error; await page.context().newPage().catch(e => error = e); @@ -38,7 +38,7 @@ test('should throw upon second create new page', async function({browser}) { expect(error.message).toContain('Please use browser.newContext()'); }); -test('version should work', async function({browser, browserName}) { +test('version should work', async function({ browser, browserName }) { const version = browser.version(); if (browserName === 'chromium') expect(version.match(/^\d+\.\d+\.\d+\.\d+$/)).toBeTruthy(); diff --git a/tests/browsercontext-add-cookies.spec.ts b/tests/browsercontext-add-cookies.spec.ts index c6ed9eeccc..6b66485bb6 100644 --- a/tests/browsercontext-add-cookies.spec.ts +++ b/tests/browsercontext-add-cookies.spec.ts @@ -17,7 +17,7 @@ import { contextTest as it, playwrightTest, expect } from './config/browserTest'; -it('should work', async ({context, page, server}) => { +it('should work', async ({ context, page, server }) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: server.EMPTY_PAGE, @@ -27,7 +27,7 @@ it('should work', async ({context, page, server}) => { expect(await page.evaluate(() => document.cookie)).toEqual('password=123456'); }); -it('should work with expires=-1', async ({context, page}) => { +it('should work with expires=-1', async ({ context, page }) => { await context.addCookies([{ name: 'username', value: 'John Doe', @@ -45,7 +45,7 @@ it('should work with expires=-1', async ({context, page}) => { expect(await page.evaluate(() => document.cookie)).toEqual('username=John Doe'); }); -it('should roundtrip cookie', async ({context, page, server}) => { +it('should roundtrip cookie', async ({ context, page, server }) => { await page.goto(server.EMPTY_PAGE); // @see https://en.wikipedia.org/wiki/Year_2038_problem const date = +(new Date('1/1/2038')); @@ -62,22 +62,22 @@ it('should roundtrip cookie', async ({context, page, server}) => { expect(await context.cookies()).toEqual(cookies); }); -it('should send cookie header', async ({server, context}) => { +it('should send cookie header', async ({ server, context }) => { let cookie = ''; server.setRoute('/empty.html', (req, res) => { cookie = req.headers.cookie; res.end(); }); - await context.addCookies([{url: server.EMPTY_PAGE, name: 'cookie', value: 'value'}]); + await context.addCookies([{ url: server.EMPTY_PAGE, name: 'cookie', value: 'value' }]); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); expect(cookie).toBe('cookie=value'); }); -it('should isolate cookies in browser contexts', async ({context, server, browser}) => { +it('should isolate cookies in browser contexts', async ({ context, server, browser }) => { const anotherContext = await browser.newContext(); - await context.addCookies([{url: server.EMPTY_PAGE, name: 'isolatecookie', value: 'page1value'}]); - await anotherContext.addCookies([{url: server.EMPTY_PAGE, name: 'isolatecookie', value: 'page2value'}]); + await context.addCookies([{ url: server.EMPTY_PAGE, name: 'isolatecookie', value: 'page1value' }]); + await anotherContext.addCookies([{ url: server.EMPTY_PAGE, name: 'isolatecookie', value: 'page2value' }]); const cookies1 = await context.cookies(); const cookies2 = await anotherContext.cookies(); @@ -90,7 +90,7 @@ it('should isolate cookies in browser contexts', async ({context, server, browse await anotherContext.close(); }); -it('should isolate session cookies', async ({context, server, browser}) => { +it('should isolate session cookies', async ({ context, server, browser }) => { server.setRoute('/setcookie.html', (req, res) => { res.setHeader('Set-Cookie', 'session=value'); res.end(); @@ -116,7 +116,7 @@ it('should isolate session cookies', async ({context, server, browser}) => { } }); -it('should isolate persistent cookies', async ({context, server, browser}) => { +it('should isolate persistent cookies', async ({ context, server, browser }) => { server.setRoute('/setcookie.html', (req, res) => { res.setHeader('Set-Cookie', 'persistent=persistent-value; max-age=3600'); res.end(); @@ -136,13 +136,13 @@ it('should isolate persistent cookies', async ({context, server, browser}) => { await context2.close(); }); -it('should isolate send cookie header', async ({server, context, browser}) => { +it('should isolate send cookie header', async ({ server, context, browser }) => { let cookie = ''; server.setRoute('/empty.html', (req, res) => { cookie = req.headers.cookie || ''; res.end(); }); - await context.addCookies([{url: server.EMPTY_PAGE, name: 'sendcookie', value: 'value'}]); + await context.addCookies([{ url: server.EMPTY_PAGE, name: 'sendcookie', value: 'value' }]); { const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -157,12 +157,12 @@ it('should isolate send cookie header', async ({server, context, browser}) => { } }); -playwrightTest('should isolate cookies between launches', async ({browserType, server, browserOptions}) => { +playwrightTest('should isolate cookies between launches', async ({ browserType, server, browserOptions }) => { playwrightTest.slow(); const browser1 = await browserType.launch(browserOptions); const context1 = await browser1.newContext(); - await context1.addCookies([{url: server.EMPTY_PAGE, name: 'cookie-in-context-1', value: 'value', expires: Date.now() / 1000 + 10000}]); + await context1.addCookies([{ url: server.EMPTY_PAGE, name: 'cookie-in-context-1', value: 'value', expires: Date.now() / 1000 + 10000 }]); await browser1.close(); const browser2 = await browserType.launch(browserOptions); @@ -172,7 +172,7 @@ playwrightTest('should isolate cookies between launches', async ({browserType, s await browser2.close(); }); -it('should set multiple cookies', async ({context, page, server}) => { +it('should set multiple cookies', async ({ context, page, server }) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: server.EMPTY_PAGE, @@ -192,7 +192,7 @@ it('should set multiple cookies', async ({context, page, server}) => { ]); }); -it('should have |expires| set to |-1| for session cookies', async ({context, server}) => { +it('should have |expires| set to |-1| for session cookies', async ({ context, server }) => { await context.addCookies([{ url: server.EMPTY_PAGE, name: 'expires', @@ -202,7 +202,7 @@ it('should have |expires| set to |-1| for session cookies', async ({context, ser expect(cookies[0].expires).toBe(-1); }); -it('should set cookie with reasonable defaults', async ({context, server, browserName}) => { +it('should set cookie with reasonable defaults', async ({ context, server, browserName }) => { await context.addCookies([{ url: server.EMPTY_PAGE, name: 'defaults', @@ -221,7 +221,7 @@ it('should set cookie with reasonable defaults', async ({context, server, browse }]); }); -it('should set a cookie with a path', async ({context, page, server, browserName, isWindows}) => { +it('should set a cookie with a path', async ({ context, page, server, browserName, isWindows }) => { await page.goto(server.PREFIX + '/grid.html'); await context.addCookies([{ domain: 'localhost', @@ -247,12 +247,12 @@ it('should set a cookie with a path', async ({context, page, server, browserName expect(await page.evaluate('document.cookie')).toBe('gridcookie=GRID'); }); -it('should not set a cookie with blank page URL', async function({context, server}) { +it('should not set a cookie with blank page URL', async function({ context, server }) { let error = null; try { await context.addCookies([ - {url: server.EMPTY_PAGE, name: 'example-cookie', value: 'best'}, - {url: 'about:blank', name: 'example-cookie-blank', value: 'best'} + { url: server.EMPTY_PAGE, name: 'example-cookie', value: 'best' }, + { url: 'about:blank', name: 'example-cookie-blank', value: 'best' } ]); } catch (e) { error = e; @@ -262,17 +262,17 @@ it('should not set a cookie with blank page URL', async function({context, serve ); }); -it('should not set a cookie on a data URL page', async function({context}) { +it('should not set a cookie on a data URL page', async function({ context }) { let error = null; try { - await context.addCookies([{url: 'data:,Hello%2C%20World!', name: 'example-cookie', value: 'best'}]); + await context.addCookies([{ url: 'data:,Hello%2C%20World!', name: 'example-cookie', value: 'best' }]); } catch (e) { error = e; } expect(error.message).toContain('Data URL page can not have cookie "example-cookie"'); }); -it('should default to setting secure cookie for HTTPS websites', async ({context, page, server}) => { +it('should default to setting secure cookie for HTTPS websites', async ({ context, page, server }) => { await page.goto(server.EMPTY_PAGE); const SECURE_URL = 'https://example.com'; await context.addCookies([{ @@ -284,7 +284,7 @@ it('should default to setting secure cookie for HTTPS websites', async ({context expect(cookie.secure).toBe(true); }); -it('should be able to set unsecure cookie for HTTP website', async ({context, page, server}) => { +it('should be able to set unsecure cookie for HTTP website', async ({ context, page, server }) => { await page.goto(server.EMPTY_PAGE); const HTTP_URL = 'http://example.com'; await context.addCookies([{ @@ -296,7 +296,7 @@ it('should be able to set unsecure cookie for HTTP website', async ({context, pa expect(cookie.secure).toBe(false); }); -it('should set a cookie on a different domain', async ({context, page, server, browserName, isWindows}) => { +it('should set a cookie on a different domain', async ({ context, page, server, browserName, isWindows }) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: 'https://www.example.com', @@ -317,10 +317,10 @@ it('should set a cookie on a different domain', async ({context, page, server, b }]); }); -it('should set cookies for a frame', async ({context, page, server}) => { +it('should set cookies for a frame', async ({ context, page, server }) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([ - {url: server.PREFIX, name: 'frame-cookie', value: 'value'} + { url: server.PREFIX, name: 'frame-cookie', value: 'value' } ]); await page.evaluate(src => { let fulfill; @@ -335,7 +335,7 @@ it('should set cookies for a frame', async ({context, page, server}) => { expect(await page.frames()[1].evaluate('document.cookie')).toBe('frame-cookie=value'); }); -it('should(not) block third party cookies', async ({context, page, server, browserName}) => { +it('should(not) block third party cookies', async ({ context, page, server, browserName }) => { await page.goto(server.EMPTY_PAGE); await page.evaluate(src => { let fulfill; diff --git a/tests/browsercontext-base-url.spec.ts b/tests/browsercontext-base-url.spec.ts index cb283c3c3d..639776442c 100644 --- a/tests/browsercontext-base-url.spec.ts +++ b/tests/browsercontext-base-url.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should construct a new URL when a baseURL in browser.newContext is passed to page.goto', async function({browser, server}) { +it('should construct a new URL when a baseURL in browser.newContext is passed to page.goto', async function({ browser, server }) { const context = await browser.newContext({ baseURL: server.PREFIX, }); @@ -26,7 +26,7 @@ it('should construct a new URL when a baseURL in browser.newContext is passed to await context.close(); }); -it('should construct a new URL when a baseURL in browser.newPage is passed to page.goto', async function({browser, server}) { +it('should construct a new URL when a baseURL in browser.newPage is passed to page.goto', async function({ browser, server }) { const page = await browser.newPage({ baseURL: server.PREFIX, }); @@ -34,7 +34,7 @@ it('should construct a new URL when a baseURL in browser.newPage is passed to pa await page.close(); }); -it('should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto', async function({browserType, server, createUserDataDir, browserOptions}) { +it('should construct a new URL when a baseURL in browserType.launchPersistentContext is passed to page.goto', async function({ browserType, server, createUserDataDir, browserOptions }) { const userDataDir = await createUserDataDir(); const context = await browserType.launchPersistentContext(userDataDir, { ...browserOptions, @@ -45,7 +45,7 @@ it('should construct a new URL when a baseURL in browserType.launchPersistentCon await context.close(); }); -it('should construct the URLs correctly when a baseURL without a trailing slash in browser.newPage is passed to page.goto', async function({browser, server}) { +it('should construct the URLs correctly when a baseURL without a trailing slash in browser.newPage is passed to page.goto', async function({ browser, server }) { const page = await browser.newPage({ baseURL: server.PREFIX + '/url-construction', }); @@ -55,7 +55,7 @@ it('should construct the URLs correctly when a baseURL without a trailing slash await page.close(); }); -it('should construct the URLs correctly when a baseURL with a trailing slash in browser.newPage is passed to page.goto', async function({browser, server}) { +it('should construct the URLs correctly when a baseURL with a trailing slash in browser.newPage is passed to page.goto', async function({ browser, server }) { const page = await browser.newPage({ baseURL: server.PREFIX + '/url-construction/', }); @@ -67,7 +67,7 @@ it('should construct the URLs correctly when a baseURL with a trailing slash in await page.close(); }); -it('should not construct a new URL when valid URLs are passed', async function({browser, server}) { +it('should not construct a new URL when valid URLs are passed', async function({ browser, server }) { const page = await browser.newPage({ baseURL: 'http://microsoft.com', }); @@ -81,7 +81,7 @@ it('should not construct a new URL when valid URLs are passed', async function({ await page.close(); }); -it('should be able to match a URL relative to its given URL with urlMatcher', async function({browser, server}) { +it('should be able to match a URL relative to its given URL with urlMatcher', async function({ browser, server }) { const page = await browser.newPage({ baseURL: server.PREFIX + '/foobar/', }); @@ -103,7 +103,7 @@ it('should be able to match a URL relative to its given URL with urlMatcher', as await page.close(); }); -it('should not construct a new URL with baseURL when a glob was used', async function({browser, server}) { +it('should not construct a new URL with baseURL when a glob was used', async function({ browser, server }) { const page = await browser.newPage({ baseURL: server.PREFIX + '/foobar/', }); diff --git a/tests/browsercontext-basic.spec.ts b/tests/browsercontext-basic.spec.ts index baf963c975..d4dd082c2c 100644 --- a/tests/browsercontext-basic.spec.ts +++ b/tests/browsercontext-basic.spec.ts @@ -18,7 +18,7 @@ import { browserTest as it, expect } from './config/browserTest'; import { attachFrame, verifyViewport } from './config/utils'; -it('should create new context', async function({browser}) { +it('should create new context', async function({ browser }) { expect(browser.contexts().length).toBe(0); const context = await browser.newContext(); expect(browser.contexts().length).toBe(1); @@ -29,7 +29,7 @@ it('should create new context', async function({browser}) { expect(browser).toBe(context.browser()); }); -it('window.open should use parent tab context', async function({browser, server}) { +it('window.open should use parent tab context', async function({ browser, server }) { const context = await browser.newContext(); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -41,7 +41,7 @@ it('window.open should use parent tab context', async function({browser, server} await context.close(); }); -it('should isolate localStorage and cookies', async function({browser, server}) { +it('should isolate localStorage and cookies', async function({ browser, server }) { // Create two incognito contexts. const context1 = await browser.newContext(); const context2 = await browser.newContext(); @@ -132,7 +132,7 @@ it('close() should abort waitForEvent', async ({ browser }) => { expect(error.message).toContain('Context closed'); }); -it('close() should be callable twice', async ({browser}) => { +it('close() should be callable twice', async ({ browser }) => { const context = await browser.newContext(); await Promise.all([ context.close(), @@ -141,7 +141,7 @@ it('close() should be callable twice', async ({browser}) => { await context.close(); }); -it('should pass self to close event', async ({browser}) => { +it('should pass self to close event', async ({ browser }) => { const newContext = await browser.newContext(); const [closedContext] = await Promise.all([ newContext.waitForEvent('close'), @@ -150,7 +150,7 @@ it('should pass self to close event', async ({browser}) => { expect(closedContext).toBe(newContext); }); -it('should not report frameless pages on error', async ({browser, server}) => { +it('should not report frameless pages on error', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); server.setRoute('/empty.html', (req, res) => { @@ -168,7 +168,7 @@ it('should not report frameless pages on error', async ({browser, server}) => { } }); -it('should return all of the pages', async ({browser, server}) => { +it('should return all of the pages', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); const second = await context.newPage(); @@ -179,7 +179,7 @@ it('should return all of the pages', async ({browser, server}) => { await context.close(); }); -it('should close all belonging pages once closing context', async function({browser}) { +it('should close all belonging pages once closing context', async function({ browser }) { const context = await browser.newContext(); await context.newPage(); expect(context.pages().length).toBe(1); @@ -188,7 +188,7 @@ it('should close all belonging pages once closing context', async function({brow expect(context.pages().length).toBe(0); }); -it('should disable javascript', async ({browser, browserName}) => { +it('should disable javascript', async ({ browser, browserName }) => { { const context = await browser.newContext({ javaScriptEnabled: false }); const page = await context.newPage(); @@ -211,15 +211,15 @@ it('should disable javascript', async ({browser, browserName}) => { } }); -it('should be able to navigate after disabling javascript', async ({browser, server}) => { +it('should be able to navigate after disabling javascript', async ({ browser, server }) => { const context = await browser.newContext({ javaScriptEnabled: false }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); await context.close(); }); -it('should work with offline option', async ({browser, server}) => { - const context = await browser.newContext({offline: true}); +it('should work with offline option', async ({ browser, server }) => { + const context = await browser.newContext({ offline: true }); const page = await context.newPage(); let error = null; await page.goto(server.EMPTY_PAGE).catch(e => error = e); @@ -230,7 +230,7 @@ it('should work with offline option', async ({browser, server}) => { await context.close(); }); -it('should emulate navigator.onLine', async ({browser, server}) => { +it('should emulate navigator.onLine', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); expect(await page.evaluate(() => window.navigator.onLine)).toBe(true); @@ -241,7 +241,7 @@ it('should emulate navigator.onLine', async ({browser, server}) => { await context.close(); }); -it('should emulate media in popup', async ({browser, server}) => { +it('should emulate media in popup', async ({ browser, server }) => { { const context = await browser.newContext({ colorScheme: 'dark' }); const page = await context.newPage(); @@ -267,7 +267,7 @@ it('should emulate media in popup', async ({browser, server}) => { } }); -it('should emulate media in cross-process iframe', async ({browser, server}) => { +it('should emulate media in cross-process iframe', async ({ browser, server }) => { const page = await browser.newPage({ colorScheme: 'dark' }); await page.goto(server.EMPTY_PAGE); await attachFrame(page, 'frame1', server.CROSS_PROCESS_PREFIX + '/empty.html'); diff --git a/tests/browsercontext-clearcookies.spec.ts b/tests/browsercontext-clearcookies.spec.ts index 78427795c6..85ebec5bb3 100644 --- a/tests/browsercontext-clearcookies.spec.ts +++ b/tests/browsercontext-clearcookies.spec.ts @@ -17,7 +17,7 @@ import { contextTest as it, expect } from './config/browserTest'; -it('should clear cookies', async ({context, page, server}) => { +it('should clear cookies', async ({ context, page, server }) => { await page.goto(server.EMPTY_PAGE); await context.addCookies([{ url: server.EMPTY_PAGE, @@ -31,10 +31,10 @@ it('should clear cookies', async ({context, page, server}) => { expect(await page.evaluate('document.cookie')).toBe(''); }); -it('should isolate cookies when clearing', async ({context, server, browser}) => { +it('should isolate cookies when clearing', async ({ context, server, browser }) => { const anotherContext = await browser.newContext(); - await context.addCookies([{url: server.EMPTY_PAGE, name: 'page1cookie', value: 'page1value'}]); - await anotherContext.addCookies([{url: server.EMPTY_PAGE, name: 'page2cookie', value: 'page2value'}]); + await context.addCookies([{ url: server.EMPTY_PAGE, name: 'page1cookie', value: 'page1value' }]); + await anotherContext.addCookies([{ url: server.EMPTY_PAGE, name: 'page2cookie', value: 'page2value' }]); expect((await context.cookies()).length).toBe(1); expect((await anotherContext.cookies()).length).toBe(1); diff --git a/tests/browsercontext-cookies.spec.ts b/tests/browsercontext-cookies.spec.ts index 522ad3573d..adc0329acc 100644 --- a/tests/browsercontext-cookies.spec.ts +++ b/tests/browsercontext-cookies.spec.ts @@ -17,11 +17,11 @@ import { contextTest as it, expect } from './config/browserTest'; -it('should return no cookies in pristine browser context', async ({context, page, server}) => { +it('should return no cookies in pristine browser context', async ({ context, page, server }) => { expect(await context.cookies()).toEqual([]); }); -it('should get a cookie', async ({context, page, server, browserName}) => { +it('should get a cookie', async ({ context, page, server, browserName }) => { await page.goto(server.EMPTY_PAGE); const documentCookie = await page.evaluate(() => { document.cookie = 'username=John Doe'; @@ -40,7 +40,7 @@ it('should get a cookie', async ({context, page, server, browserName}) => { }]); }); -it('should get a non-session cookie', async ({context, page, server, browserName}) => { +it('should get a non-session cookie', async ({ context, page, server, browserName }) => { await page.goto(server.EMPTY_PAGE); // @see https://en.wikipedia.org/wiki/Year_2038_problem const date = +(new Date('1/1/2038')); @@ -62,7 +62,7 @@ it('should get a non-session cookie', async ({context, page, server, browserName }]); }); -it('should properly report httpOnly cookie', async ({context, page, server}) => { +it('should properly report httpOnly cookie', async ({ context, page, server }) => { server.setRoute('/empty.html', (req, res) => { res.setHeader('Set-Cookie', 'name=value;HttpOnly; Path=/'); res.end(); @@ -73,7 +73,7 @@ it('should properly report httpOnly cookie', async ({context, page, server}) => expect(cookies[0].httpOnly).toBe(true); }); -it('should properly report "Strict" sameSite cookie', async ({context, page, server, browserName, platform}) => { +it('should properly report "Strict" sameSite cookie', async ({ context, page, server, browserName, platform }) => { it.fail(browserName === 'webkit' && platform === 'win32'); server.setRoute('/empty.html', (req, res) => { @@ -86,7 +86,7 @@ it('should properly report "Strict" sameSite cookie', async ({context, page, ser expect(cookies[0].sameSite).toBe('Strict'); }); -it('should properly report "Lax" sameSite cookie', async ({context, page, server, browserName, platform}) => { +it('should properly report "Lax" sameSite cookie', async ({ context, page, server, browserName, platform }) => { it.fail(browserName === 'webkit' && platform === 'win32'); server.setRoute('/empty.html', (req, res) => { @@ -99,7 +99,7 @@ it('should properly report "Lax" sameSite cookie', async ({context, page, server expect(cookies[0].sameSite).toBe('Lax'); }); -it('should get multiple cookies', async ({context, page, server, browserName}) => { +it('should get multiple cookies', async ({ context, page, server, browserName }) => { await page.goto(server.EMPTY_PAGE); const documentCookie = await page.evaluate(() => { document.cookie = 'username=John Doe'; @@ -132,7 +132,7 @@ it('should get multiple cookies', async ({context, page, server, browserName}) = ])); }); -it('should get cookies from multiple urls', async ({context, browserName, isWindows}) => { +it('should get cookies from multiple urls', async ({ context, browserName, isWindows }) => { await context.addCookies([{ url: 'https://foo.com', name: 'doggo', @@ -171,7 +171,7 @@ it('should get cookies from multiple urls', async ({context, browserName, isWind }])); }); -it('should work with subdomain cookie', async ({context, browserName, isWindows}) => { +it('should work with subdomain cookie', async ({ context, browserName, isWindows }) => { await context.addCookies([{ domain: '.foo.com', path: '/', @@ -202,7 +202,7 @@ it('should work with subdomain cookie', async ({context, browserName, isWindows} }]); }); -it('should not return cookies with empty value', async ({context, page, server}) => { +it('should not return cookies with empty value', async ({ context, page, server }) => { server.setRoute('/empty.html', (req, res) => { res.setHeader('Set-Cookie', 'name=;Path=/'); res.end(); @@ -212,7 +212,7 @@ it('should not return cookies with empty value', async ({context, page, server}) expect(cookies.length).toBe(0); }); -it('should return secure cookies based on HTTP(S) protocol', async ({context, browserName, isWindows}) => { +it('should return secure cookies based on HTTP(S) protocol', async ({ context, browserName, isWindows }) => { await context.addCookies([{ url: 'https://foo.com', name: 'doggo', diff --git a/tests/browsercontext-credentials.spec.ts b/tests/browsercontext-credentials.spec.ts index 5cc890f39c..6d4ad9af1b 100644 --- a/tests/browsercontext-credentials.spec.ts +++ b/tests/browsercontext-credentials.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should fail without credentials', async ({browser, server, browserName, headless}) => { +it('should fail without credentials', async ({ browser, server, browserName, headless }) => { it.fail(browserName === 'chromium' && !headless); server.setAuth('/empty.html', 'user', 'pass'); @@ -28,7 +28,7 @@ it('should fail without credentials', async ({browser, server, browserName, head await context.close(); }); -it('should work with setHTTPCredentials', async ({browser, server, browserName, headless}) => { +it('should work with setHTTPCredentials', async ({ browser, server, browserName, headless }) => { it.fail(browserName === 'chromium' && !headless); server.setAuth('/empty.html', 'user', 'pass'); @@ -42,7 +42,7 @@ it('should work with setHTTPCredentials', async ({browser, server, browserName, await context.close(); }); -it('should work with correct credentials', async ({browser, server}) => { +it('should work with correct credentials', async ({ browser, server }) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext({ httpCredentials: { username: 'user', password: 'pass' } @@ -53,7 +53,7 @@ it('should work with correct credentials', async ({browser, server}) => { await context.close(); }); -it('should fail with wrong credentials', async ({browser, server}) => { +it('should fail with wrong credentials', async ({ browser, server }) => { server.setAuth('/empty.html', 'user', 'pass'); const context = await browser.newContext({ httpCredentials: { username: 'foo', password: 'bar' } @@ -64,7 +64,7 @@ it('should fail with wrong credentials', async ({browser, server}) => { await context.close(); }); -it('should return resource body', async ({browser, server}) => { +it('should return resource body', async ({ browser, server }) => { server.setAuth('/playground.html', 'user', 'pass'); const context = await browser.newContext({ httpCredentials: { username: 'user', password: 'pass' } diff --git a/tests/browsercontext-csp.spec.ts b/tests/browsercontext-csp.spec.ts index 1118637137..5a82325f8b 100644 --- a/tests/browsercontext-csp.spec.ts +++ b/tests/browsercontext-csp.spec.ts @@ -18,13 +18,13 @@ import { browserTest as it, expect } from './config/browserTest'; import { attachFrame } from './config/utils'; -it('should bypass CSP meta tag', async ({browser, server}) => { +it('should bypass CSP meta tag', async ({ browser, server }) => { // Make sure CSP prohibits addScriptTag. { const context = await browser.newContext(); const page = await context.newPage(); await page.goto(server.PREFIX + '/csp.html'); - await page.addScriptTag({content: 'window["__injected"] = 42;'}).catch(e => void e); + await page.addScriptTag({ content: 'window["__injected"] = 42;' }).catch(e => void e); expect(await page.evaluate('window["__injected"]')).toBe(undefined); await context.close(); } @@ -34,13 +34,13 @@ it('should bypass CSP meta tag', async ({browser, server}) => { const context = await browser.newContext({ bypassCSP: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/csp.html'); - await page.addScriptTag({content: 'window["__injected"] = 42;'}); + await page.addScriptTag({ content: 'window["__injected"] = 42;' }); expect(await page.evaluate('window["__injected"]')).toBe(42); await context.close(); } }); -it('should bypass CSP header', async ({browser, server}) => { +it('should bypass CSP header', async ({ browser, server }) => { // Make sure CSP prohibits addScriptTag. server.setCSP('/empty.html', 'default-src "self"'); @@ -48,7 +48,7 @@ it('should bypass CSP header', async ({browser, server}) => { const context = await browser.newContext(); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); - await page.addScriptTag({content: 'window["__injected"] = 42;'}).catch(e => void e); + await page.addScriptTag({ content: 'window["__injected"] = 42;' }).catch(e => void e); expect(await page.evaluate('window["__injected"]')).toBe(undefined); await context.close(); } @@ -58,33 +58,33 @@ it('should bypass CSP header', async ({browser, server}) => { const context = await browser.newContext({ bypassCSP: true }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); - await page.addScriptTag({content: 'window["__injected"] = 42;'}); + await page.addScriptTag({ content: 'window["__injected"] = 42;' }); expect(await page.evaluate('window["__injected"]')).toBe(42); await context.close(); } }); -it('should bypass after cross-process navigation', async ({browser, server}) => { +it('should bypass after cross-process navigation', async ({ browser, server }) => { const context = await browser.newContext({ bypassCSP: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/csp.html'); - await page.addScriptTag({content: 'window["__injected"] = 42;'}); + await page.addScriptTag({ content: 'window["__injected"] = 42;' }); expect(await page.evaluate('window["__injected"]')).toBe(42); await page.goto(server.CROSS_PROCESS_PREFIX + '/csp.html'); - await page.addScriptTag({content: 'window["__injected"] = 42;'}); + await page.addScriptTag({ content: 'window["__injected"] = 42;' }); expect(await page.evaluate('window["__injected"]')).toBe(42); await context.close(); }); -it('should bypass CSP in iframes as well', async ({browser, server}) => { +it('should bypass CSP in iframes as well', async ({ browser, server }) => { // Make sure CSP prohibits addScriptTag in an iframe. { const context = await browser.newContext(); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); const frame = await attachFrame(page, 'frame1', server.PREFIX + '/csp.html'); - await frame.addScriptTag({content: 'window["__injected"] = 42;'}).catch(e => void e); + await frame.addScriptTag({ content: 'window["__injected"] = 42;' }).catch(e => void e); expect(await frame.evaluate('window["__injected"]')).toBe(undefined); await context.close(); } @@ -95,7 +95,7 @@ it('should bypass CSP in iframes as well', async ({browser, server}) => { const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); const frame = await attachFrame(page, 'frame1', server.PREFIX + '/csp.html'); - await frame.addScriptTag({content: 'window["__injected"] = 42;'}).catch(e => void e); + await frame.addScriptTag({ content: 'window["__injected"] = 42;' }).catch(e => void e); expect(await frame.evaluate('window["__injected"]')).toBe(42); await context.close(); } diff --git a/tests/browsercontext-device.spec.ts b/tests/browsercontext-device.spec.ts index 610e90d80e..9804db41ca 100644 --- a/tests/browsercontext-device.spec.ts +++ b/tests/browsercontext-device.spec.ts @@ -20,7 +20,7 @@ import { browserTest as it, expect } from './config/browserTest'; it.describe('device', () => { it.skip(({ browserName }) => browserName === 'firefox'); - it('should work', async ({playwright, browser, server}) => { + it('should work', async ({ playwright, browser, server }) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -30,7 +30,7 @@ it.describe('device', () => { await context.close(); }); - it('should support clicking', async ({playwright, browser, server}) => { + it('should support clicking', async ({ playwright, browser, server }) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -42,7 +42,7 @@ it.describe('device', () => { await context.close(); }); - it('should scroll to click', async ({browser, server, contextOptions}) => { + it('should scroll to click', async ({ browser, server, contextOptions }) => { const context = await browser.newContext({ ...contextOptions, viewport: { @@ -60,7 +60,7 @@ it.describe('device', () => { await context.close(); }); - it('should scroll twice when emulated', async ({server, contextFactory, playwright}) => { + it('should scroll twice when emulated', async ({ server, contextFactory, playwright }) => { const device = playwright.devices['iPhone 6']; const context = await contextFactory(device); const page = await context.newPage(); @@ -78,7 +78,7 @@ it.describe('device', () => { await context.close(); }); - it('should reset scroll top after a navigation', async ({server, contextFactory, playwright, browserName}) => { + it('should reset scroll top after a navigation', async ({ server, contextFactory, playwright, browserName }) => { it.skip(browserName === 'webkit'); const device = playwright.devices['iPhone 6']; @@ -92,7 +92,7 @@ it.describe('device', () => { await context.close(); }); - it('should scroll to a precise position with mobile scale', async ({server, contextFactory, playwright, browserName}) => { + it('should scroll to a precise position with mobile scale', async ({ server, contextFactory, playwright, browserName }) => { it.skip(browserName === 'webkit'); const device = playwright.devices['iPhone 6']; @@ -105,7 +105,7 @@ it.describe('device', () => { await context.close(); }); - it('should emulate viewport and screen size', async ({server, contextFactory, playwright}) => { + it('should emulate viewport and screen size', async ({ server, contextFactory, playwright }) => { const device = playwright.devices['iPhone 12']; const context = await contextFactory(device); const page = await context.newPage(); @@ -124,7 +124,7 @@ it.describe('device', () => { await context.close(); }); - it('should emulate viewport without screen size', async ({server, contextFactory, playwright}) => { + it('should emulate viewport without screen size', async ({ server, contextFactory, playwright }) => { const device = playwright.devices['iPhone 6']; const context = await contextFactory(device); const page = await context.newPage(); diff --git a/tests/browsercontext-dsf.spec.ts b/tests/browsercontext-dsf.spec.ts index 2e123b71ac..4417c87a7c 100644 --- a/tests/browsercontext-dsf.spec.ts +++ b/tests/browsercontext-dsf.spec.ts @@ -16,7 +16,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should fetch lodpi assets', async ({ contextFactory, server}) => { +it('should fetch lodpi assets', async ({ contextFactory, server }) => { const context = await contextFactory({ deviceScaleFactor: 1 }); diff --git a/tests/browsercontext-expose-function.spec.ts b/tests/browsercontext-expose-function.spec.ts index bf2e2fc80e..1848f3bed8 100644 --- a/tests/browsercontext-expose-function.spec.ts +++ b/tests/browsercontext-expose-function.spec.ts @@ -17,7 +17,7 @@ import { contextTest as it, expect } from './config/browserTest'; -it('expose binding should work', async ({context}) => { +it('expose binding should work', async ({ context }) => { let bindingSource; await context.exposeBinding('add', (source, a, b) => { bindingSource = source; @@ -31,7 +31,7 @@ it('expose binding should work', async ({context}) => { expect(result).toEqual(11); }); -it('should work', async ({context, server}) => { +it('should work', async ({ context, server }) => { await context.exposeFunction('add', (a, b) => a + b); const page = await context.newPage(); await page.exposeFunction('mul', (a, b) => a * b); @@ -44,7 +44,7 @@ it('should work', async ({context, server}) => { expect(result).toEqual({ mul: 36, add: 13, sub: 5, addHandle: 11 }); }); -it('should throw for duplicate registrations', async ({context, server}) => { +it('should throw for duplicate registrations', async ({ context, server }) => { await context.exposeFunction('foo', () => {}); await context.exposeFunction('bar', () => {}); let error = await context.exposeFunction('foo', () => {}).catch(e => e); @@ -57,7 +57,7 @@ it('should throw for duplicate registrations', async ({context, server}) => { expect(error.message).toContain('Function "baz" has been already registered in one of the pages'); }); -it('should be callable from-inside addInitScript', async ({context, server}) => { +it('should be callable from-inside addInitScript', async ({ context, server }) => { let args = []; await context.exposeFunction('woof', function(arg) { args.push(arg); @@ -72,7 +72,7 @@ it('should be callable from-inside addInitScript', async ({context, server}) => expect(args).toEqual(['context', 'page']); }); -it('exposeBindingHandle should work', async ({context}) => { +it('exposeBindingHandle should work', async ({ context }) => { let target; await context.exposeBinding('logme', (source, t) => { target = t; diff --git a/tests/browsercontext-fetch.spec.ts b/tests/browsercontext-fetch.spec.ts index edabf0a462..beb6f32d54 100644 --- a/tests/browsercontext-fetch.spec.ts +++ b/tests/browsercontext-fetch.spec.ts @@ -42,7 +42,7 @@ it.afterAll(() => { http.globalAgent = prevAgent; }); -it('get should work', async ({context, server}) => { +it('get should work', async ({ context, server }) => { const response = await context._request.get(server.PREFIX + '/simple.json'); expect(response.url()).toBe(server.PREFIX + '/simple.json'); expect(response.status()).toBe(200); @@ -54,7 +54,7 @@ it('get should work', async ({context, server}) => { expect(await response.text()).toBe('{"foo": "bar"}\n'); }); -it('fetch should work', async ({context, server}) => { +it('fetch should work', async ({ context, server }) => { const response = await context._request.fetch(server.PREFIX + '/simple.json'); expect(response.url()).toBe(server.PREFIX + '/simple.json'); expect(response.status()).toBe(200); @@ -66,7 +66,7 @@ it('fetch should work', async ({context, server}) => { expect(await response.text()).toBe('{"foo": "bar"}\n'); }); -it('should throw on network error', async ({context, server}) => { +it('should throw on network error', async ({ context, server }) => { server.setRoute('/test', (req, res) => { req.socket.destroy(); }); @@ -74,7 +74,7 @@ it('should throw on network error', async ({context, server}) => { expect(error.message).toContain('socket hang up'); }); -it('should throw on network error after redirect', async ({context, server}) => { +it('should throw on network error after redirect', async ({ context, server }) => { server.setRedirect('/redirect', '/test'); server.setRoute('/test', (req, res) => { req.socket.destroy(); @@ -83,7 +83,7 @@ it('should throw on network error after redirect', async ({context, server}) => expect(error.message).toContain('socket hang up'); }); -it('should throw on network error when sending body', async ({context, server}) => { +it('should throw on network error when sending body', async ({ context, server }) => { server.setRoute('/test', (req, res) => { res.writeHead(200, { 'content-length': 4096, @@ -97,7 +97,7 @@ it('should throw on network error when sending body', async ({context, server}) expect(error.message).toContain('Error: aborted'); }); -it('should throw on network error when sending body after redirect', async ({context, server}) => { +it('should throw on network error when sending body after redirect', async ({ context, server }) => { server.setRedirect('/redirect', '/test'); server.setRoute('/test', (req, res) => { res.writeHead(200, { @@ -112,7 +112,7 @@ it('should throw on network error when sending body after redirect', async ({con expect(error.message).toContain('Error: aborted'); }); -it('should add session cookies to request', async ({context, server}) => { +it('should add session cookies to request', async ({ context, server }) => { await context.addCookies([{ name: 'username', value: 'John Doe', @@ -131,7 +131,7 @@ it('should add session cookies to request', async ({context, server}) => { }); for (const method of ['get', 'post', 'fetch']) { - it(`${method} should support queryParams`, async ({context, server}) => { + it(`${method} should support queryParams`, async ({ context, server }) => { let request; const url = new URL(server.EMPTY_PAGE); url.searchParams.set('p1', 'v1'); @@ -151,7 +151,7 @@ for (const method of ['get', 'post', 'fetch']) { expect(params.get('парам2')).toEqual('знач2'); }); - it(`${method} should support failOnStatusCode`, async ({context, server}) => { + it(`${method} should support failOnStatusCode`, async ({ context, server }) => { const error = await context._request[method](server.PREFIX + '/does-not-exist.html', { failOnStatusCode: true }).catch(e => e); @@ -159,7 +159,7 @@ for (const method of ['get', 'post', 'fetch']) { }); } -it('should not add context cookie if cookie header passed as a parameter', async ({context, server}) => { +it('should not add context cookie if cookie header passed as a parameter', async ({ context, server }) => { await context.addCookies([{ name: 'username', value: 'John Doe', @@ -181,7 +181,7 @@ it('should not add context cookie if cookie header passed as a parameter', async expect(req.headers.cookie).toEqual('foo=bar'); }); -it('should follow redirects', async ({context, server}) => { +it('should follow redirects', async ({ context, server }) => { server.setRedirect('/redirect1', '/redirect2'); server.setRedirect('/redirect2', '/simple.json'); await context.addCookies([{ @@ -200,10 +200,10 @@ it('should follow redirects', async ({context, server}) => { ]); expect(req.headers.cookie).toEqual('username=John Doe'); expect(response.url()).toBe(`http://www.my.playwright.dev:${server.PORT}/simple.json`); - expect(await response.json()).toEqual({foo: 'bar'}); + expect(await response.json()).toEqual({ foo: 'bar' }); }); -it('should add cookies from Set-Cookie header', async ({context, page, server}) => { +it('should add cookies from Set-Cookie header', async ({ context, page, server }) => { server.setRoute('/setcookie.html', (req, res) => { res.setHeader('Set-Cookie', ['session=value', 'foo=bar; max-age=3600']); res.end(); @@ -224,7 +224,7 @@ it('should add cookies from Set-Cookie header', async ({context, page, server}) expect((await page.evaluate(() => document.cookie)).split(';').map(s => s.trim()).sort()).toEqual(['foo=bar', 'session=value']); }); -it('should not lose body while handling Set-Cookie header', async ({context, server}) => { +it('should not lose body while handling Set-Cookie header', async ({ context, server }) => { server.setRoute('/setcookie.html', (req, res) => { res.setHeader('Set-Cookie', ['session=value', 'foo=bar; max-age=3600']); res.end('text content'); @@ -233,7 +233,7 @@ it('should not lose body while handling Set-Cookie header', async ({context, ser expect(await response.text()).toBe('text content'); }); -it('should handle cookies on redirects', async ({context, server, browserName, isWindows}) => { +it('should handle cookies on redirects', async ({ context, server, browserName, isWindows }) => { server.setRoute('/redirect1', (req, res) => { res.setHeader('Set-Cookie', 'r1=v1;SameSite=Lax'); res.writeHead(301, { location: '/a/b/redirect2' }); @@ -291,7 +291,7 @@ it('should handle cookies on redirects', async ({context, server, browserName, i ])); }); -it('should return raw headers', async ({context, page, server}) => { +it('should return raw headers', async ({ context, page, server }) => { server.setRoute('/headers', (req, res) => { // Headers array is only supported since Node v14.14.0 so we write directly to the socket. // res.writeHead(200, ['name-a', 'v1','name-b', 'v4','Name-a', 'v2', 'name-A', 'v3']); @@ -314,7 +314,7 @@ it('should return raw headers', async ({context, page, server}) => { expect(response.headers()['name-b']).toBe('v4'); }); -it('should work with context level proxy', async ({browserOptions, browserType, contextOptions, server, proxyServer}) => { +it('should work with context level proxy', async ({ browserOptions, browserType, contextOptions, server, proxyServer }) => { server.setRoute('/target.html', async (req, res) => { res.end('Served by the proxy'); }); @@ -342,7 +342,7 @@ it('should work with context level proxy', async ({browserOptions, browserType, } }); -it('should pass proxy credentials', async ({browserType, browserOptions, server, proxyServer}) => { +it('should pass proxy credentials', async ({ browserType, browserOptions, server, proxyServer }) => { proxyServer.forwardTo(server.PORT); let auth; proxyServer.setAuthHandler(req => { @@ -357,11 +357,11 @@ it('should pass proxy credentials', async ({browserType, browserOptions, server, const response = await context._request.get('http://non-existent.com/simple.json'); expect(proxyServer.connectHosts).toContain('non-existent.com:80'); expect(auth).toBe('Basic ' + Buffer.from('user:secret').toString('base64')); - expect(await response.json()).toEqual({foo: 'bar'}); + expect(await response.json()).toEqual({ foo: 'bar' }); await browser.close(); }); -it('should work with http credentials', async ({context, server}) => { +it('should work with http credentials', async ({ context, server }) => { server.setAuth('/empty.html', 'user', 'pass'); const [request, response] = await Promise.all([ @@ -376,7 +376,7 @@ it('should work with http credentials', async ({context, server}) => { expect(request.url).toBe('/empty.html'); }); -it('should work with setHTTPCredentials', async ({context, server}) => { +it('should work with setHTTPCredentials', async ({ context, server }) => { server.setAuth('/empty.html', 'user', 'pass'); const response1 = await context._request.get(server.EMPTY_PAGE); expect(response1.status()).toBe(401); @@ -386,14 +386,14 @@ it('should work with setHTTPCredentials', async ({context, server}) => { expect(response2.status()).toBe(200); }); -it('should return error with wrong credentials', async ({context, server}) => { +it('should return error with wrong credentials', async ({ context, server }) => { server.setAuth('/empty.html', 'user', 'pass'); await context.setHTTPCredentials({ username: 'user', password: 'wrong' }); const response2 = await context._request.get(server.EMPTY_PAGE); expect(response2.status()).toBe(401); }); -it('should support post data', async ({context, server}) => { +it('should support post data', async ({ context, server }) => { const [request, response] = await Promise.all([ server.waitForRequest('/simple.json'), context._request.post(`${server.PREFIX}/simple.json`, { @@ -406,7 +406,7 @@ it('should support post data', async ({context, server}) => { expect(request.url).toBe('/simple.json'); }); -it('should add default headers', async ({context, server, page}) => { +it('should add default headers', async ({ context, server, page }) => { const [request] = await Promise.all([ server.waitForRequest('/empty.html'), context._request.get(server.EMPTY_PAGE) @@ -417,7 +417,7 @@ it('should add default headers', async ({context, server, page}) => { expect(request.headers['accept-encoding']).toBe('gzip,deflate,br'); }); -it('should send content-length', async function({context, asset, server}) { +it('should send content-length', async function({ context, asset, server }) { const bytes = []; for (let i = 0; i < 256; i++) bytes.push(i); @@ -431,7 +431,7 @@ it('should send content-length', async function({context, asset, server}) { expect(request.headers['content-type']).toBe('application/octet-stream'); }); -it('should add default headers to redirects', async ({context, server, page}) => { +it('should add default headers to redirects', async ({ context, server, page }) => { server.setRedirect('/redirect', '/empty.html'); const [request] = await Promise.all([ server.waitForRequest('/empty.html'), @@ -443,7 +443,7 @@ it('should add default headers to redirects', async ({context, server, page}) => expect(request.headers['accept-encoding']).toBe('gzip,deflate,br'); }); -it('should allow to override default headers', async ({context, server, page}) => { +it('should allow to override default headers', async ({ context, server, page }) => { const [request] = await Promise.all([ server.waitForRequest('/empty.html'), context._request.get(server.EMPTY_PAGE, { @@ -459,21 +459,21 @@ it('should allow to override default headers', async ({context, server, page}) = expect(request.headers['accept-encoding']).toBe('br'); }); -it('should propagate custom headers with redirects', async ({context, server}) => { +it('should propagate custom headers with redirects', async ({ context, server }) => { server.setRedirect('/a/redirect1', '/b/c/redirect2'); server.setRedirect('/b/c/redirect2', '/simple.json'); const [req1, req2, req3] = await Promise.all([ server.waitForRequest('/a/redirect1'), server.waitForRequest('/b/c/redirect2'), server.waitForRequest('/simple.json'), - context._request.get(`${server.PREFIX}/a/redirect1`, {headers: {'foo': 'bar'}}), + context._request.get(`${server.PREFIX}/a/redirect1`, { headers: { 'foo': 'bar' } }), ]); expect(req1.headers['foo']).toBe('bar'); expect(req2.headers['foo']).toBe('bar'); expect(req3.headers['foo']).toBe('bar'); }); -it('should propagate extra http headers with redirects', async ({context, server}) => { +it('should propagate extra http headers with redirects', async ({ context, server }) => { server.setRedirect('/a/redirect1', '/b/c/redirect2'); server.setRedirect('/b/c/redirect2', '/simple.json'); await context.setExtraHTTPHeaders({ 'My-Secret': 'Value' }); @@ -488,7 +488,7 @@ it('should propagate extra http headers with redirects', async ({context, server expect(req3.headers['my-secret']).toBe('Value'); }); -it('should throw on invalid header value', async ({context, server}) => { +it('should throw on invalid header value', async ({ context, server }) => { const error = await context._request.get(`${server.PREFIX}/a/redirect1`, { headers: { 'foo': 'недопустимое значение', @@ -497,14 +497,14 @@ it('should throw on invalid header value', async ({context, server}) => { expect(error.message).toContain('Invalid character in header content'); }); -it('should throw on non-http(s) protocol', async ({context}) => { +it('should throw on non-http(s) protocol', async ({ context }) => { const error1 = await context._request.get(`data:text/plain,test`).catch(e => e); expect(error1.message).toContain('Protocol "data:" not supported'); const error2 = await context._request.get(`file:///tmp/foo`).catch(e => e); expect(error2.message).toContain('Protocol "file:" not supported'); }); -it('should support https', async ({context, httpsServer}) => { +it('should support https', async ({ context, httpsServer }) => { const oldValue = process.env['NODE_TLS_REJECT_UNAUTHORIZED']; // https://stackoverflow.com/a/21961005/552185 process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'; @@ -517,13 +517,13 @@ it('should support https', async ({context, httpsServer}) => { } }); -it('should support ignoreHTTPSErrors', async ({contextFactory, contextOptions, httpsServer}) => { +it('should support ignoreHTTPSErrors', async ({ contextFactory, contextOptions, httpsServer }) => { const context = await contextFactory({ ...contextOptions, ignoreHTTPSErrors: true }); const response = await context._request.get(httpsServer.EMPTY_PAGE); expect(response.status()).toBe(200); }); -it('should resolve url relative to baseURL', async function({server, contextFactory, contextOptions}) { +it('should resolve url relative to baseURL', async function({ server, contextFactory, contextOptions }) { const context = await contextFactory({ ...contextOptions, baseURL: server.PREFIX, @@ -532,7 +532,7 @@ it('should resolve url relative to baseURL', async function({server, contextFact expect(response.url()).toBe(server.EMPTY_PAGE); }); -it('should support gzip compression', async function({context, server}) { +it('should support gzip compression', async function({ context, server }) { server.setRoute('/compressed', (req, res) => { res.writeHead(200, { 'Content-Encoding': 'gzip', @@ -552,7 +552,7 @@ it('should support gzip compression', async function({context, server}) { expect(await response.text()).toBe('Hello, world!'); }); -it('should throw informatibe error on corrupted gzip body', async function({context, server}) { +it('should throw informatibe error on corrupted gzip body', async function({ context, server }) { server.setRoute('/corrupted', (req, res) => { res.writeHead(200, { 'Content-Encoding': 'gzip', @@ -566,7 +566,7 @@ it('should throw informatibe error on corrupted gzip body', async function({cont expect(error.message).toContain(`failed to decompress 'gzip' encoding`); }); -it('should support brotli compression', async function({context, server}) { +it('should support brotli compression', async function({ context, server }) { server.setRoute('/compressed', (req, res) => { res.writeHead(200, { 'Content-Encoding': 'br', @@ -586,7 +586,7 @@ it('should support brotli compression', async function({context, server}) { expect(await response.text()).toBe('Hello, world!'); }); -it('should throw informatibe error on corrupted brotli body', async function({context, server}) { +it('should throw informatibe error on corrupted brotli body', async function({ context, server }) { server.setRoute('/corrupted', (req, res) => { res.writeHead(200, { 'Content-Encoding': 'br', @@ -600,7 +600,7 @@ it('should throw informatibe error on corrupted brotli body', async function({co expect(error.message).toContain(`failed to decompress 'br' encoding`); }); -it('should support deflate compression', async function({context, server}) { +it('should support deflate compression', async function({ context, server }) { server.setRoute('/compressed', (req, res) => { res.writeHead(200, { 'Content-Encoding': 'deflate', @@ -620,7 +620,7 @@ it('should support deflate compression', async function({context, server}) { expect(await response.text()).toBe('Hello, world!'); }); -it('should throw informatibe error on corrupted deflate body', async function({context, server}) { +it('should throw informatibe error on corrupted deflate body', async function({ context, server }) { server.setRoute('/corrupted', (req, res) => { res.writeHead(200, { 'Content-Encoding': 'deflate', @@ -634,7 +634,7 @@ it('should throw informatibe error on corrupted deflate body', async function({c expect(error.message).toContain(`failed to decompress 'deflate' encoding`); }); -it('should support timeout option', async function({context, server}) { +it('should support timeout option', async function({ context, server }) { server.setRoute('/slow', (req, res) => { res.writeHead(200, { 'content-length': 4096, @@ -646,7 +646,7 @@ it('should support timeout option', async function({context, server}) { expect(error.message).toContain(`Request timed out after 10ms`); }); -it('should support a timeout of 0', async function({context, server}) { +it('should support a timeout of 0', async function({ context, server }) { server.setRoute('/slow', (req, res) => { res.writeHead(200, { 'content-length': 4, @@ -663,7 +663,7 @@ it('should support a timeout of 0', async function({context, server}) { expect(await response.text()).toBe('done'); }); -it('should respect timeout after redirects', async function({context, server}) { +it('should respect timeout after redirects', async function({ context, server }) { server.setRedirect('/redirect', '/slow'); server.setRoute('/slow', (req, res) => { res.writeHead(200, { @@ -677,7 +677,7 @@ it('should respect timeout after redirects', async function({context, server}) { expect(error.message).toContain(`Request timed out after 100ms`); }); -it('should dispose', async function({context, server}) { +it('should dispose', async function({ context, server }) { const response = await context._request.get(server.PREFIX + '/simple.json'); expect(await response.json()).toEqual({ foo: 'bar' }); await response.dispose(); @@ -685,7 +685,7 @@ it('should dispose', async function({context, server}) { expect(error.message).toContain('Response has been disposed'); }); -it('should dispose when context closes', async function({context, server}) { +it('should dispose when context closes', async function({ context, server }) { const response = await context._request.get(server.PREFIX + '/simple.json'); expect(await response.json()).toEqual({ foo: 'bar' }); await context.close(); @@ -693,12 +693,12 @@ it('should dispose when context closes', async function({context, server}) { expect(error.message).toContain('Response has been disposed'); }); -it('should throw on invalid first argument', async function({context}) { +it('should throw on invalid first argument', async function({ context }) { const error = await context._request.get({} as any).catch(e => e); expect(error.message).toContain('First argument must be either URL string or Request'); }); -it('should override request parameters', async function({context, page, server}) { +it('should override request parameters', async function({ context, page, server }) { const [pageReq] = await Promise.all([ page.waitForRequest('**/*'), page.goto(server.EMPTY_PAGE) @@ -717,7 +717,7 @@ it('should override request parameters', async function({context, page, server}) expect((await req.postBody).toString('utf8')).toBe('data'); }); -it('should support application/x-www-form-urlencoded', async function({context, page, server}) { +it('should support application/x-www-form-urlencoded', async function({ context, page, server }) { const [req] = await Promise.all([ server.waitForRequest('/empty.html'), context._request.post(server.EMPTY_PAGE, { @@ -741,7 +741,7 @@ it('should support application/x-www-form-urlencoded', async function({context, expect(params.get('file')).toBe('f.js'); }); -it('should encode to application/json by default', async function({context, page, server}) { +it('should encode to application/json by default', async function({ context, page, server }) { const data = { firstName: 'John', lastName: 'Doe', @@ -760,13 +760,13 @@ it('should encode to application/json by default', async function({context, page expect(json).toEqual(data); }); -it('should support multipart/form-data', async function({context, page, server}) { +it('should support multipart/form-data', async function({ context, page, server }) { const formReceived = new Promise(resolve => { server.setRoute('/empty.html', async (serverRequest, res) => { const form = new formidable.IncomingForm(); form.parse(serverRequest, (error, fields, files) => { server.serveFile(serverRequest, res); - resolve({error, fields, files, serverRequest }); + resolve({ error, fields, files, serverRequest }); }); }); }); @@ -776,7 +776,7 @@ it('should support multipart/form-data', async function({context, page, server}) mimeType: 'text/javascript', buffer: Buffer.from('var x = 10;\r\n;console.log(x);') }; - const [{error, fields, files, serverRequest}, response] = await Promise.all([ + const [{ error, fields, files, serverRequest }, response] = await Promise.all([ formReceived, context._request.post(server.EMPTY_PAGE, { headers: { @@ -800,18 +800,18 @@ it('should support multipart/form-data', async function({context, page, server}) expect(response.status()).toBe(200); }); -it('should support multipart/form-data with ReadSream values', async function({context, page, asset, server}) { +it('should support multipart/form-data with ReadSream values', async function({ context, page, asset, server }) { const formReceived = new Promise(resolve => { server.setRoute('/empty.html', async (serverRequest, res) => { const form = new formidable.IncomingForm(); form.parse(serverRequest, (error, fields, files) => { server.serveFile(serverRequest, res); - resolve({error, fields, files, serverRequest }); + resolve({ error, fields, files, serverRequest }); }); }); }); const readStream = fs.createReadStream(asset('simplezip.json')); - const [{error, fields, files, serverRequest}, response] = await Promise.all([ + const [{ error, fields, files, serverRequest }, response] = await Promise.all([ formReceived, context._request.post(server.EMPTY_PAGE, { headers: { @@ -836,7 +836,7 @@ it('should support multipart/form-data with ReadSream values', async function({c expect(response.status()).toBe(200); }); -it('should throw nice error on unsupported encoding', async function({context, server}) { +it('should throw nice error on unsupported encoding', async function({ context, server }) { const error = await context._request.post(server.EMPTY_PAGE, { headers: { 'content-type': 'unknown' @@ -849,7 +849,7 @@ it('should throw nice error on unsupported encoding', async function({context, s expect(error.message).toContain('Cannot serialize data using content type: unknown'); }); -it('should throw nice error on unsupported data type', async function({context, server}) { +it('should throw nice error on unsupported data type', async function({ context, server }) { const error = await context._request.post(server.EMPTY_PAGE, { headers: { 'content-type': 'application/json' @@ -859,7 +859,7 @@ it('should throw nice error on unsupported data type', async function({context, expect(error.message).toContain(`Unexpected 'data' type`); }); -it('should throw when data passed for unsupported request', async function({context, server}) { +it('should throw when data passed for unsupported request', async function({ context, server }) { const error = await context._request.fetch(server.EMPTY_PAGE, { method: 'GET', headers: { diff --git a/tests/browsercontext-locale.spec.ts b/tests/browsercontext-locale.spec.ts index 6ba4048b21..5a92b80dcb 100644 --- a/tests/browsercontext-locale.spec.ts +++ b/tests/browsercontext-locale.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should affect accept-language header', async ({browser, server}) => { +it('should affect accept-language header', async ({ browser, server }) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); const [request] = await Promise.all([ @@ -28,14 +28,14 @@ it('should affect accept-language header', async ({browser, server}) => { await context.close(); }); -it('should affect navigator.language', async ({browser, server}) => { +it('should affect navigator.language', async ({ browser, server }) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); expect(await page.evaluate(() => navigator.language)).toBe('fr-CH'); await context.close(); }); -it('should format number', async ({browser, server}) => { +it('should format number', async ({ browser, server }) => { { const context = await browser.newContext({ locale: 'en-US' }); const page = await context.newPage(); @@ -52,7 +52,7 @@ it('should format number', async ({browser, server}) => { } }); -it('should format date', async ({browser, server, browserName}) => { +it('should format date', async ({ browser, server, browserName }) => { { const context = await browser.newContext({ locale: 'en-US', timezoneId: 'America/Los_Angeles' }); const page = await context.newPage(); @@ -71,7 +71,7 @@ it('should format date', async ({browser, server, browserName}) => { } }); -it('should format number in popups', async ({browser, server}) => { +it('should format number in popups', async ({ browser, server }) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -86,7 +86,7 @@ it('should format number in popups', async ({browser, server}) => { await context.close(); }); -it('should affect navigator.language in popups', async ({browser, server}) => { +it('should affect navigator.language in popups', async ({ browser, server }) => { const context = await browser.newContext({ locale: 'fr-CH' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -100,7 +100,7 @@ it('should affect navigator.language in popups', async ({browser, server}) => { await context.close(); }); -it('should work for multiple pages sharing same process', async ({browser, server}) => { +it('should work for multiple pages sharing same process', async ({ browser, server }) => { const context = await browser.newContext({ locale: 'ru-RU' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -115,7 +115,7 @@ it('should work for multiple pages sharing same process', async ({browser, serve await context.close(); }); -it('should be isolated between contexts', async ({browser, server}) => { +it('should be isolated between contexts', async ({ browser, server }) => { const context1 = await browser.newContext({ locale: 'en-US' }); const promises = []; // By default firefox limits number of child web processes to 8. @@ -138,7 +138,7 @@ it('should be isolated between contexts', async ({browser, server}) => { ]); }); -it('should not change default locale in another context', async ({browser, server}) => { +it('should not change default locale in another context', async ({ browser, server }) => { async function getContextLocale(context) { const page = await context.newPage(); return await page.evaluate(() => (new Intl.NumberFormat()).resolvedOptions().locale); @@ -152,7 +152,7 @@ it('should not change default locale in another context', async ({browser, serve } const localeOverride = defaultLocale === 'ru-RU' ? 'de-DE' : 'ru-RU'; { - const context = await browser.newContext({ locale: localeOverride}); + const context = await browser.newContext({ locale: localeOverride }); expect(await getContextLocale(context)).toBe(localeOverride); await context.close(); } @@ -163,13 +163,13 @@ it('should not change default locale in another context', async ({browser, serve } }); -it('should format number in workers', async ({browser, server}) => { +it('should format number in workers', async ({ browser, server }) => { const context = await browser.newContext({ locale: 'ru-RU' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); const [worker] = await Promise.all([ page.waitForEvent('worker'), - page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))), + page.evaluate(() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], { type: 'application/javascript' })))), ]); expect(await worker.evaluate(() => (10000.20).toLocaleString())).toBe('10\u00A0000,2'); await context.close(); diff --git a/tests/browsercontext-network-event.spec.ts b/tests/browsercontext-network-event.spec.ts index 5bf0517f97..61dd7113c9 100644 --- a/tests/browsercontext-network-event.spec.ts +++ b/tests/browsercontext-network-event.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('BrowserContext.Events.Request', async ({context, server}) => { +it('BrowserContext.Events.Request', async ({ context, server }) => { const page = await context.newPage(); const requests = []; context.on('request', request => requests.push(request)); @@ -36,7 +36,7 @@ it('BrowserContext.Events.Request', async ({context, server}) => { ]); }); -it('BrowserContext.Events.Response', async ({context, server}) => { +it('BrowserContext.Events.Response', async ({ context, server }) => { const page = await context.newPage(); const responses = []; context.on('response', response => responses.push(response)); @@ -55,7 +55,7 @@ it('BrowserContext.Events.Response', async ({context, server}) => { ]); }); -it('BrowserContext.Events.RequestFailed', async ({context, server}) => { +it('BrowserContext.Events.RequestFailed', async ({ context, server }) => { server.setRoute('/one-style.css', (_, res) => { res.setHeader('Content-Type', 'text/css'); res.connection.destroy(); @@ -72,7 +72,7 @@ it('BrowserContext.Events.RequestFailed', async ({context, server}) => { }); -it('BrowserContext.Events.RequestFinished', async ({context, server}) => { +it('BrowserContext.Events.RequestFinished', async ({ context, server }) => { const page = await context.newPage(); const [response] = await Promise.all([ page.goto(server.EMPTY_PAGE), @@ -86,7 +86,7 @@ it('BrowserContext.Events.RequestFinished', async ({context, server}) => { expect(request.failure()).toBe(null); }); -it('should fire events in proper order', async ({context, server}) => { +it('should fire events in proper order', async ({ context, server }) => { const page = await context.newPage(); const events = []; context.on('request', () => events.push('request')); @@ -103,7 +103,7 @@ it('should fire events in proper order', async ({context, server}) => { ]); }); -it('should not fire events for favicon or favicon redirects', async ({context, page, server, browserName, channel, headless}) => { +it('should not fire events for favicon or favicon redirects', async ({ context, page, server, browserName, channel, headless }) => { it.skip(headless && browserName !== 'firefox', 'headless browsers, except firefox, do not request favicons'); it.skip(!headless && browserName === 'webkit' && !channel, 'headed webkit does not have a favicon feature'); const favicon = `/no-cache/favicon.ico`; diff --git a/tests/browsercontext-page-event.spec.ts b/tests/browsercontext-page-event.spec.ts index 9876d1d7dc..18b17727cf 100644 --- a/tests/browsercontext-page-event.spec.ts +++ b/tests/browsercontext-page-event.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should have url', async ({browser, server}) => { +it('should have url', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -28,7 +28,7 @@ it('should have url', async ({browser, server}) => { await context.close(); }); -it('should have url after domcontentloaded', async ({browser, server}) => { +it('should have url after domcontentloaded', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -40,7 +40,7 @@ it('should have url after domcontentloaded', async ({browser, server}) => { await context.close(); }); -it('should have about:blank url with domcontentloaded', async ({browser, server}) => { +it('should have about:blank url with domcontentloaded', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -52,7 +52,7 @@ it('should have about:blank url with domcontentloaded', async ({browser, server} await context.close(); }); -it('should have about:blank for empty url with domcontentloaded', async ({browser, server}) => { +it('should have about:blank for empty url with domcontentloaded', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -64,7 +64,7 @@ it('should have about:blank for empty url with domcontentloaded', async ({browse await context.close(); }); -it('should report when a new page is created and closed', async ({browser, server}) => { +it('should report when a new page is created and closed', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); const [otherPage] = await Promise.all([ @@ -91,7 +91,7 @@ it('should report when a new page is created and closed', async ({browser, serve await context.close(); }); -it('should report initialized pages', async ({browser, server}) => { +it('should report initialized pages', async ({ browser, server }) => { const context = await browser.newContext(); const pagePromise = context.waitForEvent('page'); context.newPage(); @@ -106,7 +106,7 @@ it('should report initialized pages', async ({browser, server}) => { await context.close(); }); -it('should not crash while redirecting of original request was missed', async ({browser, server}) => { +it('should not crash while redirecting of original request was missed', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); let serverResponse = null; @@ -126,7 +126,7 @@ it('should not crash while redirecting of original request was missed', async ({ await context.close(); }); -it('should have an opener', async ({browser, server}) => { +it('should have an opener', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -140,7 +140,7 @@ it('should have an opener', async ({browser, server}) => { await context.close(); }); -it('should fire page lifecycle events', async function({browser, server}) { +it('should fire page lifecycle events', async function({ browser, server }) { const context = await browser.newContext(); const events = []; context.on('page', async page => { @@ -157,7 +157,7 @@ it('should fire page lifecycle events', async function({browser, server}) { await context.close(); }); -it('should work with Shift-clicking', async ({browser, server, browserName}) => { +it('should work with Shift-clicking', async ({ browser, server, browserName }) => { it.fixme(browserName === 'webkit', 'WebKit: Shift+Click does not open a new window.'); const context = await browser.newContext(); @@ -172,7 +172,7 @@ it('should work with Shift-clicking', async ({browser, server, browserName}) => await context.close(); }); -it('should work with Ctrl-clicking', async ({browser, server, isMac, browserName}) => { +it('should work with Ctrl-clicking', async ({ browser, server, isMac, browserName }) => { it.fixme(browserName === 'webkit', 'Ctrl+Click does not open a new tab.'); it.fixme(browserName === 'firefox', 'Reports an opener in this case.'); diff --git a/tests/browsercontext-pages.spec.ts b/tests/browsercontext-pages.spec.ts index 1e1186eaee..e395cc904d 100644 --- a/tests/browsercontext-pages.spec.ts +++ b/tests/browsercontext-pages.spec.ts @@ -18,7 +18,7 @@ import { browserTest as it, expect } from './config/browserTest'; import { attachFrame, chromiumVersionLessThan } from './config/utils'; -it('should not be visible in context.pages', async ({contextFactory}) => { +it('should not be visible in context.pages', async ({ contextFactory }) => { const context = await contextFactory(); const page = await context.newPage(); expect(context.pages()).toContain(page); @@ -26,7 +26,7 @@ it('should not be visible in context.pages', async ({contextFactory}) => { expect(context.pages()).not.toContain(page); }); -it('page.context should return the correct instance', async function({contextFactory}) { +it('page.context should return the correct instance', async function({ contextFactory }) { const context = await contextFactory(); const page = await context.newPage(); expect(page.context()).toBe(context); @@ -43,7 +43,7 @@ it('frame.focus should work multiple times', async ({ contextFactory }) => { } }); -it('should click with disabled javascript', async ({browser, server}) => { +it('should click with disabled javascript', async ({ browser, server }) => { const context = await browser.newContext({ javaScriptEnabled: false }); const page = await context.newPage(); await page.goto(server.PREFIX + '/wrappedlink.html'); @@ -55,7 +55,7 @@ it('should click with disabled javascript', async ({browser, server}) => { await context.close(); }); -it('should not hang with touch-enabled viewports', async ({browser, playwright}) => { +it('should not hang with touch-enabled viewports', async ({ browser, playwright }) => { // @see https://github.com/GoogleChrome/puppeteer/issues/161 const { viewport, hasTouch } = playwright.devices['iPhone 6']; const context = await browser.newContext({ viewport, hasTouch }); @@ -66,7 +66,7 @@ it('should not hang with touch-enabled viewports', async ({browser, playwright}) await context.close(); }); -it('should click the button with deviceScaleFactor set', async ({browser, server}) => { +it('should click the button with deviceScaleFactor set', async ({ browser, server }) => { const context = await browser.newContext({ viewport: { width: 400, height: 400 }, deviceScaleFactor: 5 }); const page = await context.newPage(); expect(await page.evaluate(() => window.devicePixelRatio)).toBe(5); @@ -79,7 +79,7 @@ it('should click the button with deviceScaleFactor set', async ({browser, server await context.close(); }); -it('should click the button with offset with page scale', async ({browser, server, headless, browserName, browserVersion}) => { +it('should click the button with offset with page scale', async ({ browser, server, headless, browserName, browserVersion }) => { it.skip(browserName === 'firefox'); const context = await browser.newContext({ viewport: { width: 400, height: 400 }, isMobile: true }); @@ -131,7 +131,7 @@ it('should return bounding box with page scale', async ({ browser, server, brows await context.close(); }); -it('should not leak listeners during navigation of 20 pages', async ({contextFactory, server}) => { +it('should not leak listeners during navigation of 20 pages', async ({ contextFactory, server }) => { it.slow(true, 'We open 20 pages here!'); const context = await contextFactory(); diff --git a/tests/browsercontext-proxy.spec.ts b/tests/browsercontext-proxy.spec.ts index 99dc84e7a8..142c1d33fa 100644 --- a/tests/browsercontext-proxy.spec.ts +++ b/tests/browsercontext-proxy.spec.ts @@ -40,7 +40,7 @@ it('should throw for missing global proxy on Chromium Windows', async ({ browser } }); -it('should work when passing the proxy only on the context level', async ({browserName, platform, browserType, browserOptions, contextOptions, server, proxyServer}) => { +it('should work when passing the proxy only on the context level', async ({ browserName, platform, browserType, browserOptions, contextOptions, server, proxyServer }) => { // Currently an upstream bug in the network stack of Chromium which leads that // the wrong proxy gets used in the BrowserContext. it.fixme(browserName === 'chromium' && platform === 'win32'); @@ -100,7 +100,7 @@ it('should use proxy twice', async ({ contextFactory, server, proxyServer }) => await context.close(); }); -it('should use proxy for second page', async ({contextFactory, server, proxyServer}) => { +it('should use proxy for second page', async ({ contextFactory, server, proxyServer }) => { proxyServer.forwardTo(server.PORT); const context = await contextFactory({ proxy: { server: `localhost:${proxyServer.PORT}` } @@ -136,7 +136,7 @@ it('should use proxy for https urls', async ({ contextFactory, server, httpsServ await context.close(); }); -it('should work with IP:PORT notion', async ({contextFactory, server, proxyServer}) => { +it('should work with IP:PORT notion', async ({ contextFactory, server, proxyServer }) => { proxyServer.forwardTo(server.PORT); const context = await contextFactory({ proxy: { server: `127.0.0.1:${proxyServer.PORT}` } @@ -148,21 +148,21 @@ it('should work with IP:PORT notion', async ({contextFactory, server, proxyServe await context.close(); }); -it('should throw for socks5 authentication', async ({contextFactory}) => { +it('should throw for socks5 authentication', async ({ contextFactory }) => { const error = await contextFactory({ proxy: { server: `socks5://localhost:1234`, username: 'user', password: 'secret' } }).catch(e => e); expect(error.message).toContain('Browser does not support socks5 proxy authentication'); }); -it('should throw for socks4 authentication', async ({contextFactory}) => { +it('should throw for socks4 authentication', async ({ contextFactory }) => { const error = await contextFactory({ proxy: { server: `socks4://localhost:1234`, username: 'user', password: 'secret' } }).catch(e => e); expect(error.message).toContain('Socks4 proxy protocol does not support authentication'); }); -it('should authenticate', async ({contextFactory, server, proxyServer}) => { +it('should authenticate', async ({ contextFactory, server, proxyServer }) => { proxyServer.forwardTo(server.PORT); let auth; proxyServer.setAuthHandler(req => { @@ -180,7 +180,7 @@ it('should authenticate', async ({contextFactory, server, proxyServer}) => { await context.close(); }); -it('should authenticate with empty password', async ({contextFactory, server, proxyServer}) => { +it('should authenticate with empty password', async ({ contextFactory, server, proxyServer }) => { proxyServer.forwardTo(server.PORT); let auth; proxyServer.setAuthHandler(req => { @@ -197,7 +197,7 @@ it('should authenticate with empty password', async ({contextFactory, server, pr await context.close(); }); -it('should isolate proxy credentials between contexts', async ({contextFactory, server, browserName, proxyServer}) => { +it('should isolate proxy credentials between contexts', async ({ contextFactory, server, browserName, proxyServer }) => { it.fixme(browserName === 'firefox', 'Credentials from the first context stick around'); proxyServer.forwardTo(server.PORT); @@ -229,7 +229,7 @@ it('should isolate proxy credentials between contexts', async ({contextFactory, } }); -it('should exclude patterns', async ({contextFactory, server, browserName, headless, proxyServer}) => { +it('should exclude patterns', async ({ contextFactory, server, browserName, headless, proxyServer }) => { it.fixme(browserName === 'chromium' && !headless, 'Chromium headed crashes with CHECK(!in_frame_tree_) in RenderFrameImpl::OnDeleteFrame.'); proxyServer.forwardTo(server.PORT); diff --git a/tests/browsercontext-route.spec.ts b/tests/browsercontext-route.spec.ts index 3e5730637a..5eb528392d 100644 --- a/tests/browsercontext-route.spec.ts +++ b/tests/browsercontext-route.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should intercept', async ({browser, server}) => { +it('should intercept', async ({ browser, server }) => { const context = await browser.newContext(); let intercepted = false; await context.route('**/empty.html', route => { @@ -40,7 +40,7 @@ it('should intercept', async ({browser, server}) => { await context.close(); }); -it('should unroute', async ({browser, server}) => { +it('should unroute', async ({ browser, server }) => { const context = await browser.newContext(); const page = await context.newPage(); @@ -78,7 +78,7 @@ it('should unroute', async ({browser, server}) => { await context.close(); }); -it('should yield to page.route', async ({browser, server}) => { +it('should yield to page.route', async ({ browser, server }) => { const context = await browser.newContext(); await context.route('**/empty.html', route => { route.fulfill({ status: 200, body: 'context' }); @@ -93,7 +93,7 @@ it('should yield to page.route', async ({browser, server}) => { await context.close(); }); -it('should fall back to context.route', async ({browser, server}) => { +it('should fall back to context.route', async ({ browser, server }) => { const context = await browser.newContext(); await context.route('**/empty.html', route => { route.fulfill({ status: 200, body: 'context' }); @@ -108,7 +108,7 @@ it('should fall back to context.route', async ({browser, server}) => { await context.close(); }); -it('should support Set-Cookie header', async ({contextFactory, server, browserName}) => { +it('should support Set-Cookie header', async ({ contextFactory, server, browserName }) => { it.fixme(browserName === 'webkit'); const context = await contextFactory(); @@ -135,7 +135,7 @@ it('should support Set-Cookie header', async ({contextFactory, server, browserNa }]); }); -it('should ignore secure Set-Cookie header for insecure requests', async ({contextFactory, server, browserName}) => { +it('should ignore secure Set-Cookie header for insecure requests', async ({ contextFactory, server, browserName }) => { it.fixme(browserName === 'webkit'); const context = await contextFactory(); @@ -153,7 +153,7 @@ it('should ignore secure Set-Cookie header for insecure requests', async ({conte expect(await context.cookies()).toEqual([]); }); -it('should use Set-Cookie header in future requests', async ({contextFactory, server, browserName}) => { +it('should use Set-Cookie header in future requests', async ({ contextFactory, server, browserName }) => { it.fixme(browserName === 'webkit'); const context = await contextFactory(); @@ -189,7 +189,7 @@ it('should use Set-Cookie header in future requests', async ({contextFactory, se expect(cookie).toBe('name=value'); }); -it('should work with ignoreHTTPSErrors', async ({browser, httpsServer}) => { +it('should work with ignoreHTTPSErrors', async ({ browser, httpsServer }) => { const context = await browser.newContext({ ignoreHTTPSErrors: true }); const page = await context.newPage(); @@ -199,12 +199,12 @@ it('should work with ignoreHTTPSErrors', async ({browser, httpsServer}) => { await context.close(); }); -it('should support the times parameter with route matching', async ({context, page, server}) => { +it('should support the times parameter with route matching', async ({ context, page, server }) => { const intercepted = []; await context.route('**/empty.html', route => { intercepted.push(1); route.continue(); - }, { times: 1}); + }, { times: 1 }); await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE); diff --git a/tests/browsercontext-set-extra-http-headers.spec.ts b/tests/browsercontext-set-extra-http-headers.spec.ts index c63bebec31..85cd52b788 100644 --- a/tests/browsercontext-set-extra-http-headers.spec.ts +++ b/tests/browsercontext-set-extra-http-headers.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should override extra headers from browser context', async ({browser, server}) => { +it('should override extra headers from browser context', async ({ browser, server }) => { const context = await browser.newContext({ extraHTTPHeaders: { 'fOo': 'bAr', 'baR': 'foO' }, }); @@ -34,7 +34,7 @@ it('should override extra headers from browser context', async ({browser, server expect(request.headers['bar']).toBe('foO'); }); -it('should throw for non-string header values', async ({browser}) => { +it('should throw for non-string header values', async ({ browser }) => { const error3 = await browser.newContext({ extraHTTPHeaders: { 'foo': null } }).catch(e => e); expect(error3.message).toContain('Expected value of header "foo" to be String, but "object" is found.'); }); diff --git a/tests/browsercontext-timezone-id.spec.ts b/tests/browsercontext-timezone-id.spec.ts index 5147bf91f2..e7fd550acf 100644 --- a/tests/browsercontext-timezone-id.spec.ts +++ b/tests/browsercontext-timezone-id.spec.ts @@ -45,7 +45,7 @@ it('should work', async ({ browser, browserName }) => { } }); -it('should throw for invalid timezone IDs when creating pages', async ({browser}) => { +it('should throw for invalid timezone IDs when creating pages', async ({ browser }) => { for (const timezoneId of ['Foo/Bar', 'Baz/Qux']) { let error = null; const context = await browser.newContext({ timezoneId }); @@ -55,7 +55,7 @@ it('should throw for invalid timezone IDs when creating pages', async ({browser} } }); -it('should work for multiple pages sharing same process', async ({browser, server}) => { +it('should work for multiple pages sharing same process', async ({ browser, server }) => { const context = await browser.newContext({ timezoneId: 'Europe/Moscow' }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -70,7 +70,7 @@ it('should work for multiple pages sharing same process', async ({browser, serve await context.close(); }); -it('should not change default timezone in another context', async ({browser, server}) => { +it('should not change default timezone in another context', async ({ browser, server }) => { async function getContextTimezone(context) { const page = await context.newPage(); return await page.evaluate(() => Intl.DateTimeFormat().resolvedOptions().timeZone); @@ -84,7 +84,7 @@ it('should not change default timezone in another context', async ({browser, ser } const timezoneOverride = defaultTimezone === 'Europe/Moscow' ? 'America/Los_Angeles' : 'Europe/Moscow'; { - const context = await browser.newContext({ timezoneId: timezoneOverride}); + const context = await browser.newContext({ timezoneId: timezoneOverride }); expect(await getContextTimezone(context)).toBe(timezoneOverride); await context.close(); } diff --git a/tests/browsercontext-user-agent.spec.ts b/tests/browsercontext-user-agent.spec.ts index 7846a1fe05..0e87f2545a 100644 --- a/tests/browsercontext-user-agent.spec.ts +++ b/tests/browsercontext-user-agent.spec.ts @@ -18,7 +18,7 @@ import { browserTest as it, expect } from './config/browserTest'; import { attachFrame } from './config/utils'; -it('should work', async ({browser, server}) => { +it('should work', async ({ browser, server }) => { { const context = await browser.newContext(); const page = await context.newPage(); @@ -37,7 +37,7 @@ it('should work', async ({browser, server}) => { } }); -it('should work for subframes', async ({browser, server}) => { +it('should work for subframes', async ({ browser, server }) => { { const context = await browser.newContext(); const page = await context.newPage(); @@ -56,7 +56,7 @@ it('should work for subframes', async ({browser, server}) => { } }); -it('should emulate device user-agent', async ({browser, server, playwright}) => { +it('should emulate device user-agent', async ({ browser, server, playwright }) => { { const context = await browser.newContext(); const page = await context.newPage(); @@ -73,7 +73,7 @@ it('should emulate device user-agent', async ({browser, server, playwright}) => } }); -it('should make a copy of default options', async ({browser, server}) => { +it('should make a copy of default options', async ({ browser, server }) => { const options = { userAgent: 'foobar' }; const context = await browser.newContext(options); options.userAgent = 'wrong'; diff --git a/tests/browsercontext-viewport-mobile.spec.ts b/tests/browsercontext-viewport-mobile.spec.ts index a583d3ec78..178503244d 100644 --- a/tests/browsercontext-viewport-mobile.spec.ts +++ b/tests/browsercontext-viewport-mobile.spec.ts @@ -20,18 +20,18 @@ import { browserTest as it, expect } from './config/browserTest'; it.describe('mobile viewport', () => { it.skip(({ browserName }) => browserName === 'firefox'); - it('should support mobile emulation', async ({playwright, browser, server}) => { + it('should support mobile emulation', async ({ playwright, browser, server }) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); expect(await page.evaluate(() => window.innerWidth)).toBe(375); - await page.setViewportSize({width: 400, height: 300}); + await page.setViewportSize({ width: 400, height: 300 }); expect(await page.evaluate(() => window.innerWidth)).toBe(400); await context.close(); }); - it('should support touch emulation', async ({playwright, browser, server}) => { + it('should support touch emulation', async ({ playwright, browser, server }) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -54,7 +54,7 @@ it.describe('mobile viewport', () => { } }); - it('should be detectable by Modernizr', async ({playwright, browser, server}) => { + it('should be detectable by Modernizr', async ({ playwright, browser, server }) => { const iPhone = playwright.devices['iPhone 6']; const context = await browser.newContext({ ...iPhone }); const page = await context.newPage(); @@ -63,16 +63,16 @@ it.describe('mobile viewport', () => { await context.close(); }); - it('should detect touch when applying viewport with touches', async ({browser, server}) => { + it('should detect touch when applying viewport with touches', async ({ browser, server }) => { const context = await browser.newContext({ viewport: { width: 800, height: 600 }, hasTouch: true }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); - await page.addScriptTag({url: server.PREFIX + '/modernizr.js'}); + await page.addScriptTag({ url: server.PREFIX + '/modernizr.js' }); expect(await page.evaluate(() => window['Modernizr'].touchevents)).toBe(true); await context.close(); }); - it('should support landscape emulation', async ({playwright, browser, server}) => { + it('should support landscape emulation', async ({ playwright, browser, server }) => { const iPhone = playwright.devices['iPhone 6']; const iPhoneLandscape = playwright.devices['iPhone 6 landscape']; const context1 = await browser.newContext({ ...iPhone }); @@ -86,17 +86,17 @@ it.describe('mobile viewport', () => { await context2.close(); }); - it('should support window.orientation emulation', async ({browser, server}) => { + it('should support window.orientation emulation', async ({ browser, server }) => { const context = await browser.newContext({ viewport: { width: 300, height: 400 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); expect(await page.evaluate(() => window.orientation)).toBe(0); - await page.setViewportSize({width: 400, height: 300}); + await page.setViewportSize({ width: 400, height: 300 }); expect(await page.evaluate(() => window.orientation)).toBe(90); await context.close(); }); - it('should fire orientationchange event', async ({browser, server}) => { + it('should fire orientationchange event', async ({ browser, server }) => { const context = await browser.newContext({ viewport: { width: 300, height: 400 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); @@ -106,32 +106,32 @@ it.describe('mobile viewport', () => { }); const event1 = page.waitForEvent('console'); - await page.setViewportSize({width: 400, height: 300}); + await page.setViewportSize({ width: 400, height: 300 }); expect((await event1).text()).toBe('1'); const event2 = page.waitForEvent('console'); - await page.setViewportSize({width: 300, height: 400}); + await page.setViewportSize({ width: 300, height: 400 }); expect((await event2).text()).toBe('2'); await context.close(); }); - it('default mobile viewports to 980 width', async ({browser, server}) => { - const context = await browser.newContext({ viewport: {width: 320, height: 480 }, isMobile: true }); + it('default mobile viewports to 980 width', async ({ browser, server }) => { + const context = await browser.newContext({ viewport: { width: 320, height: 480 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/empty.html'); expect(await page.evaluate(() => window.innerWidth)).toBe(980); await context.close(); }); - it('respect meta viewport tag', async ({browser, server}) => { - const context = await browser.newContext({ viewport: {width: 320, height: 480 }, isMobile: true }); + it('respect meta viewport tag', async ({ browser, server }) => { + const context = await browser.newContext({ viewport: { width: 320, height: 480 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); expect(await page.evaluate(() => window.innerWidth)).toBe(320); await context.close(); }); - it('should emulate the hover media feature', async ({playwright, browser}) => { + it('should emulate the hover media feature', async ({ playwright, browser }) => { const iPhone = playwright.devices['iPhone 6']; const mobilepage = await browser.newPage({ ...iPhone }); expect(await mobilepage.evaluate(() => matchMedia('(hover: hover)').matches)).toBe(false); @@ -156,21 +156,21 @@ it.describe('mobile viewport', () => { await desktopPage.close(); }); - it('mouse should work with mobile viewports and cross process navigations', async ({browser, server, browserName}) => { + it('mouse should work with mobile viewports and cross process navigations', async ({ browser, server, browserName }) => { // @see https://crbug.com/929806 - const context = await browser.newContext({ viewport: {width: 360, height: 640}, isMobile: true }); + const context = await browser.newContext({ viewport: { width: 360, height: 640 }, isMobile: true }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); await page.goto(server.CROSS_PROCESS_PREFIX + '/mobile.html'); await page.evaluate(() => { document.addEventListener('click', event => { - window['result'] = {x: event.clientX, y: event.clientY}; + window['result'] = { x: event.clientX, y: event.clientY }; }); }); await page.mouse.click(30, 40); - expect(await page.evaluate('result')).toEqual({x: 30, y: 40}); + expect(await page.evaluate('result')).toEqual({ x: 30, y: 40 }); await context.close(); }); }); diff --git a/tests/browsercontext-viewport.spec.ts b/tests/browsercontext-viewport.spec.ts index bb143a49fa..2b430dca89 100644 --- a/tests/browsercontext-viewport.spec.ts +++ b/tests/browsercontext-viewport.spec.ts @@ -19,17 +19,17 @@ import { contextTest as it, expect } from './config/browserTest'; import { browserTest } from './config/browserTest'; import { verifyViewport } from './config/utils'; -it('should get the proper default viewport size', async ({page, server}) => { +it('should get the proper default viewport size', async ({ page, server }) => { await verifyViewport(page, 1280, 720); }); -it('should set the proper viewport size', async ({page, server}) => { +it('should set the proper viewport size', async ({ page, server }) => { await verifyViewport(page, 1280, 720); - await page.setViewportSize({width: 123, height: 456}); + await page.setViewportSize({ width: 123, height: 456 }); await verifyViewport(page, 123, 456); }); -it('should return correct outerWidth and outerHeight', async ({page}) => { +it('should return correct outerWidth and outerHeight', async ({ page }) => { const size = await page.evaluate(() => { return { innerWidth: window.innerWidth, @@ -44,9 +44,9 @@ it('should return correct outerWidth and outerHeight', async ({page}) => { expect(size.outerHeight >= size.innerHeight).toBeTruthy(); }); -it('should emulate device width', async ({page, server}) => { - expect(page.viewportSize()).toEqual({width: 1280, height: 720}); - await page.setViewportSize({width: 200, height: 200}); +it('should emulate device width', async ({ page, server }) => { + expect(page.viewportSize()).toEqual({ width: 1280, height: 720 }); + await page.setViewportSize({ width: 200, height: 200 }); expect(await page.evaluate(() => window.screen.width)).toBe(200); expect(await page.evaluate(() => matchMedia('(min-device-width: 100px)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(min-device-width: 300px)').matches)).toBe(false); @@ -54,7 +54,7 @@ it('should emulate device width', async ({page, server}) => { expect(await page.evaluate(() => matchMedia('(max-device-width: 300px)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(device-width: 500px)').matches)).toBe(false); expect(await page.evaluate(() => matchMedia('(device-width: 200px)').matches)).toBe(true); - await page.setViewportSize({width: 500, height: 500}); + await page.setViewportSize({ width: 500, height: 500 }); expect(await page.evaluate(() => window.screen.width)).toBe(500); expect(await page.evaluate(() => matchMedia('(min-device-width: 400px)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(min-device-width: 600px)').matches)).toBe(false); @@ -64,9 +64,9 @@ it('should emulate device width', async ({page, server}) => { expect(await page.evaluate(() => matchMedia('(device-width: 500px)').matches)).toBe(true); }); -it('should emulate device height', async ({page, server}) => { - expect(page.viewportSize()).toEqual({width: 1280, height: 720}); - await page.setViewportSize({width: 200, height: 200}); +it('should emulate device height', async ({ page, server }) => { + expect(page.viewportSize()).toEqual({ width: 1280, height: 720 }); + await page.setViewportSize({ width: 200, height: 200 }); expect(await page.evaluate(() => window.screen.height)).toBe(200); expect(await page.evaluate(() => matchMedia('(min-device-height: 100px)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(min-device-height: 300px)').matches)).toBe(false); @@ -74,7 +74,7 @@ it('should emulate device height', async ({page, server}) => { expect(await page.evaluate(() => matchMedia('(max-device-height: 300px)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(device-height: 500px)').matches)).toBe(false); expect(await page.evaluate(() => matchMedia('(device-height: 200px)').matches)).toBe(true); - await page.setViewportSize({width: 500, height: 500}); + await page.setViewportSize({ width: 500, height: 500 }); expect(await page.evaluate(() => window.screen.height)).toBe(500); expect(await page.evaluate(() => matchMedia('(min-device-height: 400px)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(min-device-height: 600px)').matches)).toBe(false); @@ -84,20 +84,20 @@ it('should emulate device height', async ({page, server}) => { expect(await page.evaluate(() => matchMedia('(device-height: 500px)').matches)).toBe(true); }); -it('should emulate availWidth and availHeight', async ({page}) => { - await page.setViewportSize({width: 500, height: 600}); +it('should emulate availWidth and availHeight', async ({ page }) => { + await page.setViewportSize({ width: 500, height: 600 }); expect(await page.evaluate(() => window.screen.availWidth)).toBe(500); expect(await page.evaluate(() => window.screen.availHeight)).toBe(600); }); -it('should not have touch by default', async ({page, server}) => { +it('should not have touch by default', async ({ page, server }) => { await page.goto(server.PREFIX + '/mobile.html'); expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false); await page.goto(server.PREFIX + '/detect-touch.html'); expect(await page.evaluate(() => document.body.textContent.trim())).toBe('NO'); }); -browserTest('should support touch with null viewport', async ({browser, server}) => { +browserTest('should support touch with null viewport', async ({ browser, server }) => { const context = await browser.newContext({ viewport: null, hasTouch: true }); const page = await context.newPage(); await page.goto(server.PREFIX + '/mobile.html'); @@ -105,14 +105,14 @@ browserTest('should support touch with null viewport', async ({browser, server}) await context.close(); }); -browserTest('should report null viewportSize when given null viewport', async ({browser, server}) => { +browserTest('should report null viewportSize when given null viewport', async ({ browser, server }) => { const context = await browser.newContext({ viewport: null }); const page = await context.newPage(); expect(page.viewportSize()).toBe(null); await context.close(); }); -browserTest('should drag with high dpi', async ({ browser, server}) => { +browserTest('should drag with high dpi', async ({ browser, server }) => { const page = await browser.newPage({ deviceScaleFactor: 2 }); await page.goto(server.PREFIX + '/drag-n-drop.html'); await page.hover('#source'); diff --git a/tests/browsertype-basic.spec.ts b/tests/browsertype-basic.spec.ts index 128f00005c..b0f4a83123 100644 --- a/tests/browsertype-basic.spec.ts +++ b/tests/browsertype-basic.spec.ts @@ -26,13 +26,13 @@ test('browserType.executablePath should work', async ({ browserType, channel, br expect(fs.existsSync(executablePath)).toBe(true); }); -test('browserType.name should work', async ({browserType, browserName}) => { +test('browserType.name should work', async ({ browserType, browserName }) => { expect(browserType.name()).toBe(browserName); }); test('should throw when trying to connect with not-chromium', async ({ browserType, browserName }) => { test.skip(browserName === 'chromium'); - const error = await browserType.connectOverCDP({endpointURL: 'ws://foo'}).catch(e => e); + const error = await browserType.connectOverCDP({ endpointURL: 'ws://foo' }).catch(e => e); expect(error.message).toBe('Connecting over CDP is only supported in Chromium.'); }); diff --git a/tests/browsertype-connect.spec.ts b/tests/browsertype-connect.spec.ts index 2ac16b3593..70954cd66d 100644 --- a/tests/browsertype-connect.spec.ts +++ b/tests/browsertype-connect.spec.ts @@ -24,7 +24,7 @@ import { suppressCertificateWarning } from './config/utils'; 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(); @@ -60,7 +60,7 @@ test('should connect over wss', async ({browserType , startRemoteServer, httpsSe } }); -test('should be able to reconnect to a browser', async ({browserType, startRemoteServer, server}) => { +test('should be able to reconnect to a browser', async ({ browserType, startRemoteServer, server }) => { const remoteServer = await startRemoteServer(); { const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); @@ -80,7 +80,7 @@ test('should be able to reconnect to a browser', async ({browserType, startRemot } }); -test('should be able to connect two browsers at the same time', async ({browserType, startRemoteServer}) => { +test('should be able to connect two browsers at the same time', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser1 = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); @@ -102,7 +102,7 @@ test('should be able to connect two browsers at the same time', async ({browserT await browser2.close(); }); -test('should timeout in socket while connecting', async ({browserType, startRemoteServer, server}) => { +test('should timeout in socket while connecting', async ({ browserType, startRemoteServer, server }) => { const e = await browserType.connect({ wsEndpoint: `ws://localhost:${server.PORT}/ws-slow`, timeout: 1000, @@ -110,7 +110,7 @@ test('should timeout in socket while connecting', async ({browserType, startRemo expect(e.message).toContain('browserType.connect: Opening handshake has timed out'); }); -test('should timeout in connect while connecting', async ({browserType, startRemoteServer, server}) => { +test('should timeout in connect while connecting', async ({ browserType, startRemoteServer, server }) => { const e = await browserType.connect({ wsEndpoint: `ws://localhost:${server.PORT}/ws`, timeout: 100, @@ -118,7 +118,7 @@ test('should timeout in connect while connecting', async ({browserType, startRem expect(e.message).toContain('browserType.connect: Timeout 100ms exceeded'); }); -test('should send extra headers with connect request', async ({browserType, startRemoteServer, server}) => { +test('should send extra headers with connect request', async ({ browserType, startRemoteServer, server }) => { const [request] = await Promise.all([ server.waitForWebSocketConnectionRequest(), browserType.connect({ @@ -134,7 +134,7 @@ test('should send extra headers with connect request', async ({browserType, star expect(request.headers['foo']).toBe('bar'); }); -test('should send default User-Agent header with connect request', async ({browserType, startRemoteServer, server}) => { +test('should send default User-Agent header with connect request', async ({ browserType, startRemoteServer, server }) => { const [request] = await Promise.all([ server.waitForWebSocketConnectionRequest(), browserType.connect({ @@ -149,7 +149,7 @@ test('should send default User-Agent header with connect request', async ({brows expect(request.headers['foo']).toBe('bar'); }); -test('should support slowmo option', async ({browserType, startRemoteServer}) => { +test('should support slowmo option', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser1 = await browserType.connect(remoteServer.wsEndpoint(), { slowMo: 200 }); @@ -159,7 +159,7 @@ test('should support slowmo option', async ({browserType, startRemoteServer}) => expect(Date.now() - start).toBeGreaterThan(199); }); -test('disconnected event should be emitted when browser is closed or server is closed', async ({browserType, startRemoteServer}) => { +test('disconnected event should be emitted when browser is closed or server is closed', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser1 = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); @@ -188,7 +188,7 @@ test('disconnected event should be emitted when browser is closed or server is c expect(disconnected2).toBe(1); }); -test('disconnected event should have browser as argument', async ({browserType, startRemoteServer}) => { +test('disconnected event should have browser as argument', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const [disconnected] = await Promise.all([ @@ -198,7 +198,7 @@ test('disconnected event should have browser as argument', async ({browserType, expect(disconnected).toBe(browser); }); -test('should handle exceptions during connect', async ({browserType, startRemoteServer, mode}) => { +test('should handle exceptions during connect', async ({ browserType, startRemoteServer, mode }) => { test.skip(mode !== 'default'); const remoteServer = await startRemoteServer(); @@ -207,7 +207,7 @@ test('should handle exceptions during connect', async ({browserType, startRemote expect(error.message).toContain('Dummy'); }); -test('should set the browser connected state', async ({browserType, startRemoteServer}) => { +test('should set the browser connected state', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const remote = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); expect(remote.isConnected()).toBe(true); @@ -215,7 +215,7 @@ test('should set the browser connected state', async ({browserType, startRemoteS expect(remote.isConnected()).toBe(false); }); -test('should throw when used after isConnected returns false', async ({browserType, startRemoteServer}) => { +test('should throw when used after isConnected returns false', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await browser.newPage(); @@ -228,7 +228,7 @@ test('should throw when used after isConnected returns false', async ({browserTy expect(error.message).toContain('has been closed'); }); -test('should throw when calling waitForNavigation after disconnect', async ({browserType, startRemoteServer}) => { +test('should throw when calling waitForNavigation after disconnect', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await browser.newPage(); @@ -241,19 +241,19 @@ test('should throw when calling waitForNavigation after disconnect', async ({bro expect(error.message).toContain('Navigation failed because page was closed'); }); -test('should reject navigation when browser closes', async ({browserType, startRemoteServer, server}) => { +test('should reject navigation when browser closes', async ({ browserType, startRemoteServer, server }) => { const remoteServer = await startRemoteServer(); server.setRoute('/one-style.css', () => {}); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await browser.newPage(); - const navigationPromise = page.goto(server.PREFIX + '/one-style.html', {timeout: 60000}).catch(e => e); + const navigationPromise = page.goto(server.PREFIX + '/one-style.html', { timeout: 60000 }).catch(e => e); await server.waitForRequest('/one-style.css'); await browser.close(); const error = await navigationPromise; expect(error.message).toContain('has been closed'); }); -test('should reject waitForSelector when browser closes', async ({browserType, startRemoteServer, server}) => { +test('should reject waitForSelector when browser closes', async ({ browserType, startRemoteServer, server }) => { const remoteServer = await startRemoteServer(); server.setRoute('/empty.html', () => {}); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); @@ -268,7 +268,7 @@ test('should reject waitForSelector when browser closes', async ({browserType, s expect(error.message).toContain('has been closed'); }); -test('should emit close events on pages and contexts', async ({browserType, startRemoteServer}) => { +test('should emit close events on pages and contexts', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const context = await browser.newContext(); @@ -282,7 +282,7 @@ test('should emit close events on pages and contexts', async ({browserType, star expect(pageClosed).toBeTruthy(); }); -test('should terminate network waiters', async ({browserType, startRemoteServer, server}) => { +test('should terminate network waiters', async ({ browserType, startRemoteServer, server }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const newPage = await browser.newPage(); @@ -339,7 +339,7 @@ test('should respect selectors', async ({ playwright, browserType, startRemoteSe await browser1.close(); }); -test('should not throw on close after disconnect', async ({browserType, startRemoteServer}) => { +test('should not throw on close after disconnect', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); await browser.newPage(); @@ -350,7 +350,7 @@ test('should not throw on close after disconnect', async ({browserType, startRem await browser.close(); }); -test('should not throw on context.close after disconnect', async ({browserType, startRemoteServer}) => { +test('should not throw on context.close after disconnect', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const context = await browser.newContext(); @@ -362,7 +362,7 @@ test('should not throw on context.close after disconnect', async ({browserType, await context.close(); }); -test('should not throw on page.close after disconnect', async ({browserType, startRemoteServer}) => { +test('should not throw on page.close after disconnect', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await browser.newPage(); @@ -373,7 +373,7 @@ test('should not throw on page.close after disconnect', async ({browserType, sta await page.close(); }); -test('should saveAs videos from remote browser', async ({browserType, startRemoteServer}, testInfo) => { +test('should saveAs videos from remote browser', async ({ browserType, startRemoteServer }, testInfo) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const videosPath = testInfo.outputPath(); @@ -392,7 +392,7 @@ test('should saveAs videos from remote browser', async ({browserType, startRemot expect(error.message).toContain('Path is not available when using browserType.connect(). Use saveAs() to save a local copy.'); }); -test('should be able to connect 20 times to a single server without warnings', async ({browserType, startRemoteServer}) => { +test('should be able to connect 20 times to a single server without warnings', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); let warning = null; @@ -408,7 +408,7 @@ test('should be able to connect 20 times to a single server without warnings', a expect(warning).toBe(null); }); -test('should save download', async ({server, browserType, startRemoteServer}, testInfo) => { +test('should save download', async ({ server, browserType, startRemoteServer }, testInfo) => { server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Disposition', 'attachment'); @@ -432,7 +432,7 @@ test('should save download', async ({server, browserType, startRemoteServer}, te await browser.close(); }); -test('should error when saving download after deletion', async ({server, browserType, startRemoteServer}, testInfo) => { +test('should error when saving download after deletion', async ({ server, browserType, startRemoteServer }, testInfo) => { server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Disposition', 'attachment'); @@ -454,19 +454,19 @@ test('should error when saving download after deletion', async ({server, browser await browser.close(); }); -test('should work with cluster', async ({browserType, startRemoteServer}) => { +test('should work with cluster', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer({ inCluster: true }); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await browser.newPage(); expect(await page.evaluate('1 + 2')).toBe(3); }); -test('should properly disconnect when connection closes from the client side', async ({browserType, startRemoteServer, server}) => { +test('should properly disconnect when connection closes from the client side', async ({ browserType, startRemoteServer, server }) => { server.setRoute('/one-style.css', () => {}); const remoteServer = await startRemoteServer(); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await browser.newPage(); - const navigationPromise = page.goto(server.PREFIX + '/one-style.html', {timeout: 60000}).catch(e => e); + const navigationPromise = page.goto(server.PREFIX + '/one-style.html', { timeout: 60000 }).catch(e => e); const waitForNavigationPromise = page.waitForNavigation().catch(e => e); const disconnectedPromise = new Promise(f => browser.once('disconnected', f)); @@ -481,14 +481,14 @@ test('should properly disconnect when connection closes from the client side', a expect((await page.waitForNavigation().catch(e => e)).message).toContain('Navigation failed because page was closed'); }); -test('should properly disconnect when connection closes from the server side', async ({browserType, startRemoteServer, server, platform}) => { +test('should properly disconnect when connection closes from the server side', async ({ browserType, startRemoteServer, server, platform }) => { test.skip(platform === 'win32', 'Cannot send signals'); server.setRoute('/one-style.css', () => {}); const remoteServer = await startRemoteServer({ disconnectOnSIGHUP: true }); const browser = await browserType.connect({ wsEndpoint: remoteServer.wsEndpoint() }); const page = await browser.newPage(); - const navigationPromise = page.goto(server.PREFIX + '/one-style.html', {timeout: 60000}).catch(e => e); + const navigationPromise = page.goto(server.PREFIX + '/one-style.html', { timeout: 60000 }).catch(e => e); const waitForNavigationPromise = page.waitForNavigation().catch(e => e); const disconnectedPromise = new Promise(f => browser.once('disconnected', f)); @@ -503,7 +503,7 @@ test('should properly disconnect when connection closes from the server side', a expect((await page.waitForNavigation().catch(e => e)).message).toContain('Navigation failed because page was closed'); }); -test('should be able to connect when the wsEndpont is passed as the first argument', async ({browserType, startRemoteServer}) => { +test('should be able to connect when the wsEndpont is passed as the first argument', async ({ browserType, startRemoteServer }) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect(remoteServer.wsEndpoint()); const page = await browser.newPage(); @@ -511,7 +511,7 @@ test('should be able to connect when the wsEndpont is passed as the first argume await browser.close(); }); -test('should save har', async ({browserType, startRemoteServer, server}, testInfo) => { +test('should save har', async ({ browserType, startRemoteServer, server }, testInfo) => { const remoteServer = await startRemoteServer(); const browser = await browserType.connect(remoteServer.wsEndpoint()); const harPath = testInfo.outputPath('test.har'); diff --git a/tests/browsertype-launch-server.spec.ts b/tests/browsertype-launch-server.spec.ts index cf73567ea8..30f41e79cd 100644 --- a/tests/browsertype-launch-server.spec.ts +++ b/tests/browsertype-launch-server.spec.ts @@ -18,49 +18,49 @@ import { playwrightTest as it, expect } from './config/browserTest'; it.describe('launch server', () => { - it.skip(({ mode}) => mode !== 'default'); + it.skip(({ mode }) => mode !== 'default'); - it('should work', async ({browserType, browserOptions}) => { + it('should work', async ({ browserType, browserOptions }) => { const browserServer = await browserType.launchServer(browserOptions); expect(browserServer.wsEndpoint()).not.toBe(null); await browserServer.close(); }); - it('should work with port', async ({browserType, browserOptions}, testInfo) => { + it('should work with port', async ({ browserType, browserOptions }, testInfo) => { const port = 8800 + testInfo.workerIndex; const browserServer = await browserType.launchServer({ ...browserOptions, port }); expect(browserServer.wsEndpoint()).toContain(String(port)); await browserServer.close(); }); - it('should work with wsPath', async ({browserType, browserOptions}) => { + it('should work with wsPath', async ({ browserType, browserOptions }) => { const wsPath = '/unguessable-token'; const browserServer = await browserType.launchServer({ ...browserOptions, wsPath }); expect(browserServer.wsEndpoint()).toMatch(/:\d+\/unguessable-token$/); await browserServer.close(); }); - it('should work when wsPath is missing leading slash', async ({browserType, browserOptions}) => { + it('should work when wsPath is missing leading slash', async ({ browserType, browserOptions }) => { const wsPath = 'unguessable-token'; const browserServer = await browserType.launchServer({ ...browserOptions, wsPath }); expect(browserServer.wsEndpoint()).toMatch(/:\d+\/unguessable-token$/); await browserServer.close(); }); - it('should default to random wsPath', async ({browserType, browserOptions}) => { + it('should default to random wsPath', async ({ browserType, browserOptions }) => { const browserServer = await browserType.launchServer({ ...browserOptions }); expect(browserServer.wsEndpoint()).toMatch(/:\d+\/[a-f\d]{32}$/); await browserServer.close(); }); - it('should provide an error when ws endpoint is incorrect', async ({browserType, browserOptions}) => { + it('should provide an error when ws endpoint is incorrect', async ({ browserType, browserOptions }) => { const browserServer = await browserType.launchServer(browserOptions); const error = await browserType.connect({ wsEndpoint: browserServer.wsEndpoint() + '-foo' }).catch(e => e); await browserServer.close(); expect(error.message).toContain('Unexpected server response: 400'); }); - it('should fire "close" event during kill', async ({browserType, browserOptions}) => { + it('should fire "close" event during kill', async ({ browserType, browserOptions }) => { const order = []; const browserServer = await browserType.launchServer(browserOptions); const closedPromise = new Promise(f => browserServer.on('close', () => { @@ -74,13 +74,13 @@ it.describe('launch server', () => { expect(order).toEqual(['closed', 'killed']); }); - it('should return child_process instance', async ({browserType, browserOptions}) => { + it('should return child_process instance', async ({ browserType, browserOptions }) => { const browserServer = await browserType.launchServer(browserOptions); expect(browserServer.process().pid).toBeGreaterThan(0); await browserServer.close(); }); - it('should fire close event', async ({browserType, browserOptions}) => { + it('should fire close event', async ({ browserType, browserOptions }) => { const browserServer = await browserType.launchServer(browserOptions); const [result] = await Promise.all([ // @ts-expect-error The signal parameter is not documented. @@ -91,7 +91,7 @@ it.describe('launch server', () => { expect(result['signal']).toBe(null); }); - it('should log protocol', async ({browserType, browserOptions}) => { + it('should log protocol', async ({ browserType, browserOptions }) => { const logs: string[] = []; const logger = { isEnabled(name: string) { diff --git a/tests/browsertype-launch.spec.ts b/tests/browsertype-launch.spec.ts index b55f1fcd02..3f48ace2b7 100644 --- a/tests/browsertype-launch.spec.ts +++ b/tests/browsertype-launch.spec.ts @@ -17,7 +17,7 @@ import { playwrightTest as it, expect } from './config/browserTest'; -it('should reject all promises when browser is closed', async ({browserType, browserOptions}) => { +it('should reject all promises when browser is closed', async ({ browserType, browserOptions }) => { const browser = await browserType.launch(browserOptions); const page = await (await browser.newContext()).newPage(); let error = null; @@ -29,33 +29,33 @@ it('should reject all promises when browser is closed', async ({browserType, bro expect(error.message).toContain(' closed'); }); -it('should throw if userDataDir option is passed', async ({browserType, browserOptions}) => { +it('should throw if userDataDir option is passed', async ({ browserType, browserOptions }) => { let waitError = null; - const options = Object.assign({}, browserOptions, {userDataDir: 'random-path'}); + const options = Object.assign({}, browserOptions, { userDataDir: 'random-path' }); await browserType.launch(options).catch(e => waitError = e); expect(waitError.message).toContain('userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistentContext` instead'); }); -it('should throw if userDataDir is passed as an argument', async ({browserType, browserOptions}) => { +it('should throw if userDataDir is passed as an argument', async ({ browserType, browserOptions }) => { let waitError = null; - const options = Object.assign({}, browserOptions, {args: ['--user-data-dir=random-path', '--profile=random-path']}); + const options = Object.assign({}, browserOptions, { args: ['--user-data-dir=random-path', '--profile=random-path'] }); await browserType.launch(options).catch(e => waitError = e); expect(waitError.message).toContain('Pass userDataDir parameter to `browserType.launchPersistentContext'); }); -it('should throw if port option is passed', async ({browserType, browserOptions}) => { - const options = Object.assign({}, browserOptions, {port: 1234}); +it('should throw if port option is passed', async ({ browserType, browserOptions }) => { + const options = Object.assign({}, browserOptions, { port: 1234 }); const error = await browserType.launch(options).catch(e => e); expect(error.message).toContain('Cannot specify a port without launching as a server.'); }); -it('should throw if port option is passed for persistent context', async ({browserType, browserOptions}) => { - const options = Object.assign({}, browserOptions, {port: 1234}); +it('should throw if port option is passed for persistent context', async ({ browserType, browserOptions }) => { + const options = Object.assign({}, browserOptions, { port: 1234 }); const error = await browserType.launchPersistentContext('foo', options).catch(e => e); expect(error.message).toContain('Cannot specify a port without launching as a server.'); }); -it('should throw if page argument is passed', async ({browserType, browserOptions, browserName}) => { +it('should throw if page argument is passed', async ({ browserType, browserOptions, browserName }) => { it.skip(browserName === 'firefox'); let waitError = null; @@ -64,21 +64,21 @@ it('should throw if page argument is passed', async ({browserType, browserOption expect(waitError.message).toContain('can not specify page'); }); -it('should reject if launched browser fails immediately', async ({browserType, browserOptions, asset}) => { - const options = Object.assign({}, browserOptions, {executablePath: asset('dummy_bad_browser_executable.js')}); +it('should reject if launched browser fails immediately', async ({ browserType, browserOptions, asset }) => { + const options = Object.assign({}, browserOptions, { executablePath: asset('dummy_bad_browser_executable.js') }); let waitError = null; await browserType.launch(options).catch(e => waitError = e); expect(waitError.message).toContain('== logs =='); }); -it('should reject if executable path is invalid', async ({browserType, browserOptions}) => { +it('should reject if executable path is invalid', async ({ browserType, browserOptions }) => { let waitError = null; - const options = Object.assign({}, browserOptions, {executablePath: 'random-invalid-path'}); + const options = Object.assign({}, browserOptions, { executablePath: 'random-invalid-path' }); await browserType.launch(options).catch(e => waitError = e); expect(waitError.message).toContain('Failed to launch'); }); -it('should handle timeout', async ({browserType, browserOptions, mode}) => { +it('should handle timeout', async ({ browserType, browserOptions, mode }) => { it.skip(mode !== 'default'); const options = { ...browserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) }; @@ -88,7 +88,7 @@ it('should handle timeout', async ({browserType, browserOptions, mode}) => { expect(error.message).toContain(` pid=`); }); -it('should handle exception', async ({browserType, browserOptions, mode}) => { +it('should handle exception', async ({ browserType, browserOptions, mode }) => { it.skip(mode !== 'default'); const e = new Error('Dummy'); @@ -97,7 +97,7 @@ it('should handle exception', async ({browserType, browserOptions, mode}) => { expect(error.message).toContain('Dummy'); }); -it('should report launch log', async ({browserType, browserOptions, mode}) => { +it('should report launch log', async ({ browserType, browserOptions, mode }) => { it.skip(mode !== 'default'); const e = new Error('Dummy'); @@ -106,13 +106,13 @@ it('should report launch log', async ({browserType, browserOptions, mode}) => { expect(error.message).toContain(''); }); -it('should accept objects as options', async ({browserType, browserOptions}) => { +it('should accept objects as options', async ({ browserType, browserOptions }) => { // @ts-expect-error process is not a real option. const browser = await browserType.launch({ ...browserOptions, process }); await browser.close(); }); -it('should fire close event for all contexts', async ({browserType, browserOptions}) => { +it('should fire close event for all contexts', async ({ browserType, browserOptions }) => { const browser = await browserType.launch(browserOptions); const context = await browser.newContext(); let closed = false; @@ -121,7 +121,7 @@ it('should fire close event for all contexts', async ({browserType, browserOptio expect(closed).toBe(true); }); -it('should be callable twice', async ({browserType, browserOptions}) => { +it('should be callable twice', async ({ browserType, browserOptions }) => { const browser = await browserType.launch(browserOptions); await Promise.all([ browser.close(), diff --git a/tests/capabilities.spec.ts b/tests/capabilities.spec.ts index 9bd23718c5..0152a7489d 100644 --- a/tests/capabilities.spec.ts +++ b/tests/capabilities.spec.ts @@ -18,7 +18,7 @@ import os from 'os'; import url from 'url'; import { contextTest as it, expect } from './config/browserTest'; -it('SharedArrayBuffer should work', async function({contextFactory, httpsServer, browserName}) { +it('SharedArrayBuffer should work', async function({ contextFactory, httpsServer, browserName }) { it.fail(browserName === 'webkit', 'no shared array buffer on webkit'); const context = await contextFactory({ ignoreHTTPSErrors: true }); const page = await context.newPage(); @@ -31,14 +31,14 @@ it('SharedArrayBuffer should work', async function({contextFactory, httpsServer, expect(await page.evaluate(() => typeof SharedArrayBuffer)).toBe('function'); }); -it('Web Assembly should work', async function({page, server, browserName, platform}) { +it('Web Assembly should work', async function({ page, server, browserName, platform }) { it.fail(browserName === 'webkit' && platform === 'win32'); await page.goto(server.PREFIX + '/wasm/table2.html'); expect(await page.evaluate('loadTable()')).toBe('42, 83'); }); -it('WebSocket should work', async ({page, server}) => { +it('WebSocket should work', async ({ page, server }) => { server.sendOnWebSocketConnection('incoming'); const value = await page.evaluate(port => { let cb; @@ -51,7 +51,7 @@ it('WebSocket should work', async ({page, server}) => { expect(value).toBe('incoming'); }); -it('should respect CSP', async ({page, server}) => { +it('should respect CSP', async ({ page, server }) => { server.setRoute('/empty.html', async (req, res) => { res.setHeader('Content-Security-Policy', `script-src 'unsafe-inline';`); res.end(` @@ -65,7 +65,7 @@ it('should respect CSP', async ({page, server}) => { expect(await page.evaluate(() => window['testStatus'])).toBe('SUCCESS'); }); -it('should play video', async ({page, asset, browserName, platform}) => { +it('should play video', async ({ page, asset, browserName, platform }) => { // TODO: the test passes on Windows locally but fails on GitHub Action bot, // apparently due to a Media Pack issue in the Windows Server. // Also the test is very flaky on Linux WebKit. @@ -82,7 +82,7 @@ it('should play video', async ({page, asset, browserName, platform}) => { await page.$eval('video', v => v.pause()); }); -it('should support webgl', async ({page, browserName, headless}) => { +it('should support webgl', async ({ page, browserName, headless }) => { it.fixme(browserName === 'firefox' && headless); const hasWebGL = await page.evaluate(() => { @@ -92,7 +92,7 @@ it('should support webgl', async ({page, browserName, headless}) => { expect(hasWebGL).toBe(true); }); -it('should support webgl 2', async ({page, browserName, headless}) => { +it('should support webgl 2', async ({ page, browserName, headless }) => { it.skip(browserName === 'webkit', 'WebKit doesn\'t have webgl2 enabled yet upstream.'); it.fixme(browserName === 'firefox' && headless); it.fixme(browserName === 'chromium' && !headless, 'chromium doesn\'t like webgl2 when running under xvfb'); diff --git a/tests/channels.spec.ts b/tests/channels.spec.ts index 5206a41a6b..41c958274f 100644 --- a/tests/channels.spec.ts +++ b/tests/channels.spec.ts @@ -22,7 +22,7 @@ import { playwrightTest as it, expect } from './config/browserTest'; // Otherwise, a browser launched for other tests in this worker will affect the expectations. it.use({ args: [] }); -it('should scope context handles', async ({browserType, browserOptions, server}) => { +it('should scope context handles', async ({ browserType, browserOptions, server }) => { const browser = await browserType.launch(browserOptions); const GOLDEN_PRECONDITION = { _guid: '', @@ -53,10 +53,10 @@ it('should scope context handles', async ({browserType, browserOptions, server}) { _guid: 'browser', objects: [ { _guid: 'browser-context', objects: [ { _guid: 'frame', objects: [] }, - { _guid: 'page', objects: []}, + { _guid: 'page', objects: [] }, { _guid: 'request', objects: [] }, { _guid: 'response', objects: [] }, - ]}, + ] }, { _guid: 'fetchRequest', objects: [] } ] }, ] }, @@ -71,7 +71,7 @@ it('should scope context handles', async ({browserType, browserOptions, server}) await browser.close(); }); -it('should scope CDPSession handles', async ({browserType, browserOptions, browserName}) => { +it('should scope CDPSession handles', async ({ browserType, browserOptions, browserName }) => { it.skip(browserName !== 'chromium'); const browser = await browserType.launch(browserOptions); @@ -115,7 +115,7 @@ it('should scope CDPSession handles', async ({browserType, browserOptions, brows await browser.close(); }); -it('should scope browser handles', async ({browserType, browserOptions}) => { +it('should scope browser handles', async ({ browserType, browserOptions }) => { const GOLDEN_PRECONDITION = { _guid: '', objects: [ diff --git a/tests/chromium/chromium.spec.ts b/tests/chromium/chromium.spec.ts index 9e48957b99..08887a6b63 100644 --- a/tests/chromium/chromium.spec.ts +++ b/tests/chromium/chromium.spec.ts @@ -21,7 +21,7 @@ import http from 'http'; import { getUserAgent } from '../../lib/utils/utils'; import { suppressCertificateWarning } from '../config/utils'; -test('should create a worker from a service worker', async ({page, server}) => { +test('should create a worker from a service worker', async ({ page, server }) => { const [worker] = await Promise.all([ page.context().waitForEvent('serviceworker'), page.goto(server.PREFIX + '/serviceworkers/empty/sw.html') @@ -29,7 +29,7 @@ test('should create a worker from a service worker', async ({page, server}) => { expect(await worker.evaluate(() => self.toString())).toBe('[object ServiceWorkerGlobalScope]'); }); -test('serviceWorkers() should return current workers', async ({page, server}) => { +test('serviceWorkers() should return current workers', async ({ page, server }) => { const context = page.context(); const [worker1] = await Promise.all([ context.waitForEvent('serviceworker'), @@ -48,7 +48,7 @@ test('serviceWorkers() should return current workers', async ({page, server}) => expect(workers).toContain(worker2); }); -test('should not create a worker from a shared worker', async ({page, server}) => { +test('should not create a worker from a shared worker', async ({ page, server }) => { await page.goto(server.EMPTY_PAGE); let serviceWorkerCreated; page.context().once('serviceworker', () => serviceWorkerCreated = true); @@ -58,7 +58,7 @@ test('should not create a worker from a shared worker', async ({page, server}) = expect(serviceWorkerCreated).not.toBeTruthy(); }); -test('Page.route should work with intervention headers', async ({server, page}) => { +test('Page.route should work with intervention headers', async ({ server, page }) => { server.setRoute('/intervention', (req, res) => res.end(` '); let error = null; await page.evaluate('something').catch(e => error = e); @@ -158,23 +158,23 @@ it('should support javascriptEnabled option', async ({launchPersistent, browserN expect(error.message).toContain('something is not defined'); }); -it('should support httpCredentials option', async ({server, launchPersistent}) => { - const {page} = await launchPersistent({httpCredentials: { username: 'user', password: 'pass' }}); +it('should support httpCredentials option', async ({ server, launchPersistent }) => { + const { page } = await launchPersistent({ httpCredentials: { username: 'user', password: 'pass' } }); server.setAuth('/playground.html', 'user', 'pass'); const response = await page.goto(server.PREFIX + '/playground.html'); expect(response.status()).toBe(200); }); -it('should support offline option', async ({server, launchPersistent}) => { - const {page} = await launchPersistent({offline: true}); +it('should support offline option', async ({ server, launchPersistent }) => { + const { page } = await launchPersistent({ offline: true }); const error = await page.goto(server.EMPTY_PAGE).catch(e => e); expect(error).toBeTruthy(); }); -it('should support acceptDownloads option', async ({server, launchPersistent}) => { +it('should support acceptDownloads option', async ({ server, launchPersistent }) => { it.skip(true, 'Unskip once we support downloads in persistent context.'); - const {page} = await launchPersistent({acceptDownloads: true}); + const { page } = await launchPersistent({ acceptDownloads: true }); server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Disposition', 'attachment'); diff --git a/tests/defaultbrowsercontext-2.spec.ts b/tests/defaultbrowsercontext-2.spec.ts index af39c089f2..ed8ea942e2 100644 --- a/tests/defaultbrowsercontext-2.spec.ts +++ b/tests/defaultbrowsercontext-2.spec.ts @@ -18,68 +18,68 @@ import { playwrightTest as it, expect } from './config/browserTest'; import fs from 'fs'; -it('should support hasTouch option', async ({server, launchPersistent}) => { - const {page} = await launchPersistent({hasTouch: true}); +it('should support hasTouch option', async ({ server, launchPersistent }) => { + const { page } = await launchPersistent({ hasTouch: true }); await page.goto(server.PREFIX + '/mobile.html'); expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true); }); -it('should work in persistent context', async ({server, launchPersistent, browserName}) => { +it('should work in persistent context', async ({ server, launchPersistent, browserName }) => { it.skip(browserName === 'firefox', 'Firefox does not support mobile'); - const {page} = await launchPersistent({viewport: {width: 320, height: 480}, isMobile: true}); + const { page } = await launchPersistent({ viewport: { width: 320, height: 480 }, isMobile: true }); await page.goto(server.PREFIX + '/empty.html'); expect(await page.evaluate(() => window.innerWidth)).toBe(980); }); -it('should support colorScheme option', async ({launchPersistent}) => { - const {page} = await launchPersistent({colorScheme: 'dark'}); +it('should support colorScheme option', async ({ launchPersistent }) => { + const { page } = await launchPersistent({ colorScheme: 'dark' }); expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches)).toBe(false); expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true); }); -it('should support reducedMotion option', async ({launchPersistent}) => { - const {page} = await launchPersistent({reducedMotion: 'reduce'}); +it('should support reducedMotion option', async ({ launchPersistent }) => { + const { page } = await launchPersistent({ reducedMotion: 'reduce' }); expect(await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(prefers-reduced-motion: no-preference)').matches)).toBe(false); }); -it('should support forcedColors option', async ({launchPersistent, browserName}) => { +it('should support forcedColors option', async ({ launchPersistent, browserName }) => { it.skip(browserName === 'webkit', 'https://bugs.webkit.org/show_bug.cgi?id=225281'); - const {page} = await launchPersistent({forcedColors: 'active'}); + const { page } = await launchPersistent({ forcedColors: 'active' }); expect(await page.evaluate(() => matchMedia('(forced-colors: active)').matches)).toBe(true); expect(await page.evaluate(() => matchMedia('(forced-colors: none)').matches)).toBe(false); }); -it('should support timezoneId option', async ({launchPersistent, browserName}) => { - const {page} = await launchPersistent({locale: 'en-US', timezoneId: 'America/Jamaica'}); +it('should support timezoneId option', async ({ launchPersistent, browserName }) => { + const { page } = await launchPersistent({ locale: 'en-US', timezoneId: 'America/Jamaica' }); expect(await page.evaluate(() => new Date(1479579154987).toString())).toBe('Sat Nov 19 2016 13:12:34 GMT-0500 (Eastern Standard Time)'); }); -it('should support locale option', async ({launchPersistent}) => { - const {page} = await launchPersistent({locale: 'fr-CH'}); +it('should support locale option', async ({ launchPersistent }) => { + const { page } = await launchPersistent({ locale: 'fr-CH' }); expect(await page.evaluate(() => navigator.language)).toBe('fr-CH'); }); -it('should support geolocation and permissions options', async ({server, launchPersistent}) => { - const {page} = await launchPersistent({geolocation: {longitude: 10, latitude: 10}, permissions: ['geolocation']}); +it('should support geolocation and permissions options', async ({ server, launchPersistent }) => { + const { page } = await launchPersistent({ geolocation: { longitude: 10, latitude: 10 }, permissions: ['geolocation'] }); await page.goto(server.EMPTY_PAGE); const geolocation = await page.evaluate(() => new Promise(resolve => navigator.geolocation.getCurrentPosition(position => { - resolve({latitude: position.coords.latitude, longitude: position.coords.longitude}); + resolve({ latitude: position.coords.latitude, longitude: position.coords.longitude }); }))); - expect(geolocation).toEqual({latitude: 10, longitude: 10}); + expect(geolocation).toEqual({ latitude: 10, longitude: 10 }); }); -it('should support ignoreHTTPSErrors option', async ({httpsServer, launchPersistent}) => { - const {page} = await launchPersistent({ignoreHTTPSErrors: true}); +it('should support ignoreHTTPSErrors option', async ({ httpsServer, launchPersistent }) => { + const { page } = await launchPersistent({ ignoreHTTPSErrors: true }); let error = null; const response = await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e); expect(error).toBe(null); expect(response.ok()).toBe(true); }); -it('should support extraHTTPHeaders option', async ({server, launchPersistent}) => { - const {page} = await launchPersistent({extraHTTPHeaders: { foo: 'bar' }}); +it('should support extraHTTPHeaders option', async ({ server, launchPersistent }) => { + const { page } = await launchPersistent({ extraHTTPHeaders: { foo: 'bar' } }); const [request] = await Promise.all([ server.waitForRequest('/empty.html'), page.goto(server.EMPTY_PAGE), @@ -87,7 +87,7 @@ it('should support extraHTTPHeaders option', async ({server, launchPersistent}) expect(request.headers['foo']).toBe('bar'); }); -it('should accept userDataDir', async ({createUserDataDir, browserType, browserOptions}) => { +it('should accept userDataDir', async ({ createUserDataDir, browserType, browserOptions }) => { const userDataDir = await createUserDataDir(); const context = await browserType.launchPersistentContext(userDataDir, browserOptions); expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); @@ -95,7 +95,7 @@ it('should accept userDataDir', async ({createUserDataDir, browserType, browserO expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0); }); -it('should restore state from userDataDir', async ({browserType, browserOptions, server, createUserDataDir}) => { +it('should restore state from userDataDir', async ({ browserType, browserOptions, server, createUserDataDir }) => { it.slow(); const userDataDir = await createUserDataDir(); @@ -119,7 +119,7 @@ it('should restore state from userDataDir', async ({browserType, browserOptions, await browserContext3.close(); }); -it('should restore cookies from userDataDir', async ({browserType, browserOptions, server, createUserDataDir, platform, channel}) => { +it('should restore cookies from userDataDir', async ({ browserType, browserOptions, server, createUserDataDir, platform, channel }) => { it.fixme(platform === 'win32' && channel === 'chrome'); it.slow(); @@ -148,21 +148,21 @@ it('should restore cookies from userDataDir', async ({browserType, browserOption await browserContext3.close(); }); -it('should have default URL when launching browser', async ({launchPersistent}) => { - const {context} = await launchPersistent(); +it('should have default URL when launching browser', async ({ launchPersistent }) => { + const { context } = await launchPersistent(); const urls = context.pages().map(page => page.url()); expect(urls).toEqual(['about:blank']); }); -it('should throw if page argument is passed', async ({browserType, browserOptions, server, createUserDataDir, browserName}) => { +it('should throw if page argument is passed', async ({ browserType, browserOptions, server, createUserDataDir, browserName }) => { it.skip(browserName === 'firefox'); - const options = {...browserOptions, args: [server.EMPTY_PAGE] }; + const options = { ...browserOptions, args: [server.EMPTY_PAGE] }; const error = await browserType.launchPersistentContext(await createUserDataDir(), options).catch(e => e); expect(error.message).toContain('can not specify page'); }); -it('should have passed URL when launching with ignoreDefaultArgs: true', async ({browserType, browserOptions, server, createUserDataDir, toImpl, mode, browserName}) => { +it('should have passed URL when launching with ignoreDefaultArgs: true', async ({ browserType, browserOptions, server, createUserDataDir, toImpl, mode, browserName }) => { it.skip(mode !== 'default'); const userDataDir = await createUserDataDir(); @@ -181,7 +181,7 @@ it('should have passed URL when launching with ignoreDefaultArgs: true', async ( await browserContext.close(); }); -it('should handle timeout', async ({browserType, browserOptions, createUserDataDir, mode}) => { +it('should handle timeout', async ({ browserType, browserOptions, createUserDataDir, mode }) => { it.skip(mode !== 'default'); const options = { ...browserOptions, timeout: 5000, __testHookBeforeCreateBrowser: () => new Promise(f => setTimeout(f, 6000)) }; @@ -189,7 +189,7 @@ it('should handle timeout', async ({browserType, browserOptions, createUserDataD expect(error.message).toContain(`browserType.launchPersistentContext: Timeout 5000ms exceeded.`); }); -it('should handle exception', async ({browserType, browserOptions, createUserDataDir, mode}) => { +it('should handle exception', async ({ browserType, browserOptions, createUserDataDir, mode }) => { it.skip(mode !== 'default'); const e = new Error('Dummy'); @@ -198,18 +198,18 @@ it('should handle exception', async ({browserType, browserOptions, createUserDat expect(error.message).toContain('Dummy'); }); -it('should fire close event for a persistent context', async ({launchPersistent}) => { - const {context} = await launchPersistent(); +it('should fire close event for a persistent context', async ({ launchPersistent }) => { + const { context } = await launchPersistent(); let closed = false; context.on('close', () => closed = true); await context.close(); expect(closed).toBe(true); }); -it('coverage should work', async ({server, launchPersistent, browserName}) => { +it('coverage should work', async ({ server, launchPersistent, browserName }) => { it.skip(browserName !== 'chromium'); - const {page} = await launchPersistent(); + const { page } = await launchPersistent(); await page.coverage.startJSCoverage(); await page.goto(server.PREFIX + '/jscoverage/simple.html', { waitUntil: 'load' }); const coverage = await page.coverage.stopJSCoverage(); @@ -218,8 +218,8 @@ it('coverage should work', async ({server, launchPersistent, browserName}) => { expect(coverage[0].functions.find(f => f.functionName === 'foo').ranges[0].count).toEqual(1); }); -it('should respect selectors', async ({playwright, launchPersistent}) => { - const {page} = await launchPersistent(); +it('should respect selectors', async ({ playwright, launchPersistent }) => { + const { page } = await launchPersistent(); const defaultContextCSS = () => ({ query(root, selector) { @@ -236,7 +236,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, browserOptions, createUserDataDir, mode}) => { +it('should connect to a browser with the default page', async ({ browserType, browserOptions, createUserDataDir, mode }) => { it.skip(mode !== 'default'); const options = { ...browserOptions, __testHookOnConnectToBrowser: () => new Promise(f => setTimeout(f, 3000)) }; diff --git a/tests/download.spec.ts b/tests/download.spec.ts index 39a22f5f59..fb338f9c51 100644 --- a/tests/download.spec.ts +++ b/tests/download.spec.ts @@ -20,7 +20,7 @@ import path from 'path'; import crypto from 'crypto'; it.describe('download event', () => { - it.beforeEach(async ({server}) => { + it.beforeEach(async ({ server }) => { server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Disposition', 'attachment'); @@ -41,7 +41,7 @@ it.describe('download event', () => { }); }); - it('should report download when navigation turns into download', async ({browser, server, browserName}) => { + it('should report download when navigation turns into download', async ({ browser, server, browserName }) => { const page = await browser.newPage({ acceptDownloads: true }); const [ download, responseOrError ] = await Promise.all([ page.waitForEvent('download'), @@ -67,7 +67,7 @@ it.describe('download event', () => { await page.close(); }); - it('should report downloads with acceptDownloads: false', async ({browser, server}) => { + it('should report downloads with acceptDownloads: false', async ({ browser, server }) => { const page = await browser.newPage(); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -84,7 +84,7 @@ it.describe('download event', () => { await page.close(); }); - it('should report downloads with acceptDownloads: true', async ({browser, server}) => { + it('should report downloads with acceptDownloads: true', async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -97,7 +97,7 @@ it.describe('download event', () => { await page.close(); }); - it('should report proper download url when download is from download attribute', async ({browser, server, browserName}) => { + it('should report proper download url when download is from download attribute', async ({ browser, server, browserName }) => { const page = await browser.newPage({ acceptDownloads: true }); await page.goto(server.PREFIX + '/empty.html'); await page.setContent(`download`); @@ -109,7 +109,7 @@ it.describe('download event', () => { await page.close(); }); - it('should report downloads for download attribute', async ({browser, server}) => { + it('should report downloads for download attribute', async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); await page.goto(server.PREFIX + '/empty.html'); await page.setContent(`download`); @@ -123,7 +123,7 @@ it.describe('download event', () => { await page.close(); }); - it('should save to user-specified path', async ({browser, server}, testInfo) => { + it('should save to user-specified path', async ({ browser, server }, testInfo) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -137,7 +137,7 @@ it.describe('download event', () => { await page.close(); }); - it('should save to user-specified path without updating original path', async ({browser, server}, testInfo) => { + it('should save to user-specified path without updating original path', async ({ browser, server }, testInfo) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -155,7 +155,7 @@ it.describe('download event', () => { await page.close(); }); - it('should save to two different paths with multiple saveAs calls', async ({browser, server}, testInfo) => { + it('should save to two different paths with multiple saveAs calls', async ({ browser, server }, testInfo) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -174,7 +174,7 @@ it.describe('download event', () => { await page.close(); }); - it('should save to overwritten filepath', async ({browser, server}, testInfo) => { + it('should save to overwritten filepath', async ({ browser, server }, testInfo) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -192,7 +192,7 @@ it.describe('download event', () => { await page.close(); }); - it('should create subdirectories when saving to non-existent user-specified path', async ({browser, server}, testInfo) => { + it('should create subdirectories when saving to non-existent user-specified path', async ({ browser, server }, testInfo) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -206,7 +206,7 @@ it.describe('download event', () => { await page.close(); }); - it('should error when saving with downloads disabled', async ({browser, server}, testInfo) => { + it('should error when saving with downloads disabled', async ({ browser, server }, testInfo) => { const page = await browser.newPage({ acceptDownloads: false }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -219,7 +219,7 @@ it.describe('download event', () => { await page.close(); }); - it('should error when saving after deletion', async ({browser, server}, testInfo) => { + it('should error when saving after deletion', async ({ browser, server }, testInfo) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -233,7 +233,7 @@ it.describe('download event', () => { await page.close(); }); - it('should report non-navigation downloads', async ({browser, server}) => { + it('should report non-navigation downloads', async ({ browser, server }) => { // Mac WebKit embedder does not download in this case, although Safari does. server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); @@ -254,7 +254,7 @@ it.describe('download event', () => { await page.close(); }); - it(`should report download path within page.on('download', …) handler for Files`, async ({browser, server}) => { + it(`should report download path within page.on('download', …) handler for Files`, async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); const onDownloadPath = new Promise(res => { page.on('download', dl => { @@ -268,7 +268,7 @@ it.describe('download event', () => { await page.close(); }); - it(`should report download path within page.on('download', …) handler for Blobs`, async ({browser, server}) => { + it(`should report download path within page.on('download', …) handler for Blobs`, async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); const onDownloadPath = new Promise(res => { page.on('download', dl => { @@ -282,7 +282,7 @@ it.describe('download event', () => { await page.close(); }); - it('should report alt-click downloads', async ({browser, server, browserName}) => { + it('should report alt-click downloads', async ({ browser, server, browserName }) => { it.fixme(browserName === 'firefox' || browserName === 'webkit'); // Firefox does not download on alt-click by default. @@ -297,7 +297,7 @@ it.describe('download event', () => { await page.setContent(`download`); const [ download ] = await Promise.all([ page.waitForEvent('download'), - page.click('a', { modifiers: ['Alt']}) + page.click('a', { modifiers: ['Alt'] }) ]); const path = await download.path(); expect(fs.existsSync(path)).toBeTruthy(); @@ -305,7 +305,7 @@ it.describe('download event', () => { await page.close(); }); - it('should report new window downloads', async ({browser, server}) => { + it('should report new window downloads', async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -317,7 +317,7 @@ it.describe('download event', () => { await page.close(); }); - it('should delete file', async ({browser, server}) => { + it('should delete file', async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -331,7 +331,7 @@ it.describe('download event', () => { await page.close(); }); - it('should expose stream', async ({browser, server}) => { + it('should expose stream', async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -346,7 +346,7 @@ it.describe('download event', () => { await page.close(); }); - it('should delete downloads on context destruction', async ({browser, server}) => { + it('should delete downloads on context destruction', async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); await page.setContent(`download`); const [ download1 ] = await Promise.all([ @@ -388,7 +388,7 @@ it.describe('download event', () => { expect(fs.existsSync(path.join(path1, '..'))).toBeFalsy(); }); - it('should close the context without awaiting the failed download', async ({browser, server, httpsServer, browserName, headless}, testInfo) => { + it('should close the context without awaiting the failed download', async ({ browser, server, httpsServer, browserName, headless }, testInfo) => { it.skip(browserName !== 'chromium', 'Only Chromium downloads on alt-click'); const page = await browser.newPage({ acceptDownloads: true }); @@ -398,7 +398,7 @@ it.describe('download event', () => { page.waitForEvent('download'), // Use alt-click to force the download. Otherwise browsers might try to navigate first, // probably because of http -> https link. - page.click('a', { modifiers: ['Alt']}) + page.click('a', { modifiers: ['Alt'] }) ]); const [downloadPath, saveError] = await Promise.all([ download.path(), @@ -412,7 +412,7 @@ it.describe('download event', () => { ]).toContain(saveError.message); }); - it('should close the context without awaiting the download', async ({browser, server, browserName, platform}, testInfo) => { + it('should close the context without awaiting the download', async ({ browser, server, browserName, platform }, testInfo) => { it.skip(browserName === 'webkit' && platform === 'linux', 'WebKit on linux does not convert to the download immediately upon receiving headers'); server.setRoute('/downloadStall', (req, res) => { @@ -444,7 +444,7 @@ it.describe('download event', () => { ]).toContain(saveError.message); }); - it('should throw if browser dies', async ({ server, browserType, browserName, browserOptions, platform}, testInfo) => { + it('should throw if browser dies', async ({ server, browserType, browserName, browserOptions, platform }, testInfo) => { it.skip(browserName === 'webkit' && platform === 'linux', 'WebKit on linux does not convert to the download immediately upon receiving headers'); server.setRoute('/downloadStall', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); @@ -471,7 +471,7 @@ it.describe('download event', () => { await browser.close(); }); - it('should download large binary.zip', async ({browser, server, browserName}, testInfo) => { + it('should download large binary.zip', async ({ browser, server, browserName }, testInfo) => { const zipFile = testInfo.outputPath('binary.zip'); const content = crypto.randomBytes(1 << 20); fs.writeFileSync(zipFile, content); @@ -501,7 +501,7 @@ it.describe('download event', () => { await page.close(); }); - it('should be able to cancel pending downloads', async ({browser, server, browserName, browserVersion}) => { + it('should be able to cancel pending downloads', async ({ browser, server, browserName, browserVersion }) => { // The exact upstream change is in b449b5c, which still does not appear in the first few 91.* tags until 91.0.4437.0. 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({ acceptDownloads: true }); @@ -516,7 +516,7 @@ it.describe('download event', () => { await page.close(); }); - it('should not fail explicitly to cancel a download even if that is already finished', async ({browser, server, browserName, browserVersion}) => { + it('should not fail explicitly to cancel a download even if that is already finished', async ({ browser, server, browserName, browserVersion }) => { // The exact upstream change is in b449b5c, which still does not appear in the first few 91.* tags until 91.0.4437.0. 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({ acceptDownloads: true }); @@ -534,7 +534,7 @@ it.describe('download event', () => { await page.close(); }); - it('should report downloads with interception', async ({browser, server}) => { + it('should report downloads with interception', async ({ browser, server }) => { const page = await browser.newPage({ acceptDownloads: true }); await page.route(/.*/, r => r.continue()); await page.setContent(`download`); diff --git a/tests/downloads-path.spec.ts b/tests/downloads-path.spec.ts index a5858da172..3dfaa2e4bb 100644 --- a/tests/downloads-path.spec.ts +++ b/tests/downloads-path.spec.ts @@ -19,7 +19,7 @@ import fs from 'fs'; import path from 'path'; it.describe('downloads path', () => { - it.beforeEach(async ({server}) => { + it.beforeEach(async ({ server }) => { server.setRoute('/download', (req, res) => { res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Disposition', 'attachment; filename=file.txt'); @@ -27,7 +27,7 @@ it.describe('downloads path', () => { }); }); - it('should keep downloadsPath folder', async ({browserType, browserOptions, server}, testInfo) => { + it('should keep downloadsPath folder', async ({ browserType, browserOptions, server }, testInfo) => { const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: testInfo.outputPath('') }); const page = await downloadsBrowser.newPage(); await page.setContent(`download`); @@ -43,7 +43,7 @@ it.describe('downloads path', () => { expect(fs.existsSync(testInfo.outputPath(''))).toBeTruthy(); }); - it('should delete downloads when context closes', async ({browserType, browserOptions, server}, testInfo) => { + it('should delete downloads when context closes', async ({ browserType, browserOptions, server }, testInfo) => { const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: testInfo.outputPath('') }); const page = await downloadsBrowser.newPage({ acceptDownloads: true }); await page.setContent(`download`); @@ -58,7 +58,7 @@ it.describe('downloads path', () => { await downloadsBrowser.close(); }); - it('should report downloads in downloadsPath folder', async ({browserType, browserOptions, server}, testInfo) => { + it('should report downloads in downloadsPath folder', async ({ browserType, browserOptions, server }, testInfo) => { const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: testInfo.outputPath('') }); const page = await downloadsBrowser.newPage({ acceptDownloads: true }); await page.setContent(`download`); @@ -72,7 +72,7 @@ it.describe('downloads path', () => { await downloadsBrowser.close(); }); - it('should report downloads in downloadsPath folder with a relative path', async ({browserType, browserOptions, server}, testInfo) => { + it('should report downloads in downloadsPath folder with a relative path', async ({ browserType, browserOptions, server }, testInfo) => { const downloadsBrowser = await browserType.launch({ ...browserOptions, downloadsPath: path.relative(process.cwd(), testInfo.outputPath('')) }); const page = await downloadsBrowser.newPage({ acceptDownloads: true }); await page.setContent(`download`); @@ -86,7 +86,7 @@ it.describe('downloads path', () => { await downloadsBrowser.close(); }); - it('should accept downloads in persistent context', async ({launchPersistent, server}, testInfo) => { + it('should accept downloads in persistent context', async ({ launchPersistent, server }, testInfo) => { const { context, page } = await launchPersistent({ acceptDownloads: true, downloadsPath: testInfo.outputPath('') }); await page.setContent(`download`); const [ download ] = await Promise.all([ @@ -100,7 +100,7 @@ it.describe('downloads path', () => { await context.close(); }); - it('should delete downloads when persistent context closes', async ({launchPersistent, server}, testInfo) => { + it('should delete downloads when persistent context closes', async ({ launchPersistent, server }, testInfo) => { const { context, page } = await launchPersistent({ acceptDownloads: true, downloadsPath: testInfo.outputPath('') }); await page.setContent(`download`); const [ download ] = await Promise.all([ diff --git a/tests/electron/electron-app.spec.ts b/tests/electron/electron-app.spec.ts index 93b15874b9..31ca614697 100644 --- a/tests/electron/electron-app.spec.ts +++ b/tests/electron/electron-app.spec.ts @@ -86,8 +86,8 @@ test('should wait for first window', async ({ electronApp }) => { test('should have a clipboard instance', async ({ electronApp }) => { const clipboardContentToWrite = 'Hello from Playwright'; - await electronApp.evaluate(async ({clipboard}, text) => clipboard.writeText(text), clipboardContentToWrite); - const clipboardContentRead = await electronApp.evaluate(async ({clipboard}) => clipboard.readText()); + await electronApp.evaluate(async ({ clipboard }, text) => clipboard.writeText(text), clipboardContentToWrite); + const clipboardContentRead = await electronApp.evaluate(async ({ clipboard }) => clipboard.readText()); expect(clipboardContentRead).toEqual(clipboardContentToWrite); }); @@ -108,7 +108,7 @@ test('should return browser window', async ({ playwright }) => { await electronApp.close(); }); -test('should bypass csp', async ({playwright, server}) => { +test('should bypass csp', async ({ playwright, server }) => { const app = await playwright._electron.launch({ args: [require('path').join(__dirname, 'electron-app.js')], bypassCSP: true, @@ -122,7 +122,7 @@ test('should bypass csp', async ({playwright, server}) => { }); const page = await app.firstWindow(); await page.goto(server.PREFIX + '/csp.html'); - await page.addScriptTag({content: 'window["__injected"] = 42;'}); + await page.addScriptTag({ content: 'window["__injected"] = 42;' }); expect(await page.evaluate('window["__injected"]')).toBe(42); await app.close(); }); diff --git a/tests/electron/electron-window.spec.ts b/tests/electron/electron-window.spec.ts index 14b5256335..735b62823a 100644 --- a/tests/electron/electron-window.spec.ts +++ b/tests/electron/electron-window.spec.ts @@ -16,28 +16,28 @@ import { electronTest as test, expect } from './electronTest'; -test('should click the button', async ({newWindow, server}) => { +test('should click the button', async ({ newWindow, server }) => { const window = await newWindow(); await window.goto(server.PREFIX + '/input/button.html'); await window.click('button'); expect(await window.evaluate('result')).toBe('Clicked'); }); -test('should check the box', async ({newWindow}) => { +test('should check the box', async ({ newWindow }) => { const window = await newWindow(); await window.setContent(``); await window.check('input'); expect(await window.evaluate('checkbox.checked')).toBe(true); }); -test('should not check the checked box', async ({newWindow}) => { +test('should not check the checked box', async ({ newWindow }) => { const window = await newWindow(); await window.setContent(``); await window.check('input'); expect(await window.evaluate('checkbox.checked')).toBe(true); }); -test('should type into a textarea', async ({newWindow}) => { +test('should type into a textarea', async ({ newWindow }) => { const window = await newWindow(); await window.evaluate(() => { const textarea = document.createElement('textarea'); diff --git a/tests/emulation-focus.spec.ts b/tests/emulation-focus.spec.ts index ef2772dff2..3e432073be 100644 --- a/tests/emulation-focus.spec.ts +++ b/tests/emulation-focus.spec.ts @@ -18,18 +18,18 @@ import { contextTest as it, browserTest, expect } from './config/browserTest'; import { attachFrame } from './config/utils'; -it('should think that it is focused by default', async ({page}) => { +it('should think that it is focused by default', async ({ page }) => { expect(await page.evaluate('document.hasFocus()')).toBe(true); }); -it('should think that all pages are focused', async ({page}) => { +it('should think that all pages are focused', async ({ page }) => { const page2 = await page.context().newPage(); expect(await page.evaluate('document.hasFocus()')).toBe(true); expect(await page2.evaluate('document.hasFocus()')).toBe(true); await page2.close(); }); -it('should focus popups by default', async ({page, server}) => { +it('should focus popups by default', async ({ page, server }) => { await page.goto(server.EMPTY_PAGE); const [popup] = await Promise.all([ page.waitForEvent('popup'), @@ -39,7 +39,7 @@ it('should focus popups by default', async ({page, server}) => { expect(await page.evaluate('document.hasFocus()')).toBe(true); }); -it('should provide target for keyboard events', async ({page, server}) => { +it('should provide target for keyboard events', async ({ page, server }) => { const page2 = await page.context().newPage(); await Promise.all([ page.goto(server.PREFIX + '/input/textarea.html'), @@ -62,7 +62,7 @@ it('should provide target for keyboard events', async ({page, server}) => { expect(results).toEqual([text, text2]); }); -it('should not affect mouse event target page', async ({page, server}) => { +it('should not affect mouse event target page', async ({ page, server }) => { const page2 = await page.context().newPage(); function clickCounter() { document.onclick = () => window['clickCount'] = (window['clickCount'] || 0) + 1; @@ -84,7 +84,7 @@ it('should not affect mouse event target page', async ({page, server}) => { expect(counters).toEqual([1,1]); }); -it('should change document.activeElement', async ({page, server}) => { +it('should change document.activeElement', async ({ page, server }) => { const page2 = await page.context().newPage(); await Promise.all([ page.goto(server.PREFIX + '/input/textarea.html'), @@ -101,14 +101,14 @@ it('should change document.activeElement', async ({page, server}) => { expect(active).toEqual(['INPUT', 'TEXTAREA']); }); -it('should not affect screenshots', async ({page, server, browserName, headless}) => { +it('should not affect screenshots', async ({ page, server, browserName, headless }) => { it.skip(browserName === 'firefox' && !headless, 'Firefox headede produces a different image'); const page2 = await page.context().newPage(); await Promise.all([ - page.setViewportSize({width: 500, height: 500}), + page.setViewportSize({ width: 500, height: 500 }), page.goto(server.PREFIX + '/grid.html'), - page2.setViewportSize({width: 50, height: 50}), + page2.setViewportSize({ width: 50, height: 50 }), page2.goto(server.PREFIX + '/grid.html'), ]); await Promise.all([ @@ -123,7 +123,7 @@ it('should not affect screenshots', async ({page, server, browserName, headless} expect(screenshots[1]).toMatchSnapshot('grid-cell-0.png'); }); -it('should change focused iframe', async ({page, server}) => { +it('should change focused iframe', async ({ page, server }) => { await page.goto(server.EMPTY_PAGE); const [frame1, frame2] = await Promise.all([ attachFrame(page, 'frame1', server.PREFIX + '/input/textarea.html'), @@ -172,7 +172,7 @@ it('should change focused iframe', async ({page, server}) => { }); // @see https://github.com/microsoft/playwright/issues/3476 -browserTest('should focus with more than one page/context', async ({contextFactory}) => { +browserTest('should focus with more than one page/context', async ({ contextFactory }) => { const page1 = await (await contextFactory()).newPage(); const page2 = await (await contextFactory()).newPage(); await page1.setContent(``); diff --git a/tests/favicon.spec.ts b/tests/favicon.spec.ts index 6685a212c3..82df7e7c68 100644 --- a/tests/favicon.spec.ts +++ b/tests/favicon.spec.ts @@ -17,7 +17,7 @@ import { contextTest as it } from './config/browserTest'; -it('should load svg favicon with prefer-color-scheme', async ({page, server, browserName, channel, headless, asset}) => { +it('should load svg favicon with prefer-color-scheme', async ({ page, server, browserName, channel, headless, asset }) => { it.skip(headless && browserName !== 'firefox', 'headless browsers, except firefox, do not request favicons'); it.skip(!headless && browserName === 'webkit' && !channel, 'headed webkit does not have a favicon feature'); diff --git a/tests/firefox/launcher.spec.ts b/tests/firefox/launcher.spec.ts index 2b53c4c2f3..1c9317f249 100644 --- a/tests/firefox/launcher.spec.ts +++ b/tests/firefox/launcher.spec.ts @@ -16,7 +16,7 @@ import { playwrightTest as it, expect } from '../config/browserTest'; -it('should pass firefox user preferences', async ({browserType, browserOptions, browserName}) => { +it('should pass firefox user preferences', async ({ browserType, browserOptions, browserName }) => { const browser = await browserType.launch({ ...browserOptions, firefoxUserPrefs: { diff --git a/tests/geolocation.spec.ts b/tests/geolocation.spec.ts index 298ca025ac..bb2b2d07f0 100644 --- a/tests/geolocation.spec.ts +++ b/tests/geolocation.spec.ts @@ -17,14 +17,14 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should work', async ({server, contextFactory}) => { +it('should work', async ({ server, contextFactory }) => { const context = await contextFactory(); const page = await context.newPage(); await context.grantPermissions(['geolocation']); await page.goto(server.EMPTY_PAGE); - await context.setGeolocation({longitude: 10, latitude: 10}); + await context.setGeolocation({ longitude: 10, latitude: 10 }); const geolocation = await page.evaluate(() => new Promise(resolve => navigator.geolocation.getCurrentPosition(position => { - resolve({latitude: position.coords.latitude, longitude: position.coords.longitude}); + resolve({ latitude: position.coords.latitude, longitude: position.coords.longitude }); }))); expect(geolocation).toEqual({ latitude: 10, @@ -32,33 +32,33 @@ it('should work', async ({server, contextFactory}) => { }); }); -it('should throw when invalid longitude', async ({contextFactory}) => { +it('should throw when invalid longitude', async ({ contextFactory }) => { const context = await contextFactory(); let error = null; try { - await context.setGeolocation({longitude: 200, latitude: 10}); + await context.setGeolocation({ longitude: 200, latitude: 10 }); } catch (e) { error = e; } expect(error.message).toContain('geolocation.longitude: precondition -180 <= LONGITUDE <= 180 failed.'); }); -it('should isolate contexts', async ({server, contextFactory, browser}) => { +it('should isolate contexts', async ({ server, contextFactory, browser }) => { const context = await contextFactory(); const page = await context.newPage(); await context.grantPermissions(['geolocation']); - await context.setGeolocation({longitude: 10, latitude: 10}); + await context.setGeolocation({ longitude: 10, latitude: 10 }); await page.goto(server.EMPTY_PAGE); const context2 = await browser.newContext({ permissions: ['geolocation'], - geolocation: {longitude: 20, latitude: 20} + geolocation: { longitude: 20, latitude: 20 } }); const page2 = await context2.newPage(); await page2.goto(server.EMPTY_PAGE); const geolocation = await page.evaluate(() => new Promise(resolve => navigator.geolocation.getCurrentPosition(position => { - resolve({latitude: position.coords.latitude, longitude: position.coords.longitude}); + resolve({ latitude: position.coords.latitude, longitude: position.coords.longitude }); }))); expect(geolocation).toEqual({ latitude: 10, @@ -66,7 +66,7 @@ it('should isolate contexts', async ({server, contextFactory, browser}) => { }); const geolocation2 = await page2.evaluate(() => new Promise(resolve => navigator.geolocation.getCurrentPosition(position => { - resolve({latitude: position.coords.latitude, longitude: position.coords.longitude}); + resolve({ latitude: position.coords.latitude, longitude: position.coords.longitude }); }))); expect(geolocation2).toEqual({ latitude: 20, @@ -76,19 +76,19 @@ it('should isolate contexts', async ({server, contextFactory, browser}) => { await context2.close(); }); -it('should throw with missing latitude', async ({contextFactory}) => { +it('should throw with missing latitude', async ({ contextFactory }) => { const context = await contextFactory(); let error = null; try { // @ts-expect-error setGeolocation must have latitude - await context.setGeolocation({longitude: 10}); + await context.setGeolocation({ longitude: 10 }); } catch (e) { error = e; } expect(error.message).toContain('geolocation.latitude: expected number, got undefined'); }); -it('should not modify passed default options object', async ({browser}) => { +it('should not modify passed default options object', async ({ browser }) => { const geolocation = { longitude: 10, latitude: 10 }; const options = { geolocation }; const context = await browser.newContext(options); @@ -97,11 +97,11 @@ it('should not modify passed default options object', async ({browser}) => { await context.close(); }); -it('should throw with missing longitude in default options', async ({browser}) => { +it('should throw with missing longitude in default options', async ({ browser }) => { let error = null; try { // @ts-expect-error geolocation must have longitude - const context = await browser.newContext({ geolocation: {latitude: 10} }); + const context = await browser.newContext({ geolocation: { latitude: 10 } }); await context.close(); } catch (e) { error = e; @@ -109,14 +109,14 @@ it('should throw with missing longitude in default options', async ({browser}) = expect(error.message).toContain('geolocation.longitude: expected number, got undefined'); }); -it('should use context options', async ({browser, server}) => { +it('should use context options', async ({ browser, server }) => { const options = { geolocation: { longitude: 10, latitude: 10 }, permissions: ['geolocation'] }; const context = await browser.newContext(options); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); const geolocation = await page.evaluate(() => new Promise(resolve => navigator.geolocation.getCurrentPosition(position => { - resolve({latitude: position.coords.latitude, longitude: position.coords.longitude}); + resolve({ latitude: position.coords.latitude, longitude: position.coords.longitude }); }))); expect(geolocation).toEqual({ latitude: 10, @@ -125,7 +125,7 @@ it('should use context options', async ({browser, server}) => { await context.close(); }); -it('watchPosition should be notified', async ({server, contextFactory}) => { +it('watchPosition should be notified', async ({ server, contextFactory }) => { const context = await contextFactory(); const page = await context.newPage(); await context.grantPermissions(['geolocation']); @@ -133,18 +133,18 @@ it('watchPosition should be notified', async ({server, contextFactory}) => { const messages = []; page.on('console', message => messages.push(message.text())); - await context.setGeolocation({latitude: 0, longitude: 0}); + await context.setGeolocation({ latitude: 0, longitude: 0 }); await page.evaluate(() => { navigator.geolocation.watchPosition(pos => { const coords = pos.coords; console.log(`lat=${coords.latitude} lng=${coords.longitude}`); }, err => {}); }); - await context.setGeolocation({latitude: 0, longitude: 10}); + await context.setGeolocation({ latitude: 0, longitude: 10 }); await page.waitForEvent('console', message => message.text().includes('lat=0 lng=10')); - await context.setGeolocation({latitude: 20, longitude: 30}); + await context.setGeolocation({ latitude: 20, longitude: 30 }); await page.waitForEvent('console', message => message.text().includes('lat=20 lng=30')); - await context.setGeolocation({latitude: 40, longitude: 50}); + await context.setGeolocation({ latitude: 40, longitude: 50 }); await page.waitForEvent('console', message => message.text().includes('lat=40 lng=50')); const allMessages = messages.join('|'); @@ -153,7 +153,7 @@ it('watchPosition should be notified', async ({server, contextFactory}) => { expect(allMessages).toContain('lat=40 lng=50'); }); -it('should use context options for popup', async ({contextFactory, server}) => { +it('should use context options for popup', async ({ contextFactory, server }) => { const context = await contextFactory(); const page = await context.newPage(); await context.grantPermissions(['geolocation']); diff --git a/tests/global-fetch.spec.ts b/tests/global-fetch.spec.ts index b5021d822f..28ecc82c92 100644 --- a/tests/global-fetch.spec.ts +++ b/tests/global-fetch.spec.ts @@ -38,7 +38,7 @@ it.afterAll(() => { }); for (const method of ['get', 'post', 'fetch']) { - it(`${method} should work`, async ({playwright, server}) => { + it(`${method} should work`, async ({ playwright, server }) => { const request = await playwright._newRequest(); const response = await request[method](server.PREFIX + '/simple.json'); expect(response.url()).toBe(server.PREFIX + '/simple.json'); @@ -51,7 +51,7 @@ for (const method of ['get', 'post', 'fetch']) { expect(await response.text()).toBe('{"foo": "bar"}\n'); }); - it(`should dispose global ${method} request`, async function({playwright, context, server}) { + it(`should dispose global ${method} request`, async function({ playwright, context, server }) { const request = await playwright._newRequest(); const response = await request.get(server.PREFIX + '/simple.json'); expect(await response.json()).toEqual({ foo: 'bar' }); @@ -61,8 +61,8 @@ for (const method of ['get', 'post', 'fetch']) { }); } -it('should support global userAgent option', async ({playwright, server}) => { - const request = await playwright._newRequest({ userAgent: 'My Agent'}); +it('should support global userAgent option', async ({ playwright, server }) => { + const request = await playwright._newRequest({ userAgent: 'My Agent' }); const [serverRequest, response] = await Promise.all([ server.waitForRequest('/empty.html'), request.get(server.EMPTY_PAGE) @@ -72,17 +72,17 @@ it('should support global userAgent option', async ({playwright, server}) => { expect(serverRequest.headers['user-agent']).toBe('My Agent'); }); -it('should support global timeout option', async ({playwright, server}) => { - const request = await playwright._newRequest({ timeout: 1}); +it('should support global timeout option', async ({ playwright, server }) => { + const request = await playwright._newRequest({ timeout: 1 }); server.setRoute('/empty.html', (req, res) => {}); const error = await request.get(server.EMPTY_PAGE).catch(e => e); expect(error.message).toContain('Request timed out after 1ms'); }); -it('should propagate extra http headers with redirects', async ({playwright, server}) => { +it('should propagate extra http headers with redirects', async ({ playwright, server }) => { server.setRedirect('/a/redirect1', '/b/c/redirect2'); server.setRedirect('/b/c/redirect2', '/simple.json'); - const request = await playwright._newRequest({ extraHTTPHeaders: { 'My-Secret': 'Value' }}); + const request = await playwright._newRequest({ extraHTTPHeaders: { 'My-Secret': 'Value' } }); const [req1, req2, req3] = await Promise.all([ server.waitForRequest('/a/redirect1'), server.waitForRequest('/b/c/redirect2'), @@ -94,27 +94,27 @@ it('should propagate extra http headers with redirects', async ({playwright, ser expect(req3.headers['my-secret']).toBe('Value'); }); -it('should support global httpCredentials option', async ({playwright, server}) => { +it('should support global httpCredentials option', async ({ playwright, server }) => { server.setAuth('/empty.html', 'user', 'pass'); const request1 = await playwright._newRequest(); const response1 = await request1.get(server.EMPTY_PAGE); expect(response1.status()).toBe(401); await request1.dispose(); - const request2 = await playwright._newRequest({ httpCredentials: { username: 'user', password: 'pass' }}); + const request2 = await playwright._newRequest({ httpCredentials: { username: 'user', password: 'pass' } }); const response2 = await request2.get(server.EMPTY_PAGE); expect(response2.status()).toBe(200); await request2.dispose(); }); -it('should return error with wrong credentials', async ({playwright, server}) => { +it('should return error with wrong credentials', async ({ playwright, server }) => { server.setAuth('/empty.html', 'user', 'pass'); - const request = await playwright._newRequest({ httpCredentials: { username: 'user', password: 'wrong' }}); + const request = await playwright._newRequest({ httpCredentials: { username: 'user', password: 'wrong' } }); const response2 = await request.get(server.EMPTY_PAGE); expect(response2.status()).toBe(401); }); -it('should pass proxy credentials', async ({playwright, server, proxyServer}) => { +it('should pass proxy credentials', async ({ playwright, server, proxyServer }) => { proxyServer.forwardTo(server.PORT); let auth; proxyServer.setAuthHandler(req => { @@ -127,17 +127,17 @@ it('should pass proxy credentials', async ({playwright, server, proxyServer}) => const response = await request.get('http://non-existent.com/simple.json'); expect(proxyServer.connectHosts).toContain('non-existent.com:80'); expect(auth).toBe('Basic ' + Buffer.from('user:secret').toString('base64')); - expect(await response.json()).toEqual({foo: 'bar'}); + expect(await response.json()).toEqual({ foo: 'bar' }); await request.dispose(); }); -it('should support global ignoreHTTPSErrors option', async ({playwright, httpsServer}) => { +it('should support global ignoreHTTPSErrors option', async ({ playwright, httpsServer }) => { const request = await playwright._newRequest({ ignoreHTTPSErrors: true }); const response = await request.get(httpsServer.EMPTY_PAGE); expect(response.status()).toBe(200); }); -it('should resolve url relative to gobal baseURL option', async ({playwright, server}) => { +it('should resolve url relative to gobal baseURL option', async ({ playwright, server }) => { const request = await playwright._newRequest({ baseURL: server.PREFIX }); const response = await request.get('/empty.html'); expect(response.url()).toBe(server.EMPTY_PAGE); diff --git a/tests/har.spec.ts b/tests/har.spec.ts index f4c0871458..fdff14f50c 100644 --- a/tests/har.spec.ts +++ b/tests/har.spec.ts @@ -423,9 +423,9 @@ it('should have security details', async ({ contextFactory, httpsServer, browser expect(serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/); expect(port).toBe(httpsServer.PORT); if (browserName === 'webkit' && platform === 'darwin') - expect(securityDetails).toEqual({protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863}); + expect(securityDetails).toEqual({ protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863 }); else - expect(securityDetails).toEqual({issuer: 'puppeteer-tests', protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863}); + expect(securityDetails).toEqual({ issuer: 'puppeteer-tests', protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863 }); }); it('should have connection details for redirects', async ({ contextFactory, server, browserName }, testInfo) => { @@ -479,11 +479,11 @@ it('should return security details directly from response', async ({ contextFact const response = await page.goto(httpsServer.EMPTY_PAGE); const securityDetails = await response.securityDetails(); if (browserName === 'webkit' && platform === 'win32') - expect(securityDetails).toEqual({subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: -1}); + expect(securityDetails).toEqual({ subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: -1 }); else if (browserName === 'webkit') - expect(securityDetails).toEqual({protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863}); + expect(securityDetails).toEqual({ protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863 }); else - expect(securityDetails).toEqual({issuer: 'puppeteer-tests', protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863}); + expect(securityDetails).toEqual({ issuer: 'puppeteer-tests', protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863 }); }); it('should contain http2 for http2 requests', async ({ contextFactory, browserName, platform }, testInfo) => { @@ -512,7 +512,7 @@ it('should contain http2 for http2 requests', async ({ contextFactory, browserNa server.close(); }); -it('should filter favicon and favicon redirects', async ({server, browserName, channel, headless, asset, contextFactory}, testInfo) => { +it('should filter favicon and favicon redirects', async ({ server, browserName, channel, headless, asset, contextFactory }, testInfo) => { it.skip(headless && browserName !== 'firefox', 'headless browsers, except firefox, do not request favicons'); it.skip(!headless && browserName === 'webkit' && !channel, 'headed webkit does not have a favicon feature'); diff --git a/tests/headful.spec.ts b/tests/headful.spec.ts index c6a7a00964..f33a130f3d 100644 --- a/tests/headful.spec.ts +++ b/tests/headful.spec.ts @@ -16,17 +16,17 @@ import { playwrightTest as it, expect } from './config/browserTest'; -it('should have default url when launching browser', async ({browserType, browserOptions, createUserDataDir}) => { - const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), {...browserOptions, headless: false }); +it('should have default url when launching browser', async ({ browserType, browserOptions, createUserDataDir }) => { + const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { ...browserOptions, headless: false }); const urls = browserContext.pages().map(page => page.url()); expect(urls).toEqual(['about:blank']); await browserContext.close(); }); -it('should close browser with beforeunload page', async ({browserType, browserOptions, server, createUserDataDir}) => { +it('should close browser with beforeunload page', async ({ browserType, browserOptions, server, createUserDataDir }) => { it.slow(); - const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), {...browserOptions, headless: false}); + const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { ...browserOptions, headless: false }); const page = await browserContext.newPage(); await page.goto(server.PREFIX + '/beforeunload.html'); // We have to interact with a page so that 'beforeunload' handlers @@ -35,8 +35,8 @@ it('should close browser with beforeunload page', async ({browserType, browserOp await browserContext.close(); }); -it('should not crash when creating second context', async ({browserType, browserOptions}) => { - const browser = await browserType.launch({...browserOptions, headless: false }); +it('should not crash when creating second context', async ({ browserType, browserOptions }) => { + const browser = await browserType.launch({ ...browserOptions, headless: false }); { const browserContext = await browser.newContext(); await browserContext.newPage(); @@ -50,8 +50,8 @@ it('should not crash when creating second context', async ({browserType, browser await browser.close(); }); -it('should click background tab', async ({browserType, browserOptions, server}) => { - const browser = await browserType.launch({...browserOptions, headless: false }); +it('should click background tab', async ({ browserType, browserOptions, server }) => { + const browser = await browserType.launch({ ...browserOptions, headless: false }); const page = await browser.newPage(); await page.setContent(`empty.html`); await page.click('a'); @@ -59,16 +59,16 @@ it('should click background tab', async ({browserType, browserOptions, server}) await browser.close(); }); -it('should close browser after context menu was triggered', async ({browserType, browserOptions, server}) => { - const browser = await browserType.launch({...browserOptions, headless: false }); +it('should close browser after context menu was triggered', async ({ browserType, browserOptions, server }) => { + const browser = await browserType.launch({ ...browserOptions, headless: false }); const page = await browser.newPage(); await page.goto(server.PREFIX + '/grid.html'); - await page.click('body', {button: 'right'}); + await page.click('body', { button: 'right' }); await browser.close(); }); -it('should(not) block third party cookies', async ({browserType, browserOptions, server, browserName}) => { - const browser = await browserType.launch({...browserOptions, headless: false }); +it('should(not) block third party cookies', async ({ browserType, browserOptions, server, browserName }) => { + const browser = await browserType.launch({ ...browserOptions, headless: false }); const page = await browser.newPage(); await page.goto(server.EMPTY_PAGE); await page.evaluate(src => { @@ -107,11 +107,11 @@ it('should(not) block third party cookies', async ({browserType, browserOptions, await browser.close(); }); -it('should not override viewport size when passed null', async function({browserType, browserOptions, server, browserName}) { +it('should not override viewport size when passed null', async function({ browserType, browserOptions, server, browserName }) { it.fixme(browserName === 'webkit'); // Our WebKit embedder does not respect window features. - const browser = await browserType.launch({...browserOptions, headless: false }); + const browser = await browserType.launch({ ...browserOptions, headless: false }); const context = await browser.newContext({ viewport: null }); const page = await context.newPage(); await page.goto(server.EMPTY_PAGE); @@ -128,8 +128,8 @@ it('should not override viewport size when passed null', async function({browser await browser.close(); }); -it('Page.bringToFront should work', async ({browserType, browserOptions}) => { - const browser = await browserType.launch({...browserOptions, headless: false }); +it('Page.bringToFront should work', async ({ browserType, browserOptions }) => { + const browser = await browserType.launch({ ...browserOptions, headless: false }); const page1 = await browser.newPage(); await page1.setContent('Page1'); const page2 = await browser.newPage(); diff --git a/tests/ignorehttpserrors.spec.ts b/tests/ignorehttpserrors.spec.ts index 5fb6b58143..bcdf8b841d 100644 --- a/tests/ignorehttpserrors.spec.ts +++ b/tests/ignorehttpserrors.spec.ts @@ -17,7 +17,7 @@ import { browserTest as it, expect } from './config/browserTest'; -it('should work', async ({browser, httpsServer}) => { +it('should work', async ({ browser, httpsServer }) => { let error = null; const context = await browser.newContext({ ignoreHTTPSErrors: true }); const page = await context.newPage(); @@ -27,7 +27,7 @@ it('should work', async ({browser, httpsServer}) => { await context.close(); }); -it('should isolate contexts', async ({browser, httpsServer}) => { +it('should isolate contexts', async ({ browser, httpsServer }) => { { let error = null; const context = await browser.newContext({ ignoreHTTPSErrors: true }); @@ -47,13 +47,13 @@ it('should isolate contexts', async ({browser, httpsServer}) => { } }); -it('should work with mixed content', async ({browser, server, httpsServer}) => { +it('should work with mixed content', async ({ browser, server, httpsServer }) => { httpsServer.setRoute('/mixedcontent.html', (req, res) => { res.end(``); }); const context = await browser.newContext({ ignoreHTTPSErrors: true }); const page = await context.newPage(); - await page.goto(httpsServer.PREFIX + '/mixedcontent.html', {waitUntil: 'domcontentloaded'}); + await page.goto(httpsServer.PREFIX + '/mixedcontent.html', { waitUntil: 'domcontentloaded' }); expect(page.frames().length).toBe(2); // Make sure blocked iframe has functional execution context // @see https://github.com/GoogleChrome/puppeteer/issues/2709 @@ -62,7 +62,7 @@ it('should work with mixed content', async ({browser, server, httpsServer}) => { await context.close(); }); -it('should work with WebSocket', async ({browser, httpsServer}) => { +it('should work with WebSocket', async ({ browser, httpsServer }) => { httpsServer.sendOnWebSocketConnection('incoming'); const context = await browser.newContext({ ignoreHTTPSErrors: true }); const page = await context.newPage(); @@ -78,7 +78,7 @@ it('should work with WebSocket', async ({browser, httpsServer}) => { await context.close(); }); -it('should fail with WebSocket if not ignored', async ({browser, httpsServer}) => { +it('should fail with WebSocket if not ignored', async ({ browser, httpsServer }) => { const context = await browser.newContext(); const page = await context.newPage(); const value = await page.evaluate(endpoint => { diff --git a/tests/inspector/pause.spec.ts b/tests/inspector/pause.spec.ts index d27bc63692..422930176d 100644 --- a/tests/inspector/pause.spec.ts +++ b/tests/inspector/pause.spec.ts @@ -18,7 +18,7 @@ import { Page } from '../../index'; import { test as it, expect } from './inspectorTest'; -it('should resume when closing inspector', async ({page, recorderPageGetter, closeRecorder, mode}) => { +it('should resume when closing inspector', async ({ page, recorderPageGetter, closeRecorder, mode }) => { it.skip(mode !== 'default'); const scriptPromise = (async () => { @@ -50,7 +50,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should resume from console', async ({page}) => { + it('should resume from console', async ({ page }) => { const scriptPromise = (async () => { await page.pause(); })(); @@ -62,7 +62,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should pause after a navigation', async ({page, server, recorderPageGetter}) => { + it('should pause after a navigation', async ({ page, server, recorderPageGetter }) => { const scriptPromise = (async () => { await page.goto(server.EMPTY_PAGE); await page.pause(); @@ -72,7 +72,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should show source', async ({page, recorderPageGetter}) => { + it('should show source', async ({ page, recorderPageGetter }) => { const scriptPromise = (async () => { await page.pause(); })(); @@ -83,7 +83,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should pause on next pause', async ({page, recorderPageGetter}) => { + it('should pause on next pause', async ({ page, recorderPageGetter }) => { const scriptPromise = (async () => { await page.pause(); // 1 await page.pause(); // 2 @@ -97,7 +97,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should step', async ({page, recorderPageGetter}) => { + it('should step', async ({ page, recorderPageGetter }) => { await page.setContent(''); const scriptPromise = (async () => { await page.pause(); @@ -114,7 +114,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should highlight pointer', async ({page, recorderPageGetter}) => { + it('should highlight pointer', async ({ page, recorderPageGetter }) => { await page.setContent(''); const scriptPromise = (async () => { await page.pause(); @@ -140,7 +140,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should skip input when resuming', async ({page, recorderPageGetter}) => { + it('should skip input when resuming', async ({ page, recorderPageGetter }) => { await page.setContent(''); const scriptPromise = (async () => { await page.pause(); @@ -154,7 +154,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should populate log', async ({page, recorderPageGetter}) => { + it('should populate log', async ({ page, recorderPageGetter }) => { await page.setContent(''); const scriptPromise = (async () => { await page.pause(); @@ -173,7 +173,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should highlight waitForEvent', async ({page, recorderPageGetter}) => { + it('should highlight waitForEvent', async ({ page, recorderPageGetter }) => { await page.setContent(''); const scriptPromise = (async () => { await page.pause(); @@ -190,7 +190,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should populate log with waitForEvent', async ({page, recorderPageGetter}) => { + it('should populate log with waitForEvent', async ({ page, recorderPageGetter }) => { await page.setContent(''); const scriptPromise = (async () => { await page.pause(); @@ -213,7 +213,7 @@ it.describe('pause', () => { await scriptPromise; }); - it('should populate log with error', async ({page, recorderPageGetter}) => { + it('should populate log with error', async ({ page, recorderPageGetter }) => { await page.setContent(''); const scriptPromise = (async () => { await page.pause(); @@ -233,7 +233,7 @@ it.describe('pause', () => { expect(error.message).toContain('Not a checkbox or radio button'); }); - it('should populate log with error in waitForEvent', async ({page, recorderPageGetter}) => { + it('should populate log with error in waitForEvent', async ({ page, recorderPageGetter }) => { await page.setContent(''); const scriptPromise = (async () => { await page.pause(); diff --git a/tests/launcher.spec.ts b/tests/launcher.spec.ts index a33c666bfc..24403e063b 100644 --- a/tests/launcher.spec.ts +++ b/tests/launcher.spec.ts @@ -22,14 +22,14 @@ it('should require top-level Errors', async ({}) => { expect(String(Errors.TimeoutError)).toContain('TimeoutError'); }); -it('should require top-level DeviceDescriptors', async ({playwright}) => { +it('should require top-level DeviceDescriptors', async ({ playwright }) => { const Devices = require('../lib/server/deviceDescriptors.js'); expect(Devices['iPhone 6']).toBeTruthy(); expect(Devices['iPhone 6']).toEqual(playwright.devices['iPhone 6']); expect(playwright.devices['iPhone 6'].defaultBrowserType).toBe('webkit'); }); -it('should kill browser process on timeout after close', async ({browserType, browserOptions, mode}) => { +it('should kill browser process on timeout after close', async ({ browserType, browserOptions, mode }) => { it.skip(mode !== 'default', 'Test passes server hooks via options'); const launchOptions = { ...browserOptions }; diff --git a/tests/logger.spec.ts b/tests/logger.spec.ts index 2d58930e31..b26c69959e 100644 --- a/tests/logger.spec.ts +++ b/tests/logger.spec.ts @@ -16,12 +16,12 @@ import { playwrightTest as it, expect } from './config/browserTest'; -it('should log', async ({browserType, browserOptions}) => { +it('should log', async ({ browserType, browserOptions }) => { const log = []; - const browser = await browserType.launch({...browserOptions, logger: { - log: (name, severity, message) => log.push({name, severity, message}), + const browser = await browserType.launch({ ...browserOptions, logger: { + log: (name, severity, message) => log.push({ name, severity, message }), isEnabled: (name, severity) => severity !== 'verbose' - }}); + } }); await browser.newContext(); await browser.close(); expect(log.length > 0).toBeTruthy(); @@ -30,12 +30,12 @@ it('should log', async ({browserType, browserOptions}) => { expect(log.filter(item => item.message.includes('browserType.launch succeeded')).length > 0).toBeTruthy(); }); -it('should log context-level', async ({browserType, browserOptions}) => { +it('should log context-level', async ({ browserType, browserOptions }) => { const log = []; const browser = await browserType.launch(browserOptions); const context = await browser.newContext({ logger: { - log: (name, severity, message) => log.push({name, severity, message}), + log: (name, severity, message) => log.push({ name, severity, message }), isEnabled: (name, severity) => severity !== 'verbose' } }); diff --git a/tests/page/elementhandle-convenience.spec.ts b/tests/page/elementhandle-convenience.spec.ts index 736eada2d5..039fbecee8 100644 --- a/tests/page/elementhandle-convenience.spec.ts +++ b/tests/page/elementhandle-convenience.spec.ts @@ -195,7 +195,7 @@ it('isVisible and isHidden should work', async ({ page }) => { expect(await page.isHidden('no-such-element')).toBe(true); }); -it('element state checks should work for label with zero-sized input', async ({page, server}) => { +it('element state checks should work for label with zero-sized input', async ({ page, server }) => { await page.setContent(`