From 4bc8cf0d4790edb7137db403a19c4a3510d35bf9 Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Fri, 7 Feb 2025 12:05:04 -0800 Subject: [PATCH 01/11] feat(recorder): display primary page URL in recorder title (#34637) --- .../playwright-core/src/server/recorder.ts | 5 +- .../src/server/recorder/recorderApp.ts | 10 +-- .../src/server/recorder/recorderFrontend.ts | 2 +- packages/recorder/src/main.tsx | 38 +++++---- packages/recorder/src/recorderTypes.d.ts | 2 +- tests/library/inspector/title.spec.ts | 83 +++++++++++++++++++ 6 files changed, 115 insertions(+), 25 deletions(-) create mode 100644 tests/library/inspector/title.spec.ts diff --git a/packages/playwright-core/src/server/recorder.ts b/packages/playwright-core/src/server/recorder.ts index 59705c2eb4..9fbe4962d2 100644 --- a/packages/playwright-core/src/server/recorder.ts +++ b/packages/playwright-core/src/server/recorder.ts @@ -32,6 +32,7 @@ import type * as actions from '@recorder/actions'; import { stringifySelector } from '../utils/isomorphic/selectorParser'; import type { Frame } from './frames'; import type { AriaTemplateNode } from '@isomorphic/ariaSnapshot'; +import type { Page } from './page'; const recorderSymbol = Symbol('recorderSymbol'); @@ -148,6 +149,7 @@ export class Recorder implements InstrumentationListener, IRecorder { this._context.instrumentation.removeListener(this); this._recorderApp?.close().catch(() => {}); }); + this._contextRecorder.on(ContextRecorder.Events.Change, (data: { sources: Source[], actions: actions.ActionInContext[] }) => { this._recorderSources = data.sources; recorderApp.setActions(data.actions, data.sources); @@ -346,7 +348,8 @@ export class Recorder implements InstrumentationListener, IRecorder { } private _pushAllSources() { - this._recorderApp?.setSources([...this._recorderSources, ...this._userSources.values()]); + const primaryPage: Page | undefined = this._context.pages()[0]; + this._recorderApp?.setSources([...this._recorderSources, ...this._userSources.values()], primaryPage?.mainFrame().url()); } async onBeforeInputAction(sdkObject: SdkObject, metadata: CallMetadata) { diff --git a/packages/playwright-core/src/server/recorder/recorderApp.ts b/packages/playwright-core/src/server/recorder/recorderApp.ts index f8971531cf..05ac4cd0dd 100644 --- a/packages/playwright-core/src/server/recorder/recorderApp.ts +++ b/packages/playwright-core/src/server/recorder/recorderApp.ts @@ -37,7 +37,7 @@ export class EmptyRecorderApp extends EventEmitter implements IRecorderApp { async setRunningFile(file: string | undefined): Promise {} async elementPicked(elementInfo: ElementInfo, userGesture?: boolean): Promise {} async updateCallLogs(callLogs: CallLog[]): Promise {} - async setSources(sources: Source[]): Promise {} + async setSources(sources: Source[], primaryPageURL: string | undefined): Promise {} async setActions(actions: actions.ActionInContext[], sources: Source[]): Promise {} } @@ -143,10 +143,10 @@ export class RecorderApp extends EventEmitter implements IRecorderApp { }).toString(), { isFunction: true }, paused).catch(() => {}); } - async setSources(sources: Source[]): Promise { - await this._page.mainFrame().evaluateExpression(((sources: Source[]) => { - window.playwrightSetSources(sources); - }).toString(), { isFunction: true }, sources).catch(() => {}); + async setSources(sources: Source[], primaryPageURL: string | undefined): Promise { + await this._page.mainFrame().evaluateExpression((({ sources, primaryPageURL }: { sources: Source[], primaryPageURL: string | undefined }) => { + window.playwrightSetSources(sources, primaryPageURL); + }).toString(), { isFunction: true }, { sources, primaryPageURL }).catch(() => {}); // Testing harness for runCLI mode. if (process.env.PWTEST_CLI_IS_UNDER_TEST && sources.length) { diff --git a/packages/playwright-core/src/server/recorder/recorderFrontend.ts b/packages/playwright-core/src/server/recorder/recorderFrontend.ts index b3dc0daad9..c6fb6e0a1c 100644 --- a/packages/playwright-core/src/server/recorder/recorderFrontend.ts +++ b/packages/playwright-core/src/server/recorder/recorderFrontend.ts @@ -32,7 +32,7 @@ export interface IRecorderApp extends EventEmitter { setRunningFile(file: string | undefined): Promise; elementPicked(elementInfo: ElementInfo, userGesture?: boolean): Promise; updateCallLogs(callLogs: CallLog[]): Promise; - setSources(sources: Source[]): Promise; + setSources(sources: Source[], primaryPageURL: string | undefined): Promise; setActions(actions: actions.ActionInContext[], sources: Source[]): Promise; } diff --git a/packages/recorder/src/main.tsx b/packages/recorder/src/main.tsx index 61ac9da67f..4ecfc97760 100644 --- a/packages/recorder/src/main.tsx +++ b/packages/recorder/src/main.tsx @@ -19,29 +19,33 @@ import * as React from 'react'; import { Recorder } from './recorder'; import './recorder.css'; -export const Main: React.FC = ({ -}) => { +export const Main: React.FC = ({}) => { const [sources, setSources] = React.useState([]); const [paused, setPaused] = React.useState(false); const [log, setLog] = React.useState(new Map()); const [mode, setMode] = React.useState('none'); - window.playwrightSetMode = setMode; - window.playwrightSetSources = React.useCallback((sources: Source[]) => { - setSources(sources); - window.playwrightSourcesEchoForTest = sources; + React.useLayoutEffect(() => { + window.playwrightSetMode = setMode; + window.playwrightSetSources = (sources, primaryPageURL) => { + setSources(sources); + window.playwrightSourcesEchoForTest = sources; + document.title = primaryPageURL + ? `Playwright Inspector - ${primaryPageURL}` + : `Playwright Inspector`; + }; + window.playwrightSetPaused = setPaused; + window.playwrightUpdateLogs = callLogs => { + setLog(log => { + const newLog = new Map(log); + for (const callLog of callLogs) { + callLog.reveal = !log.has(callLog.id); + newLog.set(callLog.id, callLog); + } + return newLog; + }); + }; }, []); - window.playwrightSetPaused = setPaused; - window.playwrightUpdateLogs = callLogs => { - setLog(log => { - const newLog = new Map(log); - for (const callLog of callLogs) { - callLog.reveal = !log.has(callLog.id); - newLog.set(callLog.id, callLog); - } - return newLog; - }); - }; return ; }; diff --git a/packages/recorder/src/recorderTypes.d.ts b/packages/recorder/src/recorderTypes.d.ts index 22561608ae..ae4c41f4f7 100644 --- a/packages/recorder/src/recorderTypes.d.ts +++ b/packages/recorder/src/recorderTypes.d.ts @@ -101,7 +101,7 @@ declare global { interface Window { playwrightSetMode: (mode: Mode) => void; playwrightSetPaused: (paused: boolean) => void; - playwrightSetSources: (sources: Source[]) => void; + playwrightSetSources: (sources: Source[], primaryPageURL: string | undefined) => void; playwrightSetOverlayVisible: (visible: boolean) => void; playwrightUpdateLogs: (callLogs: CallLog[]) => void; playwrightSetRunningFile: (file: string | undefined) => void; diff --git a/tests/library/inspector/title.spec.ts b/tests/library/inspector/title.spec.ts new file mode 100644 index 0000000000..edd73be21a --- /dev/null +++ b/tests/library/inspector/title.spec.ts @@ -0,0 +1,83 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { test, expect } from './inspectorTest'; + +test('should reflect formatted URL of the page', async ({ + openRecorder, + server, +}) => { + const { recorder } = await openRecorder(); + await recorder.setContentAndWait(''); + await expect(recorder.recorderPage).toHaveTitle( + 'Playwright Inspector - about:blank', + ); + + await recorder.setContentAndWait('', server.EMPTY_PAGE); + await expect(recorder.recorderPage).toHaveTitle( + `Playwright Inspector - ${server.EMPTY_PAGE}`, + ); +}); + +test('should update primary page URL when original primary closes', async ({ + context, + openRecorder, + server, +}) => { + const { recorder } = await openRecorder(); + await recorder.setContentAndWait( + '', + `${server.PREFIX}/background-color.html`, + ); + await expect(recorder.recorderPage).toHaveTitle( + `Playwright Inspector - ${server.PREFIX}/background-color.html`, + ); + + const page2 = await context.newPage(); + await page2.goto(`${server.PREFIX}/empty.html`); + await expect(recorder.recorderPage).toHaveTitle( + `Playwright Inspector - ${server.PREFIX}/background-color.html`, + ); + + const page3 = await context.newPage(); + await page3.goto(`${server.PREFIX}/dom.html`); + await expect(recorder.recorderPage).toHaveTitle( + `Playwright Inspector - ${server.PREFIX}/background-color.html`, + ); + + const page4 = await context.newPage(); + await page4.goto(`${server.PREFIX}/grid.html`); + await expect(recorder.recorderPage).toHaveTitle( + `Playwright Inspector - ${server.PREFIX}/background-color.html`, + ); + + await page2.close(); + await expect(recorder.recorderPage).toHaveTitle( + `Playwright Inspector - ${server.PREFIX}/background-color.html`, + ); + + await recorder.page.close(); + // URL will not update without performing some action + await page3.getByRole('checkbox').click(); + await expect(recorder.recorderPage).toHaveTitle( + `Playwright Inspector - ${server.PREFIX}/dom.html`, + ); + + await page3.close(); + await expect(recorder.recorderPage).toHaveTitle( + `Playwright Inspector - ${server.PREFIX}/grid.html`, + ); +}); From 4a7f6a6ef04cef79fc46aa9b5421f2ff52c2b85c Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 7 Feb 2025 13:54:01 -0800 Subject: [PATCH 02/11] chore: organize imports in playwright-core (#34680) --- eslint.config.mjs | 22 +- package-lock.json | 263 ++++++++++++++++-- package.json | 1 + .../bundles/utils/src/utilsBundleImpl.ts | 2 + .../playwright-core/src/androidServerImpl.ts | 13 +- .../playwright-core/src/browserServerImpl.ts | 19 +- packages/playwright-core/src/cli/driver.ts | 10 +- packages/playwright-core/src/cli/program.ts | 35 +-- .../src/client/accessibility.ts | 2 +- .../playwright-core/src/client/android.ts | 24 +- packages/playwright-core/src/client/api.ts | 4 +- .../playwright-core/src/client/artifact.ts | 6 +- .../playwright-core/src/client/browser.ts | 24 +- .../src/client/browserContext.ts | 51 ++-- .../playwright-core/src/client/browserType.ts | 11 +- .../playwright-core/src/client/cdpSession.ts | 5 +- .../src/client/channelOwner.ts | 8 +- .../src/client/clientHelper.ts | 6 +- .../src/client/clientInstrumentation.ts | 2 +- packages/playwright-core/src/client/clock.ts | 2 +- .../playwright-core/src/client/connection.ts | 43 +-- .../src/client/consoleMessage.ts | 6 +- .../playwright-core/src/client/coverage.ts | 2 +- packages/playwright-core/src/client/dialog.ts | 6 +- .../playwright-core/src/client/download.ts | 4 +- .../playwright-core/src/client/electron.ts | 21 +- .../src/client/elementHandle.ts | 32 ++- packages/playwright-core/src/client/errors.ts | 5 +- .../src/client/eventEmitter.ts | 9 +- packages/playwright-core/src/client/fetch.ts | 24 +- .../playwright-core/src/client/fileChooser.ts | 2 +- packages/playwright-core/src/client/frame.ts | 39 +-- .../playwright-core/src/client/harRouter.ts | 1 + packages/playwright-core/src/client/input.ts | 4 +- .../playwright-core/src/client/jsHandle.ts | 10 +- .../playwright-core/src/client/jsonPipe.ts | 3 +- .../playwright-core/src/client/localUtils.ts | 3 +- .../playwright-core/src/client/locator.ts | 15 +- .../playwright-core/src/client/network.ts | 28 +- packages/playwright-core/src/client/page.ts | 38 +-- .../playwright-core/src/client/playwright.ts | 5 +- .../playwright-core/src/client/selectors.ts | 8 +- packages/playwright-core/src/client/stream.ts | 4 +- .../playwright-core/src/client/tracing.ts | 5 +- packages/playwright-core/src/client/types.ts | 4 +- packages/playwright-core/src/client/video.ts | 7 +- packages/playwright-core/src/client/waiter.ts | 7 +- .../playwright-core/src/client/webError.ts | 2 +- packages/playwright-core/src/client/worker.ts | 16 +- .../src/client/writableStream.ts | 4 +- .../playwright-core/src/common/socksProxy.ts | 8 +- .../src/image_tools/compare.ts | 2 +- .../playwright-core/src/inProcessFactory.ts | 9 +- packages/playwright-core/src/outofprocess.ts | 9 +- .../playwright-core/src/protocol/validator.ts | 1 + .../src/remote/playwrightConnection.ts | 17 +- .../src/remote/playwrightServer.ts | 20 +- .../src/server/android/android.ts | 36 +-- .../src/server/android/backendAdb.ts | 11 +- .../playwright-core/src/server/artifact.ts | 7 +- .../src/server/bidi/bidiBrowser.ts | 20 +- .../src/server/bidi/bidiChromium.ts | 13 +- .../src/server/bidi/bidiConnection.ts | 10 +- .../src/server/bidi/bidiExecutionContext.ts | 3 +- .../src/server/bidi/bidiFirefox.ts | 15 +- .../src/server/bidi/bidiInput.ts | 7 +- .../src/server/bidi/bidiNetworkManager.ts | 15 +- .../src/server/bidi/bidiOverCdp.ts | 8 +- .../src/server/bidi/bidiPage.ts | 25 +- .../src/server/bidi/bidiPdf.ts | 3 +- .../server/bidi/third_party/firefoxPrefs.ts | 4 +- .../playwright-core/src/server/browser.ts | 22 +- .../src/server/browserContext.ts | 42 +-- .../playwright-core/src/server/browserType.ts | 43 +-- .../src/server/chromium/chromium.ts | 50 ++-- .../src/server/chromium/crAccessibility.ts | 2 +- .../src/server/chromium/crBrowser.ts | 34 +-- .../src/server/chromium/crConnection.ts | 14 +- .../src/server/chromium/crCoverage.ts | 12 +- .../src/server/chromium/crDevTools.ts | 3 +- .../src/server/chromium/crDragDrop.ts | 6 +- .../src/server/chromium/crExecutionContext.ts | 7 +- .../src/server/chromium/crInput.ts | 8 +- .../src/server/chromium/crNetworkManager.ts | 16 +- .../src/server/chromium/crPage.ts | 25 +- .../src/server/chromium/crPdf.ts | 7 +- .../src/server/chromium/crProtocolHelper.ts | 11 +- .../src/server/chromium/crServiceWorker.ts | 7 +- .../src/server/chromium/videoRecorder.ts | 9 +- packages/playwright-core/src/server/clock.ts | 3 +- .../src/server/codegen/csharp.ts | 9 +- .../src/server/codegen/java.ts | 11 +- .../src/server/codegen/javascript.ts | 11 +- .../src/server/codegen/jsonl.ts | 3 +- .../src/server/codegen/language.ts | 2 +- .../src/server/codegen/languages.ts | 2 +- .../src/server/codegen/python.ts | 11 +- .../src/server/codegen/types.ts | 2 +- .../playwright-core/src/server/console.ts | 2 +- .../playwright-core/src/server/cookieStore.ts | 3 +- .../src/server/debugController.ts | 18 +- .../playwright-core/src/server/debugger.ts | 4 +- .../src/server/deviceDescriptors.ts | 5 +- packages/playwright-core/src/server/dialog.ts | 3 +- .../server/dispatchers/androidDispatcher.ts | 11 +- .../server/dispatchers/artifactDispatcher.ts | 8 +- .../dispatchers/browserContextDispatcher.ts | 46 +-- .../server/dispatchers/browserDispatcher.ts | 13 +- .../dispatchers/browserTypeDispatcher.ts | 11 +- .../dispatchers/cdpSessionDispatcher.ts | 7 +- .../dispatchers/debugControllerDispatcher.ts | 8 +- .../server/dispatchers/dialogDispatcher.ts | 5 +- .../src/server/dispatchers/dispatcher.ts | 15 +- .../server/dispatchers/electronDispatcher.ts | 16 +- .../dispatchers/elementHandlerDispatcher.ts | 18 +- .../src/server/dispatchers/frameDispatcher.ts | 11 +- .../server/dispatchers/jsHandleDispatcher.ts | 7 +- .../server/dispatchers/jsonPipeDispatcher.ts | 3 +- .../dispatchers/localUtilsDispatcher.ts | 48 ++-- .../server/dispatchers/networkDispatchers.ts | 16 +- .../src/server/dispatchers/pageDispatcher.ts | 29 +- .../dispatchers/playwrightDispatcher.ts | 20 +- .../server/dispatchers/selectorsDispatcher.ts | 5 +- .../server/dispatchers/streamDispatcher.ts | 5 +- .../server/dispatchers/tracingDispatcher.ts | 7 +- .../dispatchers/webSocketRouteDispatcher.ts | 17 +- .../dispatchers/writableStreamDispatcher.ts | 6 +- packages/playwright-core/src/server/dom.ts | 27 +- .../playwright-core/src/server/download.ts | 3 +- .../src/server/electron/electron.ts | 58 ++-- .../src/server/electron/loader.ts | 1 + packages/playwright-core/src/server/errors.ts | 5 +- packages/playwright-core/src/server/fetch.ts | 36 +-- .../src/server/fileUploadUtils.ts | 8 +- .../src/server/firefox/ffBrowser.ts | 18 +- .../src/server/firefox/ffConnection.ts | 9 +- .../src/server/firefox/ffExecutionContext.ts | 7 +- .../src/server/firefox/ffNetworkManager.ts | 9 +- .../src/server/firefox/ffPage.ts | 19 +- .../src/server/firefox/firefox.ts | 10 +- .../playwright-core/src/server/formData.ts | 1 + .../src/server/frameSelectors.ts | 15 +- packages/playwright-core/src/server/frames.ts | 48 ++-- .../src/server/har/harRecorder.ts | 22 +- .../src/server/har/harTracer.ts | 21 +- packages/playwright-core/src/server/helper.ts | 10 +- packages/playwright-core/src/server/index.ts | 6 +- .../src/server/injected/ariaSnapshot.ts | 6 +- .../src/server/injected/consoleApi.ts | 7 +- .../src/server/injected/highlight.ts | 12 +- .../src/server/injected/injectedScript.ts | 52 ++-- .../server/injected/reactSelectorEngine.ts | 3 +- .../injected/recorder/pollingRecorder.ts | 7 +- .../src/server/injected/recorder/recorder.ts | 13 +- .../src/server/injected/roleSelectorEngine.ts | 8 +- .../src/server/injected/roleUtils.ts | 3 +- .../src/server/injected/selectorEvaluator.ts | 11 +- .../src/server/injected/selectorGenerator.ts | 7 +- .../src/server/injected/selectorUtils.ts | 5 +- .../src/server/injected/utilityScript.ts | 2 +- .../src/server/injected/vueSelectorEngine.ts | 3 +- packages/playwright-core/src/server/input.ts | 5 +- .../src/server/instrumentation.ts | 13 +- .../playwright-core/src/server/javascript.ts | 11 +- .../playwright-core/src/server/launchApp.ts | 15 +- .../playwright-core/src/server/network.ts | 22 +- packages/playwright-core/src/server/page.ts | 55 ++-- .../src/server/pipeTransport.ts | 3 +- .../playwright-core/src/server/playwright.ts | 26 +- .../playwright-core/src/server/progress.ts | 5 +- .../playwright-core/src/server/recorder.ts | 20 +- .../src/server/recorder/chat.ts | 1 + .../src/server/recorder/contextRecorder.ts | 17 +- .../src/server/recorder/recorderApp.ts | 16 +- .../src/server/recorder/recorderCollection.ts | 12 +- .../src/server/recorder/recorderFrontend.ts | 2 +- .../src/server/recorder/recorderRunner.ts | 7 +- .../src/server/recorder/recorderUtils.ts | 6 +- .../src/server/registry/browserFetcher.ts | 17 +- .../src/server/registry/dependencies.ts | 16 +- .../src/server/registry/index.ts | 32 ++- .../server/registry/oopDownloadBrowserMain.ts | 7 +- .../src/server/screenshotter.ts | 16 +- .../playwright-core/src/server/selectors.ts | 4 +- .../socksClientCertificatesInterceptor.ts | 26 +- .../src/server/socksInterceptor.ts | 8 +- .../src/server/storageScript.ts | 2 +- .../src/server/trace/recorder/snapshotter.ts | 17 +- .../src/server/trace/recorder/tracing.ts | 39 +-- .../server/trace/test/inMemorySnapshotter.ts | 20 +- .../src/server/trace/viewer/traceViewer.ts | 18 +- .../playwright-core/src/server/transport.ts | 9 +- packages/playwright-core/src/server/types.ts | 4 +- .../src/server/webkit/webkit.ts | 16 +- .../src/server/webkit/wkAccessibility.ts | 2 +- .../src/server/webkit/wkBrowser.ts | 17 +- .../src/server/webkit/wkConnection.ts | 9 +- .../src/server/webkit/wkExecutionContext.ts | 7 +- .../src/server/webkit/wkInput.ts | 9 +- .../server/webkit/wkInterceptableRequest.ts | 6 +- .../src/server/webkit/wkPage.ts | 33 ++- .../src/server/webkit/wkProvisionalPage.ts | 7 +- .../src/server/webkit/wkWorkers.ts | 7 +- .../playwright-core/src/utils/comparators.ts | 4 +- packages/playwright-core/src/utils/crypto.ts | 3 +- .../playwright-core/src/utils/debugLogger.ts | 3 +- .../playwright-core/src/utils/expectUtils.ts | 3 +- .../playwright-core/src/utils/fileUtils.ts | 8 +- .../src/utils/happy-eyeballs.ts | 3 +- .../playwright-core/src/utils/hostPlatform.ts | 3 +- .../playwright-core/src/utils/httpServer.ts | 14 +- .../src/utils/isomorphic/locatorGenerators.ts | 4 +- .../src/utils/isomorphic/locatorParser.ts | 5 +- .../src/utils/isomorphic/selectorParser.ts | 3 +- .../playwright-core/src/utils/linuxUtils.ts | 2 +- packages/playwright-core/src/utils/network.ts | 12 +- .../src/utils/processLauncher.ts | 6 +- .../playwright-core/src/utils/spawnAsync.ts | 3 +- .../playwright-core/src/utils/stackTrace.ts | 6 +- .../playwright-core/src/utils/traceUtils.ts | 2 +- .../playwright-core/src/utils/userAgent.ts | 5 +- .../playwright-core/src/utils/wsServer.ts | 8 +- packages/playwright-core/src/utils/zipFile.ts | 3 +- packages/playwright-core/src/utilsBundle.ts | 8 +- packages/playwright-core/src/zipBundle.ts | 2 +- utils/generate_channels.js | 1 + 226 files changed, 1800 insertions(+), 1216 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index a604e14f13..97b29eb05f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,6 +20,7 @@ import notice from 'eslint-plugin-notice'; import path from 'path'; import { fileURLToPath } from 'url'; import stylistic from '@stylistic/eslint-plugin'; +import importRules from 'eslint-plugin-import'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -28,6 +29,7 @@ const plugins = { '@stylistic': stylistic, '@typescript-eslint': typescriptEslint, notice, + import: importRules, }; const ignores = [ @@ -57,7 +59,7 @@ const ignores = [ export const baseRules = { '@typescript-eslint/no-unused-vars': [2, { args: 'none', caughtErrors: 'none' }], - '@typescript-eslint/consistent-type-imports': [2, { disallowTypeAnnotations: false }], + /** * Enforced rules */ @@ -184,6 +186,19 @@ const noRestrictedGlobalsRules = { ], }; +const importOrderRules = { + 'import/order': [2, { + 'alphabetize': { + 'order': 'asc', + 'caseInsensitive': false + }, + 'named': true, + 'groups': ['builtin', 'external', 'internal', ['parent', 'sibling'], 'index', 'type'], + 'newlines-between': 'always', + }], + 'import/consistent-type-specifier-style': [2, 'prefer-top-level'] +}; + const languageOptions = { parser: tsParser, ecmaVersion: 9, @@ -217,6 +232,11 @@ export default [{ 'message': 'Please use gracefullyProcessExitDoNotHang function to exit the process.', }], } +}, { + files: ['packages/playwright-core/**/*.ts'], + rules: { + ...importOrderRules + }, }, { files: ['packages/playwright/**/*.ts'], rules: { diff --git a/package-lock.json b/package-lock.json index be17fabc1b..6b59e3ab0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,6 +52,7 @@ "electron": "^30.1.2", "esbuild": "^0.18.11", "eslint": "^9.19.0", + "eslint-plugin-import": "^2.31.0", "eslint-plugin-notice": "^1.0.0", "eslint-plugin-react": "^7.37.4", "eslint-plugin-react-hooks": "^5.1.0", @@ -1817,6 +1818,13 @@ "win32" ] }, + "node_modules/@rtsao/scc": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", + "integrity": "sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==", + "dev": true, + "license": "MIT" + }, "node_modules/@sindresorhus/is": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", @@ -2019,6 +2027,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/keyv": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", @@ -2717,6 +2732,27 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/array.prototype.findlastindex": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.5.tgz", + "integrity": "sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/array.prototype.flat": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", @@ -3536,6 +3572,19 @@ "wrappy": "1" } }, + "node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -3920,6 +3969,145 @@ } } }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/eslint-module-utils": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.12.0.tgz", + "integrity": "sha512-wALZ0HFoytlyh/1+4wuZ9FJCD/leWHQzzrxJ8+rebyReSLk7LApMyd3WJaLVoN+D5+WIdJyDK1c6JnE65V4Zyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^3.2.7" + }, + "engines": { + "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import": { + "version": "2.31.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.31.0.tgz", + "integrity": "sha512-ixmkI62Rbc2/w8Vfxyh1jQRTdRTF52VxwRVHl/ykPAmqG+Nb7/kNn+byLP0LxPgI7zWA16Jt82SybJInmMia3A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rtsao/scc": "^1.1.0", + "array-includes": "^3.1.8", + "array.prototype.findlastindex": "^1.2.5", + "array.prototype.flat": "^1.3.2", + "array.prototype.flatmap": "^1.3.2", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.12.0", + "hasown": "^2.0.2", + "is-core-module": "^2.15.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.8", + "object.groupby": "^1.0.3", + "object.values": "^1.2.0", + "semver": "^6.3.1", + "string.prototype.trimend": "^1.0.8", + "tsconfig-paths": "^3.15.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9" + } + }, + "node_modules/eslint-plugin-import/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/eslint-plugin-notice": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-notice/-/eslint-plugin-notice-1.0.0.tgz", @@ -3991,18 +4179,6 @@ "concat-map": "0.0.1" } }, - "node_modules/eslint-plugin-react/node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/eslint-plugin-react/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -5105,12 +5281,16 @@ } }, "node_modules/is-core-module": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", - "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", "dev": true, + "license": "MIT", "dependencies": { - "hasown": "^2.0.0" + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -6104,6 +6284,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/object.groupby": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.3.tgz", + "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/object.values": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.2.1.tgz", @@ -7287,6 +7482,16 @@ "node": ">=8" } }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -7424,6 +7629,32 @@ "typescript": ">=4.8.4" } }, + "node_modules/tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tsconfig-paths/node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", diff --git a/package.json b/package.json index 49483a5dbf..30578abf1b 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "electron": "^30.1.2", "esbuild": "^0.18.11", "eslint": "^9.19.0", + "eslint-plugin-import": "^2.31.0", "eslint-plugin-notice": "^1.0.0", "eslint-plugin-react": "^7.37.4", "eslint-plugin-react-hooks": "^5.1.0", diff --git a/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts b/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts index 5c8434f907..5e94036ae3 100644 --- a/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts +++ b/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +/* eslint-disable import/order */ + import colorsLibrary from 'colors/safe'; export const colors = colorsLibrary; diff --git a/packages/playwright-core/src/androidServerImpl.ts b/packages/playwright-core/src/androidServerImpl.ts index f0108e67c7..aee8bf7b31 100644 --- a/packages/playwright-core/src/androidServerImpl.ts +++ b/packages/playwright-core/src/androidServerImpl.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { LaunchAndroidServerOptions } from './client/types'; -import { ws } from './utilsBundle'; -import type { WebSocketEventEmitter } from './utilsBundle'; -import type { BrowserServer } from './client/browserType'; -import { createGuid } from './utils'; -import { createPlaywright } from './server/playwright'; import { PlaywrightServer } from './remote/playwrightServer'; +import { createPlaywright } from './server/playwright'; +import { createGuid } from './utils'; +import { ws } from './utilsBundle'; + +import type { BrowserServer } from './client/browserType'; +import type { LaunchAndroidServerOptions } from './client/types'; +import type { WebSocketEventEmitter } from './utilsBundle'; export class AndroidServerLauncherImpl { async launchServer(options: LaunchAndroidServerOptions = {}): Promise { diff --git a/packages/playwright-core/src/browserServerImpl.ts b/packages/playwright-core/src/browserServerImpl.ts index d59c95bfb1..f76f852bed 100644 --- a/packages/playwright-core/src/browserServerImpl.ts +++ b/packages/playwright-core/src/browserServerImpl.ts @@ -14,19 +14,20 @@ * limitations under the License. */ -import type { LaunchServerOptions, Logger } from './client/types'; -import { ws } from './utilsBundle'; -import type { WebSocketEventEmitter } from './utilsBundle'; -import type { BrowserServerLauncher, BrowserServer } from './client/browserType'; import { envObjectToArray } from './client/clientHelper'; -import { createGuid } from './utils'; -import type { ProtocolLogger } from './server/types'; -import { serverSideCallMetadata } from './server/instrumentation'; -import { createPlaywright } from './server/playwright'; +import { SocksProxy } from './common/socksProxy'; import { PlaywrightServer } from './remote/playwrightServer'; import { helper } from './server/helper'; +import { serverSideCallMetadata } from './server/instrumentation'; +import { createPlaywright } from './server/playwright'; +import { createGuid } from './utils'; import { rewriteErrorMessage } from './utils/stackTrace'; -import { SocksProxy } from './common/socksProxy'; +import { ws } from './utilsBundle'; + +import type { BrowserServer, BrowserServerLauncher } from './client/browserType'; +import type { LaunchServerOptions, Logger } from './client/types'; +import type { ProtocolLogger } from './server/types'; +import type { WebSocketEventEmitter } from './utilsBundle'; export class BrowserServerLauncherImpl implements BrowserServerLauncher { private _browserName: 'chromium' | 'firefox' | 'webkit' | 'bidiFirefox' | 'bidiChromium'; diff --git a/packages/playwright-core/src/cli/driver.ts b/packages/playwright-core/src/cli/driver.ts index e48dc2a4d2..0e4cbb5816 100644 --- a/packages/playwright-core/src/cli/driver.ts +++ b/packages/playwright-core/src/cli/driver.ts @@ -16,15 +16,17 @@ /* eslint-disable no-console */ -import fs from 'fs'; +import * as fs from 'fs'; + import * as playwright from '../..'; -import type { BrowserType } from '../client/browserType'; -import type { LaunchServerOptions } from '../client/types'; -import { createPlaywright, DispatcherConnection, RootDispatcher, PlaywrightDispatcher } from '../server'; import { PipeTransport } from '../protocol/transport'; import { PlaywrightServer } from '../remote/playwrightServer'; +import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from '../server'; import { gracefullyProcessExitDoNotHang } from '../utils/processLauncher'; +import type { BrowserType } from '../client/browserType'; +import type { LaunchServerOptions } from '../client/types'; + export function printApiJson() { // Note: this file is generated by build-playwright-driver.sh console.log(JSON.stringify(require('../../api.json'))); diff --git a/packages/playwright-core/src/cli/program.ts b/packages/playwright-core/src/cli/program.ts index ce568b8dd3..2c0a955207 100644 --- a/packages/playwright-core/src/cli/program.ts +++ b/packages/playwright-core/src/cli/program.ts @@ -16,25 +16,28 @@ /* eslint-disable no-console */ -import fs from 'fs'; -import os from 'os'; -import path from 'path'; -import type { Command } from '../utilsBundle'; -import { program, dotenv } from '../utilsBundle'; -export { program } from '../utilsBundle'; -import { runDriver, runServer, printApiJson, launchBrowserServer } from './driver'; -import { runTraceInBrowser, runTraceViewerApp } from '../server/trace/viewer/traceViewer'; -import type { TraceViewerServerOptions } from '../server/trace/viewer/traceViewer'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + import * as playwright from '../..'; -import type { BrowserContext } from '../client/browserContext'; -import type { Browser } from '../client/browser'; -import type { Page } from '../client/page'; -import type { BrowserType } from '../client/browserType'; -import type { BrowserContextOptions, LaunchOptions } from '../client/types'; -import { wrapInASCIIBox, isLikelyNpxGlobal, assert, gracefullyProcessExitDoNotHang, getPackageManagerExecCommand } from '../utils'; -import type { Executable } from '../server'; import { registry, writeDockerVersion } from '../server'; +import { launchBrowserServer, printApiJson, runDriver, runServer } from './driver'; import { isTargetClosedError } from '../client/errors'; +import { runTraceInBrowser, runTraceViewerApp } from '../server/trace/viewer/traceViewer'; +import { assert, getPackageManagerExecCommand, gracefullyProcessExitDoNotHang, isLikelyNpxGlobal, wrapInASCIIBox } from '../utils'; +import { dotenv, program } from '../utilsBundle'; + +import type { Browser } from '../client/browser'; +import type { BrowserContext } from '../client/browserContext'; +import type { BrowserType } from '../client/browserType'; +import type { Page } from '../client/page'; +import type { BrowserContextOptions, LaunchOptions } from '../client/types'; +import type { Executable } from '../server'; +import type { TraceViewerServerOptions } from '../server/trace/viewer/traceViewer'; +import type { Command } from '../utilsBundle'; + +export { program } from '../utilsBundle'; const packageJSON = require('../../package.json'); diff --git a/packages/playwright-core/src/client/accessibility.ts b/packages/playwright-core/src/client/accessibility.ts index a3390d8c58..02db39e801 100644 --- a/packages/playwright-core/src/client/accessibility.ts +++ b/packages/playwright-core/src/client/accessibility.ts @@ -15,9 +15,9 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import type { ElementHandle } from './elementHandle'; import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; type SerializedAXNode = Omit & { value?: string|number, diff --git a/packages/playwright-core/src/client/android.ts b/packages/playwright-core/src/client/android.ts index 07912bfbdd..1f4b89ed8a 100644 --- a/packages/playwright-core/src/client/android.ts +++ b/packages/playwright-core/src/client/android.ts @@ -14,22 +14,24 @@ * limitations under the License. */ -import fs from 'fs'; -import { isString, isRegExp, monotonicTime } from '../utils'; -import type * as channels from '@protocol/channels'; -import { Events } from './events'; +import { EventEmitter } from 'events'; +import * as fs from 'fs'; + +import { isRegExp, isString, monotonicTime } from '../utils'; import { BrowserContext, prepareBrowserContextParams } from './browserContext'; import { ChannelOwner } from './channelOwner'; -import type * as api from '../../types/types'; -import type * as types from './types'; -import type { Page } from './page'; -import { TimeoutSettings } from '../common/timeoutSettings'; -import { Waiter } from './waiter'; -import { EventEmitter } from 'events'; import { Connection } from './connection'; -import { isTargetClosedError, TargetClosedError } from './errors'; +import { TargetClosedError, isTargetClosedError } from './errors'; +import { Events } from './events'; +import { Waiter } from './waiter'; +import { TimeoutSettings } from '../common/timeoutSettings'; import { raceAgainstDeadline } from '../utils/timeoutRunner'; + +import type { Page } from './page'; +import type * as types from './types'; +import type * as api from '../../types/types'; import type { AndroidServerLauncherImpl } from '../androidServerImpl'; +import type * as channels from '@protocol/channels'; type Direction = 'down' | 'up' | 'left' | 'right'; type SpeedOptions = { speed?: number }; diff --git a/packages/playwright-core/src/client/api.ts b/packages/playwright-core/src/client/api.ts index 0d3d2448fe..7273ea244a 100644 --- a/packages/playwright-core/src/client/api.ts +++ b/packages/playwright-core/src/client/api.ts @@ -15,7 +15,7 @@ */ export { Accessibility } from './accessibility'; -export { Android, AndroidDevice, AndroidWebView, AndroidInput, AndroidSocket } from './android'; +export { Android, AndroidDevice, AndroidInput, AndroidSocket, AndroidWebView } from './android'; export { Browser } from './browser'; export { BrowserContext } from './browserContext'; export type { BrowserServer } from './browserType'; @@ -26,7 +26,7 @@ export { Coverage } from './coverage'; export { Dialog } from './dialog'; export { Download } from './download'; export { Electron, ElectronApplication } from './electron'; -export { Locator, FrameLocator } from './locator'; +export { FrameLocator, Locator } from './locator'; export { ElementHandle } from './elementHandle'; export { FileChooser } from './fileChooser'; export type { Logger } from './types'; diff --git a/packages/playwright-core/src/client/artifact.ts b/packages/playwright-core/src/client/artifact.ts index c3a53c0294..1874ba0c1d 100644 --- a/packages/playwright-core/src/client/artifact.ts +++ b/packages/playwright-core/src/client/artifact.ts @@ -14,11 +14,13 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import * as fs from 'fs'; + +import { ChannelOwner } from './channelOwner'; import { Stream } from './stream'; import { mkdirIfNeeded } from '../utils/fileUtils'; -import { ChannelOwner } from './channelOwner'; + +import type * as channels from '@protocol/channels'; import type { Readable } from 'stream'; export class Artifact extends ChannelOwner { diff --git a/packages/playwright-core/src/client/browser.ts b/packages/playwright-core/src/client/browser.ts index 10cac4d0f9..444074ba54 100644 --- a/packages/playwright-core/src/client/browser.ts +++ b/packages/playwright-core/src/client/browser.ts @@ -14,20 +14,22 @@ * limitations under the License. */ -import fs from 'fs'; -import type * as channels from '@protocol/channels'; -import { BrowserContext, prepareBrowserContextParams } from './browserContext'; -import type { Page } from './page'; -import { ChannelOwner } from './channelOwner'; -import { Events } from './events'; -import type { LaunchOptions, BrowserContextOptions, HeadersArray } from './types'; -import { isTargetClosedError } from './errors'; -import type * as api from '../../types/types'; -import { CDPSession } from './cdpSession'; -import type { BrowserType } from './browserType'; +import * as fs from 'fs'; + import { Artifact } from './artifact'; +import { BrowserContext, prepareBrowserContextParams } from './browserContext'; +import { CDPSession } from './cdpSession'; +import { ChannelOwner } from './channelOwner'; +import { isTargetClosedError } from './errors'; +import { Events } from './events'; import { mkdirIfNeeded } from '../utils'; +import type { BrowserType } from './browserType'; +import type { Page } from './page'; +import type { BrowserContextOptions, HeadersArray, LaunchOptions } from './types'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; + export class Browser extends ChannelOwner implements api.Browser { readonly _contexts = new Set(); private _isConnected = true; diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.ts index 83655887e6..a8417d896b 100644 --- a/packages/playwright-core/src/client/browserContext.ts +++ b/packages/playwright-core/src/client/browserContext.ts @@ -15,35 +15,38 @@ * limitations under the License. */ -import { Page, BindingCall } from './page'; -import { Frame } from './frame'; -import * as network from './network'; -import type * as channels from '@protocol/channels'; -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { Artifact } from './artifact'; +import { Browser } from './browser'; +import { CDPSession } from './cdpSession'; import { ChannelOwner } from './channelOwner'; import { evaluationScript } from './clientHelper'; -import { Browser } from './browser'; -import { Worker } from './worker'; -import { Events } from './events'; -import { TimeoutSettings } from '../common/timeoutSettings'; -import { Waiter } from './waiter'; -import type { Headers, WaitForEventOptions, BrowserContextOptions, LaunchOptions, StorageState } from './types'; -import { type URLMatch, headersObjectToArray, isRegExp, isString, urlMatchesEqual, mkdirIfNeeded } from '../utils'; -import type * as api from '../../types/types'; -import type * as structs from '../../types/structs'; -import { CDPSession } from './cdpSession'; -import { Tracing } from './tracing'; -import type { BrowserType } from './browserType'; -import { Artifact } from './artifact'; -import { APIRequestContext } from './fetch'; -import { rewriteErrorMessage } from '../utils/stackTrace'; -import { HarRouter } from './harRouter'; +import { Clock } from './clock'; import { ConsoleMessage } from './consoleMessage'; import { Dialog } from './dialog'; -import { WebError } from './webError'; import { TargetClosedError, parseError } from './errors'; -import { Clock } from './clock'; +import { Events } from './events'; +import { APIRequestContext } from './fetch'; +import { Frame } from './frame'; +import { HarRouter } from './harRouter'; +import * as network from './network'; +import { BindingCall, Page } from './page'; +import { Tracing } from './tracing'; +import { Waiter } from './waiter'; +import { WebError } from './webError'; +import { Worker } from './worker'; +import { TimeoutSettings } from '../common/timeoutSettings'; +import { headersObjectToArray, isRegExp, isString, mkdirIfNeeded, urlMatchesEqual } from '../utils'; +import { rewriteErrorMessage } from '../utils/stackTrace'; + +import type { BrowserType } from './browserType'; +import type { BrowserContextOptions, Headers, LaunchOptions, StorageState, WaitForEventOptions } from './types'; +import type * as structs from '../../types/structs'; +import type * as api from '../../types/types'; +import type { URLMatch } from '../utils'; +import type * as channels from '@protocol/channels'; export class BrowserContext extends ChannelOwner implements api.BrowserContext { _pages = new Set(); diff --git a/packages/playwright-core/src/client/browserType.ts b/packages/playwright-core/src/client/browserType.ts index 1932d6e2d8..36b9fe4d7e 100644 --- a/packages/playwright-core/src/client/browserType.ts +++ b/packages/playwright-core/src/client/browserType.ts @@ -14,19 +14,20 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { Browser } from './browser'; import { BrowserContext, prepareBrowserContextParams } from './browserContext'; import { ChannelOwner } from './channelOwner'; -import type { LaunchOptions, LaunchServerOptions, ConnectOptions, LaunchPersistentContextOptions, Logger } from './types'; +import { envObjectToArray } from './clientHelper'; import { Connection } from './connection'; import { Events } from './events'; -import type { ChildProcess } from 'child_process'; -import { envObjectToArray } from './clientHelper'; import { assert, headersObjectToArray, monotonicTime } from '../utils'; -import type * as api from '../../types/types'; import { raceAgainstDeadline } from '../utils/timeoutRunner'; + import type { Playwright } from './playwright'; +import type { ConnectOptions, LaunchOptions, LaunchPersistentContextOptions, LaunchServerOptions, Logger } from './types'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; +import type { ChildProcess } from 'child_process'; export interface BrowserServerLauncher { launchServer(options?: LaunchServerOptions): Promise; diff --git a/packages/playwright-core/src/client/cdpSession.ts b/packages/playwright-core/src/client/cdpSession.ts index 68d1cb57f8..0a58f79d27 100644 --- a/packages/playwright-core/src/client/cdpSession.ts +++ b/packages/playwright-core/src/client/cdpSession.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { ChannelOwner } from './channelOwner'; -import type { Protocol } from '../server/chromium/protocol'; + import type * as api from '../../types/types'; +import type { Protocol } from '../server/chromium/protocol'; +import type * as channels from '@protocol/channels'; export class CDPSession extends ChannelOwner implements api.CDPSession { static from(cdpSession: channels.CDPSessionChannel): CDPSession { diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.ts index d48ba439f0..2624be7282 100644 --- a/packages/playwright-core/src/client/channelOwner.ts +++ b/packages/playwright-core/src/client/channelOwner.ts @@ -15,15 +15,17 @@ */ import { EventEmitter } from './eventEmitter'; -import type * as channels from '@protocol/channels'; -import { maybeFindValidator, ValidationError, type ValidatorContext } from '../protocol/validator'; +import { ValidationError, maybeFindValidator } from '../protocol/validator'; +import { isUnderTest } from '../utils'; import { debugLogger } from '../utils/debugLogger'; import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/stackTrace'; -import { isUnderTest } from '../utils'; import { zones } from '../utils/zones'; + import type { ClientInstrumentation } from './clientInstrumentation'; import type { Connection } from './connection'; import type { Logger } from './types'; +import type { ValidatorContext } from '../protocol/validator'; +import type * as channels from '@protocol/channels'; type Listener = (...args: any[]) => void; diff --git a/packages/playwright-core/src/client/clientHelper.ts b/packages/playwright-core/src/client/clientHelper.ts index 540230a4fc..88e5babddd 100644 --- a/packages/playwright-core/src/client/clientHelper.ts +++ b/packages/playwright-core/src/client/clientHelper.ts @@ -15,10 +15,12 @@ * limitations under the License. */ -import type * as types from './types'; -import fs from 'fs'; +import * as fs from 'fs'; + import { isString } from '../utils'; +import type * as types from './types'; + export function envObjectToArray(env: types.Env): { name: string, value: string }[] { const result: { name: string, value: string }[] = []; for (const name in env) { diff --git a/packages/playwright-core/src/client/clientInstrumentation.ts b/packages/playwright-core/src/client/clientInstrumentation.ts index e2e8c6678e..479a88003d 100644 --- a/packages/playwright-core/src/client/clientInstrumentation.ts +++ b/packages/playwright-core/src/client/clientInstrumentation.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type { StackFrame } from '@protocol/channels'; import type { BrowserContext } from './browserContext'; import type { APIRequestContext } from './fetch'; +import type { StackFrame } from '@protocol/channels'; // Instrumentation can mutate the data, for example change apiName or stepId. export interface ApiCallData { diff --git a/packages/playwright-core/src/client/clock.ts b/packages/playwright-core/src/client/clock.ts index 73eb538c26..fdc7789b59 100644 --- a/packages/playwright-core/src/client/clock.ts +++ b/packages/playwright-core/src/client/clock.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import type * as api from '../../types/types'; import type { BrowserContext } from './browserContext'; +import type * as api from '../../types/types'; export class Clock implements api.Clock { private _browserContext: BrowserContext; diff --git a/packages/playwright-core/src/client/connection.ts b/packages/playwright-core/src/client/connection.ts index 375a84265f..30eba37cf0 100644 --- a/packages/playwright-core/src/client/connection.ts +++ b/packages/playwright-core/src/client/connection.ts @@ -14,37 +14,40 @@ * limitations under the License. */ +import { EventEmitter } from 'events'; + +import { Android, AndroidDevice, AndroidSocket } from './android'; +import { Artifact } from './artifact'; import { Browser } from './browser'; import { BrowserContext } from './browserContext'; import { BrowserType } from './browserType'; +import { CDPSession } from './cdpSession'; import { ChannelOwner } from './channelOwner'; +import { createInstrumentation } from './clientInstrumentation'; +import { Dialog } from './dialog'; +import { Electron, ElectronApplication } from './electron'; import { ElementHandle } from './elementHandle'; +import { TargetClosedError, parseError } from './errors'; +import { APIRequestContext } from './fetch'; import { Frame } from './frame'; import { JSHandle } from './jsHandle'; -import { Request, Response, Route, WebSocket, WebSocketRoute } from './network'; -import { Page, BindingCall } from './page'; -import { Worker } from './worker'; -import { Dialog } from './dialog'; -import { parseError, TargetClosedError } from './errors'; -import { CDPSession } from './cdpSession'; -import { Playwright } from './playwright'; -import { Electron, ElectronApplication } from './electron'; -import type * as channels from '@protocol/channels'; -import { Stream } from './stream'; -import { WritableStream } from './writableStream'; -import { debugLogger } from '../utils/debugLogger'; -import { SelectorsOwner } from './selectors'; -import { Android, AndroidSocket, AndroidDevice } from './android'; -import { Artifact } from './artifact'; -import { EventEmitter } from 'events'; import { JsonPipe } from './jsonPipe'; -import { APIRequestContext } from './fetch'; import { LocalUtils } from './localUtils'; +import { Request, Response, Route, WebSocket, WebSocketRoute } from './network'; +import { BindingCall, Page } from './page'; +import { Playwright } from './playwright'; +import { SelectorsOwner } from './selectors'; +import { Stream } from './stream'; import { Tracing } from './tracing'; -import { findValidator, ValidationError, type ValidatorContext } from '../protocol/validator'; -import { createInstrumentation } from './clientInstrumentation'; -import type { ClientInstrumentation } from './clientInstrumentation'; +import { Worker } from './worker'; +import { WritableStream } from './writableStream'; +import { ValidationError, findValidator } from '../protocol/validator'; import { formatCallLog, rewriteErrorMessage, zones } from '../utils'; +import { debugLogger } from '../utils/debugLogger'; + +import type { ClientInstrumentation } from './clientInstrumentation'; +import type { ValidatorContext } from '../protocol/validator'; +import type * as channels from '@protocol/channels'; class Root extends ChannelOwner { constructor(connection: Connection) { diff --git a/packages/playwright-core/src/client/consoleMessage.ts b/packages/playwright-core/src/client/consoleMessage.ts index fcdc3fd149..db2ed1a246 100644 --- a/packages/playwright-core/src/client/consoleMessage.ts +++ b/packages/playwright-core/src/client/consoleMessage.ts @@ -15,11 +15,13 @@ */ import * as util from 'util'; + import { JSHandle } from './jsHandle'; -import type * as channels from '@protocol/channels'; -import type * as api from '../../types/types'; import { Page } from './page'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; + type ConsoleMessageLocation = channels.BrowserContextConsoleEvent['location']; export class ConsoleMessage implements api.ConsoleMessage { diff --git a/packages/playwright-core/src/client/coverage.ts b/packages/playwright-core/src/client/coverage.ts index c736d1fad0..7e1cb7ef2b 100644 --- a/packages/playwright-core/src/client/coverage.ts +++ b/packages/playwright-core/src/client/coverage.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; export class Coverage implements api.Coverage { private _channel: channels.PageChannel; diff --git a/packages/playwright-core/src/client/dialog.ts b/packages/playwright-core/src/client/dialog.ts index c012838b7c..52722cecfd 100644 --- a/packages/playwright-core/src/client/dialog.ts +++ b/packages/playwright-core/src/client/dialog.ts @@ -14,11 +14,13 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { ChannelOwner } from './channelOwner'; -import type * as api from '../../types/types'; import { Page } from './page'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; + + export class Dialog extends ChannelOwner implements api.Dialog { static from(dialog: channels.DialogChannel): Dialog { return (dialog as any)._object; diff --git a/packages/playwright-core/src/client/download.ts b/packages/playwright-core/src/client/download.ts index e5cdd01aa6..550f485aa0 100644 --- a/packages/playwright-core/src/client/download.ts +++ b/packages/playwright-core/src/client/download.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import type { Readable } from 'stream'; -import type * as api from '../../types/types'; import type { Artifact } from './artifact'; import type { Page } from './page'; +import type * as api from '../../types/types'; +import type { Readable } from 'stream'; export class Download implements api.Download { private _page: Page; diff --git a/packages/playwright-core/src/client/electron.ts b/packages/playwright-core/src/client/electron.ts index fe5b6e189e..15551ebce9 100644 --- a/packages/playwright-core/src/client/electron.ts +++ b/packages/playwright-core/src/client/electron.ts @@ -14,22 +14,23 @@ * limitations under the License. */ -import type { BrowserWindow } from 'electron'; -import type * as childProcess from 'child_process'; -import type * as structs from '../../types/structs'; -import type * as api from '../../types/types'; -import type * as channels from '@protocol/channels'; -import { TimeoutSettings } from '../common/timeoutSettings'; import { BrowserContext, prepareBrowserContextParams } from './browserContext'; import { ChannelOwner } from './channelOwner'; import { envObjectToArray } from './clientHelper'; +import { ConsoleMessage } from './consoleMessage'; +import { TargetClosedError, isTargetClosedError } from './errors'; import { Events } from './events'; import { JSHandle, parseResult, serializeArgument } from './jsHandle'; -import type { Page } from './page'; -import { ConsoleMessage } from './consoleMessage'; -import type { Env, WaitForEventOptions, Headers, BrowserContextOptions } from './types'; import { Waiter } from './waiter'; -import { TargetClosedError, isTargetClosedError } from './errors'; +import { TimeoutSettings } from '../common/timeoutSettings'; + +import type { Page } from './page'; +import type { BrowserContextOptions, Env, Headers, WaitForEventOptions } from './types'; +import type * as structs from '../../types/structs'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; +import type * as childProcess from 'child_process'; +import type { BrowserWindow } from 'electron'; type ElectronOptions = Omit & { env?: Env, diff --git a/packages/playwright-core/src/client/elementHandle.ts b/packages/playwright-core/src/client/elementHandle.ts index c6249e8078..2883a69dfc 100644 --- a/packages/playwright-core/src/client/elementHandle.ts +++ b/packages/playwright-core/src/client/elementHandle.ts @@ -14,24 +14,26 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import { Frame } from './frame'; -import type { Locator } from './locator'; -import { JSHandle, serializeArgument, parseResult } from './jsHandle'; -import type { ChannelOwner } from './channelOwner'; -import type { SelectOption, FilePayload, Rect, SelectOptionOptions } from './types'; -import fs from 'fs'; -import { mime } from '../utilsBundle'; -import path from 'path'; -import { assert, isString } from '../utils'; -import { fileUploadSizeLimit, mkdirIfNeeded } from '../utils/fileUtils'; -import type * as api from '../../types/types'; -import type * as structs from '../../types/structs'; -import type { BrowserContext } from './browserContext'; -import { WritableStream } from './writableStream'; +import * as fs from 'fs'; +import * as path from 'path'; import { pipeline } from 'stream'; import { promisify } from 'util'; +import { Frame } from './frame'; +import { JSHandle, parseResult, serializeArgument } from './jsHandle'; +import { assert, isString } from '../utils'; +import { fileUploadSizeLimit, mkdirIfNeeded } from '../utils/fileUtils'; +import { mime } from '../utilsBundle'; +import { WritableStream } from './writableStream'; + +import type { BrowserContext } from './browserContext'; +import type { ChannelOwner } from './channelOwner'; +import type { Locator } from './locator'; +import type { FilePayload, Rect, SelectOption, SelectOptionOptions } from './types'; +import type * as structs from '../../types/structs'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; + const pipelineAsync = promisify(pipeline); export class ElementHandle extends JSHandle implements api.ElementHandle { diff --git a/packages/playwright-core/src/client/errors.ts b/packages/playwright-core/src/client/errors.ts index 51555202e5..4757a6d0f7 100644 --- a/packages/playwright-core/src/client/errors.ts +++ b/packages/playwright-core/src/client/errors.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { SerializedError } from '@protocol/channels'; -import { isError } from '../utils'; import { parseSerializedValue, serializeValue } from '../protocol/serializers'; +import { isError } from '../utils'; + +import type { SerializedError } from '@protocol/channels'; export class TimeoutError extends Error { constructor(message: string) { diff --git a/packages/playwright-core/src/client/eventEmitter.ts b/packages/playwright-core/src/client/eventEmitter.ts index 89d723eb8d..b295f87eba 100644 --- a/packages/playwright-core/src/client/eventEmitter.ts +++ b/packages/playwright-core/src/client/eventEmitter.ts @@ -22,12 +22,15 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ +import { EventEmitter as OriginalEventEmitter } from 'events'; + +import { isUnderTest } from '../utils'; + +import type { EventEmitter as EventEmitterType } from 'events'; + type EventType = string | symbol; type Listener = (...args: any[]) => any; type EventMap = Record; -import { EventEmitter as OriginalEventEmitter } from 'events'; -import type { EventEmitter as EventEmitterType } from 'events'; -import { isUnderTest } from '../utils'; export class EventEmitter implements EventEmitterType { diff --git a/packages/playwright-core/src/client/fetch.ts b/packages/playwright-core/src/client/fetch.ts index a424004474..fea6c1a17e 100644 --- a/packages/playwright-core/src/client/fetch.ts +++ b/packages/playwright-core/src/client/fetch.ts @@ -14,22 +14,24 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; import * as util from 'util'; + +import { assert, headersObjectToArray, isString } from '../utils'; +import { toClientCertificatesProtocol } from './browserContext'; +import { ChannelOwner } from './channelOwner'; +import { TargetClosedError, isTargetClosedError } from './errors'; +import { RawHeaders } from './network'; +import { Tracing } from './tracing'; +import { mkdirIfNeeded } from '../utils/fileUtils'; + +import type { Playwright } from './playwright'; +import type { ClientCertificate, FilePayload, Headers, SetStorageState, StorageState } from './types'; import type { Serializable } from '../../types/structs'; import type * as api from '../../types/types'; import type { HeadersArray, NameValue } from '../common/types'; import type * as channels from '@protocol/channels'; -import { assert, headersObjectToArray, isString } from '../utils'; -import { mkdirIfNeeded } from '../utils/fileUtils'; -import { ChannelOwner } from './channelOwner'; -import { RawHeaders } from './network'; -import type { ClientCertificate, FilePayload, Headers, SetStorageState, StorageState } from './types'; -import type { Playwright } from './playwright'; -import { Tracing } from './tracing'; -import { TargetClosedError, isTargetClosedError } from './errors'; -import { toClientCertificatesProtocol } from './browserContext'; export type FetchOptions = { params?: { [key: string]: string | number | boolean; } | URLSearchParams | string, diff --git a/packages/playwright-core/src/client/fileChooser.ts b/packages/playwright-core/src/client/fileChooser.ts index 5e7b1113ff..ee669ee519 100644 --- a/packages/playwright-core/src/client/fileChooser.ts +++ b/packages/playwright-core/src/client/fileChooser.ts @@ -17,8 +17,8 @@ import type { ElementHandle } from './elementHandle'; import type { Page } from './page'; import type { FilePayload } from './types'; -import type * as channels from '@protocol/channels'; import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; export class FileChooser implements api.FileChooser { private _page: Page; diff --git a/packages/playwright-core/src/client/frame.ts b/packages/playwright-core/src/client/frame.ts index c337077630..a3b99cfb20 100644 --- a/packages/playwright-core/src/client/frame.ts +++ b/packages/playwright-core/src/client/frame.ts @@ -15,27 +15,30 @@ * limitations under the License. */ -import { assert } from '../utils'; -import type * as channels from '@protocol/channels'; +import { EventEmitter } from 'events'; +import * as fs from 'fs'; + import { ChannelOwner } from './channelOwner'; import { FrameLocator, Locator, testIdAttributeName } from './locator'; -import type { LocatorOptions } from './locator'; -import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../utils/isomorphic/locatorUtils'; -import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils'; -import { ElementHandle, convertSelectOptionValues, convertInputFiles } from './elementHandle'; -import { assertMaxArguments, JSHandle, serializeArgument, parseResult } from './jsHandle'; -import fs from 'fs'; -import * as network from './network'; -import type { Page } from './page'; -import { EventEmitter } from 'events'; -import { Waiter } from './waiter'; -import { Events } from './events'; -import type { LifecycleEvent, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions, StrictOptions } from './types'; -import { kLifecycleEvents } from './types'; -import { type URLMatch, urlMatches } from '../utils'; -import type * as api from '../../types/types'; -import type * as structs from '../../types/structs'; +import { assert } from '../utils'; +import { urlMatches } from '../utils'; import { addSourceUrlToScript } from './clientHelper'; +import { ElementHandle, convertInputFiles, convertSelectOptionValues } from './elementHandle'; +import { Events } from './events'; +import { JSHandle, assertMaxArguments, parseResult, serializeArgument } from './jsHandle'; +import * as network from './network'; +import { kLifecycleEvents } from './types'; +import { Waiter } from './waiter'; +import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../utils/isomorphic/locatorUtils'; + +import type { LocatorOptions } from './locator'; +import type { Page } from './page'; +import type { FilePayload, LifecycleEvent, SelectOption, SelectOptionOptions, StrictOptions, WaitForFunctionOptions } from './types'; +import type * as structs from '../../types/structs'; +import type * as api from '../../types/types'; +import type { URLMatch } from '../utils'; +import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils'; +import type * as channels from '@protocol/channels'; export type WaitForNavigationOptions = { timeout?: number, diff --git a/packages/playwright-core/src/client/harRouter.ts b/packages/playwright-core/src/client/harRouter.ts index 5e617d7ce9..3fb2ce0e7b 100644 --- a/packages/playwright-core/src/client/harRouter.ts +++ b/packages/playwright-core/src/client/harRouter.ts @@ -15,6 +15,7 @@ */ import { debugLogger } from '../utils/debugLogger'; + import type { BrowserContext } from './browserContext'; import type { LocalUtils } from './localUtils'; import type { Route } from './network'; diff --git a/packages/playwright-core/src/client/input.ts b/packages/playwright-core/src/client/input.ts index e06b0e3e4a..3d40deccdf 100644 --- a/packages/playwright-core/src/client/input.ts +++ b/packages/playwright-core/src/client/input.ts @@ -15,9 +15,9 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import type * as api from '../../types/types'; import type { Page } from './page'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; export class Keyboard implements api.Keyboard { private _page: Page; diff --git a/packages/playwright-core/src/client/jsHandle.ts b/packages/playwright-core/src/client/jsHandle.ts index 8577400f3d..62a54950d5 100644 --- a/packages/playwright-core/src/client/jsHandle.ts +++ b/packages/playwright-core/src/client/jsHandle.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { ChannelOwner } from './channelOwner'; -import { parseSerializedValue, serializeValue } from '../protocol/serializers'; -import type * as api from '../../types/types'; -import type * as structs from '../../types/structs'; import { isTargetClosedError } from './errors'; +import { parseSerializedValue, serializeValue } from '../protocol/serializers'; + +import type * as structs from '../../types/structs'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; + export class JSHandle extends ChannelOwner implements api.JSHandle { private _preview: string; diff --git a/packages/playwright-core/src/client/jsonPipe.ts b/packages/playwright-core/src/client/jsonPipe.ts index 0c6b53502f..9e6635638e 100644 --- a/packages/playwright-core/src/client/jsonPipe.ts +++ b/packages/playwright-core/src/client/jsonPipe.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { ChannelOwner } from './channelOwner'; +import type * as channels from '@protocol/channels'; + export class JsonPipe extends ChannelOwner { static from(jsonPipe: channels.JsonPipeChannel): JsonPipe { return (jsonPipe as any)._object; diff --git a/packages/playwright-core/src/client/localUtils.ts b/packages/playwright-core/src/client/localUtils.ts index 530547b227..eb8990abe9 100644 --- a/packages/playwright-core/src/client/localUtils.ts +++ b/packages/playwright-core/src/client/localUtils.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { ChannelOwner } from './channelOwner'; + import type { Size } from './types'; +import type * as channels from '@protocol/channels'; type DeviceDescriptor = { userAgent: string, diff --git a/packages/playwright-core/src/client/locator.ts b/packages/playwright-core/src/client/locator.ts index 7784e1d685..af84294d2e 100644 --- a/packages/playwright-core/src/client/locator.ts +++ b/packages/playwright-core/src/client/locator.ts @@ -14,18 +14,21 @@ * limitations under the License. */ -import type * as structs from '../../types/structs'; -import type * as api from '../../types/types'; -import type * as channels from '@protocol/channels'; import * as util from 'util'; + import { asLocator, isString, monotonicTime } from '../utils'; import { ElementHandle } from './elementHandle'; +import { parseResult, serializeArgument } from './jsHandle'; +import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../utils/isomorphic/locatorUtils'; +import { escapeForTextSelector } from '../utils/isomorphic/stringUtils'; + import type { Frame } from './frame'; import type { FilePayload, FrameExpectParams, Rect, SelectOption, SelectOptionOptions, TimeoutOptions } from './types'; -import { parseResult, serializeArgument } from './jsHandle'; -import { escapeForTextSelector } from '../utils/isomorphic/stringUtils'; +import type * as structs from '../../types/structs'; +import type * as api from '../../types/types'; import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils'; -import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../utils/isomorphic/locatorUtils'; +import type * as channels from '@protocol/channels'; + export type LocatorOptions = { hasText?: string | RegExp; diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.ts index a6b40307b3..8667447e8b 100644 --- a/packages/playwright-core/src/client/network.ts +++ b/packages/playwright-core/src/client/network.ts @@ -14,26 +14,28 @@ * limitations under the License. */ +import * as fs from 'fs'; import { URLSearchParams } from 'url'; -import type * as channels from '@protocol/channels'; + import { ChannelOwner } from './channelOwner'; +import { isTargetClosedError } from './errors'; +import { Events } from './events'; +import { APIResponse } from './fetch'; import { Frame } from './frame'; import { Worker } from './worker'; -import type { Headers, RemoteAddr, SecurityDetails, WaitForEventOptions } from './types'; -import fs from 'fs'; -import { mime } from '../utilsBundle'; -import { assert, isString, headersObjectToArray, isRegExp, rewriteErrorMessage, MultiMap, urlMatches, zones } from '../utils'; -import type { URLMatch, Zone } from '../utils'; -import { ManualPromise, LongStandingScope } from '../utils/manualPromise'; -import { Events } from './events'; -import type { Page } from './page'; +import { MultiMap, assert, headersObjectToArray, isRegExp, isString, rewriteErrorMessage, urlMatches, zones } from '../utils'; import { Waiter } from './waiter'; +import { LongStandingScope, ManualPromise } from '../utils/manualPromise'; +import { mime } from '../utilsBundle'; + +import type { Headers, RemoteAddr, SecurityDetails, WaitForEventOptions } from './types'; +import type { URLMatch, Zone } from '../utils'; +import type { BrowserContext } from './browserContext'; +import type { Page } from './page'; +import type { Serializable } from '../../types/structs'; import type * as api from '../../types/types'; import type { HeadersArray } from '../common/types'; -import { APIResponse } from './fetch'; -import type { Serializable } from '../../types/structs'; -import type { BrowserContext } from './browserContext'; -import { isTargetClosedError } from './errors'; +import type * as channels from '@protocol/channels'; export type NetworkCookie = { name: string, diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.ts index d0db2cbae9..c68435321a 100644 --- a/packages/playwright-core/src/client/page.ts +++ b/packages/playwright-core/src/client/page.ts @@ -15,38 +15,42 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type * as structs from '../../types/structs'; -import type * as api from '../../types/types'; -import { serializeError, isTargetClosedError, TargetClosedError } from './errors'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { TargetClosedError, isTargetClosedError, serializeError } from './errors'; import { TimeoutSettings } from '../common/timeoutSettings'; -import type * as channels from '@protocol/channels'; -import { assert, headersObjectToArray, isObject, isRegExp, isString, LongStandingScope, urlMatches, urlMatchesEqual, mkdirIfNeeded, trimStringWithEllipsis, type URLMatch } from '../utils'; +import { LongStandingScope, assert, headersObjectToArray, isObject, isRegExp, isString, mkdirIfNeeded, trimStringWithEllipsis, urlMatches, urlMatchesEqual } from '../utils'; import { Accessibility } from './accessibility'; import { Artifact } from './artifact'; -import type { BrowserContext } from './browserContext'; import { ChannelOwner } from './channelOwner'; import { evaluationScript } from './clientHelper'; import { Coverage } from './coverage'; import { Download } from './download'; -import { determineScreenshotType, ElementHandle } from './elementHandle'; +import { ElementHandle, determineScreenshotType } from './elementHandle'; import { Events } from './events'; -import type { APIRequestContext } from './fetch'; import { FileChooser } from './fileChooser'; -import type { WaitForNavigationOptions } from './frame'; import { Frame, verifyLoadState } from './frame'; +import { HarRouter } from './harRouter'; import { Keyboard, Mouse, Touchscreen } from './input'; -import { assertMaxArguments, JSHandle, parseResult, serializeArgument } from './jsHandle'; -import type { FrameLocator, Locator, LocatorOptions } from './locator'; -import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils'; -import { type RouteHandlerCallback, type Request, Response, Route, RouteHandler, validateHeaders, WebSocket, type WebSocketRouteHandlerCallback, WebSocketRoute, WebSocketRouteHandler } from './network'; -import type { FilePayload, Headers, LifecycleEvent, SelectOption, SelectOptionOptions, Size, WaitForEventOptions, WaitForFunctionOptions } from './types'; +import { JSHandle, assertMaxArguments, parseResult, serializeArgument } from './jsHandle'; +import { Response, Route, RouteHandler, WebSocket, WebSocketRoute, WebSocketRouteHandler, validateHeaders } from './network'; import { Video } from './video'; import { Waiter } from './waiter'; import { Worker } from './worker'; -import { HarRouter } from './harRouter'; + +import type { BrowserContext } from './browserContext'; import type { Clock } from './clock'; +import type { APIRequestContext } from './fetch'; +import type { WaitForNavigationOptions } from './frame'; +import type { FrameLocator, Locator, LocatorOptions } from './locator'; +import type { Request, RouteHandlerCallback, WebSocketRouteHandlerCallback } from './network'; +import type { FilePayload, Headers, LifecycleEvent, SelectOption, SelectOptionOptions, Size, WaitForEventOptions, WaitForFunctionOptions } from './types'; +import type * as structs from '../../types/structs'; +import type * as api from '../../types/types'; +import type { URLMatch } from '../utils'; +import type { ByRoleOptions } from '../utils/isomorphic/locatorUtils'; +import type * as channels from '@protocol/channels'; type PDFOptions = Omit & { width?: string | number, diff --git a/packages/playwright-core/src/client/playwright.ts b/packages/playwright-core/src/client/playwright.ts index 078e31259d..3a0e359a0e 100644 --- a/packages/playwright-core/src/client/playwright.ts +++ b/packages/playwright-core/src/client/playwright.ts @@ -14,14 +14,15 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import { TimeoutError } from './errors'; import { Android } from './android'; import { BrowserType } from './browserType'; import { ChannelOwner } from './channelOwner'; import { Electron } from './electron'; +import { TimeoutError } from './errors'; import { APIRequest } from './fetch'; import { Selectors, SelectorsOwner } from './selectors'; + +import type * as channels from '@protocol/channels'; import type { BrowserContextOptions, LaunchOptions } from 'playwright-core'; export class Playwright extends ChannelOwner { diff --git a/packages/playwright-core/src/client/selectors.ts b/packages/playwright-core/src/client/selectors.ts index 2739be0e8d..4f8ee784a8 100644 --- a/packages/playwright-core/src/client/selectors.ts +++ b/packages/playwright-core/src/client/selectors.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import { evaluationScript } from './clientHelper'; -import type * as channels from '@protocol/channels'; import { ChannelOwner } from './channelOwner'; +import { evaluationScript } from './clientHelper'; +import { setTestIdAttribute, testIdAttributeName } from './locator'; + import type { SelectorEngine } from './types'; import type * as api from '../../types/types'; -import { setTestIdAttribute, testIdAttributeName } from './locator'; +import type * as channels from '@protocol/channels'; + export class Selectors implements api.Selectors { private _channels = new Set(); diff --git a/packages/playwright-core/src/client/stream.ts b/packages/playwright-core/src/client/stream.ts index bb202ac4ad..4f43b9afad 100644 --- a/packages/playwright-core/src/client/stream.ts +++ b/packages/playwright-core/src/client/stream.ts @@ -15,9 +15,11 @@ */ import { Readable } from 'stream'; -import type * as channels from '@protocol/channels'; + import { ChannelOwner } from './channelOwner'; +import type * as channels from '@protocol/channels'; + export class Stream extends ChannelOwner { static from(Stream: channels.StreamChannel): Stream { return (Stream as any)._object; diff --git a/packages/playwright-core/src/client/tracing.ts b/packages/playwright-core/src/client/tracing.ts index 2481741e3e..a75f026625 100644 --- a/packages/playwright-core/src/client/tracing.ts +++ b/packages/playwright-core/src/client/tracing.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import type * as api from '../../types/types'; -import type * as channels from '@protocol/channels'; import { Artifact } from './artifact'; import { ChannelOwner } from './channelOwner'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; + export class Tracing extends ChannelOwner implements api.Tracing { private _includeSources = false; _tracesDir: string | undefined; diff --git a/packages/playwright-core/src/client/types.ts b/packages/playwright-core/src/client/types.ts index e21b34a8a8..5d232e9607 100644 --- a/packages/playwright-core/src/client/types.ts +++ b/packages/playwright-core/src/client/types.ts @@ -15,9 +15,9 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import type { Size } from '../common/types'; -export type { Size, Point, Rect, Quad, TimeoutOptions, HeadersArray } from '../common/types'; +import type * as channels from '@protocol/channels'; +export type { HeadersArray, Point, Quad, Rect, Size, TimeoutOptions } from '../common/types'; type LoggerSeverity = 'verbose' | 'info' | 'warning' | 'error'; export interface Logger { diff --git a/packages/playwright-core/src/client/video.ts b/packages/playwright-core/src/client/video.ts index 08c39d4247..f15d75bade 100644 --- a/packages/playwright-core/src/client/video.ts +++ b/packages/playwright-core/src/client/video.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import type { Page } from './page'; -import type * as api from '../../types/types'; +import { ManualPromise } from '../utils'; + import type { Artifact } from './artifact'; import type { Connection } from './connection'; -import { ManualPromise } from '../utils'; +import type { Page } from './page'; +import type * as api from '../../types/types'; export class Video implements api.Video { private _artifact: Promise | null = null; diff --git a/packages/playwright-core/src/client/waiter.ts b/packages/playwright-core/src/client/waiter.ts index 408a01f3d0..6453fb875d 100644 --- a/packages/playwright-core/src/client/waiter.ts +++ b/packages/playwright-core/src/client/waiter.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { EventEmitter } from 'events'; -import { rewriteErrorMessage } from '../utils/stackTrace'; import { TimeoutError } from './errors'; import { createGuid, zones } from '../utils'; +import { rewriteErrorMessage } from '../utils/stackTrace'; + import type { Zone } from '../utils'; -import type * as channels from '@protocol/channels'; import type { ChannelOwner } from './channelOwner'; +import type * as channels from '@protocol/channels'; +import type { EventEmitter } from 'events'; export class Waiter { private _dispose: (() => void)[]; diff --git a/packages/playwright-core/src/client/webError.ts b/packages/playwright-core/src/client/webError.ts index 13a942abee..3993113796 100644 --- a/packages/playwright-core/src/client/webError.ts +++ b/packages/playwright-core/src/client/webError.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import type * as api from '../../types/types'; import type { Page } from './page'; +import type * as api from '../../types/types'; export class WebError implements api.WebError { private _page: Page | null; diff --git a/packages/playwright-core/src/client/worker.ts b/packages/playwright-core/src/client/worker.ts index 31d5d3057f..36d5bddff3 100644 --- a/packages/playwright-core/src/client/worker.ts +++ b/packages/playwright-core/src/client/worker.ts @@ -14,17 +14,19 @@ * limitations under the License. */ -import { Events } from './events'; -import type * as channels from '@protocol/channels'; import { ChannelOwner } from './channelOwner'; -import { assertMaxArguments, JSHandle, parseResult, serializeArgument } from './jsHandle'; -import type { Page } from './page'; -import type { BrowserContext } from './browserContext'; -import type * as api from '../../types/types'; -import type * as structs from '../../types/structs'; +import { Events } from './events'; +import { JSHandle, assertMaxArguments, parseResult, serializeArgument } from './jsHandle'; import { LongStandingScope } from '../utils'; import { TargetClosedError } from './errors'; +import type { BrowserContext } from './browserContext'; +import type { Page } from './page'; +import type * as structs from '../../types/structs'; +import type * as api from '../../types/types'; +import type * as channels from '@protocol/channels'; + + export class Worker extends ChannelOwner implements api.Worker { _page: Page | undefined; // Set for web workers. _context: BrowserContext | undefined; // Set for service workers. diff --git a/packages/playwright-core/src/client/writableStream.ts b/packages/playwright-core/src/client/writableStream.ts index 8ed799292c..66cf17201d 100644 --- a/packages/playwright-core/src/client/writableStream.ts +++ b/packages/playwright-core/src/client/writableStream.ts @@ -15,9 +15,11 @@ */ import { Writable } from 'stream'; -import type * as channels from '@protocol/channels'; + import { ChannelOwner } from './channelOwner'; +import type * as channels from '@protocol/channels'; + export class WritableStream extends ChannelOwner { static from(Stream: channels.WritableStreamChannel): WritableStream { return (Stream as any)._object; diff --git a/packages/playwright-core/src/common/socksProxy.ts b/packages/playwright-core/src/common/socksProxy.ts index 6566262d64..632e698dc2 100644 --- a/packages/playwright-core/src/common/socksProxy.ts +++ b/packages/playwright-core/src/common/socksProxy.ts @@ -15,11 +15,13 @@ */ import EventEmitter from 'events'; -import type { AddressInfo } from 'net'; -import net from 'net'; +import * as net from 'net'; + +import { assert, createGuid, } from '../utils'; import { debugLogger } from '../utils/debugLogger'; import { createSocket } from '../utils/happy-eyeballs'; -import { assert, createGuid, } from '../utils'; + +import type { AddressInfo } from 'net'; // https://tools.ietf.org/html/rfc1928 diff --git a/packages/playwright-core/src/image_tools/compare.ts b/packages/playwright-core/src/image_tools/compare.ts index ee4b6b691d..8dddb5df35 100644 --- a/packages/playwright-core/src/image_tools/compare.ts +++ b/packages/playwright-core/src/image_tools/compare.ts @@ -16,7 +16,7 @@ import { blendWithWhite, colorDeltaE94, rgb2gray } from './colorUtils'; import { ImageChannel } from './imageChannel'; -import { ssim, FastStats } from './stats'; +import { FastStats, ssim } from './stats'; const SSIM_WINDOW_RADIUS = 15; const VARIANCE_WINDOW_RADIUS = 1; diff --git a/packages/playwright-core/src/inProcessFactory.ts b/packages/playwright-core/src/inProcessFactory.ts index a757294da8..d6cd8110c2 100644 --- a/packages/playwright-core/src/inProcessFactory.ts +++ b/packages/playwright-core/src/inProcessFactory.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import type { Playwright as PlaywrightAPI } from './client/playwright'; -import { createPlaywright, DispatcherConnection, RootDispatcher, PlaywrightDispatcher } from './server'; -import { Connection } from './client/connection'; -import { BrowserServerLauncherImpl } from './browserServerImpl'; import { AndroidServerLauncherImpl } from './androidServerImpl'; +import { BrowserServerLauncherImpl } from './browserServerImpl'; +import { Connection } from './client/connection'; +import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from './server'; + +import type { Playwright as PlaywrightAPI } from './client/playwright'; import type { Language } from './utils'; export function createInProcessPlaywright(): PlaywrightAPI { diff --git a/packages/playwright-core/src/outofprocess.ts b/packages/playwright-core/src/outofprocess.ts index 81deaead67..3d8c43788e 100644 --- a/packages/playwright-core/src/outofprocess.ts +++ b/packages/playwright-core/src/outofprocess.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import { Connection } from './client/connection'; -import { PipeTransport } from './protocol/transport'; -import type { Playwright } from './client/playwright'; import * as childProcess from 'child_process'; import * as path from 'path'; + +import { Connection } from './client/connection'; +import { PipeTransport } from './protocol/transport'; import { ManualPromise } from './utils/manualPromise'; +import type { Playwright } from './client/playwright'; + + export async function start(env: any = {}): Promise<{ playwright: Playwright, stop: () => Promise }> { const client = new PlaywrightClient(env); const playwright = await client._playwright; diff --git a/packages/playwright-core/src/protocol/validator.ts b/packages/playwright-core/src/protocol/validator.ts index d1e7c3d63c..7072464089 100644 --- a/packages/playwright-core/src/protocol/validator.ts +++ b/packages/playwright-core/src/protocol/validator.ts @@ -16,6 +16,7 @@ // This file is generated by generate_channels.js, do not edit manually. +/* eslint-disable import/order */ import { scheme, tOptional, tObject, tBoolean, tNumber, tString, tAny, tEnum, tArray, tBinary, tChannel, tType } from './validatorPrimitives'; export type { Validator, ValidatorContext } from './validatorPrimitives'; export { ValidationError, findValidator, maybeFindValidator, createMetadataValidator } from './validatorPrimitives'; diff --git a/packages/playwright-core/src/remote/playwrightConnection.ts b/packages/playwright-core/src/remote/playwrightConnection.ts index 5f39be5671..9817f8d295 100644 --- a/packages/playwright-core/src/remote/playwrightConnection.ts +++ b/packages/playwright-core/src/remote/playwrightConnection.ts @@ -14,21 +14,22 @@ * limitations under the License. */ -import type { WebSocket } from '../utilsBundle'; -import type { DispatcherScope, Playwright } from '../server'; -import type * as channels from '@protocol/channels'; -import { createPlaywright, DispatcherConnection, RootDispatcher, PlaywrightDispatcher } from '../server'; -import { Browser } from '../server/browser'; -import { serverSideCallMetadata } from '../server/instrumentation'; import { SocksProxy } from '../common/socksProxy'; -import { assert, isUnderTest } from '../utils'; -import type { LaunchOptions } from '../server/types'; +import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from '../server'; import { AndroidDevice } from '../server/android/android'; +import { Browser } from '../server/browser'; import { DebugControllerDispatcher } from '../server/dispatchers/debugControllerDispatcher'; +import { serverSideCallMetadata } from '../server/instrumentation'; +import { assert, isUnderTest } from '../utils'; import { startProfiling, stopProfiling } from '../utils'; import { monotonicTime } from '../utils'; import { debugLogger } from '../utils/debugLogger'; +import type { DispatcherScope, Playwright } from '../server'; +import type { LaunchOptions } from '../server/types'; +import type { WebSocket } from '../utilsBundle'; +import type * as channels from '@protocol/channels'; + export type ClientType = 'controller' | 'launch-browser' | 'reuse-browser' | 'pre-launched-browser-or-android'; type Options = { diff --git a/packages/playwright-core/src/remote/playwrightServer.ts b/packages/playwright-core/src/remote/playwrightServer.ts index 5cd99285ed..232ead0806 100644 --- a/packages/playwright-core/src/remote/playwrightServer.ts +++ b/packages/playwright-core/src/remote/playwrightServer.ts @@ -14,18 +14,20 @@ * limitations under the License. */ +import { PlaywrightConnection } from './playwrightConnection'; +import { createPlaywright } from '../server/playwright'; +import { userAgentVersionMatchesErrorMessage } from '../utils'; +import { debugLogger } from '../utils/debugLogger'; +import { Semaphore } from '../utils/semaphore'; +import { WSServer } from '../utils/wsServer'; + +import type { ClientType } from './playwrightConnection'; +import type { SocksProxy } from '../common/socksProxy'; +import type { AndroidDevice } from '../server/android/android'; import type { Browser } from '../server/browser'; import type { Playwright } from '../server/playwright'; -import { createPlaywright } from '../server/playwright'; -import { PlaywrightConnection } from './playwrightConnection'; -import type { ClientType } from './playwrightConnection'; import type { LaunchOptions } from '../server/types'; -import { Semaphore } from '../utils/semaphore'; -import type { AndroidDevice } from '../server/android/android'; -import type { SocksProxy } from '../common/socksProxy'; -import { debugLogger } from '../utils/debugLogger'; -import { userAgentVersionMatchesErrorMessage } from '../utils'; -import { WSServer } from '../utils/wsServer'; + type ServerOptions = { path: string; diff --git a/packages/playwright-core/src/server/android/android.ts b/packages/playwright-core/src/server/android/android.ts index b6303935b7..d411581eab 100644 --- a/packages/playwright-core/src/server/android/android.ts +++ b/packages/playwright-core/src/server/android/android.ts @@ -14,31 +14,33 @@ * limitations under the License. */ -import { debug } from '../../utilsBundle'; import { EventEmitter } from 'events'; -import fs from 'fs'; -import os from 'os'; -import path from 'path'; -import type * as stream from 'stream'; -import { wsReceiver, wsSender } from '../../utilsBundle'; -import { createGuid, makeWaitForNextTask, isUnderTest, getPackageManagerExecCommand } from '../../utils'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + +import { TimeoutSettings } from '../../common/timeoutSettings'; +import { PipeTransport } from '../../protocol/transport'; +import { createGuid, getPackageManagerExecCommand, isUnderTest, makeWaitForNextTask } from '../../utils'; +import { RecentLogsCollector } from '../../utils/debugLogger'; import { removeFolders } from '../../utils/fileUtils'; -import type { BrowserOptions, BrowserProcess } from '../browser'; -import type { BrowserContext } from '../browserContext'; +import { gracefullyCloseSet } from '../../utils/processLauncher'; +import { debug } from '../../utilsBundle'; +import { wsReceiver, wsSender } from '../../utilsBundle'; import { validateBrowserContextOptions } from '../browserContext'; -import { ProgressController } from '../progress'; +import { chromiumSwitches } from '../chromium/chromiumSwitches'; import { CRBrowser } from '../chromium/crBrowser'; import { helper } from '../helper'; -import type * as types from '../types'; -import { PipeTransport } from '../../protocol/transport'; -import { RecentLogsCollector } from '../../utils/debugLogger'; -import { gracefullyCloseSet } from '../../utils/processLauncher'; -import { TimeoutSettings } from '../../common/timeoutSettings'; -import type * as channels from '@protocol/channels'; import { SdkObject, serverSideCallMetadata } from '../instrumentation'; -import { chromiumSwitches } from '../chromium/chromiumSwitches'; +import { ProgressController } from '../progress'; import { registry } from '../registry'; +import type { BrowserOptions, BrowserProcess } from '../browser'; +import type { BrowserContext } from '../browserContext'; +import type * as types from '../types'; +import type * as channels from '@protocol/channels'; +import type * as stream from 'stream'; + const ARTIFACTS_FOLDER = path.join(os.tmpdir(), 'playwright-artifacts-'); export interface Backend { diff --git a/packages/playwright-core/src/server/android/backendAdb.ts b/packages/playwright-core/src/server/android/backendAdb.ts index cd718b9d95..a5f28f1d35 100644 --- a/packages/playwright-core/src/server/android/backendAdb.ts +++ b/packages/playwright-core/src/server/android/backendAdb.ts @@ -14,12 +14,15 @@ * limitations under the License. */ -import { debug } from '../../utilsBundle'; -import type * as channels from '@protocol/channels'; -import * as net from 'net'; import { EventEmitter } from 'events'; -import type { Backend, DeviceBackend, SocketBackend } from './android'; +import * as net from 'net'; + import { assert, createGuid } from '../../utils'; +import { debug } from '../../utilsBundle'; + +import type { Backend, DeviceBackend, SocketBackend } from './android'; +import type * as channels from '@protocol/channels'; + export class AdbBackend implements Backend { async devices(options: channels.AndroidDevicesOptions = {}): Promise { diff --git a/packages/playwright-core/src/server/artifact.ts b/packages/playwright-core/src/server/artifact.ts index 8824365b80..26b97d4d56 100644 --- a/packages/playwright-core/src/server/artifact.ts +++ b/packages/playwright-core/src/server/artifact.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import fs from 'fs'; +import * as fs from 'fs'; + import { assert } from '../utils'; -import { ManualPromise } from '../utils/manualPromise'; -import { SdkObject } from './instrumentation'; import { TargetClosedError } from './errors'; +import { SdkObject } from './instrumentation'; +import { ManualPromise } from '../utils/manualPromise'; type SaveCallback = (localPath: string, error?: Error) => Promise; type CancelCallback = () => Promise; diff --git a/packages/playwright-core/src/server/bidi/bidiBrowser.ts b/packages/playwright-core/src/server/bidi/bidiBrowser.ts index 96c48ea2a8..45c12bc347 100644 --- a/packages/playwright-core/src/server/bidi/bidiBrowser.ts +++ b/packages/playwright-core/src/server/bidi/bidiBrowser.ts @@ -14,23 +14,25 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import type { RegisteredListener } from '../../utils/eventsHelper'; import { eventsHelper } from '../../utils/eventsHelper'; -import type { BrowserOptions } from '../browser'; import { Browser } from '../browser'; -import { assertBrowserContextIsNotOwned, BrowserContext } from '../browserContext'; -import type { SdkObject } from '../instrumentation'; +import { BrowserContext, assertBrowserContextIsNotOwned } from '../browserContext'; import * as network from '../network'; -import type { InitScript, Page } from '../page'; -import type { ConnectionTransport } from '../transport'; -import type * as types from '../types'; -import type { BidiSession } from './bidiConnection'; import { BidiConnection } from './bidiConnection'; import { bidiBytesValueToString } from './bidiNetworkManager'; import { BidiPage } from './bidiPage'; import * as bidi from './third_party/bidiProtocol'; +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type { BrowserOptions } from '../browser'; +import type { SdkObject } from '../instrumentation'; +import type { InitScript, Page } from '../page'; +import type { ConnectionTransport } from '../transport'; +import type * as types from '../types'; +import type { BidiSession } from './bidiConnection'; +import type * as channels from '@protocol/channels'; + + export class BidiBrowser extends Browser { private readonly _connection: BidiConnection; readonly _browserSession: BidiSession; diff --git a/packages/playwright-core/src/server/bidi/bidiChromium.ts b/packages/playwright-core/src/server/bidi/bidiChromium.ts index 9572ac71ed..a46f1a017a 100644 --- a/packages/playwright-core/src/server/bidi/bidiChromium.ts +++ b/packages/playwright-core/src/server/bidi/bidiChromium.ts @@ -14,18 +14,21 @@ * limitations under the License. */ -import os from 'os'; +import * as os from 'os'; + import { assert, wrapInASCIIBox } from '../../utils'; +import { BrowserReadyState, BrowserType, kNoXServerRunningError } from '../browserType'; +import { BidiBrowser } from './bidiBrowser'; +import { kBrowserCloseMessageId } from './bidiConnection'; +import { chromiumSwitches } from '../chromium/chromiumSwitches'; + import type { Env } from '../../utils/processLauncher'; import type { BrowserOptions } from '../browser'; -import { BrowserReadyState, BrowserType, kNoXServerRunningError } from '../browserType'; -import { chromiumSwitches } from '../chromium/chromiumSwitches'; import type { SdkObject } from '../instrumentation'; import type { ProtocolError } from '../protocolError'; import type { ConnectionTransport } from '../transport'; import type * as types from '../types'; -import { BidiBrowser } from './bidiBrowser'; -import { kBrowserCloseMessageId } from './bidiConnection'; + export class BidiChromium extends BrowserType { constructor(parent: SdkObject) { diff --git a/packages/playwright-core/src/server/bidi/bidiConnection.ts b/packages/playwright-core/src/server/bidi/bidiConnection.ts index 48472bf748..87b3f59c9b 100644 --- a/packages/playwright-core/src/server/bidi/bidiConnection.ts +++ b/packages/playwright-core/src/server/bidi/bidiConnection.ts @@ -15,14 +15,16 @@ */ import { EventEmitter } from 'events'; -import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport'; -import type { RecentLogsCollector } from '../../utils/debugLogger'; + import { debugLogger } from '../../utils/debugLogger'; -import type { ProtocolLogger } from '../types'; import { helper } from '../helper'; import { ProtocolError } from '../protocolError'; -import type * as bidi from './third_party/bidiProtocol'; + +import type { RecentLogsCollector } from '../../utils/debugLogger'; +import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport'; +import type { ProtocolLogger } from '../types'; import type * as bidiCommands from './third_party/bidiCommands'; +import type * as bidi from './third_party/bidiProtocol'; // BidiPlaywright uses this special id to issue Browser.close command which we // should ignore. diff --git a/packages/playwright-core/src/server/bidi/bidiExecutionContext.ts b/packages/playwright-core/src/server/bidi/bidiExecutionContext.ts index de1b50bd1a..ec0cb681a0 100644 --- a/packages/playwright-core/src/server/bidi/bidiExecutionContext.ts +++ b/packages/playwright-core/src/server/bidi/bidiExecutionContext.ts @@ -16,11 +16,12 @@ import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers'; import * as js from '../javascript'; -import type { BidiSession } from './bidiConnection'; import { BidiDeserializer } from './third_party/bidiDeserializer'; import * as bidi from './third_party/bidiProtocol'; import { BidiSerializer } from './third_party/bidiSerializer'; +import type { BidiSession } from './bidiConnection'; + export class BidiExecutionContext implements js.ExecutionContextDelegate { private readonly _session: BidiSession; readonly _target: bidi.Script.Target; diff --git a/packages/playwright-core/src/server/bidi/bidiFirefox.ts b/packages/playwright-core/src/server/bidi/bidiFirefox.ts index 204cabdef7..94d943898f 100644 --- a/packages/playwright-core/src/server/bidi/bidiFirefox.ts +++ b/packages/playwright-core/src/server/bidi/bidiFirefox.ts @@ -14,19 +14,22 @@ * limitations under the License. */ -import os from 'os'; -import path from 'path'; +import * as os from 'os'; +import * as path from 'path'; + import { assert, wrapInASCIIBox } from '../../utils'; +import { BrowserReadyState, BrowserType, kNoXServerRunningError } from '../browserType'; +import { BidiBrowser } from './bidiBrowser'; +import { kBrowserCloseMessageId } from './bidiConnection'; +import { createProfile } from './third_party/firefoxPrefs'; + import type { Env } from '../../utils/processLauncher'; import type { BrowserOptions } from '../browser'; -import { BrowserReadyState, BrowserType, kNoXServerRunningError } from '../browserType'; import type { SdkObject } from '../instrumentation'; import type { ProtocolError } from '../protocolError'; import type { ConnectionTransport } from '../transport'; import type * as types from '../types'; -import { BidiBrowser } from './bidiBrowser'; -import { kBrowserCloseMessageId } from './bidiConnection'; -import { createProfile } from './third_party/firefoxPrefs'; + export class BidiFirefox extends BrowserType { constructor(parent: SdkObject) { diff --git a/packages/playwright-core/src/server/bidi/bidiInput.ts b/packages/playwright-core/src/server/bidi/bidiInput.ts index 01a359dd12..a7f8810da5 100644 --- a/packages/playwright-core/src/server/bidi/bidiInput.ts +++ b/packages/playwright-core/src/server/bidi/bidiInput.ts @@ -14,12 +14,13 @@ * limitations under the License. */ +import { resolveSmartModifierString } from '../input'; +import { getBidiKeyValue } from './third_party/bidiKeyboard'; +import * as bidi from './third_party/bidiProtocol'; + import type * as input from '../input'; import type * as types from '../types'; import type { BidiSession } from './bidiConnection'; -import * as bidi from './third_party/bidiProtocol'; -import { getBidiKeyValue } from './third_party/bidiKeyboard'; -import { resolveSmartModifierString } from '../input'; export class RawKeyboardImpl implements input.RawKeyboard { private _session: BidiSession; diff --git a/packages/playwright-core/src/server/bidi/bidiNetworkManager.ts b/packages/playwright-core/src/server/bidi/bidiNetworkManager.ts index c46ce90307..185eee86a0 100644 --- a/packages/playwright-core/src/server/bidi/bidiNetworkManager.ts +++ b/packages/playwright-core/src/server/bidi/bidiNetworkManager.ts @@ -14,15 +14,16 @@ * limitations under the License. */ -import type { RegisteredListener } from '../../utils/eventsHelper'; import { eventsHelper } from '../../utils/eventsHelper'; -import type { Page } from '../page'; -import * as network from '../network'; -import type * as frames from '../frames'; -import type * as types from '../types'; -import * as bidi from './third_party/bidiProtocol'; -import type { BidiSession } from './bidiConnection'; import { parseRawCookie } from '../cookieStore'; +import * as network from '../network'; +import * as bidi from './third_party/bidiProtocol'; + +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type * as frames from '../frames'; +import type { Page } from '../page'; +import type * as types from '../types'; +import type { BidiSession } from './bidiConnection'; export class BidiNetworkManager { diff --git a/packages/playwright-core/src/server/bidi/bidiOverCdp.ts b/packages/playwright-core/src/server/bidi/bidiOverCdp.ts index 1d01317c1e..adf7c9afbf 100644 --- a/packages/playwright-core/src/server/bidi/bidiOverCdp.ts +++ b/packages/playwright-core/src/server/bidi/bidiOverCdp.ts @@ -16,11 +16,13 @@ import * as bidiMapper from 'chromium-bidi/lib/cjs/bidiMapper/BidiMapper'; import * as bidiCdpConnection from 'chromium-bidi/lib/cjs/cdp/CdpConnection'; -import type * as bidiTransport from 'chromium-bidi/lib/cjs/utils/transport'; -import type { ChromiumBidi } from 'chromium-bidi/lib/cjs/protocol/protocol'; -import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport'; + import { debugLogger } from '../../utils/debugLogger'; +import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport'; +import type { ChromiumBidi } from 'chromium-bidi/lib/cjs/protocol/protocol'; +import type * as bidiTransport from 'chromium-bidi/lib/cjs/utils/transport'; + const bidiServerLogger = (prefix: string, ...args: unknown[]): void => { debugLogger.log(prefix as any, args); }; diff --git a/packages/playwright-core/src/server/bidi/bidiPage.ts b/packages/playwright-core/src/server/bidi/bidiPage.ts index cf0662738b..dd2d276c18 100644 --- a/packages/playwright-core/src/server/bidi/bidiPage.ts +++ b/packages/playwright-core/src/server/bidi/bidiPage.ts @@ -14,26 +14,27 @@ * limitations under the License. */ -import type { RegisteredListener } from '../../utils/eventsHelper'; -import { eventsHelper } from '../../utils/eventsHelper'; import { assert } from '../../utils'; -import type * as accessibility from '../accessibility'; -import * as dom from '../dom'; +import { eventsHelper } from '../../utils/eventsHelper'; +import { BrowserContext } from '../browserContext'; import * as dialog from '../dialog'; -import type * as frames from '../frames'; +import * as dom from '../dom'; import { Page } from '../page'; -import type * as channels from '@protocol/channels'; +import { BidiExecutionContext } from './bidiExecutionContext'; +import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './bidiInput'; +import { BidiNetworkManager } from './bidiNetworkManager'; +import { BidiPDF } from './bidiPdf'; +import * as bidi from './third_party/bidiProtocol'; + +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type * as accessibility from '../accessibility'; +import type * as frames from '../frames'; import type { InitScript, PageDelegate } from '../page'; import type { Progress } from '../progress'; import type * as types from '../types'; import type { BidiBrowserContext } from './bidiBrowser'; import type { BidiSession } from './bidiConnection'; -import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './bidiInput'; -import * as bidi from './third_party/bidiProtocol'; -import { BidiExecutionContext } from './bidiExecutionContext'; -import { BidiNetworkManager } from './bidiNetworkManager'; -import { BrowserContext } from '../browserContext'; -import { BidiPDF } from './bidiPdf'; +import type * as channels from '@protocol/channels'; const UTILITY_WORLD_NAME = '__playwright_utility_world__'; const kPlaywrightBindingChannel = 'playwrightChannel'; diff --git a/packages/playwright-core/src/server/bidi/bidiPdf.ts b/packages/playwright-core/src/server/bidi/bidiPdf.ts index 89fefb5260..b9a8c5cb92 100644 --- a/packages/playwright-core/src/server/bidi/bidiPdf.ts +++ b/packages/playwright-core/src/server/bidi/bidiPdf.ts @@ -16,8 +16,9 @@ */ import { assert } from '../../utils'; -import type * as channels from '@protocol/channels'; + import type { BidiSession } from './bidiConnection'; +import type * as channels from '@protocol/channels'; const PagePaperFormats: { [key: string]: { width: number, height: number }} = { letter: { width: 8.5, height: 11 }, diff --git a/packages/playwright-core/src/server/bidi/third_party/firefoxPrefs.ts b/packages/playwright-core/src/server/bidi/third_party/firefoxPrefs.ts index 3e0c347b52..4b246f6c3b 100644 --- a/packages/playwright-core/src/server/bidi/third_party/firefoxPrefs.ts +++ b/packages/playwright-core/src/server/bidi/third_party/firefoxPrefs.ts @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; /* eslint-disable curly, indent */ diff --git a/packages/playwright-core/src/server/browser.ts b/packages/playwright-core/src/server/browser.ts index 252443bc44..d99a3f8f8a 100644 --- a/packages/playwright-core/src/server/browser.ts +++ b/packages/playwright-core/src/server/browser.ts @@ -14,19 +14,21 @@ * limitations under the License. */ -import type * as types from './types'; -import type * as channels from '@protocol/channels'; -import { BrowserContext, validateBrowserContextOptions } from './browserContext'; -import { Page } from './page'; -import { Download } from './download'; -import type { ProxySettings } from './types'; -import type { ChildProcess } from 'child_process'; -import type { RecentLogsCollector } from '../utils/debugLogger'; -import type { CallMetadata } from './instrumentation'; -import { SdkObject } from './instrumentation'; import { Artifact } from './artifact'; +import { BrowserContext, validateBrowserContextOptions } from './browserContext'; +import { Download } from './download'; +import { SdkObject } from './instrumentation'; +import { Page } from './page'; import { ClientCertificatesProxy } from './socksClientCertificatesInterceptor'; +import type { CallMetadata } from './instrumentation'; +import type * as types from './types'; +import type { ProxySettings } from './types'; +import type { RecentLogsCollector } from '../utils/debugLogger'; +import type * as channels from '@protocol/channels'; +import type { ChildProcess } from 'child_process'; + + export interface BrowserProcess { onclose?: ((exitCode: number | null, signal: string | null) => void); process?: ChildProcess; diff --git a/packages/playwright-core/src/server/browserContext.ts b/packages/playwright-core/src/server/browserContext.ts index c4469f52b0..69f879ded6 100644 --- a/packages/playwright-core/src/server/browserContext.ts +++ b/packages/playwright-core/src/server/browserContext.ts @@ -15,36 +15,38 @@ * limitations under the License. */ +import * as fs from 'fs'; +import * as path from 'path'; + import { TimeoutSettings } from '../common/timeoutSettings'; import { createGuid, debugMode } from '../utils'; -import { mkdirIfNeeded } from '../utils/fileUtils'; -import type { Browser, BrowserOptions } from './browser'; -import type { Download } from './download'; -import type * as frames from './frames'; +import { Clock } from './clock'; +import { Debugger } from './debugger'; +import { BrowserContextAPIRequestContext } from './fetch'; +import { HarRecorder } from './har/harRecorder'; import { helper } from './helper'; +import { SdkObject, serverSideCallMetadata } from './instrumentation'; +import * as utilityScriptSerializers from './isomorphic/utilityScriptSerializers'; import * as network from './network'; import { InitScript } from './page'; import { Page, PageBinding } from './page'; +import { Recorder } from './recorder'; +import * as storageScript from './storageScript'; +import { mkdirIfNeeded } from '../utils/fileUtils'; +import { RecorderApp } from './recorder/recorderApp'; +import * as consoleApiSource from '../generated/consoleApiSource'; +import { Tracing } from './trace/recorder/tracing'; + +import type { Artifact } from './artifact'; +import type { Browser, BrowserOptions } from './browser'; +import type { Download } from './download'; +import type * as frames from './frames'; +import type { CallMetadata } from './instrumentation'; import type { Progress, ProgressController } from './progress'; import type { Selectors } from './selectors'; +import type { ClientCertificatesProxy } from './socksClientCertificatesInterceptor'; import type * as types from './types'; import type * as channels from '@protocol/channels'; -import path from 'path'; -import fs from 'fs'; -import type { CallMetadata } from './instrumentation'; -import { serverSideCallMetadata, SdkObject } from './instrumentation'; -import { Debugger } from './debugger'; -import { Tracing } from './trace/recorder/tracing'; -import { HarRecorder } from './har/harRecorder'; -import { Recorder } from './recorder'; -import * as consoleApiSource from '../generated/consoleApiSource'; -import { BrowserContextAPIRequestContext } from './fetch'; -import type { Artifact } from './artifact'; -import { Clock } from './clock'; -import type { ClientCertificatesProxy } from './socksClientCertificatesInterceptor'; -import { RecorderApp } from './recorder/recorderApp'; -import * as storageScript from './storageScript'; -import * as utilityScriptSerializers from './isomorphic/utilityScriptSerializers'; export abstract class BrowserContext extends SdkObject { static Events = { diff --git a/packages/playwright-core/src/server/browserType.ts b/packages/playwright-core/src/server/browserType.ts index 128b80a352..62ec63011e 100644 --- a/packages/playwright-core/src/server/browserType.ts +++ b/packages/playwright-core/src/server/browserType.ts @@ -14,32 +14,35 @@ * limitations under the License. */ -import fs from 'fs'; +import * as fs from 'fs'; import * as os from 'os'; -import path from 'path'; -import type { BrowserContext } from './browserContext'; +import * as path from 'path'; + import { normalizeProxySettings, validateBrowserContextOptions } from './browserContext'; -import type { BrowserName } from './registry'; -import { registry } from './registry'; -import type { ConnectionTransport } from './transport'; -import { WebSocketTransport } from './transport'; -import type { BrowserOptions, Browser, BrowserProcess } from './browser'; -import type { Env } from '../utils/processLauncher'; -import { launchProcess, envArrayToObject } from '../utils/processLauncher'; -import { PipeTransport } from './pipeTransport'; -import type { Progress } from './progress'; -import { ProgressController } from './progress'; -import type * as types from './types'; -import type * as channels from '@protocol/channels'; import { DEFAULT_TIMEOUT, TimeoutSettings } from '../common/timeoutSettings'; -import { debugMode, ManualPromise } from '../utils'; -import { existsAsync } from '../utils/fileUtils'; +import { ManualPromise, debugMode } from '../utils'; import { helper } from './helper'; -import { RecentLogsCollector } from '../utils/debugLogger'; -import type { CallMetadata } from './instrumentation'; import { SdkObject } from './instrumentation'; -import { type ProtocolError, isProtocolError } from './protocolError'; +import { PipeTransport } from './pipeTransport'; +import { ProgressController } from './progress'; +import { isProtocolError } from './protocolError'; +import { registry } from './registry'; import { ClientCertificatesProxy } from './socksClientCertificatesInterceptor'; +import { WebSocketTransport } from './transport'; +import { RecentLogsCollector } from '../utils/debugLogger'; +import { existsAsync } from '../utils/fileUtils'; +import { envArrayToObject, launchProcess } from '../utils/processLauncher'; + +import type { Browser, BrowserOptions, BrowserProcess } from './browser'; +import type { BrowserContext } from './browserContext'; +import type { CallMetadata } from './instrumentation'; +import type { Progress } from './progress'; +import type { ProtocolError } from './protocolError'; +import type { BrowserName } from './registry'; +import type { ConnectionTransport } from './transport'; +import type * as types from './types'; +import type { Env } from '../utils/processLauncher'; +import type * as channels from '@protocol/channels'; export const kNoXServerRunningError = 'Looks like you launched a headed browser without having a XServer running.\n' + 'Set either \'headless: true\' or use \'xvfb-run \' before running Playwright.\n\n<3 Playwright Team'; diff --git a/packages/playwright-core/src/server/chromium/chromium.ts b/packages/playwright-core/src/server/chromium/chromium.ts index 8fce8f51ca..badbe700bb 100644 --- a/packages/playwright-core/src/server/chromium/chromium.ts +++ b/packages/playwright-core/src/server/chromium/chromium.ts @@ -15,40 +15,42 @@ * limitations under the License. */ -import fs from 'fs'; -import os from 'os'; -import path from 'path'; -import type stream from 'stream'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + +import { chromiumSwitches } from './chromiumSwitches'; import { CRBrowser } from './crBrowser'; -import type { Env } from '../../utils/processLauncher'; -import { gracefullyCloseSet } from '../../utils/processLauncher'; import { kBrowserCloseMessageId } from './crConnection'; +import { TimeoutSettings } from '../../common/timeoutSettings'; +import { debugMode, headersArrayToObject, headersObjectToArray, } from '../../utils'; +import { wrapInASCIIBox } from '../../utils/ascii'; +import { RecentLogsCollector } from '../../utils/debugLogger'; +import { removeFolders } from '../../utils/fileUtils'; +import { ManualPromise } from '../../utils/manualPromise'; +import { fetchData } from '../../utils/network'; +import { gracefullyCloseSet } from '../../utils/processLauncher'; +import { getUserAgent } from '../../utils/userAgent'; +import { validateBrowserContextOptions } from '../browserContext'; import { BrowserType, kNoXServerRunningError } from '../browserType'; import { BrowserReadyState } from '../browserType'; -import type { ConnectionTransport, ProtocolRequest } from '../transport'; +import { helper } from '../helper'; +import { registry } from '../registry'; import { WebSocketTransport } from '../transport'; import { CRDevTools } from './crDevTools'; -import type { BrowserOptions, BrowserProcess } from '../browser'; import { Browser } from '../browser'; -import type * as types from '../types'; -import type { HTTPRequestParams } from '../../utils/network'; -import { fetchData } from '../../utils/network'; -import { getUserAgent } from '../../utils/userAgent'; -import { wrapInASCIIBox } from '../../utils/ascii'; -import { debugMode, headersArrayToObject, headersObjectToArray, } from '../../utils'; -import { removeFolders } from '../../utils/fileUtils'; -import { RecentLogsCollector } from '../../utils/debugLogger'; -import type { Progress } from '../progress'; import { ProgressController } from '../progress'; -import { TimeoutSettings } from '../../common/timeoutSettings'; -import { helper } from '../helper'; + +import type { HTTPRequestParams } from '../../utils/network'; +import type { Env } from '../../utils/processLauncher'; +import type { BrowserOptions, BrowserProcess } from '../browser'; import type { CallMetadata, SdkObject } from '../instrumentation'; -import type http from 'http'; -import { registry } from '../registry'; -import { ManualPromise } from '../../utils/manualPromise'; -import { validateBrowserContextOptions } from '../browserContext'; -import { chromiumSwitches } from './chromiumSwitches'; +import type { Progress } from '../progress'; import type { ProtocolError } from '../protocolError'; +import type { ConnectionTransport, ProtocolRequest } from '../transport'; +import type * as types from '../types'; +import type http from 'http'; +import type stream from 'stream'; const ARTIFACTS_FOLDER = path.join(os.tmpdir(), 'playwright-artifacts-'); diff --git a/packages/playwright-core/src/server/chromium/crAccessibility.ts b/packages/playwright-core/src/server/chromium/crAccessibility.ts index 4114663a0e..539f3057c7 100644 --- a/packages/playwright-core/src/server/chromium/crAccessibility.ts +++ b/packages/playwright-core/src/server/chromium/crAccessibility.ts @@ -17,8 +17,8 @@ import type { CRSession } from './crConnection'; import type { Protocol } from './protocol'; -import type * as dom from '../dom'; import type * as accessibility from '../accessibility'; +import type * as dom from '../dom'; import type * as channels from '@protocol/channels'; export async function getAccessibilityTree(client: CRSession, needle?: dom.ElementHandle): Promise<{tree: accessibility.AXNode, needle: accessibility.AXNode | null}> { diff --git a/packages/playwright-core/src/server/chromium/crBrowser.ts b/packages/playwright-core/src/server/chromium/crBrowser.ts index 9f03803dcb..51ad0ae887 100644 --- a/packages/playwright-core/src/server/chromium/crBrowser.ts +++ b/packages/playwright-core/src/server/chromium/crBrowser.ts @@ -15,28 +15,30 @@ * limitations under the License. */ -import type { BrowserOptions } from '../browser'; -import path from 'path'; -import { Browser } from '../browser'; -import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext'; +import * as path from 'path'; + import { assert, createGuid } from '../../utils'; -import * as network from '../network'; -import type { InitScript, Worker } from '../page'; -import { Page } from '../page'; +import { Artifact } from '../artifact'; +import { Browser } from '../browser'; +import { BrowserContext, assertBrowserContextIsNotOwned, verifyGeolocation } from '../browserContext'; import { Frame } from '../frames'; -import type { Dialog } from '../dialog'; -import type { ConnectionTransport } from '../transport'; -import type * as types from '../types'; -import type * as channels from '@protocol/channels'; -import type { CRSession, CDPSession } from './crConnection'; -import { ConnectionEvents, CRConnection } from './crConnection'; +import * as network from '../network'; +import { Page } from '../page'; +import { CRConnection, ConnectionEvents } from './crConnection'; import { CRPage } from './crPage'; import { saveProtocolStream } from './crProtocolHelper'; -import type { Protocol } from './protocol'; -import type { CRDevTools } from './crDevTools'; import { CRServiceWorker } from './crServiceWorker'; + +import type { Dialog } from '../dialog'; +import type { InitScript, Worker } from '../page'; +import type { ConnectionTransport } from '../transport'; +import type * as types from '../types'; +import type { CDPSession, CRSession } from './crConnection'; +import type { CRDevTools } from './crDevTools'; +import type { Protocol } from './protocol'; +import type { BrowserOptions } from '../browser'; import type { SdkObject } from '../instrumentation'; -import { Artifact } from '../artifact'; +import type * as channels from '@protocol/channels'; export class CRBrowser extends Browser { readonly _connection: CRConnection; diff --git a/packages/playwright-core/src/server/chromium/crConnection.ts b/packages/playwright-core/src/server/chromium/crConnection.ts index c257d0d7ec..424d64a500 100644 --- a/packages/playwright-core/src/server/chromium/crConnection.ts +++ b/packages/playwright-core/src/server/chromium/crConnection.ts @@ -15,16 +15,20 @@ * limitations under the License. */ -import { type RegisteredListener, assert, eventsHelper } from '../../utils'; -import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport'; -import type { Protocol } from './protocol'; import { EventEmitter } from 'events'; -import type { RecentLogsCollector } from '../../utils/debugLogger'; + +import { assert, eventsHelper } from '../../utils'; import { debugLogger } from '../../utils/debugLogger'; -import type { ProtocolLogger } from '../types'; import { helper } from '../helper'; import { ProtocolError } from '../protocolError'; +import type { RegisteredListener } from '../../utils'; +import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport'; +import type { Protocol } from './protocol'; +import type { RecentLogsCollector } from '../../utils/debugLogger'; +import type { ProtocolLogger } from '../types'; + + export const ConnectionEvents = { Disconnected: Symbol('ConnectionEvents.Disconnected') }; diff --git a/packages/playwright-core/src/server/chromium/crCoverage.ts b/packages/playwright-core/src/server/chromium/crCoverage.ts index ccb9b40ae0..81dd2c0f4c 100644 --- a/packages/playwright-core/src/server/chromium/crCoverage.ts +++ b/packages/playwright-core/src/server/chromium/crCoverage.ts @@ -15,12 +15,14 @@ * limitations under the License. */ -import type { CRSession } from './crConnection'; -import type { RegisteredListener } from '../../utils/eventsHelper'; -import { eventsHelper } from '../../utils/eventsHelper'; -import type { Protocol } from './protocol'; -import type * as channels from '@protocol/channels'; import { assert } from '../../utils'; +import { eventsHelper } from '../../utils/eventsHelper'; + +import type { CRSession } from './crConnection'; +import type { Protocol } from './protocol'; +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type * as channels from '@protocol/channels'; + export class CRCoverage { private _jsCoverage: JSCoverage; diff --git a/packages/playwright-core/src/server/chromium/crDevTools.ts b/packages/playwright-core/src/server/chromium/crDevTools.ts index 40cd134bcc..f6e6774416 100644 --- a/packages/playwright-core/src/server/chromium/crDevTools.ts +++ b/packages/playwright-core/src/server/chromium/crDevTools.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import fs from 'fs'; +import * as fs from 'fs'; + import type { CRSession } from './crConnection'; const kBindingName = '__pw_devtools__'; diff --git a/packages/playwright-core/src/server/chromium/crDragDrop.ts b/packages/playwright-core/src/server/chromium/crDragDrop.ts index ea4af1ce7e..f94a306701 100644 --- a/packages/playwright-core/src/server/chromium/crDragDrop.ts +++ b/packages/playwright-core/src/server/chromium/crDragDrop.ts @@ -13,11 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { toModifiersMask } from './crProtocolHelper'; +import { assert } from '../../utils'; + import type { CRPage } from './crPage'; import type * as types from '../types'; -import { assert } from '../../utils'; import type { Protocol } from './protocol'; -import { toModifiersMask } from './crProtocolHelper'; + declare global { interface Window { diff --git a/packages/playwright-core/src/server/chromium/crExecutionContext.ts b/packages/playwright-core/src/server/chromium/crExecutionContext.ts index 661d216fb4..bd1b64099b 100644 --- a/packages/playwright-core/src/server/chromium/crExecutionContext.ts +++ b/packages/playwright-core/src/server/chromium/crExecutionContext.ts @@ -15,14 +15,15 @@ * limitations under the License. */ -import type { CRSession } from './crConnection'; import { getExceptionMessage, releaseObject } from './crProtocolHelper'; -import type { Protocol } from './protocol'; -import * as js from '../javascript'; import { rewriteErrorMessage } from '../../utils/stackTrace'; import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers'; +import * as js from '../javascript'; import { isSessionClosedError } from '../protocolError'; +import type { CRSession } from './crConnection'; +import type { Protocol } from './protocol'; + export class CRExecutionContext implements js.ExecutionContextDelegate { _client: CRSession; _contextId: number; diff --git a/packages/playwright-core/src/server/chromium/crInput.ts b/packages/playwright-core/src/server/chromium/crInput.ts index e08f3b0233..60c7130425 100644 --- a/packages/playwright-core/src/server/chromium/crInput.ts +++ b/packages/playwright-core/src/server/chromium/crInput.ts @@ -15,14 +15,16 @@ * limitations under the License. */ +import { isString } from '../../utils'; import * as input from '../input'; +import { macEditingCommands } from '../macEditingCommands'; +import { toButtonsMask, toModifiersMask } from './crProtocolHelper'; + import type * as types from '../types'; import type { CRSession } from './crConnection'; -import { macEditingCommands } from '../macEditingCommands'; -import { isString } from '../../utils'; import type { DragManager } from './crDragDrop'; import type { CRPage } from './crPage'; -import { toButtonsMask, toModifiersMask } from './crProtocolHelper'; + export class RawKeyboardImpl implements input.RawKeyboard { constructor( diff --git a/packages/playwright-core/src/server/chromium/crNetworkManager.ts b/packages/playwright-core/src/server/chromium/crNetworkManager.ts index a8ff5a08dc..b9a5447189 100644 --- a/packages/playwright-core/src/server/chromium/crNetworkManager.ts +++ b/packages/playwright-core/src/server/chromium/crNetworkManager.ts @@ -15,20 +15,22 @@ * limitations under the License. */ -import type { CRSession } from './crConnection'; -import type { Page } from '../page'; -import { helper } from '../helper'; -import type { RegisteredListener } from '../../utils/eventsHelper'; +import { assert, headersArrayToObject, headersObjectToArray } from '../../utils'; import { eventsHelper } from '../../utils/eventsHelper'; -import type { Protocol } from './protocol'; +import { helper } from '../helper'; import * as network from '../network'; +import { isProtocolError, isSessionClosedError } from '../protocolError'; + +import type { CRSession } from './crConnection'; +import type { Protocol } from './protocol'; +import type { RegisteredListener } from '../../utils/eventsHelper'; import type * as contexts from '../browserContext'; import type * as frames from '../frames'; +import type { Page } from '../page'; import type * as types from '../types'; import type { CRPage } from './crPage'; -import { assert, headersArrayToObject, headersObjectToArray } from '../../utils'; import type { CRServiceWorker } from './crServiceWorker'; -import { isProtocolError, isSessionClosedError } from '../protocolError'; + type SessionInfo = { session: CRSession; diff --git a/packages/playwright-core/src/server/chromium/crPage.ts b/packages/playwright-core/src/server/chromium/crPage.ts index 9fb43b2d51..65122407a0 100644 --- a/packages/playwright-core/src/server/chromium/crPage.ts +++ b/packages/playwright-core/src/server/chromium/crPage.ts @@ -15,25 +15,21 @@ * limitations under the License. */ -import path from 'path'; -import type { RegisteredListener } from '../../utils/eventsHelper'; -import { eventsHelper } from '../../utils/eventsHelper'; -import { registry } from '../registry'; -import { rewriteErrorMessage } from '../../utils/stackTrace'; +import * as path from 'path'; + import { assert, createGuid } from '../../utils'; +import { eventsHelper } from '../../utils/eventsHelper'; +import { rewriteErrorMessage } from '../../utils/stackTrace'; import * as dialog from '../dialog'; import * as dom from '../dom'; import * as frames from '../frames'; import { helper } from '../helper'; import * as network from '../network'; -import { type InitScript, PageBinding, type PageDelegate } from '../page'; +import { PageBinding } from '../page'; import { Page, Worker } from '../page'; -import type { Progress } from '../progress'; -import type * as types from '../types'; -import type * as channels from '@protocol/channels'; +import { registry } from '../registry'; import { getAccessibilityTree } from './crAccessibility'; import { CRBrowserContext } from './crBrowser'; -import type { CRSession } from './crConnection'; import { CRCoverage } from './crCoverage'; import { DragManager } from './crDragDrop'; import { CRExecutionContext } from './crExecutionContext'; @@ -42,12 +38,19 @@ import { CRNetworkManager } from './crNetworkManager'; import { CRPDF } from './crPdf'; import { exceptionToError, releaseObject, toConsoleMessageLocation } from './crProtocolHelper'; import { platformToFontFamilies } from './defaultFontFamilies'; -import type { Protocol } from './protocol'; import { VideoRecorder } from './videoRecorder'; import { BrowserContext } from '../browserContext'; import { TargetClosedError } from '../errors'; import { isSessionClosedError } from '../protocolError'; +import type { CRSession } from './crConnection'; +import type { Protocol } from './protocol'; +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type { InitScript, PageDelegate } from '../page'; +import type { Progress } from '../progress'; +import type * as types from '../types'; +import type * as channels from '@protocol/channels'; + const UTILITY_WORLD_NAME = '__playwright_utility_world__'; export type WindowBounds = { top?: number, left?: number, width?: number, height?: number }; diff --git a/packages/playwright-core/src/server/chromium/crPdf.ts b/packages/playwright-core/src/server/chromium/crPdf.ts index 8dae2d1fa1..70d11208b9 100644 --- a/packages/playwright-core/src/server/chromium/crPdf.ts +++ b/packages/playwright-core/src/server/chromium/crPdf.ts @@ -15,10 +15,11 @@ * limitations under the License. */ -import { assert } from '../../utils'; -import type * as channels from '@protocol/channels'; -import type { CRSession } from './crConnection'; import { readProtocolStream } from './crProtocolHelper'; +import { assert } from '../../utils'; + +import type { CRSession } from './crConnection'; +import type * as channels from '@protocol/channels'; const PagePaperFormats: { [key: string]: { width: number, height: number }} = { letter: { width: 8.5, height: 11 }, diff --git a/packages/playwright-core/src/server/chromium/crProtocolHelper.ts b/packages/playwright-core/src/server/chromium/crProtocolHelper.ts index 9458bed124..4852626b93 100644 --- a/packages/playwright-core/src/server/chromium/crProtocolHelper.ts +++ b/packages/playwright-core/src/server/chromium/crProtocolHelper.ts @@ -15,13 +15,16 @@ * limitations under the License. */ -import type { CRSession } from './crConnection'; -import type { Protocol } from './protocol'; -import fs from 'fs'; -import type * as types from '../types'; +import * as fs from 'fs'; + import { mkdirIfNeeded } from '../../utils/fileUtils'; import { splitErrorMessage } from '../../utils/stackTrace'; +import type { CRSession } from './crConnection'; +import type { Protocol } from './protocol'; +import type * as types from '../types'; + + export function getExceptionMessage(exceptionDetails: Protocol.Runtime.ExceptionDetails): string { if (exceptionDetails.exception) return exceptionDetails.exception.description || String(exceptionDetails.exception.value); diff --git a/packages/playwright-core/src/server/chromium/crServiceWorker.ts b/packages/playwright-core/src/server/chromium/crServiceWorker.ts index 730504866b..deb858cfa2 100644 --- a/packages/playwright-core/src/server/chromium/crServiceWorker.ts +++ b/packages/playwright-core/src/server/chromium/crServiceWorker.ts @@ -14,12 +14,13 @@ * limitations under the License. */ import { Worker } from '../page'; -import type { CRBrowserContext } from './crBrowser'; -import type { CRSession } from './crConnection'; import { CRExecutionContext } from './crExecutionContext'; import { CRNetworkManager } from './crNetworkManager'; -import * as network from '../network'; import { BrowserContext } from '../browserContext'; +import * as network from '../network'; + +import type { CRBrowserContext } from './crBrowser'; +import type { CRSession } from './crConnection'; export class CRServiceWorker extends Worker { readonly _browserContext: CRBrowserContext; diff --git a/packages/playwright-core/src/server/chromium/videoRecorder.ts b/packages/playwright-core/src/server/chromium/videoRecorder.ts index 68bfbea037..e8f96e4129 100644 --- a/packages/playwright-core/src/server/chromium/videoRecorder.ts +++ b/packages/playwright-core/src/server/chromium/videoRecorder.ts @@ -14,14 +14,15 @@ * limitations under the License. */ -import type { ChildProcess } from 'child_process'; import { assert, monotonicTime } from '../../utils'; -import { Page } from '../page'; import { launchProcess } from '../../utils/processLauncher'; -import type { Progress } from '../progress'; -import { ProgressController } from '../progress'; import { serverSideCallMetadata } from '../instrumentation'; +import { Page } from '../page'; +import { ProgressController } from '../progress'; + +import type { Progress } from '../progress'; import type * as types from '../types'; +import type { ChildProcess } from 'child_process'; const fps = 25; diff --git a/packages/playwright-core/src/server/clock.ts b/packages/playwright-core/src/server/clock.ts index e77399c4fe..59cc05c208 100644 --- a/packages/playwright-core/src/server/clock.ts +++ b/packages/playwright-core/src/server/clock.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { BrowserContext } from './browserContext'; import * as clockSource from '../generated/clockSource'; +import type { BrowserContext } from './browserContext'; + export class Clock { private _browserContext: BrowserContext; private _scriptInstalled = false; diff --git a/packages/playwright-core/src/server/codegen/csharp.ts b/packages/playwright-core/src/server/codegen/csharp.ts index 548a06343a..9fd67fa96c 100644 --- a/packages/playwright-core/src/server/codegen/csharp.ts +++ b/packages/playwright-core/src/server/codegen/csharp.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { BrowserContextOptions } from '../../../types/types'; -import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; -import type * as actions from '@recorder/actions'; import { sanitizeDeviceOptions, toClickOptionsForSourceCode, toKeyboardModifiers, toSignalMap } from './language'; -import { escapeWithQuotes, asLocator } from '../../utils'; +import { asLocator, escapeWithQuotes } from '../../utils'; import { deviceDescriptors } from '../deviceDescriptors'; +import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; +import type { BrowserContextOptions } from '../../../types/types'; +import type * as actions from '@recorder/actions'; + type CSharpLanguageMode = 'library' | 'mstest' | 'nunit'; export class CSharpLanguageGenerator implements LanguageGenerator { diff --git a/packages/playwright-core/src/server/codegen/java.ts b/packages/playwright-core/src/server/codegen/java.ts index ac04783c23..42456eb4a9 100644 --- a/packages/playwright-core/src/server/codegen/java.ts +++ b/packages/playwright-core/src/server/codegen/java.ts @@ -14,14 +14,15 @@ * limitations under the License. */ -import type { BrowserContextOptions } from '../../../types/types'; -import type * as types from '../types'; -import type * as actions from '@recorder/actions'; -import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; import { toClickOptionsForSourceCode, toKeyboardModifiers, toSignalMap } from './language'; import { deviceDescriptors } from '../deviceDescriptors'; import { JavaScriptFormatter } from './javascript'; -import { escapeWithQuotes, asLocator } from '../../utils'; +import { asLocator, escapeWithQuotes } from '../../utils'; + +import type { BrowserContextOptions } from '../../../types/types'; +import type * as types from '../types'; +import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; +import type * as actions from '@recorder/actions'; type JavaLanguageMode = 'library' | 'junit'; diff --git a/packages/playwright-core/src/server/codegen/javascript.ts b/packages/playwright-core/src/server/codegen/javascript.ts index 80cb10926b..568f0a5113 100644 --- a/packages/playwright-core/src/server/codegen/javascript.ts +++ b/packages/playwright-core/src/server/codegen/javascript.ts @@ -14,12 +14,13 @@ * limitations under the License. */ -import type { BrowserContextOptions } from '../../../types/types'; -import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; -import type * as actions from '@recorder/actions'; -import { sanitizeDeviceOptions, toSignalMap, toKeyboardModifiers, toClickOptionsForSourceCode } from './language'; +import { sanitizeDeviceOptions, toClickOptionsForSourceCode, toKeyboardModifiers, toSignalMap } from './language'; +import { asLocator, escapeWithQuotes } from '../../utils'; import { deviceDescriptors } from '../deviceDescriptors'; -import { escapeWithQuotes, asLocator } from '../../utils'; + +import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; +import type { BrowserContextOptions } from '../../../types/types'; +import type * as actions from '@recorder/actions'; export class JavaScriptLanguageGenerator implements LanguageGenerator { id: string; diff --git a/packages/playwright-core/src/server/codegen/jsonl.ts b/packages/playwright-core/src/server/codegen/jsonl.ts index e6769cd8d7..9457c45f4c 100644 --- a/packages/playwright-core/src/server/codegen/jsonl.ts +++ b/packages/playwright-core/src/server/codegen/jsonl.ts @@ -15,8 +15,9 @@ */ import { asLocator } from '../../utils'; -import type * as actions from '@recorder/actions'; + import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; +import type * as actions from '@recorder/actions'; export class JsonlLanguageGenerator implements LanguageGenerator { id = 'jsonl'; diff --git a/packages/playwright-core/src/server/codegen/language.ts b/packages/playwright-core/src/server/codegen/language.ts index b38959b89b..9eba5e6725 100644 --- a/packages/playwright-core/src/server/codegen/language.ts +++ b/packages/playwright-core/src/server/codegen/language.ts @@ -15,9 +15,9 @@ */ import type { BrowserContextOptions } from '../../..'; -import type * as actions from '@recorder/actions'; import type * as types from '../types'; import type { LanguageGenerator, LanguageGeneratorOptions } from './types'; +import type * as actions from '@recorder/actions'; export function generateCode(actions: actions.ActionInContext[], languageGenerator: LanguageGenerator, options: LanguageGeneratorOptions) { const header = languageGenerator.generateHeader(options); diff --git a/packages/playwright-core/src/server/codegen/languages.ts b/packages/playwright-core/src/server/codegen/languages.ts index d379be6be7..0a17208835 100644 --- a/packages/playwright-core/src/server/codegen/languages.ts +++ b/packages/playwright-core/src/server/codegen/languages.ts @@ -14,10 +14,10 @@ * limitations under the License. */ +import { CSharpLanguageGenerator } from './csharp'; import { JavaLanguageGenerator } from './java'; import { JavaScriptLanguageGenerator } from './javascript'; import { JsonlLanguageGenerator } from './jsonl'; -import { CSharpLanguageGenerator } from './csharp'; import { PythonLanguageGenerator } from './python'; export function languageSet() { diff --git a/packages/playwright-core/src/server/codegen/python.ts b/packages/playwright-core/src/server/codegen/python.ts index 714265a25c..d7b056f083 100644 --- a/packages/playwright-core/src/server/codegen/python.ts +++ b/packages/playwright-core/src/server/codegen/python.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { BrowserContextOptions } from '../../../types/types'; -import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; -import type * as actions from '@recorder/actions'; -import { sanitizeDeviceOptions, toSignalMap, toKeyboardModifiers, toClickOptionsForSourceCode } from './language'; -import { escapeWithQuotes, toSnakeCase, asLocator } from '../../utils'; +import { sanitizeDeviceOptions, toClickOptionsForSourceCode, toKeyboardModifiers, toSignalMap } from './language'; +import { asLocator, escapeWithQuotes, toSnakeCase } from '../../utils'; import { deviceDescriptors } from '../deviceDescriptors'; +import type { Language, LanguageGenerator, LanguageGeneratorOptions } from './types'; +import type { BrowserContextOptions } from '../../../types/types'; +import type * as actions from '@recorder/actions'; + export class PythonLanguageGenerator implements LanguageGenerator { id: string; groupName = 'Python'; diff --git a/packages/playwright-core/src/server/codegen/types.ts b/packages/playwright-core/src/server/codegen/types.ts index 81cd59948b..da3583e2f6 100644 --- a/packages/playwright-core/src/server/codegen/types.ts +++ b/packages/playwright-core/src/server/codegen/types.ts @@ -15,8 +15,8 @@ */ import type { BrowserContextOptions, LaunchOptions } from '../../../types/types'; -import type * as actions from '@recorder/actions'; import type { Language } from '../../utils'; +import type * as actions from '@recorder/actions'; export type { Language } from '../../utils'; export type LanguageGeneratorOptions = { diff --git a/packages/playwright-core/src/server/console.ts b/packages/playwright-core/src/server/console.ts index e1faa7fb8f..383b49fc82 100644 --- a/packages/playwright-core/src/server/console.ts +++ b/packages/playwright-core/src/server/console.ts @@ -15,8 +15,8 @@ */ import type * as js from './javascript'; -import type { ConsoleMessageLocation } from './types'; import type { Page } from './page'; +import type { ConsoleMessageLocation } from './types'; export class ConsoleMessage { private _type: string; diff --git a/packages/playwright-core/src/server/cookieStore.ts b/packages/playwright-core/src/server/cookieStore.ts index d1842660c7..34ebc72874 100644 --- a/packages/playwright-core/src/server/cookieStore.ts +++ b/packages/playwright-core/src/server/cookieStore.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { kMaxCookieExpiresDateInSeconds } from './network'; +import type * as channels from '@protocol/channels'; + class Cookie { private _raw: channels.NetworkCookie; constructor(data: channels.NetworkCookie) { diff --git a/packages/playwright-core/src/server/debugController.ts b/packages/playwright-core/src/server/debugController.ts index 468b550f48..601a8338b9 100644 --- a/packages/playwright-core/src/server/debugController.ts +++ b/packages/playwright-core/src/server/debugController.ts @@ -14,19 +14,21 @@ * limitations under the License. */ -import type { ElementInfo, Mode, Source } from '@recorder/recorderTypes'; +import { SdkObject, createInstrumentation, serverSideCallMetadata } from './instrumentation'; +import { Recorder } from './recorder'; +import { asLocator } from '../utils'; +import { parseAriaSnapshotUnsafe } from '../utils/isomorphic/ariaSnapshot'; +import { yaml } from '../utilsBundle'; +import { EmptyRecorderApp } from './recorder/recorderApp'; +import { unsafeLocatorOrSelectorAsSelector } from '../utils/isomorphic/locatorParser'; import { gracefullyProcessExitDoNotHang } from '../utils/processLauncher'; + +import type { Language } from '../utils'; import type { Browser } from './browser'; import type { BrowserContext } from './browserContext'; -import { createInstrumentation, SdkObject, serverSideCallMetadata } from './instrumentation'; import type { InstrumentationListener } from './instrumentation'; import type { Playwright } from './playwright'; -import { Recorder } from './recorder'; -import { EmptyRecorderApp } from './recorder/recorderApp'; -import { asLocator, type Language } from '../utils'; -import { yaml } from '../utilsBundle'; -import { unsafeLocatorOrSelectorAsSelector } from '../utils/isomorphic/locatorParser'; -import { parseAriaSnapshotUnsafe } from '../utils/isomorphic/ariaSnapshot'; +import type { ElementInfo, Mode, Source } from '@recorder/recorderTypes'; const internalMetadata = serverSideCallMetadata(); diff --git a/packages/playwright-core/src/server/debugger.ts b/packages/playwright-core/src/server/debugger.ts index 53a96ba8f2..530a62843d 100644 --- a/packages/playwright-core/src/server/debugger.ts +++ b/packages/playwright-core/src/server/debugger.ts @@ -15,11 +15,13 @@ */ import { EventEmitter } from 'events'; + import { debugMode, isUnderTest, monotonicTime } from '../utils'; import { BrowserContext } from './browserContext'; -import type { CallMetadata, InstrumentationListener, SdkObject } from './instrumentation'; import { commandsWithTracingSnapshots, pausesBeforeInputActions, slowMoActions } from '../protocol/debug'; +import type { CallMetadata, InstrumentationListener, SdkObject } from './instrumentation'; + const symbol = Symbol('Debugger'); export class Debugger extends EventEmitter implements InstrumentationListener { diff --git a/packages/playwright-core/src/server/deviceDescriptors.ts b/packages/playwright-core/src/server/deviceDescriptors.ts index b46789c0e5..c4ad1f73fa 100644 --- a/packages/playwright-core/src/server/deviceDescriptors.ts +++ b/packages/playwright-core/src/server/deviceDescriptors.ts @@ -15,8 +15,9 @@ * limitations under the License. */ -import type { Devices } from './types'; - import deviceDescriptorsSource from './deviceDescriptorsSource.json'; +import type { Devices } from './types'; + + export const deviceDescriptors = deviceDescriptorsSource as Devices; diff --git a/packages/playwright-core/src/server/dialog.ts b/packages/playwright-core/src/server/dialog.ts index f0793d43fb..38ec035384 100644 --- a/packages/playwright-core/src/server/dialog.ts +++ b/packages/playwright-core/src/server/dialog.ts @@ -16,9 +16,10 @@ */ import { assert } from '../utils'; -import type { Page } from './page'; import { SdkObject } from './instrumentation'; +import type { Page } from './page'; + type OnHandle = (accept: boolean, promptText?: string) => Promise; export type DialogType = 'alert' | 'beforeunload' | 'confirm' | 'prompt'; diff --git a/packages/playwright-core/src/server/dispatchers/androidDispatcher.ts b/packages/playwright-core/src/server/dispatchers/androidDispatcher.ts index 77f38c5558..c20670dd69 100644 --- a/packages/playwright-core/src/server/dispatchers/androidDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/androidDispatcher.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { RootDispatcher } from './dispatcher'; -import { Dispatcher, existingDispatcher } from './dispatcher'; -import type { Android, SocketBackend } from '../android/android'; -import { AndroidDevice } from '../android/android'; -import type * as channels from '@protocol/channels'; import { BrowserContextDispatcher } from './browserContextDispatcher'; +import { Dispatcher, existingDispatcher } from './dispatcher'; +import { AndroidDevice } from '../android/android'; + +import type { RootDispatcher } from './dispatcher'; +import type { Android, SocketBackend } from '../android/android'; import type { CallMetadata } from '../instrumentation'; +import type * as channels from '@protocol/channels'; export class AndroidDispatcher extends Dispatcher implements channels.AndroidChannel { _type_Android = true; diff --git a/packages/playwright-core/src/server/dispatchers/artifactDispatcher.ts b/packages/playwright-core/src/server/dispatchers/artifactDispatcher.ts index 1996f11776..d43a846607 100644 --- a/packages/playwright-core/src/server/dispatchers/artifactDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/artifactDispatcher.ts @@ -14,14 +14,16 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; +import * as fs from 'fs'; + import { Dispatcher, existingDispatcher } from './dispatcher'; -import type { DispatcherScope } from './dispatcher'; import { StreamDispatcher } from './streamDispatcher'; -import fs from 'fs'; import { mkdirIfNeeded } from '../../utils/fileUtils'; + +import type { DispatcherScope } from './dispatcher'; import type { Artifact } from '../artifact'; import type { CallMetadata } from '../instrumentation'; +import type * as channels from '@protocol/channels'; export class ArtifactDispatcher extends Dispatcher implements channels.ArtifactChannel { _type_Artifact = true; diff --git a/packages/playwright-core/src/server/dispatchers/browserContextDispatcher.ts b/packages/playwright-core/src/server/dispatchers/browserContextDispatcher.ts index 9ee416ce85..3488964e8e 100644 --- a/packages/playwright-core/src/server/dispatchers/browserContextDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/browserContextDispatcher.ts @@ -14,33 +14,35 @@ * limitations under the License. */ -import { BrowserContext } from '../browserContext'; -import { Dispatcher, existingDispatcher } from './dispatcher'; -import type { DispatcherScope } from './dispatcher'; -import { PageDispatcher, BindingCallDispatcher, WorkerDispatcher } from './pageDispatcher'; -import type { FrameDispatcher } from './frameDispatcher'; -import type * as channels from '@protocol/channels'; -import { RouteDispatcher, RequestDispatcher, ResponseDispatcher, APIRequestContextDispatcher } from './networkDispatchers'; -import { CRBrowserContext } from '../chromium/crBrowser'; -import { CDPSessionDispatcher } from './cdpSessionDispatcher'; -import { Recorder } from '../recorder'; -import type { CallMetadata } from '../instrumentation'; -import { ArtifactDispatcher } from './artifactDispatcher'; -import type { Artifact } from '../artifact'; -import type { Request, Response } from '../network'; -import { TracingDispatcher } from './tracingDispatcher'; import * as fs from 'fs'; import * as path from 'path'; -import { createGuid, urlMatches } from '../../utils'; -import { WritableStreamDispatcher } from './writableStreamDispatcher'; + +import { BrowserContext } from '../browserContext'; +import { ArtifactDispatcher } from './artifactDispatcher'; +import { CDPSessionDispatcher } from './cdpSessionDispatcher'; import { DialogDispatcher } from './dialogDispatcher'; -import type { Page } from '../page'; -import type { Dialog } from '../dialog'; -import type { ConsoleMessage } from '../console'; -import { serializeError } from '../errors'; +import { Dispatcher, existingDispatcher } from './dispatcher'; import { ElementHandleDispatcher } from './elementHandlerDispatcher'; -import { RecorderApp } from '../recorder/recorderApp'; +import { APIRequestContextDispatcher, RequestDispatcher, ResponseDispatcher, RouteDispatcher } from './networkDispatchers'; +import { BindingCallDispatcher, PageDispatcher, WorkerDispatcher } from './pageDispatcher'; +import { CRBrowserContext } from '../chromium/crBrowser'; +import { serializeError } from '../errors'; +import { Recorder } from '../recorder'; +import { TracingDispatcher } from './tracingDispatcher'; import { WebSocketRouteDispatcher } from './webSocketRouteDispatcher'; +import { WritableStreamDispatcher } from './writableStreamDispatcher'; +import { createGuid, urlMatches } from '../../utils'; +import { RecorderApp } from '../recorder/recorderApp'; + +import type { Artifact } from '../artifact'; +import type { ConsoleMessage } from '../console'; +import type { Dialog } from '../dialog'; +import type { CallMetadata } from '../instrumentation'; +import type { Request, Response } from '../network'; +import type { Page } from '../page'; +import type { DispatcherScope } from './dispatcher'; +import type { FrameDispatcher } from './frameDispatcher'; +import type * as channels from '@protocol/channels'; export class BrowserContextDispatcher extends Dispatcher implements channels.BrowserContextChannel { _type_EventTarget = true; diff --git a/packages/playwright-core/src/server/dispatchers/browserDispatcher.ts b/packages/playwright-core/src/server/dispatchers/browserDispatcher.ts index 99ce5f961f..60682b366b 100644 --- a/packages/playwright-core/src/server/dispatchers/browserDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/browserDispatcher.ts @@ -15,20 +15,21 @@ */ import { Browser } from '../browser'; -import type * as channels from '@protocol/channels'; import { BrowserContextDispatcher } from './browserContextDispatcher'; import { CDPSessionDispatcher } from './cdpSessionDispatcher'; import { existingDispatcher } from './dispatcher'; -import type { RootDispatcher } from './dispatcher'; import { Dispatcher } from './dispatcher'; -import type { CRBrowser } from '../chromium/crBrowser'; -import type { PageDispatcher } from './pageDispatcher'; -import type { CallMetadata } from '../instrumentation'; import { BrowserContext } from '../browserContext'; import { Selectors } from '../selectors'; -import type { BrowserTypeDispatcher } from './browserTypeDispatcher'; import { ArtifactDispatcher } from './artifactDispatcher'; +import type { BrowserTypeDispatcher } from './browserTypeDispatcher'; +import type { RootDispatcher } from './dispatcher'; +import type { PageDispatcher } from './pageDispatcher'; +import type { CRBrowser } from '../chromium/crBrowser'; +import type { CallMetadata } from '../instrumentation'; +import type * as channels from '@protocol/channels'; + export class BrowserDispatcher extends Dispatcher implements channels.BrowserChannel { _type_Browser = true; diff --git a/packages/playwright-core/src/server/dispatchers/browserTypeDispatcher.ts b/packages/playwright-core/src/server/dispatchers/browserTypeDispatcher.ts index bf7ccd518f..bf21e726bc 100644 --- a/packages/playwright-core/src/server/dispatchers/browserTypeDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/browserTypeDispatcher.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { BrowserType } from '../browserType'; -import { BrowserDispatcher } from './browserDispatcher'; -import type * as channels from '@protocol/channels'; -import type { RootDispatcher } from './dispatcher'; -import { Dispatcher } from './dispatcher'; import { BrowserContextDispatcher } from './browserContextDispatcher'; +import { BrowserDispatcher } from './browserDispatcher'; +import { Dispatcher } from './dispatcher'; + +import type { BrowserType } from '../browserType'; +import type { RootDispatcher } from './dispatcher'; import type { CallMetadata } from '../instrumentation'; +import type * as channels from '@protocol/channels'; export class BrowserTypeDispatcher extends Dispatcher implements channels.BrowserTypeChannel { _type_BrowserType = true; diff --git a/packages/playwright-core/src/server/dispatchers/cdpSessionDispatcher.ts b/packages/playwright-core/src/server/dispatchers/cdpSessionDispatcher.ts index 33fa19f5e7..8263870039 100644 --- a/packages/playwright-core/src/server/dispatchers/cdpSessionDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/cdpSessionDispatcher.ts @@ -14,12 +14,13 @@ * limitations under the License. */ -import { CDPSession } from '../chromium/crConnection'; -import type * as channels from '@protocol/channels'; import { Dispatcher } from './dispatcher'; -import type { BrowserDispatcher } from './browserDispatcher'; +import { CDPSession } from '../chromium/crConnection'; + import type { BrowserContextDispatcher } from './browserContextDispatcher'; +import type { BrowserDispatcher } from './browserDispatcher'; import type { CallMetadata } from '../instrumentation'; +import type * as channels from '@protocol/channels'; export class CDPSessionDispatcher extends Dispatcher implements channels.CDPSessionChannel { _type_CDPSession = true; diff --git a/packages/playwright-core/src/server/dispatchers/debugControllerDispatcher.ts b/packages/playwright-core/src/server/dispatchers/debugControllerDispatcher.ts index fc722d1bd3..a3acb24bd1 100644 --- a/packages/playwright-core/src/server/dispatchers/debugControllerDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/debugControllerDispatcher.ts @@ -14,13 +14,15 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { eventsHelper } from '../../utils'; -import type { RegisteredListener } from '../../utils/eventsHelper'; import { DebugController } from '../debugController'; -import type { DispatcherConnection, RootDispatcher } from './dispatcher'; import { Dispatcher } from './dispatcher'; +import type { DispatcherConnection, RootDispatcher } from './dispatcher'; +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type * as channels from '@protocol/channels'; + + export class DebugControllerDispatcher extends Dispatcher implements channels.DebugControllerChannel { _type_DebugController; private _listeners: RegisteredListener[]; diff --git a/packages/playwright-core/src/server/dispatchers/dialogDispatcher.ts b/packages/playwright-core/src/server/dispatchers/dialogDispatcher.ts index 50ff01f108..b86872b133 100644 --- a/packages/playwright-core/src/server/dispatchers/dialogDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/dialogDispatcher.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import type { Dialog } from '../dialog'; -import type * as channels from '@protocol/channels'; import { Dispatcher } from './dispatcher'; import { PageDispatcher } from './pageDispatcher'; + +import type { Dialog } from '../dialog'; import type { BrowserContextDispatcher } from './browserContextDispatcher'; +import type * as channels from '@protocol/channels'; export class DialogDispatcher extends Dispatcher implements channels.DialogChannel { _type_Dialog = true; diff --git a/packages/playwright-core/src/server/dispatchers/dispatcher.ts b/packages/playwright-core/src/server/dispatchers/dispatcher.ts index ce63891f4f..34f2614e08 100644 --- a/packages/playwright-core/src/server/dispatchers/dispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/dispatcher.ts @@ -15,17 +15,20 @@ */ import { EventEmitter } from 'events'; -import type * as channels from '@protocol/channels'; -import { findValidator, ValidationError, createMetadataValidator, type ValidatorContext } from '../../protocol/validator'; + +import { eventsHelper } from '../..//utils/eventsHelper'; +import { ValidationError, createMetadataValidator, findValidator } from '../../protocol/validator'; import { LongStandingScope, assert, compressCallLog, isUnderTest, monotonicTime, rewriteErrorMessage } from '../../utils'; import { TargetClosedError, isTargetClosedError, serializeError } from '../errors'; -import type { CallMetadata } from '../instrumentation'; import { SdkObject } from '../instrumentation'; -import type { PlaywrightDispatcher } from './playwrightDispatcher'; -import { eventsHelper } from '../..//utils/eventsHelper'; -import type { RegisteredListener } from '../..//utils/eventsHelper'; import { isProtocolError } from '../protocolError'; +import type { CallMetadata } from '../instrumentation'; +import type { PlaywrightDispatcher } from './playwrightDispatcher'; +import type { RegisteredListener } from '../..//utils/eventsHelper'; +import type { ValidatorContext } from '../../protocol/validator'; +import type * as channels from '@protocol/channels'; + export const dispatcherSymbol = Symbol('dispatcher'); const metadataValidator = createMetadataValidator(); diff --git a/packages/playwright-core/src/server/dispatchers/electronDispatcher.ts b/packages/playwright-core/src/server/dispatchers/electronDispatcher.ts index a4e28da26f..57b0b3bb14 100644 --- a/packages/playwright-core/src/server/dispatchers/electronDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/electronDispatcher.ts @@ -14,16 +14,18 @@ * limitations under the License. */ -import type { RootDispatcher } from './dispatcher'; -import { Dispatcher } from './dispatcher'; -import type { Electron } from '../electron/electron'; -import { ElectronApplication } from '../electron/electron'; -import type * as channels from '@protocol/channels'; import { BrowserContextDispatcher } from './browserContextDispatcher'; +import { Dispatcher } from './dispatcher'; +import { ElementHandleDispatcher } from './elementHandlerDispatcher'; +import { parseArgument, serializeResult } from './jsHandleDispatcher'; +import { ElectronApplication } from '../electron/electron'; + +import type { RootDispatcher } from './dispatcher'; import type { PageDispatcher } from './pageDispatcher'; import type { ConsoleMessage } from '../console'; -import { parseArgument, serializeResult } from './jsHandleDispatcher'; -import { ElementHandleDispatcher } from './elementHandlerDispatcher'; +import type { Electron } from '../electron/electron'; +import type * as channels from '@protocol/channels'; + export class ElectronDispatcher extends Dispatcher implements channels.ElectronChannel { _type_Electron = true; diff --git a/packages/playwright-core/src/server/dispatchers/elementHandlerDispatcher.ts b/packages/playwright-core/src/server/dispatchers/elementHandlerDispatcher.ts index 8a6e4fcbaa..9a398fb351 100644 --- a/packages/playwright-core/src/server/dispatchers/elementHandlerDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/elementHandlerDispatcher.ts @@ -14,17 +14,19 @@ * limitations under the License. */ +import { BrowserContextDispatcher } from './browserContextDispatcher'; +import { existingDispatcher } from './dispatcher'; +import { FrameDispatcher } from './frameDispatcher'; +import { JSHandleDispatcher, parseArgument, serializeResult } from './jsHandleDispatcher'; +import { PageDispatcher, WorkerDispatcher } from './pageDispatcher'; + import type { ElementHandle } from '../dom'; import type { Frame } from '../frames'; -import type * as js from '../javascript'; -import type * as channels from '@protocol/channels'; -import { existingDispatcher } from './dispatcher'; -import { JSHandleDispatcher, serializeResult, parseArgument } from './jsHandleDispatcher'; -import type { JSHandleDispatcherParentScope } from './jsHandleDispatcher'; -import { FrameDispatcher } from './frameDispatcher'; import type { CallMetadata } from '../instrumentation'; -import { BrowserContextDispatcher } from './browserContextDispatcher'; -import { PageDispatcher, WorkerDispatcher } from './pageDispatcher'; +import type * as js from '../javascript'; +import type { JSHandleDispatcherParentScope } from './jsHandleDispatcher'; +import type * as channels from '@protocol/channels'; + export class ElementHandleDispatcher extends JSHandleDispatcher implements channels.ElementHandleChannel { _type_ElementHandle = true; diff --git a/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts b/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts index 3426389a9c..7e99511d33 100644 --- a/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts @@ -14,21 +14,22 @@ * limitations under the License. */ -import type { NavigationEvent } from '../frames'; import { Frame } from '../frames'; -import type * as channels from '@protocol/channels'; import { Dispatcher, existingDispatcher } from './dispatcher'; import { ElementHandleDispatcher } from './elementHandlerDispatcher'; import { parseArgument, serializeResult } from './jsHandleDispatcher'; import { ResponseDispatcher } from './networkDispatchers'; import { RequestDispatcher } from './networkDispatchers'; -import type { CallMetadata } from '../instrumentation'; -import type { BrowserContextDispatcher } from './browserContextDispatcher'; -import type { PageDispatcher } from './pageDispatcher'; import { debugAssert } from '../../utils'; import { parseAriaSnapshotUnsafe } from '../../utils/isomorphic/ariaSnapshot'; import { yaml } from '../../utilsBundle'; +import type { CallMetadata } from '../instrumentation'; +import type { BrowserContextDispatcher } from './browserContextDispatcher'; +import type { PageDispatcher } from './pageDispatcher'; +import type { NavigationEvent } from '../frames'; +import type * as channels from '@protocol/channels'; + export class FrameDispatcher extends Dispatcher implements channels.FrameChannel { _type_Frame = true; private _frame: Frame; diff --git a/packages/playwright-core/src/server/dispatchers/jsHandleDispatcher.ts b/packages/playwright-core/src/server/dispatchers/jsHandleDispatcher.ts index 33960e72d5..cf492f39b7 100644 --- a/packages/playwright-core/src/server/dispatchers/jsHandleDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/jsHandleDispatcher.ts @@ -14,15 +14,16 @@ * limitations under the License. */ -import type * as js from '../javascript'; -import type * as channels from '@protocol/channels'; import { Dispatcher } from './dispatcher'; import { ElementHandleDispatcher } from './elementHandlerDispatcher'; import { parseSerializedValue, serializeValue } from '../../protocol/serializers'; -import type { PageDispatcher, WorkerDispatcher } from './pageDispatcher'; + +import type * as js from '../javascript'; import type { ElectronApplicationDispatcher } from './electronDispatcher'; import type { FrameDispatcher } from './frameDispatcher'; +import type { PageDispatcher, WorkerDispatcher } from './pageDispatcher'; import type { CallMetadata } from '../instrumentation'; +import type * as channels from '@protocol/channels'; export type JSHandleDispatcherParentScope = PageDispatcher | FrameDispatcher | WorkerDispatcher | ElectronApplicationDispatcher; diff --git a/packages/playwright-core/src/server/dispatchers/jsonPipeDispatcher.ts b/packages/playwright-core/src/server/dispatchers/jsonPipeDispatcher.ts index dead26993f..67f36e94a1 100644 --- a/packages/playwright-core/src/server/dispatchers/jsonPipeDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/jsonPipeDispatcher.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { Dispatcher } from './dispatcher'; import { createGuid } from '../../utils'; + import type { LocalUtilsDispatcher } from './localUtilsDispatcher'; +import type * as channels from '@protocol/channels'; export class JsonPipeDispatcher extends Dispatcher<{ guid: string }, channels.JsonPipeChannel, LocalUtilsDispatcher> implements channels.JsonPipeChannel { _type_JsonPipe = true; diff --git a/packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts b/packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts index b6f8fe80ac..d65e3a5775 100644 --- a/packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/localUtilsDispatcher.ts @@ -14,33 +14,35 @@ * limitations under the License. */ -import type EventEmitter from 'events'; -import fs from 'fs'; -import path from 'path'; -import os from 'os'; -import type * as channels from '@protocol/channels'; -import { ManualPromise } from '../../utils/manualPromise'; -import { assert, calculateSha1, createGuid, removeFolders } from '../../utils'; -import type { RootDispatcher } from './dispatcher'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + import { Dispatcher } from './dispatcher'; -import { yazl, yauzl } from '../../zipBundle'; -import { ZipFile } from '../../utils/zipFile'; -import type * as har from '@trace/har'; -import type { HeadersArray } from '../types'; -import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher'; -import { WebSocketTransport } from '../transport'; -import { SocksInterceptor } from '../socksInterceptor'; -import type { CallMetadata } from '../instrumentation'; -import { getUserAgent } from '../../utils/userAgent'; -import type { Progress } from '../progress'; -import { ProgressController } from '../progress'; -import { fetchData } from '../../utils/network'; -import type { HTTPRequestParams } from '../../utils/network'; -import type http from 'http'; -import type { Playwright } from '../playwright'; import { SdkObject } from '../../server/instrumentation'; +import { assert, calculateSha1, createGuid, removeFolders } from '../../utils'; import { serializeClientSideCallMetadata } from '../../utils'; +import { ManualPromise } from '../../utils/manualPromise'; +import { fetchData } from '../../utils/network'; +import { getUserAgent } from '../../utils/userAgent'; +import { ZipFile } from '../../utils/zipFile'; +import { yauzl, yazl } from '../../zipBundle'; import { deviceDescriptors as descriptors } from '../deviceDescriptors'; +import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher'; +import { ProgressController } from '../progress'; +import { SocksInterceptor } from '../socksInterceptor'; +import { WebSocketTransport } from '../transport'; + +import type { HTTPRequestParams } from '../../utils/network'; +import type { CallMetadata } from '../instrumentation'; +import type { Playwright } from '../playwright'; +import type { Progress } from '../progress'; +import type { HeadersArray } from '../types'; +import type { RootDispatcher } from './dispatcher'; +import type * as channels from '@protocol/channels'; +import type * as har from '@trace/har'; +import type EventEmitter from 'events'; +import type http from 'http'; export class LocalUtilsDispatcher extends Dispatcher<{ guid: string }, channels.LocalUtilsChannel, RootDispatcher> implements channels.LocalUtilsChannel { _type_LocalUtils: boolean; diff --git a/packages/playwright-core/src/server/dispatchers/networkDispatchers.ts b/packages/playwright-core/src/server/dispatchers/networkDispatchers.ts index 6c2468176a..c6c783f390 100644 --- a/packages/playwright-core/src/server/dispatchers/networkDispatchers.ts +++ b/packages/playwright-core/src/server/dispatchers/networkDispatchers.ts @@ -14,18 +14,20 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; +import { WebSocket } from '../network'; +import { Dispatcher, existingDispatcher } from './dispatcher'; +import { FrameDispatcher } from './frameDispatcher'; +import { WorkerDispatcher } from './pageDispatcher'; +import { TracingDispatcher } from './tracingDispatcher'; + import type { APIRequestContext } from '../fetch'; import type { CallMetadata } from '../instrumentation'; import type { Request, Response, Route } from '../network'; -import { WebSocket } from '../network'; -import type { RootDispatcher } from './dispatcher'; -import { Dispatcher, existingDispatcher } from './dispatcher'; -import { TracingDispatcher } from './tracingDispatcher'; import type { BrowserContextDispatcher } from './browserContextDispatcher'; +import type { RootDispatcher } from './dispatcher'; import type { PageDispatcher } from './pageDispatcher'; -import { FrameDispatcher } from './frameDispatcher'; -import { WorkerDispatcher } from './pageDispatcher'; +import type * as channels from '@protocol/channels'; + export class RequestDispatcher extends Dispatcher implements channels.RequestChannel { _type_Request: boolean; diff --git a/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts b/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts index db8dfb4404..1b8a0677dd 100644 --- a/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts @@ -14,28 +14,29 @@ * limitations under the License. */ -import type { BrowserContext } from '../browserContext'; -import type { Frame } from '../frames'; import { Page, Worker } from '../page'; -import type * as channels from '@protocol/channels'; import { Dispatcher, existingDispatcher } from './dispatcher'; import { parseError } from '../errors'; +import { ArtifactDispatcher } from './artifactDispatcher'; +import { ElementHandleDispatcher } from './elementHandlerDispatcher'; import { FrameDispatcher } from './frameDispatcher'; +import { parseArgument, serializeResult } from './jsHandleDispatcher'; import { RequestDispatcher } from './networkDispatchers'; import { ResponseDispatcher } from './networkDispatchers'; import { RouteDispatcher, WebSocketDispatcher } from './networkDispatchers'; -import { serializeResult, parseArgument } from './jsHandleDispatcher'; -import { ElementHandleDispatcher } from './elementHandlerDispatcher'; -import type { FileChooser } from '../fileChooser'; -import type { CRCoverage } from '../chromium/crCoverage'; -import type { JSHandle } from '../javascript'; -import type { CallMetadata } from '../instrumentation'; -import type { Artifact } from '../artifact'; -import { ArtifactDispatcher } from './artifactDispatcher'; -import type { Download } from '../download'; -import { createGuid, urlMatches } from '../../utils'; -import type { BrowserContextDispatcher } from './browserContextDispatcher'; import { WebSocketRouteDispatcher } from './webSocketRouteDispatcher'; +import { createGuid, urlMatches } from '../../utils'; + +import type { Artifact } from '../artifact'; +import type { BrowserContext } from '../browserContext'; +import type { CRCoverage } from '../chromium/crCoverage'; +import type { Download } from '../download'; +import type { FileChooser } from '../fileChooser'; +import type { CallMetadata } from '../instrumentation'; +import type { JSHandle } from '../javascript'; +import type { BrowserContextDispatcher } from './browserContextDispatcher'; +import type { Frame } from '../frames'; +import type * as channels from '@protocol/channels'; export class PageDispatcher extends Dispatcher implements channels.PageChannel { _type_EventTarget = true; diff --git a/packages/playwright-core/src/server/dispatchers/playwrightDispatcher.ts b/packages/playwright-core/src/server/dispatchers/playwrightDispatcher.ts index c411f93198..d8c2081981 100644 --- a/packages/playwright-core/src/server/dispatchers/playwrightDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/playwrightDispatcher.ts @@ -14,25 +14,27 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import type { Browser } from '../browser'; -import { GlobalAPIRequestContext } from '../fetch'; -import type { Playwright } from '../playwright'; -import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../../common/socksProxy'; import { SocksProxy } from '../../common/socksProxy'; +import { GlobalAPIRequestContext } from '../fetch'; import { AndroidDispatcher } from './androidDispatcher'; +import { AndroidDeviceDispatcher } from './androidDispatcher'; +import { ConnectedBrowserDispatcher } from './browserDispatcher'; import { BrowserTypeDispatcher } from './browserTypeDispatcher'; -import type { RootDispatcher } from './dispatcher'; import { Dispatcher } from './dispatcher'; import { ElectronDispatcher } from './electronDispatcher'; import { LocalUtilsDispatcher } from './localUtilsDispatcher'; import { APIRequestContextDispatcher } from './networkDispatchers'; import { SelectorsDispatcher } from './selectorsDispatcher'; -import { ConnectedBrowserDispatcher } from './browserDispatcher'; import { createGuid } from '../../utils'; +import { eventsHelper } from '../../utils/eventsHelper'; + +import type { RootDispatcher } from './dispatcher'; +import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../../common/socksProxy'; +import type { RegisteredListener } from '../../utils/eventsHelper'; import type { AndroidDevice } from '../android/android'; -import { AndroidDeviceDispatcher } from './androidDispatcher'; -import { eventsHelper, type RegisteredListener } from '../../utils/eventsHelper'; +import type { Browser } from '../browser'; +import type { Playwright } from '../playwright'; +import type * as channels from '@protocol/channels'; export class PlaywrightDispatcher extends Dispatcher implements channels.PlaywrightChannel { _type_Playwright; diff --git a/packages/playwright-core/src/server/dispatchers/selectorsDispatcher.ts b/packages/playwright-core/src/server/dispatchers/selectorsDispatcher.ts index 4582a8081d..d542f8ba2c 100644 --- a/packages/playwright-core/src/server/dispatchers/selectorsDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/selectorsDispatcher.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import type { RootDispatcher } from './dispatcher'; import { Dispatcher } from './dispatcher'; -import type * as channels from '@protocol/channels'; + +import type { RootDispatcher } from './dispatcher'; import type { Selectors } from '../selectors'; +import type * as channels from '@protocol/channels'; export class SelectorsDispatcher extends Dispatcher implements channels.SelectorsChannel { _type_Selectors = true; diff --git a/packages/playwright-core/src/server/dispatchers/streamDispatcher.ts b/packages/playwright-core/src/server/dispatchers/streamDispatcher.ts index 4a45468389..8ceb69e669 100644 --- a/packages/playwright-core/src/server/dispatchers/streamDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/streamDispatcher.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import { Dispatcher } from './dispatcher'; -import type * as stream from 'stream'; import { ManualPromise, createGuid } from '../../utils'; + import type { ArtifactDispatcher } from './artifactDispatcher'; +import type * as channels from '@protocol/channels'; +import type * as stream from 'stream'; export class StreamDispatcher extends Dispatcher<{ guid: string, stream: stream.Readable }, channels.StreamChannel, ArtifactDispatcher> implements channels.StreamChannel { _type_Stream = true; diff --git a/packages/playwright-core/src/server/dispatchers/tracingDispatcher.ts b/packages/playwright-core/src/server/dispatchers/tracingDispatcher.ts index 5555de15d1..096e50ca17 100644 --- a/packages/playwright-core/src/server/dispatchers/tracingDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/tracingDispatcher.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import type { CallMetadata } from '@protocol/callMetadata'; -import type { Tracing } from '../trace/recorder/tracing'; import { ArtifactDispatcher } from './artifactDispatcher'; import { Dispatcher, existingDispatcher } from './dispatcher'; + import type { BrowserContextDispatcher } from './browserContextDispatcher'; import type { APIRequestContextDispatcher } from './networkDispatchers'; +import type { Tracing } from '../trace/recorder/tracing'; +import type { CallMetadata } from '@protocol/callMetadata'; +import type * as channels from '@protocol/channels'; export class TracingDispatcher extends Dispatcher implements channels.TracingChannel { _type_Tracing = true; diff --git a/packages/playwright-core/src/server/dispatchers/webSocketRouteDispatcher.ts b/packages/playwright-core/src/server/dispatchers/webSocketRouteDispatcher.ts index bcbc89fe03..fea8d06eec 100644 --- a/packages/playwright-core/src/server/dispatchers/webSocketRouteDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/webSocketRouteDispatcher.ts @@ -14,17 +14,18 @@ * limitations under the License. */ +import { Page } from '../page'; +import { Dispatcher, existingDispatcher } from './dispatcher'; +import { PageDispatcher } from './pageDispatcher'; +import * as webSocketMockSource from '../../generated/webSocketMockSource'; +import { createGuid, urlMatches } from '../../utils'; +import { eventsHelper } from '../../utils/eventsHelper'; + +import type { BrowserContextDispatcher } from './browserContextDispatcher'; import type { BrowserContext } from '../browserContext'; import type { Frame } from '../frames'; -import { Page } from '../page'; -import type * as channels from '@protocol/channels'; -import { Dispatcher, existingDispatcher } from './dispatcher'; -import { createGuid, urlMatches } from '../../utils'; -import { PageDispatcher } from './pageDispatcher'; -import type { BrowserContextDispatcher } from './browserContextDispatcher'; -import * as webSocketMockSource from '../../generated/webSocketMockSource'; import type * as ws from '../injected/webSocketMock'; -import { eventsHelper } from '../../utils/eventsHelper'; +import type * as channels from '@protocol/channels'; export class WebSocketRouteDispatcher extends Dispatcher<{ guid: string }, channels.WebSocketRouteChannel, PageDispatcher | BrowserContextDispatcher> implements channels.WebSocketRouteChannel { _type_WebSocketRoute = true; diff --git a/packages/playwright-core/src/server/dispatchers/writableStreamDispatcher.ts b/packages/playwright-core/src/server/dispatchers/writableStreamDispatcher.ts index 3e54e644d5..7d8ce2e4e1 100644 --- a/packages/playwright-core/src/server/dispatchers/writableStreamDispatcher.ts +++ b/packages/playwright-core/src/server/dispatchers/writableStreamDispatcher.ts @@ -14,11 +14,13 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import { Dispatcher } from './dispatcher'; import * as fs from 'fs'; + +import { Dispatcher } from './dispatcher'; import { createGuid } from '../../utils'; + import type { BrowserContextDispatcher } from './browserContextDispatcher'; +import type * as channels from '@protocol/channels'; export class WritableStreamDispatcher extends Dispatcher<{ guid: string, streamOrDirectory: fs.WriteStream | string }, channels.WritableStreamChannel, BrowserContextDispatcher> implements channels.WritableStreamChannel { _type_WritableStream = true; diff --git a/packages/playwright-core/src/server/dom.ts b/packages/playwright-core/src/server/dom.ts index 288b8c2c8d..7bb1862645 100644 --- a/packages/playwright-core/src/server/dom.ts +++ b/packages/playwright-core/src/server/dom.ts @@ -14,22 +14,25 @@ * limitations under the License. */ -import fs from 'fs'; -import type * as channels from '@protocol/channels'; -import * as injectedScriptSource from '../generated/injectedScriptSource'; -import { isSessionClosedError } from './protocolError'; -import type { ScreenshotOptions } from './screenshotter'; -import type * as frames from './frames'; -import type { InjectedScript, HitTargetInterceptionResult, ElementState } from './injected/injectedScript'; -import type { CallMetadata } from './instrumentation'; +import * as fs from 'fs'; + import * as js from './javascript'; -import type { Page } from './page'; -import type { Progress } from './progress'; import { ProgressController } from './progress'; -import type * as types from './types'; -import type { TimeoutOptions } from '../common/types'; import { asLocator, isUnderTest } from '../utils'; import { prepareFilesForUpload } from './fileUploadUtils'; +import { isSessionClosedError } from './protocolError'; +import * as injectedScriptSource from '../generated/injectedScriptSource'; + +import type * as frames from './frames'; +import type { ElementState, HitTargetInterceptionResult, InjectedScript } from './injected/injectedScript'; +import type { CallMetadata } from './instrumentation'; +import type { Page } from './page'; +import type { Progress } from './progress'; +import type { ScreenshotOptions } from './screenshotter'; +import type * as types from './types'; +import type { TimeoutOptions } from '../common/types'; +import type * as channels from '@protocol/channels'; + export type InputFilesItems = { filePayloads?: types.FilePayload[], diff --git a/packages/playwright-core/src/server/download.ts b/packages/playwright-core/src/server/download.ts index 78a9c015dc..85840b7ff2 100644 --- a/packages/playwright-core/src/server/download.ts +++ b/packages/playwright-core/src/server/download.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; + import { Page } from './page'; import { assert } from '../utils'; import { Artifact } from './artifact'; diff --git a/packages/playwright-core/src/server/electron/electron.ts b/packages/playwright-core/src/server/electron/electron.ts index 1606c407d5..565fce7fb1 100644 --- a/packages/playwright-core/src/server/electron/electron.ts +++ b/packages/playwright-core/src/server/electron/electron.ts @@ -14,39 +14,41 @@ * limitations under the License. */ -import fs from 'fs'; -import os from 'os'; -import path from 'path'; -import type { CRBrowserContext } from '../chromium/crBrowser'; -import { CRBrowser } from '../chromium/crBrowser'; -import type { CRSession } from '../chromium/crConnection'; -import { CRConnection } from '../chromium/crConnection'; -import type { CRPage } from '../chromium/crPage'; -import { CRExecutionContext } from '../chromium/crExecutionContext'; -import type { Protocol } from '../chromium/protocol'; -import * as js from '../javascript'; -import type { Page } from '../page'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; +import * as readline from 'readline'; + import { TimeoutSettings } from '../../common/timeoutSettings'; import { ManualPromise, wrapInASCIIBox } from '../../utils'; -import { WebSocketTransport } from '../transport'; -import { launchProcess, envArrayToObject } from '../../utils/processLauncher'; -import type { BrowserContext } from '../browserContext'; -import { validateBrowserContextOptions } from '../browserContext'; -import type { BrowserWindow } from 'electron'; -import type { Progress } from '../progress'; -import { ProgressController } from '../progress'; -import { helper } from '../helper'; -import type * as types from '../types'; -import { eventsHelper } from '../../utils/eventsHelper'; -import type { BrowserOptions, BrowserProcess } from '../browser'; -import type { Playwright } from '../playwright'; -import type * as childProcess from 'child_process'; -import * as readline from 'readline'; import { RecentLogsCollector } from '../../utils/debugLogger'; -import { serverSideCallMetadata, SdkObject } from '../instrumentation'; -import type * as channels from '@protocol/channels'; +import { eventsHelper } from '../../utils/eventsHelper'; +import { envArrayToObject, launchProcess } from '../../utils/processLauncher'; +import { validateBrowserContextOptions } from '../browserContext'; +import { CRBrowser } from '../chromium/crBrowser'; +import { CRConnection } from '../chromium/crConnection'; +import { CRExecutionContext } from '../chromium/crExecutionContext'; import { toConsoleMessageLocation } from '../chromium/crProtocolHelper'; import { ConsoleMessage } from '../console'; +import { helper } from '../helper'; +import { SdkObject, serverSideCallMetadata } from '../instrumentation'; +import * as js from '../javascript'; +import { ProgressController } from '../progress'; +import { WebSocketTransport } from '../transport'; + +import type { BrowserOptions, BrowserProcess } from '../browser'; +import type { BrowserContext } from '../browserContext'; +import type { CRBrowserContext } from '../chromium/crBrowser'; +import type { CRSession } from '../chromium/crConnection'; +import type { CRPage } from '../chromium/crPage'; +import type { Protocol } from '../chromium/protocol'; +import type { Page } from '../page'; +import type { Playwright } from '../playwright'; +import type { Progress } from '../progress'; +import type * as types from '../types'; +import type * as channels from '@protocol/channels'; +import type * as childProcess from 'child_process'; +import type { BrowserWindow } from 'electron'; const ARTIFACTS_FOLDER = path.join(os.tmpdir(), 'playwright-artifacts-'); diff --git a/packages/playwright-core/src/server/electron/loader.ts b/packages/playwright-core/src/server/electron/loader.ts index 98bd92d457..91f63095da 100644 --- a/packages/playwright-core/src/server/electron/loader.ts +++ b/packages/playwright-core/src/server/electron/loader.ts @@ -15,6 +15,7 @@ */ const { app } = require('electron'); + const { chromiumSwitches } = require('../chromium/chromiumSwitches'); // Always pass user arguments first, see https://github.com/microsoft/playwright/issues/16614 and diff --git a/packages/playwright-core/src/server/errors.ts b/packages/playwright-core/src/server/errors.ts index c3a63cb033..88fe8b4403 100644 --- a/packages/playwright-core/src/server/errors.ts +++ b/packages/playwright-core/src/server/errors.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { SerializedError } from '@protocol/channels'; -import { isError } from '../utils'; import { parseSerializedValue, serializeValue } from '../protocol/serializers'; +import { isError } from '../utils'; + +import type { SerializedError } from '@protocol/channels'; class CustomError extends Error { constructor(message: string) { diff --git a/packages/playwright-core/src/server/fetch.ts b/packages/playwright-core/src/server/fetch.ts index 778fbcee95..9210340c8c 100644 --- a/packages/playwright-core/src/server/fetch.ts +++ b/packages/playwright-core/src/server/fetch.ts @@ -14,34 +14,38 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import type { LookupAddress } from 'dns'; -import http from 'http'; -import https from 'https'; -import type { Readable, TransformCallback } from 'stream'; -import { pipeline, Transform } from 'stream'; -import url from 'url'; -import zlib from 'zlib'; -import type { HTTPCredentials } from '../../types/types'; +import * as http from 'http'; +import * as https from 'https'; +import { Transform, pipeline } from 'stream'; +import { TLSSocket } from 'tls'; +import * as url from 'url'; +import * as zlib from 'zlib'; + import { TimeoutSettings } from '../common/timeoutSettings'; +import { assert, constructURLBasedOnBaseURL, createGuid, eventsHelper, monotonicTime } from '../utils'; import { getUserAgent } from '../utils/userAgent'; -import { assert, constructURLBasedOnBaseURL, createGuid, eventsHelper, monotonicTime, type RegisteredListener } from '../utils'; import { HttpsProxyAgent, SocksProxyAgent } from '../utilsBundle'; import { BrowserContext, verifyClientCertificates } from './browserContext'; import { CookieStore, domainMatches, parseRawCookie } from './cookieStore'; import { MultipartFormData } from './formData'; -import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent, timingForSocket } from '../utils/happy-eyeballs'; -import type { CallMetadata } from './instrumentation'; import { SdkObject } from './instrumentation'; +import { ProgressController } from './progress'; +import { getMatchingTLSOptionsForOrigin, rewriteOpenSSLErrorIfNeeded } from './socksClientCertificatesInterceptor'; +import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent, timingForSocket } from '../utils/happy-eyeballs'; +import { Tracing } from './trace/recorder/tracing'; + +import type { CallMetadata } from './instrumentation'; import type { Playwright } from './playwright'; import type { Progress } from './progress'; -import { ProgressController } from './progress'; -import { Tracing } from './trace/recorder/tracing'; import type * as types from './types'; import type { HeadersArray, ProxySettings } from './types'; -import { getMatchingTLSOptionsForOrigin, rewriteOpenSSLErrorIfNeeded } from './socksClientCertificatesInterceptor'; +import type { HTTPCredentials } from '../../types/types'; +import type { RegisteredListener } from '../utils'; +import type * as channels from '@protocol/channels'; import type * as har from '@trace/har'; -import { TLSSocket } from 'tls'; +import type { LookupAddress } from 'dns'; +import type { Readable, TransformCallback } from 'stream'; + type FetchRequestOptions = { userAgent: string; diff --git a/packages/playwright-core/src/server/fileUploadUtils.ts b/packages/playwright-core/src/server/fileUploadUtils.ts index 2696ba0116..9ec4e76ad3 100644 --- a/packages/playwright-core/src/server/fileUploadUtils.ts +++ b/packages/playwright-core/src/server/fileUploadUtils.ts @@ -14,15 +14,17 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + import { assert, fileUploadSizeLimit } from '../utils'; import { mime } from '../utilsBundle'; + import type { WritableStreamDispatcher } from './dispatchers/writableStreamDispatcher'; import type { InputFilesItems } from './dom'; import type { Frame } from './frames'; import type * as types from './types'; +import type * as channels from '@protocol/channels'; async function filesExceedUploadLimit(files: string[]) { const sizes = await Promise.all(files.map(async file => (await fs.promises.stat(file)).size)); diff --git a/packages/playwright-core/src/server/firefox/ffBrowser.ts b/packages/playwright-core/src/server/firefox/ffBrowser.ts index 0bafecf12f..2320dcc77a 100644 --- a/packages/playwright-core/src/server/firefox/ffBrowser.ts +++ b/packages/playwright-core/src/server/firefox/ffBrowser.ts @@ -15,21 +15,23 @@ * limitations under the License. */ -import { TargetClosedError } from '../errors'; import { assert } from '../../utils'; -import type { BrowserOptions } from '../browser'; import { Browser } from '../browser'; -import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext'; +import { BrowserContext, assertBrowserContextIsNotOwned, verifyGeolocation } from '../browserContext'; +import { TargetClosedError } from '../errors'; import * as network from '../network'; -import type { InitScript, Page } from '../page'; import { PageBinding } from '../page'; +import { ConnectionEvents, FFConnection } from './ffConnection'; +import { FFPage } from './ffPage'; + +import type { BrowserOptions } from '../browser'; +import type { SdkObject } from '../instrumentation'; +import type { InitScript, Page } from '../page'; import type { ConnectionTransport } from '../transport'; import type * as types from '../types'; -import type * as channels from '@protocol/channels'; -import { ConnectionEvents, FFConnection, type FFSession } from './ffConnection'; -import { FFPage } from './ffPage'; +import type { FFSession } from './ffConnection'; import type { Protocol } from './protocol'; -import type { SdkObject } from '../instrumentation'; +import type * as channels from '@protocol/channels'; export class FFBrowser extends Browser { private _connection: FFConnection; diff --git a/packages/playwright-core/src/server/firefox/ffConnection.ts b/packages/playwright-core/src/server/firefox/ffConnection.ts index 1a24e1dbf0..6001754219 100644 --- a/packages/playwright-core/src/server/firefox/ffConnection.ts +++ b/packages/playwright-core/src/server/firefox/ffConnection.ts @@ -16,13 +16,16 @@ */ import { EventEmitter } from 'events'; + +import { debugLogger } from '../../utils/debugLogger'; +import { helper } from '../helper'; +import { ProtocolError } from '../protocolError'; + import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport'; import type { Protocol } from './protocol'; import type { RecentLogsCollector } from '../../utils/debugLogger'; -import { debugLogger } from '../../utils/debugLogger'; import type { ProtocolLogger } from '../types'; -import { helper } from '../helper'; -import { ProtocolError } from '../protocolError'; + export const ConnectionEvents = { Disconnected: Symbol('Disconnected'), diff --git a/packages/playwright-core/src/server/firefox/ffExecutionContext.ts b/packages/playwright-core/src/server/firefox/ffExecutionContext.ts index c7a3f106f8..7de27727cd 100644 --- a/packages/playwright-core/src/server/firefox/ffExecutionContext.ts +++ b/packages/playwright-core/src/server/firefox/ffExecutionContext.ts @@ -15,13 +15,14 @@ * limitations under the License. */ -import * as js from '../javascript'; -import type { FFSession } from './ffConnection'; -import type { Protocol } from './protocol'; import { rewriteErrorMessage } from '../../utils/stackTrace'; import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers'; +import * as js from '../javascript'; import { isSessionClosedError } from '../protocolError'; +import type { FFSession } from './ffConnection'; +import type { Protocol } from './protocol'; + export class FFExecutionContext implements js.ExecutionContextDelegate { _session: FFSession; _executionContextId: string; diff --git a/packages/playwright-core/src/server/firefox/ffNetworkManager.ts b/packages/playwright-core/src/server/firefox/ffNetworkManager.ts index 73b8e3589f..95df0643d0 100644 --- a/packages/playwright-core/src/server/firefox/ffNetworkManager.ts +++ b/packages/playwright-core/src/server/firefox/ffNetworkManager.ts @@ -15,15 +15,16 @@ * limitations under the License. */ -import type { RegisteredListener } from '../../utils/eventsHelper'; import { eventsHelper } from '../../utils/eventsHelper'; -import type { FFSession } from './ffConnection'; -import type { Page } from '../page'; import * as network from '../network'; + +import type { FFSession } from './ffConnection'; +import type { HeadersArray } from '../../server/types'; +import type { RegisteredListener } from '../../utils/eventsHelper'; import type * as frames from '../frames'; +import type { Page } from '../page'; import type * as types from '../types'; import type { Protocol } from './protocol'; -import type { HeadersArray } from '../../server/types'; export class FFNetworkManager { private _session: FFSession; diff --git a/packages/playwright-core/src/server/firefox/ffPage.ts b/packages/playwright-core/src/server/firefox/ffPage.ts index 71199dc8d5..0e1755a2da 100644 --- a/packages/playwright-core/src/server/firefox/ffPage.ts +++ b/packages/playwright-core/src/server/firefox/ffPage.ts @@ -15,28 +15,29 @@ * limitations under the License. */ +import { eventsHelper } from '../../utils/eventsHelper'; import * as dialog from '../dialog'; import * as dom from '../dom'; -import type * as frames from '../frames'; -import type { RegisteredListener } from '../../utils/eventsHelper'; -import { eventsHelper } from '../../utils/eventsHelper'; -import type { PageDelegate } from '../page'; import { InitScript } from '../page'; import { Page, Worker } from '../page'; -import type * as types from '../types'; import { getAccessibilityTree } from './ffAccessibility'; -import type { FFBrowserContext } from './ffBrowser'; import { FFSession } from './ffConnection'; import { FFExecutionContext } from './ffExecutionContext'; import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './ffInput'; import { FFNetworkManager } from './ffNetworkManager'; -import type { Protocol } from './protocol'; -import type { Progress } from '../progress'; -import { splitErrorMessage } from '../../utils/stackTrace'; import { debugLogger } from '../../utils/debugLogger'; +import { splitErrorMessage } from '../../utils/stackTrace'; import { BrowserContext } from '../browserContext'; import { TargetClosedError } from '../errors'; +import type { Progress } from '../progress'; +import type { FFBrowserContext } from './ffBrowser'; +import type { Protocol } from './protocol'; +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type * as frames from '../frames'; +import type { PageDelegate } from '../page'; +import type * as types from '../types'; + export const UTILITY_WORLD_NAME = '__playwright_utility_world__'; export class FFPage implements PageDelegate { diff --git a/packages/playwright-core/src/server/firefox/firefox.ts b/packages/playwright-core/src/server/firefox/firefox.ts index 1e0e4cc055..fe55417c8c 100644 --- a/packages/playwright-core/src/server/firefox/firefox.ts +++ b/packages/playwright-core/src/server/firefox/firefox.ts @@ -16,18 +16,20 @@ */ import * as os from 'os'; -import path from 'path'; +import * as path from 'path'; + import { FFBrowser } from './ffBrowser'; import { kBrowserCloseMessageId } from './ffConnection'; +import { wrapInASCIIBox } from '../../utils'; import { BrowserType, kNoXServerRunningError } from '../browserType'; import { BrowserReadyState } from '../browserType'; + import type { Env } from '../../utils/processLauncher'; -import type { ConnectionTransport } from '../transport'; import type { BrowserOptions } from '../browser'; -import type * as types from '../types'; -import { wrapInASCIIBox } from '../../utils'; import type { SdkObject } from '../instrumentation'; import type { ProtocolError } from '../protocolError'; +import type { ConnectionTransport } from '../transport'; +import type * as types from '../types'; export class Firefox extends BrowserType { constructor(parent: SdkObject) { diff --git a/packages/playwright-core/src/server/formData.ts b/packages/playwright-core/src/server/formData.ts index bc7f1e5bfe..d628480954 100644 --- a/packages/playwright-core/src/server/formData.ts +++ b/packages/playwright-core/src/server/formData.ts @@ -15,6 +15,7 @@ */ import { mime } from '../utilsBundle'; + import type * as channels from '@protocol/channels'; export class MultipartFormData { diff --git a/packages/playwright-core/src/server/frameSelectors.ts b/packages/playwright-core/src/server/frameSelectors.ts index 4be2a9c285..c375b0b52a 100644 --- a/packages/playwright-core/src/server/frameSelectors.ts +++ b/packages/playwright-core/src/server/frameSelectors.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import type { Frame } from './frames'; -import type * as types from './types'; -import { stringifySelector, type ParsedSelector, splitSelectorByFrame, InvalidSelectorError, visitAllSelectorParts } from '../utils/isomorphic/selectorParser'; -import type { FrameExecutionContext, ElementHandle } from './dom'; -import type { JSHandle } from './javascript'; -import type { InjectedScript } from './injected/injectedScript'; import { asLocator } from '../utils'; +import { InvalidSelectorError, splitSelectorByFrame, stringifySelector, visitAllSelectorParts } from '../utils/isomorphic/selectorParser'; + +import type { ElementHandle, FrameExecutionContext } from './dom'; +import type { Frame } from './frames'; +import type { InjectedScript } from './injected/injectedScript'; +import type { JSHandle } from './javascript'; +import type * as types from './types'; +import type { ParsedSelector } from '../utils/isomorphic/selectorParser'; + export type SelectorInfo = { parsed: ParsedSelector, diff --git a/packages/playwright-core/src/server/frames.ts b/packages/playwright-core/src/server/frames.ts index b1f4d4c1c6..2183d3f409 100644 --- a/packages/playwright-core/src/server/frames.ts +++ b/packages/playwright-core/src/server/frames.ts @@ -15,32 +15,34 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import type { ConsoleMessage } from './console'; -import * as dom from './dom'; -import { helper } from './helper'; -import type { RegisteredListener } from '../utils/eventsHelper'; -import { eventsHelper } from '../utils/eventsHelper'; -import * as js from './javascript'; -import * as network from './network'; -import type { Dialog } from './dialog'; -import { Page } from './page'; -import * as types from './types'; import { BrowserContext } from './browserContext'; -import type { Progress } from './progress'; -import { ProgressController } from './progress'; -import { LongStandingScope, assert, constructURLBasedOnBaseURL, makeWaitForNextTask, monotonicTime, asLocator, compressCallLog } from '../utils'; -import { ManualPromise } from '../utils/manualPromise'; -import { debugLogger } from '../utils/debugLogger'; -import type { CallMetadata } from './instrumentation'; -import { serverSideCallMetadata, SdkObject } from './instrumentation'; -import type { InjectedScript, ElementStateWithoutStable, FrameExpectParams } from './injected/injectedScript'; -import { isSessionClosedError } from './protocolError'; -import { type ParsedSelector, isInvalidSelectorError } from '../utils/isomorphic/selectorParser'; -import type { ScreenshotOptions } from './screenshotter'; -import { FrameSelectors } from './frameSelectors'; +import * as dom from './dom'; import { TimeoutError } from './errors'; import { prepareFilesForUpload } from './fileUploadUtils'; +import { FrameSelectors } from './frameSelectors'; +import { helper } from './helper'; +import { SdkObject, serverSideCallMetadata } from './instrumentation'; +import * as js from './javascript'; +import * as network from './network'; +import { Page } from './page'; +import { ProgressController } from './progress'; +import * as types from './types'; +import { LongStandingScope, asLocator, assert, compressCallLog, constructURLBasedOnBaseURL, makeWaitForNextTask, monotonicTime } from '../utils'; +import { isSessionClosedError } from './protocolError'; +import { debugLogger } from '../utils/debugLogger'; +import { eventsHelper } from '../utils/eventsHelper'; +import { isInvalidSelectorError } from '../utils/isomorphic/selectorParser'; +import { ManualPromise } from '../utils/manualPromise'; + +import type { ConsoleMessage } from './console'; +import type { Dialog } from './dialog'; +import type { ElementStateWithoutStable, FrameExpectParams, InjectedScript } from './injected/injectedScript'; +import type { CallMetadata } from './instrumentation'; +import type { Progress } from './progress'; +import type { ScreenshotOptions } from './screenshotter'; +import type { RegisteredListener } from '../utils/eventsHelper'; +import type { ParsedSelector } from '../utils/isomorphic/selectorParser'; +import type * as channels from '@protocol/channels'; type ContextData = { contextPromise: ManualPromise; diff --git a/packages/playwright-core/src/server/har/harRecorder.ts b/packages/playwright-core/src/server/har/harRecorder.ts index e623587e57..7cde24fa3a 100644 --- a/packages/playwright-core/src/server/har/harRecorder.ts +++ b/packages/playwright-core/src/server/har/harRecorder.ts @@ -14,20 +14,22 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + import { Artifact } from '../artifact'; -import type { BrowserContext } from '../browserContext'; -import type * as har from '@trace/har'; import { HarTracer } from './harTracer'; -import type { HarTracerDelegate } from './harTracer'; -import type * as channels from '@protocol/channels'; -import { yazl } from '../../zipBundle'; -import type { ZipFile } from '../../zipBundle'; -import { ManualPromise } from '../../utils/manualPromise'; -import type EventEmitter from 'events'; import { createGuid } from '../../utils'; +import { ManualPromise } from '../../utils/manualPromise'; +import { yazl } from '../../zipBundle'; + +import type { BrowserContext } from '../browserContext'; +import type { HarTracerDelegate } from './harTracer'; +import type { ZipFile } from '../../zipBundle'; import type { Page } from '../page'; +import type * as channels from '@protocol/channels'; +import type * as har from '@trace/har'; +import type EventEmitter from 'events'; export class HarRecorder implements HarTracerDelegate { private _artifact: Artifact; diff --git a/packages/playwright-core/src/server/har/harTracer.ts b/packages/playwright-core/src/server/har/harTracer.ts index ba0e8b46c2..0e3a66b938 100644 --- a/packages/playwright-core/src/server/har/harTracer.ts +++ b/packages/playwright-core/src/server/har/harTracer.ts @@ -14,22 +14,23 @@ * limitations under the License. */ +import { assert, calculateSha1, monotonicTime } from '../../utils'; +import { getPlaywrightVersion, isTextualMimeType, urlMatches } from '../../utils'; +import { eventsHelper } from '../../utils/eventsHelper'; +import { ManualPromise } from '../../utils/manualPromise'; +import { mime } from '../../utilsBundle'; import { BrowserContext } from '../browserContext'; -import type { APIRequestEvent, APIRequestFinishedEvent } from '../fetch'; import { APIRequestContext } from '../fetch'; +import { Frame } from '../frames'; import { helper } from '../helper'; import * as network from '../network'; -import type { Worker } from '../page'; -import type { Page } from '../page'; -import type * as har from '@trace/har'; -import { assert, calculateSha1, monotonicTime } from '../../utils'; + import type { RegisteredListener } from '../../utils/eventsHelper'; -import { eventsHelper } from '../../utils/eventsHelper'; -import { mime } from '../../utilsBundle'; -import { ManualPromise } from '../../utils/manualPromise'; -import { getPlaywrightVersion, isTextualMimeType, urlMatches } from '../../utils'; -import { Frame } from '../frames'; +import type { APIRequestEvent, APIRequestFinishedEvent } from '../fetch'; +import type { Page } from '../page'; +import type { Worker } from '../page'; import type { HeadersArray, LifecycleEvent } from '../types'; +import type * as har from '@trace/har'; const FALLBACK_HTTP_VERSION = 'HTTP/1.1'; diff --git a/packages/playwright-core/src/server/helper.ts b/packages/playwright-core/src/server/helper.ts index 5b22dfd5e1..ccf9af12b0 100644 --- a/packages/playwright-core/src/server/helper.ts +++ b/packages/playwright-core/src/server/helper.ts @@ -15,13 +15,15 @@ * limitations under the License. */ -import type { EventEmitter } from 'events'; -import type * as types from './types'; -import type { Progress } from './progress'; import { debugLogger } from '../utils/debugLogger'; -import type { RegisteredListener } from '../utils/eventsHelper'; import { eventsHelper } from '../utils/eventsHelper'; +import type { Progress } from './progress'; +import type * as types from './types'; +import type { RegisteredListener } from '../utils/eventsHelper'; +import type { EventEmitter } from 'events'; + + const MAX_LOG_LENGTH = process.env.MAX_LOG_LENGTH ? +process.env.MAX_LOG_LENGTH : Infinity; class Helper { diff --git a/packages/playwright-core/src/server/index.ts b/packages/playwright-core/src/server/index.ts index 31e177a219..e93399007a 100644 --- a/packages/playwright-core/src/server/index.ts +++ b/packages/playwright-core/src/server/index.ts @@ -16,10 +16,10 @@ export type { Executable } from './registry'; export { - registry, - registryDirectory, Registry, installBrowsersForNpmInstall, + registry, + registryDirectory, writeDockerVersion } from './registry'; export { DispatcherConnection, RootDispatcher } from './dispatchers/dispatcher'; @@ -28,6 +28,6 @@ export { createPlaywright } from './playwright'; export type { DispatcherScope } from './dispatchers/dispatcher'; export type { Playwright } from './playwright'; -export { openTraceInBrowser, openTraceViewerApp, runTraceViewerApp, startTraceViewerServer, installRootRedirect } from './trace/viewer/traceViewer'; +export { installRootRedirect, openTraceInBrowser, openTraceViewerApp, runTraceViewerApp, startTraceViewerServer } from './trace/viewer/traceViewer'; export { serverSideCallMetadata } from './instrumentation'; export { SocksProxy } from '../common/socksProxy'; diff --git a/packages/playwright-core/src/server/injected/ariaSnapshot.ts b/packages/playwright-core/src/server/injected/ariaSnapshot.ts index 4318b9aea9..3813960fe4 100644 --- a/packages/playwright-core/src/server/injected/ariaSnapshot.ts +++ b/packages/playwright-core/src/server/injected/ariaSnapshot.ts @@ -14,10 +14,12 @@ * limitations under the License. */ -import * as roleUtils from './roleUtils'; -import { getElementComputedStyle } from './domUtils'; import { escapeRegExp, longestCommonSubstring, normalizeWhiteSpace } from '@isomorphic/stringUtils'; + +import { getElementComputedStyle } from './domUtils'; +import * as roleUtils from './roleUtils'; import { yamlEscapeKeyIfNeeded, yamlEscapeValueIfNeeded } from './yaml'; + import type { AriaProps, AriaRegex, AriaRole, AriaTemplateNode, AriaTemplateRoleNode, AriaTemplateTextNode } from '@isomorphic/ariaSnapshot'; export type AriaNode = AriaProps & { diff --git a/packages/playwright-core/src/server/injected/consoleApi.ts b/packages/playwright-core/src/server/injected/consoleApi.ts index faba90c57d..c79ee6610c 100644 --- a/packages/playwright-core/src/server/injected/consoleApi.ts +++ b/packages/playwright-core/src/server/injected/consoleApi.ts @@ -14,12 +14,13 @@ * limitations under the License. */ -import type { ByRoleOptions } from '../../utils/isomorphic/locatorUtils'; +import { asLocator } from '../../utils/isomorphic/locatorGenerators'; import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../../utils/isomorphic/locatorUtils'; import { escapeForTextSelector } from '../../utils/isomorphic/stringUtils'; -import { asLocator } from '../../utils/isomorphic/locatorGenerators'; -import type { Language } from '../../utils/isomorphic/locatorGenerators'; + import type { InjectedScript } from './injectedScript'; +import type { Language } from '../../utils/isomorphic/locatorGenerators'; +import type { ByRoleOptions } from '../../utils/isomorphic/locatorUtils'; const selectorSymbol = Symbol('selector'); diff --git a/packages/playwright-core/src/server/injected/highlight.ts b/packages/playwright-core/src/server/injected/highlight.ts index 5720ffc539..332a6a7754 100644 --- a/packages/playwright-core/src/server/injected/highlight.ts +++ b/packages/playwright-core/src/server/injected/highlight.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import { stringifySelector } from '../../utils/isomorphic/selectorParser'; -import type { ParsedSelector } from '../../utils/isomorphic/selectorParser'; -import type { InjectedScript } from './injectedScript'; -import { asLocator } from '../../utils/isomorphic/locatorGenerators'; -import type { Language } from '../../utils/isomorphic/locatorGenerators'; import highlightCSS from './highlight.css?inline'; +import { asLocator } from '../../utils/isomorphic/locatorGenerators'; +import { stringifySelector } from '../../utils/isomorphic/selectorParser'; + +import type { InjectedScript } from './injectedScript'; +import type { Language } from '../../utils/isomorphic/locatorGenerators'; +import type { ParsedSelector } from '../../utils/isomorphic/selectorParser'; + type HighlightEntry = { targetElement: Element, diff --git a/packages/playwright-core/src/server/injected/injectedScript.ts b/packages/playwright-core/src/server/injected/injectedScript.ts index bb004590f5..547928081d 100644 --- a/packages/playwright-core/src/server/injected/injectedScript.ts +++ b/packages/playwright-core/src/server/injected/injectedScript.ts @@ -14,31 +14,37 @@ * limitations under the License. */ -import type { SelectorEngine, SelectorRoot } from './selectorEngine'; -import { XPathEngine } from './xpathSelectorEngine'; -import { ReactEngine } from './reactSelectorEngine'; -import { VueEngine } from './vueSelectorEngine'; -import { createRoleEngine } from './roleSelectorEngine'; -import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser'; -import type { NestedSelectorBody, ParsedSelector, ParsedSelectorPart } from '../../utils/isomorphic/selectorParser'; -import { visitAllSelectorParts, parseSelector, stringifySelector } from '../../utils/isomorphic/selectorParser'; -import { type TextMatcher, elementMatchesText, elementText, type ElementText, getElementLabels } from './selectorUtils'; -import { SelectorEvaluatorImpl, sortInDOMOrder } from './selectorEvaluator'; -import { enclosingShadowRootOrDocument, isElementVisible, isInsideScope, parentElementOrShadowHost, setBrowserName } from './domUtils'; -import type { CSSComplexSelectorList } from '../../utils/isomorphic/cssParser'; -import { generateSelector, type GenerateSelectorOptions } from './selectorGenerator'; -import type * as channels from '@protocol/channels'; -import { Highlight } from './highlight'; -import { getAriaDisabled, getAriaRole, getElementAccessibleName, getElementAccessibleDescription, getReadonly, getElementAccessibleErrorMessage, getCheckedAllowMixed, getCheckedWithoutMixed } from './roleUtils'; -import { kLayoutSelectorNames, type LayoutSelectorName, layoutSelectorScore } from './layoutSelectorUtils'; -import { asLocator } from '../../utils/isomorphic/locatorGenerators'; -import type { Language } from '../../utils/isomorphic/locatorGenerators'; -import { cacheNormalizedWhitespaces, normalizeWhiteSpace, trimStringWithEllipsis } from '../../utils/isomorphic/stringUtils'; -import { matchesAriaTree, getAllByAria, generateAriaTree, renderAriaTree } from './ariaSnapshot'; -import type { AriaNode, AriaSnapshot } from './ariaSnapshot'; -import type { AriaTemplateNode } from '@isomorphic/ariaSnapshot'; import { parseAriaSnapshot } from '@isomorphic/ariaSnapshot'; +import { generateAriaTree, getAllByAria, matchesAriaTree, renderAriaTree } from './ariaSnapshot'; +import { enclosingShadowRootOrDocument, isElementVisible, isInsideScope, parentElementOrShadowHost, setBrowserName } from './domUtils'; +import { Highlight } from './highlight'; +import { kLayoutSelectorNames, layoutSelectorScore } from './layoutSelectorUtils'; +import { ReactEngine } from './reactSelectorEngine'; +import { createRoleEngine } from './roleSelectorEngine'; +import { getAriaDisabled, getAriaRole, getCheckedAllowMixed, getCheckedWithoutMixed, getElementAccessibleDescription, getElementAccessibleErrorMessage, getElementAccessibleName, getReadonly } from './roleUtils'; +import { SelectorEvaluatorImpl, sortInDOMOrder } from './selectorEvaluator'; +import { generateSelector } from './selectorGenerator'; +import { elementMatchesText, elementText, getElementLabels } from './selectorUtils'; +import { VueEngine } from './vueSelectorEngine'; +import { XPathEngine } from './xpathSelectorEngine'; +import { asLocator } from '../../utils/isomorphic/locatorGenerators'; +import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser'; +import { parseSelector, stringifySelector, visitAllSelectorParts } from '../../utils/isomorphic/selectorParser'; +import { cacheNormalizedWhitespaces, normalizeWhiteSpace, trimStringWithEllipsis } from '../../utils/isomorphic/stringUtils'; + +import type { AriaNode, AriaSnapshot } from './ariaSnapshot'; +import type { LayoutSelectorName } from './layoutSelectorUtils'; +import type { SelectorEngine, SelectorRoot } from './selectorEngine'; +import type { GenerateSelectorOptions } from './selectorGenerator'; +import type { ElementText, TextMatcher } from './selectorUtils'; +import type { CSSComplexSelectorList } from '../../utils/isomorphic/cssParser'; +import type { Language } from '../../utils/isomorphic/locatorGenerators'; +import type { NestedSelectorBody, ParsedSelector, ParsedSelectorPart } from '../../utils/isomorphic/selectorParser'; +import type { AriaTemplateNode } from '@isomorphic/ariaSnapshot'; +import type * as channels from '@protocol/channels'; + + export type FrameExpectParams = Omit & { expectedValue?: any }; export type ElementState = 'visible' | 'hidden' | 'enabled' | 'disabled' | 'editable' | 'checked' | 'unchecked' | 'indeterminate' | 'stable'; diff --git a/packages/playwright-core/src/server/injected/reactSelectorEngine.ts b/packages/playwright-core/src/server/injected/reactSelectorEngine.ts index 2d0e51f0b2..5beb3cc9ee 100644 --- a/packages/playwright-core/src/server/injected/reactSelectorEngine.ts +++ b/packages/playwright-core/src/server/injected/reactSelectorEngine.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import type { SelectorEngine, SelectorRoot } from './selectorEngine'; import { isInsideScope } from './domUtils'; import { matchesComponentAttribute } from './selectorUtils'; import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser'; +import type { SelectorEngine, SelectorRoot } from './selectorEngine'; + type ComponentNode = { key?: any, name: string, diff --git a/packages/playwright-core/src/server/injected/recorder/pollingRecorder.ts b/packages/playwright-core/src/server/injected/recorder/pollingRecorder.ts index 86b2babdd9..fd9a3edf98 100644 --- a/packages/playwright-core/src/server/injected/recorder/pollingRecorder.ts +++ b/packages/playwright-core/src/server/injected/recorder/pollingRecorder.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import type { ElementInfo, Mode, OverlayState, UIState } from '@recorder/recorderTypes'; -import type * as actions from '@recorder/actions'; -import type { InjectedScript } from '../injectedScript'; import { Recorder } from './recorder'; + +import type { InjectedScript } from '../injectedScript'; import type { RecorderDelegate } from './recorder'; +import type * as actions from '@recorder/actions'; +import type { ElementInfo, Mode, OverlayState, UIState } from '@recorder/recorderTypes'; interface Embedder { __pw_recorderPerformAction(action: actions.PerformOnRecordAction): Promise; diff --git a/packages/playwright-core/src/server/injected/recorder/recorder.ts b/packages/playwright-core/src/server/injected/recorder/recorder.ts index 3df43f751e..27e4f35a10 100644 --- a/packages/playwright-core/src/server/injected/recorder/recorder.ts +++ b/packages/playwright-core/src/server/injected/recorder/recorder.ts @@ -14,14 +14,15 @@ * limitations under the License. */ -import type * as actions from '@recorder/actions'; -import type { InjectedScript } from '../injectedScript'; -import type { Point } from '../../../common/types'; -import type { ElementInfo, Mode, OverlayState, UIState } from '@recorder/recorderTypes'; -import type { ElementText } from '../selectorUtils'; -import type { Highlight, HighlightOptions } from '../highlight'; import clipPaths from './clipPaths'; +import type { Point } from '../../../common/types'; +import type { Highlight, HighlightOptions } from '../highlight'; +import type { InjectedScript } from '../injectedScript'; +import type { ElementText } from '../selectorUtils'; +import type * as actions from '@recorder/actions'; +import type { ElementInfo, Mode, OverlayState, UIState } from '@recorder/recorderTypes'; + export interface RecorderDelegate { performAction?(action: actions.PerformOnRecordAction): Promise; recordAction?(action: actions.Action): Promise; diff --git a/packages/playwright-core/src/server/injected/roleSelectorEngine.ts b/packages/playwright-core/src/server/injected/roleSelectorEngine.ts index b647f81b8e..2a9c8f648e 100644 --- a/packages/playwright-core/src/server/injected/roleSelectorEngine.ts +++ b/packages/playwright-core/src/server/injected/roleSelectorEngine.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import type { SelectorEngine, SelectorRoot } from './selectorEngine'; -import { matchesAttributePart } from './selectorUtils'; import { beginAriaCaches, endAriaCaches, getAriaChecked, getAriaDisabled, getAriaExpanded, getAriaLevel, getAriaPressed, getAriaRole, getAriaSelected, getElementAccessibleName, isElementHiddenForAria, kAriaCheckedRoles, kAriaExpandedRoles, kAriaLevelRoles, kAriaPressedRoles, kAriaSelectedRoles } from './roleUtils'; -import { parseAttributeSelector, type AttributeSelectorPart, type AttributeSelectorOperator } from '../../utils/isomorphic/selectorParser'; +import { matchesAttributePart } from './selectorUtils'; +import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser'; import { normalizeWhiteSpace } from '../../utils/isomorphic/stringUtils'; +import type { SelectorEngine, SelectorRoot } from './selectorEngine'; +import type { AttributeSelectorOperator, AttributeSelectorPart } from '../../utils/isomorphic/selectorParser'; + type RoleEngineOptions = { role: string; name?: string | RegExp; diff --git a/packages/playwright-core/src/server/injected/roleUtils.ts b/packages/playwright-core/src/server/injected/roleUtils.ts index a7b3cd1d4b..d56075ea58 100644 --- a/packages/playwright-core/src/server/injected/roleUtils.ts +++ b/packages/playwright-core/src/server/injected/roleUtils.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { AriaRole } from '@isomorphic/ariaSnapshot'; import { closestCrossShadow, elementSafeTagName, enclosingShadowRootOrDocument, getElementComputedStyle, isElementStyleVisibilityVisible, isVisibleTextNode, parentElementOrShadowHost } from './domUtils'; +import type { AriaRole } from '@isomorphic/ariaSnapshot'; + function hasExplicitAccessibleName(e: Element) { return e.hasAttribute('aria-label') || e.hasAttribute('aria-labelledby'); } diff --git a/packages/playwright-core/src/server/injected/selectorEvaluator.ts b/packages/playwright-core/src/server/injected/selectorEvaluator.ts index d2f481526f..7d55229166 100644 --- a/packages/playwright-core/src/server/injected/selectorEvaluator.ts +++ b/packages/playwright-core/src/server/injected/selectorEvaluator.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import type { CSSComplexSelector, CSSSimpleSelector, CSSComplexSelectorList, CSSFunctionArgument } from '../../utils/isomorphic/cssParser'; -import { customCSSNames } from '../../utils/isomorphic/selectorParser'; import { isElementVisible, parentElementOrShadowHost } from './domUtils'; -import { type LayoutSelectorName, layoutSelectorScore } from './layoutSelectorUtils'; -import { elementMatchesText, elementText, shouldSkipForTextMatching, type ElementText } from './selectorUtils'; +import { layoutSelectorScore } from './layoutSelectorUtils'; +import { elementMatchesText, elementText, shouldSkipForTextMatching } from './selectorUtils'; +import { customCSSNames } from '../../utils/isomorphic/selectorParser'; import { normalizeWhiteSpace } from '../../utils/isomorphic/stringUtils'; +import type { LayoutSelectorName } from './layoutSelectorUtils'; +import type { ElementText } from './selectorUtils'; +import type { CSSComplexSelector, CSSComplexSelectorList, CSSFunctionArgument, CSSSimpleSelector } from '../../utils/isomorphic/cssParser'; + type QueryContext = { scope: Element | Document; pierceShadow: boolean; diff --git a/packages/playwright-core/src/server/injected/selectorGenerator.ts b/packages/playwright-core/src/server/injected/selectorGenerator.ts index 04f1598762..70541abfc0 100644 --- a/packages/playwright-core/src/server/injected/selectorGenerator.ts +++ b/packages/playwright-core/src/server/injected/selectorGenerator.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import { cssEscape, escapeForAttributeSelector, escapeForTextSelector, escapeRegExp, quoteCSSAttributeValue } from '../../utils/isomorphic/stringUtils'; import { closestCrossShadow, isElementVisible, isInsideScope, parentElementOrShadowHost } from './domUtils'; -import type { InjectedScript } from './injectedScript'; -import { getAriaRole, getElementAccessibleName, beginAriaCaches, endAriaCaches } from './roleUtils'; +import { beginAriaCaches, endAriaCaches, getAriaRole, getElementAccessibleName } from './roleUtils'; import { elementText, getElementLabels } from './selectorUtils'; +import { cssEscape, escapeForAttributeSelector, escapeForTextSelector, escapeRegExp, quoteCSSAttributeValue } from '../../utils/isomorphic/stringUtils'; + +import type { InjectedScript } from './injectedScript'; type SelectorToken = { engine: string; diff --git a/packages/playwright-core/src/server/injected/selectorUtils.ts b/packages/playwright-core/src/server/injected/selectorUtils.ts index da0f869fa0..31db84683d 100644 --- a/packages/playwright-core/src/server/injected/selectorUtils.ts +++ b/packages/playwright-core/src/server/injected/selectorUtils.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { AttributeSelectorPart } from '../../utils/isomorphic/selectorParser'; -import { normalizeWhiteSpace } from '../../utils/isomorphic/stringUtils'; import { getAriaLabelledByElements } from './roleUtils'; +import { normalizeWhiteSpace } from '../../utils/isomorphic/stringUtils'; + +import type { AttributeSelectorPart } from '../../utils/isomorphic/selectorParser'; export function matchesComponentAttribute(obj: any, attr: AttributeSelectorPart) { for (const token of attr.jsonPath) { diff --git a/packages/playwright-core/src/server/injected/utilityScript.ts b/packages/playwright-core/src/server/injected/utilityScript.ts index 7b046a529a..2a987802ff 100644 --- a/packages/playwright-core/src/server/injected/utilityScript.ts +++ b/packages/playwright-core/src/server/injected/utilityScript.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { serializeAsCallArgument, parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers'; +import { parseEvaluationResultValue, serializeAsCallArgument } from '../isomorphic/utilityScriptSerializers'; export class UtilityScript { constructor(isUnderTest: boolean) { diff --git a/packages/playwright-core/src/server/injected/vueSelectorEngine.ts b/packages/playwright-core/src/server/injected/vueSelectorEngine.ts index 154f36b983..a9f179bf43 100644 --- a/packages/playwright-core/src/server/injected/vueSelectorEngine.ts +++ b/packages/playwright-core/src/server/injected/vueSelectorEngine.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import type { SelectorEngine, SelectorRoot } from './selectorEngine'; import { isInsideScope } from './domUtils'; import { matchesComponentAttribute } from './selectorUtils'; import { parseAttributeSelector } from '../../utils/isomorphic/selectorParser'; +import type { SelectorEngine, SelectorRoot } from './selectorEngine'; + type ComponentNode = { name: string, children: ComponentNode[], diff --git a/packages/playwright-core/src/server/input.ts b/packages/playwright-core/src/server/input.ts index f8beb789f8..62261edfae 100644 --- a/packages/playwright-core/src/server/input.ts +++ b/packages/playwright-core/src/server/input.ts @@ -16,9 +16,10 @@ import { assert } from '../utils'; import * as keyboardLayout from './usKeyboardLayout'; -import type * as types from './types'; -import type { Page } from './page'; + import type { CallMetadata } from './instrumentation'; +import type { Page } from './page'; +import type * as types from './types'; export const keypadLocation = keyboardLayout.keypadLocation; diff --git a/packages/playwright-core/src/server/instrumentation.ts b/packages/playwright-core/src/server/instrumentation.ts index 2a384fb169..b33ec542ec 100644 --- a/packages/playwright-core/src/server/instrumentation.ts +++ b/packages/playwright-core/src/server/instrumentation.ts @@ -15,14 +15,20 @@ */ import { EventEmitter } from 'events'; + import { createGuid } from '../utils'; -import type { APIRequestContext } from './fetch'; + import type { Browser } from './browser'; import type { BrowserContext } from './browserContext'; import type { BrowserType } from './browserType'; +import type { Dialog } from './dialog'; +import type { Download } from './download'; +import type { APIRequestContext } from './fetch'; import type { Frame } from './frames'; import type { Page } from './page'; import type { Playwright } from './playwright'; +import type { CallMetadata } from '@protocol/callMetadata'; +export type { CallMetadata } from '@protocol/callMetadata'; export type Attribution = { playwright: Playwright; @@ -33,11 +39,6 @@ export type Attribution = { frame?: Frame; }; -import type { CallMetadata } from '@protocol/callMetadata'; -import type { Dialog } from './dialog'; -import type { Download } from './download'; -export type { CallMetadata } from '@protocol/callMetadata'; - export class SdkObject extends EventEmitter { guid: string; attribution: Attribution; diff --git a/packages/playwright-core/src/server/javascript.ts b/packages/playwright-core/src/server/javascript.ts index dbbe89d5c2..32ba84179e 100644 --- a/packages/playwright-core/src/server/javascript.ts +++ b/packages/playwright-core/src/server/javascript.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type * as dom from './dom'; -import * as utilityScriptSource from '../generated/utilityScriptSource'; -import { serializeAsCallArgument } from './isomorphic/utilityScriptSerializers'; -import type { UtilityScript } from './injected/utilityScript'; import { SdkObject } from './instrumentation'; -import { LongStandingScope } from '../utils/manualPromise'; +import * as utilityScriptSource from '../generated/utilityScriptSource'; import { isUnderTest } from '../utils'; +import { serializeAsCallArgument } from './isomorphic/utilityScriptSerializers'; +import { LongStandingScope } from '../utils/manualPromise'; + +import type * as dom from './dom'; +import type { UtilityScript } from './injected/utilityScript'; export type ObjectId = string; export type RemoteObject = { diff --git a/packages/playwright-core/src/server/launchApp.ts b/packages/playwright-core/src/server/launchApp.ts index d8c81a3169..009748395a 100644 --- a/packages/playwright-core/src/server/launchApp.ts +++ b/packages/playwright-core/src/server/launchApp.ts @@ -14,16 +14,19 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { Page } from './page'; -import { findChromiumChannel } from './registry'; +import * as fs from 'fs'; +import * as path from 'path'; + import { isUnderTest } from '../utils'; import { serverSideCallMetadata } from './instrumentation'; -import type * as types from './types'; +import { findChromiumChannel } from './registry'; +import { registryDirectory } from './registry'; + import type { BrowserType } from './browserType'; import type { CRPage } from './chromium/crPage'; -import { registryDirectory } from './registry'; +import type { Page } from './page'; +import type * as types from './types'; + export async function launchApp(browserType: BrowserType, options: { sdkLanguage: string, diff --git a/packages/playwright-core/src/server/network.ts b/packages/playwright-core/src/server/network.ts index 006f2f4cbf..81e23abd82 100644 --- a/packages/playwright-core/src/server/network.ts +++ b/packages/playwright-core/src/server/network.ts @@ -14,18 +14,20 @@ * limitations under the License. */ -import type * as contexts from './browserContext'; -import type * as pages from './page'; -import type * as frames from './frames'; -import type * as types from './types'; -import type * as channels from '@protocol/channels'; import { assert } from '../utils'; -import { ManualPromise } from '../utils/manualPromise'; -import { SdkObject } from './instrumentation'; -import type { HeadersArray, NameValue } from '../common/types'; -import { APIRequestContext } from './fetch'; -import type { NormalizedContinueOverrides } from './types'; import { BrowserContext } from './browserContext'; +import { APIRequestContext } from './fetch'; +import { SdkObject } from './instrumentation'; +import { ManualPromise } from '../utils/manualPromise'; + +import type * as contexts from './browserContext'; +import type * as frames from './frames'; +import type * as pages from './page'; +import type * as types from './types'; +import type { NormalizedContinueOverrides } from './types'; +import type { HeadersArray, NameValue } from '../common/types'; +import type * as channels from '@protocol/channels'; + export function filterCookies(cookies: channels.NetworkCookie[], urls: string[]): channels.NetworkCookie[] { const parsedURLs = urls.map(s => new URL(s)); diff --git a/packages/playwright-core/src/server/page.ts b/packages/playwright-core/src/server/page.ts index b8fdae2808..0f50455155 100644 --- a/packages/playwright-core/src/server/page.ts +++ b/packages/playwright-core/src/server/page.ts @@ -15,37 +15,38 @@ * limitations under the License. */ -import type * as dom from './dom'; -import * as frames from './frames'; -import * as input from './input'; -import * as js from './javascript'; -import type * as network from './network'; -import type * as channels from '@protocol/channels'; -import type { ScreenshotOptions } from './screenshotter'; -import { Screenshotter, validateScreenshotOptions } from './screenshotter'; -import { TimeoutSettings } from '../common/timeoutSettings'; -import type * as types from './types'; +import * as accessibility from './accessibility'; import { BrowserContext } from './browserContext'; import { ConsoleMessage } from './console'; -import * as accessibility from './accessibility'; -import { FileChooser } from './fileChooser'; -import type { Progress } from './progress'; -import { ProgressController } from './progress'; -import { LongStandingScope, assert, compressCallLog, createGuid, trimStringWithEllipsis } from '../utils'; -import { ManualPromise } from '../utils/manualPromise'; -import { debugLogger } from '../utils/debugLogger'; -import type { ImageComparatorOptions } from '../utils/comparators'; -import { getComparator } from '../utils/comparators'; -import type { CallMetadata } from './instrumentation'; -import { SdkObject } from './instrumentation'; -import type { Artifact } from './artifact'; -import type { TimeoutOptions } from '../common/types'; -import { isInvalidSelectorError } from '../utils/isomorphic/selectorParser'; -import { parseEvaluationResultValue, source } from './isomorphic/utilityScriptSerializers'; -import type { SerializedValue } from './isomorphic/utilityScriptSerializers'; import { TargetClosedError, TimeoutError } from './errors'; -import { asLocator } from '../utils'; +import { FileChooser } from './fileChooser'; +import * as frames from './frames'; import { helper } from './helper'; +import * as input from './input'; +import { SdkObject } from './instrumentation'; +import { parseEvaluationResultValue, source } from './isomorphic/utilityScriptSerializers'; +import * as js from './javascript'; +import { ProgressController } from './progress'; +import { Screenshotter, validateScreenshotOptions } from './screenshotter'; +import { TimeoutSettings } from '../common/timeoutSettings'; +import { LongStandingScope, assert, compressCallLog, createGuid, trimStringWithEllipsis } from '../utils'; +import { asLocator } from '../utils'; +import { getComparator } from '../utils/comparators'; +import { debugLogger } from '../utils/debugLogger'; +import { isInvalidSelectorError } from '../utils/isomorphic/selectorParser'; +import { ManualPromise } from '../utils/manualPromise'; + +import type { Artifact } from './artifact'; +import type * as dom from './dom'; +import type { CallMetadata } from './instrumentation'; +import type { SerializedValue } from './isomorphic/utilityScriptSerializers'; +import type * as network from './network'; +import type { Progress } from './progress'; +import type { ScreenshotOptions } from './screenshotter'; +import type * as types from './types'; +import type { TimeoutOptions } from '../common/types'; +import type { ImageComparatorOptions } from '../utils/comparators'; +import type * as channels from '@protocol/channels'; export interface PageDelegate { readonly rawMouse: input.RawMouse; diff --git a/packages/playwright-core/src/server/pipeTransport.ts b/packages/playwright-core/src/server/pipeTransport.ts index b5755d098d..67bf126324 100644 --- a/packages/playwright-core/src/server/pipeTransport.ts +++ b/packages/playwright-core/src/server/pipeTransport.ts @@ -15,10 +15,11 @@ * limitations under the License. */ -import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from './transport'; import { makeWaitForNextTask } from '../utils'; import { debugLogger } from '../utils/debugLogger'; +import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from './transport'; + export class PipeTransport implements ConnectionTransport { private _pipeRead: NodeJS.ReadableStream; private _pipeWrite: NodeJS.WritableStream; diff --git a/packages/playwright-core/src/server/playwright.ts b/packages/playwright-core/src/server/playwright.ts index 722400b6fc..a1092361ae 100644 --- a/packages/playwright-core/src/server/playwright.ts +++ b/packages/playwright-core/src/server/playwright.ts @@ -14,22 +14,24 @@ * limitations under the License. */ +import { debugLogger } from '../utils'; import { Android } from './android/android'; import { AdbBackend } from './android/backendAdb'; -import type { Browser } from './browser'; -import { Chromium } from './chromium/chromium'; -import { Electron } from './electron/electron'; -import { Firefox } from './firefox/firefox'; -import { Selectors } from './selectors'; -import { WebKit } from './webkit/webkit'; -import type { CallMetadata } from './instrumentation'; -import { createInstrumentation, SdkObject } from './instrumentation'; -import { debugLogger, type Language } from '../utils'; -import type { Page } from './page'; -import { DebugController } from './debugController'; -import type { BrowserType } from './browserType'; import { BidiChromium } from './bidi/bidiChromium'; import { BidiFirefox } from './bidi/bidiFirefox'; +import { Chromium } from './chromium/chromium'; +import { DebugController } from './debugController'; +import { Electron } from './electron/electron'; +import { Firefox } from './firefox/firefox'; +import { SdkObject, createInstrumentation } from './instrumentation'; +import { Selectors } from './selectors'; +import { WebKit } from './webkit/webkit'; + +import type { BrowserType } from './browserType'; +import type { Language } from '../utils'; +import type { Browser } from './browser'; +import type { CallMetadata } from './instrumentation'; +import type { Page } from './page'; type PlaywrightOptions = { socksProxyPort?: number; diff --git a/packages/playwright-core/src/server/progress.ts b/packages/playwright-core/src/server/progress.ts index d92c5ed226..f1c54edfe8 100644 --- a/packages/playwright-core/src/server/progress.ts +++ b/packages/playwright-core/src/server/progress.ts @@ -16,10 +16,11 @@ import { TimeoutError } from './errors'; import { assert, monotonicTime } from '../utils'; -import type { LogName } from '../utils/debugLogger'; -import type { CallMetadata, Instrumentation, SdkObject } from './instrumentation'; import { ManualPromise } from '../utils/manualPromise'; +import type { CallMetadata, Instrumentation, SdkObject } from './instrumentation'; +import type { LogName } from '../utils/debugLogger'; + export interface Progress { log(message: string): void; timeUntilDeadline(): number; diff --git a/packages/playwright-core/src/server/recorder.ts b/packages/playwright-core/src/server/recorder.ts index 9fbe4962d2..79165df8f2 100644 --- a/packages/playwright-core/src/server/recorder.ts +++ b/packages/playwright-core/src/server/recorder.ts @@ -14,25 +14,27 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import type { CallLog, CallLogStatus, ElementInfo, EventData, Mode, OverlayState, Source, UIState } from '@recorder/recorderTypes'; import * as fs from 'fs'; -import type { Point } from '../common/types'; + import * as consoleApiSource from '../generated/consoleApiSource'; import { isUnderTest } from '../utils'; -import { locatorOrSelectorAsSelector } from '../utils/isomorphic/locatorParser'; import { BrowserContext } from './browserContext'; -import { type Language } from './codegen/types'; import { Debugger } from './debugger'; -import type { CallMetadata, InstrumentationListener, SdkObject } from './instrumentation'; import { ContextRecorder, generateFrameSelector } from './recorder/contextRecorder'; -import type { IRecorderAppFactory, IRecorderApp, IRecorder } from './recorder/recorderFrontend'; import { buildFullSelector, metadataToCallLog } from './recorder/recorderUtils'; -import type * as actions from '@recorder/actions'; +import { locatorOrSelectorAsSelector } from '../utils/isomorphic/locatorParser'; import { stringifySelector } from '../utils/isomorphic/selectorParser'; + +import type { Language } from './codegen/types'; import type { Frame } from './frames'; -import type { AriaTemplateNode } from '@isomorphic/ariaSnapshot'; +import type { CallMetadata, InstrumentationListener, SdkObject } from './instrumentation'; import type { Page } from './page'; +import type { IRecorder, IRecorderApp, IRecorderAppFactory } from './recorder/recorderFrontend'; +import type { Point } from '../common/types'; +import type { AriaTemplateNode } from '@isomorphic/ariaSnapshot'; +import type * as channels from '@protocol/channels'; +import type * as actions from '@recorder/actions'; +import type { CallLog, CallLogStatus, ElementInfo, EventData, Mode, OverlayState, Source, UIState } from '@recorder/recorderTypes'; const recorderSymbol = Symbol('recorderSymbol'); diff --git a/packages/playwright-core/src/server/recorder/chat.ts b/packages/playwright-core/src/server/recorder/chat.ts index 5b3917c735..c3ad0238f7 100644 --- a/packages/playwright-core/src/server/recorder/chat.ts +++ b/packages/playwright-core/src/server/recorder/chat.ts @@ -15,6 +15,7 @@ */ import { WebSocketTransport } from '../transport'; + import type { ConnectionTransport, ProtocolResponse } from '../transport'; export type ChatMessage = { diff --git a/packages/playwright-core/src/server/recorder/contextRecorder.ts b/packages/playwright-core/src/server/recorder/contextRecorder.ts index 292271acd5..5cc3e9abae 100644 --- a/packages/playwright-core/src/server/recorder/contextRecorder.ts +++ b/packages/playwright-core/src/server/recorder/contextRecorder.ts @@ -14,23 +14,26 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; -import type { Source } from '@recorder/recorderTypes'; import { EventEmitter } from 'events'; + +import { RecorderCollection } from './recorderCollection'; import * as recorderSource from '../../generated/pollingRecorderSource'; -import { eventsHelper, monotonicTime, quoteCSSAttributeValue, type RegisteredListener } from '../../utils'; +import { eventsHelper, monotonicTime, quoteCSSAttributeValue } from '../../utils'; import { raceAgainstDeadline } from '../../utils/timeoutRunner'; import { BrowserContext } from '../browserContext'; -import type { LanguageGeneratorOptions, Language, LanguageGenerator } from '../codegen/types'; import { languageSet } from '../codegen/languages'; -import type { Dialog } from '../dialog'; import { Frame } from '../frames'; import { Page } from '../page'; -import type * as actions from '@recorder/actions'; import { ThrottledFile } from './throttledFile'; -import { RecorderCollection } from './recorderCollection'; import { generateCode } from '../codegen/language'; +import type { RegisteredListener } from '../../utils'; +import type { Language, LanguageGenerator, LanguageGeneratorOptions } from '../codegen/types'; +import type { Dialog } from '../dialog'; +import type * as channels from '@protocol/channels'; +import type * as actions from '@recorder/actions'; +import type { Source } from '@recorder/recorderTypes'; + type BindingSource = { frame: Frame, page: Page }; export interface ContextRecorderDelegate { diff --git a/packages/playwright-core/src/server/recorder/recorderApp.ts b/packages/playwright-core/src/server/recorder/recorderApp.ts index 05ac4cd0dd..79c7d2d4d0 100644 --- a/packages/playwright-core/src/server/recorder/recorderApp.ts +++ b/packages/playwright-core/src/server/recorder/recorderApp.ts @@ -14,20 +14,22 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { Page } from '../page'; -import { ProgressController } from '../progress'; import { EventEmitter } from 'events'; -import { serverSideCallMetadata } from '../instrumentation'; -import type { CallLog, ElementInfo, Mode, Source } from '@recorder/recorderTypes'; +import * as fs from 'fs'; +import * as path from 'path'; + import { isUnderTest } from '../../utils'; import { mime } from '../../utilsBundle'; +import { serverSideCallMetadata } from '../instrumentation'; import { syncLocalStorageWithSettings } from '../launchApp'; -import type { BrowserContext } from '../browserContext'; import { launchApp } from '../launchApp'; +import { ProgressController } from '../progress'; + +import type { BrowserContext } from '../browserContext'; +import type { Page } from '../page'; import type { IRecorder, IRecorderApp, IRecorderAppFactory } from './recorderFrontend'; import type * as actions from '@recorder/actions'; +import type { CallLog, ElementInfo, Mode, Source } from '@recorder/recorderTypes'; export class EmptyRecorderApp extends EventEmitter implements IRecorderApp { wsEndpointForTest: undefined; diff --git a/packages/playwright-core/src/server/recorder/recorderCollection.ts b/packages/playwright-core/src/server/recorder/recorderCollection.ts index 9f28efd930..1780502d7d 100644 --- a/packages/playwright-core/src/server/recorder/recorderCollection.ts +++ b/packages/playwright-core/src/server/recorder/recorderCollection.ts @@ -15,14 +15,16 @@ */ import { EventEmitter } from 'events'; + +import { performAction } from './recorderRunner'; +import { collapseActions } from './recorderUtils'; +import { isUnderTest } from '../../utils/debug'; +import { monotonicTime } from '../../utils/time'; + +import type { Signal } from '../../../../recorder/src/actions'; import type { Frame } from '../frames'; import type { Page } from '../page'; -import type { Signal } from '../../../../recorder/src/actions'; import type * as actions from '@recorder/actions'; -import { monotonicTime } from '../../utils/time'; -import { collapseActions } from './recorderUtils'; -import { performAction } from './recorderRunner'; -import { isUnderTest } from '../../utils/debug'; export class RecorderCollection extends EventEmitter { private _actions: actions.ActionInContext[] = []; diff --git a/packages/playwright-core/src/server/recorder/recorderFrontend.ts b/packages/playwright-core/src/server/recorder/recorderFrontend.ts index c6fb6e0a1c..1b97541cb7 100644 --- a/packages/playwright-core/src/server/recorder/recorderFrontend.ts +++ b/packages/playwright-core/src/server/recorder/recorderFrontend.ts @@ -15,7 +15,7 @@ */ import type * as actions from '@recorder/actions'; -import type { CallLog, Mode, Source, ElementInfo } from '@recorder/recorderTypes'; +import type { CallLog, ElementInfo, Mode, Source } from '@recorder/recorderTypes'; import type { EventEmitter } from 'events'; export interface IRecorder { diff --git a/packages/playwright-core/src/server/recorder/recorderRunner.ts b/packages/playwright-core/src/server/recorder/recorderRunner.ts index bb225ec5ab..5936060609 100644 --- a/packages/playwright-core/src/server/recorder/recorderRunner.ts +++ b/packages/playwright-core/src/server/recorder/recorderRunner.ts @@ -17,11 +17,12 @@ import { serializeExpectedTextValues } from '../../utils'; import { toKeyboardModifiers } from '../codegen/language'; import { serverSideCallMetadata } from '../instrumentation'; -import type { Page } from '../page'; -import type * as actions from '@recorder/actions'; -import type * as types from '../types'; import { buildFullSelector, mainFrameForAction } from './recorderUtils'; +import type { Page } from '../page'; +import type * as types from '../types'; +import type * as actions from '@recorder/actions'; + export async function performAction(pageAliases: Map, actionInContext: actions.ActionInContext) { const callMetadata = serverSideCallMetadata(); const mainFrame = mainFrameForAction(pageAliases, actionInContext); diff --git a/packages/playwright-core/src/server/recorder/recorderUtils.ts b/packages/playwright-core/src/server/recorder/recorderUtils.ts index 77ef329d27..39e8c07557 100644 --- a/packages/playwright-core/src/server/recorder/recorderUtils.ts +++ b/packages/playwright-core/src/server/recorder/recorderUtils.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -import type { CallMetadata } from '../instrumentation'; -import type { CallLog, CallLogStatus } from '@recorder/recorderTypes'; -import type { Page } from '../page'; import type { Frame } from '../frames'; +import type { CallMetadata } from '../instrumentation'; +import type { Page } from '../page'; import type * as actions from '@recorder/actions'; +import type { CallLog, CallLogStatus } from '@recorder/recorderTypes'; export function buildFullSelector(framePath: string[], selector: string) { return [...framePath, selector].join(' >> internal:control=enter-frame >> '); diff --git a/packages/playwright-core/src/server/registry/browserFetcher.ts b/packages/playwright-core/src/server/registry/browserFetcher.ts index 3a6e36b42d..f206382b17 100644 --- a/packages/playwright-core/src/server/registry/browserFetcher.ts +++ b/packages/playwright-core/src/server/registry/browserFetcher.ts @@ -15,16 +15,19 @@ * limitations under the License. */ -import fs from 'fs'; -import os from 'os'; -import path from 'path'; -import childProcess from 'child_process'; -import { existsAsync } from '../../utils/fileUtils'; +import * as childProcess from 'child_process'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + import { debugLogger } from '../../utils/debugLogger'; +import { existsAsync } from '../../utils/fileUtils'; import { ManualPromise } from '../../utils/manualPromise'; -import { colors, progress as ProgressBar } from '../../utilsBundle'; -import { browserDirectoryToMarkerFilePath } from '.'; import { getUserAgent } from '../../utils/userAgent'; +import { colors, progress as ProgressBar } from '../../utilsBundle'; + +import { browserDirectoryToMarkerFilePath } from '.'; + import type { DownloadParams } from './oopDownloadBrowserMain'; export async function downloadBrowserWithProgressBar(title: string, browserDirectory: string, executablePath: string | undefined, downloadURLs: string[], downloadFileName: string, downloadConnectionTimeout: number): Promise { diff --git a/packages/playwright-core/src/server/registry/dependencies.ts b/packages/playwright-core/src/server/registry/dependencies.ts index 4aa568a6f9..4b61f59058 100644 --- a/packages/playwright-core/src/server/registry/dependencies.ts +++ b/packages/playwright-core/src/server/registry/dependencies.ts @@ -14,17 +14,19 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as childProcess from 'child_process'; +import * as fs from 'fs'; import * as os from 'os'; -import childProcess from 'child_process'; -import * as utils from '../../utils'; -import { spawnAsync } from '../../utils/spawnAsync'; -import { hostPlatform, isOfficiallySupportedPlatform } from '../../utils/hostPlatform'; -import { buildPlaywrightCLICommand, registry } from '.'; +import * as path from 'path'; + import { deps } from './nativeDeps'; +import * as utils from '../../utils'; +import { hostPlatform, isOfficiallySupportedPlatform } from '../../utils/hostPlatform'; +import { spawnAsync } from '../../utils/spawnAsync'; import { getPlaywrightVersion } from '../../utils/userAgent'; +import { buildPlaywrightCLICommand, registry } from '.'; + const BIN_DIRECTORY = path.join(__dirname, '..', '..', '..', 'bin'); const languageBindingVersion = process.env.PW_CLI_DISPLAY_VERSION || require('../../../package.json').version; diff --git a/packages/playwright-core/src/server/registry/index.ts b/packages/playwright-core/src/server/registry/index.ts index c221fc01c2..a1aa6a68d2 100644 --- a/packages/playwright-core/src/server/registry/index.ts +++ b/packages/playwright-core/src/server/registry/index.ts @@ -15,23 +15,27 @@ * limitations under the License. */ -import * as os from 'os'; -import path from 'path'; -import * as util from 'util'; import * as fs from 'fs'; -import { lockfile } from '../../utilsBundle'; -import { fetchData } from '../../utils/network'; -import { getEmbedderName } from '../../utils/userAgent'; -import { getFromENV, getAsBooleanFromENV, calculateSha1, wrapInASCIIBox, getPackageManagerExecCommand } from '../../utils'; -import { removeFolders, existsAsync, canAccessFile } from '../../utils/fileUtils'; -import { type HostPlatform, hostPlatform, isOfficiallySupportedPlatform } from '../../utils/hostPlatform'; -import { spawnAsync } from '../../utils/spawnAsync'; -import type { DependencyGroup } from './dependencies'; -import { transformCommandsForRoot, dockerVersion, readDockerVersionSync } from './dependencies'; -import { installDependenciesLinux, installDependenciesWindows, validateDependenciesLinux, validateDependenciesWindows } from './dependencies'; +import * as os from 'os'; +import * as path from 'path'; +import * as util from 'util'; + import { downloadBrowserWithProgressBar, logPolitely } from './browserFetcher'; -export { writeDockerVersion } from './dependencies'; +import { dockerVersion, readDockerVersionSync, transformCommandsForRoot } from './dependencies'; +import { installDependenciesLinux, installDependenciesWindows, validateDependenciesLinux, validateDependenciesWindows } from './dependencies'; +import { calculateSha1, getAsBooleanFromENV, getFromENV, getPackageManagerExecCommand, wrapInASCIIBox } from '../../utils'; import { debugLogger } from '../../utils/debugLogger'; +import { canAccessFile, existsAsync, removeFolders } from '../../utils/fileUtils'; +import { hostPlatform, isOfficiallySupportedPlatform } from '../../utils/hostPlatform'; +import { fetchData } from '../../utils/network'; +import { spawnAsync } from '../../utils/spawnAsync'; +import { getEmbedderName } from '../../utils/userAgent'; +import { lockfile } from '../../utilsBundle'; + +import type { DependencyGroup } from './dependencies'; +import type { HostPlatform } from '../../utils/hostPlatform'; + +export { writeDockerVersion } from './dependencies'; const PACKAGE_PATH = path.join(__dirname, '..', '..', '..'); const BIN_PATH = path.join(__dirname, '..', '..', '..', 'bin'); diff --git a/packages/playwright-core/src/server/registry/oopDownloadBrowserMain.ts b/packages/playwright-core/src/server/registry/oopDownloadBrowserMain.ts index 247581277e..765e5b89a8 100644 --- a/packages/playwright-core/src/server/registry/oopDownloadBrowserMain.ts +++ b/packages/playwright-core/src/server/registry/oopDownloadBrowserMain.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import { httpRequest } from '../../utils/network'; +import * as fs from 'fs'; +import * as path from 'path'; + import { ManualPromise } from '../../utils/manualPromise'; +import { httpRequest } from '../../utils/network'; import { extract } from '../../zipBundle'; export type DownloadParams = { diff --git a/packages/playwright-core/src/server/screenshotter.ts b/packages/playwright-core/src/server/screenshotter.ts index 485560b539..88870b8900 100644 --- a/packages/playwright-core/src/server/screenshotter.ts +++ b/packages/playwright-core/src/server/screenshotter.ts @@ -15,17 +15,19 @@ * limitations under the License. */ -import type * as dom from './dom'; -import type { Rect } from '../common/types'; import { helper } from './helper'; -import type { Page } from './page'; -import type { Frame } from './frames'; -import type { ParsedSelector } from '../utils/isomorphic/selectorParser'; -import type * as types from './types'; -import type { Progress } from './progress'; import { assert } from '../utils'; import { MultiMap } from '../utils/multimap'; +import type * as dom from './dom'; +import type { Frame } from './frames'; +import type { Page } from './page'; +import type { Progress } from './progress'; +import type * as types from './types'; +import type { Rect } from '../common/types'; +import type { ParsedSelector } from '../utils/isomorphic/selectorParser'; + + declare global { interface Window { __pwCleanupScreenshot?: () => void; diff --git a/packages/playwright-core/src/server/selectors.ts b/packages/playwright-core/src/server/selectors.ts index edc11b9a86..1d1eece9cc 100644 --- a/packages/playwright-core/src/server/selectors.ts +++ b/packages/playwright-core/src/server/selectors.ts @@ -14,8 +14,10 @@ * limitations under the License. */ -import { visitAllSelectorParts, InvalidSelectorError, type ParsedSelector, parseSelector, stringifySelector } from '../utils/isomorphic/selectorParser'; import { createGuid } from '../utils'; +import { InvalidSelectorError, parseSelector, stringifySelector, visitAllSelectorParts } from '../utils/isomorphic/selectorParser'; + +import type { ParsedSelector } from '../utils/isomorphic/selectorParser'; export class Selectors { private readonly _builtinEngines: Set; diff --git a/packages/playwright-core/src/server/socksClientCertificatesInterceptor.ts b/packages/playwright-core/src/server/socksClientCertificatesInterceptor.ts index 6413cd1ddf..05e6b374c9 100644 --- a/packages/playwright-core/src/server/socksClientCertificatesInterceptor.ts +++ b/packages/playwright-core/src/server/socksClientCertificatesInterceptor.ts @@ -14,20 +14,22 @@ * limitations under the License. */ -import net from 'net'; -import http2 from 'http2'; -import type https from 'https'; -import tls from 'tls'; -import stream from 'stream'; -import { createSocket, createTLSSocket } from '../utils/happy-eyeballs'; -import { escapeHTML, generateSelfSignedCertificate, ManualPromise, rewriteErrorMessage } from '../utils'; -import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../common/socksProxy'; -import { SocksProxy } from '../common/socksProxy'; -import type * as types from './types'; -import { debugLogger } from '../utils/debugLogger'; -import { createProxyAgent } from './fetch'; import { EventEmitter } from 'events'; +import * as http2 from 'http2'; +import * as net from 'net'; +import * as stream from 'stream'; +import * as tls from 'tls'; + +import { SocksProxy } from '../common/socksProxy'; +import { ManualPromise, escapeHTML, generateSelfSignedCertificate, rewriteErrorMessage } from '../utils'; import { verifyClientCertificates } from './browserContext'; +import { createProxyAgent } from './fetch'; +import { debugLogger } from '../utils/debugLogger'; +import { createSocket, createTLSSocket } from '../utils/happy-eyeballs'; + +import type * as types from './types'; +import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../common/socksProxy'; +import type https from 'https'; let dummyServerTlsOptions: tls.TlsOptions | undefined = undefined; function loadDummyServerCertsIfNeeded() { diff --git a/packages/playwright-core/src/server/socksInterceptor.ts b/packages/playwright-core/src/server/socksInterceptor.ts index 6b29636a00..61309ab11d 100644 --- a/packages/playwright-core/src/server/socksInterceptor.ts +++ b/packages/playwright-core/src/server/socksInterceptor.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import * as socks from '../common/socksProxy'; import EventEmitter from 'events'; -import type * as channels from '@protocol/channels'; + +import * as socks from '../common/socksProxy'; +import { ValidationError, findValidator } from '../protocol/validator'; + import type { WebSocketTransport } from './transport'; -import { findValidator, ValidationError } from '../protocol/validator'; import type { ValidatorContext } from '../protocol/validator'; +import type * as channels from '@protocol/channels'; export class SocksInterceptor { private _handler: socks.SocksProxyHandler; diff --git a/packages/playwright-core/src/server/storageScript.ts b/packages/playwright-core/src/server/storageScript.ts index 04e6b3f6d1..fb4ca02082 100644 --- a/packages/playwright-core/src/server/storageScript.ts +++ b/packages/playwright-core/src/server/storageScript.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import type * as channels from '@protocol/channels'; import type { source } from './isomorphic/utilityScriptSerializers'; +import type * as channels from '@protocol/channels'; export type Storage = Omit; diff --git a/packages/playwright-core/src/server/trace/recorder/snapshotter.ts b/packages/playwright-core/src/server/trace/recorder/snapshotter.ts index 115cd3dd94..1ad2fdf1ca 100644 --- a/packages/playwright-core/src/server/trace/recorder/snapshotter.ts +++ b/packages/playwright-core/src/server/trace/recorder/snapshotter.ts @@ -14,17 +14,18 @@ * limitations under the License. */ -import { BrowserContext } from '../../browserContext'; -import { Page } from '../../page'; -import type { RegisteredListener } from '../../../utils/eventsHelper'; -import { eventsHelper } from '../../../utils/eventsHelper'; -import { debugLogger } from '../../../utils/debugLogger'; -import type { Frame } from '../../frames'; -import type { SnapshotData } from './snapshotterInjected'; import { frameSnapshotStreamer } from './snapshotterInjected'; import { calculateSha1, createGuid, monotonicTime } from '../../../utils'; -import type { FrameSnapshot } from '@trace/snapshot'; +import { debugLogger } from '../../../utils/debugLogger'; +import { eventsHelper } from '../../../utils/eventsHelper'; import { mime } from '../../../utilsBundle'; +import { BrowserContext } from '../../browserContext'; +import { Page } from '../../page'; + +import type { SnapshotData } from './snapshotterInjected'; +import type { RegisteredListener } from '../../../utils/eventsHelper'; +import type { Frame } from '../../frames'; +import type { FrameSnapshot } from '@trace/snapshot'; export type SnapshotterBlob = { buffer: Buffer, diff --git a/packages/playwright-core/src/server/trace/recorder/tracing.ts b/packages/playwright-core/src/server/trace/recorder/tracing.ts index 6f6724e368..a245de16f6 100644 --- a/packages/playwright-core/src/server/trace/recorder/tracing.ts +++ b/packages/playwright-core/src/server/trace/recorder/tracing.ts @@ -14,31 +14,34 @@ * limitations under the License. */ -import fs from 'fs'; -import os from 'os'; -import path from 'path'; -import type { NameValue } from '../../../common/types'; -import type { TracingTracingStopChunkParams, StackFrame } from '@protocol/channels'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + +import { Snapshotter } from './snapshotter'; import { commandsWithTracingSnapshots } from '../../../protocol/debug'; -import { assert, createGuid, monotonicTime, SerializedFS, removeFolders, eventsHelper, type RegisteredListener } from '../../../utils'; +import { SerializedFS, assert, createGuid, eventsHelper, monotonicTime, removeFolders } from '../../../utils'; import { Artifact } from '../../artifact'; import { BrowserContext } from '../../browserContext'; -import type { APIRequestContext } from '../../fetch'; -import type { CallMetadata, InstrumentationListener } from '../../instrumentation'; -import { SdkObject } from '../../instrumentation'; -import { Page } from '../../page'; -import type * as har from '@trace/har'; -import type { HarTracerDelegate } from '../../har/harTracer'; -import { HarTracer } from '../../har/harTracer'; -import type { FrameSnapshot } from '@trace/snapshot'; -import type * as trace from '@trace/trace'; -import type { SnapshotterBlob, SnapshotterDelegate } from './snapshotter'; -import { Snapshotter } from './snapshotter'; -import type { ConsoleMessage } from '../../console'; import { Dispatcher } from '../../dispatchers/dispatcher'; import { serializeError } from '../../errors'; +import { HarTracer } from '../../har/harTracer'; +import { SdkObject } from '../../instrumentation'; +import { Page } from '../../page'; + +import type { SnapshotterBlob, SnapshotterDelegate } from './snapshotter'; +import type { NameValue } from '../../../common/types'; +import type { RegisteredListener } from '../../../utils'; +import type { ConsoleMessage } from '../../console'; import type { Dialog } from '../../dialog'; import type { Download } from '../../download'; +import type { APIRequestContext } from '../../fetch'; +import type { HarTracerDelegate } from '../../har/harTracer'; +import type { CallMetadata, InstrumentationListener } from '../../instrumentation'; +import type { StackFrame, TracingTracingStopChunkParams } from '@protocol/channels'; +import type * as har from '@trace/har'; +import type { FrameSnapshot } from '@trace/snapshot'; +import type * as trace from '@trace/trace'; const version: trace.VERSION = 7; diff --git a/packages/playwright-core/src/server/trace/test/inMemorySnapshotter.ts b/packages/playwright-core/src/server/trace/test/inMemorySnapshotter.ts index d5da0e4229..36d4cf655e 100644 --- a/packages/playwright-core/src/server/trace/test/inMemorySnapshotter.ts +++ b/packages/playwright-core/src/server/trace/test/inMemorySnapshotter.ts @@ -14,17 +14,19 @@ * limitations under the License. */ -import type { BrowserContext } from '../../browserContext'; -import type { Page } from '../../page'; -import type { FrameSnapshot } from '@trace/snapshot'; -import type { SnapshotRenderer } from '../../../../../trace-viewer/src/sw/snapshotRenderer'; import { SnapshotStorage } from '../../../../../trace-viewer/src/sw/snapshotStorage'; -import type { SnapshotterBlob, SnapshotterDelegate } from '../recorder/snapshotter'; -import { Snapshotter } from '../recorder/snapshotter'; -import type { HarTracerDelegate } from '../../har/harTracer'; -import { HarTracer } from '../../har/harTracer'; -import type * as har from '@trace/har'; import { ManualPromise } from '../../../utils'; +import { HarTracer } from '../../har/harTracer'; +import { Snapshotter } from '../recorder/snapshotter'; + +import type { SnapshotRenderer } from '../../../../../trace-viewer/src/sw/snapshotRenderer'; +import type { BrowserContext } from '../../browserContext'; +import type { HarTracerDelegate } from '../../har/harTracer'; +import type { Page } from '../../page'; +import type { SnapshotterBlob, SnapshotterDelegate } from '../recorder/snapshotter'; +import type * as har from '@trace/har'; +import type { FrameSnapshot } from '@trace/snapshot'; + export class InMemorySnapshotter implements SnapshotterDelegate, HarTracerDelegate { private _blobs = new Map(); diff --git a/packages/playwright-core/src/server/trace/viewer/traceViewer.ts b/packages/playwright-core/src/server/trace/viewer/traceViewer.ts index 55cbca1cad..ad9de86715 100644 --- a/packages/playwright-core/src/server/trace/viewer/traceViewer.ts +++ b/packages/playwright-core/src/server/trace/viewer/traceViewer.ts @@ -14,19 +14,21 @@ * limitations under the License. */ -import path from 'path'; -import fs from 'fs'; -import { HttpServer } from '../../../utils/httpServer'; -import type { Transport } from '../../../utils/httpServer'; +import * as fs from 'fs'; +import * as path from 'path'; + import { gracefullyProcessExitDoNotHang, isUnderTest } from '../../../utils'; -import { syncLocalStorageWithSettings } from '../../launchApp'; +import { HttpServer } from '../../../utils/httpServer'; +import { open } from '../../../utilsBundle'; import { serverSideCallMetadata } from '../../instrumentation'; +import { syncLocalStorageWithSettings } from '../../launchApp'; +import { launchApp } from '../../launchApp'; import { createPlaywright } from '../../playwright'; import { ProgressController } from '../../progress'; -import { open } from '../../../utilsBundle'; -import type { Page } from '../../page'; + +import type { Transport } from '../../../utils/httpServer'; import type { BrowserType } from '../../browserType'; -import { launchApp } from '../../launchApp'; +import type { Page } from '../../page'; export type TraceViewerServerOptions = { host?: string; diff --git a/packages/playwright-core/src/server/transport.ts b/packages/playwright-core/src/server/transport.ts index 507225b04c..6de9f9ca8e 100644 --- a/packages/playwright-core/src/server/transport.ts +++ b/packages/playwright-core/src/server/transport.ts @@ -15,13 +15,14 @@ * limitations under the License. */ -import { ws } from '../utilsBundle'; -import type { WebSocket } from '../utilsBundle'; -import type { ClientRequest, IncomingMessage } from 'http'; -import type { Progress } from './progress'; import { makeWaitForNextTask } from '../utils'; import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent } from '../utils/happy-eyeballs'; +import { ws } from '../utilsBundle'; + +import type { WebSocket } from '../utilsBundle'; +import type { Progress } from './progress'; import type { HeadersArray } from './types'; +import type { ClientRequest, IncomingMessage } from 'http'; export const perMessageDeflate = { clientNoContextTakeover: true, diff --git a/packages/playwright-core/src/server/types.ts b/packages/playwright-core/src/server/types.ts index b5603f19e6..e7bf2c11f3 100644 --- a/packages/playwright-core/src/server/types.ts +++ b/packages/playwright-core/src/server/types.ts @@ -15,8 +15,8 @@ * limitations under the License. */ -import type { Size, Point, TimeoutOptions, HeadersArray } from '../common/types'; -export type { Size, Point, Rect, Quad, TimeoutOptions, HeadersArray } from '../common/types'; +import type { HeadersArray, Point, Size, TimeoutOptions } from '../common/types'; +export type { HeadersArray, Point, Quad, Rect, Size, TimeoutOptions } from '../common/types'; import type * as channels from '@protocol/channels'; export type StrictOptions = { diff --git a/packages/playwright-core/src/server/webkit/webkit.ts b/packages/playwright-core/src/server/webkit/webkit.ts index 5159f8cecb..69273b8e95 100644 --- a/packages/playwright-core/src/server/webkit/webkit.ts +++ b/packages/playwright-core/src/server/webkit/webkit.ts @@ -15,17 +15,19 @@ * limitations under the License. */ -import { WKBrowser } from '../webkit/wkBrowser'; -import type { Env } from '../../utils/processLauncher'; -import path from 'path'; +import * as path from 'path'; + import { kBrowserCloseMessageId } from './wkConnection'; -import { BrowserType, kNoXServerRunningError } from '../browserType'; -import type { ConnectionTransport } from '../transport'; -import type { BrowserOptions } from '../browser'; -import type * as types from '../types'; import { wrapInASCIIBox } from '../../utils'; +import { BrowserType, kNoXServerRunningError } from '../browserType'; +import { WKBrowser } from '../webkit/wkBrowser'; + +import type { Env } from '../../utils/processLauncher'; +import type { BrowserOptions } from '../browser'; import type { SdkObject } from '../instrumentation'; import type { ProtocolError } from '../protocolError'; +import type { ConnectionTransport } from '../transport'; +import type * as types from '../types'; export class WebKit extends BrowserType { constructor(parent: SdkObject) { diff --git a/packages/playwright-core/src/server/webkit/wkAccessibility.ts b/packages/playwright-core/src/server/webkit/wkAccessibility.ts index 80c855ea7b..52b9199df5 100644 --- a/packages/playwright-core/src/server/webkit/wkAccessibility.ts +++ b/packages/playwright-core/src/server/webkit/wkAccessibility.ts @@ -14,8 +14,8 @@ * limitations under the License. */ import type * as accessibility from '../accessibility'; -import type { WKSession } from './wkConnection'; import type { Protocol } from './protocol'; +import type { WKSession } from './wkConnection'; import type * as dom from '../dom'; import type * as channels from '@protocol/channels'; diff --git a/packages/playwright-core/src/server/webkit/wkBrowser.ts b/packages/playwright-core/src/server/webkit/wkBrowser.ts index 86833088d8..4924abe77e 100644 --- a/packages/playwright-core/src/server/webkit/wkBrowser.ts +++ b/packages/playwright-core/src/server/webkit/wkBrowser.ts @@ -15,21 +15,22 @@ * limitations under the License. */ -import type { BrowserOptions } from '../browser'; -import { Browser } from '../browser'; -import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext'; import { assert } from '../../utils'; +import { Browser } from '../browser'; +import { BrowserContext, assertBrowserContextIsNotOwned, verifyGeolocation } from '../browserContext'; import * as network from '../network'; +import { WKConnection, WKSession, kPageProxyMessageReceived } from './wkConnection'; +import { WKPage } from './wkPage'; +import { TargetClosedError } from '../errors'; + +import type { BrowserOptions } from '../browser'; +import type { SdkObject } from '../instrumentation'; import type { InitScript, Page } from '../page'; import type { ConnectionTransport } from '../transport'; import type * as types from '../types'; -import type * as channels from '@protocol/channels'; import type { Protocol } from './protocol'; import type { PageProxyMessageReceivedPayload } from './wkConnection'; -import { kPageProxyMessageReceived, WKConnection, WKSession } from './wkConnection'; -import { WKPage } from './wkPage'; -import { TargetClosedError } from '../errors'; -import type { SdkObject } from '../instrumentation'; +import type * as channels from '@protocol/channels'; const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Safari/605.1.15'; const BROWSER_VERSION = '18.2'; diff --git a/packages/playwright-core/src/server/webkit/wkConnection.ts b/packages/playwright-core/src/server/webkit/wkConnection.ts index a2bbed1121..0012d8702f 100644 --- a/packages/playwright-core/src/server/webkit/wkConnection.ts +++ b/packages/playwright-core/src/server/webkit/wkConnection.ts @@ -16,14 +16,17 @@ */ import { EventEmitter } from 'events'; + import { assert } from '../../utils'; +import { debugLogger } from '../../utils/debugLogger'; +import { helper } from '../helper'; +import { ProtocolError } from '../protocolError'; + import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport'; import type { Protocol } from './protocol'; import type { RecentLogsCollector } from '../../utils/debugLogger'; -import { debugLogger } from '../../utils/debugLogger'; import type { ProtocolLogger } from '../types'; -import { helper } from '../helper'; -import { ProtocolError } from '../protocolError'; + // WKPlaywright uses this special id to issue Browser.close command which we // should ignore. diff --git a/packages/playwright-core/src/server/webkit/wkExecutionContext.ts b/packages/playwright-core/src/server/webkit/wkExecutionContext.ts index 2b75745cbd..2101b6002b 100644 --- a/packages/playwright-core/src/server/webkit/wkExecutionContext.ts +++ b/packages/playwright-core/src/server/webkit/wkExecutionContext.ts @@ -15,12 +15,13 @@ * limitations under the License. */ -import type { WKSession } from './wkConnection'; -import type { Protocol } from './protocol'; -import * as js from '../javascript'; import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers'; +import * as js from '../javascript'; import { isSessionClosedError } from '../protocolError'; +import type { Protocol } from './protocol'; +import type { WKSession } from './wkConnection'; + export class WKExecutionContext implements js.ExecutionContextDelegate { private readonly _session: WKSession; readonly _contextId: number | undefined; diff --git a/packages/playwright-core/src/server/webkit/wkInput.ts b/packages/playwright-core/src/server/webkit/wkInput.ts index 5769fd6465..1e4ccf6b0b 100644 --- a/packages/playwright-core/src/server/webkit/wkInput.ts +++ b/packages/playwright-core/src/server/webkit/wkInput.ts @@ -15,11 +15,12 @@ * limitations under the License. */ -import * as input from '../input'; -import type * as types from '../types'; -import { macEditingCommands } from '../macEditingCommands'; -import type { WKSession } from './wkConnection'; import { isString } from '../../utils'; +import * as input from '../input'; +import { macEditingCommands } from '../macEditingCommands'; + +import type * as types from '../types'; +import type { WKSession } from './wkConnection'; import type { Page } from '../page'; function toModifiersMask(modifiers: Set): number { diff --git a/packages/playwright-core/src/server/webkit/wkInterceptableRequest.ts b/packages/playwright-core/src/server/webkit/wkInterceptableRequest.ts index 93367726ed..45494d6cc9 100644 --- a/packages/playwright-core/src/server/webkit/wkInterceptableRequest.ts +++ b/packages/playwright-core/src/server/webkit/wkInterceptableRequest.ts @@ -15,12 +15,14 @@ * limitations under the License. */ -import type * as frames from '../frames'; +import { assert, headersArrayToObject, headersObjectToArray } from '../../utils'; import * as network from '../network'; + +import type * as frames from '../frames'; import type * as types from '../types'; import type { Protocol } from './protocol'; import type { WKSession } from './wkConnection'; -import { assert, headersObjectToArray, headersArrayToObject } from '../../utils'; + const errorReasons: { [reason: string]: Protocol.Network.ResourceErrorType } = { 'aborted': 'Cancellation', diff --git a/packages/playwright-core/src/server/webkit/wkPage.ts b/packages/playwright-core/src/server/webkit/wkPage.ts index 4a78642668..e80031d388 100644 --- a/packages/playwright-core/src/server/webkit/wkPage.ts +++ b/packages/playwright-core/src/server/webkit/wkPage.ts @@ -15,27 +15,22 @@ * limitations under the License. */ -import path from 'path'; -import { PNG, jpegjs } from '../../utilsBundle'; -import { splitErrorMessage } from '../../utils/stackTrace'; +import * as path from 'path'; + import { assert, createGuid, debugAssert, headersArrayToObject } from '../../utils'; +import { eventsHelper } from '../../utils/eventsHelper'; import { hostPlatform } from '../../utils/hostPlatform'; -import type * as accessibility from '../accessibility'; +import { splitErrorMessage } from '../../utils/stackTrace'; +import { PNG, jpegjs } from '../../utilsBundle'; +import { BrowserContext } from '../browserContext'; import * as dialog from '../dialog'; import * as dom from '../dom'; -import type * as frames from '../frames'; -import type { RegisteredListener } from '../../utils/eventsHelper'; -import { eventsHelper } from '../../utils/eventsHelper'; +import { TargetClosedError } from '../errors'; import { helper } from '../helper'; -import type { JSHandle } from '../javascript'; import * as network from '../network'; -import { type InitScript, PageBinding, type PageDelegate } from '../page'; +import { PageBinding } from '../page'; import { Page } from '../page'; -import type { Progress } from '../progress'; -import type * as types from '../types'; -import type { Protocol } from './protocol'; import { getAccessibilityTree } from './wkAccessibility'; -import type { WKBrowserContext } from './wkBrowser'; import { WKSession } from './wkConnection'; import { WKExecutionContext } from './wkExecutionContext'; import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './wkInput'; @@ -43,8 +38,16 @@ import { WKInterceptableRequest, WKRouteImpl } from './wkInterceptableRequest'; import { WKProvisionalPage } from './wkProvisionalPage'; import { WKWorkers } from './wkWorkers'; import { debugLogger } from '../../utils/debugLogger'; -import { BrowserContext } from '../browserContext'; -import { TargetClosedError } from '../errors'; + +import type { Protocol } from './protocol'; +import type { WKBrowserContext } from './wkBrowser'; +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type * as accessibility from '../accessibility'; +import type * as frames from '../frames'; +import type { JSHandle } from '../javascript'; +import type { InitScript, PageDelegate } from '../page'; +import type { Progress } from '../progress'; +import type * as types from '../types'; const UTILITY_WORLD_NAME = '__playwright_utility_world__'; diff --git a/packages/playwright-core/src/server/webkit/wkProvisionalPage.ts b/packages/playwright-core/src/server/webkit/wkProvisionalPage.ts index 6d7459c978..2958f4597c 100644 --- a/packages/playwright-core/src/server/webkit/wkProvisionalPage.ts +++ b/packages/playwright-core/src/server/webkit/wkProvisionalPage.ts @@ -14,12 +14,13 @@ * limitations under the License. */ +import { assert } from '../../utils'; +import { eventsHelper } from '../../utils/eventsHelper'; + +import type { Protocol } from './protocol'; import type { WKSession } from './wkConnection'; import type { WKPage } from './wkPage'; import type { RegisteredListener } from '../../utils/eventsHelper'; -import { eventsHelper } from '../../utils/eventsHelper'; -import type { Protocol } from './protocol'; -import { assert } from '../../utils'; import type * as network from '../network'; export class WKProvisionalPage { diff --git a/packages/playwright-core/src/server/webkit/wkWorkers.ts b/packages/playwright-core/src/server/webkit/wkWorkers.ts index ae69b72f8a..644c64a27f 100644 --- a/packages/playwright-core/src/server/webkit/wkWorkers.ts +++ b/packages/playwright-core/src/server/webkit/wkWorkers.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { RegisteredListener } from '../../utils/eventsHelper'; import { eventsHelper } from '../../utils/eventsHelper'; -import type { Page } from '../page'; import { Worker } from '../page'; -import type { Protocol } from './protocol'; import { WKSession } from './wkConnection'; import { WKExecutionContext } from './wkExecutionContext'; + +import type { Protocol } from './protocol'; +import type { RegisteredListener } from '../../utils/eventsHelper'; +import type { Page } from '../page'; import type * as types from '../types'; export class WKWorkers { diff --git a/packages/playwright-core/src/utils/comparators.ts b/packages/playwright-core/src/utils/comparators.ts index c848200d66..ac6bc24421 100644 --- a/packages/playwright-core/src/utils/comparators.ts +++ b/packages/playwright-core/src/utils/comparators.ts @@ -15,10 +15,10 @@ * limitations under the License. */ -import { colors, jpegjs } from '../utilsBundle'; +import { compare } from '../image_tools/compare'; // @ts-ignore import pixelmatch from '../third_party/pixelmatch'; -import { compare } from '../image_tools/compare'; +import { colors, jpegjs } from '../utilsBundle'; import { diff } from '../utilsBundle'; import { PNG } from '../utilsBundle'; diff --git a/packages/playwright-core/src/utils/crypto.ts b/packages/playwright-core/src/utils/crypto.ts index f538912d24..c59b84caf0 100644 --- a/packages/playwright-core/src/utils/crypto.ts +++ b/packages/playwright-core/src/utils/crypto.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import crypto from 'crypto'; +import * as crypto from 'crypto'; + import { assert } from './debug'; export function createGuid(): string { diff --git a/packages/playwright-core/src/utils/debugLogger.ts b/packages/playwright-core/src/utils/debugLogger.ts index d50180a2ed..24b0a1dbf8 100644 --- a/packages/playwright-core/src/utils/debugLogger.ts +++ b/packages/playwright-core/src/utils/debugLogger.ts @@ -14,8 +14,9 @@ * limitations under the License. */ +import * as fs from 'fs'; + import { debug } from '../utilsBundle'; -import fs from 'fs'; const debugLoggerColorMap = { 'api': 45, // cyan diff --git a/packages/playwright-core/src/utils/expectUtils.ts b/packages/playwright-core/src/utils/expectUtils.ts index 0ae21e8602..f39af23cee 100644 --- a/packages/playwright-core/src/utils/expectUtils.ts +++ b/packages/playwright-core/src/utils/expectUtils.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { ExpectedTextValue } from '@protocol/channels'; import { isRegExp, isString } from './rtti'; +import type { ExpectedTextValue } from '@protocol/channels'; + export function serializeExpectedTextValues(items: (string | RegExp)[], options: { matchSubstring?: boolean, normalizeWhiteSpace?: boolean, ignoreCase?: boolean } = {}): ExpectedTextValue[] { return items.map(i => ({ string: isString(i) ? i : undefined, diff --git a/packages/playwright-core/src/utils/fileUtils.ts b/packages/playwright-core/src/utils/fileUtils.ts index b7f441aa37..8cfd3d1fe0 100644 --- a/packages/playwright-core/src/utils/fileUtils.ts +++ b/packages/playwright-core/src/utils/fileUtils.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + import { ManualPromise } from './manualPromise'; -import type { EventEmitter } from 'events'; import { yazl } from '../zipBundle'; +import type { EventEmitter } from 'events'; + export const fileUploadSizeLimit = 50 * 1024 * 1024; export const existsAsync = (path: string): Promise => new Promise(resolve => fs.stat(path, err => resolve(!err))); diff --git a/packages/playwright-core/src/utils/happy-eyeballs.ts b/packages/playwright-core/src/utils/happy-eyeballs.ts index 02b78de4f0..48e1909371 100644 --- a/packages/playwright-core/src/utils/happy-eyeballs.ts +++ b/packages/playwright-core/src/utils/happy-eyeballs.ts @@ -19,8 +19,9 @@ import * as http from 'http'; import * as https from 'https'; import * as net from 'net'; import * as tls from 'tls'; -import { ManualPromise } from './manualPromise'; + import { assert } from './debug'; +import { ManualPromise } from './manualPromise'; import { monotonicTime } from './time'; // Implementation(partial) of Happy Eyeballs 2 algorithm described in diff --git a/packages/playwright-core/src/utils/hostPlatform.ts b/packages/playwright-core/src/utils/hostPlatform.ts index 0563e4ab29..058b5b9f78 100644 --- a/packages/playwright-core/src/utils/hostPlatform.ts +++ b/packages/playwright-core/src/utils/hostPlatform.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import os from 'os'; +import * as os from 'os'; + import { getLinuxDistributionInfoSync } from './linuxUtils'; export type HostPlatform = 'win64' | diff --git a/packages/playwright-core/src/utils/httpServer.ts b/packages/playwright-core/src/utils/httpServer.ts index 1d78df4659..71b0754b8f 100644 --- a/packages/playwright-core/src/utils/httpServer.ts +++ b/packages/playwright-core/src/utils/httpServer.ts @@ -14,14 +14,16 @@ * limitations under the License. */ -import type http from 'http'; -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + import { mime, wsServer } from '../utilsBundle'; -import { assert } from './debug'; -import { createHttpServer } from './network'; -import { ManualPromise } from './manualPromise'; import { createGuid } from './crypto'; +import { assert } from './debug'; +import { ManualPromise } from './manualPromise'; +import { createHttpServer } from './network'; + +import type http from 'http'; export type ServerRouteHandler = (request: http.IncomingMessage, response: http.ServerResponse) => boolean; diff --git a/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts b/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts index 355d0cec5f..77ce63f313 100644 --- a/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts +++ b/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts @@ -14,8 +14,10 @@ * limitations under the License. */ +import { parseAttributeSelector, parseSelector, stringifySelector } from './selectorParser'; import { escapeWithQuotes, normalizeEscapedRegexQuotes, toSnakeCase, toTitleCase } from './stringUtils'; -import { type NestedSelectorBody, parseAttributeSelector, parseSelector, stringifySelector } from './selectorParser'; + +import type { NestedSelectorBody } from './selectorParser'; import type { ParsedSelector } from './selectorParser'; export type Language = 'javascript' | 'python' | 'java' | 'csharp' | 'jsonl'; diff --git a/packages/playwright-core/src/utils/isomorphic/locatorParser.ts b/packages/playwright-core/src/utils/isomorphic/locatorParser.ts index fff3d078ff..f89dbb50f7 100644 --- a/packages/playwright-core/src/utils/isomorphic/locatorParser.ts +++ b/packages/playwright-core/src/utils/isomorphic/locatorParser.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import { escapeForAttributeSelector, escapeForTextSelector } from './stringUtils'; import { asLocators } from './locatorGenerators'; -import type { Language, Quote } from './locatorGenerators'; import { parseSelector } from './selectorParser'; +import { escapeForAttributeSelector, escapeForTextSelector } from './stringUtils'; + +import type { Language, Quote } from './locatorGenerators'; type TemplateParams = { quote: string, text: string }[]; function parseLocator(locator: string, testIdAttributeName: string): { selector: string, preferredQuote: Quote | undefined } { diff --git a/packages/playwright-core/src/utils/isomorphic/selectorParser.ts b/packages/playwright-core/src/utils/isomorphic/selectorParser.ts index 64ba3c0c4d..f37d1ef4c3 100644 --- a/packages/playwright-core/src/utils/isomorphic/selectorParser.ts +++ b/packages/playwright-core/src/utils/isomorphic/selectorParser.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -import type { CSSComplexSelectorList } from './cssParser'; import { InvalidSelectorError, parseCSS } from './cssParser'; + +import type { CSSComplexSelectorList } from './cssParser'; export { InvalidSelectorError, isInvalidSelectorError } from './cssParser'; export type NestedSelectorBody = { parsed: ParsedSelector, distance?: number }; diff --git a/packages/playwright-core/src/utils/linuxUtils.ts b/packages/playwright-core/src/utils/linuxUtils.ts index 5d98c823a5..c51d32f9d5 100644 --- a/packages/playwright-core/src/utils/linuxUtils.ts +++ b/packages/playwright-core/src/utils/linuxUtils.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import fs from 'fs'; +import * as fs from 'fs'; let didFailToReadOSRelease = false; let osRelease: { diff --git a/packages/playwright-core/src/utils/network.ts b/packages/playwright-core/src/utils/network.ts index b800a8773d..5c5b851705 100644 --- a/packages/playwright-core/src/utils/network.ts +++ b/packages/playwright-core/src/utils/network.ts @@ -15,15 +15,17 @@ */ -import http from 'http'; -import https from 'https'; -import http2 from 'http2'; -import type net from 'net'; +import * as http from 'http'; +import * as http2 from 'http2'; +import * as https from 'https'; +import * as url from 'url'; + import { getProxyForUrl } from '../utilsBundle'; import { HttpsProxyAgent } from '../utilsBundle'; -import url from 'url'; import { httpHappyEyeballsAgent, httpsHappyEyeballsAgent } from './happy-eyeballs'; +import type net from 'net'; + export type HTTPRequestParams = { url: string, method?: string, diff --git a/packages/playwright-core/src/utils/processLauncher.ts b/packages/playwright-core/src/utils/processLauncher.ts index 1310f95277..68176acc8b 100644 --- a/packages/playwright-core/src/utils/processLauncher.ts +++ b/packages/playwright-core/src/utils/processLauncher.ts @@ -15,12 +15,14 @@ * limitations under the License. */ -import fs from 'fs'; import * as childProcess from 'child_process'; +import * as fs from 'fs'; import * as readline from 'readline'; -import { isUnderTest } from './'; + import { removeFolders } from './fileUtils'; +import { isUnderTest } from './'; + export type Env = {[key: string]: string | number | boolean | undefined}; export type LaunchProcessOptions = { diff --git a/packages/playwright-core/src/utils/spawnAsync.ts b/packages/playwright-core/src/utils/spawnAsync.ts index 8e286fad47..f68719d620 100644 --- a/packages/playwright-core/src/utils/spawnAsync.ts +++ b/packages/playwright-core/src/utils/spawnAsync.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { SpawnOptions } from 'child_process'; import { spawn } from 'child_process'; +import type { SpawnOptions } from 'child_process'; + export function spawnAsync(cmd: string, args: string[], options: SpawnOptions = {}): Promise<{stdout: string, stderr: string, code: number | null, error?: Error}> { const process = spawn(cmd, args, Object.assign({ windowsHide: true }, options)); diff --git a/packages/playwright-core/src/utils/stackTrace.ts b/packages/playwright-core/src/utils/stackTrace.ts index eba52a30f2..bcab6c7230 100644 --- a/packages/playwright-core/src/utils/stackTrace.ts +++ b/packages/playwright-core/src/utils/stackTrace.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; + import { parseStackTraceLine } from '../utilsBundle'; -import type { StackFrame } from '@protocol/channels'; import { colors } from '../utilsBundle'; import { findRepeatedSubsequences } from './sequence'; +import type { StackFrame } from '@protocol/channels'; + export function rewriteErrorMessage(e: E, newMessage: string): E { const lines: string[] = (e.stack?.split('\n') || []).filter(l => l.startsWith(' at ')); e.message = newMessage; diff --git a/packages/playwright-core/src/utils/traceUtils.ts b/packages/playwright-core/src/utils/traceUtils.ts index d0090b3665..c6ecc7988b 100644 --- a/packages/playwright-core/src/utils/traceUtils.ts +++ b/packages/playwright-core/src/utils/traceUtils.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import type { ClientSideCallMetadata } from '@protocol/channels'; import type { SerializedClientSideCallMetadata, SerializedStack, SerializedStackFrame } from './isomorphic/traceUtils'; +import type { ClientSideCallMetadata } from '@protocol/channels'; export function serializeClientSideCallMetadata(metadatas: ClientSideCallMetadata[]): SerializedClientSideCallMetadata { const fileNames = new Map(); diff --git a/packages/playwright-core/src/utils/userAgent.ts b/packages/playwright-core/src/utils/userAgent.ts index 17b1bc51c8..40bb41a49f 100644 --- a/packages/playwright-core/src/utils/userAgent.ts +++ b/packages/playwright-core/src/utils/userAgent.ts @@ -15,9 +15,10 @@ */ import { execSync } from 'child_process'; -import os from 'os'; -import { getLinuxDistributionInfoSync } from '../utils/linuxUtils'; +import * as os from 'os'; + import { wrapInASCIIBox } from './ascii'; +import { getLinuxDistributionInfoSync } from '../utils/linuxUtils'; let cachedUserAgent: string | undefined; diff --git a/packages/playwright-core/src/utils/wsServer.ts b/packages/playwright-core/src/utils/wsServer.ts index 636a57c3cc..f6ba7f6b1b 100644 --- a/packages/playwright-core/src/utils/wsServer.ts +++ b/packages/playwright-core/src/utils/wsServer.ts @@ -14,13 +14,15 @@ * limitations under the License. */ -import type http from 'http'; -import type stream from 'stream'; import { createHttpServer } from '../utils'; -import type { WebSocketServer, WebSocket } from '../utilsBundle'; import { wsServer } from '../utilsBundle'; import { debugLogger } from './debugLogger'; +import type { WebSocket, WebSocketServer } from '../utilsBundle'; +import type http from 'http'; +import type stream from 'stream'; + + let lastConnectionId = 0; const kConnectionSymbol = Symbol('kConnection'); diff --git a/packages/playwright-core/src/utils/zipFile.ts b/packages/playwright-core/src/utils/zipFile.ts index 3ae68b1650..1f70c5e1bc 100644 --- a/packages/playwright-core/src/utils/zipFile.ts +++ b/packages/playwright-core/src/utils/zipFile.ts @@ -15,7 +15,8 @@ */ import { yauzl } from '../zipBundle'; -import type { UnzipFile, Entry } from '../zipBundle'; + +import type { Entry, UnzipFile } from '../zipBundle'; export class ZipFile { private _fileName: string; diff --git a/packages/playwright-core/src/utilsBundle.ts b/packages/playwright-core/src/utilsBundle.ts index fba52c05a8..5e7dd3771a 100644 --- a/packages/playwright-core/src/utilsBundle.ts +++ b/packages/playwright-core/src/utilsBundle.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import url from 'url'; -import path from 'path'; +import * as path from 'path'; +import * as url from 'url'; export const colors: typeof import('../bundles/utils/node_modules/colors/safe') = require('./utilsBundleImpl').colors; export const debug: typeof import('../bundles/utils/node_modules/@types/debug') = require('./utilsBundleImpl').debug; @@ -33,13 +33,13 @@ export const program: typeof import('../bundles/utils/node_modules/commander').p export const progress: typeof import('../bundles/utils/node_modules/@types/progress') = require('./utilsBundleImpl').progress; export const SocksProxyAgent: typeof import('../bundles/utils/node_modules/socks-proxy-agent').SocksProxyAgent = require('./utilsBundleImpl').SocksProxyAgent; export const yaml: typeof import('../bundles/utils/node_modules/yaml') = require('./utilsBundleImpl').yaml; -export type { Scalar as YAMLScalar, YAMLSeq, YAMLMap, YAMLError, Range as YAMLRange } from '../bundles/utils/node_modules/yaml'; +export type { Range as YAMLRange, Scalar as YAMLScalar, YAMLError, YAMLMap, YAMLSeq } from '../bundles/utils/node_modules/yaml'; export const ws: typeof import('../bundles/utils/node_modules/@types/ws') = require('./utilsBundleImpl').ws; export const wsServer: typeof import('../bundles/utils/node_modules/@types/ws').WebSocketServer = require('./utilsBundleImpl').wsServer; export const wsReceiver = require('./utilsBundleImpl').wsReceiver; export const wsSender = require('./utilsBundleImpl').wsSender; export type { Command } from '../bundles/utils/node_modules/commander'; -export type { WebSocket, WebSocketServer, RawData as WebSocketRawData, EventEmitter as WebSocketEventEmitter } from '../bundles/utils/node_modules/@types/ws'; +export type { EventEmitter as WebSocketEventEmitter, RawData as WebSocketRawData, WebSocket, WebSocketServer } from '../bundles/utils/node_modules/@types/ws'; import type { StackFrame } from '@protocol/channels'; const StackUtils: typeof import('../bundles/utils/node_modules/@types/stack-utils') = require('./utilsBundleImpl').StackUtils; diff --git a/packages/playwright-core/src/zipBundle.ts b/packages/playwright-core/src/zipBundle.ts index 9c275873a8..22569758b6 100644 --- a/packages/playwright-core/src/zipBundle.ts +++ b/packages/playwright-core/src/zipBundle.ts @@ -17,5 +17,5 @@ export const yazl: typeof import('../bundles/zip/node_modules/@types/yazl') = require('./zipBundleImpl').yazl; export type { ZipFile } from '../bundles/zip/node_modules/@types/yazl'; export const yauzl: typeof import('../bundles/zip/node_modules/@types/yauzl') = require('./zipBundleImpl').yauzl; -export type { ZipFile as UnzipFile, Entry } from '../bundles/zip/node_modules/@types/yauzl'; +export type { Entry, ZipFile as UnzipFile } from '../bundles/zip/node_modules/@types/yauzl'; export const extract: typeof import('../bundles/zip/node_modules/extract-zip') = require('./zipBundleImpl').extract; diff --git a/utils/generate_channels.js b/utils/generate_channels.js index 827250ad8c..d6bfdf020f 100755 --- a/utils/generate_channels.js +++ b/utils/generate_channels.js @@ -153,6 +153,7 @@ const validator_ts = [ // This file is generated by ${path.basename(__filename)}, do not edit manually. +/* eslint-disable import/order */ import { scheme, tOptional, tObject, tBoolean, tNumber, tString, tAny, tEnum, tArray, tBinary, tChannel, tType } from './validatorPrimitives'; export type { Validator, ValidatorContext } from './validatorPrimitives'; export { ValidationError, findValidator, maybeFindValidator, createMetadataValidator } from './validatorPrimitives'; From d5d47f2b6ecc2e004e9bb1ec6fa9e450277d96c4 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 7 Feb 2025 14:44:00 -0800 Subject: [PATCH 03/11] chore: organize imports in packages (#34681) --- docs/src/auth.md | 10 ++--- docs/src/chrome-extensions-js-python.md | 2 +- docs/src/evaluating.md | 2 +- docs/src/test-api/class-testconfig.md | 2 +- docs/src/test-api/class-testinfo.md | 2 +- docs/src/test-api/class-testproject.md | 2 +- docs/src/test-parameterize-js.md | 6 +-- docs/src/webview2.md | 6 +-- eslint.config.mjs | 4 +- packages/html-reporter/bundle.ts | 4 +- packages/html-reporter/playwright.config.ts | 4 +- packages/playwright-ct-core/src/devServer.ts | 11 +++-- packages/playwright-ct-core/src/mount.ts | 9 ++-- .../playwright-ct-core/src/tsxTransform.ts | 8 ++-- packages/playwright-ct-core/src/vitePlugin.ts | 32 ++++++++------- packages/playwright-ct-core/src/viteUtils.ts | 13 +++--- .../src/examples/browser-anthropic.ts | 4 +- .../src/examples/browser-openai.ts | 3 +- .../examples/computer-20241022-anthropic.ts | 6 ++- .../playwright-tools/src/tools/browser.ts | 8 ++-- .../src/tools/computer-20241022.ts | 8 ++-- packages/playwright-tools/src/tools/utils.ts | 3 +- .../bundles/babel/src/babelBundleImpl.ts | 12 +++--- .../bundles/expect/src/expectBundleImpl.ts | 6 ++- .../expect/third_party/asymmetricMatchers.ts | 2 + .../extractExpectedAssertionsErrors.ts | 2 + .../bundles/expect/third_party/index.ts | 4 +- .../expect/third_party/jestMatchersObject.ts | 4 +- .../bundles/expect/third_party/matchers.ts | 7 +++- .../bundles/expect/third_party/spyMatchers.ts | 7 +++- .../expect/third_party/toThrowMatchers.ts | 7 +++- .../bundles/expect/third_party/types.ts | 2 +- .../bundles/utils/src/utilsBundleImpl.ts | 2 + packages/playwright/src/common/config.ts | 14 ++++--- .../playwright/src/common/configLoader.ts | 11 +++-- .../playwright/src/common/esmLoaderHost.ts | 5 ++- packages/playwright/src/common/fixtures.ts | 6 ++- packages/playwright/src/common/globals.ts | 2 +- packages/playwright/src/common/ipc.ts | 4 +- packages/playwright/src/common/poolBuilder.ts | 5 ++- packages/playwright/src/common/process.ts | 4 +- packages/playwright/src/common/suiteUtils.ts | 11 +++-- packages/playwright/src/common/test.ts | 12 +++--- packages/playwright/src/common/testLoader.ts | 10 +++-- packages/playwright/src/common/testType.ts | 19 +++++---- packages/playwright/src/fsWatcher.ts | 1 + packages/playwright/src/index.ts | 13 +++--- packages/playwright/src/internalsForTest.ts | 3 +- .../playwright/src/isomorphic/teleReceiver.ts | 2 +- .../src/isomorphic/teleSuiteUpdater.ts | 3 +- .../src/isomorphic/testServerConnection.ts | 3 +- .../src/isomorphic/testServerInterface.ts | 2 +- packages/playwright/src/loader/loaderMain.ts | 15 +++---- packages/playwright/src/matchers/expect.ts | 25 ++++++----- .../playwright/src/matchers/matcherHint.ts | 9 ++-- packages/playwright/src/matchers/matchers.ts | 16 ++++---- .../playwright/src/matchers/toBeTruthy.ts | 3 +- packages/playwright/src/matchers/toEqual.ts | 6 ++- packages/playwright/src/matchers/toHaveURL.ts | 11 +++-- .../src/matchers/toMatchAriaSnapshot.ts | 17 +++++--- .../src/matchers/toMatchSnapshot.ts | 28 +++++++------ .../playwright/src/matchers/toMatchText.ts | 10 +++-- .../src/plugins/gitCommitInfoPlugin.ts | 1 + .../playwright/src/plugins/webServerPlugin.ts | 8 ++-- packages/playwright/src/program.ts | 33 ++++++++------- packages/playwright/src/reporters/base.ts | 13 +++--- packages/playwright/src/reporters/blob.ts | 17 ++++---- packages/playwright/src/reporters/dot.ts | 3 +- packages/playwright/src/reporters/github.ts | 7 +++- packages/playwright/src/reporters/html.ts | 29 +++++++------ .../src/reporters/internalReporter.ts | 16 +++++--- packages/playwright/src/reporters/json.ts | 11 +++-- packages/playwright/src/reporters/junit.ts | 11 +++-- packages/playwright/src/reporters/line.ts | 3 +- packages/playwright/src/reporters/list.ts | 8 ++-- packages/playwright/src/reporters/markdown.ts | 8 ++-- packages/playwright/src/reporters/merge.ts | 24 ++++++----- .../playwright/src/reporters/multiplexer.ts | 4 +- .../playwright/src/reporters/reporterV2.ts | 2 +- .../playwright/src/reporters/teleEmitter.ts | 9 ++-- packages/playwright/src/runner/dispatcher.ts | 28 +++++++------ packages/playwright/src/runner/lastRun.ts | 8 ++-- packages/playwright/src/runner/loadUtils.ts | 25 ++++++----- packages/playwright/src/runner/loaderHost.ts | 12 +++--- packages/playwright/src/runner/processHost.ts | 9 ++-- .../playwright/src/runner/projectUtils.ts | 12 ++++-- packages/playwright/src/runner/rebase.ts | 14 ++++--- packages/playwright/src/runner/reporters.ts | 23 +++++++---- packages/playwright/src/runner/runner.ts | 16 ++++---- packages/playwright/src/runner/taskRunner.ts | 7 +++- packages/playwright/src/runner/tasks.ts | 41 +++++++++++-------- packages/playwright/src/runner/testServer.ts | 41 ++++++++++--------- packages/playwright/src/runner/vcs.ts | 3 +- packages/playwright/src/runner/watchMode.ts | 27 +++++++----- packages/playwright/src/runner/workerHost.ts | 18 ++++---- .../playwright/src/transform/babelBundle.ts | 2 +- .../src/transform/compilationCache.ts | 9 ++-- .../playwright/src/transform/esmLoader.ts | 9 ++-- packages/playwright/src/transform/esmUtils.ts | 2 +- .../playwright/src/transform/transform.ts | 21 ++++++---- packages/playwright/src/util.ts | 16 ++++---- .../playwright/src/worker/fixtureRunner.ts | 9 ++-- packages/playwright/src/worker/testInfo.ts | 24 ++++++----- packages/playwright/src/worker/testTracing.ts | 19 +++++---- .../playwright/src/worker/timeoutManager.ts | 3 +- packages/playwright/src/worker/util.ts | 3 +- packages/playwright/src/worker/workerMain.ts | 34 +++++++-------- packages/playwright/types/test.d.ts | 6 +-- packages/trace-viewer/vite.config.ts | 2 +- packages/trace-viewer/vite.sw.config.ts | 2 +- packages/trace/src/trace.ts | 4 +- 111 files changed, 671 insertions(+), 459 deletions(-) diff --git a/docs/src/auth.md b/docs/src/auth.md index 4a3853edf1..19c97c7c43 100644 --- a/docs/src/auth.md +++ b/docs/src/auth.md @@ -47,7 +47,7 @@ Create `tests/auth.setup.ts` that will prepare authenticated browser state for a ```js title="tests/auth.setup.ts" import { test as setup, expect } from '@playwright/test'; -import path from 'path'; +import * as path from 'path'; const authFile = path.join(__dirname, '../playwright/.auth/user.json'); @@ -143,8 +143,8 @@ Create `playwright/fixtures.ts` file that will [override `storageState` fixture] ```js title="playwright/fixtures.ts" import { test as baseTest, expect } from '@playwright/test'; -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; export * from '@playwright/test'; export const test = baseTest.extend<{}, { workerStorageState: string }>({ @@ -348,8 +348,8 @@ Alternatively, in a [worker fixture](#moderate-one-account-per-parallel-worker): ```js title="playwright/fixtures.ts" import { test as baseTest, request } from '@playwright/test'; -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; export * from '@playwright/test'; export const test = baseTest.extend<{}, { workerStorageState: string }>({ diff --git a/docs/src/chrome-extensions-js-python.md b/docs/src/chrome-extensions-js-python.md index 5cabc1c864..3ac6692f16 100644 --- a/docs/src/chrome-extensions-js-python.md +++ b/docs/src/chrome-extensions-js-python.md @@ -109,7 +109,7 @@ First, add fixtures that will load the extension: ```js title="fixtures.ts" import { test as base, chromium, type BrowserContext } from '@playwright/test'; -import path from 'path'; +import * as path from 'path'; export const test = base.extend<{ context: BrowserContext; diff --git a/docs/src/evaluating.md b/docs/src/evaluating.md index 903aeb8a90..d1ee75b8a8 100644 --- a/docs/src/evaluating.md +++ b/docs/src/evaluating.md @@ -389,7 +389,7 @@ Next, add init script to the page. ```js import { test, expect } from '@playwright/test'; -import path from 'path'; +import * as path from 'path'; test.beforeEach(async ({ page }) => { // Add script for every test in the beforeEach hook. diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md index c57789a82b..5b89e62b88 100644 --- a/docs/src/test-api/class-testconfig.md +++ b/docs/src/test-api/class-testconfig.md @@ -291,7 +291,7 @@ Here is an example that uses [`method: TestInfo.outputPath`] to create a tempora ```js import { test, expect } from '@playwright/test'; -import fs from 'fs'; +import * as fs from 'fs'; test('example test', async ({}, testInfo) => { const file = testInfo.outputPath('temporary-file.txt'); diff --git a/docs/src/test-api/class-testinfo.md b/docs/src/test-api/class-testinfo.md index 93cbc93b75..b612699db6 100644 --- a/docs/src/test-api/class-testinfo.md +++ b/docs/src/test-api/class-testinfo.md @@ -254,7 +254,7 @@ Returns a path inside the [`property: TestInfo.outputDir`] where the test can sa ```js import { test, expect } from '@playwright/test'; -import fs from 'fs'; +import * as fs from 'fs'; test('example test', async ({}, testInfo) => { const file = testInfo.outputPath('dir', 'temporary-file.txt'); diff --git a/docs/src/test-api/class-testproject.md b/docs/src/test-api/class-testproject.md index 17fecf6930..e0dda139a3 100644 --- a/docs/src/test-api/class-testproject.md +++ b/docs/src/test-api/class-testproject.md @@ -212,7 +212,7 @@ Here is an example that uses [`method: TestInfo.outputPath`] to create a tempora ```js import { test, expect } from '@playwright/test'; -import fs from 'fs'; +import * as fs from 'fs'; test('example test', async ({}, testInfo) => { const file = testInfo.outputPath('temporary-file.txt'); diff --git a/docs/src/test-parameterize-js.md b/docs/src/test-parameterize-js.md index 7575f96695..8670006833 100644 --- a/docs/src/test-parameterize-js.md +++ b/docs/src/test-parameterize-js.md @@ -262,7 +262,7 @@ To make environment variables easier to manage, consider something like `.env` f ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; import dotenv from 'dotenv'; -import path from 'path'; +import * as path from 'path'; // Read from ".env" file. dotenv.config({ path: path.resolve(__dirname, '.env') }); @@ -309,8 +309,8 @@ See for example this CSV file, in our example `input.csv`: Based on this we'll generate some tests by using the [csv-parse](https://www.npmjs.com/package/csv-parse) library from NPM: ```js title="test.spec.ts" -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; import { test } from '@playwright/test'; import { parse } from 'csv-parse/sync'; diff --git a/docs/src/webview2.md b/docs/src/webview2.md index 7aef7216ca..81a9f698ad 100644 --- a/docs/src/webview2.md +++ b/docs/src/webview2.md @@ -72,9 +72,9 @@ Using the following, Playwright will run your WebView2 application as a sub-proc ```js title="webView2Test.ts" import { test as base } from '@playwright/test'; -import fs from 'fs'; -import os from 'os'; -import path from 'path'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; import childProcess from 'child_process'; const EXECUTABLE_PATH = path.join( diff --git a/eslint.config.mjs b/eslint.config.mjs index 97b29eb05f..d47653345e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -233,7 +233,9 @@ export default [{ }], } }, { - files: ['packages/playwright-core/**/*.ts'], + files: [ + 'packages/**/*.ts', + ], rules: { ...importOrderRules }, diff --git a/packages/html-reporter/bundle.ts b/packages/html-reporter/bundle.ts index 63530cfaad..cb85f309d8 100644 --- a/packages/html-reporter/bundle.ts +++ b/packages/html-reporter/bundle.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; import type { Plugin, UserConfig } from 'vite'; export function bundle(): Plugin { diff --git a/packages/html-reporter/playwright.config.ts b/packages/html-reporter/playwright.config.ts index 1e6cb8b8a3..d2160cd009 100644 --- a/packages/html-reporter/playwright.config.ts +++ b/packages/html-reporter/playwright.config.ts @@ -15,8 +15,8 @@ */ import { devices, defineConfig } from '@playwright/experimental-ct-react'; -import path from 'path'; -import url from 'url'; +import * as path from 'path'; +import * as url from 'url'; export default defineConfig({ testDir: 'src', diff --git a/packages/playwright-ct-core/src/devServer.ts b/packages/playwright-ct-core/src/devServer.ts index 2152a672b3..e93a633b1b 100644 --- a/packages/playwright-ct-core/src/devServer.ts +++ b/packages/playwright-ct-core/src/devServer.ts @@ -14,14 +14,17 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + import { Watcher } from 'playwright/lib/fsWatcher'; -import type { PluginContext } from 'rollup'; + import { source as injectedSource } from './generated/indexSource'; -import { createConfig, populateComponentsFromTests, resolveDirs, transformIndexFile, frameworkConfig } from './viteUtils'; +import { createConfig, frameworkConfig, populateComponentsFromTests, resolveDirs, transformIndexFile } from './viteUtils'; + import type { ComponentRegistry } from './viteUtils'; import type { FullConfig } from 'playwright/test'; +import type { PluginContext } from 'rollup'; export async function runDevServer(config: FullConfig): Promise<() => Promise> { const { registerSourceFile, frameworkPluginFactory } = frameworkConfig(config); diff --git a/packages/playwright-ct-core/src/mount.ts b/packages/playwright-ct-core/src/mount.ts index a3bcfe0641..68a2468c35 100644 --- a/packages/playwright-ct-core/src/mount.ts +++ b/packages/playwright-ct-core/src/mount.ts @@ -14,13 +14,14 @@ * limitations under the License. */ -import type { Fixtures, Locator, Page, BrowserContextOptions, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, BrowserContext } from 'playwright/test'; -import type { Component, JsxComponent, MountOptions, ObjectComponentOptions } from '../types/component'; -import type { ContextReuseMode, FullConfigInternal } from '../../playwright/src/common/config'; -import type { ImportRef } from './injected/importRegistry'; import { wrapObject } from './injected/serializers'; import { Router } from './router'; + +import type { ContextReuseMode, FullConfigInternal } from '../../playwright/src/common/config'; import type { RouterFixture } from '../index'; +import type { ImportRef } from './injected/importRegistry'; +import type { Component, JsxComponent, MountOptions, ObjectComponentOptions } from '../types/component'; +import type { BrowserContext, BrowserContextOptions, Fixtures, Locator, Page, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions } from 'playwright/test'; let boundCallbacksForMount: Function[] = []; diff --git a/packages/playwright-ct-core/src/tsxTransform.ts b/packages/playwright-ct-core/src/tsxTransform.ts index 0af7c181b9..ece6dbccd0 100644 --- a/packages/playwright-ct-core/src/tsxTransform.ts +++ b/packages/playwright-ct-core/src/tsxTransform.ts @@ -14,10 +14,12 @@ * limitations under the License. */ -import path from 'path'; -import type { T, BabelAPI, PluginObj } from 'playwright/src/transform/babelBundle'; -import { types, declare, traverse } from 'playwright/lib/transform/babelBundle'; +import * as path from 'path'; + +import { declare, traverse, types } from 'playwright/lib/transform/babelBundle'; import { setTransformData } from 'playwright/lib/transform/transform'; + +import type { BabelAPI, PluginObj, T } from 'playwright/src/transform/babelBundle'; const t: typeof T = types; let jsxComponentNames: Set; diff --git a/packages/playwright-ct-core/src/vitePlugin.ts b/packages/playwright-ct-core/src/vitePlugin.ts index ec738c8700..038143cdb8 100644 --- a/packages/playwright-ct-core/src/vitePlugin.ts +++ b/packages/playwright-ct-core/src/vitePlugin.ts @@ -14,25 +14,29 @@ * limitations under the License. */ -import fs from 'fs'; -import type http from 'http'; -import type { AddressInfo } from 'net'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { setExternalDependencies } from 'playwright/lib/transform/compilationCache'; +import { resolveHook } from 'playwright/lib/transform/transform'; +import { removeDirAndLogToConsole } from 'playwright/lib/util'; +import { stoppable } from 'playwright/lib/utilsBundle'; import { assert, calculateSha1, getPlaywrightVersion, isURLAvailable } from 'playwright-core/lib/utils'; import { debug } from 'playwright-core/lib/utilsBundle'; -import { setExternalDependencies } from 'playwright/lib/transform/compilationCache'; -import { stoppable } from 'playwright/lib/utilsBundle'; + +import { runDevServer } from './devServer'; +import { source as injectedSource } from './generated/indexSource'; +import { createConfig, frameworkConfig, hasJSComponents, populateComponentsFromTests, resolveDirs, resolveEndpoint, transformIndexFile } from './viteUtils'; + +import type { ImportInfo } from './tsxTransform'; +import type { ComponentRegistry } from './viteUtils'; +import type { TestRunnerPlugin } from '../../playwright/src/plugins'; +import type http from 'http'; +import type { AddressInfo } from 'net'; import type { FullConfig, Suite } from 'playwright/types/testReporter'; import type { PluginContext } from 'rollup'; import type { Plugin, ResolveFn, ResolvedConfig } from 'vite'; -import type { TestRunnerPlugin } from '../../playwright/src/plugins'; -import { source as injectedSource } from './generated/indexSource'; -import type { ImportInfo } from './tsxTransform'; -import type { ComponentRegistry } from './viteUtils'; -import { createConfig, frameworkConfig, hasJSComponents, populateComponentsFromTests, resolveDirs, resolveEndpoint, transformIndexFile } from './viteUtils'; -import { resolveHook } from 'playwright/lib/transform/transform'; -import { runDevServer } from './devServer'; -import { removeDirAndLogToConsole } from 'playwright/lib/util'; + const log = debug('pw:vite'); diff --git a/packages/playwright-ct-core/src/viteUtils.ts b/packages/playwright-ct-core/src/viteUtils.ts index a9f7020999..5873ad4bf0 100644 --- a/packages/playwright-ct-core/src/viteUtils.ts +++ b/packages/playwright-ct-core/src/viteUtils.ts @@ -14,15 +14,18 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import { debug } from 'playwright-core/lib/utilsBundle'; +import * as fs from 'fs'; +import * as path from 'path'; + import { getUserData } from 'playwright/lib/transform/compilationCache'; +import { resolveHook } from 'playwright/lib/transform/transform'; +import { debug } from 'playwright-core/lib/utilsBundle'; + +import type { ImportInfo } from './tsxTransform'; import type { PlaywrightTestConfig as BasePlaywrightTestConfig } from 'playwright/types/test'; import type { FullConfig } from 'playwright/types/testReporter'; import type { InlineConfig, Plugin, TransformResult, UserConfig } from 'vite'; -import type { ImportInfo } from './tsxTransform'; -import { resolveHook } from 'playwright/lib/transform/transform'; + const log = debug('pw:vite'); diff --git a/packages/playwright-tools/src/examples/browser-anthropic.ts b/packages/playwright-tools/src/examples/browser-anthropic.ts index 0053c5749d..d7dd750a18 100644 --- a/packages/playwright-tools/src/examples/browser-anthropic.ts +++ b/packages/playwright-tools/src/examples/browser-anthropic.ts @@ -16,10 +16,10 @@ /* eslint-disable no-console */ -import playwright from 'playwright'; import Anthropic from '@anthropic-ai/sdk'; -import dotenv from 'dotenv'; import browser from '@playwright/experimental-tools/browser'; +import dotenv from 'dotenv'; +import playwright from 'playwright'; dotenv.config(); diff --git a/packages/playwright-tools/src/examples/browser-openai.ts b/packages/playwright-tools/src/examples/browser-openai.ts index 3542d4ba1d..c3f1752d78 100644 --- a/packages/playwright-tools/src/examples/browser-openai.ts +++ b/packages/playwright-tools/src/examples/browser-openai.ts @@ -16,10 +16,11 @@ /* eslint-disable no-console */ -import playwright from 'playwright'; import browser from '@playwright/experimental-tools/browser'; import dotenv from 'dotenv'; import OpenAI from 'openai'; +import playwright from 'playwright'; + import type { ChatCompletionMessageParam, ChatCompletionTool } from 'openai/resources'; dotenv.config(); diff --git a/packages/playwright-tools/src/examples/computer-20241022-anthropic.ts b/packages/playwright-tools/src/examples/computer-20241022-anthropic.ts index 20028c564c..2d8ee4b7f9 100644 --- a/packages/playwright-tools/src/examples/computer-20241022-anthropic.ts +++ b/packages/playwright-tools/src/examples/computer-20241022-anthropic.ts @@ -16,11 +16,13 @@ /* eslint-disable no-console */ -import playwright from 'playwright'; import Anthropic from '@anthropic-ai/sdk'; +import computer from '@playwright/experimental-tools/computer-20241022'; import dotenv from 'dotenv'; -import computer, { type ToolResult } from '@playwright/experimental-tools/computer-20241022'; +import playwright from 'playwright'; + import type { BetaImageBlockParam, BetaTextBlockParam } from '@anthropic-ai/sdk/resources/beta/messages/messages'; +import type { ToolResult } from '@playwright/experimental-tools/computer-20241022'; dotenv.config(); diff --git a/packages/playwright-tools/src/tools/browser.ts b/packages/playwright-tools/src/tools/browser.ts index 4b63487942..1ca7fb074a 100644 --- a/packages/playwright-tools/src/tools/browser.ts +++ b/packages/playwright-tools/src/tools/browser.ts @@ -15,11 +15,13 @@ * limitations under the License. */ -import type playwright from 'playwright'; -import type { JSONSchemaType, ToolDeclaration } from '../../types'; -import type { ToolResult } from '../../browser'; import { waitForNetwork } from './utils'; +import type { ToolResult } from '../../browser'; +import type { JSONSchemaType, ToolDeclaration } from '../../types'; +import type playwright from 'playwright'; + + type LocatorEx = playwright.Locator & { _generateLocatorString: () => Promise; }; diff --git a/packages/playwright-tools/src/tools/computer-20241022.ts b/packages/playwright-tools/src/tools/computer-20241022.ts index e407d027ba..2a7574c485 100644 --- a/packages/playwright-tools/src/tools/computer-20241022.ts +++ b/packages/playwright-tools/src/tools/computer-20241022.ts @@ -15,11 +15,13 @@ * limitations under the License. */ -import type playwright from 'playwright'; -import type { JSONSchemaType } from '../../types'; -import type { ToolResult } from '../../computer-20241022'; import { waitForNetwork } from './utils'; +import type { ToolResult } from '../../computer-20241022'; +import type { JSONSchemaType } from '../../types'; +import type playwright from 'playwright'; + + export async function call(page: playwright.Page, toolName: string, input: Record): Promise { if (toolName !== 'computer') throw new Error('Unsupported tool'); diff --git a/packages/playwright-tools/src/tools/utils.ts b/packages/playwright-tools/src/tools/utils.ts index 08e674014d..71c49e4fe1 100644 --- a/packages/playwright-tools/src/tools/utils.ts +++ b/packages/playwright-tools/src/tools/utils.ts @@ -15,9 +15,10 @@ * limitations under the License. */ -import type playwright from 'playwright'; import { ManualPromise } from 'playwright-core/lib/utils'; +import type playwright from 'playwright'; + export async function waitForNetwork(page: playwright.Page, callback: () => Promise): Promise { const requests = new Set(); let frameNavigated = false; diff --git a/packages/playwright/bundles/babel/src/babelBundleImpl.ts b/packages/playwright/bundles/babel/src/babelBundleImpl.ts index d58554b44b..a040deddb2 100644 --- a/packages/playwright/bundles/babel/src/babelBundleImpl.ts +++ b/packages/playwright/bundles/babel/src/babelBundleImpl.ts @@ -14,16 +14,18 @@ * limitations under the License. */ -import path from 'path'; -import type { BabelFileResult, NodePath, PluginObj, TransformOptions } from '@babel/core'; -import type { TSExportAssignment, ImportDeclaration } from '@babel/types'; -import type { TemplateBuilder } from '@babel/template'; +import * as path from 'path'; + import * as babel from '@babel/core'; +import traverseFunction from '@babel/traverse'; + +import type { BabelFileResult, NodePath, PluginObj, TransformOptions } from '@babel/core'; +import type { TemplateBuilder } from '@babel/template'; +import type { ImportDeclaration, TSExportAssignment } from '@babel/types'; export { codeFrameColumns } from '@babel/code-frame'; export { declare } from '@babel/helper-plugin-utils'; export { types } from '@babel/core'; -import traverseFunction from '@babel/traverse'; export const traverse = traverseFunction; function babelTransformOptions(isTypeScript: boolean, isModule: boolean, pluginsPrologue: [string, any?][], pluginsEpilogue: [string, any?][]): TransformOptions { diff --git a/packages/playwright/bundles/expect/src/expectBundleImpl.ts b/packages/playwright/bundles/expect/src/expectBundleImpl.ts index 875b48e614..0ffe8acbd8 100644 --- a/packages/playwright/bundles/expect/src/expectBundleImpl.ts +++ b/packages/playwright/bundles/expect/src/expectBundleImpl.ts @@ -14,11 +14,13 @@ * limitations under the License. */ +import * as mu from 'jest-matcher-utils'; + +import * as am from '../third_party/asymmetricMatchers'; import expectLibrary from '../third_party/index'; + export const expect = expectLibrary; export * as mock from 'jest-mock'; -import * as am from '../third_party/asymmetricMatchers'; -import * as mu from 'jest-matcher-utils'; export const asymmetricMatchers = { any: am.any, diff --git a/packages/playwright/bundles/expect/third_party/asymmetricMatchers.ts b/packages/playwright/bundles/expect/third_party/asymmetricMatchers.ts index 4e7a3402c9..a779f8be35 100644 --- a/packages/playwright/bundles/expect/third_party/asymmetricMatchers.ts +++ b/packages/playwright/bundles/expect/third_party/asymmetricMatchers.ts @@ -15,7 +15,9 @@ import { } from '@jest/expect-utils'; import * as matcherUtils from 'jest-matcher-utils'; import { pluralize } from 'jest-util'; + import { getCustomEqualityTesters, getState } from './jestMatchersObject'; + import type { AsymmetricMatcher as AsymmetricMatcherInterface, MatcherContext, diff --git a/packages/playwright/bundles/expect/third_party/extractExpectedAssertionsErrors.ts b/packages/playwright/bundles/expect/third_party/extractExpectedAssertionsErrors.ts index 1be9b4dce9..d50c01c692 100644 --- a/packages/playwright/bundles/expect/third_party/extractExpectedAssertionsErrors.ts +++ b/packages/playwright/bundles/expect/third_party/extractExpectedAssertionsErrors.ts @@ -12,7 +12,9 @@ import { matcherHint, pluralize, } from 'jest-matcher-utils'; + import { getState, setState } from './jestMatchersObject'; + import type { Expect, ExpectedAssertionsErrors } from './types'; const resetAssertionsLocalState = () => { diff --git a/packages/playwright/bundles/expect/third_party/index.ts b/packages/playwright/bundles/expect/third_party/index.ts index 3935ab71e1..7d5e7bce0e 100644 --- a/packages/playwright/bundles/expect/third_party/index.ts +++ b/packages/playwright/bundles/expect/third_party/index.ts @@ -9,6 +9,7 @@ import { equals, iterableEquality, subsetEquality } from '@jest/expect-utils'; import * as matcherUtils from 'jest-matcher-utils'; import { isPromise } from 'jest-util'; + import { any, anything, @@ -38,6 +39,7 @@ import spyMatchers from './spyMatchers'; import toThrowMatchers, { createMatcher as createThrowMatcher, } from './toThrowMatchers'; + import type { Expect, ExpectationResult, @@ -54,8 +56,8 @@ import type { export type { Tester, TesterContext } from '@jest/expect-utils'; export { AsymmetricMatcher } from './asymmetricMatchers'; export type { - AsyncExpectationResult, AsymmetricMatchers, + AsyncExpectationResult, BaseExpect, Expect, ExpectationResult, diff --git a/packages/playwright/bundles/expect/third_party/jestMatchersObject.ts b/packages/playwright/bundles/expect/third_party/jestMatchersObject.ts index 7a9a304b30..30879e11c1 100644 --- a/packages/playwright/bundles/expect/third_party/jestMatchersObject.ts +++ b/packages/playwright/bundles/expect/third_party/jestMatchersObject.ts @@ -6,15 +6,17 @@ * */ -import type { Tester } from '@jest/expect-utils'; import { getType } from 'jest-get-type'; + import { AsymmetricMatcher } from './asymmetricMatchers'; + import type { Expect, MatcherState, MatchersObject, SyncExpectationResult, } from './types'; +import type { Tester } from '@jest/expect-utils'; // Global matchers object holds the list of available matchers and // the state, that can hold matcher specific values that change over time. diff --git a/packages/playwright/bundles/expect/third_party/matchers.ts b/packages/playwright/bundles/expect/third_party/matchers.ts index 5102b50c32..fac0446666 100644 --- a/packages/playwright/bundles/expect/third_party/matchers.ts +++ b/packages/playwright/bundles/expect/third_party/matchers.ts @@ -23,7 +23,7 @@ import { getType, isPrimitive } from 'jest-get-type'; import { DIM_COLOR, EXPECTED_COLOR, - type MatcherHintOptions, + RECEIVED_COLOR, SUGGEST_TO_CONTAIN_EQUAL, ensureExpectedIsNonNegativeInteger, @@ -36,8 +36,9 @@ import { printExpected, printReceived, printWithType, - stringify, + stringify } from 'jest-matcher-utils'; + import { printCloseTo, printExpectedConstructorName, @@ -48,7 +49,9 @@ import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring, } from './print'; + import type { MatchersObject } from './types'; +import type { MatcherHintOptions } from 'jest-matcher-utils'; // Omit colon and one or more spaces, so can call getLabelPrinter. const EXPECTED_LABEL = 'Expected'; diff --git a/packages/playwright/bundles/expect/third_party/spyMatchers.ts b/packages/playwright/bundles/expect/third_party/spyMatchers.ts index ac74fd8d91..038351bc06 100644 --- a/packages/playwright/bundles/expect/third_party/spyMatchers.ts +++ b/packages/playwright/bundles/expect/third_party/spyMatchers.ts @@ -10,7 +10,7 @@ import { getType, isPrimitive } from 'jest-get-type'; import { DIM_COLOR, EXPECTED_COLOR, - type MatcherHintOptions, + RECEIVED_COLOR, diff, ensureExpectedIsNonNegativeInteger, @@ -20,14 +20,17 @@ import { printExpected, printReceived, printWithType, - stringify, + stringify } from 'jest-matcher-utils'; + import { getCustomEqualityTesters } from './jestMatchersObject'; + import type { MatcherFunction, MatchersObject, SyncExpectationResult, } from './types'; +import type { MatcherHintOptions } from 'jest-matcher-utils'; /* eslint-disable eqeqeq */ diff --git a/packages/playwright/bundles/expect/third_party/toThrowMatchers.ts b/packages/playwright/bundles/expect/third_party/toThrowMatchers.ts index 5a2bb9dcad..bcb8697379 100644 --- a/packages/playwright/bundles/expect/third_party/toThrowMatchers.ts +++ b/packages/playwright/bundles/expect/third_party/toThrowMatchers.ts @@ -9,16 +9,17 @@ import { isError } from '@jest/expect-utils'; import { EXPECTED_COLOR, - type MatcherHintOptions, + RECEIVED_COLOR, matcherErrorMessage, matcherHint, printDiffOrStringify, printExpected, printReceived, - printWithType, + printWithType } from 'jest-matcher-utils'; import { formatStackTrace, separateMessageFromStack } from 'jest-message-util'; + import { printExpectedConstructorName, printExpectedConstructorNameNot, @@ -27,12 +28,14 @@ import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring, } from './print'; + import type { ExpectationResult, MatcherFunction, MatchersObject, SyncExpectationResult, } from './types'; +import type { MatcherHintOptions } from 'jest-matcher-utils'; /* eslint-disable eqeqeq */ diff --git a/packages/playwright/bundles/expect/third_party/types.ts b/packages/playwright/bundles/expect/third_party/types.ts index abaa3a3b69..65660ff38b 100644 --- a/packages/playwright/bundles/expect/third_party/types.ts +++ b/packages/playwright/bundles/expect/third_party/types.ts @@ -6,9 +6,9 @@ * */ +import type { INTERNAL_MATCHER_FLAG } from './jestMatchersObject'; import type { EqualsFunction, Tester } from '@jest/expect-utils'; import type * as jestMatcherUtils from 'jest-matcher-utils'; -import type { INTERNAL_MATCHER_FLAG } from './jestMatchersObject'; export type SyncExpectationResult = { pass: boolean; diff --git a/packages/playwright/bundles/utils/src/utilsBundleImpl.ts b/packages/playwright/bundles/utils/src/utilsBundleImpl.ts index 6cd35e2885..6928295763 100644 --- a/packages/playwright/bundles/utils/src/utilsBundleImpl.ts +++ b/packages/playwright/bundles/utils/src/utilsBundleImpl.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +/* eslint-disable import/order */ + import json5Library from 'json5'; export const json5 = json5Library; diff --git a/packages/playwright/src/common/config.ts b/packages/playwright/src/common/config.ts index b55c3d6527..b0bc394873 100644 --- a/packages/playwright/src/common/config.ts +++ b/packages/playwright/src/common/config.ts @@ -14,15 +14,17 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import os from 'os'; -import type { Config, Fixtures, Project, ReporterDescription } from '../../types/test'; -import type { Location } from '../../types/testReporter'; -import type { TestRunnerPluginRegistration } from '../plugins'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + import { getPackageJsonPath, mergeObjects } from '../util'; + +import type { Config, Fixtures, Project, ReporterDescription } from '../../types/test'; +import type { TestRunnerPluginRegistration } from '../plugins'; import type { Matcher } from '../util'; import type { ConfigCLIOverrides } from './ipc'; +import type { Location } from '../../types/testReporter'; import type { FullConfig, FullProject } from '../../types/testReporter'; export type ConfigLocation = { diff --git a/packages/playwright/src/common/configLoader.ts b/packages/playwright/src/common/configLoader.ts index b9f24b929a..da02b83c75 100644 --- a/packages/playwright/src/common/configLoader.ts +++ b/packages/playwright/src/common/configLoader.ts @@ -16,17 +16,20 @@ import * as fs from 'fs'; import * as path from 'path'; + import { gracefullyProcessExitDoNotHang, isRegExp } from 'playwright-core/lib/utils'; -import type { ConfigCLIOverrides, SerializedConfig } from './ipc'; + import { requireOrImport, setSingleTSConfig, setTransformConfig } from '../transform/transform'; -import type { Config, Project } from '../../types/test'; import { errorWithFile, fileIsModule } from '../util'; -import type { ConfigLocation } from './config'; import { FullConfigInternal } from './config'; -import { addToCompilationCache } from '../transform/compilationCache'; import { configureESMLoader, configureESMLoaderTransformConfig, registerESMLoader } from './esmLoaderHost'; +import { addToCompilationCache } from '../transform/compilationCache'; import { execArgvWithExperimentalLoaderOptions, execArgvWithoutExperimentalLoaderOptions } from '../transform/esmUtils'; +import type { ConfigLocation } from './config'; +import type { ConfigCLIOverrides, SerializedConfig } from './ipc'; +import type { Config, Project } from '../../types/test'; + const kDefineConfigWasUsed = Symbol('defineConfigWasUsed'); export const defineConfig = (...configs: any[]) => { let result = configs[0]; diff --git a/packages/playwright/src/common/esmLoaderHost.ts b/packages/playwright/src/common/esmLoaderHost.ts index 9daa71107c..fbe5704044 100644 --- a/packages/playwright/src/common/esmLoaderHost.ts +++ b/packages/playwright/src/common/esmLoaderHost.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import url from 'url'; +import * as url from 'url'; + import { addToCompilationCache, serializeCompilationCache } from '../transform/compilationCache'; -import { singleTSConfig, transformConfig } from '../transform/transform'; import { PortTransport } from '../transform/portTransport'; +import { singleTSConfig, transformConfig } from '../transform/transform'; let loaderChannel: PortTransport | undefined; // Node.js < 20 diff --git a/packages/playwright/src/common/fixtures.ts b/packages/playwright/src/common/fixtures.ts index 6b50947ab5..ad0a16bd22 100644 --- a/packages/playwright/src/common/fixtures.ts +++ b/packages/playwright/src/common/fixtures.ts @@ -14,11 +14,13 @@ * limitations under the License. */ -import { filterStackFile, formatLocation } from '../util'; import * as crypto from 'crypto'; + +import { filterStackFile, formatLocation } from '../util'; + +import type { FixturesWithLocation } from './config'; import type { Fixtures } from '../../types/test'; import type { Location } from '../../types/testReporter'; -import type { FixturesWithLocation } from './config'; export type FixtureScope = 'test' | 'worker'; type FixtureAuto = boolean | 'all-hooks-included'; diff --git a/packages/playwright/src/common/globals.ts b/packages/playwright/src/common/globals.ts index 746e1ec847..41f912acb8 100644 --- a/packages/playwright/src/common/globals.ts +++ b/packages/playwright/src/common/globals.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import type { TestInfoImpl } from '../worker/testInfo'; import type { Suite } from './test'; +import type { TestInfoImpl } from '../worker/testInfo'; let currentTestInfoValue: TestInfoImpl | null = null; export function setCurrentTestInfo(testInfo: TestInfoImpl | null) { diff --git a/packages/playwright/src/common/ipc.ts b/packages/playwright/src/common/ipc.ts index 2e085f5b78..d1cebd5cb4 100644 --- a/packages/playwright/src/common/ipc.ts +++ b/packages/playwright/src/common/ipc.ts @@ -15,11 +15,13 @@ */ import util from 'util'; + import { serializeCompilationCache } from '../transform/compilationCache'; -import type { SerializedCompilationCache } from '../transform/compilationCache'; + import type { ConfigLocation, FullConfigInternal } from './config'; import type { ReporterDescription, TestInfoError, TestStatus } from '../../types/test'; import type { MatcherResultProperty } from '../matchers/matcherHint'; +import type { SerializedCompilationCache } from '../transform/compilationCache'; export type ConfigCLIOverrides = { debug?: boolean; diff --git a/packages/playwright/src/common/poolBuilder.ts b/packages/playwright/src/common/poolBuilder.ts index cc1bc095c9..f975efe92f 100644 --- a/packages/playwright/src/common/poolBuilder.ts +++ b/packages/playwright/src/common/poolBuilder.ts @@ -15,11 +15,12 @@ */ import { FixturePool } from './fixtures'; +import { formatLocation } from '../util'; + +import type { FullProjectInternal } from './config'; import type { LoadError } from './fixtures'; import type { Suite, TestCase } from './test'; import type { TestTypeImpl } from './testType'; -import type { FullProjectInternal } from './config'; -import { formatLocation } from '../util'; import type { TestError } from '../../types/testReporter'; export class PoolBuilder { diff --git a/packages/playwright/src/common/process.ts b/packages/playwright/src/common/process.ts index a372139698..54dd2fe991 100644 --- a/packages/playwright/src/common/process.ts +++ b/packages/playwright/src/common/process.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import type { EnvProducedPayload, ProcessInitParams, TestInfoErrorImpl } from './ipc'; import { startProfiling, stopProfiling } from 'playwright-core/lib/utils'; + import { serializeError } from '../util'; import { registerESMLoader } from './esmLoaderHost'; import { execArgvWithoutExperimentalLoaderOptions } from '../transform/esmUtils'; +import type { EnvProducedPayload, ProcessInitParams, TestInfoErrorImpl } from './ipc'; + export type ProtocolRequest = { id: number; method: string; diff --git a/packages/playwright/src/common/suiteUtils.ts b/packages/playwright/src/common/suiteUtils.ts index 81dc9d5465..d229e62732 100644 --- a/packages/playwright/src/common/suiteUtils.ts +++ b/packages/playwright/src/common/suiteUtils.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; + import { calculateSha1, toPosixPath } from 'playwright-core/lib/utils'; -import type { Suite, TestCase } from './test'; -import type { FullProjectInternal } from './config'; -import type { Matcher, TestFileFilter } from '../util'; + import { createFileMatcher } from '../util'; +import type { FullProjectInternal } from './config'; +import type { Suite, TestCase } from './test'; +import type { Matcher, TestFileFilter } from '../util'; + export function filterSuite(suite: Suite, suiteFilter: (suites: Suite) => boolean, testFilter: (test: TestCase) => boolean) { for (const child of suite.suites) { diff --git a/packages/playwright/src/common/test.ts b/packages/playwright/src/common/test.ts index 3e7fb30a1a..7b54f0c291 100644 --- a/packages/playwright/src/common/test.ts +++ b/packages/playwright/src/common/test.ts @@ -14,14 +14,16 @@ * limitations under the License. */ -import type { FixturePool } from './fixtures'; -import type * as reporterTypes from '../../types/testReporter'; -import type { TestTypeImpl } from './testType'; import { rootTestType } from './testType'; -import type { Annotation, FixturesWithLocation, FullProjectInternal } from './config'; -import type { Location, FullProject } from '../../types/testReporter'; import { computeTestCaseOutcome } from '../isomorphic/teleReceiver'; +import type { Annotation, FixturesWithLocation, FullProjectInternal } from './config'; +import type { FixturePool } from './fixtures'; +import type { TestTypeImpl } from './testType'; +import type * as reporterTypes from '../../types/testReporter'; +import type { FullProject, Location } from '../../types/testReporter'; + + class Base { title: string; _only = false; diff --git a/packages/playwright/src/common/testLoader.ts b/packages/playwright/src/common/testLoader.ts index 6a8940ee19..31a7b63fee 100644 --- a/packages/playwright/src/common/testLoader.ts +++ b/packages/playwright/src/common/testLoader.ts @@ -14,15 +14,17 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; import util from 'util'; -import type { TestError } from '../../types/testReporter'; + +import * as esmLoaderHost from './esmLoaderHost'; import { isWorkerProcess, setCurrentlyLoadingFileSuite } from './globals'; import { Suite } from './test'; +import { startCollectingFileDeps, stopCollectingFileDeps } from '../transform/compilationCache'; import { requireOrImport } from '../transform/transform'; import { filterStackTrace } from '../util'; -import { startCollectingFileDeps, stopCollectingFileDeps } from '../transform/compilationCache'; -import * as esmLoaderHost from './esmLoaderHost'; + +import type { TestError } from '../../types/testReporter'; export const defaultTimeout = 30000; diff --git a/packages/playwright/src/common/testType.ts b/packages/playwright/src/common/testType.ts index 71761b33e1..7395e38217 100644 --- a/packages/playwright/src/common/testType.ts +++ b/packages/playwright/src/common/testType.ts @@ -14,15 +14,18 @@ * limitations under the License. */ -import { expect } from '../matchers/expect'; -import { currentlyLoadingFileSuite, currentTestInfo, setCurrentlyLoadingFileSuite } from './globals'; -import { TestCase, Suite } from './test'; -import { wrapFunctionWithLocation } from '../transform/transform'; -import type { FixturesWithLocation } from './config'; -import type { Fixtures, TestType, TestDetails, TestStepInfo } from '../../types/test'; -import type { Location } from '../../types/testReporter'; -import { getPackageManagerExecCommand, monotonicTime, raceAgainstDeadline, zones } from 'playwright-core/lib/utils'; import { errors } from 'playwright-core'; +import { getPackageManagerExecCommand, monotonicTime, raceAgainstDeadline, zones } from 'playwright-core/lib/utils'; + +import { currentTestInfo, currentlyLoadingFileSuite, setCurrentlyLoadingFileSuite } from './globals'; +import { Suite, TestCase } from './test'; +import { expect } from '../matchers/expect'; +import { wrapFunctionWithLocation } from '../transform/transform'; + +import type { FixturesWithLocation } from './config'; +import type { Fixtures, TestDetails, TestStepInfo, TestType } from '../../types/test'; +import type { Location } from '../../types/testReporter'; + const testTypeSymbol = Symbol('testType'); diff --git a/packages/playwright/src/fsWatcher.ts b/packages/playwright/src/fsWatcher.ts index 53e6849b1a..4078e4f994 100644 --- a/packages/playwright/src/fsWatcher.ts +++ b/packages/playwright/src/fsWatcher.ts @@ -15,6 +15,7 @@ */ import { chokidar } from './utilsBundle'; + import type { FSWatcher } from 'chokidar'; export type FSEvent = { event: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', file: string }; diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index 652e8ecab1..b2ba203386 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -16,16 +16,19 @@ import * as fs from 'fs'; import * as path from 'path'; -import type { APIRequestContext, BrowserContext, Browser, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core'; + import * as playwrightLibrary from 'playwright-core'; -import { createGuid, debugMode, addInternalStackPrefix, isString, asLocator, jsonStringifyForceASCII, zones } from 'playwright-core/lib/utils'; -import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, VideoMode } from '../types/test'; -import type { TestInfoImpl, TestStepInternal } from './worker/testInfo'; +import { addInternalStackPrefix, asLocator, createGuid, debugMode, isString, jsonStringifyForceASCII, zones } from 'playwright-core/lib/utils'; + +import { currentTestInfo } from './common/globals'; import { rootTestType } from './common/testType'; + +import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, VideoMode } from '../types/test'; import type { ContextReuseMode } from './common/config'; +import type { TestInfoImpl, TestStepInternal } from './worker/testInfo'; import type { ApiCallData, ClientInstrumentation, ClientInstrumentationListener } from '../../playwright-core/src/client/clientInstrumentation'; import type { Playwright as PlaywrightImpl } from '../../playwright-core/src/client/playwright'; -import { currentTestInfo } from './common/globals'; +import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core'; export { expect } from './matchers/expect'; export const _baseTest: TestType<{}, {}> = rootTestType.test; diff --git a/packages/playwright/src/internalsForTest.ts b/packages/playwright/src/internalsForTest.ts index c0d2cbd95f..f80d63bc7a 100644 --- a/packages/playwright/src/internalsForTest.ts +++ b/packages/playwright/src/internalsForTest.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; + import { fileDependenciesForTest } from './transform/compilationCache'; export function fileDependencies() { diff --git a/packages/playwright/src/isomorphic/teleReceiver.ts b/packages/playwright/src/isomorphic/teleReceiver.ts index 1eb83df623..91b1a1a434 100644 --- a/packages/playwright/src/isomorphic/teleReceiver.ts +++ b/packages/playwright/src/isomorphic/teleReceiver.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type { Annotation } from '../common/config'; import type { Metadata } from '../../types/test'; import type * as reporterTypes from '../../types/testReporter'; +import type { Annotation } from '../common/config'; import type { ReporterV2 } from '../reporters/reporterV2'; export type StringIntern = (s: string) => string; diff --git a/packages/playwright/src/isomorphic/teleSuiteUpdater.ts b/packages/playwright/src/isomorphic/teleSuiteUpdater.ts index 6f86c50147..7c4c14fae7 100644 --- a/packages/playwright/src/isomorphic/teleSuiteUpdater.ts +++ b/packages/playwright/src/isomorphic/teleSuiteUpdater.ts @@ -16,8 +16,9 @@ import { TeleReporterReceiver, TeleSuite } from './teleReceiver'; import { statusEx } from './testTree'; -import type { ReporterV2 } from '../reporters/reporterV2'; + import type * as reporterTypes from '../../types/testReporter'; +import type { ReporterV2 } from '../reporters/reporterV2'; export type TeleSuiteUpdaterProgress = { total: number; diff --git a/packages/playwright/src/isomorphic/testServerConnection.ts b/packages/playwright/src/isomorphic/testServerConnection.ts index 22bdce30ff..f4caf62fae 100644 --- a/packages/playwright/src/isomorphic/testServerConnection.ts +++ b/packages/playwright/src/isomorphic/testServerConnection.ts @@ -14,9 +14,10 @@ * limitations under the License. */ -import type { TestServerInterface, TestServerInterfaceEvents } from '@testIsomorphic/testServerInterface'; import * as events from './events'; +import type { TestServerInterface, TestServerInterfaceEvents } from '@testIsomorphic/testServerInterface'; + // -- Reuse boundary -- Everything below this line is reused in the vscode extension. export interface TestServerTransport { diff --git a/packages/playwright/src/isomorphic/testServerInterface.ts b/packages/playwright/src/isomorphic/testServerInterface.ts index e4faa682ac..470f44ee41 100644 --- a/packages/playwright/src/isomorphic/testServerInterface.ts +++ b/packages/playwright/src/isomorphic/testServerInterface.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type * as reporterTypes from '../../types/testReporter'; import type { Event } from './events'; import type { JsonEvent } from './teleReceiver'; +import type * as reporterTypes from '../../types/testReporter'; // -- Reuse boundary -- Everything below this line is reused in the vscode extension. diff --git a/packages/playwright/src/loader/loaderMain.ts b/packages/playwright/src/loader/loaderMain.ts index 97befeea9d..50bd380c7c 100644 --- a/packages/playwright/src/loader/loaderMain.ts +++ b/packages/playwright/src/loader/loaderMain.ts @@ -14,15 +14,16 @@ * limitations under the License. */ -import type { SerializedConfig } from '../common/ipc'; import { deserializeConfig } from '../common/configLoader'; -import { ProcessRunner } from '../common/process'; -import type { FullConfigInternal } from '../common/config'; -import { loadTestFile } from '../common/testLoader'; -import type { TestError } from '../../types/testReporter'; -import { serializeCompilationCache } from '../transform/compilationCache'; -import { PoolBuilder } from '../common/poolBuilder'; import { incorporateCompilationCache } from '../common/esmLoaderHost'; +import { PoolBuilder } from '../common/poolBuilder'; +import { ProcessRunner } from '../common/process'; +import { loadTestFile } from '../common/testLoader'; +import { serializeCompilationCache } from '../transform/compilationCache'; + +import type { TestError } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; +import type { SerializedConfig } from '../common/ipc'; export class LoaderMain extends ProcessRunner { private _serializedConfig: SerializedConfig; diff --git a/packages/playwright/src/matchers/expect.ts b/packages/playwright/src/matchers/expect.ts index 68e52c46c8..707e5457e1 100644 --- a/packages/playwright/src/matchers/expect.ts +++ b/packages/playwright/src/matchers/expect.ts @@ -19,6 +19,9 @@ import { createGuid, isString, pollAgainstDeadline } from 'playwright-core/lib/utils'; +import { zones } from 'playwright-core/lib/utils'; + +import { ExpectError, isJestError } from './matcherHint'; import { toBeAttached, toBeChecked, @@ -33,12 +36,12 @@ import { toBeVisible, toContainText, toHaveAccessibleDescription, - toHaveAccessibleName, toHaveAccessibleErrorMessage, + toHaveAccessibleName, toHaveAttribute, + toHaveCSS, toHaveClass, toHaveCount, - toHaveCSS, toHaveId, toHaveJSProperty, toHaveRole, @@ -49,22 +52,22 @@ import { toHaveValues, toPass } from './matchers'; -import type { ExpectMatcherStateInternal } from './matchers'; -import { toMatchSnapshot, toHaveScreenshot, toHaveScreenshotStepTitle } from './toMatchSnapshot'; -import type { Expect } from '../../types/test'; -import { currentTestInfo } from '../common/globals'; -import { filteredStackTrace, trimLongString } from '../util'; +import { toMatchAriaSnapshot } from './toMatchAriaSnapshot'; +import { toHaveScreenshot, toHaveScreenshotStepTitle, toMatchSnapshot } from './toMatchSnapshot'; import { - expect as expectLibrary, INVERTED_COLOR, RECEIVED_COLOR, + expect as expectLibrary, printReceived, } from '../common/expectBundle'; -import { zones } from 'playwright-core/lib/utils'; +import { currentTestInfo } from '../common/globals'; +import { filteredStackTrace, trimLongString } from '../util'; import { TestInfoImpl } from '../worker/testInfo'; + +import type { ExpectMatcherStateInternal } from './matchers'; +import type { Expect } from '../../types/test'; import type { TestStepInfoImpl } from '../worker/testInfo'; -import { ExpectError, isJestError } from './matcherHint'; -import { toMatchAriaSnapshot } from './toMatchAriaSnapshot'; + // #region // Mirrored from https://github.com/facebook/jest/blob/f13abff8df9a0e1148baf3584bcde6d1b479edc7/packages/expect/src/print.ts diff --git a/packages/playwright/src/matchers/matcherHint.ts b/packages/playwright/src/matchers/matcherHint.ts index dc4264d56b..1dfa1ceb4a 100644 --- a/packages/playwright/src/matchers/matcherHint.ts +++ b/packages/playwright/src/matchers/matcherHint.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import { colors } from 'playwright-core/lib/utilsBundle'; -import type { ExpectMatcherState } from '../../types/test'; -import type { Locator } from 'playwright-core'; -import type { StackFrame } from '@protocol/channels'; import { stringifyStackFrames } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +import type { ExpectMatcherState } from '../../types/test'; +import type { StackFrame } from '@protocol/channels'; +import type { Locator } from 'playwright-core'; export const kNoElementsFoundError = ''; diff --git a/packages/playwright/src/matchers/matchers.ts b/packages/playwright/src/matchers/matchers.ts index be960dd424..2890feaac6 100644 --- a/packages/playwright/src/matchers/matchers.ts +++ b/packages/playwright/src/matchers/matchers.ts @@ -14,20 +14,22 @@ * limitations under the License. */ -import type { Locator, Page, APIResponse } from 'playwright-core'; -import type { FrameExpectParams } from 'playwright-core/lib/client/types'; +import { isRegExp, isString, isTextualMimeType, pollAgainstDeadline, serializeExpectedTextValues } from 'playwright-core/lib/utils'; import { colors } from 'playwright-core/lib/utilsBundle'; -import { expectTypes, callLogText } from '../util'; + +import { callLogText, expectTypes } from '../util'; import { toBeTruthy } from './toBeTruthy'; import { toEqual } from './toEqual'; +import { toHaveURL as toHaveURLExternal } from './toHaveURL'; import { toMatchText } from './toMatchText'; -import { isRegExp, isString, isTextualMimeType, pollAgainstDeadline, serializeExpectedTextValues } from 'playwright-core/lib/utils'; +import { takeFirst } from '../common/config'; import { currentTestInfo } from '../common/globals'; import { TestInfoImpl } from '../worker/testInfo'; -import type { TestStepInfoImpl } from '../worker/testInfo'; + import type { ExpectMatcherState } from '../../types/test'; -import { takeFirst } from '../common/config'; -import { toHaveURL as toHaveURLExternal } from './toHaveURL'; +import type { TestStepInfoImpl } from '../worker/testInfo'; +import type { APIResponse, Locator, Page } from 'playwright-core'; +import type { FrameExpectParams } from 'playwright-core/lib/client/types'; export type ExpectMatcherStateInternal = ExpectMatcherState & { _stepInfo?: TestStepInfoImpl }; diff --git a/packages/playwright/src/matchers/toBeTruthy.ts b/packages/playwright/src/matchers/toBeTruthy.ts index 0075dd5a64..0faf5555a9 100644 --- a/packages/playwright/src/matchers/toBeTruthy.ts +++ b/packages/playwright/src/matchers/toBeTruthy.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -import { expectTypes, callLogText } from '../util'; +import { callLogText, expectTypes } from '../util'; import { kNoElementsFoundError, matcherHint } from './matcherHint'; + import type { MatcherResult } from './matcherHint'; import type { ExpectMatcherState } from '../../types/test'; import type { Locator } from 'playwright-core'; diff --git a/packages/playwright/src/matchers/toEqual.ts b/packages/playwright/src/matchers/toEqual.ts index 4296444a7b..ecbcb15239 100644 --- a/packages/playwright/src/matchers/toEqual.ts +++ b/packages/playwright/src/matchers/toEqual.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import { expectTypes, callLogText } from '../util'; +import { isRegExp } from 'playwright-core/lib/utils'; + +import { callLogText, expectTypes } from '../util'; import { matcherHint } from './matcherHint'; + import type { MatcherResult } from './matcherHint'; import type { ExpectMatcherState } from '../../types/test'; import type { Locator } from 'playwright-core'; -import { isRegExp } from 'playwright-core/lib/utils'; // Omit colon and one or more spaces, so can call getLabelPrinter. const EXPECTED_LABEL = 'Expected'; diff --git a/packages/playwright/src/matchers/toHaveURL.ts b/packages/playwright/src/matchers/toHaveURL.ts index df09833f84..c56441fee5 100644 --- a/packages/playwright/src/matchers/toHaveURL.ts +++ b/packages/playwright/src/matchers/toHaveURL.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import type { Page } from 'playwright-core'; -import type { ExpectMatcherState } from '../../types/test'; -import { EXPECTED_COLOR, printReceived } from '../common/expectBundle'; -import { matcherHint, type MatcherResult } from './matcherHint'; import { constructURLBasedOnBaseURL, urlMatches } from 'playwright-core/lib/utils'; import { colors } from 'playwright-core/lib/utilsBundle'; + import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring } from './expect'; +import { matcherHint } from './matcherHint'; +import { EXPECTED_COLOR, printReceived } from '../common/expectBundle'; + +import type { MatcherResult } from './matcherHint'; +import type { ExpectMatcherState } from '../../types/test'; +import type { Page } from 'playwright-core'; export async function toHaveURL( this: ExpectMatcherState, diff --git a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts b/packages/playwright/src/matchers/toMatchAriaSnapshot.ts index 412a4bf275..1ad5777871 100644 --- a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts +++ b/packages/playwright/src/matchers/toMatchAriaSnapshot.ts @@ -15,17 +15,22 @@ */ -import type { LocatorEx } from './matchers'; -import type { ExpectMatcherState } from '../../types/test'; -import { kNoElementsFoundError, matcherHint, type MatcherResult } from './matcherHint'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { escapeTemplateString, isString, sanitizeForFilePath } from 'playwright-core/lib/utils'; + +import { kNoElementsFoundError, matcherHint } from './matcherHint'; import { EXPECTED_COLOR } from '../common/expectBundle'; import { callLogText, sanitizeFilePathBeforeExtension, trimLongString } from '../util'; import { printReceivedStringContainExpectedSubstring } from './expect'; import { currentTestInfo } from '../common/globals'; + +import type { MatcherResult } from './matcherHint'; +import type { LocatorEx } from './matchers'; +import type { ExpectMatcherState } from '../../types/test'; import type { MatcherReceived } from '@injected/ariaSnapshot'; -import { escapeTemplateString, isString, sanitizeForFilePath } from 'playwright-core/lib/utils'; -import fs from 'fs'; -import path from 'path'; + type ToMatchAriaSnapshotExpected = { name?: string; diff --git a/packages/playwright/src/matchers/toMatchSnapshot.ts b/packages/playwright/src/matchers/toMatchSnapshot.ts index 09ca66ab3c..220c948887 100644 --- a/packages/playwright/src/matchers/toMatchSnapshot.ts +++ b/packages/playwright/src/matchers/toMatchSnapshot.ts @@ -14,25 +14,29 @@ * limitations under the License. */ -import type { Locator, Page } from 'playwright-core'; -import type { ExpectScreenshotOptions, Page as PageEx } from 'playwright-core/lib/client/page'; -import { currentTestInfo } from '../common/globals'; -import type { ImageComparatorOptions, Comparator } from 'playwright-core/lib/utils'; +import * as fs from 'fs'; +import * as path from 'path'; + import { compareBuffersOrStrings, getComparator, isString, sanitizeForFilePath } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; +import { mime } from 'playwright-core/lib/utilsBundle'; + import { - addSuffixToFilePath, - trimLongString, callLogText, + addSuffixToFilePath, callLogText, expectTypes, sanitizeFilePathBeforeExtension, + trimLongString, windowsFilesystemFriendlyLength } from '../util'; -import { colors } from 'playwright-core/lib/utilsBundle'; -import fs from 'fs'; -import path from 'path'; -import { mime } from 'playwright-core/lib/utilsBundle'; -import type { TestInfoImpl, TestStepInfoImpl } from '../worker/testInfo'; +import { matcherHint } from './matcherHint'; +import { currentTestInfo } from '../common/globals'; + +import type { MatcherResult } from './matcherHint'; import type { ExpectMatcherStateInternal } from './matchers'; -import { matcherHint, type MatcherResult } from './matcherHint'; import type { FullProjectInternal } from '../common/config'; +import type { TestInfoImpl, TestStepInfoImpl } from '../worker/testInfo'; +import type { Locator, Page } from 'playwright-core'; +import type { ExpectScreenshotOptions, Page as PageEx } from 'playwright-core/lib/client/page'; +import type { Comparator, ImageComparatorOptions } from 'playwright-core/lib/utils'; type NameOrSegments = string | string[]; const snapshotNamesSymbol = Symbol('snapshotNames'); diff --git a/packages/playwright/src/matchers/toMatchText.ts b/packages/playwright/src/matchers/toMatchText.ts index 2f8bc34b21..961937eb5b 100644 --- a/packages/playwright/src/matchers/toMatchText.ts +++ b/packages/playwright/src/matchers/toMatchText.ts @@ -15,17 +15,19 @@ */ -import { expectTypes, callLogText } from '../util'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +import { callLogText, expectTypes } from '../util'; import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring } from './expect'; -import { EXPECTED_COLOR } from '../common/expectBundle'; -import type { ExpectMatcherState } from '../../types/test'; import { kNoElementsFoundError, matcherHint } from './matcherHint'; +import { EXPECTED_COLOR } from '../common/expectBundle'; + import type { MatcherResult } from './matcherHint'; +import type { ExpectMatcherState } from '../../types/test'; import type { Locator } from 'playwright-core'; -import { colors } from 'playwright-core/lib/utilsBundle'; export async function toMatchText( this: ExpectMatcherState, diff --git a/packages/playwright/src/plugins/gitCommitInfoPlugin.ts b/packages/playwright/src/plugins/gitCommitInfoPlugin.ts index e96c122cc6..29010183c7 100644 --- a/packages/playwright/src/plugins/gitCommitInfoPlugin.ts +++ b/packages/playwright/src/plugins/gitCommitInfoPlugin.ts @@ -15,6 +15,7 @@ */ import { createGuid, spawnAsync } from 'playwright-core/lib/utils'; + import type { TestRunnerPlugin } from './'; import type { FullConfig } from '../../types/testReporter'; import type { FullConfigInternal } from '../common/config'; diff --git a/packages/playwright/src/plugins/webServerPlugin.ts b/packages/playwright/src/plugins/webServerPlugin.ts index 002ad235bd..5f30a58e95 100644 --- a/packages/playwright/src/plugins/webServerPlugin.ts +++ b/packages/playwright/src/plugins/webServerPlugin.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import path from 'path'; -import net from 'net'; +import * as net from 'net'; +import * as path from 'path'; +import { isURLAvailable, launchProcess, monotonicTime, raceAgainstDeadline } from 'playwright-core/lib/utils'; import { colors, debug } from 'playwright-core/lib/utilsBundle'; -import { raceAgainstDeadline, launchProcess, monotonicTime, isURLAvailable } from 'playwright-core/lib/utils'; -import type { FullConfig } from '../../types/testReporter'; import type { TestRunnerPlugin } from '.'; +import type { FullConfig } from '../../types/testReporter'; import type { FullConfigInternal } from '../common/config'; import type { ReporterV2 } from '../reporters/reporterV2'; diff --git a/packages/playwright/src/program.ts b/packages/playwright/src/program.ts index c6278dc0ad..5100e06f37 100644 --- a/packages/playwright/src/program.ts +++ b/packages/playwright/src/program.ts @@ -16,25 +16,28 @@ /* eslint-disable no-console */ -import type { Command } from 'playwright-core/lib/utilsBundle'; -import fs from 'fs'; -import path from 'path'; -import { Runner } from './runner/runner'; -import { stopProfiling, startProfiling, gracefullyProcessExitDoNotHang } from 'playwright-core/lib/utils'; -import { serializeError } from './util'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { program } from 'playwright-core/lib/cli/program'; +import { gracefullyProcessExitDoNotHang, startProfiling, stopProfiling } from 'playwright-core/lib/utils'; + +import { builtInReporters, defaultReporter, defaultTimeout } from './common/config'; +import { loadConfigFromFileRestartIfNeeded, loadEmptyConfigForMergeReports, resolveConfigLocation } from './common/configLoader'; +export { program } from 'playwright-core/lib/cli/program'; +import { prepareErrorStack } from './reporters/base'; import { showHTMLReport } from './reporters/html'; import { createMergedReport } from './reporters/merge'; -import { loadConfigFromFileRestartIfNeeded, loadEmptyConfigForMergeReports, resolveConfigLocation } from './common/configLoader'; -import type { ConfigCLIOverrides } from './common/ipc'; -import type { TestError } from '../types/testReporter'; -import type { TraceMode } from '../types/test'; -import { builtInReporters, defaultReporter, defaultTimeout } from './common/config'; -import { program } from 'playwright-core/lib/cli/program'; -export { program } from 'playwright-core/lib/cli/program'; -import type { ReporterDescription } from '../types/test'; -import { prepareErrorStack } from './reporters/base'; +import { Runner } from './runner/runner'; import * as testServer from './runner/testServer'; import { runWatchModeLoop } from './runner/watchMode'; +import { serializeError } from './util'; + +import type { TestError } from '../types/testReporter'; +import type { ConfigCLIOverrides } from './common/ipc'; +import type { TraceMode } from '../types/test'; +import type { ReporterDescription } from '../types/test'; +import type { Command } from 'playwright-core/lib/utilsBundle'; function addTestCommand(program: Command) { const command = program.command('test [test-filter...]'); diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index ec11413391..96f47fb192 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import { colors as realColors, ms as milliseconds, parseStackTraceLine } from 'playwright-core/lib/utilsBundle'; -import path from 'path'; -import type { FullConfig, TestCase, Suite, TestResult, TestError, FullResult, TestStep, Location } from '../../types/testReporter'; +import * as path from 'path'; + import { getPackageManagerExecCommand } from 'playwright-core/lib/utils'; -import { getEastAsianWidth } from '../utilsBundle'; -import type { ReporterV2 } from './reporterV2'; +import { colors as realColors, ms as milliseconds, parseStackTraceLine } from 'playwright-core/lib/utilsBundle'; + import { resolveReporterOutputPath } from '../util'; +import { getEastAsianWidth } from '../utilsBundle'; + +import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, Location, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; export type TestResultOutput = { chunk: string | Buffer, type: 'stdout' | 'stderr' }; export const kOutputSymbol = Symbol('output'); diff --git a/packages/playwright/src/reporters/blob.ts b/packages/playwright/src/reporters/blob.ts index 837fe55be0..4f913ba452 100644 --- a/packages/playwright/src/reporters/blob.ts +++ b/packages/playwright/src/reporters/blob.ts @@ -14,17 +14,20 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; +import { Readable } from 'stream'; + import { ManualPromise, calculateSha1, createGuid, getUserAgent, removeFolders, sanitizeForFilePath } from 'playwright-core/lib/utils'; import { mime } from 'playwright-core/lib/utilsBundle'; -import { Readable } from 'stream'; -import type { EventEmitter } from 'events'; +import { yazl } from 'playwright-core/lib/zipBundle'; + +import { resolveOutputFile } from './base'; +import { TeleReporterEmitter } from './teleEmitter'; + import type { FullConfig, FullResult, TestResult } from '../../types/testReporter'; import type { JsonAttachment, JsonEvent } from '../isomorphic/teleReceiver'; -import { TeleReporterEmitter } from './teleEmitter'; -import { yazl } from 'playwright-core/lib/zipBundle'; -import { resolveOutputFile } from './base'; +import type { EventEmitter } from 'events'; type BlobReporterOptions = { configDir: string; diff --git a/packages/playwright/src/reporters/dot.ts b/packages/playwright/src/reporters/dot.ts index 7f635f8214..b3e7b114c0 100644 --- a/packages/playwright/src/reporters/dot.ts +++ b/packages/playwright/src/reporters/dot.ts @@ -15,7 +15,8 @@ */ import { TerminalReporter } from './base'; -import type { FullResult, TestCase, TestResult, Suite, TestError } from '../../types/testReporter'; + +import type { FullResult, Suite, TestCase, TestError, TestResult } from '../../types/testReporter'; class DotReporter extends TerminalReporter { private _counter = 0; diff --git a/packages/playwright/src/reporters/github.ts b/packages/playwright/src/reporters/github.ts index e7ec7198fb..e3677dd3ff 100644 --- a/packages/playwright/src/reporters/github.ts +++ b/packages/playwright/src/reporters/github.ts @@ -14,10 +14,13 @@ * limitations under the License. */ +import * as path from 'path'; + import { ms as milliseconds } from 'playwright-core/lib/utilsBundle'; -import path from 'path'; + import { TerminalReporter, formatResultFailure, formatRetry, noColors, stripAnsiEscapes } from './base'; -import type { TestCase, FullResult, TestError } from '../../types/testReporter'; + +import type { FullResult, TestCase, TestError } from '../../types/testReporter'; type GitHubLogType = 'debug' | 'notice' | 'warning' | 'error'; diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.ts index e258f22798..557ad580b7 100644 --- a/packages/playwright/src/reporters/html.ts +++ b/packages/playwright/src/reporters/html.ts @@ -14,23 +14,26 @@ * limitations under the License. */ -import { colors, open } from 'playwright-core/lib/utilsBundle'; -import { MultiMap, getPackageManagerExecCommand } from 'playwright-core/lib/utils'; -import fs from 'fs'; -import path from 'path'; -import type { TransformCallback } from 'stream'; +import * as fs from 'fs'; +import * as path from 'path'; import { Transform } from 'stream'; -import { codeFrameColumns } from '../transform/babelBundle'; -import type * as api from '../../types/testReporter'; + +import { MultiMap, getPackageManagerExecCommand } from 'playwright-core/lib/utils'; import { HttpServer, assert, calculateSha1, copyFileAndMakeWritable, gracefullyProcessExitDoNotHang, removeFolders, sanitizeForFilePath, toPosixPath } from 'playwright-core/lib/utils'; -import { formatError, formatResultFailure, internalScreen, stripAnsiEscapes } from './base'; -import { resolveReporterOutputPath } from '../util'; -import type { Metadata } from '../../types/test'; -import type { ZipFile } from 'playwright-core/lib/zipBundle'; -import { yazl } from 'playwright-core/lib/zipBundle'; +import { colors, open } from 'playwright-core/lib/utilsBundle'; import { mime } from 'playwright-core/lib/utilsBundle'; -import type { HTMLReport, Stats, TestAttachment, TestCase, TestCaseSummary, TestFile, TestFileSummary, TestResult, TestStep } from '@html-reporter/types'; +import { yazl } from 'playwright-core/lib/zipBundle'; + +import { formatError, formatResultFailure, internalScreen, stripAnsiEscapes } from './base'; +import { codeFrameColumns } from '../transform/babelBundle'; +import { resolveReporterOutputPath } from '../util'; + import type { ReporterV2 } from './reporterV2'; +import type { Metadata } from '../../types/test'; +import type * as api from '../../types/testReporter'; +import type { HTMLReport, Stats, TestAttachment, TestCase, TestCaseSummary, TestFile, TestFileSummary, TestResult, TestStep } from '@html-reporter/types'; +import type { ZipFile } from 'playwright-core/lib/zipBundle'; +import type { TransformCallback } from 'stream'; type TestEntry = { testCase: TestCase; diff --git a/packages/playwright/src/reporters/internalReporter.ts b/packages/playwright/src/reporters/internalReporter.ts index da5e667ffd..5655bd4fb2 100644 --- a/packages/playwright/src/reporters/internalReporter.ts +++ b/packages/playwright/src/reporters/internalReporter.ts @@ -14,14 +14,18 @@ * limitations under the License. */ -import fs from 'fs'; -import { codeFrameColumns } from '../transform/babelBundle'; -import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep } from '../../types/testReporter'; -import { Suite } from '../common/test'; -import { internalScreen, prepareErrorStack, relativeFilePath } from './base'; -import type { ReporterV2 } from './reporterV2'; +import * as fs from 'fs'; + import { monotonicTime } from 'playwright-core/lib/utils'; + +import { internalScreen, prepareErrorStack, relativeFilePath } from './base'; import { Multiplexer } from './multiplexer'; +import { Suite } from '../common/test'; +import { codeFrameColumns } from '../transform/babelBundle'; + +import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; + export class InternalReporter implements ReporterV2 { private _reporter: ReporterV2; diff --git a/packages/playwright/src/reporters/json.ts b/packages/playwright/src/reporters/json.ts index 3c827aea78..377f4f3b88 100644 --- a/packages/playwright/src/reporters/json.ts +++ b/packages/playwright/src/reporters/json.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { FullConfig, TestCase, Suite, TestResult, TestError, TestStep, FullResult, Location, JSONReport, JSONReportSuite, JSONReportSpec, JSONReportTest, JSONReportTestResult, JSONReportTestStep, JSONReportError } from '../../types/testReporter'; -import { formatError, nonTerminalScreen, prepareErrorStack, resolveOutputFile } from './base'; +import * as fs from 'fs'; +import * as path from 'path'; + import { MultiMap, toPosixPath } from 'playwright-core/lib/utils'; + +import { formatError, nonTerminalScreen, prepareErrorStack, resolveOutputFile } from './base'; import { getProjectId } from '../common/config'; + import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, JSONReport, JSONReportError, JSONReportSpec, JSONReportSuite, JSONReportTest, JSONReportTestResult, JSONReportTestStep, Location, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; type JSONOptions = { outputFile?: string, diff --git a/packages/playwright/src/reporters/junit.ts b/packages/playwright/src/reporters/junit.ts index 9140fb19d8..54aa1c519b 100644 --- a/packages/playwright/src/reporters/junit.ts +++ b/packages/playwright/src/reporters/junit.ts @@ -14,12 +14,15 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { FullConfig, FullResult, Suite, TestCase } from '../../types/testReporter'; -import { formatFailure, nonTerminalScreen, resolveOutputFile, stripAnsiEscapes } from './base'; +import * as fs from 'fs'; +import * as path from 'path'; + import { getAsBooleanFromENV } from 'playwright-core/lib/utils'; + +import { formatFailure, nonTerminalScreen, resolveOutputFile, stripAnsiEscapes } from './base'; + import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, Suite, TestCase } from '../../types/testReporter'; type JUnitOptions = { outputFile?: string, diff --git a/packages/playwright/src/reporters/line.ts b/packages/playwright/src/reporters/line.ts index 4ff5221224..b0bf0fd6fd 100644 --- a/packages/playwright/src/reporters/line.ts +++ b/packages/playwright/src/reporters/line.ts @@ -15,7 +15,8 @@ */ import { TerminalReporter } from './base'; -import type { TestCase, Suite, TestResult, FullResult, TestStep, TestError } from '../../types/testReporter'; + +import type { FullResult, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; class LineReporter extends TerminalReporter { private _current = 0; diff --git a/packages/playwright/src/reporters/list.ts b/packages/playwright/src/reporters/list.ts index aef9fcbe2f..e320a13cc4 100644 --- a/packages/playwright/src/reporters/list.ts +++ b/packages/playwright/src/reporters/list.ts @@ -14,10 +14,12 @@ * limitations under the License. */ -import { ms as milliseconds } from 'playwright-core/lib/utilsBundle'; -import { TerminalReporter, stepSuffix, stripAnsiEscapes } from './base'; -import type { FullResult, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; import { getAsBooleanFromENV } from 'playwright-core/lib/utils'; +import { ms as milliseconds } from 'playwright-core/lib/utilsBundle'; + +import { TerminalReporter, stepSuffix, stripAnsiEscapes } from './base'; + +import type { FullResult, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; // Allow it in the Visual Studio Code Terminal and the new Windows Terminal const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION; diff --git a/packages/playwright/src/reporters/markdown.ts b/packages/playwright/src/reporters/markdown.ts index 2b6bcbf063..158751f1b6 100644 --- a/packages/playwright/src/reporters/markdown.ts +++ b/packages/playwright/src/reporters/markdown.ts @@ -14,12 +14,14 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { FullResult, TestCase } from '../../types/testReporter'; +import * as fs from 'fs'; +import * as path from 'path'; + import { resolveReporterOutputPath } from '../util'; import { TerminalReporter } from './base'; +import type { FullResult, TestCase } from '../../types/testReporter'; + type MarkdownReporterOptions = { configDir: string, outputFile?: string; diff --git a/packages/playwright/src/reporters/merge.ts b/packages/playwright/src/reporters/merge.ts index 102335cceb..fcbecf865e 100644 --- a/packages/playwright/src/reporters/merge.ts +++ b/packages/playwright/src/reporters/merge.ts @@ -14,19 +14,23 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { ReporterDescription } from '../../types/test'; -import type { FullConfigInternal } from '../common/config'; -import type { JsonConfig, JsonEvent, JsonFullResult, JsonLocation, JsonProject, JsonSuite, JsonTestCase, JsonTestResultEnd, JsonTestStepStart, JsonTestStepEnd } from '../isomorphic/teleReceiver'; -import { TeleReporterReceiver } from '../isomorphic/teleReceiver'; -import { JsonStringInternalizer, StringInternPool } from '../isomorphic/stringInternPool'; -import { createReporters } from '../runner/reporters'; -import { Multiplexer } from './multiplexer'; +import * as fs from 'fs'; +import * as path from 'path'; + import { ZipFile } from 'playwright-core/lib/utils'; -import { currentBlobReportVersion, type BlobReportMetadata } from './blob'; + +import { currentBlobReportVersion } from './blob'; +import { Multiplexer } from './multiplexer'; +import { JsonStringInternalizer, StringInternPool } from '../isomorphic/stringInternPool'; +import { TeleReporterReceiver } from '../isomorphic/teleReceiver'; +import { createReporters } from '../runner/reporters'; import { relativeFilePath } from '../util'; + +import type { BlobReportMetadata } from './blob'; +import type { ReporterDescription } from '../../types/test'; import type { TestError } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; +import type { JsonConfig, JsonEvent, JsonFullResult, JsonLocation, JsonProject, JsonSuite, JsonTestCase, JsonTestResultEnd, JsonTestStepEnd, JsonTestStepStart } from '../isomorphic/teleReceiver'; import type * as blobV1 from './versions/blobV1'; type StatusCallback = (message: string) => void; diff --git a/packages/playwright/src/reporters/multiplexer.ts b/packages/playwright/src/reporters/multiplexer.ts index b666128ab4..9ecc9de0f3 100644 --- a/packages/playwright/src/reporters/multiplexer.ts +++ b/packages/playwright/src/reporters/multiplexer.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep } from '../../types/testReporter'; -import type { Suite } from '../common/test'; import type { ReporterV2 } from './reporterV2'; +import type { FullConfig, FullResult, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; +import type { Suite } from '../common/test'; export class Multiplexer implements ReporterV2 { private _reporters: ReporterV2[]; diff --git a/packages/playwright/src/reporters/reporterV2.ts b/packages/playwright/src/reporters/reporterV2.ts index 2cdffdfe12..94cee34213 100644 --- a/packages/playwright/src/reporters/reporterV2.ts +++ b/packages/playwright/src/reporters/reporterV2.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import type { FullConfig, TestCase, TestError, TestResult, FullResult, TestStep, Reporter, Suite } from '../../types/testReporter'; +import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, TestResult, TestStep } from '../../types/testReporter'; export interface ReporterV2 { onConfigure?(config: FullConfig): void; diff --git a/packages/playwright/src/reporters/teleEmitter.ts b/packages/playwright/src/reporters/teleEmitter.ts index 76fc1490a6..11d10987f2 100644 --- a/packages/playwright/src/reporters/teleEmitter.ts +++ b/packages/playwright/src/reporters/teleEmitter.ts @@ -14,12 +14,15 @@ * limitations under the License. */ -import path from 'path'; +import * as path from 'path'; + import { createGuid } from 'playwright-core/lib/utils'; + +import { serializeRegexPatterns } from '../isomorphic/teleReceiver'; + +import type { ReporterV2 } from './reporterV2'; import type * as reporterTypes from '../../types/testReporter'; import type * as teleReceiver from '../isomorphic/teleReceiver'; -import { serializeRegexPatterns } from '../isomorphic/teleReceiver'; -import type { ReporterV2 } from './reporterV2'; export type TeleReporterEmitterOptions = { omitOutput?: boolean; diff --git a/packages/playwright/src/runner/dispatcher.ts b/packages/playwright/src/runner/dispatcher.ts index 9f6367c106..084deba11d 100644 --- a/packages/playwright/src/runner/dispatcher.ts +++ b/packages/playwright/src/runner/dispatcher.ts @@ -14,20 +14,24 @@ * limitations under the License. */ -import type { TestBeginPayload, TestEndPayload, DonePayload, TestOutputPayload, StepBeginPayload, StepEndPayload, TeardownErrorsPayload, RunPayload, SerializedConfig, AttachmentPayload } from '../common/ipc'; -import { serializeConfig } from '../common/ipc'; -import type { TestResult, TestStep, TestError } from '../../types/testReporter'; -import type { Suite } from '../common/test'; -import type { ProcessExitData } from './processHost'; -import type { TestCase } from '../common/test'; -import { ManualPromise, type RegisteredListener, eventsHelper } from 'playwright-core/lib/utils'; -import { WorkerHost } from './workerHost'; -import type { TestGroup } from './testGroups'; -import type { FullConfigInternal } from '../common/config'; -import type { ReporterV2 } from '../reporters/reporterV2'; -import type { FailureTracker } from './failureTracker'; +import { ManualPromise, eventsHelper } from 'playwright-core/lib/utils'; import { colors } from 'playwright-core/lib/utilsBundle'; + import { addSuggestedRebaseline } from './rebase'; +import { WorkerHost } from './workerHost'; +import { serializeConfig } from '../common/ipc'; + +import type { FailureTracker } from './failureTracker'; +import type { ProcessExitData } from './processHost'; +import type { TestGroup } from './testGroups'; +import type { TestError, TestResult, TestStep } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; +import type { AttachmentPayload, DonePayload, RunPayload, SerializedConfig, StepBeginPayload, StepEndPayload, TeardownErrorsPayload, TestBeginPayload, TestEndPayload, TestOutputPayload } from '../common/ipc'; +import type { Suite } from '../common/test'; +import type { TestCase } from '../common/test'; +import type { ReporterV2 } from '../reporters/reporterV2'; +import type { RegisteredListener } from 'playwright-core/lib/utils'; + export type EnvByProjectId = Map>; diff --git a/packages/playwright/src/runner/lastRun.ts b/packages/playwright/src/runner/lastRun.ts index 2152f977cf..158450ed41 100644 --- a/packages/playwright/src/runner/lastRun.ts +++ b/packages/playwright/src/runner/lastRun.ts @@ -14,10 +14,12 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { FullResult, Suite } from '../../types/testReporter'; +import * as fs from 'fs'; +import * as path from 'path'; + import { filterProjects } from './projectUtils'; + +import type { FullResult, Suite } from '../../types/testReporter'; import type { FullConfigInternal } from '../common/config'; import type { ReporterV2 } from '../reporters/reporterV2'; diff --git a/packages/playwright/src/runner/loadUtils.ts b/packages/playwright/src/runner/loadUtils.ts index 62799747b6..457444b94c 100644 --- a/packages/playwright/src/runner/loadUtils.ts +++ b/packages/playwright/src/runner/loadUtils.ts @@ -14,22 +14,25 @@ * limitations under the License. */ -import path from 'path'; -import type { FullConfig, Reporter, TestError } from '../../types/testReporter'; +import * as path from 'path'; + import { InProcessLoaderHost, OutOfProcessLoaderHost } from './loaderHost'; +import { createFileFiltersFromArguments, createFileMatcherFromArguments, createTitleMatcher, errorWithFile, forceRegExp } from '../util'; +import { buildProjectsClosure, collectFilesForProject, filterProjects } from './projectUtils'; +import { createTestGroups, filterForShard } from './testGroups'; +import { applyRepeatEachIndex, bindFileSuiteToProject, filterByFocusedLine, filterByTestIds, filterOnly, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; import { Suite } from '../common/test'; -import type { TestCase } from '../common/test'; +import { dependenciesForTestFile } from '../transform/compilationCache'; +import { requireOrImport } from '../transform/transform'; +import { sourceMapSupport } from '../utilsBundle'; + +import type { TestRun } from './tasks'; +import type { TestGroup } from './testGroups'; +import type { FullConfig, Reporter, TestError } from '../../types/testReporter'; import type { FullProjectInternal } from '../common/config'; import type { FullConfigInternal } from '../common/config'; -import { createFileMatcherFromArguments, createFileFiltersFromArguments, createTitleMatcher, errorWithFile, forceRegExp } from '../util'; +import type { TestCase } from '../common/test'; import type { Matcher, TestFileFilter } from '../util'; -import { buildProjectsClosure, collectFilesForProject, filterProjects } from './projectUtils'; -import type { TestRun } from './tasks'; -import { requireOrImport } from '../transform/transform'; -import { applyRepeatEachIndex, bindFileSuiteToProject, filterByFocusedLine, filterByTestIds, filterOnly, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; -import { createTestGroups, filterForShard, type TestGroup } from './testGroups'; -import { dependenciesForTestFile } from '../transform/compilationCache'; -import { sourceMapSupport } from '../utilsBundle'; import type { RawSourceMap } from '../utilsBundle'; diff --git a/packages/playwright/src/runner/loaderHost.ts b/packages/playwright/src/runner/loaderHost.ts index e6db22695b..369cf49a21 100644 --- a/packages/playwright/src/runner/loaderHost.ts +++ b/packages/playwright/src/runner/loaderHost.ts @@ -14,15 +14,17 @@ * limitations under the License. */ -import type { TestError } from '../../types/testReporter'; -import { serializeConfig } from '../common/ipc'; import { ProcessHost } from './processHost'; +import { incorporateCompilationCache } from '../common/esmLoaderHost'; +import { serializeConfig } from '../common/ipc'; +import { PoolBuilder } from '../common/poolBuilder'; import { Suite } from '../common/test'; import { loadTestFile } from '../common/testLoader'; -import type { FullConfigInternal } from '../common/config'; -import { PoolBuilder } from '../common/poolBuilder'; import { addToCompilationCache } from '../transform/compilationCache'; -import { incorporateCompilationCache } from '../common/esmLoaderHost'; + +import type { TestError } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; + export class InProcessLoaderHost { private _config: FullConfigInternal; diff --git a/packages/playwright/src/runner/processHost.ts b/packages/playwright/src/runner/processHost.ts index 4c77c17857..cc972b2601 100644 --- a/packages/playwright/src/runner/processHost.ts +++ b/packages/playwright/src/runner/processHost.ts @@ -16,12 +16,15 @@ import child_process from 'child_process'; import { EventEmitter } from 'events'; + +import { assert } from 'playwright-core/lib/utils'; import { debug } from 'playwright-core/lib/utilsBundle'; + +import { esmLoaderRegistered } from '../common/esmLoaderHost'; +import { execArgvWithExperimentalLoaderOptions } from '../transform/esmUtils'; + import type { EnvProducedPayload, ProcessInitParams } from '../common/ipc'; import type { ProtocolResponse } from '../common/process'; -import { execArgvWithExperimentalLoaderOptions } from '../transform/esmUtils'; -import { assert } from 'playwright-core/lib/utils'; -import { esmLoaderRegistered } from '../common/esmLoaderHost'; export type ProcessExitData = { unexpectedly: boolean; diff --git a/packages/playwright/src/runner/projectUtils.ts b/packages/playwright/src/runner/projectUtils.ts index 49a6c89d84..7bb1495ba3 100644 --- a/packages/playwright/src/runner/projectUtils.ts +++ b/packages/playwright/src/runner/projectUtils.ts @@ -14,14 +14,18 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; +import { promisify } from 'util'; + import { escapeRegExp } from 'playwright-core/lib/utils'; import { minimatch } from 'playwright-core/lib/utilsBundle'; -import { promisify } from 'util'; -import type { FullProjectInternal } from '../common/config'; + import { createFileMatcher } from '../util'; +import type { FullProjectInternal } from '../common/config'; + + const readFileAsync = promisify(fs.readFile); const readDirAsync = promisify(fs.readdir); diff --git a/packages/playwright/src/runner/rebase.ts b/packages/playwright/src/runner/rebase.ts index b040761df9..c2d9f96d18 100644 --- a/packages/playwright/src/runner/rebase.ts +++ b/packages/playwright/src/runner/rebase.ts @@ -14,15 +14,19 @@ * limitations under the License. */ -import path from 'path'; -import fs from 'fs'; -import type { T } from '../transform/babelBundle'; -import { types, traverse, babelParse } from '../transform/babelBundle'; +import * as fs from 'fs'; +import * as path from 'path'; + + import { MultiMap } from 'playwright-core/lib/utils'; import { colors, diff } from 'playwright-core/lib/utilsBundle'; -import type { FullConfigInternal } from '../common/config'; + import { filterProjects } from './projectUtils'; +import { babelParse, traverse, types } from '../transform/babelBundle'; + +import type { FullConfigInternal } from '../common/config'; import type { InternalReporter } from '../reporters/internalReporter'; +import type { T } from '../transform/babelBundle'; const t: typeof T = types; type Location = { diff --git a/packages/playwright/src/runner/reporters.ts b/packages/playwright/src/runner/reporters.ts index b25cb84154..163b8b8e3e 100644 --- a/packages/playwright/src/runner/reporters.ts +++ b/packages/playwright/src/runner/reporters.ts @@ -14,10 +14,13 @@ * limitations under the License. */ -import path from 'path'; -import type { FullConfig, TestError } from '../../types/testReporter'; +import * as path from 'path'; + +import { calculateSha1 } from 'playwright-core/lib/utils'; + +import { loadReporter } from './loadUtils'; import { formatError, terminalScreen } from '../reporters/base'; -import type { Screen } from '../reporters/base'; +import { BlobReporter } from '../reporters/blob'; import DotReporter from '../reporters/dot'; import EmptyReporter from '../reporters/empty'; import GitHubReporter from '../reporters/github'; @@ -26,13 +29,15 @@ import JSONReporter from '../reporters/json'; import JUnitReporter from '../reporters/junit'; import LineReporter from '../reporters/line'; import ListReporter from '../reporters/list'; -import type { Suite } from '../common/test'; -import type { BuiltInReporter, FullConfigInternal } from '../common/config'; -import { loadReporter } from './loadUtils'; -import { BlobReporter } from '../reporters/blob'; +import { wrapReporterAsV2 } from '../reporters/reporterV2'; + import type { ReporterDescription } from '../../types/test'; -import { type ReporterV2, wrapReporterAsV2 } from '../reporters/reporterV2'; -import { calculateSha1 } from 'playwright-core/lib/utils'; +import type { FullConfig, TestError } from '../../types/testReporter'; +import type { BuiltInReporter, FullConfigInternal } from '../common/config'; +import type { Suite } from '../common/test'; +import type { Screen } from '../reporters/base'; +import type { ReporterV2 } from '../reporters/reporterV2'; + export async function createReporters(config: FullConfigInternal, mode: 'list' | 'test' | 'merge', isTestServer: boolean, descriptions?: ReporterDescription[]): Promise { const defaultReporters: { [key in BuiltInReporter]: new(arg: any) => ReporterV2 } = { diff --git a/packages/playwright/src/runner/runner.ts b/packages/playwright/src/runner/runner.ts index 51eb15e299..22694c251e 100644 --- a/packages/playwright/src/runner/runner.ts +++ b/packages/playwright/src/runner/runner.ts @@ -15,17 +15,19 @@ * limitations under the License. */ -import type { FullResult, TestError } from '../../types/testReporter'; -import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; -import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin'; +import { LastRunReporter } from './lastRun'; import { collectFilesForProject, filterProjects } from './projectUtils'; import { createErrorCollectingReporter, createReporters } from './reporters'; import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks } from './tasks'; -import type { FullConfigInternal } from '../common/config'; -import { affectedTestFiles } from '../transform/compilationCache'; -import { InternalReporter } from '../reporters/internalReporter'; -import { LastRunReporter } from './lastRun'; +import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin'; +import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; import { terminalScreen } from '../reporters/base'; +import { InternalReporter } from '../reporters/internalReporter'; +import { affectedTestFiles } from '../transform/compilationCache'; + +import type { FullResult, TestError } from '../../types/testReporter'; +import type { FullConfigInternal } from '../common/config'; + type ProjectConfigWithFiles = { name: string; diff --git a/packages/playwright/src/runner/taskRunner.ts b/packages/playwright/src/runner/taskRunner.ts index dd29d6b0f8..12185aa951 100644 --- a/packages/playwright/src/runner/taskRunner.ts +++ b/packages/playwright/src/runner/taskRunner.ts @@ -14,11 +14,14 @@ * limitations under the License. */ -import { colors, debug } from 'playwright-core/lib/utilsBundle'; import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils'; -import type { FullResult, TestError } from '../../types/testReporter'; +import { colors, debug } from 'playwright-core/lib/utilsBundle'; + + import { SigIntWatcher } from './sigIntWatcher'; import { serializeError } from '../util'; + +import type { FullResult, TestError } from '../../types/testReporter'; import type { InternalReporter } from '../reporters/internalReporter'; type TaskPhase = (context: Context, errors: TestError[], softErrors: TestError[]) => Promise | void; diff --git a/packages/playwright/src/runner/tasks.ts b/packages/playwright/src/runner/tasks.ts index 2d0b57f13a..4a1056f6a8 100644 --- a/packages/playwright/src/runner/tasks.ts +++ b/packages/playwright/src/runner/tasks.ts @@ -14,27 +14,34 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; import { promisify } from 'util'; + +import { monotonicTime, removeFolders } from 'playwright-core/lib/utils'; import { debug } from 'playwright-core/lib/utilsBundle'; -import { type ManualPromise, monotonicTime, removeFolders } from 'playwright-core/lib/utils'; -import { Dispatcher, type EnvByProjectId } from './dispatcher'; -import type { TestRunnerPluginRegistration } from '../plugins'; -import { createTestGroups, type TestGroup } from '../runner/testGroups'; -import type { Task } from './taskRunner'; -import { TaskRunner } from './taskRunner'; -import type { FullConfigInternal, FullProjectInternal } from '../common/config'; -import { collectProjectsAndTestFiles, createRootSuite, loadFileSuites, loadGlobalHook } from './loadUtils'; -import { removeDirAndLogToConsole, type Matcher } from '../util'; -import { Suite } from '../common/test'; -import { buildDependentProjects, buildTeardownToSetupsMap, filterProjects } from './projectUtils'; + +import { Dispatcher } from './dispatcher'; import { FailureTracker } from './failureTracker'; -import { detectChangedTestFiles } from './vcs'; -import type { InternalReporter } from '../reporters/internalReporter'; -import { cacheDir } from '../transform/compilationCache'; -import type { FullResult } from '../../types/testReporter'; +import { collectProjectsAndTestFiles, createRootSuite, loadFileSuites, loadGlobalHook } from './loadUtils'; +import { buildDependentProjects, buildTeardownToSetupsMap, filterProjects } from './projectUtils'; import { applySuggestedRebaselines, clearSuggestedRebaselines } from './rebase'; +import { Suite } from '../common/test'; +import { createTestGroups } from '../runner/testGroups'; +import { removeDirAndLogToConsole } from '../util'; +import { TaskRunner } from './taskRunner'; +import { detectChangedTestFiles } from './vcs'; +import { cacheDir } from '../transform/compilationCache'; + +import type { TestGroup } from '../runner/testGroups'; +import type { Matcher } from '../util'; +import type { EnvByProjectId } from './dispatcher'; +import type { TestRunnerPluginRegistration } from '../plugins'; +import type { Task } from './taskRunner'; +import type { FullResult } from '../../types/testReporter'; +import type { FullConfigInternal, FullProjectInternal } from '../common/config'; +import type { InternalReporter } from '../reporters/internalReporter'; +import type { ManualPromise } from 'playwright-core/lib/utils'; const readDirAsync = promisify(fs.readdir); diff --git a/packages/playwright/src/runner/testServer.ts b/packages/playwright/src/runner/testServer.ts index db080728e9..14fa5796d4 100644 --- a/packages/playwright/src/runner/testServer.ts +++ b/packages/playwright/src/runner/testServer.ts @@ -14,32 +14,35 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; +import * as fs from 'fs'; +import * as path from 'path'; + import { installRootRedirect, openTraceInBrowser, openTraceViewerApp, registry, startTraceViewerServer } from 'playwright-core/lib/server'; import { ManualPromise, gracefullyProcessExitDoNotHang, isUnderTest } from 'playwright-core/lib/utils'; -import type { Transport, HttpServer } from 'playwright-core/lib/utils'; -import type * as reporterTypes from '../../types/testReporter'; -import { affectedTestFiles, collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache'; -import type { ConfigLocation, FullConfigInternal } from '../common/config'; -import { createErrorCollectingReporter, createReporterForTestServer, createReporters } from './reporters'; -import { TestRun, runTasks, createLoadTask, createRunTestsTasks, createReportBeginTask, createListFilesTask, runTasksDeferCleanup, createClearCacheTask, createGlobalSetupTasks, createStartDevServerTask, createApplyRebaselinesTask } from './tasks'; import { open } from 'playwright-core/lib/utilsBundle'; -import ListReporter from '../reporters/list'; + +import { createErrorCollectingReporter, createReporterForTestServer, createReporters } from './reporters'; import { SigIntWatcher } from './sigIntWatcher'; -import { Watcher } from '../fsWatcher'; -import type { ReportEntry, TestServerInterface, TestServerInterfaceEventEmitters } from '../isomorphic/testServerInterface'; -import type { ConfigCLIOverrides } from '../common/ipc'; +import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createListFilesTask, createLoadTask, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks, runTasksDeferCleanup } from './tasks'; import { loadConfig, resolveConfigLocation, restartWithExperimentalTsEsm } from '../common/configLoader'; -import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; -import type { TraceViewerRedirectOptions, TraceViewerServerOptions } from 'playwright-core/lib/server/trace/viewer/traceViewer'; -import type { TestRunnerPluginRegistration } from '../plugins'; -import { serializeError } from '../util'; +import { Watcher } from '../fsWatcher'; import { baseFullConfig } from '../isomorphic/teleReceiver'; -import { InternalReporter } from '../reporters/internalReporter'; -import type { ReporterV2 } from '../reporters/reporterV2'; -import { internalScreen } from '../reporters/base'; import { addGitCommitInfoPlugin } from '../plugins/gitCommitInfoPlugin'; +import { webServerPluginsForConfig } from '../plugins/webServerPlugin'; +import { internalScreen } from '../reporters/base'; +import { InternalReporter } from '../reporters/internalReporter'; +import ListReporter from '../reporters/list'; +import { affectedTestFiles, collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache'; +import { serializeError } from '../util'; + +import type * as reporterTypes from '../../types/testReporter'; +import type { ConfigLocation, FullConfigInternal } from '../common/config'; +import type { ConfigCLIOverrides } from '../common/ipc'; +import type { ReportEntry, TestServerInterface, TestServerInterfaceEventEmitters } from '../isomorphic/testServerInterface'; +import type { TestRunnerPluginRegistration } from '../plugins'; +import type { ReporterV2 } from '../reporters/reporterV2'; +import type { TraceViewerRedirectOptions, TraceViewerServerOptions } from 'playwright-core/lib/server/trace/viewer/traceViewer'; +import type { HttpServer, Transport } from 'playwright-core/lib/utils'; const originalStdoutWrite = process.stdout.write; const originalStderrWrite = process.stderr.write; diff --git a/packages/playwright/src/runner/vcs.ts b/packages/playwright/src/runner/vcs.ts index da7c4c2cc8..91d88bc49d 100644 --- a/packages/playwright/src/runner/vcs.ts +++ b/packages/playwright/src/runner/vcs.ts @@ -15,8 +15,9 @@ */ import childProcess from 'child_process'; +import * as path from 'path'; + import { affectedTestFiles } from '../transform/compilationCache'; -import path from 'path'; export async function detectChangedTestFiles(baseCommit: string, configDir: string): Promise> { function gitFileList(command: string) { diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.ts index 5c8ddf34a0..c9768c47ba 100644 --- a/packages/playwright/src/runner/watchMode.ts +++ b/packages/playwright/src/runner/watchMode.ts @@ -14,20 +14,25 @@ * limitations under the License. */ +import * as path from 'path'; import readline from 'readline'; -import path from 'path'; -import { createGuid, eventsHelper, getPackageManagerExecCommand, ManualPromise } from 'playwright-core/lib/utils'; -import type { ConfigLocation } from '../common/config'; -import type { FullResult } from '../../types/testReporter'; -import { colors } from 'playwright-core/lib/utilsBundle'; -import { enquirer } from '../utilsBundle'; -import { separator, terminalScreen } from '../reporters/base'; -import { PlaywrightServer } from 'playwright-core/lib/remote/playwrightServer'; -import { TestServerDispatcher } from './testServer'; import { EventEmitter } from 'stream'; -import { type TestServerTransport, TestServerConnection } from '../isomorphic/testServerConnection'; -import { TeleSuiteUpdater } from '../isomorphic/teleSuiteUpdater'; + +import { PlaywrightServer } from 'playwright-core/lib/remote/playwrightServer'; +import { ManualPromise, createGuid, eventsHelper, getPackageManagerExecCommand } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +import { separator, terminalScreen } from '../reporters/base'; +import { enquirer } from '../utilsBundle'; +import { TestServerDispatcher } from './testServer'; import { restartWithExperimentalTsEsm } from '../common/configLoader'; +import { TeleSuiteUpdater } from '../isomorphic/teleSuiteUpdater'; +import { TestServerConnection } from '../isomorphic/testServerConnection'; + +import type { FullResult } from '../../types/testReporter'; +import type { ConfigLocation } from '../common/config'; +import type { TestServerTransport } from '../isomorphic/testServerConnection'; + class InMemoryTransport extends EventEmitter implements TestServerTransport { public readonly _send: (data: string) => void; diff --git a/packages/playwright/src/runner/workerHost.ts b/packages/playwright/src/runner/workerHost.ts index 834dd1facf..d92093e72b 100644 --- a/packages/playwright/src/runner/workerHost.ts +++ b/packages/playwright/src/runner/workerHost.ts @@ -14,15 +14,19 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import type { TestGroup } from './testGroups'; -import { stdioChunkToParams } from '../common/ipc'; -import type { RunPayload, SerializedConfig, WorkerInitParams } from '../common/ipc'; -import { ProcessHost } from './processHost'; -import { artifactsFolderName } from '../isomorphic/folders'; +import * as fs from 'fs'; +import * as path from 'path'; + import { removeFolders } from 'playwright-core/lib/utils'; +import { ProcessHost } from './processHost'; +import { stdioChunkToParams } from '../common/ipc'; +import { artifactsFolderName } from '../isomorphic/folders'; + +import type { TestGroup } from './testGroups'; +import type { RunPayload, SerializedConfig, WorkerInitParams } from '../common/ipc'; + + let lastWorkerIndex = 0; export class WorkerHost extends ProcessHost { diff --git a/packages/playwright/src/transform/babelBundle.ts b/packages/playwright/src/transform/babelBundle.ts index 349b7b9c30..ce61eecc90 100644 --- a/packages/playwright/src/transform/babelBundle.ts +++ b/packages/playwright/src/transform/babelBundle.ts @@ -24,5 +24,5 @@ export type BabelTransformFunction = (code: string, filename: string, isModule: export const babelTransform: BabelTransformFunction = require('./babelBundleImpl').babelTransform; export type BabelParseFunction = (code: string, filename: string, isModule: boolean) => ParseResult; export const babelParse: BabelParseFunction = require('./babelBundleImpl').babelParse; -export type { NodePath, types as T, PluginObj } from '../../bundles/babel/node_modules/@types/babel__core'; +export type { NodePath, PluginObj, types as T } from '../../bundles/babel/node_modules/@types/babel__core'; export type { BabelAPI } from '../../bundles/babel/node_modules/@types/babel__helper-plugin-utils'; diff --git a/packages/playwright/src/transform/compilationCache.ts b/packages/playwright/src/transform/compilationCache.ts index 39c1189ea2..ae9391d79a 100644 --- a/packages/playwright/src/transform/compilationCache.ts +++ b/packages/playwright/src/transform/compilationCache.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import fs from 'fs'; -import os from 'os'; -import path from 'path'; -import { sourceMapSupport } from '../utilsBundle'; +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; + import { isWorkerProcess } from '../common/globals'; +import { sourceMapSupport } from '../utilsBundle'; export type MemoryCache = { codePath: string; diff --git a/packages/playwright/src/transform/esmLoader.ts b/packages/playwright/src/transform/esmLoader.ts index c84d15146b..6e6b37cf4c 100644 --- a/packages/playwright/src/transform/esmLoader.ts +++ b/packages/playwright/src/transform/esmLoader.ts @@ -14,11 +14,12 @@ * limitations under the License. */ -import fs from 'fs'; -import url from 'url'; +import * as fs from 'fs'; +import * as url from 'url'; + import { addToCompilationCache, currentFileDepsCollector, serializeCompilationCache, startCollectingFileDeps, stopCollectingFileDeps } from './compilationCache'; -import { transformHook, resolveHook, setTransformConfig, shouldTransform, setSingleTSConfig } from './transform'; import { PortTransport } from './portTransport'; +import { resolveHook, setSingleTSConfig, setTransformConfig, shouldTransform, transformHook } from './transform'; import { fileIsModule } from '../util'; // Node < 18.6: defaultResolve takes 3 arguments. @@ -120,4 +121,4 @@ function createTransport(port: MessagePort) { } -module.exports = { resolve, load, globalPreload, initialize }; +module.exports = { globalPreload, initialize, load, resolve }; diff --git a/packages/playwright/src/transform/esmUtils.ts b/packages/playwright/src/transform/esmUtils.ts index 31851f61d3..bfa4a23790 100644 --- a/packages/playwright/src/transform/esmUtils.ts +++ b/packages/playwright/src/transform/esmUtils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import url from 'url'; +import * as url from 'url'; const kExperimentalLoaderOptions = [ '--no-warnings', diff --git a/packages/playwright/src/transform/transform.ts b/packages/playwright/src/transform/transform.ts index 88950670be..06717dde21 100644 --- a/packages/playwright/src/transform/transform.ts +++ b/packages/playwright/src/transform/transform.ts @@ -15,18 +15,21 @@ */ import crypto from 'crypto'; -import fs from 'fs'; -import path from 'path'; -import url from 'url'; -import { sourceMapSupport, pirates } from '../utilsBundle'; +import * as fs from 'fs'; +import Module from 'module'; +import * as path from 'path'; +import * as url from 'url'; + +import { loadTsConfig } from '../third_party/tsconfig-loader'; +import { createFileMatcher, fileIsModule, resolveImportSpecifierAfterMapping } from '../util'; +import { pirates, sourceMapSupport } from '../utilsBundle'; +import { belongsToNodeModules, currentFileDepsCollector, getFromCompilationCache, installSourceMapSupport } from './compilationCache'; + +import type { BabelPlugin, BabelTransformFunction } from './babelBundle'; import type { Location } from '../../types/testReporter'; import type { LoadedTsConfig } from '../third_party/tsconfig-loader'; -import { loadTsConfig } from '../third_party/tsconfig-loader'; -import Module from 'module'; -import type { BabelPlugin, BabelTransformFunction } from './babelBundle'; -import { createFileMatcher, fileIsModule, resolveImportSpecifierAfterMapping } from '../util'; import type { Matcher } from '../util'; -import { getFromCompilationCache, currentFileDepsCollector, belongsToNodeModules, installSourceMapSupport } from './compilationCache'; + const version = require('../../package.json').version; diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.ts index f7f91d3198..74911a85cb 100644 --- a/packages/playwright/src/util.ts +++ b/packages/playwright/src/util.ts @@ -14,17 +14,19 @@ * limitations under the License. */ -import fs from 'fs'; -import type { StackFrame } from '@protocol/channels'; +import * as fs from 'fs'; +import * as path from 'path'; +import * as url from 'url'; import util from 'util'; -import path from 'path'; -import url from 'url'; -import { debug, mime, minimatch, parseStackTraceLine } from 'playwright-core/lib/utilsBundle'; + import { formatCallLog } from 'playwright-core/lib/utils'; -import type { Location } from './../types/testReporter'; import { calculateSha1, isRegExp, isString, sanitizeForFilePath, stringifyStackFrames } from 'playwright-core/lib/utils'; -import type { RawStack } from 'playwright-core/lib/utils'; +import { debug, mime, minimatch, parseStackTraceLine } from 'playwright-core/lib/utilsBundle'; + +import type { Location } from './../types/testReporter'; import type { TestInfoErrorImpl } from './common/ipc'; +import type { StackFrame } from '@protocol/channels'; +import type { RawStack } from 'playwright-core/lib/utils'; const PLAYWRIGHT_TEST_PATH = path.join(__dirname, '..'); const PLAYWRIGHT_CORE_PATH = path.dirname(require.resolve('playwright-core/package.json')); diff --git a/packages/playwright/src/worker/fixtureRunner.ts b/packages/playwright/src/worker/fixtureRunner.ts index f4fc373610..555f86ab57 100644 --- a/packages/playwright/src/worker/fixtureRunner.ts +++ b/packages/playwright/src/worker/fixtureRunner.ts @@ -14,13 +14,16 @@ * limitations under the License. */ -import { formatLocation, filterStackFile } from '../util'; import { ManualPromise } from 'playwright-core/lib/utils'; + +import { fixtureParameterNames } from '../common/fixtures'; +import { filterStackFile, formatLocation } from '../util'; + import type { TestInfoImpl } from './testInfo'; -import { type FixtureDescription, type RunnableDescription } from './timeoutManager'; -import { fixtureParameterNames, type FixturePool, type FixtureRegistration, type FixtureScope } from '../common/fixtures'; +import type { FixtureDescription, RunnableDescription } from './timeoutManager'; import type { WorkerInfo } from '../../types/test'; import type { Location } from '../../types/testReporter'; +import type { FixturePool, FixtureRegistration, FixtureScope } from '../common/fixtures'; class Fixture { runner: FixtureRunner; diff --git a/packages/playwright/src/worker/testInfo.ts b/packages/playwright/src/worker/testInfo.ts index 740f7579bd..5e964af5e0 100644 --- a/packages/playwright/src/worker/testInfo.ts +++ b/packages/playwright/src/worker/testInfo.ts @@ -14,21 +14,25 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; -import { captureRawStack, monotonicTime, zones, sanitizeForFilePath, stringifyStackFrames } from 'playwright-core/lib/utils'; -import type { TestInfo, TestStatus, FullProject, TestStepInfo } from '../../types/test'; -import type { AttachmentPayload, StepBeginPayload, StepEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc'; -import type { TestCase } from '../common/test'; +import * as fs from 'fs'; +import * as path from 'path'; + +import { captureRawStack, monotonicTime, sanitizeForFilePath, stringifyStackFrames, zones } from 'playwright-core/lib/utils'; + import { TimeoutManager, TimeoutManagerError, kMaxDeadline } from './timeoutManager'; -import type { RunnableDescription } from './timeoutManager'; -import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; -import type { FullConfig, Location } from '../../types/testReporter'; import { debugTest, filteredStackTrace, formatLocation, getContainedPath, normalizeAndSaveAttachment, trimLongString, windowsFilesystemFriendlyLength } from '../util'; import { TestTracing } from './testTracing'; -import type { StackFrame } from '@protocol/channels'; import { testInfoError } from './util'; +import type { RunnableDescription } from './timeoutManager'; +import type { FullProject, TestInfo, TestStatus, TestStepInfo } from '../../types/test'; +import type { FullConfig, Location } from '../../types/testReporter'; +import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; +import type { AttachmentPayload, StepBeginPayload, StepEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc'; +import type { TestCase } from '../common/test'; +import type { StackFrame } from '@protocol/channels'; + + export interface TestStepInternal { complete(result: { error?: Error | unknown, suggestedRebaseline?: string }): void; info: TestStepInfoImpl diff --git a/packages/playwright/src/worker/testTracing.ts b/packages/playwright/src/worker/testTracing.ts index e154d6a649..a90c006616 100644 --- a/packages/playwright/src/worker/testTracing.ts +++ b/packages/playwright/src/worker/testTracing.ts @@ -14,17 +14,20 @@ * limitations under the License. */ +import * as fs from 'fs'; +import * as path from 'path'; + +import { ManualPromise, SerializedFS, calculateSha1, createGuid, monotonicTime } from 'playwright-core/lib/utils'; +import { yauzl, yazl } from 'playwright-core/lib/zipBundle'; + +import { filteredStackTrace } from '../util'; + +import type { TestInfoImpl } from './testInfo'; +import type { PlaywrightWorkerOptions, TestInfo, TraceMode } from '../../types/test'; +import type { TestInfoErrorImpl } from '../common/ipc'; import type { SerializedError, StackFrame } from '@protocol/channels'; import type * as trace from '@trace/trace'; import type EventEmitter from 'events'; -import fs from 'fs'; -import path from 'path'; -import { ManualPromise, calculateSha1, monotonicTime, createGuid, SerializedFS } from 'playwright-core/lib/utils'; -import { yauzl, yazl } from 'playwright-core/lib/zipBundle'; -import { filteredStackTrace } from '../util'; -import type { TestInfo, TraceMode, PlaywrightWorkerOptions } from '../../types/test'; -import type { TestInfoImpl } from './testInfo'; -import type { TestInfoErrorImpl } from '../common/ipc'; export type Attachment = TestInfo['attachments'][0]; export const testTraceEntryName = 'test.trace'; diff --git a/packages/playwright/src/worker/timeoutManager.ts b/packages/playwright/src/worker/timeoutManager.ts index ef7665a650..7018dafcc9 100644 --- a/packages/playwright/src/worker/timeoutManager.ts +++ b/packages/playwright/src/worker/timeoutManager.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -import { colors } from 'playwright-core/lib/utilsBundle'; import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; + import type { Location } from '../../types/testReporter'; export type TimeSlot = { diff --git a/packages/playwright/src/worker/util.ts b/packages/playwright/src/worker/util.ts index a271f62c48..1f8cbc7d48 100644 --- a/packages/playwright/src/worker/util.ts +++ b/packages/playwright/src/worker/util.ts @@ -14,10 +14,11 @@ * limitations under the License. */ -import type { TestInfoErrorImpl } from '../common/ipc'; import { ExpectError } from '../matchers/matcherHint'; import { serializeError } from '../util'; +import type { TestInfoErrorImpl } from '../common/ipc'; + export function testInfoError(error: Error | any): TestInfoErrorImpl { const result = serializeError(error); if (error instanceof ExpectError) diff --git a/packages/playwright/src/worker/workerMain.ts b/packages/playwright/src/worker/workerMain.ts index 8bd7f3dcd0..5188614271 100644 --- a/packages/playwright/src/worker/workerMain.ts +++ b/packages/playwright/src/worker/workerMain.ts @@ -14,25 +14,27 @@ * limitations under the License. */ -import { colors } from 'playwright-core/lib/utilsBundle'; -import { debugTest, relativeFilePath } from '../util'; -import type { TestBeginPayload, TestEndPayload, RunPayload, DonePayload, WorkerInitParams, TeardownErrorsPayload, TestInfoErrorImpl } from '../common/ipc'; -import { stdioChunkToParams } from '../common/ipc'; -import { setCurrentTestInfo, setIsWorkerProcess } from '../common/globals'; -import { deserializeConfig } from '../common/configLoader'; -import type { Suite, TestCase } from '../common/test'; -import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; -import { FixtureRunner } from './fixtureRunner'; import { ManualPromise, gracefullyCloseAll, removeFolders } from 'playwright-core/lib/utils'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +import { deserializeConfig } from '../common/configLoader'; +import { setCurrentTestInfo, setIsWorkerProcess } from '../common/globals'; +import { stdioChunkToParams } from '../common/ipc'; +import { debugTest, relativeFilePath } from '../util'; +import { FixtureRunner } from './fixtureRunner'; import { SkipError, TestInfoImpl } from './testInfo'; -import { ProcessRunner } from '../common/process'; -import { loadTestFile } from '../common/testLoader'; -import { applyRepeatEachIndex, bindFileSuiteToProject, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; -import { PoolBuilder } from '../common/poolBuilder'; -import type { Location } from '../../types/testReporter'; -import { inheritFixtureNames } from '../common/fixtures'; -import { type TimeSlot } from './timeoutManager'; import { testInfoError } from './util'; +import { inheritFixtureNames } from '../common/fixtures'; +import { PoolBuilder } from '../common/poolBuilder'; +import { ProcessRunner } from '../common/process'; +import { applyRepeatEachIndex, bindFileSuiteToProject, filterTestsRemoveEmptySuites } from '../common/suiteUtils'; +import { loadTestFile } from '../common/testLoader'; + +import type { TimeSlot } from './timeoutManager'; +import type { Location } from '../../types/testReporter'; +import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config'; +import type { DonePayload, RunPayload, TeardownErrorsPayload, TestBeginPayload, TestEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc'; +import type { Suite, TestCase } from '../common/test'; export class WorkerMain extends ProcessRunner { private _params: WorkerInitParams; diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index ef839e44cb..f44acbd015 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -371,7 +371,7 @@ interface TestProject { * * ```js * import { test, expect } from '@playwright/test'; - * import fs from 'fs'; + * import * as fs from 'fs'; * * test('example test', async ({}, testInfo) => { * const file = testInfo.outputPath('temporary-file.txt'); @@ -1349,7 +1349,7 @@ interface TestConfig { * * ```js * import { test, expect } from '@playwright/test'; - * import fs from 'fs'; + * import * as fs from 'fs'; * * test('example test', async ({}, testInfo) => { * const file = testInfo.outputPath('temporary-file.txt'); @@ -9191,7 +9191,7 @@ export interface TestInfo { * * ```js * import { test, expect } from '@playwright/test'; - * import fs from 'fs'; + * import * as fs from 'fs'; * * test('example test', async ({}, testInfo) => { * const file = testInfo.outputPath('dir', 'temporary-file.txt'); diff --git a/packages/trace-viewer/vite.config.ts b/packages/trace-viewer/vite.config.ts index 00b367bbc8..52b8b8322a 100644 --- a/packages/trace-viewer/vite.config.ts +++ b/packages/trace-viewer/vite.config.ts @@ -17,7 +17,7 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { bundle } from './bundle'; -import path from 'path'; +import * as path from 'path'; // https://vitejs.dev/config/ export default defineConfig({ diff --git a/packages/trace-viewer/vite.sw.config.ts b/packages/trace-viewer/vite.sw.config.ts index 60e90b96ac..3a6caaae32 100644 --- a/packages/trace-viewer/vite.sw.config.ts +++ b/packages/trace-viewer/vite.sw.config.ts @@ -17,7 +17,7 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { bundle } from './bundle'; -import path from 'path'; +import * as path from 'path'; // https://vitejs.dev/config/ export default defineConfig({ diff --git a/packages/trace/src/trace.ts b/packages/trace/src/trace.ts index 65843de1ec..54bb48c9da 100644 --- a/packages/trace/src/trace.ts +++ b/packages/trace/src/trace.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import type { Point, SerializedError, StackFrame } from '@protocol/channels'; -import type { Language } from '../../playwright-core/src/utils/isomorphic/locatorGenerators'; import type { FrameSnapshot, ResourceSnapshot } from './snapshot'; +import type { Language } from '../../playwright-core/src/utils/isomorphic/locatorGenerators'; +import type { Point, SerializedError, StackFrame } from '@protocol/channels'; export type Size = { width: number, height: number }; From 88c01434c64e48c1abbc6bdb14d95d3f33c48897 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Fri, 7 Feb 2025 14:53:28 -0800 Subject: [PATCH 04/11] chore: fix locator type check (#34682) --- packages/playwright-core/src/client/page.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.ts index c68435321a..12983f7b62 100644 --- a/packages/playwright-core/src/client/page.ts +++ b/packages/playwright-core/src/client/page.ts @@ -577,12 +577,13 @@ export class Page extends ChannelOwner implements api.Page await this._channel.setWebSocketInterceptionPatterns({ patterns }); } - async screenshot(options: Omit & { path?: string, mask?: Locator[] } = {}): Promise { + async screenshot(options: Omit & { path?: string, mask?: api.Locator[] } = {}): Promise { + const mask = options.mask as Locator[] | undefined; const copy: channels.PageScreenshotOptions = { ...options, mask: undefined }; if (!copy.type) copy.type = determineScreenshotType(options); - if (options.mask) { - copy.mask = options.mask.map(locator => ({ + if (mask) { + copy.mask = mask.map(locator => ({ frame: locator._frame._channel, selector: locator._selector, })); From f11ed1beabf51186350d12474173f88fb2499f27 Mon Sep 17 00:00:00 2001 From: Playwright Service <89237858+playwrightmachine@users.noreply.github.com> Date: Mon, 10 Feb 2025 00:12:07 -0800 Subject: [PATCH 05/11] feat(chromium-tip-of-tree): roll to r1301 (#34696) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- packages/playwright-core/browsers.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json index 2a160902f1..e7a5721c9f 100644 --- a/packages/playwright-core/browsers.json +++ b/packages/playwright-core/browsers.json @@ -15,15 +15,15 @@ }, { "name": "chromium-tip-of-tree", - "revision": "1300", + "revision": "1301", "installByDefault": false, - "browserVersion": "134.0.6998.0" + "browserVersion": "135.0.7000.0" }, { "name": "chromium-tip-of-tree-headless-shell", - "revision": "1300", + "revision": "1301", "installByDefault": false, - "browserVersion": "134.0.6998.0" + "browserVersion": "135.0.7000.0" }, { "name": "firefox", From a95186a373e27abfd69585a1fc0928d97bc1e22a Mon Sep 17 00:00:00 2001 From: Playwright Service <89237858+playwrightmachine@users.noreply.github.com> Date: Mon, 10 Feb 2025 00:12:50 -0800 Subject: [PATCH 06/11] feat(firefox): roll to r1475 (#34695) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- README.md | 4 ++-- packages/playwright-core/browsers.json | 4 ++-- .../playwright-core/src/server/deviceDescriptorsSource.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b0e9902352..e0fc77efcd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🎭 Playwright -[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) [![Chromium version](https://img.shields.io/badge/chromium-133.0.6943.35-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-134.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-18.2-blue.svg?logo=safari)](https://webkit.org/) [![Join Discord](https://img.shields.io/badge/join-discord-infomational)](https://aka.ms/playwright/discord) +[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) [![Chromium version](https://img.shields.io/badge/chromium-133.0.6943.35-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-135.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-18.2-blue.svg?logo=safari)](https://webkit.org/) [![Join Discord](https://img.shields.io/badge/join-discord-infomational)](https://aka.ms/playwright/discord) ## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright) @@ -10,7 +10,7 @@ Playwright is a framework for Web Testing and Automation. It allows testing [Chr | :--- | :---: | :---: | :---: | | Chromium 133.0.6943.35 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 18.2 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Firefox 134.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Firefox 135.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | Headless execution is supported for all browsers on all platforms. Check out [system requirements](https://playwright.dev/docs/intro#system-requirements) for details. diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json index e7a5721c9f..659c4cda42 100644 --- a/packages/playwright-core/browsers.json +++ b/packages/playwright-core/browsers.json @@ -27,9 +27,9 @@ }, { "name": "firefox", - "revision": "1474", + "revision": "1475", "installByDefault": true, - "browserVersion": "134.0" + "browserVersion": "135.0" }, { "name": "firefox-beta", diff --git a/packages/playwright-core/src/server/deviceDescriptorsSource.json b/packages/playwright-core/src/server/deviceDescriptorsSource.json index e5d6c93b57..9bc33c3644 100644 --- a/packages/playwright-core/src/server/deviceDescriptorsSource.json +++ b/packages/playwright-core/src/server/deviceDescriptorsSource.json @@ -1592,7 +1592,7 @@ "defaultBrowserType": "chromium" }, "Desktop Firefox HiDPI": { - "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0", + "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0", "screen": { "width": 1792, "height": 1120 @@ -1652,7 +1652,7 @@ "defaultBrowserType": "chromium" }, "Desktop Firefox": { - "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:134.0) Gecko/20100101 Firefox/134.0", + "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0", "screen": { "width": 1920, "height": 1080 From 4c8af0128f9af15c8b93acc4d08ff90b49c7ec9f Mon Sep 17 00:00:00 2001 From: Playwright Service <89237858+playwrightmachine@users.noreply.github.com> Date: Mon, 10 Feb 2025 03:33:37 -0800 Subject: [PATCH 07/11] feat(chromium): roll to r1158 (#34702) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Max Schmitt --- README.md | 4 +- packages/playwright-core/browsers.json | 8 +- .../src/server/chromium/protocol.d.ts | 222 ++++++++++-------- .../src/server/deviceDescriptorsSource.json | 96 ++++---- packages/playwright-core/types/protocol.d.ts | 222 ++++++++++-------- 5 files changed, 300 insertions(+), 252 deletions(-) diff --git a/README.md b/README.md index e0fc77efcd..f236eafd1a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🎭 Playwright -[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) [![Chromium version](https://img.shields.io/badge/chromium-133.0.6943.35-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-135.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-18.2-blue.svg?logo=safari)](https://webkit.org/) [![Join Discord](https://img.shields.io/badge/join-discord-infomational)](https://aka.ms/playwright/discord) +[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) [![Chromium version](https://img.shields.io/badge/chromium-134.0.6998.3-blue.svg?logo=google-chrome)](https://www.chromium.org/Home) [![Firefox version](https://img.shields.io/badge/firefox-135.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/) [![WebKit version](https://img.shields.io/badge/webkit-18.2-blue.svg?logo=safari)](https://webkit.org/) [![Join Discord](https://img.shields.io/badge/join-discord-infomational)](https://aka.ms/playwright/discord) ## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright) @@ -8,7 +8,7 @@ Playwright is a framework for Web Testing and Automation. It allows testing [Chr | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 133.0.6943.35 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Chromium 134.0.6998.3 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 18.2 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | Firefox 135.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json index 659c4cda42..2b7e019ac6 100644 --- a/packages/playwright-core/browsers.json +++ b/packages/playwright-core/browsers.json @@ -3,15 +3,15 @@ "browsers": [ { "name": "chromium", - "revision": "1157", + "revision": "1158", "installByDefault": true, - "browserVersion": "133.0.6943.35" + "browserVersion": "134.0.6998.3" }, { "name": "chromium-headless-shell", - "revision": "1157", + "revision": "1158", "installByDefault": true, - "browserVersion": "133.0.6943.35" + "browserVersion": "134.0.6998.3" }, { "name": "chromium-tip-of-tree", diff --git a/packages/playwright-core/src/server/chromium/protocol.d.ts b/packages/playwright-core/src/server/chromium/protocol.d.ts index fa1d6121f9..ebfd237d45 100644 --- a/packages/playwright-core/src/server/chromium/protocol.d.ts +++ b/packages/playwright-core/src/server/chromium/protocol.d.ts @@ -952,7 +952,7 @@ Should be updated alongside RequestIdTokenStatus in third_party/blink/public/mojom/devtools/inspector_issue.mojom to include all cases except for success. */ - export type FederatedAuthRequestIssueReason = "ShouldEmbargo"|"TooManyRequests"|"WellKnownHttpNotFound"|"WellKnownNoResponse"|"WellKnownInvalidResponse"|"WellKnownListEmpty"|"WellKnownInvalidContentType"|"ConfigNotInWellKnown"|"WellKnownTooBig"|"ConfigHttpNotFound"|"ConfigNoResponse"|"ConfigInvalidResponse"|"ConfigInvalidContentType"|"ClientMetadataHttpNotFound"|"ClientMetadataNoResponse"|"ClientMetadataInvalidResponse"|"ClientMetadataInvalidContentType"|"IdpNotPotentiallyTrustworthy"|"DisabledInSettings"|"DisabledInFlags"|"ErrorFetchingSignin"|"InvalidSigninResponse"|"AccountsHttpNotFound"|"AccountsNoResponse"|"AccountsInvalidResponse"|"AccountsListEmpty"|"AccountsInvalidContentType"|"IdTokenHttpNotFound"|"IdTokenNoResponse"|"IdTokenInvalidResponse"|"IdTokenIdpErrorResponse"|"IdTokenCrossSiteIdpErrorResponse"|"IdTokenInvalidRequest"|"IdTokenInvalidContentType"|"ErrorIdToken"|"Canceled"|"RpPageNotVisible"|"SilentMediationFailure"|"ThirdPartyCookiesBlocked"|"NotSignedInWithIdp"|"MissingTransientUserActivation"|"ReplacedByActiveMode"|"InvalidFieldsSpecified"|"RelyingPartyOriginIsOpaque"|"TypeNotMatching"; + export type FederatedAuthRequestIssueReason = "ShouldEmbargo"|"TooManyRequests"|"WellKnownHttpNotFound"|"WellKnownNoResponse"|"WellKnownInvalidResponse"|"WellKnownListEmpty"|"WellKnownInvalidContentType"|"ConfigNotInWellKnown"|"WellKnownTooBig"|"ConfigHttpNotFound"|"ConfigNoResponse"|"ConfigInvalidResponse"|"ConfigInvalidContentType"|"ClientMetadataHttpNotFound"|"ClientMetadataNoResponse"|"ClientMetadataInvalidResponse"|"ClientMetadataInvalidContentType"|"IdpNotPotentiallyTrustworthy"|"DisabledInSettings"|"DisabledInFlags"|"ErrorFetchingSignin"|"InvalidSigninResponse"|"AccountsHttpNotFound"|"AccountsNoResponse"|"AccountsInvalidResponse"|"AccountsListEmpty"|"AccountsInvalidContentType"|"IdTokenHttpNotFound"|"IdTokenNoResponse"|"IdTokenInvalidResponse"|"IdTokenIdpErrorResponse"|"IdTokenCrossSiteIdpErrorResponse"|"IdTokenInvalidRequest"|"IdTokenInvalidContentType"|"ErrorIdToken"|"Canceled"|"RpPageNotVisible"|"SilentMediationFailure"|"ThirdPartyCookiesBlocked"|"NotSignedInWithIdp"|"MissingTransientUserActivation"|"ReplacedByActiveMode"|"InvalidFieldsSpecified"|"RelyingPartyOriginIsOpaque"|"TypeNotMatching"|"UiDismissedNoEmbargo"; export interface FederatedAuthUserInfoRequestIssueDetails { federatedAuthUserInfoRequestIssueReason: FederatedAuthUserInfoRequestIssueReason; } @@ -983,7 +983,7 @@ features, encourage the use of new ones, and provide general guidance. } export type SelectElementAccessibilityIssueReason = "DisallowedSelectChild"|"DisallowedOptGroupChild"|"NonPhrasingContentOptionChild"|"InteractiveContentOptionChild"|"InteractiveContentLegendChild"; /** - * This isue warns about errors in the select element content model. + * This issue warns about errors in the select element content model. */ export interface SelectElementAccessibilityIssueDetails { nodeId: DOM.BackendNodeId; @@ -1187,6 +1187,19 @@ flag is set. */ id: string; } + /** + * Uninstalls an unpacked extension (others not supported) from the profile. +Available if the client is connected using the --remote-debugging-pipe flag +and the --enable-unsafe-extension-debugging. + */ + export type uninstallParameters = { + /** + * Extension id. + */ + id: string; + } + export type uninstallReturnValue = { + } /** * Gets data from extension storage in the given `storageArea`. If `keys` is specified, these are used to filter the result. @@ -2913,6 +2926,13 @@ incorrect results if the declaration contains a var() for example. * Identifier of the frame where "via-inspector" stylesheet should be created. */ frameId: Page.FrameId; + /** + * If true, creates a new stylesheet for every call. If false, +returns a stylesheet previously created by a call with force=false +for the frame's document if it exists or creates a new stylesheet +(default: false). + */ + force?: boolean; } export type createStyleSheetReturnValue = { /** @@ -5974,81 +5994,6 @@ The final text color opacity is computed based on the opacity of all overlapping } } - export module Database { - /** - * Unique identifier of Database object. - */ - export type DatabaseId = string; - /** - * Database object. - */ - export interface Database { - /** - * Database ID. - */ - id: DatabaseId; - /** - * Database domain. - */ - domain: string; - /** - * Database name. - */ - name: string; - /** - * Database version. - */ - version: string; - } - /** - * Database error. - */ - export interface Error { - /** - * Error message. - */ - message: string; - /** - * Error code. - */ - code: number; - } - - export type addDatabasePayload = { - database: Database; - } - - /** - * Disables database tracking, prevents database events from being sent to the client. - */ - export type disableParameters = { - } - export type disableReturnValue = { - } - /** - * Enables database tracking, database events will now be delivered to the client. - */ - export type enableParameters = { - } - export type enableReturnValue = { - } - export type executeSQLParameters = { - databaseId: DatabaseId; - query: string; - } - export type executeSQLReturnValue = { - columnNames?: string[]; - values?: any[]; - sqlError?: Error; - } - export type getDatabaseTableNamesParameters = { - databaseId: DatabaseId; - } - export type getDatabaseTableNamesReturnValue = { - tableNames: string[]; - } - } - export module DeviceOrientation { @@ -9126,7 +9071,7 @@ This is a temporary ability and it will be removed in the future. /** * Types of reasons why a cookie should have been blocked by 3PCD but is exempted for the request. */ - export type CookieExemptionReason = "None"|"UserSetting"|"TPCDMetadata"|"TPCDDeprecationTrial"|"TopLevelTPCDDeprecationTrial"|"TPCDHeuristics"|"EnterprisePolicy"|"StorageAccess"|"TopLevelStorageAccess"|"Scheme"; + export type CookieExemptionReason = "None"|"UserSetting"|"TPCDMetadata"|"TPCDDeprecationTrial"|"TopLevelTPCDDeprecationTrial"|"TPCDHeuristics"|"EnterprisePolicy"|"StorageAccess"|"TopLevelStorageAccess"|"Scheme"|"SameSiteNoneCookiesInSandbox"; /** * A cookie which was not stored from a response with the corresponding reason. */ @@ -11702,7 +11647,7 @@ as an ad. * All Permissions Policy features. This enum should match the one defined in third_party/blink/renderer/core/permissions_policy/permissions_policy_features.json5. */ - export type PermissionsPolicyFeature = "accelerometer"|"all-screens-capture"|"ambient-light-sensor"|"attribution-reporting"|"autoplay"|"bluetooth"|"browsing-topics"|"camera"|"captured-surface-control"|"ch-dpr"|"ch-device-memory"|"ch-downlink"|"ch-ect"|"ch-prefers-color-scheme"|"ch-prefers-reduced-motion"|"ch-prefers-reduced-transparency"|"ch-rtt"|"ch-save-data"|"ch-ua"|"ch-ua-arch"|"ch-ua-bitness"|"ch-ua-platform"|"ch-ua-model"|"ch-ua-mobile"|"ch-ua-form-factors"|"ch-ua-full-version"|"ch-ua-full-version-list"|"ch-ua-platform-version"|"ch-ua-wow64"|"ch-viewport-height"|"ch-viewport-width"|"ch-width"|"clipboard-read"|"clipboard-write"|"compute-pressure"|"controlled-frame"|"cross-origin-isolated"|"deferred-fetch"|"deferred-fetch-minimal"|"digital-credentials-get"|"direct-sockets"|"direct-sockets-private"|"display-capture"|"document-domain"|"encrypted-media"|"execution-while-out-of-viewport"|"execution-while-not-rendered"|"fenced-unpartitioned-storage-read"|"focus-without-user-activation"|"fullscreen"|"frobulate"|"gamepad"|"geolocation"|"gyroscope"|"hid"|"identity-credentials-get"|"idle-detection"|"interest-cohort"|"join-ad-interest-group"|"keyboard-map"|"local-fonts"|"magnetometer"|"media-playback-while-not-visible"|"microphone"|"midi"|"otp-credentials"|"payment"|"picture-in-picture"|"popins"|"private-aggregation"|"private-state-token-issuance"|"private-state-token-redemption"|"publickey-credentials-create"|"publickey-credentials-get"|"run-ad-auction"|"screen-wake-lock"|"serial"|"shared-autofill"|"shared-storage"|"shared-storage-select-url"|"smart-card"|"speaker-selection"|"storage-access"|"sub-apps"|"sync-xhr"|"unload"|"usb"|"usb-unrestricted"|"vertical-scroll"|"web-app-installation"|"web-printing"|"web-share"|"window-management"|"xr-spatial-tracking"; + export type PermissionsPolicyFeature = "accelerometer"|"all-screens-capture"|"ambient-light-sensor"|"attribution-reporting"|"autoplay"|"bluetooth"|"browsing-topics"|"camera"|"captured-surface-control"|"ch-dpr"|"ch-device-memory"|"ch-downlink"|"ch-ect"|"ch-prefers-color-scheme"|"ch-prefers-reduced-motion"|"ch-prefers-reduced-transparency"|"ch-rtt"|"ch-save-data"|"ch-ua"|"ch-ua-arch"|"ch-ua-bitness"|"ch-ua-high-entropy-values"|"ch-ua-platform"|"ch-ua-model"|"ch-ua-mobile"|"ch-ua-form-factors"|"ch-ua-full-version"|"ch-ua-full-version-list"|"ch-ua-platform-version"|"ch-ua-wow64"|"ch-viewport-height"|"ch-viewport-width"|"ch-width"|"clipboard-read"|"clipboard-write"|"compute-pressure"|"controlled-frame"|"cross-origin-isolated"|"deferred-fetch"|"deferred-fetch-minimal"|"digital-credentials-get"|"direct-sockets"|"direct-sockets-private"|"display-capture"|"document-domain"|"encrypted-media"|"execution-while-out-of-viewport"|"execution-while-not-rendered"|"fenced-unpartitioned-storage-read"|"focus-without-user-activation"|"fullscreen"|"frobulate"|"gamepad"|"geolocation"|"gyroscope"|"hid"|"identity-credentials-get"|"idle-detection"|"interest-cohort"|"join-ad-interest-group"|"keyboard-map"|"local-fonts"|"magnetometer"|"media-playback-while-not-visible"|"microphone"|"midi"|"otp-credentials"|"payment"|"picture-in-picture"|"popins"|"private-aggregation"|"private-state-token-issuance"|"private-state-token-redemption"|"publickey-credentials-create"|"publickey-credentials-get"|"run-ad-auction"|"screen-wake-lock"|"serial"|"shared-autofill"|"shared-storage"|"shared-storage-select-url"|"smart-card"|"speaker-selection"|"storage-access"|"sub-apps"|"sync-xhr"|"unload"|"usb"|"usb-unrestricted"|"vertical-scroll"|"web-app-installation"|"web-printing"|"web-share"|"window-management"|"xr-spatial-tracking"; /** * Reason for a permissions policy feature to be disabled. */ @@ -12431,6 +12376,33 @@ subtree is actually detached. frame: Frame; } export type frameResizedPayload = void; + /** + * Fired when a navigation starts. This event is fired for both +renderer-initiated and browser-initiated navigations. For renderer-initiated +navigations, the event is fired after `frameRequestedNavigation`. +Navigation may still be cancelled after the event is issued. Multiple events +can be fired for a single navigation, for example, when a same-document +navigation becomes a cross-document navigation (such as in the case of a +frameset). + */ + export type frameStartedNavigatingPayload = { + /** + * ID of the frame that is being navigated. + */ + frameId: FrameId; + /** + * The URL the navigation started with. The final URL can be different. + */ + url: string; + /** + * Loader identifier. Even though it is present in case of same-document +navigation, the previously committed loaderId would not change unless +the navigation changes from a same-document to a cross-document +navigation. + */ + loaderId: Network.LoaderId; + navigationType: "reload"|"reloadBypassingCache"|"restore"|"restoreWithPost"|"historySameDocument"|"historyDifferentDocument"|"sameDocument"|"differentDocument"; + } /** * Fired when a renderer-initiated navigation is requested. Navigation may still be cancelled after the event is issued. @@ -14281,7 +14253,7 @@ For cached script it is the last time the cache entry was validated. /** * Enum of possible storage types. */ - export type StorageType = "appcache"|"cookies"|"file_systems"|"indexeddb"|"local_storage"|"shader_cache"|"websql"|"service_workers"|"cache_storage"|"interest_groups"|"shared_storage"|"storage_buckets"|"all"|"other"; + export type StorageType = "cookies"|"file_systems"|"indexeddb"|"local_storage"|"shader_cache"|"websql"|"service_workers"|"cache_storage"|"interest_groups"|"shared_storage"|"storage_buckets"|"all"|"other"; /** * Usage for a storage type. */ @@ -15193,6 +15165,28 @@ session. The effective Related Website Sets will not change during a browser ses export type getRelatedWebsiteSetsReturnValue = { sets: RelatedWebsiteSet[]; } + /** + * Returns the list of URLs from a page and its embedded resources that match +existing grace period URL pattern rules. +https://developers.google.com/privacy-sandbox/cookies/temporary-exceptions/grace-period + */ + export type getAffectedUrlsForThirdPartyCookieMetadataParameters = { + /** + * The URL of the page currently being visited. + */ + firstPartyUrl: string; + /** + * The list of embedded resource URLs from the page. + */ + thirdPartyUrls: string[]; + } + export type getAffectedUrlsForThirdPartyCookieMetadataReturnValue = { + /** + * Array of matching URLs. If there is a primary pattern match for the first- +party URL, only the first-party URL is returned in the array. + */ + matchedUrls: string[]; + } } /** @@ -15485,6 +15479,10 @@ If filter is not specified, the one assumed is host: string; port: number; } + /** + * The state of the target window. + */ + export type WindowState = "normal"|"minimized"|"maximized"|"fullscreen"; /** * Issued when attached to target because of auto-attach or `attachToTarget` command. @@ -15677,37 +15675,42 @@ Parts of the URL other than those constituting origin are ignored. */ url: string; /** - * Frame left origin in DIP (headless chrome only). + * Frame left origin in DIP (requires newWindow to be true or headless shell). */ left?: number; /** - * Frame top origin in DIP (headless chrome only). + * Frame top origin in DIP (requires newWindow to be true or headless shell). */ top?: number; /** - * Frame width in DIP (headless chrome only). + * Frame width in DIP (requires newWindow to be true or headless shell). */ width?: number; /** - * Frame height in DIP (headless chrome only). + * Frame height in DIP (requires newWindow to be true or headless shell). */ height?: number; + /** + * Frame window state (requires newWindow to be true or headless shell). +Default is normal. + */ + windowState?: WindowState; /** * The browser context to create the page in. */ browserContextId?: Browser.BrowserContextID; /** - * Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, + * Whether BeginFrames for this target will be controlled via DevTools (headless shell only, not supported on MacOS yet, false by default). */ enableBeginFrameControl?: boolean; /** - * Whether to create a new Window or Tab (chrome-only, false by default). + * Whether to create a new Window or Tab (false by default, not supported by headless shell). */ newWindow?: boolean; /** - * Whether to create the target in background or foreground (chrome-only, -false by default). + * Whether to create the target in background or foreground (false by default, not supported +by headless shell). */ background?: boolean; /** @@ -18012,9 +18015,20 @@ variables as its properties. */ externalURL?: string; } + export interface ResolvedBreakpoint { + /** + * Breakpoint unique identifier. + */ + breakpointId: BreakpointId; + /** + * Actual breakpoint location. + */ + location: Location; + } /** * Fired when breakpoint is resolved to an actual script and location. +Deprecated in favor of `resolvedBreakpoints` in the `scriptParsed` event. */ export type breakpointResolvedPayload = { /** @@ -18225,6 +18239,12 @@ scripts upon enabling debugger. * The name the embedder supplied for this script. */ embedderName?: string; + /** + * The list of set breakpoints in this script if calls to `setBreakpointByUrl` +matches this script's URL or hash. Clients that use this list can ignore the +`breakpointResolved` event. They are equivalent. + */ + resolvedBreakpoints?: ResolvedBreakpoint[]; } /** @@ -20150,13 +20170,21 @@ It is the total usage of the corresponding isolate not scoped to a particular Ru } export type getHeapUsageReturnValue = { /** - * Used heap size in bytes. + * Used JavaScript heap size in bytes. */ usedSize: number; /** - * Allocated heap size in bytes. + * Allocated JavaScript heap size in bytes. */ totalSize: number; + /** + * Used size in bytes in the embedder's garbage-collected heap. + */ + embedderHeapUsedSize: number; + /** + * Size in bytes of backing storage for array buffers and external strings. + */ + backingStorageSize: number; } /** * Returns properties of a given object. Object group of the result is inherited from the target @@ -20472,7 +20500,6 @@ Error was thrown. "DOMStorage.domStorageItemRemoved": DOMStorage.domStorageItemRemovedPayload; "DOMStorage.domStorageItemUpdated": DOMStorage.domStorageItemUpdatedPayload; "DOMStorage.domStorageItemsCleared": DOMStorage.domStorageItemsClearedPayload; - "Database.addDatabase": Database.addDatabasePayload; "Emulation.virtualTimeBudgetExpired": Emulation.virtualTimeBudgetExpiredPayload; "Input.dragIntercepted": Input.dragInterceptedPayload; "Inspector.detached": Inspector.detachedPayload; @@ -20526,6 +20553,7 @@ Error was thrown. "Page.frameNavigated": Page.frameNavigatedPayload; "Page.documentOpened": Page.documentOpenedPayload; "Page.frameResized": Page.frameResizedPayload; + "Page.frameStartedNavigating": Page.frameStartedNavigatingPayload; "Page.frameRequestedNavigation": Page.frameRequestedNavigationPayload; "Page.frameScheduledNavigation": Page.frameScheduledNavigationPayload; "Page.frameStartedLoading": Page.frameStartedLoadingPayload; @@ -20656,6 +20684,7 @@ Error was thrown. "Audits.checkContrast": Audits.checkContrastParameters; "Audits.checkFormsIssues": Audits.checkFormsIssuesParameters; "Extensions.loadUnpacked": Extensions.loadUnpackedParameters; + "Extensions.uninstall": Extensions.uninstallParameters; "Extensions.getStorageItems": Extensions.getStorageItemsParameters; "Extensions.removeStorageItems": Extensions.removeStorageItemsParameters; "Extensions.clearStorageItems": Extensions.clearStorageItemsParameters; @@ -20808,10 +20837,6 @@ Error was thrown. "DOMStorage.getDOMStorageItems": DOMStorage.getDOMStorageItemsParameters; "DOMStorage.removeDOMStorageItem": DOMStorage.removeDOMStorageItemParameters; "DOMStorage.setDOMStorageItem": DOMStorage.setDOMStorageItemParameters; - "Database.disable": Database.disableParameters; - "Database.enable": Database.enableParameters; - "Database.executeSQL": Database.executeSQLParameters; - "Database.getDatabaseTableNames": Database.getDatabaseTableNamesParameters; "DeviceOrientation.clearDeviceOrientationOverride": DeviceOrientation.clearDeviceOrientationOverrideParameters; "DeviceOrientation.setDeviceOrientationOverride": DeviceOrientation.setDeviceOrientationOverrideParameters; "Emulation.canEmulate": Emulation.canEmulateParameters; @@ -21088,6 +21113,7 @@ Error was thrown. "Storage.setAttributionReportingTracking": Storage.setAttributionReportingTrackingParameters; "Storage.sendPendingAttributionReports": Storage.sendPendingAttributionReportsParameters; "Storage.getRelatedWebsiteSets": Storage.getRelatedWebsiteSetsParameters; + "Storage.getAffectedUrlsForThirdPartyCookieMetadata": Storage.getAffectedUrlsForThirdPartyCookieMetadataParameters; "SystemInfo.getInfo": SystemInfo.getInfoParameters; "SystemInfo.getFeatureState": SystemInfo.getFeatureStateParameters; "SystemInfo.getProcessInfo": SystemInfo.getProcessInfoParameters; @@ -21273,6 +21299,7 @@ Error was thrown. "Audits.checkContrast": Audits.checkContrastReturnValue; "Audits.checkFormsIssues": Audits.checkFormsIssuesReturnValue; "Extensions.loadUnpacked": Extensions.loadUnpackedReturnValue; + "Extensions.uninstall": Extensions.uninstallReturnValue; "Extensions.getStorageItems": Extensions.getStorageItemsReturnValue; "Extensions.removeStorageItems": Extensions.removeStorageItemsReturnValue; "Extensions.clearStorageItems": Extensions.clearStorageItemsReturnValue; @@ -21425,10 +21452,6 @@ Error was thrown. "DOMStorage.getDOMStorageItems": DOMStorage.getDOMStorageItemsReturnValue; "DOMStorage.removeDOMStorageItem": DOMStorage.removeDOMStorageItemReturnValue; "DOMStorage.setDOMStorageItem": DOMStorage.setDOMStorageItemReturnValue; - "Database.disable": Database.disableReturnValue; - "Database.enable": Database.enableReturnValue; - "Database.executeSQL": Database.executeSQLReturnValue; - "Database.getDatabaseTableNames": Database.getDatabaseTableNamesReturnValue; "DeviceOrientation.clearDeviceOrientationOverride": DeviceOrientation.clearDeviceOrientationOverrideReturnValue; "DeviceOrientation.setDeviceOrientationOverride": DeviceOrientation.setDeviceOrientationOverrideReturnValue; "Emulation.canEmulate": Emulation.canEmulateReturnValue; @@ -21705,6 +21728,7 @@ Error was thrown. "Storage.setAttributionReportingTracking": Storage.setAttributionReportingTrackingReturnValue; "Storage.sendPendingAttributionReports": Storage.sendPendingAttributionReportsReturnValue; "Storage.getRelatedWebsiteSets": Storage.getRelatedWebsiteSetsReturnValue; + "Storage.getAffectedUrlsForThirdPartyCookieMetadata": Storage.getAffectedUrlsForThirdPartyCookieMetadataReturnValue; "SystemInfo.getInfo": SystemInfo.getInfoReturnValue; "SystemInfo.getFeatureState": SystemInfo.getFeatureStateReturnValue; "SystemInfo.getProcessInfo": SystemInfo.getProcessInfoReturnValue; diff --git a/packages/playwright-core/src/server/deviceDescriptorsSource.json b/packages/playwright-core/src/server/deviceDescriptorsSource.json index 9bc33c3644..1e6d0be7b8 100644 --- a/packages/playwright-core/src/server/deviceDescriptorsSource.json +++ b/packages/playwright-core/src/server/deviceDescriptorsSource.json @@ -110,7 +110,7 @@ "defaultBrowserType": "webkit" }, "Galaxy S5": { - "userAgent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 360, "height": 640 @@ -121,7 +121,7 @@ "defaultBrowserType": "chromium" }, "Galaxy S5 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 640, "height": 360 @@ -132,7 +132,7 @@ "defaultBrowserType": "chromium" }, "Galaxy S8": { - "userAgent": "Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 360, "height": 740 @@ -143,7 +143,7 @@ "defaultBrowserType": "chromium" }, "Galaxy S8 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 740, "height": 360 @@ -154,7 +154,7 @@ "defaultBrowserType": "chromium" }, "Galaxy S9+": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 320, "height": 658 @@ -165,7 +165,7 @@ "defaultBrowserType": "chromium" }, "Galaxy S9+ landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 658, "height": 320 @@ -176,7 +176,7 @@ "defaultBrowserType": "chromium" }, "Galaxy Tab S4": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36", "viewport": { "width": 712, "height": 1138 @@ -187,7 +187,7 @@ "defaultBrowserType": "chromium" }, "Galaxy Tab S4 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36", "viewport": { "width": 1138, "height": 712 @@ -1098,7 +1098,7 @@ "defaultBrowserType": "webkit" }, "LG Optimus L70": { - "userAgent": "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 384, "height": 640 @@ -1109,7 +1109,7 @@ "defaultBrowserType": "chromium" }, "LG Optimus L70 landscape": { - "userAgent": "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 640, "height": 384 @@ -1120,7 +1120,7 @@ "defaultBrowserType": "chromium" }, "Microsoft Lumia 550": { - "userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36 Edge/14.14263", + "userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36 Edge/14.14263", "viewport": { "width": 360, "height": 640 @@ -1131,7 +1131,7 @@ "defaultBrowserType": "chromium" }, "Microsoft Lumia 550 landscape": { - "userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36 Edge/14.14263", + "userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36 Edge/14.14263", "viewport": { "width": 640, "height": 360 @@ -1142,7 +1142,7 @@ "defaultBrowserType": "chromium" }, "Microsoft Lumia 950": { - "userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36 Edge/14.14263", + "userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36 Edge/14.14263", "viewport": { "width": 360, "height": 640 @@ -1153,7 +1153,7 @@ "defaultBrowserType": "chromium" }, "Microsoft Lumia 950 landscape": { - "userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36 Edge/14.14263", + "userAgent": "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36 Edge/14.14263", "viewport": { "width": 640, "height": 360 @@ -1164,7 +1164,7 @@ "defaultBrowserType": "chromium" }, "Nexus 10": { - "userAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36", "viewport": { "width": 800, "height": 1280 @@ -1175,7 +1175,7 @@ "defaultBrowserType": "chromium" }, "Nexus 10 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36", "viewport": { "width": 1280, "height": 800 @@ -1186,7 +1186,7 @@ "defaultBrowserType": "chromium" }, "Nexus 4": { - "userAgent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 384, "height": 640 @@ -1197,7 +1197,7 @@ "defaultBrowserType": "chromium" }, "Nexus 4 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 640, "height": 384 @@ -1208,7 +1208,7 @@ "defaultBrowserType": "chromium" }, "Nexus 5": { - "userAgent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 360, "height": 640 @@ -1219,7 +1219,7 @@ "defaultBrowserType": "chromium" }, "Nexus 5 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 640, "height": 360 @@ -1230,7 +1230,7 @@ "defaultBrowserType": "chromium" }, "Nexus 5X": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 412, "height": 732 @@ -1241,7 +1241,7 @@ "defaultBrowserType": "chromium" }, "Nexus 5X landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 732, "height": 412 @@ -1252,7 +1252,7 @@ "defaultBrowserType": "chromium" }, "Nexus 6": { - "userAgent": "Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 412, "height": 732 @@ -1263,7 +1263,7 @@ "defaultBrowserType": "chromium" }, "Nexus 6 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 732, "height": 412 @@ -1274,7 +1274,7 @@ "defaultBrowserType": "chromium" }, "Nexus 6P": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 412, "height": 732 @@ -1285,7 +1285,7 @@ "defaultBrowserType": "chromium" }, "Nexus 6P landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 732, "height": 412 @@ -1296,7 +1296,7 @@ "defaultBrowserType": "chromium" }, "Nexus 7": { - "userAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36", "viewport": { "width": 600, "height": 960 @@ -1307,7 +1307,7 @@ "defaultBrowserType": "chromium" }, "Nexus 7 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36", "viewport": { "width": 960, "height": 600 @@ -1362,7 +1362,7 @@ "defaultBrowserType": "webkit" }, "Pixel 2": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 411, "height": 731 @@ -1373,7 +1373,7 @@ "defaultBrowserType": "chromium" }, "Pixel 2 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 731, "height": 411 @@ -1384,7 +1384,7 @@ "defaultBrowserType": "chromium" }, "Pixel 2 XL": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 411, "height": 823 @@ -1395,7 +1395,7 @@ "defaultBrowserType": "chromium" }, "Pixel 2 XL landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 823, "height": 411 @@ -1406,7 +1406,7 @@ "defaultBrowserType": "chromium" }, "Pixel 3": { - "userAgent": "Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 393, "height": 786 @@ -1417,7 +1417,7 @@ "defaultBrowserType": "chromium" }, "Pixel 3 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 786, "height": 393 @@ -1428,7 +1428,7 @@ "defaultBrowserType": "chromium" }, "Pixel 4": { - "userAgent": "Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 353, "height": 745 @@ -1439,7 +1439,7 @@ "defaultBrowserType": "chromium" }, "Pixel 4 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 745, "height": 353 @@ -1450,7 +1450,7 @@ "defaultBrowserType": "chromium" }, "Pixel 4a (5G)": { - "userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "screen": { "width": 412, "height": 892 @@ -1465,7 +1465,7 @@ "defaultBrowserType": "chromium" }, "Pixel 4a (5G) landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "screen": { "height": 892, "width": 412 @@ -1480,7 +1480,7 @@ "defaultBrowserType": "chromium" }, "Pixel 5": { - "userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "screen": { "width": 393, "height": 851 @@ -1495,7 +1495,7 @@ "defaultBrowserType": "chromium" }, "Pixel 5 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "screen": { "width": 851, "height": 393 @@ -1510,7 +1510,7 @@ "defaultBrowserType": "chromium" }, "Pixel 7": { - "userAgent": "Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "screen": { "width": 412, "height": 915 @@ -1525,7 +1525,7 @@ "defaultBrowserType": "chromium" }, "Pixel 7 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "screen": { "width": 915, "height": 412 @@ -1540,7 +1540,7 @@ "defaultBrowserType": "chromium" }, "Moto G4": { - "userAgent": "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 360, "height": 640 @@ -1551,7 +1551,7 @@ "defaultBrowserType": "chromium" }, "Moto G4 landscape": { - "userAgent": "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Mobile Safari/537.36", + "userAgent": "Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Mobile Safari/537.36", "viewport": { "width": 640, "height": 360 @@ -1562,7 +1562,7 @@ "defaultBrowserType": "chromium" }, "Desktop Chrome HiDPI": { - "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36", + "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36", "screen": { "width": 1792, "height": 1120 @@ -1577,7 +1577,7 @@ "defaultBrowserType": "chromium" }, "Desktop Edge HiDPI": { - "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36 Edg/133.0.6943.35", + "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36 Edg/134.0.6998.3", "screen": { "width": 1792, "height": 1120 @@ -1622,7 +1622,7 @@ "defaultBrowserType": "webkit" }, "Desktop Chrome": { - "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36", + "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36", "screen": { "width": 1920, "height": 1080 @@ -1637,7 +1637,7 @@ "defaultBrowserType": "chromium" }, "Desktop Edge": { - "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.6943.35 Safari/537.36 Edg/133.0.6943.35", + "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.6998.3 Safari/537.36 Edg/134.0.6998.3", "screen": { "width": 1920, "height": 1080 diff --git a/packages/playwright-core/types/protocol.d.ts b/packages/playwright-core/types/protocol.d.ts index fa1d6121f9..ebfd237d45 100644 --- a/packages/playwright-core/types/protocol.d.ts +++ b/packages/playwright-core/types/protocol.d.ts @@ -952,7 +952,7 @@ Should be updated alongside RequestIdTokenStatus in third_party/blink/public/mojom/devtools/inspector_issue.mojom to include all cases except for success. */ - export type FederatedAuthRequestIssueReason = "ShouldEmbargo"|"TooManyRequests"|"WellKnownHttpNotFound"|"WellKnownNoResponse"|"WellKnownInvalidResponse"|"WellKnownListEmpty"|"WellKnownInvalidContentType"|"ConfigNotInWellKnown"|"WellKnownTooBig"|"ConfigHttpNotFound"|"ConfigNoResponse"|"ConfigInvalidResponse"|"ConfigInvalidContentType"|"ClientMetadataHttpNotFound"|"ClientMetadataNoResponse"|"ClientMetadataInvalidResponse"|"ClientMetadataInvalidContentType"|"IdpNotPotentiallyTrustworthy"|"DisabledInSettings"|"DisabledInFlags"|"ErrorFetchingSignin"|"InvalidSigninResponse"|"AccountsHttpNotFound"|"AccountsNoResponse"|"AccountsInvalidResponse"|"AccountsListEmpty"|"AccountsInvalidContentType"|"IdTokenHttpNotFound"|"IdTokenNoResponse"|"IdTokenInvalidResponse"|"IdTokenIdpErrorResponse"|"IdTokenCrossSiteIdpErrorResponse"|"IdTokenInvalidRequest"|"IdTokenInvalidContentType"|"ErrorIdToken"|"Canceled"|"RpPageNotVisible"|"SilentMediationFailure"|"ThirdPartyCookiesBlocked"|"NotSignedInWithIdp"|"MissingTransientUserActivation"|"ReplacedByActiveMode"|"InvalidFieldsSpecified"|"RelyingPartyOriginIsOpaque"|"TypeNotMatching"; + export type FederatedAuthRequestIssueReason = "ShouldEmbargo"|"TooManyRequests"|"WellKnownHttpNotFound"|"WellKnownNoResponse"|"WellKnownInvalidResponse"|"WellKnownListEmpty"|"WellKnownInvalidContentType"|"ConfigNotInWellKnown"|"WellKnownTooBig"|"ConfigHttpNotFound"|"ConfigNoResponse"|"ConfigInvalidResponse"|"ConfigInvalidContentType"|"ClientMetadataHttpNotFound"|"ClientMetadataNoResponse"|"ClientMetadataInvalidResponse"|"ClientMetadataInvalidContentType"|"IdpNotPotentiallyTrustworthy"|"DisabledInSettings"|"DisabledInFlags"|"ErrorFetchingSignin"|"InvalidSigninResponse"|"AccountsHttpNotFound"|"AccountsNoResponse"|"AccountsInvalidResponse"|"AccountsListEmpty"|"AccountsInvalidContentType"|"IdTokenHttpNotFound"|"IdTokenNoResponse"|"IdTokenInvalidResponse"|"IdTokenIdpErrorResponse"|"IdTokenCrossSiteIdpErrorResponse"|"IdTokenInvalidRequest"|"IdTokenInvalidContentType"|"ErrorIdToken"|"Canceled"|"RpPageNotVisible"|"SilentMediationFailure"|"ThirdPartyCookiesBlocked"|"NotSignedInWithIdp"|"MissingTransientUserActivation"|"ReplacedByActiveMode"|"InvalidFieldsSpecified"|"RelyingPartyOriginIsOpaque"|"TypeNotMatching"|"UiDismissedNoEmbargo"; export interface FederatedAuthUserInfoRequestIssueDetails { federatedAuthUserInfoRequestIssueReason: FederatedAuthUserInfoRequestIssueReason; } @@ -983,7 +983,7 @@ features, encourage the use of new ones, and provide general guidance. } export type SelectElementAccessibilityIssueReason = "DisallowedSelectChild"|"DisallowedOptGroupChild"|"NonPhrasingContentOptionChild"|"InteractiveContentOptionChild"|"InteractiveContentLegendChild"; /** - * This isue warns about errors in the select element content model. + * This issue warns about errors in the select element content model. */ export interface SelectElementAccessibilityIssueDetails { nodeId: DOM.BackendNodeId; @@ -1187,6 +1187,19 @@ flag is set. */ id: string; } + /** + * Uninstalls an unpacked extension (others not supported) from the profile. +Available if the client is connected using the --remote-debugging-pipe flag +and the --enable-unsafe-extension-debugging. + */ + export type uninstallParameters = { + /** + * Extension id. + */ + id: string; + } + export type uninstallReturnValue = { + } /** * Gets data from extension storage in the given `storageArea`. If `keys` is specified, these are used to filter the result. @@ -2913,6 +2926,13 @@ incorrect results if the declaration contains a var() for example. * Identifier of the frame where "via-inspector" stylesheet should be created. */ frameId: Page.FrameId; + /** + * If true, creates a new stylesheet for every call. If false, +returns a stylesheet previously created by a call with force=false +for the frame's document if it exists or creates a new stylesheet +(default: false). + */ + force?: boolean; } export type createStyleSheetReturnValue = { /** @@ -5974,81 +5994,6 @@ The final text color opacity is computed based on the opacity of all overlapping } } - export module Database { - /** - * Unique identifier of Database object. - */ - export type DatabaseId = string; - /** - * Database object. - */ - export interface Database { - /** - * Database ID. - */ - id: DatabaseId; - /** - * Database domain. - */ - domain: string; - /** - * Database name. - */ - name: string; - /** - * Database version. - */ - version: string; - } - /** - * Database error. - */ - export interface Error { - /** - * Error message. - */ - message: string; - /** - * Error code. - */ - code: number; - } - - export type addDatabasePayload = { - database: Database; - } - - /** - * Disables database tracking, prevents database events from being sent to the client. - */ - export type disableParameters = { - } - export type disableReturnValue = { - } - /** - * Enables database tracking, database events will now be delivered to the client. - */ - export type enableParameters = { - } - export type enableReturnValue = { - } - export type executeSQLParameters = { - databaseId: DatabaseId; - query: string; - } - export type executeSQLReturnValue = { - columnNames?: string[]; - values?: any[]; - sqlError?: Error; - } - export type getDatabaseTableNamesParameters = { - databaseId: DatabaseId; - } - export type getDatabaseTableNamesReturnValue = { - tableNames: string[]; - } - } - export module DeviceOrientation { @@ -9126,7 +9071,7 @@ This is a temporary ability and it will be removed in the future. /** * Types of reasons why a cookie should have been blocked by 3PCD but is exempted for the request. */ - export type CookieExemptionReason = "None"|"UserSetting"|"TPCDMetadata"|"TPCDDeprecationTrial"|"TopLevelTPCDDeprecationTrial"|"TPCDHeuristics"|"EnterprisePolicy"|"StorageAccess"|"TopLevelStorageAccess"|"Scheme"; + export type CookieExemptionReason = "None"|"UserSetting"|"TPCDMetadata"|"TPCDDeprecationTrial"|"TopLevelTPCDDeprecationTrial"|"TPCDHeuristics"|"EnterprisePolicy"|"StorageAccess"|"TopLevelStorageAccess"|"Scheme"|"SameSiteNoneCookiesInSandbox"; /** * A cookie which was not stored from a response with the corresponding reason. */ @@ -11702,7 +11647,7 @@ as an ad. * All Permissions Policy features. This enum should match the one defined in third_party/blink/renderer/core/permissions_policy/permissions_policy_features.json5. */ - export type PermissionsPolicyFeature = "accelerometer"|"all-screens-capture"|"ambient-light-sensor"|"attribution-reporting"|"autoplay"|"bluetooth"|"browsing-topics"|"camera"|"captured-surface-control"|"ch-dpr"|"ch-device-memory"|"ch-downlink"|"ch-ect"|"ch-prefers-color-scheme"|"ch-prefers-reduced-motion"|"ch-prefers-reduced-transparency"|"ch-rtt"|"ch-save-data"|"ch-ua"|"ch-ua-arch"|"ch-ua-bitness"|"ch-ua-platform"|"ch-ua-model"|"ch-ua-mobile"|"ch-ua-form-factors"|"ch-ua-full-version"|"ch-ua-full-version-list"|"ch-ua-platform-version"|"ch-ua-wow64"|"ch-viewport-height"|"ch-viewport-width"|"ch-width"|"clipboard-read"|"clipboard-write"|"compute-pressure"|"controlled-frame"|"cross-origin-isolated"|"deferred-fetch"|"deferred-fetch-minimal"|"digital-credentials-get"|"direct-sockets"|"direct-sockets-private"|"display-capture"|"document-domain"|"encrypted-media"|"execution-while-out-of-viewport"|"execution-while-not-rendered"|"fenced-unpartitioned-storage-read"|"focus-without-user-activation"|"fullscreen"|"frobulate"|"gamepad"|"geolocation"|"gyroscope"|"hid"|"identity-credentials-get"|"idle-detection"|"interest-cohort"|"join-ad-interest-group"|"keyboard-map"|"local-fonts"|"magnetometer"|"media-playback-while-not-visible"|"microphone"|"midi"|"otp-credentials"|"payment"|"picture-in-picture"|"popins"|"private-aggregation"|"private-state-token-issuance"|"private-state-token-redemption"|"publickey-credentials-create"|"publickey-credentials-get"|"run-ad-auction"|"screen-wake-lock"|"serial"|"shared-autofill"|"shared-storage"|"shared-storage-select-url"|"smart-card"|"speaker-selection"|"storage-access"|"sub-apps"|"sync-xhr"|"unload"|"usb"|"usb-unrestricted"|"vertical-scroll"|"web-app-installation"|"web-printing"|"web-share"|"window-management"|"xr-spatial-tracking"; + export type PermissionsPolicyFeature = "accelerometer"|"all-screens-capture"|"ambient-light-sensor"|"attribution-reporting"|"autoplay"|"bluetooth"|"browsing-topics"|"camera"|"captured-surface-control"|"ch-dpr"|"ch-device-memory"|"ch-downlink"|"ch-ect"|"ch-prefers-color-scheme"|"ch-prefers-reduced-motion"|"ch-prefers-reduced-transparency"|"ch-rtt"|"ch-save-data"|"ch-ua"|"ch-ua-arch"|"ch-ua-bitness"|"ch-ua-high-entropy-values"|"ch-ua-platform"|"ch-ua-model"|"ch-ua-mobile"|"ch-ua-form-factors"|"ch-ua-full-version"|"ch-ua-full-version-list"|"ch-ua-platform-version"|"ch-ua-wow64"|"ch-viewport-height"|"ch-viewport-width"|"ch-width"|"clipboard-read"|"clipboard-write"|"compute-pressure"|"controlled-frame"|"cross-origin-isolated"|"deferred-fetch"|"deferred-fetch-minimal"|"digital-credentials-get"|"direct-sockets"|"direct-sockets-private"|"display-capture"|"document-domain"|"encrypted-media"|"execution-while-out-of-viewport"|"execution-while-not-rendered"|"fenced-unpartitioned-storage-read"|"focus-without-user-activation"|"fullscreen"|"frobulate"|"gamepad"|"geolocation"|"gyroscope"|"hid"|"identity-credentials-get"|"idle-detection"|"interest-cohort"|"join-ad-interest-group"|"keyboard-map"|"local-fonts"|"magnetometer"|"media-playback-while-not-visible"|"microphone"|"midi"|"otp-credentials"|"payment"|"picture-in-picture"|"popins"|"private-aggregation"|"private-state-token-issuance"|"private-state-token-redemption"|"publickey-credentials-create"|"publickey-credentials-get"|"run-ad-auction"|"screen-wake-lock"|"serial"|"shared-autofill"|"shared-storage"|"shared-storage-select-url"|"smart-card"|"speaker-selection"|"storage-access"|"sub-apps"|"sync-xhr"|"unload"|"usb"|"usb-unrestricted"|"vertical-scroll"|"web-app-installation"|"web-printing"|"web-share"|"window-management"|"xr-spatial-tracking"; /** * Reason for a permissions policy feature to be disabled. */ @@ -12431,6 +12376,33 @@ subtree is actually detached. frame: Frame; } export type frameResizedPayload = void; + /** + * Fired when a navigation starts. This event is fired for both +renderer-initiated and browser-initiated navigations. For renderer-initiated +navigations, the event is fired after `frameRequestedNavigation`. +Navigation may still be cancelled after the event is issued. Multiple events +can be fired for a single navigation, for example, when a same-document +navigation becomes a cross-document navigation (such as in the case of a +frameset). + */ + export type frameStartedNavigatingPayload = { + /** + * ID of the frame that is being navigated. + */ + frameId: FrameId; + /** + * The URL the navigation started with. The final URL can be different. + */ + url: string; + /** + * Loader identifier. Even though it is present in case of same-document +navigation, the previously committed loaderId would not change unless +the navigation changes from a same-document to a cross-document +navigation. + */ + loaderId: Network.LoaderId; + navigationType: "reload"|"reloadBypassingCache"|"restore"|"restoreWithPost"|"historySameDocument"|"historyDifferentDocument"|"sameDocument"|"differentDocument"; + } /** * Fired when a renderer-initiated navigation is requested. Navigation may still be cancelled after the event is issued. @@ -14281,7 +14253,7 @@ For cached script it is the last time the cache entry was validated. /** * Enum of possible storage types. */ - export type StorageType = "appcache"|"cookies"|"file_systems"|"indexeddb"|"local_storage"|"shader_cache"|"websql"|"service_workers"|"cache_storage"|"interest_groups"|"shared_storage"|"storage_buckets"|"all"|"other"; + export type StorageType = "cookies"|"file_systems"|"indexeddb"|"local_storage"|"shader_cache"|"websql"|"service_workers"|"cache_storage"|"interest_groups"|"shared_storage"|"storage_buckets"|"all"|"other"; /** * Usage for a storage type. */ @@ -15193,6 +15165,28 @@ session. The effective Related Website Sets will not change during a browser ses export type getRelatedWebsiteSetsReturnValue = { sets: RelatedWebsiteSet[]; } + /** + * Returns the list of URLs from a page and its embedded resources that match +existing grace period URL pattern rules. +https://developers.google.com/privacy-sandbox/cookies/temporary-exceptions/grace-period + */ + export type getAffectedUrlsForThirdPartyCookieMetadataParameters = { + /** + * The URL of the page currently being visited. + */ + firstPartyUrl: string; + /** + * The list of embedded resource URLs from the page. + */ + thirdPartyUrls: string[]; + } + export type getAffectedUrlsForThirdPartyCookieMetadataReturnValue = { + /** + * Array of matching URLs. If there is a primary pattern match for the first- +party URL, only the first-party URL is returned in the array. + */ + matchedUrls: string[]; + } } /** @@ -15485,6 +15479,10 @@ If filter is not specified, the one assumed is host: string; port: number; } + /** + * The state of the target window. + */ + export type WindowState = "normal"|"minimized"|"maximized"|"fullscreen"; /** * Issued when attached to target because of auto-attach or `attachToTarget` command. @@ -15677,37 +15675,42 @@ Parts of the URL other than those constituting origin are ignored. */ url: string; /** - * Frame left origin in DIP (headless chrome only). + * Frame left origin in DIP (requires newWindow to be true or headless shell). */ left?: number; /** - * Frame top origin in DIP (headless chrome only). + * Frame top origin in DIP (requires newWindow to be true or headless shell). */ top?: number; /** - * Frame width in DIP (headless chrome only). + * Frame width in DIP (requires newWindow to be true or headless shell). */ width?: number; /** - * Frame height in DIP (headless chrome only). + * Frame height in DIP (requires newWindow to be true or headless shell). */ height?: number; + /** + * Frame window state (requires newWindow to be true or headless shell). +Default is normal. + */ + windowState?: WindowState; /** * The browser context to create the page in. */ browserContextId?: Browser.BrowserContextID; /** - * Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, + * Whether BeginFrames for this target will be controlled via DevTools (headless shell only, not supported on MacOS yet, false by default). */ enableBeginFrameControl?: boolean; /** - * Whether to create a new Window or Tab (chrome-only, false by default). + * Whether to create a new Window or Tab (false by default, not supported by headless shell). */ newWindow?: boolean; /** - * Whether to create the target in background or foreground (chrome-only, -false by default). + * Whether to create the target in background or foreground (false by default, not supported +by headless shell). */ background?: boolean; /** @@ -18012,9 +18015,20 @@ variables as its properties. */ externalURL?: string; } + export interface ResolvedBreakpoint { + /** + * Breakpoint unique identifier. + */ + breakpointId: BreakpointId; + /** + * Actual breakpoint location. + */ + location: Location; + } /** * Fired when breakpoint is resolved to an actual script and location. +Deprecated in favor of `resolvedBreakpoints` in the `scriptParsed` event. */ export type breakpointResolvedPayload = { /** @@ -18225,6 +18239,12 @@ scripts upon enabling debugger. * The name the embedder supplied for this script. */ embedderName?: string; + /** + * The list of set breakpoints in this script if calls to `setBreakpointByUrl` +matches this script's URL or hash. Clients that use this list can ignore the +`breakpointResolved` event. They are equivalent. + */ + resolvedBreakpoints?: ResolvedBreakpoint[]; } /** @@ -20150,13 +20170,21 @@ It is the total usage of the corresponding isolate not scoped to a particular Ru } export type getHeapUsageReturnValue = { /** - * Used heap size in bytes. + * Used JavaScript heap size in bytes. */ usedSize: number; /** - * Allocated heap size in bytes. + * Allocated JavaScript heap size in bytes. */ totalSize: number; + /** + * Used size in bytes in the embedder's garbage-collected heap. + */ + embedderHeapUsedSize: number; + /** + * Size in bytes of backing storage for array buffers and external strings. + */ + backingStorageSize: number; } /** * Returns properties of a given object. Object group of the result is inherited from the target @@ -20472,7 +20500,6 @@ Error was thrown. "DOMStorage.domStorageItemRemoved": DOMStorage.domStorageItemRemovedPayload; "DOMStorage.domStorageItemUpdated": DOMStorage.domStorageItemUpdatedPayload; "DOMStorage.domStorageItemsCleared": DOMStorage.domStorageItemsClearedPayload; - "Database.addDatabase": Database.addDatabasePayload; "Emulation.virtualTimeBudgetExpired": Emulation.virtualTimeBudgetExpiredPayload; "Input.dragIntercepted": Input.dragInterceptedPayload; "Inspector.detached": Inspector.detachedPayload; @@ -20526,6 +20553,7 @@ Error was thrown. "Page.frameNavigated": Page.frameNavigatedPayload; "Page.documentOpened": Page.documentOpenedPayload; "Page.frameResized": Page.frameResizedPayload; + "Page.frameStartedNavigating": Page.frameStartedNavigatingPayload; "Page.frameRequestedNavigation": Page.frameRequestedNavigationPayload; "Page.frameScheduledNavigation": Page.frameScheduledNavigationPayload; "Page.frameStartedLoading": Page.frameStartedLoadingPayload; @@ -20656,6 +20684,7 @@ Error was thrown. "Audits.checkContrast": Audits.checkContrastParameters; "Audits.checkFormsIssues": Audits.checkFormsIssuesParameters; "Extensions.loadUnpacked": Extensions.loadUnpackedParameters; + "Extensions.uninstall": Extensions.uninstallParameters; "Extensions.getStorageItems": Extensions.getStorageItemsParameters; "Extensions.removeStorageItems": Extensions.removeStorageItemsParameters; "Extensions.clearStorageItems": Extensions.clearStorageItemsParameters; @@ -20808,10 +20837,6 @@ Error was thrown. "DOMStorage.getDOMStorageItems": DOMStorage.getDOMStorageItemsParameters; "DOMStorage.removeDOMStorageItem": DOMStorage.removeDOMStorageItemParameters; "DOMStorage.setDOMStorageItem": DOMStorage.setDOMStorageItemParameters; - "Database.disable": Database.disableParameters; - "Database.enable": Database.enableParameters; - "Database.executeSQL": Database.executeSQLParameters; - "Database.getDatabaseTableNames": Database.getDatabaseTableNamesParameters; "DeviceOrientation.clearDeviceOrientationOverride": DeviceOrientation.clearDeviceOrientationOverrideParameters; "DeviceOrientation.setDeviceOrientationOverride": DeviceOrientation.setDeviceOrientationOverrideParameters; "Emulation.canEmulate": Emulation.canEmulateParameters; @@ -21088,6 +21113,7 @@ Error was thrown. "Storage.setAttributionReportingTracking": Storage.setAttributionReportingTrackingParameters; "Storage.sendPendingAttributionReports": Storage.sendPendingAttributionReportsParameters; "Storage.getRelatedWebsiteSets": Storage.getRelatedWebsiteSetsParameters; + "Storage.getAffectedUrlsForThirdPartyCookieMetadata": Storage.getAffectedUrlsForThirdPartyCookieMetadataParameters; "SystemInfo.getInfo": SystemInfo.getInfoParameters; "SystemInfo.getFeatureState": SystemInfo.getFeatureStateParameters; "SystemInfo.getProcessInfo": SystemInfo.getProcessInfoParameters; @@ -21273,6 +21299,7 @@ Error was thrown. "Audits.checkContrast": Audits.checkContrastReturnValue; "Audits.checkFormsIssues": Audits.checkFormsIssuesReturnValue; "Extensions.loadUnpacked": Extensions.loadUnpackedReturnValue; + "Extensions.uninstall": Extensions.uninstallReturnValue; "Extensions.getStorageItems": Extensions.getStorageItemsReturnValue; "Extensions.removeStorageItems": Extensions.removeStorageItemsReturnValue; "Extensions.clearStorageItems": Extensions.clearStorageItemsReturnValue; @@ -21425,10 +21452,6 @@ Error was thrown. "DOMStorage.getDOMStorageItems": DOMStorage.getDOMStorageItemsReturnValue; "DOMStorage.removeDOMStorageItem": DOMStorage.removeDOMStorageItemReturnValue; "DOMStorage.setDOMStorageItem": DOMStorage.setDOMStorageItemReturnValue; - "Database.disable": Database.disableReturnValue; - "Database.enable": Database.enableReturnValue; - "Database.executeSQL": Database.executeSQLReturnValue; - "Database.getDatabaseTableNames": Database.getDatabaseTableNamesReturnValue; "DeviceOrientation.clearDeviceOrientationOverride": DeviceOrientation.clearDeviceOrientationOverrideReturnValue; "DeviceOrientation.setDeviceOrientationOverride": DeviceOrientation.setDeviceOrientationOverrideReturnValue; "Emulation.canEmulate": Emulation.canEmulateReturnValue; @@ -21705,6 +21728,7 @@ Error was thrown. "Storage.setAttributionReportingTracking": Storage.setAttributionReportingTrackingReturnValue; "Storage.sendPendingAttributionReports": Storage.sendPendingAttributionReportsReturnValue; "Storage.getRelatedWebsiteSets": Storage.getRelatedWebsiteSetsReturnValue; + "Storage.getAffectedUrlsForThirdPartyCookieMetadata": Storage.getAffectedUrlsForThirdPartyCookieMetadataReturnValue; "SystemInfo.getInfo": SystemInfo.getInfoReturnValue; "SystemInfo.getFeatureState": SystemInfo.getFeatureStateReturnValue; "SystemInfo.getProcessInfo": SystemInfo.getProcessInfoReturnValue; From 967c4f5e3b88a90e9c44ef983df85b00cde0ac52 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 10 Feb 2025 13:05:17 +0100 Subject: [PATCH 08/11] chore: fix Locator type issues (#34705) --- docs/src/api/class-apirequest.md | 2 +- docs/src/api/class-apirequestcontext.md | 2 +- docs/src/api/class-browsercontext.md | 2 +- docs/src/api/params.md | 2 +- packages/playwright-core/src/client/types.ts | 2 +- packages/playwright-core/types/types.d.ts | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/src/api/class-apirequest.md b/docs/src/api/class-apirequest.md index feea5b8378..f1465cb8c6 100644 --- a/docs/src/api/class-apirequest.md +++ b/docs/src/api/class-apirequest.md @@ -81,7 +81,7 @@ Methods like [`method: APIRequestContext.get`] take the base URL into considerat - `records` <[Array]<[Object]>> - `key` ?<[Object]> - `keyEncoded` ?<[Object]> if `key` is not JSON-serializable, this contains an encoded version that preserves types. - - `value` <[Object]> + - `value` ?<[Object]> - `valueEncoded` ?<[Object]> if `value` is not JSON-serializable, this contains an encoded version that preserves types. Populates context with given storage state. This option can be used to initialize context with logged-in information diff --git a/docs/src/api/class-apirequestcontext.md b/docs/src/api/class-apirequestcontext.md index 838625bcbf..165b9f3bd6 100644 --- a/docs/src/api/class-apirequestcontext.md +++ b/docs/src/api/class-apirequestcontext.md @@ -897,7 +897,7 @@ context cookies from the response. The method will automatically follow redirect - `records` <[Array]<[Object]>> - `key` ?<[Object]> - `keyEncoded` ?<[Object]> if `key` is not JSON-serializable, this contains an encoded version that preserves types. - - `value` <[Object]> + - `value` ?<[Object]> - `valueEncoded` ?<[Object]> if `value` is not JSON-serializable, this contains an encoded version that preserves types. Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to the constructor. diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md index 156a577504..f831bd4cae 100644 --- a/docs/src/api/class-browsercontext.md +++ b/docs/src/api/class-browsercontext.md @@ -1528,7 +1528,7 @@ Whether to emulate network being offline for the browser context. - `records` <[Array]<[Object]>> - `key` ?<[Object]> - `keyEncoded` ?<[Object]> if `key` is not JSON-serializable, this contains an encoded version that preserves types. - - `value` <[Object]> + - `value` ?<[Object]> - `valueEncoded` ?<[Object]> if `value` is not JSON-serializable, this contains an encoded version that preserves types. Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB snapshot. diff --git a/docs/src/api/params.md b/docs/src/api/params.md index f2d8734336..920ba10943 100644 --- a/docs/src/api/params.md +++ b/docs/src/api/params.md @@ -281,7 +281,7 @@ Specify environment variables that will be visible to the browser. Defaults to ` - `records` <[Array]<[Object]>> - `key` ?<[Object]> - `keyEncoded` ?<[Object]> if `key` is not JSON-serializable, this contains an encoded version that preserves types. - - `value` <[Object]> + - `value` ?<[Object]> - `valueEncoded` ?<[Object]> if `value` is not JSON-serializable, this contains an encoded version that preserves types. Learn more about [storage state and auth](../auth.md). diff --git a/packages/playwright-core/src/client/types.ts b/packages/playwright-core/src/client/types.ts index 5d232e9607..2cad775712 100644 --- a/packages/playwright-core/src/client/types.ts +++ b/packages/playwright-core/src/client/types.ts @@ -37,7 +37,7 @@ export type SelectOptionOptions = { force?: boolean, timeout?: number }; export type FilePayload = { name: string, mimeType: string, buffer: Buffer }; export type StorageState = { cookies: channels.NetworkCookie[], - origins: channels.OriginStorage[] + origins: channels.OriginStorage[], }; export type SetStorageState = { cookies?: channels.SetNetworkCookie[], diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index 5a74ee6d76..cdd4dcb930 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -9351,7 +9351,7 @@ export interface BrowserContext { */ keyEncoded?: Object; - value: Object; + value?: Object; /** * if `value` is not JSON-serializable, this contains an encoded version that preserves types. @@ -10170,7 +10170,7 @@ export interface Browser { */ keyEncoded?: Object; - value: Object; + value?: Object; /** * if `value` is not JSON-serializable, this contains an encoded version that preserves types. @@ -17758,7 +17758,7 @@ export interface APIRequest { */ keyEncoded?: Object; - value: Object; + value?: Object; /** * if `value` is not JSON-serializable, this contains an encoded version that preserves types. @@ -18616,7 +18616,7 @@ export interface APIRequestContext { */ keyEncoded?: Object; - value: Object; + value?: Object; /** * if `value` is not JSON-serializable, this contains an encoded version that preserves types. @@ -22512,7 +22512,7 @@ export interface BrowserContextOptions { */ keyEncoded?: Object; - value: Object; + value?: Object; /** * if `value` is not JSON-serializable, this contains an encoded version that preserves types. From 76b7b52c343e1630217675fcdd855efe55715c83 Mon Sep 17 00:00:00 2001 From: Priyanshi Saxena <32139869+PriyanshiS@users.noreply.github.com> Date: Mon, 10 Feb 2025 07:22:53 -0500 Subject: [PATCH 09/11] docs: source section doc updated (#34627) Co-authored-by: ankursaxena17 <32309836+ankursaxena17@users.noreply.github.com> --- docs/src/test-ui-mode-js.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/src/test-ui-mode-js.md b/docs/src/test-ui-mode-js.md index 41a00264d9..4aaeae92d6 100644 --- a/docs/src/test-ui-mode-js.md +++ b/docs/src/test-ui-mode-js.md @@ -18,12 +18,13 @@ UI Mode lets you explore, run, and debug tests with a time travel experience com To open UI mode, run the following command in your terminal: - ```bash - npx playwright test --ui - ``` +```bash +npx playwright test --ui +``` + ## Running your tests -Once you launch UI Mode you will see a list of all your test files. You can run all your tests by clicking the triangle icon in the sidebar. You can also run a single test file, a block of tests or a single test by hovering over the name and clicking on the triangle next to it. +Once you launch UI Mode you will see a list of all your test files. You can run all your tests by clicking the triangle icon in the sidebar. You can also run a single test file, a block of tests or a single test by hovering over the name and clicking on the triangle next to it. ![running tests in ui mode](https://github.com/microsoft/playwright/assets/13063165/6b87712f-64a5-4d73-a91d-6562b864712c) @@ -33,17 +34,15 @@ Filter tests by text or `@tag` or by passed, failed or skipped tests. You can al ![filtering tests in ui mode](https://github.com/microsoft/playwright/assets/13063165/6f05e589-036d-45d5-9078-38134e1261e4) - ## Timeline view At the top of the trace you can see a timeline view of your test with different colors to highlight navigation and actions. Hover back and forth to see an image snapshot for each action. Double click on an action to see the time range for that action. You can use the slider in the timeline to increase the actions selected and these will be shown in the Actions tab and all console logs and network logs will be filtered to only show the logs for the actions selected. ![timeline view in ui mode](https://github.com/microsoft/playwright/assets/13063165/811a9985-32aa-4a3e-9869-de32053cf468) - ## Actions -In the Actions tab you can see what locator was used for every action and how long each one took to run. Hover over each action of your test and visually see the change in the DOM snapshot. Go back and forward in time and click an action to inspect and debug. Use the Before and After tabs to visually see what happened before and after the action. +In the Actions tab you can see what locator was used for every action and how long each one took to run. Hover over each action of your test and visually see the change in the DOM snapshot. Go back and forward in time and click an action to inspect and debug. Use the Before and After tabs to visually see what happened before and after the action. ![use before and after actions in ui mode](https://github.com/microsoft/playwright/assets/13063165/7b22fab5-7346-4b98-8fdd-a78ed280647f) ## Pop out and inspect the DOM @@ -60,7 +59,7 @@ Click on the pick locator button and hover over the DOM snapshot to see the loca ## Source -As you hover over each action of your test the line of code for that action is highlighted in the source panel. +As you hover over each action of your test the line of code for that action is highlighted in the source panel. The button "Open in VSCode" is at the top-right of this section. Upon clicking the button, it will open your test in VS Code right at the line of code that you clicked on. ![showing source code of tests in ui mode](https://github.com/microsoft/playwright/assets/13063165/49b9fa2a-8a57-4044-acaa-0a2ea4784c5c) @@ -108,7 +107,7 @@ Next to the Actions tab you will find the Metadata tab which will show you more ## Watch mode -Next to the name of each test in the sidebar you will find an eye icon. Clicking on the icon will activate watch mode which will re-run the test when you make changes to it. You can watch a number of tests at the same time be clicking the eye icon next to each one or all tests by clicking the eye icon at the top of the sidebar. If you are using VS Code then you can easily open your test by clicking on the file icon next to the eye icon. This will open your test in VS Code right at the line of code that you clicked on. +Next to the name of each test in the sidebar you will find an eye icon. Clicking on the icon will activate watch mode which will re-run the test when you make changes to it. You can watch a number of tests at the same time be clicking the eye icon next to each one or all tests by clicking the eye icon at the top of the sidebar. ![watch mode in ui mode](https://github.com/microsoft/playwright/assets/13063165/20d7d44c-b52d-43ff-8871-8b828671f3da) From 703e077f4b50578b53bcb183d8f37b1a97e43921 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 10 Feb 2025 13:23:04 +0100 Subject: [PATCH 10/11] chore: fix recorder tsconfig linting (#34704) --- packages/recorder/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/recorder/tsconfig.json b/packages/recorder/tsconfig.json index 164b02dba5..05e3481057 100644 --- a/packages/recorder/tsconfig.json +++ b/packages/recorder/tsconfig.json @@ -9,7 +9,7 @@ "allowSyntheticDefaultImports": true, "strict": true, "module": "ESNext", - "moduleResolution": "Node", + "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, From 2f8d448dbbcc9130703035203f469fae26b808d6 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Mon, 10 Feb 2025 15:02:19 +0100 Subject: [PATCH 11/11] feat(html): "copy prompt" button (#34670) --- packages/html-reporter/src/metadataView.tsx | 31 ++++++++--- packages/html-reporter/src/reportView.tsx | 5 +- packages/html-reporter/src/testErrorView.css | 33 +++++++++++- packages/html-reporter/src/testErrorView.tsx | 52 ++++++++++++++++-- packages/html-reporter/src/testFilesView.tsx | 6 +-- packages/html-reporter/src/testResultView.tsx | 6 +-- packages/playwright/src/reporters/html.ts | 11 ++++ packages/web/src/components/prompts.ts | 48 +++++++++++++++++ tests/playwright-test/reporter-html.spec.ts | 53 +++++++++++++++++++ 9 files changed, 223 insertions(+), 22 deletions(-) create mode 100644 packages/web/src/components/prompts.ts diff --git a/packages/html-reporter/src/metadataView.tsx b/packages/html-reporter/src/metadataView.tsx index 8cc66571ab..ed050f4480 100644 --- a/packages/html-reporter/src/metadataView.tsx +++ b/packages/html-reporter/src/metadataView.tsx @@ -26,9 +26,25 @@ import { linkifyText } from '@web/renderUtils'; type MetadataEntries = [string, unknown][]; -export function filterMetadata(metadata: Metadata): MetadataEntries { - // TODO: do not plumb actualWorkers through metadata. - return Object.entries(metadata).filter(([key]) => key !== 'actualWorkers'); +export const MetadataContext = React.createContext([]); + +export function MetadataProvider({ metadata, children }: React.PropsWithChildren<{ metadata: Metadata }>) { + const entries = React.useMemo(() => { + // TODO: do not plumb actualWorkers through metadata. + + return Object.entries(metadata).filter(([key]) => key !== 'actualWorkers'); + }, [metadata]); + + return {children}; +} + +export function useMetadata() { + return React.useContext(MetadataContext); +} + +export function useGitCommitInfo() { + const metadataEntries = useMetadata(); + return metadataEntries.find(([key]) => key === 'git.commit.info')?.[1] as GitCommitInfo | undefined; } class ErrorBoundary extends React.Component, { error: Error | null, errorInfo: React.ErrorInfo | null }> { @@ -57,12 +73,13 @@ class ErrorBoundary extends React.Component, { error } } -export const MetadataView: React.FC<{ metadataEntries: MetadataEntries }> = ({ metadataEntries }) => { - return ; +export const MetadataView = () => { + return ; }; -const InnerMetadataView: React.FC<{ metadataEntries: MetadataEntries }> = ({ metadataEntries }) => { - const gitCommitInfo = metadataEntries.find(([key]) => key === 'git.commit.info')?.[1] as GitCommitInfo | undefined; +const InnerMetadataView = () => { + const metadataEntries = useMetadata(); + const gitCommitInfo = useGitCommitInfo(); const entries = metadataEntries.filter(([key]) => key !== 'git.commit.info'); if (!gitCommitInfo && !entries.length) return null; diff --git a/packages/html-reporter/src/reportView.tsx b/packages/html-reporter/src/reportView.tsx index e48064201c..baf85f32a8 100644 --- a/packages/html-reporter/src/reportView.tsx +++ b/packages/html-reporter/src/reportView.tsx @@ -26,6 +26,7 @@ import './reportView.css'; import { TestCaseView } from './testCaseView'; import { TestFilesHeader, TestFilesView } from './testFilesView'; import './theme.css'; +import { MetadataProvider } from './metadataView'; declare global { interface Window { @@ -72,7 +73,7 @@ export const ReportView: React.FC<{ return result; }, [report, filter]); - return
+ return
{report?.json() && } @@ -88,7 +89,7 @@ export const ReportView: React.FC<{ {!!report && }
-
; +
; }; const TestCaseViewLoader: React.FC<{ diff --git a/packages/html-reporter/src/testErrorView.css b/packages/html-reporter/src/testErrorView.css index e29ea2a18b..7cc9e88a79 100644 --- a/packages/html-reporter/src/testErrorView.css +++ b/packages/html-reporter/src/testErrorView.css @@ -16,18 +16,47 @@ @import '@web/third_party/vscode/colors.css'; -.test-error-view { +.test-error-container { white-space: pre; overflow: auto; flex: none; padding: 0; background-color: var(--color-canvas-subtle); border-radius: 6px; - padding: 16px; line-height: initial; margin-bottom: 6px; } +.test-error-view { + padding: 16px; +} + .test-error-text { font-family: monospace; } + +.prompt-button { + flex: none; + height: 24px; + width: 80px; + border: 1px solid var(--color-btn-border); + outline: none; + color: var(--color-btn-text); + background: var(--color-btn-bg); + padding: 4px; + cursor: pointer; + display: inline-flex; + align-items: center; + justify-content: center; + border-radius: 4px; +} + +.prompt-button svg { + color: var(--color-fg-subtle); +} + +.prompt-button:not(:disabled):hover { + border-color: var(--color-btn-hover-border); + background-color: var(--color-btn-hover-bg); +} + diff --git a/packages/html-reporter/src/testErrorView.tsx b/packages/html-reporter/src/testErrorView.tsx index ea402106a8..11f8e4b474 100644 --- a/packages/html-reporter/src/testErrorView.tsx +++ b/packages/html-reporter/src/testErrorView.tsx @@ -17,15 +17,57 @@ import { ansi2html } from '@web/ansi2html'; import * as React from 'react'; import './testErrorView.css'; +import * as icons from './icons'; import type { ImageDiff } from '@web/shared/imageDiffView'; import { ImageDiffView } from '@web/shared/imageDiffView'; +import type { TestResult } from './types'; +import { fixTestPrompt } from '@web/components/prompts'; +import { useGitCommitInfo } from './metadataView'; -export const TestErrorView: React.FC<{ +export const TestErrorView: React.FC<{ error: string; testId?: string; result?: TestResult }> = ({ error, testId, result }) => { + return ( + +
+ +
+
+ ); +}; + +export const CodeSnippet = ({ code, children, testId }: React.PropsWithChildren<{ code: string; testId?: string; }>) => { + const html = React.useMemo(() => ansiErrorToHtml(code), [code]); + return ( +
+ {children} +
+
+ ); +}; + +const PromptButton: React.FC<{ error: string; - testId?: string; -}> = ({ error, testId }) => { - const html = React.useMemo(() => ansiErrorToHtml(error), [error]); - return
; + result?: TestResult; +}> = ({ error, result }) => { + const gitCommitInfo = useGitCommitInfo(); + const prompt = React.useMemo(() => fixTestPrompt( + error, + gitCommitInfo?.['pull.diff'] ?? gitCommitInfo?.['revision.diff'], + result?.attachments.find(a => a.name === 'pageSnapshot')?.body + ), [gitCommitInfo, result, error]); + + const [copied, setCopied] = React.useState(false); + + return ; }; export const TestScreenshotErrorView: React.FC<{ diff --git a/packages/html-reporter/src/testFilesView.tsx b/packages/html-reporter/src/testFilesView.tsx index bcb0696946..dcac5e8cea 100644 --- a/packages/html-reporter/src/testFilesView.tsx +++ b/packages/html-reporter/src/testFilesView.tsx @@ -22,7 +22,7 @@ import { msToString } from './utils'; import { AutoChip } from './chip'; import { TestErrorView } from './testErrorView'; import * as icons from './icons'; -import { filterMetadata, MetadataView } from './metadataView'; +import { MetadataView, useMetadata } from './metadataView'; export const TestFilesView: React.FC<{ tests: TestFileSummary[], @@ -67,9 +67,9 @@ export const TestFilesHeader: React.FC<{ metadataVisible: boolean, toggleMetadataVisible: () => void, }> = ({ report, filteredStats, metadataVisible, toggleMetadataVisible }) => { + const metadataEntries = useMetadata(); if (!report) return; - const metadataEntries = filterMetadata(report.metadata || {}); return <>
{metadataEntries.length > 0 &&
@@ -81,7 +81,7 @@ export const TestFilesHeader: React.FC<{
{report ? new Date(report.startTime).toLocaleString() : ''}
Total time: {msToString(report.duration ?? 0)}
- {metadataVisible && } + {metadataVisible && } {!!report.errors.length && {report.errors.map((error, index) => )} } diff --git a/packages/html-reporter/src/testResultView.tsx b/packages/html-reporter/src/testResultView.tsx index 681f4b507a..3243b2bcb9 100644 --- a/packages/html-reporter/src/testResultView.tsx +++ b/packages/html-reporter/src/testResultView.tsx @@ -24,7 +24,7 @@ import { Anchor, AttachmentLink, generateTraceUrl, testResultHref } from './link import { statusIcon } from './statusIcon'; import type { ImageDiff } from '@web/shared/imageDiffView'; import { ImageDiffView } from '@web/shared/imageDiffView'; -import { TestErrorView, TestScreenshotErrorView } from './testErrorView'; +import { CodeSnippet, TestErrorView, TestScreenshotErrorView } from './testErrorView'; import * as icons from './icons'; import './testResultView.css'; @@ -90,7 +90,7 @@ export const TestResultView: React.FC<{ {errors.map((error, index) => { if (error.type === 'screenshot') return ; - return ; + return ; })} } {!!result.steps.length && @@ -182,7 +182,7 @@ const StepTreeItem: React.FC<{ {step.count > 1 && <> ✕ {step.count}} {step.location && — {step.location.file}:{step.location.line}} } loadChildren={step.steps.length || step.snippet ? () => { - const snippet = step.snippet ? [] : []; + const snippet = step.snippet ? [] : []; const steps = step.steps.map((s, i) => ); return snippet.concat(steps); } : undefined} depth={depth}/>; diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.ts index 557ad580b7..2600b51797 100644 --- a/packages/playwright/src/reporters/html.ts +++ b/packages/playwright/src/reporters/html.ts @@ -449,6 +449,17 @@ class HtmlBuilder { return a; } + if (a.name === 'pageSnapshot') { + try { + const body = fs.readFileSync(a.path!, { encoding: 'utf-8' }); + return { + name: 'pageSnapshot', + contentType: a.contentType, + body, + }; + } catch {} + } + if (a.path) { let fileName = a.path; try { diff --git a/packages/web/src/components/prompts.ts b/packages/web/src/components/prompts.ts new file mode 100644 index 0000000000..88a086815e --- /dev/null +++ b/packages/web/src/components/prompts.ts @@ -0,0 +1,48 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const ansiRegex = new RegExp('([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))', 'g'); +function stripAnsiEscapes(str: string): string { + return str.replace(ansiRegex, ''); +} + +export function fixTestPrompt(error: string, diff?: string, pageSnapshot?: string) { + const promptParts = [ + 'This test failed, suggest how to fix it. Please be correct, concise and keep Playwright best practices in mind.', + 'Here is the error:', + '\n', + stripAnsiEscapes(error), + '\n', + ]; + + if (pageSnapshot) { + promptParts.push( + 'This is how the page looked at the end of the test:', + pageSnapshot, + '\n' + ); + } + + if (diff) { + promptParts.push( + 'And this is the code diff:', + diff, + '\n' + ); + } + + return promptParts.join('\n'); +} diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts index d5cc7ed50f..acb54f3b31 100644 --- a/tests/playwright-test/reporter-html.spec.ts +++ b/tests/playwright-test/reporter-html.spec.ts @@ -2694,6 +2694,59 @@ for (const useIntermediateMergeReport of [true, false] as const) { await page.getByText('my test').click(); await expect(page.locator('.tree-item', { hasText: 'stdout' })).toHaveCount(1); }); + + test('should show AI prompt', async ({ runInlineTest, writeFiles, showReport, page }) => { + const files = { + 'uncommitted.txt': `uncommitted file`, + 'playwright.config.ts': ` + export default { + populateGitInfo: true, + metadata: { foo: 'value1', bar: { prop: 'value2' }, baz: ['value3', 123] } + }; + `, + 'example.spec.ts': ` + import { test, expect } from '@playwright/test'; + test('sample', async ({}) => { expect(2).toBe(3); }); + `, + }; + const baseDir = await writeFiles(files); + + const execGit = async (args: string[]) => { + const { code, stdout, stderr } = await spawnAsync('git', args, { stdio: 'pipe', cwd: baseDir }); + if (!!code) + throw new Error(`Non-zero exit of:\n$ git ${args.join(' ')}\nConsole:\nstdout:\n${stdout}\n\nstderr:\n${stderr}\n\n`); + return; + }; + + await execGit(['init']); + await execGit(['config', '--local', 'user.email', 'shakespeare@example.local']); + await execGit(['config', '--local', 'user.name', 'William']); + await execGit(['add', 'playwright.config.ts']); + await execGit(['commit', '-m', 'init']); + await execGit(['add', '*.ts']); + await execGit(['commit', '-m', 'chore(html): make this test look nice']); + + const result = await runInlineTest(files, { reporter: 'dot,html' }, { + PLAYWRIGHT_HTML_OPEN: 'never', + GITHUB_REPOSITORY: 'microsoft/playwright-example-for-test', + GITHUB_RUN_ID: 'example-run-id', + GITHUB_SERVER_URL: 'https://playwright.dev', + GITHUB_SHA: 'example-sha', + GITHUB_REF_NAME: '42/merge', + GITHUB_BASE_REF: 'HEAD~1', + }); + + expect(result.exitCode).toBe(1); + await showReport(); + + await page.context().grantPermissions(['clipboard-read', 'clipboard-write']); + + await page.getByRole('link', { name: 'sample' }).click(); + await page.getByRole('button', { name: 'Fix with AI' }).click(); + const prompt = await page.evaluate(() => navigator.clipboard.readText()); + expect(prompt, 'contains error').toContain('expect(received).toBe(expected)'); + expect(prompt, 'contains diff').toContain(`+ test('sample', async ({}) => { expect(2).toBe(3); });`); + }); }); }