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: remove stackTrace => path dependency (#34763)
Pavel Feldmane697b1a6636f
diff --git a/packages/playwright-core/ThirdPartyNotices.txt b/packages/playwright-core/ThirdPartyNotices.txtindex 420d698fa5..f9d2225d75 100644--- a/packages/playwright-core/ThirdPartyNotices.txt+++ b/packages/playwright-core/ThirdPartyNotices.txt@@ -11,7 +11,6 @@ This project incorporates components from the projects listed below. The origina- [email protected] (https://github.com/juliangruber/brace-expansion)- [email protected] (https://github.com/brianloveswords/buffer-crc32)- [email protected] (https://github.com/codemirror/CodeMirror)-- [email protected] (https://github.com/Marak/colors.js)- [email protected] (https://github.com/tj/commander.js)- [email protected] (https://github.com/substack/node-concat-map)- [email protected] (https://github.com/debug-js/debug)@@ -355,36 +354,6 @@ THE SOFTWARE.=========================================END OF [email protected] AND INFORMATION-%% [email protected] NOTICES AND INFORMATION BEGIN HERE-=========================================-MIT License--Original Library- - Copyright (c) Marak Squires--Additional Functionality- - Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)--Permission is hereby granted, free of charge, to any person obtaining a copy-of this software and associated documentation files (the "Software"), to deal-in the Software without restriction, including without limitation the rights-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell-copies of the Software, and to permit persons to whom the Software is-furnished to do so, subject to the following conditions:--The above copyright notice and this permission notice shall be included in-all copies or substantial portions of the Software.--THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN-THE SOFTWARE.-=========================================-END OF [email protected] AND INFORMATION-%% [email protected] NOTICES AND INFORMATION BEGIN HERE=========================================(The MIT License)@@ -1555,6 +1524,6 @@ END OF [email protected] AND INFORMATIONSUMMARY BEGIN HERE=========================================-Total Packages: 46+Total Packages: 45=========================================END OF SUMMARY\ No newline at end of filediff --git a/packages/playwright-core/bundles/utils/package-lock.json b/packages/playwright-core/bundles/utils/package-lock.jsonindex 49e99ef5c3..a70731aa0e 100644--- a/packages/playwright-core/bundles/utils/package-lock.json+++ b/packages/playwright-core/bundles/utils/package-lock.json@@ -8,7 +8,6 @@"name": "utils-bundle","version": "0.0.1","dependencies": {- "colors": "1.4.0","commander": "8.3.0","debug": "^4.3.4","diff": "^7.0.0",@@ -163,14 +162,6 @@"concat-map": "0.0.1"}},- "node_modules/colors": {- "version": "1.4.0",- "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",- "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==",- "engines": {- "node": ">=0.1.90"- }- },"node_modules/commander": {"version": "8.3.0","resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",diff --git a/packages/playwright-core/bundles/utils/package.json b/packages/playwright-core/bundles/utils/package.jsonindex e7f09cf3a0..76f6a4986a 100644--- a/packages/playwright-core/bundles/utils/package.json+++ b/packages/playwright-core/bundles/utils/package.json@@ -9,7 +9,6 @@"generate-license": "node ../../../../utils/generate_third_party_notice.js"},"dependencies": {- "colors": "1.4.0","commander": "8.3.0","debug": "^4.3.4","diff": "^7.0.0",diff --git a/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts b/packages/playwright-core/bundles/utils/src/utilsBundleImpl.tsindex 409372e894..284ca5e7ad 100644--- a/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts+++ b/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts@@ -16,9 +16,6 @@/* eslint-disable import/order */-import colorsLibrary from 'colors/safe';-export const colors = colorsLibrary;-import debugLibrary from 'debug';export const debug = debugLibrary;diff --git a/packages/playwright-core/src/browserServerImpl.ts b/packages/playwright-core/src/browserServerImpl.tsindex e8d66bc4c4..77fb9a9844 100644--- a/packages/playwright-core/src/browserServerImpl.ts+++ b/packages/playwright-core/src/browserServerImpl.ts@@ -21,7 +21,7 @@ import { helper } from './server/helper';import { serverSideCallMetadata } from './server/instrumentation';import { createPlaywright } from './server/playwright';import { createGuid } from './server/utils/crypto';-import { rewriteErrorMessage } from './utils/stackTrace';+import { rewriteErrorMessage } from './utils/isomorphic/stackTrace';import { ws } from './utilsBundle';import type { BrowserServer, BrowserServerLauncher } from './client/browserType';diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.tsindex 7c0210ceaf..32cac6ba7f 100644--- a/packages/playwright-core/src/client/browserContext.ts+++ b/packages/playwright-core/src/client/browserContext.ts@@ -39,7 +39,7 @@ import { mkdirIfNeeded } from '../utils/fileUtils';import { headersObjectToArray } from '../utils/isomorphic/headers';import { urlMatchesEqual } from '../utils/isomorphic/urlMatch';import { isRegExp, isString } from '../utils/isomorphic/rtti';-import { rewriteErrorMessage } from '../utils/stackTrace';+import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';import type { BrowserType } from './browserType';import type { BrowserContextOptions, Headers, LaunchOptions, StorageState, WaitForEventOptions } from './types';diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.tsindex 70a5c51777..5c5afcdc2d 100644--- a/packages/playwright-core/src/client/channelOwner.ts+++ b/packages/playwright-core/src/client/channelOwner.ts@@ -18,7 +18,7 @@ import { EventEmitter } from './eventEmitter';import { ValidationError, maybeFindValidator } from '../protocol/validator';import { isUnderTest } from '../utils/debug';import { debugLogger } from '../utils/debugLogger';-import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/stackTrace';+import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/isomorphic/stackTrace';import { zones } from '../utils/zones';import type { ClientInstrumentation } from './clientInstrumentation';@@ -183,7 +183,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channelif (isInternal === undefined)isInternal = this._isInternalType;- const stackTrace = captureLibraryStackTrace();+ const stackTrace = captureLibraryStackTrace(this._platform.pathSeparator);const apiZone: ApiZone = { apiName: stackTrace.apiName, frames: stackTrace.frames, isInternal, reported: false, userData: undefined, stepId: undefined };try {diff --git a/packages/playwright-core/src/client/connection.ts b/packages/playwright-core/src/client/connection.tsindex 0c9ad7f66b..fe0e14b032 100644--- a/packages/playwright-core/src/client/connection.ts+++ b/packages/playwright-core/src/client/connection.ts@@ -43,7 +43,7 @@ import { Worker } from './worker';import { WritableStream } from './writableStream';import { ValidationError, findValidator } from '../protocol/validator';import { debugLogger } from '../utils/debugLogger';-import { formatCallLog, rewriteErrorMessage } from '../utils/stackTrace';+import { formatCallLog, rewriteErrorMessage } from '../utils/isomorphic/stackTrace';import { zones } from '../utils/zones';import type { ClientInstrumentation } from './clientInstrumentation';diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.tsindex 20675492eb..801146c2a7 100644--- a/packages/playwright-core/src/client/network.ts+++ b/packages/playwright-core/src/client/network.ts@@ -29,7 +29,7 @@ import { urlMatches } from '../utils/isomorphic/urlMatch';import { LongStandingScope, ManualPromise } from '../utils/isomorphic/manualPromise';import { MultiMap } from '../utils/isomorphic/multimap';import { isRegExp, isString } from '../utils/isomorphic/rtti';-import { rewriteErrorMessage } from '../utils/stackTrace';+import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';import { zones } from '../utils/zones';import { mime } from '../utilsBundle';diff --git a/packages/playwright-core/src/client/waiter.ts b/packages/playwright-core/src/client/waiter.tsindex b125ed034a..e17f93d940 100644--- a/packages/playwright-core/src/client/waiter.ts+++ b/packages/playwright-core/src/client/waiter.ts@@ -15,7 +15,7 @@*/import { TimeoutError } from './errors';-import { rewriteErrorMessage } from '../utils/stackTrace';+import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';import { zones } from '../utils/zones';import type { ChannelOwner } from './channelOwner';diff --git a/packages/playwright-core/src/inProcessFactory.ts b/packages/playwright-core/src/inProcessFactory.tsindex 296c742127..784bfc4c88 100644--- a/packages/playwright-core/src/inProcessFactory.ts+++ b/packages/playwright-core/src/inProcessFactory.ts@@ -14,10 +14,13 @@* limitations under the License.*/+import path from 'path';+import { AndroidServerLauncherImpl } from './androidServerImpl';import { BrowserServerLauncherImpl } from './browserServerImpl';import { Connection } from './client/connection';import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from './server';+import { setLibraryStackPrefix } from './utils/isomorphic/stackTrace';import type { Playwright as PlaywrightAPI } from './client/playwright';import type { Language } from './utils';@@ -25,6 +28,7 @@ import type { Platform } from './utils/platform';export function createInProcessPlaywright(platform: Platform): PlaywrightAPI {const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });+ setLibraryStackPrefix(path.join(__dirname, '..'));const clientConnection = new Connection(undefined, platform, undefined, []);clientConnection.useRawBuffers();diff --git a/packages/playwright-core/src/server/chromium/crExecutionContext.ts b/packages/playwright-core/src/server/chromium/crExecutionContext.tsindex bd1b64099b..910932caf3 100644--- a/packages/playwright-core/src/server/chromium/crExecutionContext.ts+++ b/packages/playwright-core/src/server/chromium/crExecutionContext.ts@@ -16,7 +16,7 @@*/import { getExceptionMessage, releaseObject } from './crProtocolHelper';-import { rewriteErrorMessage } from '../../utils/stackTrace';+import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers';import * as js from '../javascript';import { isSessionClosedError } from '../protocolError';diff --git a/packages/playwright-core/src/server/chromium/crPage.ts b/packages/playwright-core/src/server/chromium/crPage.tsindex 0a12f9fcd8..bb218202e6 100644--- a/packages/playwright-core/src/server/chromium/crPage.ts+++ b/packages/playwright-core/src/server/chromium/crPage.ts@@ -20,7 +20,7 @@ import * as path from 'path';import { assert } from '../../utils/debug';import { createGuid } from '../utils/crypto';import { eventsHelper } from '../utils/eventsHelper';-import { rewriteErrorMessage } from '../../utils/stackTrace';+import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';import * as dialog from '../dialog';import * as dom from '../dom';import * as frames from '../frames';diff --git a/packages/playwright-core/src/server/chromium/crProtocolHelper.ts b/packages/playwright-core/src/server/chromium/crProtocolHelper.tsindex 570b404d9b..f9e1409a79 100644--- a/packages/playwright-core/src/server/chromium/crProtocolHelper.ts+++ b/packages/playwright-core/src/server/chromium/crProtocolHelper.ts@@ -17,7 +17,7 @@import * as fs from 'fs';-import { splitErrorMessage } from '../../utils/stackTrace';+import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';import { mkdirIfNeeded } from '../utils/fileUtils';import type { CRSession } from './crConnection';diff --git a/packages/playwright-core/src/server/firefox/ffExecutionContext.ts b/packages/playwright-core/src/server/firefox/ffExecutionContext.tsindex 7de27727cd..5de8cddae3 100644--- a/packages/playwright-core/src/server/firefox/ffExecutionContext.ts+++ b/packages/playwright-core/src/server/firefox/ffExecutionContext.ts@@ -15,7 +15,7 @@* limitations under the License.*/-import { rewriteErrorMessage } from '../../utils/stackTrace';+import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers';import * as js from '../javascript';import { isSessionClosedError } from '../protocolError';diff --git a/packages/playwright-core/src/server/firefox/ffPage.ts b/packages/playwright-core/src/server/firefox/ffPage.tsindex 305a9638cb..c2b59ca08b 100644--- a/packages/playwright-core/src/server/firefox/ffPage.ts+++ b/packages/playwright-core/src/server/firefox/ffPage.ts@@ -26,7 +26,7 @@ import { FFExecutionContext } from './ffExecutionContext';import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './ffInput';import { FFNetworkManager } from './ffNetworkManager';import { debugLogger } from '../../utils/debugLogger';-import { splitErrorMessage } from '../../utils/stackTrace';+import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';import { BrowserContext } from '../browserContext';import { TargetClosedError } from '../errors';diff --git a/packages/playwright-core/src/server/protocolError.ts b/packages/playwright-core/src/server/protocolError.tsindex 1f999b7c64..9ef856c2eb 100644--- a/packages/playwright-core/src/server/protocolError.ts+++ b/packages/playwright-core/src/server/protocolError.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { rewriteErrorMessage } from '../utils/stackTrace';+import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';export class ProtocolError extends Error {type: 'error' | 'closed' | 'crashed';diff --git a/packages/playwright-core/src/server/registry/browserFetcher.ts b/packages/playwright-core/src/server/registry/browserFetcher.tsindex 16cab16db1..0e7809cadb 100644--- a/packages/playwright-core/src/server/registry/browserFetcher.ts+++ b/packages/playwright-core/src/server/registry/browserFetcher.ts@@ -23,7 +23,8 @@ import * as path from 'path';import { debugLogger } from '../../utils/debugLogger';import { ManualPromise } from '../../utils/isomorphic/manualPromise';import { getUserAgent } from '../../utils/userAgent';-import { colors, progress as ProgressBar } from '../../utilsBundle';+import { progress as ProgressBar } from '../../utilsBundle';+import { colors } from '../../utils/isomorphic/colors';import { existsAsync } from '../utils/fileUtils';import { browserDirectoryToMarkerFilePath } from '.';diff --git a/packages/playwright-core/src/server/utils/comparators.ts b/packages/playwright-core/src/server/utils/comparators.tsindex 072133d833..19b343cc03 100644--- a/packages/playwright-core/src/server/utils/comparators.ts+++ b/packages/playwright-core/src/server/utils/comparators.ts@@ -18,7 +18,8 @@import { compare } from './image_tools/compare';// @ts-ignoreimport pixelmatch from '../../third_party/pixelmatch';-import { colors, jpegjs } from '../../utilsBundle';+import { jpegjs } from '../../utilsBundle';+import { colors } from '../../utils/isomorphic/colors';import { diff } from '../../utilsBundle';import { PNG } from '../../utilsBundle';diff --git a/packages/playwright-core/src/server/webkit/wkPage.ts b/packages/playwright-core/src/server/webkit/wkPage.tsindex 323e12e553..91a5054123 100644--- a/packages/playwright-core/src/server/webkit/wkPage.ts+++ b/packages/playwright-core/src/server/webkit/wkPage.ts@@ -22,7 +22,7 @@ import { headersArrayToObject } from '../../utils/isomorphic/headers';import { createGuid } from '../utils/crypto';import { eventsHelper } from '../utils/eventsHelper';import { hostPlatform } from '../../utils/hostPlatform';-import { splitErrorMessage } from '../../utils/stackTrace';+import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';import { PNG, jpegjs } from '../../utilsBundle';import { BrowserContext } from '../browserContext';import * as dialog from '../dialog';diff --git a/packages/playwright-core/src/utils.ts b/packages/playwright-core/src/utils.tsindex 752d376899..62058f3451 100644--- a/packages/playwright-core/src/utils.ts+++ b/packages/playwright-core/src/utils.ts@@ -14,6 +14,7 @@* limitations under the License.*/+export * from './utils/isomorphic/colors';export * from './utils/isomorphic/locatorGenerators';export * from './utils/isomorphic/manualPromise';export * from './utils/isomorphic/mimeType';@@ -31,7 +32,7 @@ export * from './utils/hostPlatform';export * from './utils/isomorphic/headers';export * from './utils/isomorphic/semaphore';export * from './utils/platform';-export * from './utils/stackTrace';+export * from './utils/isomorphic/stackTrace';export * from './utils/task';export * from './utils/userAgent';export * from './utils/zipFile';diff --git a/packages/playwright-core/src/utils/isomorphic/colors.ts b/packages/playwright-core/src/utils/isomorphic/colors.tsnew file mode 100644index 0000000000..93ed823628--- /dev/null+++ b/packages/playwright-core/src/utils/isomorphic/colors.ts@@ -0,0 +1,117 @@+/**+ * 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.+ */++export const colors = {+ enabled: true,+ reset: (text: string) => applyStyle(0, 0, text),++ bold: (text: string) => applyStyle(1, 22, text),+ dim: (text: string) => applyStyle(2, 22, text),+ italic: (text: string) => applyStyle(3, 23, text),+ underline: (text: string) => applyStyle(4, 24, text),+ inverse: (text: string) => applyStyle(7, 27, text),+ hidden: (text: string) => applyStyle(8, 28, text),+ strikethrough: (text: string) => applyStyle(9, 29, text),++ black: (text: string) => applyStyle(30, 39, text),+ red: (text: string) => applyStyle(31, 39, text),+ green: (text: string) => applyStyle(32, 39, text),+ yellow: (text: string) => applyStyle(33, 39, text),+ blue: (text: string) => applyStyle(34, 39, text),+ magenta: (text: string) => applyStyle(35, 39, text),+ cyan: (text: string) => applyStyle(36, 39, text),+ white: (text: string) => applyStyle(37, 39, text),+ gray: (text: string) => applyStyle(90, 39, text),+ grey: (text: string) => applyStyle(90, 39, text),++ brightRed: (text: string) => applyStyle(91, 39, text),+ brightGreen: (text: string) => applyStyle(92, 39, text),+ brightYellow: (text: string) => applyStyle(93, 39, text),+ brightBlue: (text: string) => applyStyle(94, 39, text),+ brightMagenta: (text: string) => applyStyle(95, 39, text),+ brightCyan: (text: string) => applyStyle(96, 39, text),+ brightWhite: (text: string) => applyStyle(97, 39, text),++ bgBlack: (text: string) => applyStyle(40, 49, text),+ bgRed: (text: string) => applyStyle(41, 49, text),+ bgGreen: (text: string) => applyStyle(42, 49, text),+ bgYellow: (text: string) => applyStyle(43, 49, text),+ bgBlue: (text: string) => applyStyle(44, 49, text),+ bgMagenta: (text: string) => applyStyle(45, 49, text),+ bgCyan: (text: string) => applyStyle(46, 49, text),+ bgWhite: (text: string) => applyStyle(47, 49, text),+ bgGray: (text: string) => applyStyle(100, 49, text),+ bgGrey: (text: string) => applyStyle(100, 49, text),++ bgBrightRed: (text: string) => applyStyle(101, 49, text),+ bgBrightGreen: (text: string) => applyStyle(102, 49, text),+ bgBrightYellow: (text: string) => applyStyle(103, 49, text),+ bgBrightBlue: (text: string) => applyStyle(104, 49, text),+ bgBrightMagenta: (text: string) => applyStyle(105, 49, text),+ bgBrightCyan: (text: string) => applyStyle(106, 49, text),+ bgBrightWhite: (text: string) => applyStyle(107, 49, text),+};++type Colors = typeof colors;++export const noColors: Colors = {+ enabled: false,+ reset: t => t,+ bold: t => t,+ dim: t => t,+ italic: t => t,+ underline: t => t,+ inverse: t => t,+ hidden: t => t,+ strikethrough: t => t,+ black: t => t,+ red: t => t,+ green: t => t,+ yellow: t => t,+ blue: t => t,+ magenta: t => t,+ cyan: t => t,+ white: t => t,+ gray: t => t,+ grey: t => t,+ brightRed: t => t,+ brightGreen: t => t,+ brightYellow: t => t,+ brightBlue: t => t,+ brightMagenta: t => t,+ brightCyan: t => t,+ brightWhite: t => t,+ bgBlack: t => t,+ bgRed: t => t,+ bgGreen: t => t,+ bgYellow: t => t,+ bgBlue: t => t,+ bgMagenta: t => t,+ bgCyan: t => t,+ bgWhite: t => t,+ bgGray: t => t,+ bgGrey: t => t,+ bgBrightRed: t => t,+ bgBrightGreen: t => t,+ bgBrightYellow: t => t,+ bgBrightBlue: t => t,+ bgBrightMagenta: t => t,+ bgBrightCyan: t => t,+ bgBrightWhite: t => t+};+++const applyStyle = (open: number, close: number, text: string) => `\u001b[${open}m${text}\u001b[${close}m`;diff --git a/packages/playwright-core/src/utils/stackTrace.ts b/packages/playwright-core/src/utils/isomorphic/stackTrace.tssimilarity index 84%rename from packages/playwright-core/src/utils/stackTrace.tsrename to packages/playwright-core/src/utils/isomorphic/stackTrace.tsindex d3331698d1..7ce3f719a4 100644--- a/packages/playwright-core/src/utils/stackTrace.ts+++ b/packages/playwright-core/src/utils/isomorphic/stackTrace.ts@@ -14,16 +14,14 @@* limitations under the License.*/-import * as path from 'path';--import { colors } from '../utilsBundle';-import { findRepeatedSubsequences } from './isomorphic/sequence';+import { colors } from './colors';+import { findRepeatedSubsequences } from './sequence';import { parseStackFrame } from './stackUtils';import type { StackFrame } from '@protocol/channels';-export function parseStackTraceLine(line: string): StackFrame | null {- const frame = parseStackFrame(line);+export function parseStackTraceLine(line: string, pathSeparator: string): StackFrame | null {+ const frame = parseStackFrame(line, pathSeparator);if (!frame)return null;if (!process.env.PWDEBUGIMPL && (frame.file?.startsWith('internal') || frame.file?.startsWith('node:')))@@ -47,12 +45,15 @@ export function rewriteErrorMessage<E extends Error>(e: E, newMessage: string):return e;}-const CORE_DIR = path.resolve(__dirname, '..', '..');+let coreDir: string | undefined;++const playwrightStackPrefixes: string[] = [];+export const addInternalStackPrefix = (prefix: string) => playwrightStackPrefixes.push(prefix);-const internalStackPrefixes = [- CORE_DIR,-];-export const addInternalStackPrefix = (prefix: string) => internalStackPrefixes.push(prefix);+export const setLibraryStackPrefix = (prefix: string) => {+ coreDir = prefix;+ playwrightStackPrefixes.push(prefix);+};export type RawStack = string[];@@ -65,7 +66,7 @@ export function captureRawStack(): RawStack {return stack.split('\n');}-export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: string } {+export function captureLibraryStackTrace(pathSeparator: string): { frames: StackFrame[], apiName: string } {const stack = captureRawStack();type ParsedFrame = {@@ -74,10 +75,10 @@ export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: strisPlaywrightLibrary: boolean;};let parsedFrames = stack.map(line => {- const frame = parseStackTraceLine(line);+ const frame = parseStackTraceLine(line, pathSeparator);if (!frame || !frame.file)return null;- const isPlaywrightLibrary = frame.file.startsWith(CORE_DIR);+ const isPlaywrightLibrary = !!coreDir && frame.file.startsWith(coreDir);const parsed: ParsedFrame = {frame,frameText: line,@@ -111,7 +112,7 @@ export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: strparsedFrames = parsedFrames.filter(f => {if (process.env.PWDEBUGIMPL)return true;- if (internalStackPrefixes.some(prefix => f.frame.file.startsWith(prefix)))+ if (playwrightStackPrefixes.some(prefix => f.frame.file.startsWith(prefix)))return false;return true;});@@ -133,11 +134,6 @@ export function stringifyStackFrames(frames: StackFrame[]): string[] {return stackLines;}-export function captureLibraryStackText() {- const parsed = captureLibraryStackTrace();- return stringifyStackFrames(parsed.frames).join('\n');-}-export function splitErrorMessage(message: string): { name: string, message: string } {const separationIdx = message.indexOf(':');return {diff --git a/packages/playwright-core/src/utils/stackUtils.ts b/packages/playwright-core/src/utils/isomorphic/stackUtils.tssimilarity index 88%rename from packages/playwright-core/src/utils/stackUtils.tsrename to packages/playwright-core/src/utils/isomorphic/stackUtils.tsindex 024b6fe8d0..20be8081af 100644--- a/packages/playwright-core/src/utils/stackUtils.ts+++ b/packages/playwright-core/src/utils/isomorphic/stackUtils.ts@@ -19,8 +19,6 @@* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/-import * as url from 'url';-type StackData = {line?: number;column?: number;@@ -35,7 +33,7 @@ type StackData = {evalFile?: string | undefined;};-export function parseStackFrame(line: string): StackData | null {+export function parseStackFrame(line: string, pathSeparator: string): StackData | null {const match = line && line.match(re);if (!match)return null;@@ -92,7 +90,7 @@ export function parseStackFrame(line: string): StackData | null {}}- setFile(res, file);+ setFile(res, file, pathSeparator);if (ctor)res.isConstructor = true;@@ -113,10 +111,10 @@ export function parseStackFrame(line: string): StackData | null {return res;}-function setFile(result: StackData, filename: string) {+function setFile(result: StackData, filename: string, pathSeparator: string) {if (filename) {if (filename.startsWith('file://'))- filename = url.fileURLToPath(filename);+ filename = fileURLToPath(filename, pathSeparator);result.file = filename;}}@@ -147,3 +145,14 @@ const re = new RegExp('^' +);const methodRe = /^(.*?) \[as (.*?)\]$/;++function fileURLToPath(fileUrl: string, pathSeparator: string): string {+ if (!fileUrl.startsWith('file://'))+ return fileUrl;++ let path = decodeURIComponent(fileUrl.slice(7));+ if (path.startsWith('/') && /^[a-zA-Z]:/.test(path.slice(1)))+ path = path.slice(1);++ return path.replace(/\//g, pathSeparator);+}diff --git a/packages/playwright-core/src/utils/platform.ts b/packages/playwright-core/src/utils/platform.tsindex 60f2cdbd3a..5abf38e8c0 100644--- a/packages/playwright-core/src/utils/platform.ts+++ b/packages/playwright-core/src/utils/platform.ts@@ -25,6 +25,7 @@ export type Platform = {fs: () => typeof fs;inspectCustom: symbol | undefined;path: () => typeof path;+ pathSeparator: string;ws?: (url: string) => WebSocket;};@@ -42,6 +43,8 @@ export const nodePlatform: Platform = {inspectCustom: util.inspect.custom,path: () => path,++ pathSeparator: path.sep};export const webPlatform: Platform = {@@ -65,5 +68,7 @@ export const webPlatform: Platform = {throw new Error('Path module is not available');},+ pathSeparator: '/',+ws: (url: string) => new WebSocket(url),};diff --git a/packages/playwright-core/src/utilsBundle.ts b/packages/playwright-core/src/utilsBundle.tsindex 41cccd1f57..a72f18c30f 100644--- a/packages/playwright-core/src/utilsBundle.ts+++ b/packages/playwright-core/src/utilsBundle.ts@@ -14,7 +14,6 @@* limitations under the License.*/-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;export const diff: typeof import('../bundles/utils/node_modules/@types/diff') = require('./utilsBundleImpl').diff;export const dotenv: typeof import('../bundles/utils/node_modules/dotenv') = require('./utilsBundleImpl').dotenv;diff --git a/packages/playwright/src/matchers/matcherHint.ts b/packages/playwright/src/matchers/matcherHint.tsindex 1dfa1ceb4a..316ecad685 100644--- a/packages/playwright/src/matchers/matcherHint.ts+++ b/packages/playwright/src/matchers/matcherHint.ts@@ -15,7 +15,7 @@*/import { stringifyStackFrames } from 'playwright-core/lib/utils';-import { colors } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';import type { ExpectMatcherState } from '../../types/test';import type { StackFrame } from '@protocol/channels';diff --git a/packages/playwright/src/matchers/matchers.ts b/packages/playwright/src/matchers/matchers.tsindex 2890feaac6..d37e3285f4 100644--- a/packages/playwright/src/matchers/matchers.ts+++ b/packages/playwright/src/matchers/matchers.ts@@ -15,7 +15,7 @@*/import { isRegExp, isString, isTextualMimeType, pollAgainstDeadline, serializeExpectedTextValues } from 'playwright-core/lib/utils';-import { colors } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';import { callLogText, expectTypes } from '../util';import { toBeTruthy } from './toBeTruthy';diff --git a/packages/playwright/src/matchers/toHaveURL.ts b/packages/playwright/src/matchers/toHaveURL.tsindex c56441fee5..efc0ebd5f2 100644--- a/packages/playwright/src/matchers/toHaveURL.ts+++ b/packages/playwright/src/matchers/toHaveURL.ts@@ -15,7 +15,7 @@*/import { constructURLBasedOnBaseURL, urlMatches } from 'playwright-core/lib/utils';-import { colors } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring } from './expect';import { matcherHint } from './matcherHint';diff --git a/packages/playwright/src/matchers/toMatchSnapshot.ts b/packages/playwright/src/matchers/toMatchSnapshot.tsindex 220c948887..dd54e61aeb 100644--- a/packages/playwright/src/matchers/toMatchSnapshot.ts+++ b/packages/playwright/src/matchers/toMatchSnapshot.ts@@ -18,7 +18,7 @@ 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 { colors } from 'playwright-core/lib/utils';import { mime } from 'playwright-core/lib/utilsBundle';import {diff --git a/packages/playwright/src/matchers/toMatchText.ts b/packages/playwright/src/matchers/toMatchText.tsindex 961937eb5b..142013f1b5 100644--- a/packages/playwright/src/matchers/toMatchText.ts+++ b/packages/playwright/src/matchers/toMatchText.ts@@ -15,7 +15,7 @@*/-import { colors } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';import { callLogText, expectTypes } from '../util';import {diff --git a/packages/playwright/src/plugins/webServerPlugin.ts b/packages/playwright/src/plugins/webServerPlugin.tsindex 62583c303e..4bb1bef0db 100644--- a/packages/playwright/src/plugins/webServerPlugin.ts+++ b/packages/playwright/src/plugins/webServerPlugin.ts@@ -17,7 +17,8 @@ import * as net from 'net';import * as path from 'path';import { launchProcess, isURLAvailable, monotonicTime, raceAgainstDeadline } from 'playwright-core/lib/utils';-import { colors, debug } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';+import { debug } from 'playwright-core/lib/utilsBundle';import type { TestRunnerPlugin } from '.';import type { FullConfig } from '../../types/testReporter';diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.tsindex 156f9755db..8ba5b23af1 100644--- a/packages/playwright/src/reporters/base.ts+++ b/packages/playwright/src/reporters/base.ts@@ -18,7 +18,8 @@ import * as path from 'path';import { getPackageManagerExecCommand } from 'playwright-core/lib/utils';import { parseStackTraceLine } from 'playwright-core/lib/utils';-import { colors as realColors, ms as milliseconds } from 'playwright-core/lib/utilsBundle';+import { ms as milliseconds } from 'playwright-core/lib/utilsBundle';+import { colors as realColors, noColors } from 'playwright-core/lib/utils';import { resolveReporterOutputPath } from '../util';import { getEastAsianWidth } from '../utilsBundle';@@ -53,48 +54,6 @@ export type Screen = {ttyWidth: number;};-export const noColors: Colors = {- bold: (t: string) => t,- cyan: (t: string) => t,- dim: (t: string) => t,- gray: (t: string) => t,- green: (t: string) => t,- red: (t: string) => t,- yellow: (t: string) => t,- black: (t: string) => t,- blue: (t: string) => t,- magenta: (t: string) => t,- white: (t: string) => t,- grey: (t: string) => t,- bgBlack: (t: string) => t,- bgRed: (t: string) => t,- bgGreen: (t: string) => t,- bgYellow: (t: string) => t,- bgBlue: (t: string) => t,- bgMagenta: (t: string) => t,- bgCyan: (t: string) => t,- bgWhite: (t: string) => t,- strip: (t: string) => t,- stripColors: (t: string) => t,- reset: (t: string) => t,- italic: (t: string) => t,- underline: (t: string) => t,- inverse: (t: string) => t,- hidden: (t: string) => t,- strikethrough: (t: string) => t,- rainbow: (t: string) => t,- zebra: (t: string) => t,- america: (t: string) => t,- trap: (t: string) => t,- random: (t: string) => t,- zalgo: (t: string) => t,-- enabled: false,- enable: () => {},- disable: () => {},- setTheme: () => {},-};-// Output goes to terminal.export const terminalScreen: Screen = (() => {let isTTY = !!process.stdout.isTTY;@@ -563,7 +522,7 @@ export function prepareErrorStack(stack: string): {const stackLines = lines.slice(firstStackLine);let location: Location | undefined;for (const line of stackLines) {- const frame = parseStackTraceLine(line);+ const frame = parseStackTraceLine(line, path.sep);if (!frame || !frame.file)continue;if (belongsToNodeModules(frame.file))diff --git a/packages/playwright/src/reporters/github.ts b/packages/playwright/src/reporters/github.tsindex e3677dd3ff..7c65c00b3c 100644--- a/packages/playwright/src/reporters/github.ts+++ b/packages/playwright/src/reporters/github.ts@@ -16,9 +16,10 @@import * as path from 'path';+import { noColors } from 'playwright-core/lib/utils';import { ms as milliseconds } from 'playwright-core/lib/utilsBundle';-import { TerminalReporter, formatResultFailure, formatRetry, noColors, stripAnsiEscapes } from './base';+import { TerminalReporter, formatResultFailure, formatRetry, stripAnsiEscapes } from './base';import type { FullResult, TestCase, TestError } from '../../types/testReporter';diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.tsindex 3390a71746..a86a758d48 100644--- a/packages/playwright/src/reporters/html.ts+++ b/packages/playwright/src/reporters/html.ts@@ -19,7 +19,8 @@ import * as path from 'path';import { Transform } from 'stream';import { HttpServer, MultiMap, assert, calculateSha1, getPackageManagerExecCommand, copyFileAndMakeWritable, gracefullyProcessExitDoNotHang, removeFolders, sanitizeForFilePath, toPosixPath } from 'playwright-core/lib/utils';-import { colors, open } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';+import { open } from 'playwright-core/lib/utilsBundle';import { mime } from 'playwright-core/lib/utilsBundle';import { yazl } from 'playwright-core/lib/zipBundle';diff --git a/packages/playwright/src/runner/dispatcher.ts b/packages/playwright/src/runner/dispatcher.tsindex 084deba11d..cf0c7144c0 100644--- a/packages/playwright/src/runner/dispatcher.ts+++ b/packages/playwright/src/runner/dispatcher.ts@@ -15,7 +15,7 @@*/import { ManualPromise, eventsHelper } from 'playwright-core/lib/utils';-import { colors } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';import { addSuggestedRebaseline } from './rebase';import { WorkerHost } from './workerHost';diff --git a/packages/playwright/src/runner/rebase.ts b/packages/playwright/src/runner/rebase.tsindex c2d9f96d18..ef7d49f013 100644--- a/packages/playwright/src/runner/rebase.ts+++ b/packages/playwright/src/runner/rebase.ts@@ -19,7 +19,8 @@ import * as path from 'path';import { MultiMap } from 'playwright-core/lib/utils';-import { colors, diff } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';+import { diff } from 'playwright-core/lib/utilsBundle';import { filterProjects } from './projectUtils';import { babelParse, traverse, types } from '../transform/babelBundle';diff --git a/packages/playwright/src/runner/taskRunner.ts b/packages/playwright/src/runner/taskRunner.tsindex 12185aa951..ea0561faaa 100644--- a/packages/playwright/src/runner/taskRunner.ts+++ b/packages/playwright/src/runner/taskRunner.ts@@ -15,7 +15,8 @@*/import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils';-import { colors, debug } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';+import { debug } from 'playwright-core/lib/utilsBundle';import { SigIntWatcher } from './sigIntWatcher';diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.tsindex c9768c47ba..ad819853fc 100644--- a/packages/playwright/src/runner/watchMode.ts+++ b/packages/playwright/src/runner/watchMode.ts@@ -20,7 +20,7 @@ import { EventEmitter } from 'stream';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 { colors } from 'playwright-core/lib/utils';import { separator, terminalScreen } from '../reporters/base';import { enquirer } from '../utilsBundle';diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.tsindex 803aa73f6b..a890535fee 100644--- a/packages/playwright/src/util.ts+++ b/packages/playwright/src/util.ts@@ -55,7 +55,7 @@ export function filterStackFile(file: string) {export function filteredStackTrace(rawStack: RawStack): StackFrame[] {const frames: StackFrame[] = [];for (const line of rawStack) {- const frame = parseStackTraceLine(line);+ const frame = parseStackTraceLine(line, path.sep);if (!frame || !frame.file)continue;if (!filterStackFile(frame.file))diff --git a/packages/playwright/src/worker/timeoutManager.ts b/packages/playwright/src/worker/timeoutManager.tsindex 7018dafcc9..65e97c9f36 100644--- a/packages/playwright/src/worker/timeoutManager.ts+++ b/packages/playwright/src/worker/timeoutManager.ts@@ -15,7 +15,7 @@*/import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils';-import { colors } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';import type { Location } from '../../types/testReporter';diff --git a/packages/playwright/src/worker/workerMain.ts b/packages/playwright/src/worker/workerMain.tsindex 30b59c36e7..e09579d0e0 100644--- a/packages/playwright/src/worker/workerMain.ts+++ b/packages/playwright/src/worker/workerMain.ts@@ -15,7 +15,7 @@*/import { ManualPromise, gracefullyCloseAll, removeFolders } from 'playwright-core/lib/utils';-import { colors } from 'playwright-core/lib/utilsBundle';+import { colors } from 'playwright-core/lib/utils';import { deserializeConfig } from '../common/configLoader';import { setCurrentTestInfo, setIsWorkerProcess } from '../common/globals';