Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: use utils via index export (4) (#13404)
Pavel Feldmana3c02222bfda
diff --git a/packages/playwright-core/index.js b/packages/playwright-core/index.jsindex e26fc7e3bd..a233e0822c 100644--- a/packages/playwright-core/index.js+++ b/packages/playwright-core/index.js@@ -14,5 +14,20 @@* limitations under the License.*/-require('./lib/utils/verifyNodeJsVersion');+const currentNodeVersion = process.versions.node;+const semver = currentNodeVersion.split('.');+const [major] = [+semver[0]];++if (major < 12) {+ // eslint-disable-next-line no-console+ console.error(+ 'You are running Node.js ' ++ currentNodeVersion ++ '.\n' ++ 'Playwright requires Node.js 12 or higher. \n' ++ 'Please update your version of Node.js.'+ );+ process.exit(1);+}+module.exports = require('./lib/inprocess');diff --git a/packages/playwright-core/src/cli/DEPS.list b/packages/playwright-core/src/cli/DEPS.listindex ecb310f898..767b4e8061 100644--- a/packages/playwright-core/src/cli/DEPS.list+++ b/packages/playwright-core/src/cli/DEPS.list@@ -1,6 +1,7 @@[*]../../../client+../common../debug/injected../generated/../griddiff --git a/packages/playwright-core/src/cli/cli.ts b/packages/playwright-core/src/cli/cli.tsindex 91adf285c7..2db65f09e6 100755--- a/packages/playwright-core/src/cli/cli.ts+++ b/packages/playwright-core/src/cli/cli.ts@@ -32,7 +32,8 @@ import type { Page } from '../client/page';import type { BrowserType } from '../client/browserType';import type { BrowserContextOptions, LaunchOptions } from '../client/types';import { spawn } from 'child_process';-import { spawnAsync, getPlaywrightVersion, wrapInASCIIBox } from '../utils';+import { getPlaywrightVersion } from '../common/userAgent';+import { spawnAsync, wrapInASCIIBox } from '../utils';import { launchGridAgent } from '../grid/gridAgent';import type { GridFactory } from '../grid/gridServer';import { GridServer } from '../grid/gridServer';diff --git a/packages/playwright-core/src/client/DEPS.list b/packages/playwright-core/src/client/DEPS.listindex 42743c4eca..16a569a46d 100644--- a/packages/playwright-core/src/client/DEPS.list+++ b/packages/playwright-core/src/client/DEPS.list@@ -1,3 +1,4 @@[*]+../common/../protocol/../utils/diff --git a/packages/playwright-core/src/client/android.ts b/packages/playwright-core/src/client/android.tsindex ebc644c56d..e754d3e903 100644--- a/packages/playwright-core/src/client/android.ts+++ b/packages/playwright-core/src/client/android.ts@@ -23,7 +23,7 @@ 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 '../utils/timeoutSettings';+import { TimeoutSettings } from '../common/timeoutSettings';import { Waiter } from './waiter';import { EventEmitter } from 'events';diff --git a/packages/playwright-core/src/client/api.ts b/packages/playwright-core/src/client/api.tsindex 4c55f7b22a..df14817104 100644--- a/packages/playwright-core/src/client/api.ts+++ b/packages/playwright-core/src/client/api.ts@@ -29,7 +29,7 @@ export { Locator, FrameLocator } from './locator';export { ElementHandle } from './elementHandle';export { FileChooser } from './fileChooser';export type { Logger } from './types';-export { TimeoutError } from '../utils/errors';+export { TimeoutError } from '../common/errors';export { Frame } from './frame';export { Keyboard, Mouse, Touchscreen } from './input';export { JSHandle } from './jsHandle';diff --git a/packages/playwright-core/src/client/browser.ts b/packages/playwright-core/src/client/browser.tsindex 1dd1accfcc..38a22476ec 100644--- a/packages/playwright-core/src/client/browser.ts+++ b/packages/playwright-core/src/client/browser.ts@@ -20,7 +20,7 @@ import type { Page } from './page';import { ChannelOwner } from './channelOwner';import { Events } from './events';import type { BrowserContextOptions } from './types';-import { isSafeCloseError, kBrowserClosedError } from '../utils/errors';+import { isSafeCloseError, kBrowserClosedError } from '../common/errors';import type * as api from '../../types/types';import { CDPSession } from './cdpSession';import type { BrowserType } from './browserType';diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.tsindex 3fcb72b24f..6d9b67998c 100644--- a/packages/playwright-core/src/client/browserContext.ts+++ b/packages/playwright-core/src/client/browserContext.ts@@ -25,11 +25,11 @@ import { evaluationScript } from './clientHelper';import { Browser } from './browser';import { Worker } from './worker';import { Events } from './events';-import { TimeoutSettings } from '../utils/timeoutSettings';+import { TimeoutSettings } from '../common/timeoutSettings';import { Waiter } from './waiter';import type { URLMatch, Headers, WaitForEventOptions, BrowserContextOptions, StorageState, LaunchOptions } from './types';import { headersObjectToArray, mkdirIfNeeded } from '../utils';-import { isSafeCloseError } from '../utils/errors';+import { isSafeCloseError } from '../common/errors';import type * as api from '../../types/types';import type * as structs from '../../types/structs';import { CDPSession } from './cdpSession';diff --git a/packages/playwright-core/src/client/browserType.ts b/packages/playwright-core/src/client/browserType.tsindex 9007dbccb6..32674ca434 100644--- a/packages/playwright-core/src/client/browserType.ts+++ b/packages/playwright-core/src/client/browserType.ts@@ -25,7 +25,7 @@ import type { ChildProcess } from 'child_process';import { envObjectToArray } from './clientHelper';import { assert, headersObjectToArray, monotonicTime } from '../utils';import type * as api from '../../types/types';-import { kBrowserClosedError } from '../utils/errors';+import { kBrowserClosedError } from '../common/errors';import { raceAgainstTimeout } from '../utils';import type { Playwright } from './playwright';diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.tsindex 29411c234b..edfa03a951 100644--- a/packages/playwright-core/src/client/channelOwner.ts+++ b/packages/playwright-core/src/client/channelOwner.ts@@ -18,11 +18,10 @@ import { EventEmitter } from 'events';import type * as channels from '../protocol/channels';import type { Validator } from '../protocol/validator';import { createScheme, ValidationError } from '../protocol/validator';-import { debugLogger } from '../utils/debugLogger';+import { debugLogger } from '../common/debugLogger';import type { ParsedStackTrace } from '../utils/stackTrace';import { captureRawStack, captureStackTrace } from '../utils/stackTrace';-import { isUnderTest } from '../utils';-import { zones } from '../utils/zones';+import { isUnderTest, zones } from '../utils';import type { ClientInstrumentation } from './clientInstrumentation';import type { Connection } from './connection';import type { Logger } from './types';diff --git a/packages/playwright-core/src/client/connection.ts b/packages/playwright-core/src/client/connection.tsindex 833f3fdab0..0bfcb8947b 100644--- a/packages/playwright-core/src/client/connection.ts+++ b/packages/playwright-core/src/client/connection.ts@@ -33,7 +33,7 @@ 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 { debugLogger } from '../common/debugLogger';import { SelectorsOwner } from './selectors';import { Android, AndroidSocket, AndroidDevice } from './android';import type { ParsedStackTrace } from '../utils/stackTrace';diff --git a/packages/playwright-core/src/client/electron.ts b/packages/playwright-core/src/client/electron.tsindex f7d996621e..a4b2d2ad89 100644--- a/packages/playwright-core/src/client/electron.ts+++ b/packages/playwright-core/src/client/electron.ts@@ -19,7 +19,7 @@ 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 '../utils/timeoutSettings';+import { TimeoutSettings } from '../common/timeoutSettings';import { headersObjectToArray } from '../utils';import { BrowserContext } from './browserContext';import { ChannelOwner } from './channelOwner';diff --git a/packages/playwright-core/src/client/elementHandle.ts b/packages/playwright-core/src/client/elementHandle.tsindex a5dfdd2e1f..8377c042cf 100644--- a/packages/playwright-core/src/client/elementHandle.ts+++ b/packages/playwright-core/src/client/elementHandle.ts@@ -30,7 +30,7 @@ import type { BrowserContext } from './browserContext';import { WritableStream } from './writableStream';import { pipeline } from 'stream';import { promisify } from 'util';-import { debugLogger } from '../utils/debugLogger';+import { debugLogger } from '../common/debugLogger';const pipelineAsync = promisify(pipeline);diff --git a/packages/playwright-core/src/client/fetch.ts b/packages/playwright-core/src/client/fetch.tsindex d202eccc94..8c9ab15266 100644--- a/packages/playwright-core/src/client/fetch.ts+++ b/packages/playwright-core/src/client/fetch.ts@@ -21,7 +21,7 @@ import type { Serializable } from '../../types/structs';import type * as api from '../../types/types';import type { HeadersArray } from '../common/types';import type * as channels from '../protocol/channels';-import { kBrowserOrContextClosedError } from '../utils/errors';+import { kBrowserOrContextClosedError } from '../common/errors';import { assert, headersObjectToArray, isFilePayload, isString, mkdirIfNeeded, objectToArray } from '../utils';import { ChannelOwner } from './channelOwner';import * as network from './network';diff --git a/packages/playwright-core/src/client/frame.ts b/packages/playwright-core/src/client/frame.tsindex b7ff0fab7e..285025267e 100644--- a/packages/playwright-core/src/client/frame.ts+++ b/packages/playwright-core/src/client/frame.ts@@ -32,7 +32,7 @@ import { kLifecycleEvents } from './types';import { urlMatches } from './clientHelper';import type * as api from '../../types/types';import type * as structs from '../../types/structs';-import { debugLogger } from '../utils/debugLogger';+import { debugLogger } from '../common/debugLogger';export type WaitForNavigationOptions = {timeout?: number,diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.tsindex 94d4f414ea..3b1ed97a7e 100644--- a/packages/playwright-core/src/client/page.ts+++ b/packages/playwright-core/src/client/page.ts@@ -17,7 +17,7 @@import { Events } from './events';import { assert } from '../utils';-import { TimeoutSettings } from '../utils/timeoutSettings';+import { TimeoutSettings } from '../common/timeoutSettings';import type { ParsedStackTrace } from '../utils/stackTrace';import type * as channels from '../protocol/channels';import { parseError, serializeError } from '../protocol/serializers';@@ -47,7 +47,7 @@ import path from 'path';import type { Size, URLMatch, Headers, LifecycleEvent, WaitForEventOptions, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions } from './types';import { evaluationScript, urlMatches } from './clientHelper';import { isString, isRegExp, isObject, mkdirIfNeeded, headersObjectToArray } from '../utils';-import { isSafeCloseError } from '../utils/errors';+import { isSafeCloseError } from '../common/errors';import { Video } from './video';import { Artifact } from './artifact';import type { APIRequestContext } from './fetch';diff --git a/packages/playwright-core/src/client/playwright.ts b/packages/playwright-core/src/client/playwright.tsindex d16a087883..3d510f185d 100644--- a/packages/playwright-core/src/client/playwright.ts+++ b/packages/playwright-core/src/client/playwright.ts@@ -15,8 +15,8 @@*/import type * as channels from '../protocol/channels';-import { TimeoutError } from '../utils/errors';-import * as socks from '../utils/socksProxy';+import { TimeoutError } from '../common/errors';+import * as socks from '../common/socksProxy';import { Android } from './android';import { BrowserType } from './browserType';import { ChannelOwner } from './channelOwner';diff --git a/packages/playwright-core/src/client/waiter.ts b/packages/playwright-core/src/client/waiter.tsindex 2a04df7d91..5d85a9c770 100644--- a/packages/playwright-core/src/client/waiter.ts+++ b/packages/playwright-core/src/client/waiter.ts@@ -16,7 +16,7 @@import type { EventEmitter } from 'events';import { rewriteErrorMessage } from '../utils/stackTrace';-import { TimeoutError } from '../utils/errors';+import { TimeoutError } from '../common/errors';import { createGuid } from '../utils';import type * as channels from '../protocol/channels';import type { ChannelOwner } from './channelOwner';diff --git a/packages/playwright-core/src/common/DEPS.list b/packages/playwright-core/src/common/DEPS.listnew file mode 100644index 0000000000..53c5b6c35e--- /dev/null+++ b/packages/playwright-core/src/common/DEPS.list@@ -0,0 +1,2 @@+[*]+../utils/\ No newline at end of filediff --git a/packages/playwright-core/src/utils/debugLogger.ts b/packages/playwright-core/src/common/debugLogger.tssimilarity index 100%rename from packages/playwright-core/src/utils/debugLogger.tsrename to packages/playwright-core/src/common/debugLogger.tsdiff --git a/packages/playwright-core/src/utils/errors.ts b/packages/playwright-core/src/common/errors.tssimilarity index 100%rename from packages/playwright-core/src/utils/errors.tsrename to packages/playwright-core/src/common/errors.tsdiff --git a/packages/playwright-core/src/utils/netUtils.ts b/packages/playwright-core/src/common/netUtils.tssimilarity index 100%rename from packages/playwright-core/src/utils/netUtils.tsrename to packages/playwright-core/src/common/netUtils.tsdiff --git a/packages/playwright-core/src/utils/socksProxy.ts b/packages/playwright-core/src/common/socksProxy.tssimilarity index 99%rename from packages/playwright-core/src/utils/socksProxy.tsrename to packages/playwright-core/src/common/socksProxy.tsindex 4ef0474109..504afdfc6a 100644--- a/packages/playwright-core/src/utils/socksProxy.ts+++ b/packages/playwright-core/src/common/socksProxy.ts@@ -21,7 +21,7 @@ import net from 'net';import util from 'util';import { debugLogger } from './debugLogger';import { createSocket } from './netUtils';-import { assert, createGuid } from './';+import { assert, createGuid } from '../utils';const dnsLookupAsync = util.promisify(dns.lookup);diff --git a/packages/playwright-core/src/utils/timeoutSettings.ts b/packages/playwright-core/src/common/timeoutSettings.tssimilarity index 98%rename from packages/playwright-core/src/utils/timeoutSettings.tsrename to packages/playwright-core/src/common/timeoutSettings.tsindex 57b58df1fc..7708219444 100644--- a/packages/playwright-core/src/utils/timeoutSettings.ts+++ b/packages/playwright-core/src/common/timeoutSettings.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { debugMode } from './';+import { debugMode } from '../utils';export const DEFAULT_TIMEOUT = 30000;diff --git a/packages/playwright-core/src/common/userAgent.ts b/packages/playwright-core/src/common/userAgent.tsnew file mode 100644index 0000000000..f335220634--- /dev/null+++ b/packages/playwright-core/src/common/userAgent.ts@@ -0,0 +1,81 @@+/**+ * 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 { execSync } from 'child_process';+import fs from 'fs';+import os from 'os';+import { parseOSReleaseText } from '../utils/ubuntuVersion';++let cachedUserAgent: string | undefined;++export function getUserAgent(): string {+ if (cachedUserAgent)+ return cachedUserAgent;+ try {+ cachedUserAgent = determineUserAgent();+ } catch (e) {+ cachedUserAgent = 'Playwright/unknown';+ }+ return cachedUserAgent;+}++function determineUserAgent(): string {+ let osIdentifier = 'unknown';+ let osVersion = 'unknown';+ if (process.platform === 'win32') {+ const version = os.release().split('.');+ osIdentifier = 'windows';+ osVersion = `${version[0]}.${version[1]}`;+ } else if (process.platform === 'darwin') {+ const version = execSync('sw_vers -productVersion', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim().split('.');+ osIdentifier = 'macOS';+ osVersion = `${version[0]}.${version[1]}`;+ } else if (process.platform === 'linux') {+ try {+ // List of /etc/os-release values for different distributions could be+ // found here: https://gist.github.com/aslushnikov/8ceddb8288e4cf9db3039c02e0f4fb75+ const osReleaseText = fs.readFileSync('/etc/os-release', 'utf8');+ const fields = parseOSReleaseText(osReleaseText);+ osIdentifier = fields.get('id') || 'unknown';+ osVersion = fields.get('version_id') || 'unknown';+ } catch (e) {+ // Linux distribution without /etc/os-release.+ // Default to linux/unknown.+ osIdentifier = 'linux';+ }+ }++ const { langName, langVersion } = getClientLanguage();+ return `Playwright/${getPlaywrightVersion()} (${os.arch()}; ${osIdentifier} ${osVersion}) ${langName}/${langVersion}`;+}++export function getClientLanguage(): { langName: string, langVersion: string } {+ let langName = 'unknown';+ let langVersion = 'unknown';+ if (!process.env.PW_LANG_NAME) {+ langName = 'node';+ langVersion = process.version.substring(1).split('.').slice(0, 2).join('.');+ } else if (['node', 'python', 'java', 'csharp'].includes(process.env.PW_LANG_NAME)) {+ langName = process.env.PW_LANG_NAME;+ langVersion = process.env.PW_LANG_NAME_VERSION ?? 'unknown';+ }+ return { langName, langVersion };+}++export function getPlaywrightVersion(majorMinorOnly = false) {+ const packageJson = require('./../../package.json');+ return majorMinorOnly ? packageJson.version.split('.').slice(0, 2).join('.') : packageJson.version;+}diff --git a/packages/playwright-core/src/grid/DEPS.list b/packages/playwright-core/src/grid/DEPS.listindex 2ad866e7b1..9af6177885 100644--- a/packages/playwright-core/src/grid/DEPS.list+++ b/packages/playwright-core/src/grid/DEPS.list@@ -1,5 +1,6 @@[*]../client/+../common/../dispatchers/../remote/../server/diff --git a/packages/playwright-core/src/grid/gridAgent.ts b/packages/playwright-core/src/grid/gridAgent.tsindex 1787f51897..5fc830a16c 100644--- a/packages/playwright-core/src/grid/gridAgent.ts+++ b/packages/playwright-core/src/grid/gridAgent.ts@@ -17,7 +17,7 @@import debug from 'debug';import WebSocket from 'ws';import { fork } from 'child_process';-import { getPlaywrightVersion } from '../utils';+import { getPlaywrightVersion } from '../common/userAgent';export function launchGridAgent(agentId: string, gridURL: string) {const log = debug(`pw:grid:agent:${agentId}`);diff --git a/packages/playwright-core/src/grid/gridClient.ts b/packages/playwright-core/src/grid/gridClient.tsindex 0383a5ef17..82966bdb7d 100644--- a/packages/playwright-core/src/grid/gridClient.ts+++ b/packages/playwright-core/src/grid/gridClient.ts@@ -17,7 +17,7 @@import WebSocket from 'ws';import { Connection } from '../client/connection';import type { Playwright } from '../client/playwright';-import { getPlaywrightVersion } from '../utils';+import { getPlaywrightVersion } from '../common/userAgent';export class GridClient {private _ws: WebSocket;diff --git a/packages/playwright-core/src/grid/gridServer.ts b/packages/playwright-core/src/grid/gridServer.tsindex 7cb4620f01..e0aa3f6277 100644--- a/packages/playwright-core/src/grid/gridServer.ts+++ b/packages/playwright-core/src/grid/gridServer.ts@@ -20,7 +20,8 @@ import { URL } from 'url';import type { Server as WebSocketServer } from 'ws';import type WebSocket from 'ws';import { HttpServer } from '../utils/httpServer';-import { assert, createGuid, getPlaywrightVersion } from '../utils';+import { assert, createGuid } from '../utils';+import { getPlaywrightVersion } from '../common/userAgent';export type GridAgentLaunchOptions = {agentId: string,diff --git a/packages/playwright-core/src/grid/gridWorker.ts b/packages/playwright-core/src/grid/gridWorker.tsindex 351f694a90..5201d9dbf5 100644--- a/packages/playwright-core/src/grid/gridWorker.ts+++ b/packages/playwright-core/src/grid/gridWorker.ts@@ -18,7 +18,7 @@ import WebSocket from 'ws';import debug from 'debug';import { createPlaywright, PlaywrightDispatcher, DispatcherConnection, Root } from '../server';import { gracefullyCloseAll } from '../utils/processLauncher';-import { SocksProxy } from '../utils/socksProxy';+import { SocksProxy } from '../common/socksProxy';function launchGridWorker(gridURL: string, agentId: string, workerId: string) {const log = debug(`pw:grid:worker:${workerId}`);diff --git a/packages/playwright-core/src/protocol/DEPS.list b/packages/playwright-core/src/protocol/DEPS.listindex b633cc6bb5..bf64b324f1 100644--- a/packages/playwright-core/src/protocol/DEPS.list+++ b/packages/playwright-core/src/protocol/DEPS.list@@ -1,3 +1,4 @@[*]+../common/../utils/diff --git a/packages/playwright-core/src/protocol/serializers.ts b/packages/playwright-core/src/protocol/serializers.tsindex 87843538a5..50342c470e 100644--- a/packages/playwright-core/src/protocol/serializers.ts+++ b/packages/playwright-core/src/protocol/serializers.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { TimeoutError } from '../utils/errors';+import { TimeoutError } from '../common/errors';import type { SerializedError, SerializedValue } from './channels';export function serializeError(e: any): SerializedError {diff --git a/packages/playwright-core/src/remote/DEPS.list b/packages/playwright-core/src/remote/DEPS.listindex 4874d0e91a..fc3ae7c209 100644--- a/packages/playwright-core/src/remote/DEPS.list+++ b/packages/playwright-core/src/remote/DEPS.list@@ -1,5 +1,6 @@[*]../client/+../common/../dispatchers/../server/../utils/diff --git a/packages/playwright-core/src/remote/playwrightConnection.ts b/packages/playwright-core/src/remote/playwrightConnection.tsindex e3c03fc468..6d10db7237 100644--- a/packages/playwright-core/src/remote/playwrightConnection.ts+++ b/packages/playwright-core/src/remote/playwrightConnection.ts@@ -21,7 +21,7 @@ import { Browser } from '../server/browser';import { serverSideCallMetadata } from '../server/instrumentation';import { gracefullyCloseAll } from '../utils/processLauncher';import { registry } from '../server';-import { SocksProxy } from '../utils/socksProxy';+import { SocksProxy } from '../common/socksProxy';export class PlaywrightConnection {private _ws: WebSocket;diff --git a/packages/playwright-core/src/server/DEPS.list b/packages/playwright-core/src/server/DEPS.listindex 493f5c038e..da68a5e95e 100644--- a/packages/playwright-core/src/server/DEPS.list+++ b/packages/playwright-core/src/server/DEPS.list@@ -1,19 +1,20 @@[*]+../common/../generated/../protocol/../utils/./-common/-injected/-supplements/-trace/recorder/tracing.ts+./common/+./injected/+./supplements/+./trace/recorder/tracing.ts[browserContext.ts]-supplements/har/+./supplements/har/[playwright.ts]-android/-chromium/-electron/-firefox/-webkit/+./android/+./chromium/+./electron/+./firefox/+./webkit/diff --git a/packages/playwright-core/src/server/android/DEPS.list b/packages/playwright-core/src/server/android/DEPS.listindex 1c899cb3f3..3bd6e65247 100644--- a/packages/playwright-core/src/server/android/DEPS.list+++ b/packages/playwright-core/src/server/android/DEPS.list@@ -1,5 +1,6 @@[*]../+../../common/../../protocol/../../utils/../chromium/diff --git a/packages/playwright-core/src/server/android/android.ts b/packages/playwright-core/src/server/android/android.tsindex 0428b5df22..7ebb960a72 100644--- a/packages/playwright-core/src/server/android/android.ts+++ b/packages/playwright-core/src/server/android/android.ts@@ -30,9 +30,9 @@ import { ProgressController } from '../progress';import { CRBrowser } from '../chromium/crBrowser';import { helper } from '../helper';import { PipeTransport } from '../../protocol/transport';-import { RecentLogsCollector } from '../../utils/debugLogger';+import { RecentLogsCollector } from '../../common/debugLogger';import { gracefullyCloseSet } from '../../utils/processLauncher';-import { TimeoutSettings } from '../../utils/timeoutSettings';+import { TimeoutSettings } from '../../common/timeoutSettings';import type { AndroidWebView } from '../../protocol/channels';import { SdkObject, serverSideCallMetadata } from '../instrumentation';diff --git a/packages/playwright-core/src/server/browser.ts b/packages/playwright-core/src/server/browser.tsindex 617cc1bedf..e108978c68 100644--- a/packages/playwright-core/src/server/browser.ts+++ b/packages/playwright-core/src/server/browser.ts@@ -20,7 +20,7 @@ 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 { RecentLogsCollector } from '../common/debugLogger';import type { CallMetadata } from './instrumentation';import { SdkObject } from './instrumentation';import { Artifact } from './artifact';diff --git a/packages/playwright-core/src/server/browserContext.ts b/packages/playwright-core/src/server/browserContext.tsindex 82ee981489..15ff0282cf 100644--- a/packages/playwright-core/src/server/browserContext.ts+++ b/packages/playwright-core/src/server/browserContext.ts@@ -16,7 +16,7 @@*/import * as os from 'os';-import { TimeoutSettings } from '../utils/timeoutSettings';+import { TimeoutSettings } from '../common/timeoutSettings';import { debugMode, mkdirIfNeeded, createGuid } from '../utils';import type { Browser, BrowserOptions } from './browser';import type { Download } from './download';diff --git a/packages/playwright-core/src/server/browserType.ts b/packages/playwright-core/src/server/browserType.tsindex f68cffe12c..484839bb08 100644--- a/packages/playwright-core/src/server/browserType.ts+++ b/packages/playwright-core/src/server/browserType.ts@@ -30,10 +30,10 @@ import { PipeTransport } from './pipeTransport';import type { Progress } from './progress';import { ProgressController } from './progress';import type * as types from './types';-import { DEFAULT_TIMEOUT, TimeoutSettings } from '../utils/timeoutSettings';+import { DEFAULT_TIMEOUT, TimeoutSettings } from '../common/timeoutSettings';import { debugMode, existsAsync } from '../utils';import { helper } from './helper';-import { RecentLogsCollector } from '../utils/debugLogger';+import { RecentLogsCollector } from '../common/debugLogger';import type { CallMetadata } from './instrumentation';import { SdkObject } from './instrumentation';diff --git a/packages/playwright-core/src/server/chromium/chromium.ts b/packages/playwright-core/src/server/chromium/chromium.tsindex d113b99746..fce45e98f8 100644--- a/packages/playwright-core/src/server/chromium/chromium.ts+++ b/packages/playwright-core/src/server/chromium/chromium.ts@@ -30,13 +30,14 @@ import { CRDevTools } from './crDevTools';import type { BrowserOptions, BrowserProcess, PlaywrightOptions } from '../browser';import { Browser } from '../browser';import type * as types from '../types';-import type { HTTPRequestParams } from '../../utils';-import { fetchData } from '../../utils';-import { debugMode, getUserAgent, headersArrayToObject, removeFolders, streamToString, wrapInASCIIBox } from '../../utils';-import { RecentLogsCollector } from '../../utils/debugLogger';+import type { HTTPRequestParams } from '../../common/netUtils';+import { fetchData } from '../../common/netUtils';+import { getUserAgent } from '../../common/userAgent';+import { debugMode, headersArrayToObject, removeFolders, streamToString, wrapInASCIIBox } from '../../utils';+import { RecentLogsCollector } from '../../common/debugLogger';import type { Progress } from '../progress';import { ProgressController } from '../progress';-import { TimeoutSettings } from '../../utils/timeoutSettings';+import { TimeoutSettings } from '../../common/timeoutSettings';import { helper } from '../helper';import type { CallMetadata } from '../instrumentation';import http from 'http';diff --git a/packages/playwright-core/src/server/chromium/crConnection.ts b/packages/playwright-core/src/server/chromium/crConnection.tsindex bdbed342d9..520fe2709c 100644--- a/packages/playwright-core/src/server/chromium/crConnection.ts+++ b/packages/playwright-core/src/server/chromium/crConnection.ts@@ -20,8 +20,8 @@ import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../import type { Protocol } from './protocol';import { EventEmitter } from 'events';import { rewriteErrorMessage } from '../../utils/stackTrace';-import type { RecentLogsCollector } from '../../utils/debugLogger';-import { debugLogger } from '../../utils/debugLogger';+import type { RecentLogsCollector } from '../../common/debugLogger';+import { debugLogger } from '../../common/debugLogger';import type { ProtocolLogger } from '../types';import { helper } from '../helper';import { ProtocolError } from '../protocolError';diff --git a/packages/playwright-core/src/server/chromium/crCoverage.ts b/packages/playwright-core/src/server/chromium/crCoverage.tsindex 9f91e11ac0..e1a2e13219 100644--- a/packages/playwright-core/src/server/chromium/crCoverage.ts+++ b/packages/playwright-core/src/server/chromium/crCoverage.ts@@ -16,8 +16,8 @@*/import type { CRSession } from './crConnection';-import type { RegisteredListener } from '../../utils/eventsHelper';-import { eventsHelper } from '../../utils/eventsHelper';+import type { RegisteredListener } from '../../utils';+import { eventsHelper } from '../../utils';import type { Protocol } from './protocol';import type * as types from '../types';import { assert } from '../../utils';diff --git a/packages/playwright-core/src/server/chromium/crNetworkManager.ts b/packages/playwright-core/src/server/chromium/crNetworkManager.tsindex e517c0b89b..ba98fcbd7a 100644--- a/packages/playwright-core/src/server/chromium/crNetworkManager.ts+++ b/packages/playwright-core/src/server/chromium/crNetworkManager.ts@@ -18,8 +18,8 @@import type { CRSession } from './crConnection';import type { Page } from '../page';import { helper } from '../helper';-import type { RegisteredListener } from '../../utils/eventsHelper';-import { eventsHelper } from '../../utils/eventsHelper';+import type { RegisteredListener } from '../../utils';+import { eventsHelper } from '../../utils';import type { Protocol } from './protocol';import * as network from '../network';import type * as frames from '../frames';diff --git a/packages/playwright-core/src/server/chromium/crPage.ts b/packages/playwright-core/src/server/chromium/crPage.tsindex 73fe02568f..e8b0305439 100644--- a/packages/playwright-core/src/server/chromium/crPage.ts+++ b/packages/playwright-core/src/server/chromium/crPage.ts@@ -16,8 +16,8 @@*/import path from 'path';-import type { RegisteredListener } from '../../utils/eventsHelper';-import { eventsHelper } from '../../utils/eventsHelper';+import type { RegisteredListener } from '../../utils';+import { eventsHelper } from '../../utils';import { registry } from '../registry';import { rewriteErrorMessage } from '../../utils/stackTrace';import { assert, createGuid, headersArrayToObject } from '../../utils';diff --git a/packages/playwright-core/src/server/common/DEPS.list b/packages/playwright-core/src/server/common/DEPS.listindex b03928f3ea..e43dcb5d9f 100644--- a/packages/playwright-core/src/server/common/DEPS.list+++ b/packages/playwright-core/src/server/common/DEPS.list@@ -1,3 +1 @@[*]--diff --git a/packages/playwright-core/src/server/dispatchers/DEPS.list b/packages/playwright-core/src/server/dispatchers/DEPS.listindex 67b5329151..932624b854 100644--- a/packages/playwright-core/src/server/dispatchers/DEPS.list+++ b/packages/playwright-core/src/server/dispatchers/DEPS.list@@ -1,4 +1,5 @@[*]+../../common/../../protocol/../../utils/../**diff --git a/packages/playwright-core/src/server/dispatchers/browserTypeDispatcher.ts b/packages/playwright-core/src/server/dispatchers/browserTypeDispatcher.tsindex cd6c321921..185439e8fb 100644--- a/packages/playwright-core/src/server/dispatchers/browserTypeDispatcher.ts+++ b/packages/playwright-core/src/server/dispatchers/browserTypeDispatcher.ts@@ -22,8 +22,8 @@ import { Dispatcher } from './dispatcher';import { BrowserContextDispatcher } from './browserContextDispatcher';import type { CallMetadata } from '../instrumentation';import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher';-import { getUserAgent } from '../../utils';-import * as socks from '../../utils/socksProxy';+import { getUserAgent } from '../../common/userAgent';+import * as socks from '../../common/socksProxy';import EventEmitter from 'events';import { ProgressController } from '../progress';import { WebSocketTransport } from '../transport';diff --git a/packages/playwright-core/src/server/dispatchers/dispatcher.ts b/packages/playwright-core/src/server/dispatchers/dispatcher.tsindex 9451407986..31384f1dd9 100644--- a/packages/playwright-core/src/server/dispatchers/dispatcher.ts+++ b/packages/playwright-core/src/server/dispatchers/dispatcher.ts@@ -21,7 +21,7 @@ import type { Validator } from '../../protocol/validator';import { createScheme, ValidationError } from '../../protocol/validator';import { assert, debugAssert, isUnderTest, monotonicTime } from '../../utils';import { tOptional } from '../../protocol/validatorPrimitives';-import { kBrowserOrContextClosedError } from '../../utils/errors';+import { kBrowserOrContextClosedError } from '../../common/errors';import type { CallMetadata } from '../instrumentation';import { SdkObject } from '../instrumentation';import { rewriteErrorMessage } from '../../utils/stackTrace';diff --git a/packages/playwright-core/src/server/dispatchers/playwrightDispatcher.ts b/packages/playwright-core/src/server/dispatchers/playwrightDispatcher.tsindex 1859e44339..da505eadcc 100644--- a/packages/playwright-core/src/server/dispatchers/playwrightDispatcher.ts+++ b/packages/playwright-core/src/server/dispatchers/playwrightDispatcher.ts@@ -18,8 +18,8 @@ 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 '../../utils/socksProxy';-import { SocksProxy } from '../../utils/socksProxy';+import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../../common/socksProxy';+import { SocksProxy } from '../../common/socksProxy';import type * as types from '../types';import { AndroidDispatcher } from './androidDispatcher';import { BrowserTypeDispatcher } from './browserTypeDispatcher';diff --git a/packages/playwright-core/src/server/electron/DEPS.list b/packages/playwright-core/src/server/electron/DEPS.listindex 4bb49bdb51..99583c8624 100644--- a/packages/playwright-core/src/server/electron/DEPS.list+++ b/packages/playwright-core/src/server/electron/DEPS.list@@ -1,4 +1,5 @@[*]../+../../common/../../utils/../chromium/diff --git a/packages/playwright-core/src/server/electron/electron.ts b/packages/playwright-core/src/server/electron/electron.tsindex 20a74671b9..c055c8031e 100644--- a/packages/playwright-core/src/server/electron/electron.ts+++ b/packages/playwright-core/src/server/electron/electron.ts@@ -25,7 +25,7 @@ import type { CRPage } from '../chromium/crPage';import { CRExecutionContext } from '../chromium/crExecutionContext';import * as js from '../javascript';import type { Page } from '../page';-import { TimeoutSettings } from '../../utils/timeoutSettings';+import { TimeoutSettings } from '../../common/timeoutSettings';import { wrapInASCIIBox } from '../../utils';import { WebSocketTransport } from '../transport';import { launchProcess, envArrayToObject } from '../../utils/processLauncher';@@ -34,11 +34,11 @@ import type { BrowserWindow } from 'electron';import type { Progress } from '../progress';import { ProgressController } from '../progress';import { helper } from '../helper';-import { eventsHelper } from '../../utils/eventsHelper';+import { eventsHelper } from '../../utils';import type { BrowserOptions, BrowserProcess, PlaywrightOptions } from '../browser';import type * as childProcess from 'child_process';import * as readline from 'readline';-import { RecentLogsCollector } from '../../utils/debugLogger';+import { RecentLogsCollector } from '../../common/debugLogger';import { serverSideCallMetadata, SdkObject } from '../instrumentation';import type * as channels from '../../protocol/channels';import type { BrowserContextOptions } from '../types';diff --git a/packages/playwright-core/src/server/fetch.ts b/packages/playwright-core/src/server/fetch.tsindex 873d5e041d..7514b53e40 100644--- a/packages/playwright-core/src/server/fetch.ts+++ b/packages/playwright-core/src/server/fetch.ts@@ -24,8 +24,9 @@ import url from 'url';import zlib from 'zlib';import type { HTTPCredentials } from '../../types/types';import type * as channels from '../protocol/channels';-import { TimeoutSettings } from '../utils/timeoutSettings';-import { assert, createGuid, getUserAgent, monotonicTime } from '../utils';+import { TimeoutSettings } from '../common/timeoutSettings';+import { getUserAgent } from '../common/userAgent';+import { assert, createGuid, monotonicTime } from '../utils';import { BrowserContext } from './browserContext';import { CookieStore, domainMatches } from './cookieStore';import { MultipartFormData } from './formData';diff --git a/packages/playwright-core/src/server/firefox/ffBrowser.ts b/packages/playwright-core/src/server/firefox/ffBrowser.tsindex 6d898f8afb..3483e1c82a 100644--- a/packages/playwright-core/src/server/firefox/ffBrowser.ts+++ b/packages/playwright-core/src/server/firefox/ffBrowser.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { kBrowserClosedError } from '../../utils/errors';+import { kBrowserClosedError } from '../../common/errors';import { assert } from '../../utils';import type { BrowserOptions } from '../browser';import { Browser } from '../browser';diff --git a/packages/playwright-core/src/server/firefox/ffConnection.ts b/packages/playwright-core/src/server/firefox/ffConnection.tsindex d39ca17b1e..41bcfe4636 100644--- a/packages/playwright-core/src/server/firefox/ffConnection.ts+++ b/packages/playwright-core/src/server/firefox/ffConnection.ts@@ -20,8 +20,8 @@ import { assert } from '../../utils';import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';import type { Protocol } from './protocol';import { rewriteErrorMessage } from '../../utils/stackTrace';-import type { RecentLogsCollector } from '../../utils/debugLogger';-import { debugLogger } from '../../utils/debugLogger';+import type { RecentLogsCollector } from '../../common/debugLogger';+import { debugLogger } from '../../common/debugLogger';import type { ProtocolLogger } from '../types';import { helper } from '../helper';import { ProtocolError } from '../protocolError';diff --git a/packages/playwright-core/src/server/firefox/ffNetworkManager.ts b/packages/playwright-core/src/server/firefox/ffNetworkManager.tsindex c0018a0c42..75467d8c6e 100644--- a/packages/playwright-core/src/server/firefox/ffNetworkManager.ts+++ b/packages/playwright-core/src/server/firefox/ffNetworkManager.ts@@ -15,8 +15,8 @@* limitations under the License.*/-import type { RegisteredListener } from '../../utils/eventsHelper';-import { eventsHelper } from '../../utils/eventsHelper';+import type { RegisteredListener } from '../../utils';+import { eventsHelper } from '../../utils';import type { FFSession } from './ffConnection';import type { Page } from '../page';import * as network from '../network';diff --git a/packages/playwright-core/src/server/firefox/ffPage.ts b/packages/playwright-core/src/server/firefox/ffPage.tsindex e2df66f5bc..308bc82eab 100644--- a/packages/playwright-core/src/server/firefox/ffPage.ts+++ b/packages/playwright-core/src/server/firefox/ffPage.ts@@ -18,8 +18,8 @@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 { RegisteredListener } from '../../utils';+import { eventsHelper } from '../../utils';import { assert } from '../../utils';import type { PageBinding, PageDelegate } from '../page';import { Page, Worker } from '../page';@@ -33,7 +33,7 @@ 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 { debugLogger } from '../../common/debugLogger';import { ManualPromise } from '../../utils';export const UTILITY_WORLD_NAME = '__playwright_utility_world__';diff --git a/packages/playwright-core/src/server/frames.ts b/packages/playwright-core/src/server/frames.tsindex ba8758c65b..442319ba2a 100644--- a/packages/playwright-core/src/server/frames.ts+++ b/packages/playwright-core/src/server/frames.ts@@ -19,8 +19,8 @@ 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 type { RegisteredListener } from '../utils';+import { eventsHelper } from '../utils';import * as js from './javascript';import * as network from './network';import type { Dialog } from './dialog';@@ -31,7 +31,7 @@ import type { Progress } from './progress';import { ProgressController } from './progress';import { assert, constructURLBasedOnBaseURL, makeWaitForNextTask } from '../utils';import { ManualPromise } from '../utils';-import { debugLogger } from '../utils/debugLogger';+import { debugLogger } from '../common/debugLogger';import type { CallMetadata } from './instrumentation';import { serverSideCallMetadata, SdkObject } from './instrumentation';import { type InjectedScript } from './injected/injectedScript';diff --git a/packages/playwright-core/src/server/helper.ts b/packages/playwright-core/src/server/helper.tsindex a2190a1bed..89241e5bfe 100644--- a/packages/playwright-core/src/server/helper.ts+++ b/packages/playwright-core/src/server/helper.ts@@ -18,9 +18,9 @@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 { debugLogger } from '../common/debugLogger';+import type { RegisteredListener } from '../utils';+import { eventsHelper } from '../utils';class Helper {static completeUserURL(urlString: string): string {diff --git a/packages/playwright-core/src/server/page.ts b/packages/playwright-core/src/server/page.tsindex 3971f79a68..8a2fd2745f 100644--- a/packages/playwright-core/src/server/page.ts+++ b/packages/playwright-core/src/server/page.ts@@ -22,7 +22,7 @@ import * as js from './javascript';import * as network from './network';import type { ScreenshotOptions } from './screenshotter';import { Screenshotter } from './screenshotter';-import { TimeoutSettings } from '../utils/timeoutSettings';+import { TimeoutSettings } from '../common/timeoutSettings';import type * as types from './types';import { BrowserContext } from './browserContext';import { ConsoleMessage } from './console';@@ -32,7 +32,7 @@ import type { Progress } from './progress';import { ProgressController } from './progress';import { assert, isError } from '../utils';import { ManualPromise } from '../utils';-import { debugLogger } from '../utils/debugLogger';+import { debugLogger } from '../common/debugLogger';import type { ImageComparatorOptions } from '../utils/comparators';import { getComparator } from '../utils/comparators';import type { SelectorInfo, Selectors } from './selectors';diff --git a/packages/playwright-core/src/server/pipeTransport.ts b/packages/playwright-core/src/server/pipeTransport.tsindex 55a4de057a..eb5c63cee3 100644--- a/packages/playwright-core/src/server/pipeTransport.ts+++ b/packages/playwright-core/src/server/pipeTransport.ts@@ -17,7 +17,7 @@import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from './transport';import { makeWaitForNextTask } from '../utils';-import { debugLogger } from '../utils/debugLogger';+import { debugLogger } from '../common/debugLogger';export class PipeTransport implements ConnectionTransport {private _pipeWrite: NodeJS.WritableStream;diff --git a/packages/playwright-core/src/server/playwright.ts b/packages/playwright-core/src/server/playwright.tsindex 54aeb95ac7..e27e41bf25 100644--- a/packages/playwright-core/src/server/playwright.ts+++ b/packages/playwright-core/src/server/playwright.ts@@ -24,7 +24,7 @@ import { Selectors } from './selectors';import { WebKit } from './webkit/webkit';import type { CallMetadata } from './instrumentation';import { createInstrumentation, SdkObject } from './instrumentation';-import { debugLogger } from '../utils/debugLogger';+import { debugLogger } from '../common/debugLogger';import type { Page } from './page';export class Playwright extends SdkObject {diff --git a/packages/playwright-core/src/server/progress.ts b/packages/playwright-core/src/server/progress.tsindex 1697ca7e21..196149cd2c 100644--- a/packages/playwright-core/src/server/progress.ts+++ b/packages/playwright-core/src/server/progress.ts@@ -14,9 +14,9 @@* limitations under the License.*/-import { TimeoutError } from '../utils/errors';+import { TimeoutError } from '../common/errors';import { assert, monotonicTime } from '../utils';-import type { LogName } from '../utils/debugLogger';+import type { LogName } from '../common/debugLogger';import type { CallMetadata, Instrumentation, SdkObject } from './instrumentation';import type { ElementHandle } from './dom';import { ManualPromise } from '../utils';diff --git a/packages/playwright-core/src/server/registry/browserFetcher.ts b/packages/playwright-core/src/server/registry/browserFetcher.tsindex b2bdfbe0ba..3c378fb548 100644--- a/packages/playwright-core/src/server/registry/browserFetcher.ts+++ b/packages/playwright-core/src/server/registry/browserFetcher.ts@@ -19,8 +19,9 @@ import extract from 'extract-zip';import fs from 'fs';import os from 'os';import path from 'path';-import { existsAsync, getUserAgent } from '../../utils';-import { debugLogger } from '../../utils/debugLogger';+import { getUserAgent } from '../../common/userAgent';+import { existsAsync } from '../../utils';+import { debugLogger } from '../../common/debugLogger';import { download } from './download';export async function downloadBrowserWithProgressBar(title: string, browserDirectory: string, executablePath: string, downloadURL: string, downloadFileName: string): Promise<boolean> {diff --git a/packages/playwright-core/src/server/registry/dependencies.ts b/packages/playwright-core/src/server/registry/dependencies.tsindex 45585a9377..ab25951753 100644--- a/packages/playwright-core/src/server/registry/dependencies.ts+++ b/packages/playwright-core/src/server/registry/dependencies.ts@@ -22,6 +22,7 @@ import * as utils from '../../utils';import { buildPlaywrightCLICommand } from '.';import { deps } from './nativeDeps';import { getUbuntuVersion } from '../../utils/ubuntuVersion';+import { getPlaywrightVersion } from '../../common/userAgent';const BIN_DIRECTORY = path.join(__dirname, '..', '..', '..', 'bin');const packageJSON = require('../../../package.json');@@ -207,10 +208,10 @@ export async function validateDependenciesLinux(sdkLanguage: string, linuxLddDir];// Ignore patch versions when comparing docker container version and Playwright version:// we **NEVER** roll browsers in patch releases, so native dependencies do not change.- if (dockerInfo && !dockerInfo.driverVersion.startsWith(utils.getPlaywrightVersion(true /* majorMinorOnly */) + '.')) {+ if (dockerInfo && !dockerInfo.driverVersion.startsWith(getPlaywrightVersion(true /* majorMinorOnly */) + '.')) {// We are running in a docker container with unmatching version.// In this case, we know how to install dependencies in it.- const pwVersion = utils.getPlaywrightVersion();+ const pwVersion = getPlaywrightVersion();const requiredDockerImage = dockerInfo.dockerImageName.replace(dockerInfo.driverVersion, pwVersion);errorLines.push(...[`This is most likely due to docker image version not matching Playwright version:`,diff --git a/packages/playwright-core/src/server/registry/download.ts b/packages/playwright-core/src/server/registry/download.tsindex f59f072cd1..e474054b15 100644--- a/packages/playwright-core/src/server/registry/download.ts+++ b/packages/playwright-core/src/server/registry/download.ts@@ -16,7 +16,7 @@import fs from 'fs';import ProgressBar from 'progress';-import { httpRequest } from '../../utils';+import { httpRequest } from '../../common/netUtils';type OnProgressCallback = (downloadedBytes: number, totalBytes: number) => void;type DownloadFileLogger = (message: string) => void;diff --git a/packages/playwright-core/src/server/registry/index.ts b/packages/playwright-core/src/server/registry/index.tsindex 5bb1e4d79c..dffec7579f 100644--- a/packages/playwright-core/src/server/registry/index.ts+++ b/packages/playwright-core/src/server/registry/index.ts@@ -21,8 +21,9 @@ import * as util from 'util';import * as fs from 'fs';import lockfile from 'proper-lockfile';import { getUbuntuVersion } from '../../utils/ubuntuVersion';-import { fetchData } from '../../utils';-import { getFromENV, getAsBooleanFromENV, getClientLanguage, calculateSha1, removeFolders, existsAsync, hostPlatform, canAccessFile, spawnAsync, wrapInASCIIBox, transformCommandsForRoot } from '../../utils';+import { fetchData } from '../../common/netUtils';+import { getClientLanguage } from '../../common/userAgent';+import { getFromENV, getAsBooleanFromENV, calculateSha1, removeFolders, existsAsync, hostPlatform, canAccessFile, spawnAsync, wrapInASCIIBox, transformCommandsForRoot } from '../../utils';import type { DependencyGroup } from './dependencies';import { installDependenciesLinux, installDependenciesWindows, validateDependenciesLinux, validateDependenciesWindows } from './dependencies';import { downloadBrowserWithProgressBar, logPolitely } from './browserFetcher';diff --git a/packages/playwright-core/src/server/supplements/har/harTracer.ts b/packages/playwright-core/src/server/supplements/har/harTracer.tsindex 08dc65b997..d692962450 100644--- a/packages/playwright-core/src/server/supplements/har/harTracer.ts+++ b/packages/playwright-core/src/server/supplements/har/harTracer.ts@@ -22,8 +22,8 @@ import * as network from '../../network';import { Page } from '../../page';import type * as har from './har';import { calculateSha1, monotonicTime } from '../../../utils';-import type { RegisteredListener } from '../../../utils/eventsHelper';-import { eventsHelper } from '../../../utils/eventsHelper';+import type { RegisteredListener } from '../../../utils';+import { eventsHelper } from '../../../utils';import * as mime from 'mime';import { ManualPromise } from '../../../utils';diff --git a/packages/playwright-core/src/server/trace/recorder/DEPS.list b/packages/playwright-core/src/server/trace/recorder/DEPS.listindex 6491e78b6f..266d8369de 100644--- a/packages/playwright-core/src/server/trace/recorder/DEPS.list+++ b/packages/playwright-core/src/server/trace/recorder/DEPS.list@@ -1,5 +1,6 @@[*]../../+../../../common/../../../protocol/../../../utils/../../supplements/har/diff --git a/packages/playwright-core/src/server/trace/recorder/snapshotter.ts b/packages/playwright-core/src/server/trace/recorder/snapshotter.tsindex 4b47b567bd..3dbc6f4af3 100644--- a/packages/playwright-core/src/server/trace/recorder/snapshotter.ts+++ b/packages/playwright-core/src/server/trace/recorder/snapshotter.ts@@ -16,9 +16,9 @@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 { RegisteredListener } from '../../../utils';+import { eventsHelper } from '../../../utils';+import { debugLogger } from '../../../common/debugLogger';import type { Frame } from '../../frames';import type { SnapshotData } from './snapshotterInjected';import { frameSnapshotStreamer } from './snapshotterInjected';diff --git a/packages/playwright-core/src/server/trace/recorder/tracing.ts b/packages/playwright-core/src/server/trace/recorder/tracing.tsindex 930d78ad06..bb2ed4599b 100644--- a/packages/playwright-core/src/server/trace/recorder/tracing.ts+++ b/packages/playwright-core/src/server/trace/recorder/tracing.ts@@ -23,8 +23,8 @@ import type { NameValue } from '../../../common/types';import type { TracingTracingStopChunkParams } from '../../../protocol/channels';import { commandsWithTracingSnapshots } from '../../../protocol/channels';import { ManualPromise } from '../../../utils';-import type { RegisteredListener } from '../../../utils/eventsHelper';-import { eventsHelper } from '../../../utils/eventsHelper';+import type { RegisteredListener } from '../../../utils';+import { eventsHelper } from '../../../utils';import { assert, calculateSha1, createGuid, mkdirIfNeeded, monotonicTime, removeFolders } from '../../../utils';import { Artifact } from '../../artifact';import { BrowserContext } from '../../browserContext';diff --git a/packages/playwright-core/src/server/webkit/wkBrowser.ts b/packages/playwright-core/src/server/webkit/wkBrowser.tsindex 52de427cf1..6a4638d6df 100644--- a/packages/playwright-core/src/server/webkit/wkBrowser.ts+++ b/packages/playwright-core/src/server/webkit/wkBrowser.ts@@ -18,9 +18,8 @@import type { BrowserOptions } from '../browser';import { Browser } from '../browser';import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext';-import type { RegisteredListener } from '../../utils/eventsHelper';-import { eventsHelper } from '../../utils/eventsHelper';-import { assert } from '../../utils';+import type { RegisteredListener } from '../../utils';+import { assert, eventsHelper } from '../../utils';import * as network from '../network';import type { Page, PageBinding, PageDelegate } from '../page';import type { ConnectionTransport } from '../transport';@@ -29,7 +28,7 @@ import type { Protocol } from './protocol';import type { PageProxyMessageReceivedPayload } from './wkConnection';import { kPageProxyMessageReceived, WKConnection, WKSession } from './wkConnection';import { WKPage } from './wkPage';-import { kBrowserClosedError } from '../../utils/errors';+import { kBrowserClosedError } from '../../common/errors';const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15';const BROWSER_VERSION = '15.4';diff --git a/packages/playwright-core/src/server/webkit/wkConnection.ts b/packages/playwright-core/src/server/webkit/wkConnection.tsindex 1fe8dd66fd..a2f6759f6b 100644--- a/packages/playwright-core/src/server/webkit/wkConnection.ts+++ b/packages/playwright-core/src/server/webkit/wkConnection.ts@@ -20,11 +20,11 @@ import { assert } from '../../utils';import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';import type { Protocol } from './protocol';import { rewriteErrorMessage } from '../../utils/stackTrace';-import type { RecentLogsCollector } from '../../utils/debugLogger';-import { debugLogger } from '../../utils/debugLogger';+import type { RecentLogsCollector } from '../../common/debugLogger';+import { debugLogger } from '../../common/debugLogger';import type { ProtocolLogger } from '../types';import { helper } from '../helper';-import { kBrowserClosedError } from '../../utils/errors';+import { kBrowserClosedError } from '../../common/errors';import { ProtocolError } from '../protocolError';// WKPlaywright uses this special id to issue Browser.close command which wediff --git a/packages/playwright-core/src/server/webkit/wkPage.ts b/packages/playwright-core/src/server/webkit/wkPage.tsindex d7fff3b31e..64bb17afe1 100644--- a/packages/playwright-core/src/server/webkit/wkPage.ts+++ b/packages/playwright-core/src/server/webkit/wkPage.ts@@ -24,8 +24,8 @@ import type * as accessibility from '../accessibility';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 { RegisteredListener } from '../../utils';+import { eventsHelper } from '../../utils';import { helper } from '../helper';import type { JSHandle } from '../javascript';import * as network from '../network';@@ -42,7 +42,7 @@ import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './wkInput';import { WKInterceptableRequest, WKRouteImpl } from './wkInterceptableRequest';import { WKProvisionalPage } from './wkProvisionalPage';import { WKWorkers } from './wkWorkers';-import { debugLogger } from '../../utils/debugLogger';+import { debugLogger } from '../../common/debugLogger';import { ManualPromise } from '../../utils';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.tsindex aa6c06e57d..7e7b420a42 100644--- a/packages/playwright-core/src/server/webkit/wkProvisionalPage.ts+++ b/packages/playwright-core/src/server/webkit/wkProvisionalPage.ts@@ -16,8 +16,8 @@import type { WKSession } from './wkConnection';import type { WKPage } from './wkPage';-import type { RegisteredListener } from '../../utils/eventsHelper';-import { eventsHelper } from '../../utils/eventsHelper';+import type { RegisteredListener } from '../../utils';+import { eventsHelper } from '../../utils';import type { Protocol } from './protocol';import { assert } from '../../utils';diff --git a/packages/playwright-core/src/server/webkit/wkWorkers.ts b/packages/playwright-core/src/server/webkit/wkWorkers.tsindex f4b28588d1..ddc2755981 100644--- a/packages/playwright-core/src/server/webkit/wkWorkers.ts+++ b/packages/playwright-core/src/server/webkit/wkWorkers.ts@@ -14,8 +14,8 @@* limitations under the License.*/-import type { RegisteredListener } from '../../utils/eventsHelper';-import { eventsHelper } from '../../utils/eventsHelper';+import type { RegisteredListener } from '../../utils';+import { eventsHelper } from '../../utils';import type { Page } from '../page';import { Worker } from '../page';import type { Protocol } from './protocol';diff --git a/packages/playwright-core/src/utils/index.ts b/packages/playwright-core/src/utils/index.tsindex 05b6fae351..ce5282afd0 100644--- a/packages/playwright-core/src/utils/index.ts+++ b/packages/playwright-core/src/utils/index.ts@@ -15,7 +15,7 @@*/import type { SpawnOptions } from 'child_process';-import { execSync, spawn } from 'child_process';+import { spawn } from 'child_process';import * as crypto from 'crypto';import fs from 'fs';import os from 'os';@@ -24,13 +24,14 @@ import removeFolder from 'rimraf';import type stream from 'stream';import * as URL from 'url';import type { NameValue } from '../protocol/channels';-import { getUbuntuVersionSync, parseOSReleaseText } from './ubuntuVersion';+import { getUbuntuVersionSync } from './ubuntuVersion';+export { eventsHelper } from './eventsHelper';+export type { RegisteredListener } from './eventsHelper';export { ManualPromise } from './manualPromise';export { MultiMap } from './multimap';export { raceAgainstTimeout, TimeoutRunner, TimeoutRunnerError } from './timeoutRunner';-export type { HTTPRequestParams } from './netUtils';-export { httpRequest, fetchData } from './netUtils';+export { zones } from './zones';export const existsAsync = (path: string): Promise<boolean> => new Promise(resolve => fs.stat(path, err => resolve(!err)));@@ -235,66 +236,6 @@ export function canAccessFile(file: string) {}}-let cachedUserAgent: string | undefined;-export function getUserAgent(): string {- if (cachedUserAgent)- return cachedUserAgent;- try {- cachedUserAgent = determineUserAgent();- } catch (e) {- cachedUserAgent = 'Playwright/unknown';- }- return cachedUserAgent;-}--function determineUserAgent(): string {- let osIdentifier = 'unknown';- let osVersion = 'unknown';- if (process.platform === 'win32') {- const version = os.release().split('.');- osIdentifier = 'windows';- osVersion = `${version[0]}.${version[1]}`;- } else if (process.platform === 'darwin') {- const version = execSync('sw_vers -productVersion', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim().split('.');- osIdentifier = 'macOS';- osVersion = `${version[0]}.${version[1]}`;- } else if (process.platform === 'linux') {- try {- // List of /etc/os-release values for different distributions could be- // found here: https://gist.github.com/aslushnikov/8ceddb8288e4cf9db3039c02e0f4fb75- const osReleaseText = fs.readFileSync('/etc/os-release', 'utf8');- const fields = parseOSReleaseText(osReleaseText);- osIdentifier = fields.get('id') || 'unknown';- osVersion = fields.get('version_id') || 'unknown';- } catch (e) {- // Linux distribution without /etc/os-release.- // Default to linux/unknown.- osIdentifier = 'linux';- }- }-- const { langName, langVersion } = getClientLanguage();- return `Playwright/${getPlaywrightVersion()} (${os.arch()}; ${osIdentifier} ${osVersion}) ${langName}/${langVersion}`;-}--export function getClientLanguage(): { langName: string, langVersion: string } {- let langName = 'unknown';- let langVersion = 'unknown';- if (!process.env.PW_LANG_NAME) {- langName = 'node';- langVersion = process.version.substring(1).split('.').slice(0, 2).join('.');- } else if (['node', 'python', 'java', 'csharp'].includes(process.env.PW_LANG_NAME)) {- langName = process.env.PW_LANG_NAME;- langVersion = process.env.PW_LANG_NAME_VERSION ?? 'unknown';- }- return { langName, langVersion };-}--export function getPlaywrightVersion(majorMinorOnly = false) {- const packageJson = require('./../../package.json');- return majorMinorOnly ? packageJson.version.split('.').slice(0, 2).join('.') : packageJson.version;-}-export function constructURLBasedOnBaseURL(baseURL: string | undefined, givenURL: string): string {try {return (new URL.URL(givenURL, baseURL)).toString();diff --git a/packages/playwright-core/src/utils/stackTrace.ts b/packages/playwright-core/src/utils/stackTrace.tsindex 4a2be30ffb..ad0aa9777a 100644--- a/packages/playwright-core/src/utils/stackTrace.ts+++ b/packages/playwright-core/src/utils/stackTrace.ts@@ -15,7 +15,6 @@*/import path from 'path';-import type { StackFrame } from '../protocol/channels';import StackUtils from 'stack-utils';import { isUnderTest } from './';@@ -38,6 +37,13 @@ const TEST_DIR_LIB = path.resolve(CORE_DIR, '..', '@playwright', 'test');const COVERAGE_PATH = path.join(CORE_DIR, '..', '..', 'tests', 'config', 'coverage.js');const WS_LIB = path.relative(process.cwd(), path.dirname(require.resolve('ws')));+export type StackFrame = {+ file: string,+ line?: number,+ column?: number,+ function?: string,+};+export type ParsedStackTrace = {allFrames: StackFrame[];frames: StackFrame[];diff --git a/packages/playwright-core/src/utils/verifyNodeJsVersion.ts b/packages/playwright-core/src/utils/verifyNodeJsVersion.tsdeleted file mode 100644index c5df657648..0000000000--- a/packages/playwright-core/src/utils/verifyNodeJsVersion.ts+++ /dev/null@@ -1,33 +0,0 @@-/**- * 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 currentNodeVersion = process.versions.node;-const semver = currentNodeVersion.split('.');-const [major] = [+semver[0]];--if (major < 12) {- // eslint-disable-next-line no-console- console.error(- 'You are running Node.js ' +- currentNodeVersion +- '.\n' +- 'Playwright requires Node.js 12 or higher. \n' +- 'Please update your version of Node.js.'- );- process.exit(1);-}--export {};diff --git a/tests/library/browsertype-connect.spec.ts b/tests/library/browsertype-connect.spec.tsindex 391fb78a44..47e0c4a0be 100644--- a/tests/library/browsertype-connect.spec.ts+++ b/tests/library/browsertype-connect.spec.ts@@ -18,7 +18,7 @@import fs from 'fs';import os from 'os';import * as path from 'path';-import { getUserAgent } from '../../packages/playwright-core/lib/utils';+import { getUserAgent } from '../../packages/playwright-core/lib/common/userAgent';import WebSocket from 'ws';import { expect, playwrightTest as test } from '../config/browserTest';import { parseTrace, suppressCertificateWarning } from '../config/utils';diff --git a/tests/library/chromium/chromium.spec.ts b/tests/library/chromium/chromium.spec.tsindex b44af4e862..e1456a06a3 100644--- a/tests/library/chromium/chromium.spec.ts+++ b/tests/library/chromium/chromium.spec.ts@@ -19,7 +19,7 @@ import { contextTest as test, expect } from '../../config/browserTest';import { playwrightTest } from '../../config/browserTest';import http from 'http';import fs from 'fs';-import { getUserAgent } from '../../../packages/playwright-core/lib/utils';+import { getUserAgent } from '../../../packages/playwright-core/lib/common/userAgent';import { suppressCertificateWarning } from '../../config/utils';test('should create a worker from a service worker', async ({ page, server }) => {diff --git a/tests/library/global-fetch.spec.ts b/tests/library/global-fetch.spec.tsindex 666d6a3307..7e633d0b5e 100644--- a/tests/library/global-fetch.spec.ts+++ b/tests/library/global-fetch.spec.ts@@ -17,7 +17,7 @@import http from 'http';import os from 'os';import * as util from 'util';-import { getPlaywrightVersion } from '../../packages/playwright-core/lib/utils';+import { getPlaywrightVersion } from '../../packages/playwright-core/lib/common/userAgent';import { expect, playwrightTest as it } from '../config/browserTest';it.skip(({ mode }) => mode !== 'default');