chore: move debug, env and user agent from utils/ (#34766)
This commit is contained in:
parent
6951e6ad9d
commit
3d760b657b
|
@ -8,10 +8,13 @@
|
|||
**
|
||||
|
||||
[inprocess.ts]
|
||||
common/
|
||||
utils/
|
||||
server/utils
|
||||
|
||||
[outofprocess.ts]
|
||||
client/
|
||||
common/
|
||||
protocol/
|
||||
utils/
|
||||
utils/isomorphic
|
||||
|
|
|
@ -21,7 +21,7 @@ import { ChannelOwner } from './channelOwner';
|
|||
import { TargetClosedError, isTargetClosedError } from './errors';
|
||||
import { Events } from './events';
|
||||
import { Waiter } from './waiter';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { TimeoutSettings } from '../utils/isomorphic/timeoutSettings';
|
||||
import { isRegExp, isString } from '../utils/isomorphic/rtti';
|
||||
import { monotonicTime } from '../utils/isomorphic/time';
|
||||
import { raceAgainstDeadline } from '../utils/isomorphic/timeoutRunner';
|
||||
|
@ -30,7 +30,7 @@ import type { Page } from './page';
|
|||
import type * as types from './types';
|
||||
import type * as api from '../../types/types';
|
||||
import type { AndroidServerLauncherImpl } from '../androidServerImpl';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { Platform } from '../common/platform';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
type Direction = 'down' | 'up' | 'left' | 'right';
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { Stream } from './stream';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { mkdirIfNeeded } from '../common/fileUtils';
|
||||
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Readable } from 'stream';
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CDPSession } from './cdpSession';
|
|||
import { ChannelOwner } from './channelOwner';
|
||||
import { isTargetClosedError } from './errors';
|
||||
import { Events } from './events';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { mkdirIfNeeded } from '../common/fileUtils';
|
||||
|
||||
import type { BrowserType } from './browserType';
|
||||
import type { Page } from './page';
|
||||
|
|
|
@ -34,8 +34,8 @@ import { Tracing } from './tracing';
|
|||
import { Waiter } from './waiter';
|
||||
import { WebError } from './webError';
|
||||
import { Worker } from './worker';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { TimeoutSettings } from '../utils/isomorphic/timeoutSettings';
|
||||
import { mkdirIfNeeded } from '../common/fileUtils';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { urlMatchesEqual } from '../utils/isomorphic/urlMatch';
|
||||
import { isRegExp, isString } from '../utils/isomorphic/rtti';
|
||||
|
@ -46,7 +46,7 @@ import type { BrowserContextOptions, Headers, LaunchOptions, StorageState, WaitF
|
|||
import type * as structs from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
import type { URLMatch } from '../utils/isomorphic/urlMatch';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { Platform } from '../common/platform';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel> implements api.BrowserContext {
|
||||
|
|
|
@ -21,7 +21,7 @@ import { BrowserContext, prepareBrowserContextParams } from './browserContext';
|
|||
import { ChannelOwner } from './channelOwner';
|
||||
import { envObjectToArray } from './clientHelper';
|
||||
import { Events } from './events';
|
||||
import { assert } from '../utils/debug';
|
||||
import { assert } from '../utils/isomorphic/debug';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { monotonicTime } from '../utils/isomorphic/time';
|
||||
import { raceAgainstDeadline } from '../utils/isomorphic/timeoutRunner';
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
import { EventEmitter } from './eventEmitter';
|
||||
import { ValidationError, maybeFindValidator } from '../protocol/validator';
|
||||
import { isUnderTest } from '../utils/debug';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { isUnderTest } from '../utils/isomorphic/debug';
|
||||
import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/isomorphic/stackTrace';
|
||||
import { zones } from '../utils/zones';
|
||||
|
||||
|
@ -25,7 +24,7 @@ import type { ClientInstrumentation } from './clientInstrumentation';
|
|||
import type { Connection } from './connection';
|
||||
import type { Logger } from './types';
|
||||
import type { ValidatorContext } from '../protocol/validator';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { Platform } from '../common/platform';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
type Listener = (...args: any[]) => void;
|
||||
|
@ -158,7 +157,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
|
|||
apiZone.params = params;
|
||||
apiZone.reported = true;
|
||||
this._instrumentation.onApiCallBegin(apiZone);
|
||||
logApiCall(this._logger, `=> ${apiZone.apiName} started`);
|
||||
logApiCall(this._platform, this._logger, `=> ${apiZone.apiName} started`);
|
||||
return await this._connection.sendMessageToServer(this, prop, validatedParams, apiZone.apiName, apiZone.frames, apiZone.stepId);
|
||||
}
|
||||
// Since this api call is either internal, or has already been reported/traced once,
|
||||
|
@ -189,7 +188,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
|
|||
try {
|
||||
const result = await zones.run('apiZone', apiZone, async () => await func(apiZone));
|
||||
if (!isInternal) {
|
||||
logApiCall(logger, `<= ${apiZone.apiName} succeeded`);
|
||||
logApiCall(this._platform, logger, `<= ${apiZone.apiName} succeeded`);
|
||||
this._instrumentation.onApiCallEnd(apiZone);
|
||||
}
|
||||
return result;
|
||||
|
@ -204,7 +203,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
|
|||
e.stack = '';
|
||||
if (!isInternal) {
|
||||
apiZone.error = e;
|
||||
logApiCall(logger, `<= ${apiZone.apiName} failed`);
|
||||
logApiCall(this._platform, logger, `<= ${apiZone.apiName} failed`);
|
||||
this._instrumentation.onApiCallEnd(apiZone);
|
||||
}
|
||||
throw e;
|
||||
|
@ -227,10 +226,10 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
|
|||
}
|
||||
}
|
||||
|
||||
function logApiCall(logger: Logger | undefined, message: string) {
|
||||
function logApiCall(platform: Platform, logger: Logger | undefined, message: string) {
|
||||
if (logger && logger.isEnabled('api', 'info'))
|
||||
logger.log('api', 'info', message, [], { color: 'cyan' });
|
||||
debugLogger.log('api', message);
|
||||
platform.log('api', message);
|
||||
}
|
||||
|
||||
function tChannelImplToWire(names: '*' | string[], arg: any, path: string, context: ValidatorContext) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
import { isString } from '../utils/isomorphic/rtti';
|
||||
|
||||
import type * as types from './types';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { Platform } from '../common/platform';
|
||||
|
||||
export function envObjectToArray(env: types.Env): { name: string, value: string }[] {
|
||||
const result: { name: string, value: string }[] = [];
|
||||
|
|
|
@ -42,14 +42,13 @@ import { Tracing } from './tracing';
|
|||
import { Worker } from './worker';
|
||||
import { WritableStream } from './writableStream';
|
||||
import { ValidationError, findValidator } from '../protocol/validator';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { formatCallLog, rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
|
||||
import { zones } from '../utils/zones';
|
||||
|
||||
import type { ClientInstrumentation } from './clientInstrumentation';
|
||||
import type { HeadersArray } from './types';
|
||||
import type { ValidatorContext } from '../protocol/validator';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { Platform } from '../common/platform';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
class Root extends ChannelOwner<channels.RootChannel> {
|
||||
|
@ -139,9 +138,9 @@ export class Connection extends EventEmitter {
|
|||
const type = object._type;
|
||||
const id = ++this._lastId;
|
||||
const message = { id, guid, method, params };
|
||||
if (debugLogger.isEnabled('channel')) {
|
||||
if (this.platform.isLogEnabled('channel')) {
|
||||
// Do not include metadata in debug logs to avoid noise.
|
||||
debugLogger.log('channel', 'SEND> ' + JSON.stringify(message));
|
||||
this.platform.log('channel', 'SEND> ' + JSON.stringify(message));
|
||||
}
|
||||
const location = frames[0] ? { file: frames[0].file, line: frames[0].line, column: frames[0].column } : undefined;
|
||||
const metadata: channels.Metadata = { apiName, location, internal: !apiName, stepId };
|
||||
|
@ -159,8 +158,8 @@ export class Connection extends EventEmitter {
|
|||
|
||||
const { id, guid, method, params, result, error, log } = message as any;
|
||||
if (id) {
|
||||
if (debugLogger.isEnabled('channel'))
|
||||
debugLogger.log('channel', '<RECV ' + JSON.stringify(message));
|
||||
if (this.platform.isLogEnabled('channel'))
|
||||
this.platform.log('channel', '<RECV ' + JSON.stringify(message));
|
||||
const callback = this._callbacks.get(id);
|
||||
if (!callback)
|
||||
throw new Error(`Cannot find command to respond: ${id}`);
|
||||
|
@ -176,8 +175,8 @@ export class Connection extends EventEmitter {
|
|||
return;
|
||||
}
|
||||
|
||||
if (debugLogger.isEnabled('channel'))
|
||||
debugLogger.log('channel', '<EVENT ' + JSON.stringify(message));
|
||||
if (this.platform.isLogEnabled('channel'))
|
||||
this.platform.log('channel', '<EVENT ' + JSON.stringify(message));
|
||||
if (method === '__create__') {
|
||||
this._createRemoteObject(guid, params.type, params.guid, params.initializer);
|
||||
return;
|
||||
|
|
|
@ -18,7 +18,7 @@ import { JSHandle } from './jsHandle';
|
|||
import { Page } from './page';
|
||||
|
||||
import type * as api from '../../types/types';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { Platform } from '../common/platform';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
type ConsoleMessageLocation = channels.BrowserContextConsoleEvent['location'];
|
||||
|
|
|
@ -22,7 +22,7 @@ import { TargetClosedError, isTargetClosedError } from './errors';
|
|||
import { Events } from './events';
|
||||
import { JSHandle, parseResult, serializeArgument } from './jsHandle';
|
||||
import { Waiter } from './waiter';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { TimeoutSettings } from '../utils/isomorphic/timeoutSettings';
|
||||
|
||||
import type { Page } from './page';
|
||||
import type { BrowserContextOptions, Env, Headers, WaitForEventOptions } from './types';
|
||||
|
|
|
@ -19,8 +19,8 @@ import { promisify } from 'util';
|
|||
|
||||
import { Frame } from './frame';
|
||||
import { JSHandle, parseResult, serializeArgument } from './jsHandle';
|
||||
import { assert } from '../utils/debug';
|
||||
import { fileUploadSizeLimit, mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { assert } from '../utils/isomorphic/debug';
|
||||
import { fileUploadSizeLimit, mkdirIfNeeded } from '../common/fileUtils';
|
||||
import { isString } from '../utils/isomorphic/rtti';
|
||||
import { mime } from '../utilsBundle';
|
||||
import { WritableStream } from './writableStream';
|
||||
|
@ -31,7 +31,7 @@ import type { Locator } from './locator';
|
|||
import type { FilePayload, Rect, SelectOption, SelectOptionOptions } from './types';
|
||||
import type * as structs from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { Platform } from '../common/platform';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
const pipelineAsync = promisify(pipeline);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
import { EventEmitter as OriginalEventEmitter } from 'events';
|
||||
|
||||
import { isUnderTest } from '../utils/debug';
|
||||
import { isUnderTest } from '../utils/isomorphic/debug';
|
||||
|
||||
import type { EventEmitter as EventEmitterType } from 'events';
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ import { ChannelOwner } from './channelOwner';
|
|||
import { TargetClosedError, isTargetClosedError } from './errors';
|
||||
import { RawHeaders } from './network';
|
||||
import { Tracing } from './tracing';
|
||||
import { assert } from '../utils/debug';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { assert } from '../utils/isomorphic/debug';
|
||||
import { mkdirIfNeeded } from '../common/fileUtils';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { isString } from '../utils/isomorphic/rtti';
|
||||
|
||||
|
@ -29,7 +29,7 @@ import type { ClientCertificate, FilePayload, Headers, SetStorageState, StorageS
|
|||
import type { Serializable } from '../../types/structs';
|
||||
import type * as api from '../../types/types';
|
||||
import type { HeadersArray, NameValue } from '../common/types';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { Platform } from '../common/platform';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type * as fs from 'fs';
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import { FrameLocator, Locator, testIdAttributeName } from './locator';
|
|||
import * as network from './network';
|
||||
import { kLifecycleEvents } from './types';
|
||||
import { Waiter } from './waiter';
|
||||
import { assert } from '../utils/debug';
|
||||
import { assert } from '../utils/isomorphic/debug';
|
||||
import { getByAltTextSelector, getByLabelSelector, getByPlaceholderSelector, getByRoleSelector, getByTestIdSelector, getByTextSelector, getByTitleSelector } from '../utils/isomorphic/locatorUtils';
|
||||
import { urlMatches } from '../utils/isomorphic/urlMatch';
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
|
||||
import type { BrowserContext } from './browserContext';
|
||||
import type { LocalUtils } from './localUtils';
|
||||
import type { Route } from './network';
|
||||
|
@ -57,7 +55,7 @@ export class HarRouter {
|
|||
});
|
||||
|
||||
if (response.action === 'redirect') {
|
||||
debugLogger.log('api', `HAR: ${route.request().url()} redirected to ${response.redirectURL}`);
|
||||
route._platform.log('api', `HAR: ${route.request().url()} redirected to ${response.redirectURL}`);
|
||||
await route._redirectNavigationRequest(response.redirectURL!);
|
||||
return;
|
||||
}
|
||||
|
@ -79,7 +77,7 @@ export class HarRouter {
|
|||
}
|
||||
|
||||
if (response.action === 'error')
|
||||
debugLogger.log('api', 'HAR: ' + response.message!);
|
||||
route._platform.log('api', 'HAR: ' + response.message!);
|
||||
// Report the error, but fall through to the default handler.
|
||||
|
||||
if (this._notFoundAction === 'abort') {
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
import { ChannelOwner } from './channelOwner';
|
||||
import { Connection } from './connection';
|
||||
import * as localUtils from '../utils/localUtils';
|
||||
import * as localUtils from '../common/localUtils';
|
||||
|
||||
import type { HeadersArray, Size } from './types';
|
||||
import type { HarBackend } from '../utils/harBackend';
|
||||
import type { Platform } from '../utils/platform';
|
||||
import type { HarBackend } from '../common/harBackend';
|
||||
import type { Platform } from '../common/platform';
|
||||
import type * as channels from '@protocol/channels';
|
||||
|
||||
type DeviceDescriptor = {
|
||||
|
|
|
@ -23,7 +23,7 @@ import { APIResponse } from './fetch';
|
|||
import { Frame } from './frame';
|
||||
import { Waiter } from './waiter';
|
||||
import { Worker } from './worker';
|
||||
import { assert } from '../utils/debug';
|
||||
import { assert } from '../utils/isomorphic/debug';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { urlMatches } from '../utils/isomorphic/urlMatch';
|
||||
import { LongStandingScope, ManualPromise } from '../utils/isomorphic/manualPromise';
|
||||
|
|
|
@ -33,9 +33,9 @@ import { Response, Route, RouteHandler, WebSocket, WebSocketRoute, WebSocketRou
|
|||
import { Video } from './video';
|
||||
import { Waiter } from './waiter';
|
||||
import { Worker } from './worker';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { assert } from '../utils/debug';
|
||||
import { mkdirIfNeeded } from '../utils/fileUtils';
|
||||
import { TimeoutSettings } from '../utils/isomorphic/timeoutSettings';
|
||||
import { assert } from '../utils/isomorphic/debug';
|
||||
import { mkdirIfNeeded } from '../common/fileUtils';
|
||||
import { headersObjectToArray } from '../utils/isomorphic/headers';
|
||||
import { trimStringWithEllipsis } from '../utils/isomorphic/stringUtils';
|
||||
import { urlMatches, urlMatchesEqual } from '../utils/isomorphic/urlMatch';
|
||||
|
|
|
@ -17,19 +17,25 @@
|
|||
import { ChannelOwner } from './channelOwner';
|
||||
import { evaluationScript } from './clientHelper';
|
||||
import { setTestIdAttribute, testIdAttributeName } from './locator';
|
||||
import { nodePlatform } from '../utils/platform';
|
||||
import { emptyPlatform } from '../common/platform';
|
||||
|
||||
import type { SelectorEngine } from './types';
|
||||
import type * as api from '../../types/types';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { Platform } from '../common/platform';
|
||||
|
||||
let platform = emptyPlatform;
|
||||
|
||||
export function setPlatformForSelectors(p: Platform) {
|
||||
platform = p;
|
||||
}
|
||||
|
||||
export class Selectors implements api.Selectors {
|
||||
private _channels = new Set<SelectorsOwner>();
|
||||
private _registrations: channels.SelectorsRegisterParams[] = [];
|
||||
|
||||
async register(name: string, script: string | (() => SelectorEngine) | { path?: string, content?: string }, options: { contentScript?: boolean } = {}): Promise<void> {
|
||||
const source = await evaluationScript(nodePlatform, script, undefined, false);
|
||||
const source = await evaluationScript(platform, script, undefined, false);
|
||||
const params = { ...options, name, source };
|
||||
for (const channel of this._channels)
|
||||
await channel._channel.register(params);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[*]
|
||||
../utils/
|
||||
../utils/isomorphic/
|
||||
../utilsBundle.ts
|
||||
../zipBundle.ts
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ZipFile } from './zipFile';
|
||||
import { ZipFile } from '../utils/zipFile';
|
||||
|
||||
import type { HeadersArray } from '../common/types';
|
||||
import type { HeadersArray } from './types';
|
||||
import type * as har from '@trace/har';
|
||||
import type { Platform } from './platform';
|
||||
|
|
@ -20,11 +20,11 @@ import * as path from 'path';
|
|||
|
||||
import { removeFolders } from './fileUtils';
|
||||
import { HarBackend } from './harBackend';
|
||||
import { ManualPromise } from './isomorphic/manualPromise';
|
||||
import { ZipFile } from './zipFile';
|
||||
import { ManualPromise } from '../utils/isomorphic/manualPromise';
|
||||
import { ZipFile } from '../utils/zipFile';
|
||||
import { yauzl, yazl } from '../zipBundle';
|
||||
import { serializeClientSideCallMetadata } from '../utils/isomorphic/traceUtils';
|
||||
import { assert } from '../utils/debug';
|
||||
import { assert } from '../utils/isomorphic/debug';
|
||||
|
||||
import type { Platform } from './platform';
|
||||
import type * as channels from '@protocol/channels';
|
|
@ -17,36 +17,19 @@
|
|||
import * as crypto from 'crypto';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as util from 'util';
|
||||
|
||||
export type Platform = {
|
||||
calculateSha1(text: string): Promise<string>;
|
||||
createGuid: () => string;
|
||||
fs: () => typeof fs;
|
||||
inspectCustom: symbol | undefined;
|
||||
isLogEnabled(name: 'api' | 'channel'): boolean;
|
||||
log(name: 'api' | 'channel', message: string | Error | object): void;
|
||||
path: () => typeof path;
|
||||
pathSeparator: string;
|
||||
ws?: (url: string) => WebSocket;
|
||||
};
|
||||
|
||||
export const nodePlatform: Platform = {
|
||||
calculateSha1: (text: string) => {
|
||||
const sha1 = crypto.createHash('sha1');
|
||||
sha1.update(text);
|
||||
return Promise.resolve(sha1.digest('hex'));
|
||||
},
|
||||
|
||||
createGuid: () => crypto.randomBytes(16).toString('hex'),
|
||||
|
||||
fs: () => fs,
|
||||
|
||||
inspectCustom: util.inspect.custom,
|
||||
|
||||
path: () => path,
|
||||
|
||||
pathSeparator: path.sep
|
||||
};
|
||||
|
||||
export const webPlatform: Platform = {
|
||||
calculateSha1: async (text: string) => {
|
||||
const bytes = new TextEncoder().encode(text);
|
||||
|
@ -64,6 +47,13 @@ export const webPlatform: Platform = {
|
|||
|
||||
inspectCustom: undefined,
|
||||
|
||||
|
||||
isLogEnabled(name: 'api' | 'channel') {
|
||||
return false;
|
||||
},
|
||||
|
||||
log(name: 'api' | 'channel', message: string | Error | object) {},
|
||||
|
||||
path: () => {
|
||||
throw new Error('Path module is not available');
|
||||
},
|
||||
|
@ -72,3 +62,31 @@ export const webPlatform: Platform = {
|
|||
|
||||
ws: (url: string) => new WebSocket(url),
|
||||
};
|
||||
|
||||
export const emptyPlatform: Platform = {
|
||||
calculateSha1: async () => {
|
||||
throw new Error('Not implemented');
|
||||
},
|
||||
|
||||
createGuid: () => {
|
||||
throw new Error('Not implemented');
|
||||
},
|
||||
|
||||
fs: () => {
|
||||
throw new Error('Not implemented');
|
||||
},
|
||||
|
||||
inspectCustom: undefined,
|
||||
|
||||
isLogEnabled(name: 'api' | 'channel') {
|
||||
return false;
|
||||
},
|
||||
|
||||
log(name: 'api' | 'channel', message: string | Error | object) { },
|
||||
|
||||
path: () => {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
|
||||
pathSeparator: '/'
|
||||
};
|
|
@ -21,13 +21,21 @@ import { BrowserServerLauncherImpl } from './browserServerImpl';
|
|||
import { Connection } from './client/connection';
|
||||
import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from './server';
|
||||
import { setLibraryStackPrefix } from './utils/isomorphic/stackTrace';
|
||||
import { setDebugMode } from './utils/isomorphic/debug';
|
||||
import { getFromENV } from './server/utils/env';
|
||||
import { nodePlatform } from './server/utils/nodePlatform';
|
||||
import { setPlatformForSelectors } from './client/selectors';
|
||||
|
||||
import type { Playwright as PlaywrightAPI } from './client/playwright';
|
||||
import type { Language } from './utils';
|
||||
import type { Platform } from './utils/platform';
|
||||
import type { Platform } from './common/platform';
|
||||
|
||||
|
||||
export function createInProcessPlaywright(platform: Platform): PlaywrightAPI {
|
||||
const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });
|
||||
setDebugMode(getFromENV('PWDEBUG') || '');
|
||||
setPlatformForSelectors(nodePlatform);
|
||||
|
||||
setLibraryStackPrefix(path.join(__dirname, '..'));
|
||||
|
||||
const clientConnection = new Connection(undefined, platform, undefined, []);
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
*/
|
||||
|
||||
import { createInProcessPlaywright } from './inProcessFactory';
|
||||
import { nodePlatform } from './utils/platform';
|
||||
import { nodePlatform } from './server/utils/nodePlatform';
|
||||
|
||||
module.exports = createInProcessPlaywright(nodePlatform);
|
||||
|
|
|
@ -20,7 +20,7 @@ import * as path from 'path';
|
|||
import { Connection } from './client/connection';
|
||||
import { PipeTransport } from './utils/pipeTransport';
|
||||
import { ManualPromise } from './utils/isomorphic/manualPromise';
|
||||
import { nodePlatform } from './utils/platform';
|
||||
import { nodePlatform } from './server/utils/nodePlatform';
|
||||
|
||||
import type { Playwright } from './client/playwright';
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import { serverSideCallMetadata } from '../server/instrumentation';
|
|||
import { assert, isUnderTest } from '../utils';
|
||||
import { startProfiling, stopProfiling } from '../server/utils/profiler';
|
||||
import { monotonicTime } from '../utils';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { debugLogger } from '../server/utils/debugLogger';
|
||||
|
||||
import type { DispatcherScope, Playwright } from '../server';
|
||||
import type { LaunchOptions } from '../server/types';
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
import { PlaywrightConnection } from './playwrightConnection';
|
||||
import { createPlaywright } from '../server/playwright';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { debugLogger } from '../server/utils/debugLogger';
|
||||
import { Semaphore } from '../utils/isomorphic/semaphore';
|
||||
import { WSServer } from '../server/utils/wsServer';
|
||||
import { wrapInASCIIBox } from '../server/utils/ascii';
|
||||
import { getPlaywrightVersion } from '../utils/userAgent';
|
||||
import { getPlaywrightVersion } from '../server/utils/userAgent';
|
||||
|
||||
import type { ClientType } from './playwrightConnection';
|
||||
import type { SocksProxy } from '../server/utils/socksProxy';
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
../../common/
|
||||
../../protocol/
|
||||
../../utils/
|
||||
../../utils/isomorphic/
|
||||
../../utilsBundle.ts
|
||||
../chromium/
|
||||
../utils
|
||||
|
|
|
@ -19,13 +19,13 @@ import * as fs from 'fs';
|
|||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
|
||||
import { TimeoutSettings } from '../../common/timeoutSettings';
|
||||
import { TimeoutSettings } from '../../utils/isomorphic/timeoutSettings';
|
||||
import { PipeTransport } from '../../utils/pipeTransport';
|
||||
import { createGuid } from '../utils/crypto';
|
||||
import { isUnderTest } from '../../utils/debug';
|
||||
import { getPackageManagerExecCommand } from '../../utils/env';
|
||||
import { isUnderTest } from '../../utils/isomorphic/debug';
|
||||
import { getPackageManagerExecCommand } from '../utils/env';
|
||||
import { makeWaitForNextTask } from '../../utils/task';
|
||||
import { RecentLogsCollector } from '../../utils/debugLogger';
|
||||
import { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import { debug } from '../../utilsBundle';
|
||||
import { wsReceiver, wsSender } from '../../utilsBundle';
|
||||
import { validateBrowserContextOptions } from '../browserContext';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import { EventEmitter } from 'events';
|
||||
import * as net from 'net';
|
||||
|
||||
import { assert } from '../../utils/debug';
|
||||
import { assert } from '../../utils/isomorphic/debug';
|
||||
import { createGuid } from '../utils/crypto';
|
||||
import { debug } from '../../utilsBundle';
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { helper } from '../helper';
|
||||
import { ProtocolError } from '../protocolError';
|
||||
|
||||
import type { RecentLogsCollector } from '../../utils/debugLogger';
|
||||
import type { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
||||
import type { ProtocolLogger } from '../types';
|
||||
import type * as bidiCommands from './third_party/bidiCommands';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import * as bidiMapper from 'chromium-bidi/lib/cjs/bidiMapper/BidiMapper';
|
||||
import * as bidiCdpConnection from 'chromium-bidi/lib/cjs/cdp/CdpConnection';
|
||||
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
|
||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
||||
import type { ChromiumBidi } from 'chromium-bidi/lib/cjs/protocol/protocol';
|
||||
|
|
|
@ -24,7 +24,7 @@ import { ClientCertificatesProxy } from './socksClientCertificatesInterceptor';
|
|||
import type { CallMetadata } from './instrumentation';
|
||||
import type * as types from './types';
|
||||
import type { ProxySettings } from './types';
|
||||
import type { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import type { RecentLogsCollector } from './utils/debugLogger';
|
||||
import type * as channels from '@protocol/channels';
|
||||
import type { ChildProcess } from 'child_process';
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { TimeoutSettings } from '../utils/isomorphic/timeoutSettings';
|
||||
import { createGuid } from './utils/crypto';
|
||||
import { debugMode } from '../utils/debug';
|
||||
import { debugMode } from '../utils/isomorphic/debug';
|
||||
import { Clock } from './clock';
|
||||
import { Debugger } from './debugger';
|
||||
import { BrowserContextAPIRequestContext } from './fetch';
|
||||
|
|
|
@ -19,7 +19,7 @@ import * as os from 'os';
|
|||
import * as path from 'path';
|
||||
|
||||
import { normalizeProxySettings, validateBrowserContextOptions } from './browserContext';
|
||||
import { DEFAULT_TIMEOUT, TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { DEFAULT_TIMEOUT, TimeoutSettings } from '../utils/isomorphic/timeoutSettings';
|
||||
import { ManualPromise, assert, debugMode } from '../utils';
|
||||
import { existsAsync } from './utils/fileUtils';
|
||||
import { helper } from './helper';
|
||||
|
@ -31,7 +31,7 @@ import { isProtocolError } from './protocolError';
|
|||
import { registry } from './registry';
|
||||
import { ClientCertificatesProxy } from './socksClientCertificatesInterceptor';
|
||||
import { WebSocketTransport } from './transport';
|
||||
import { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import { RecentLogsCollector } from './utils/debugLogger';
|
||||
|
||||
import type { Browser, BrowserOptions, BrowserProcess } from './browser';
|
||||
import type { BrowserContext } from './browserContext';
|
||||
|
|
|
@ -22,13 +22,13 @@ import * as path from 'path';
|
|||
import { chromiumSwitches } from './chromiumSwitches';
|
||||
import { CRBrowser } from './crBrowser';
|
||||
import { kBrowserCloseMessageId } from './crConnection';
|
||||
import { TimeoutSettings } from '../../common/timeoutSettings';
|
||||
import { TimeoutSettings } from '../../utils/isomorphic/timeoutSettings';
|
||||
import { debugMode, headersArrayToObject, headersObjectToArray, } from '../../utils';
|
||||
import { wrapInASCIIBox } from '../utils/ascii';
|
||||
import { RecentLogsCollector } from '../../utils/debugLogger';
|
||||
import { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
|
||||
import { fetchData } from '../utils/network';
|
||||
import { getUserAgent } from '../../utils/userAgent';
|
||||
import { getUserAgent } from '../utils/userAgent';
|
||||
import { validateBrowserContextOptions } from '../browserContext';
|
||||
import { BrowserType, kNoXServerRunningError } from '../browserType';
|
||||
import { BrowserReadyState } from '../browserType';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
import * as path from 'path';
|
||||
|
||||
import { assert } from '../../utils/debug';
|
||||
import { assert } from '../../utils/isomorphic/debug';
|
||||
import { createGuid } from '../utils/crypto';
|
||||
import { Artifact } from '../artifact';
|
||||
import { Browser } from '../browser';
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
import { EventEmitter } from 'events';
|
||||
|
||||
import { assert, eventsHelper } from '../../utils';
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { helper } from '../helper';
|
||||
import { ProtocolError } from '../protocolError';
|
||||
|
||||
import type { RegisteredListener } from '../../utils';
|
||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
||||
import type { Protocol } from './protocol';
|
||||
import type { RecentLogsCollector } from '../../utils/debugLogger';
|
||||
import type { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import type { ProtocolLogger } from '../types';
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
import * as path from 'path';
|
||||
|
||||
import { assert } from '../../utils/debug';
|
||||
import { assert } from '../../utils/isomorphic/debug';
|
||||
import { createGuid } from '../utils/crypto';
|
||||
import { eventsHelper } from '../utils/eventsHelper';
|
||||
import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
import { Dispatcher } from './dispatcher';
|
||||
import { SdkObject } from '../../server/instrumentation';
|
||||
import * as localUtils from '../../utils/localUtils';
|
||||
import { nodePlatform } from '../../utils/platform';
|
||||
import { getUserAgent } from '../../utils/userAgent';
|
||||
import * as localUtils from '../../common/localUtils';
|
||||
import { nodePlatform } from '../utils/nodePlatform';
|
||||
import { getUserAgent } from '../utils/userAgent';
|
||||
import { deviceDescriptors as descriptors } from '../deviceDescriptors';
|
||||
import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher';
|
||||
import { Progress, ProgressController } from '../progress';
|
||||
|
@ -26,7 +26,7 @@ import { SocksInterceptor } from '../socksInterceptor';
|
|||
import { WebSocketTransport } from '../transport';
|
||||
import { fetchData } from '../utils/network';
|
||||
|
||||
import type { HarBackend } from '../../utils/harBackend';
|
||||
import type { HarBackend } from '../../common/harBackend';
|
||||
import type { CallMetadata } from '../instrumentation';
|
||||
import type { Playwright } from '../playwright';
|
||||
import type { RootDispatcher } from './dispatcher';
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
../
|
||||
../../common/
|
||||
../../utils/
|
||||
../../utils/isomorphic/
|
||||
../chromium/
|
||||
../utils
|
|
@ -19,10 +19,10 @@ import * as os from 'os';
|
|||
import * as path from 'path';
|
||||
import * as readline from 'readline';
|
||||
|
||||
import { TimeoutSettings } from '../../common/timeoutSettings';
|
||||
import { TimeoutSettings } from '../../utils/isomorphic/timeoutSettings';
|
||||
import { ManualPromise } from '../../utils';
|
||||
import { wrapInASCIIBox } from '../utils/ascii';
|
||||
import { RecentLogsCollector } from '../../utils/debugLogger';
|
||||
import { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import { eventsHelper } from '../utils/eventsHelper';
|
||||
import { validateBrowserContextOptions } from '../browserContext';
|
||||
import { CRBrowser } from '../chromium/crBrowser';
|
||||
|
|
|
@ -21,10 +21,10 @@ import { TLSSocket } from 'tls';
|
|||
import * as url from 'url';
|
||||
import * as zlib from 'zlib';
|
||||
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { TimeoutSettings } from '../utils/isomorphic/timeoutSettings';
|
||||
import { assert, constructURLBasedOnBaseURL, eventsHelper, monotonicTime } from '../utils';
|
||||
import { createGuid } from './utils/crypto';
|
||||
import { getUserAgent } from '../utils/userAgent';
|
||||
import { getUserAgent } from './utils/userAgent';
|
||||
import { HttpsProxyAgent, SocksProxyAgent } from '../utilsBundle';
|
||||
import { BrowserContext, verifyClientCertificates } from './browserContext';
|
||||
import { CookieStore, domainMatches, parseRawCookie } from './cookieStore';
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import { assert } from '../utils/debug';
|
||||
import { fileUploadSizeLimit } from '../utils/fileUtils';
|
||||
import { assert } from '../utils/isomorphic/debug';
|
||||
import { fileUploadSizeLimit } from '../common/fileUtils';
|
||||
import { mime } from '../utilsBundle';
|
||||
|
||||
import type { WritableStreamDispatcher } from './dispatchers/writableStreamDispatcher';
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { helper } from '../helper';
|
||||
import { ProtocolError } from '../protocolError';
|
||||
|
||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
||||
import type { Protocol } from './protocol';
|
||||
import type { RecentLogsCollector } from '../../utils/debugLogger';
|
||||
import type { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import type { ProtocolLogger } from '../types';
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import { FFSession } from './ffConnection';
|
|||
import { FFExecutionContext } from './ffExecutionContext';
|
||||
import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './ffInput';
|
||||
import { FFNetworkManager } from './ffNetworkManager';
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';
|
||||
import { BrowserContext } from '../browserContext';
|
||||
import { TargetClosedError } from '../errors';
|
||||
|
|
|
@ -29,7 +29,7 @@ import { ProgressController } from './progress';
|
|||
import * as types from './types';
|
||||
import { LongStandingScope, asLocator, assert, compressCallLog, constructURLBasedOnBaseURL, makeWaitForNextTask, monotonicTime } from '../utils';
|
||||
import { isSessionClosedError } from './protocolError';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { debugLogger } from './utils/debugLogger';
|
||||
import { eventsHelper } from './utils/eventsHelper';
|
||||
import { isInvalidSelectorError } from '../utils/isomorphic/selectorParser';
|
||||
import { ManualPromise } from '../utils/isomorphic/manualPromise';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { debugLogger } from './utils/debugLogger';
|
||||
import { eventsHelper } from './utils/eventsHelper';
|
||||
|
||||
import type { Progress } from './progress';
|
||||
|
|
|
@ -28,12 +28,12 @@ import { parseEvaluationResultValue, source } from './isomorphic/utilityScriptSe
|
|||
import * as js from './javascript';
|
||||
import { ProgressController } from './progress';
|
||||
import { Screenshotter, validateScreenshotOptions } from './screenshotter';
|
||||
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||
import { TimeoutSettings } from '../utils/isomorphic/timeoutSettings';
|
||||
import { LongStandingScope, assert, compressCallLog, trimStringWithEllipsis } from '../utils';
|
||||
import { createGuid } from './utils/crypto';
|
||||
import { asLocator } from '../utils';
|
||||
import { getComparator } from './utils/comparators';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { debugLogger } from './utils/debugLogger';
|
||||
import { isInvalidSelectorError } from '../utils/isomorphic/selectorParser';
|
||||
import { ManualPromise } from '../utils/isomorphic/manualPromise';
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
import { makeWaitForNextTask } from '../utils';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { debugLogger } from './utils/debugLogger';
|
||||
|
||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from './transport';
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import { ManualPromise } from '../utils/isomorphic/manualPromise';
|
|||
|
||||
import type { CallMetadata, Instrumentation, SdkObject } from './instrumentation';
|
||||
import type { Progress as CommonProgress } from '../common/progress';
|
||||
import type { LogName } from '../utils/debugLogger';
|
||||
import type { LogName } from './utils/debugLogger';
|
||||
|
||||
export interface Progress extends CommonProgress {
|
||||
metadata: CallMetadata;
|
||||
|
|
|
@ -18,7 +18,7 @@ import { EventEmitter } from 'events';
|
|||
|
||||
import { performAction } from './recorderRunner';
|
||||
import { collapseActions } from './recorderUtils';
|
||||
import { isUnderTest } from '../../utils/debug';
|
||||
import { isUnderTest } from '../../utils/isomorphic/debug';
|
||||
import { monotonicTime } from '../../utils/isomorphic/time';
|
||||
|
||||
import type { Signal } from '../../../../recorder/src/actions';
|
||||
|
|
|
@ -20,9 +20,9 @@ import * as fs from 'fs';
|
|||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
|
||||
import { getUserAgent } from '../../utils/userAgent';
|
||||
import { getUserAgent } from '../utils/userAgent';
|
||||
import { progress as ProgressBar } from '../../utilsBundle';
|
||||
import { colors } from '../../utils/isomorphic/colors';
|
||||
import { existsAsync } from '../utils/fileUtils';
|
||||
|
|
|
@ -21,9 +21,9 @@ import * as path from 'path';
|
|||
|
||||
import { deps } from './nativeDeps';
|
||||
import { wrapInASCIIBox } from '../utils/ascii';
|
||||
import { hostPlatform, isOfficiallySupportedPlatform } from '../../utils/hostPlatform';
|
||||
import { hostPlatform, isOfficiallySupportedPlatform } from '../utils/hostPlatform';
|
||||
import { spawnAsync } from '../utils/spawnAsync';
|
||||
import { getPlaywrightVersion } from '../../utils/userAgent';
|
||||
import { getPlaywrightVersion } from '../utils/userAgent';
|
||||
|
||||
import { buildPlaywrightCLICommand, registry } from '.';
|
||||
|
||||
|
|
|
@ -25,16 +25,16 @@ import { dockerVersion, readDockerVersionSync, transformCommandsForRoot } from '
|
|||
import { installDependenciesLinux, installDependenciesWindows, validateDependenciesLinux, validateDependenciesWindows } from './dependencies';
|
||||
import { calculateSha1, getAsBooleanFromENV, getFromENV, getPackageManagerExecCommand } from '../../utils';
|
||||
import { wrapInASCIIBox } from '../utils/ascii';
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { hostPlatform, isOfficiallySupportedPlatform } from '../../utils/hostPlatform';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { hostPlatform, isOfficiallySupportedPlatform } from '../utils/hostPlatform';
|
||||
import { fetchData } from '../utils/network';
|
||||
import { spawnAsync } from '../utils/spawnAsync';
|
||||
import { getEmbedderName } from '../../utils/userAgent';
|
||||
import { getEmbedderName } from '../utils/userAgent';
|
||||
import { lockfile } from '../../utilsBundle';
|
||||
import { canAccessFile, existsAsync, removeFolders } from '../utils/fileUtils';
|
||||
|
||||
import type { DependencyGroup } from './dependencies';
|
||||
import type { HostPlatform } from '../../utils/hostPlatform';
|
||||
import type { HostPlatform } from '../utils/hostPlatform';
|
||||
|
||||
export { writeDockerVersion } from './dependencies';
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import { SocksProxy } from './utils/socksProxy';
|
|||
import { ManualPromise, escapeHTML, generateSelfSignedCertificate, rewriteErrorMessage } from '../utils';
|
||||
import { verifyClientCertificates } from './browserContext';
|
||||
import { createProxyAgent } from './fetch';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { debugLogger } from './utils/debugLogger';
|
||||
import { createSocket, createTLSSocket } from './utils/happyEyeballs';
|
||||
|
||||
import type * as types from './types';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import { frameSnapshotStreamer } from './snapshotterInjected';
|
||||
import { monotonicTime } from '../../../utils/isomorphic/time';
|
||||
import { calculateSha1, createGuid } from '../../utils/crypto';
|
||||
import { debugLogger } from '../../../utils/debugLogger';
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { eventsHelper } from '../../utils/eventsHelper';
|
||||
import { mime } from '../../../utilsBundle';
|
||||
import { BrowserContext } from '../../browserContext';
|
||||
|
|
|
@ -20,7 +20,7 @@ import * as path from 'path';
|
|||
|
||||
import { Snapshotter } from './snapshotter';
|
||||
import { commandsWithTracingSnapshots } from '../../../protocol/debug';
|
||||
import { assert } from '../../../utils/debug';
|
||||
import { assert } from '../../../utils/isomorphic/debug';
|
||||
import { monotonicTime } from '../../../utils/isomorphic/time';
|
||||
import { eventsHelper } from '../../utils/eventsHelper';
|
||||
import { createGuid } from '../../utils/crypto';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[*]
|
||||
../../common
|
||||
../../utils
|
||||
../../utils/isomorphic
|
||||
../../utilsBundle.ts
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
import * as crypto from 'crypto';
|
||||
|
||||
import { assert } from '../../utils/debug';
|
||||
import { assert } from '../../utils/isomorphic/debug';
|
||||
|
||||
export function createGuid(): string {
|
||||
return crypto.randomBytes(16).toString('hex');
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { debug } from '../utilsBundle';
|
||||
import { debug } from '../../utilsBundle';
|
||||
|
||||
const debugLoggerColorMap = {
|
||||
'api': 45, // cyan
|
|
@ -20,7 +20,7 @@ import * as https from 'https';
|
|||
import * as net from 'net';
|
||||
import * as tls from 'tls';
|
||||
|
||||
import { assert } from '../../utils/debug';
|
||||
import { assert } from '../../utils/isomorphic/debug';
|
||||
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
|
||||
import { monotonicTime } from '../../utils/isomorphic/time';
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import * as path from 'path';
|
|||
|
||||
import { mime, wsServer } from '../../utilsBundle';
|
||||
import { createGuid } from './crypto';
|
||||
import { assert } from '../../utils/debug';
|
||||
import { assert } from '../../utils/isomorphic/debug';
|
||||
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
|
||||
import { createHttpServer } from './network';
|
||||
|
||||
|
|
|
@ -23,26 +23,6 @@ let osRelease: {
|
|||
version: string,
|
||||
} | undefined;
|
||||
|
||||
export async function getLinuxDistributionInfo(): Promise<{ id: string, version: string } | undefined> {
|
||||
if (process.platform !== 'linux')
|
||||
return undefined;
|
||||
if (!osRelease && !didFailToReadOSRelease) {
|
||||
try {
|
||||
// List of /etc/os-release values for different distributions could be
|
||||
// found here: https://gist.github.com/aslushnikov/8ceddb8288e4cf9db3039c02e0f4fb75
|
||||
const osReleaseText = await fs.promises.readFile('/etc/os-release', 'utf8');
|
||||
const fields = parseOSReleaseText(osReleaseText);
|
||||
osRelease = {
|
||||
id: fields.get('id') ?? '',
|
||||
version: fields.get('version_id') ?? '',
|
||||
};
|
||||
} catch (e) {
|
||||
didFailToReadOSRelease = true;
|
||||
}
|
||||
}
|
||||
return osRelease;
|
||||
}
|
||||
|
||||
export function getLinuxDistributionInfoSync(): { id: string, version: string } | undefined {
|
||||
if (process.platform !== 'linux')
|
||||
return undefined;
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* 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 * as crypto from 'crypto';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as util from 'util';
|
||||
|
||||
import { Platform } from '../../common/platform';
|
||||
import { debugLogger } from './debugLogger';
|
||||
|
||||
export const nodePlatform: Platform = {
|
||||
calculateSha1: (text: string) => {
|
||||
const sha1 = crypto.createHash('sha1');
|
||||
sha1.update(text);
|
||||
return Promise.resolve(sha1.digest('hex'));
|
||||
},
|
||||
|
||||
createGuid: () => crypto.randomBytes(16).toString('hex'),
|
||||
|
||||
fs: () => fs,
|
||||
|
||||
inspectCustom: util.inspect.custom,
|
||||
|
||||
isLogEnabled(name: 'api' | 'channel') {
|
||||
return debugLogger.isEnabled(name);
|
||||
},
|
||||
|
||||
log(name: 'api' | 'channel', message: string | Error | object) {
|
||||
debugLogger.log(name, message);
|
||||
},
|
||||
|
||||
path: () => path,
|
||||
|
||||
pathSeparator: path.sep
|
||||
};
|
|
@ -17,9 +17,9 @@
|
|||
import EventEmitter from 'events';
|
||||
import * as net from 'net';
|
||||
|
||||
import { assert } from '../../utils/debug';
|
||||
import { assert } from '../../utils/isomorphic/debug';
|
||||
import { createGuid } from './crypto';
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from './debugLogger';
|
||||
import { createSocket } from './happyEyeballs';
|
||||
|
||||
import type { AddressInfo } from 'net';
|
||||
|
|
|
@ -77,6 +77,6 @@ export function getEmbedderName(): { embedderName: string, embedderVersion: stri
|
|||
}
|
||||
|
||||
export function getPlaywrightVersion(majorMinorOnly = false): string {
|
||||
const version = process.env.PW_VERSION_OVERRIDE || require('./../../package.json').version;
|
||||
const version = process.env.PW_VERSION_OVERRIDE || require('./../../../package.json').version;
|
||||
return majorMinorOnly ? version.split('.').slice(0, 2).join('.') : version;
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
import { createHttpServer } from './network';
|
||||
import { wsServer } from '../../utilsBundle';
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from './debugLogger';
|
||||
|
||||
import type { WebSocket, WebSocketServer } from '../../utilsBundle';
|
||||
import type http from 'http';
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
import { EventEmitter } from 'events';
|
||||
|
||||
import { assert } from '../../utils';
|
||||
import { debugLogger } from '../../utils/debugLogger';
|
||||
import { debugLogger } from '../utils/debugLogger';
|
||||
import { helper } from '../helper';
|
||||
import { ProtocolError } from '../protocolError';
|
||||
|
||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
||||
import type { Protocol } from './protocol';
|
||||
import type { RecentLogsCollector } from '../../utils/debugLogger';
|
||||
import type { RecentLogsCollector } from '../utils/debugLogger';
|
||||
import type { ProtocolLogger } from '../types';
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import { assert, debugAssert } from '../../utils';
|
|||
import { headersArrayToObject } from '../../utils/isomorphic/headers';
|
||||
import { createGuid } from '../utils/crypto';
|
||||
import { eventsHelper } from '../utils/eventsHelper';
|
||||
import { hostPlatform } from '../../utils/hostPlatform';
|
||||
import { hostPlatform } from '../utils/hostPlatform';
|
||||
import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';
|
||||
import { PNG, jpegjs } from '../../utilsBundle';
|
||||
import { BrowserContext } from '../browserContext';
|
||||
|
@ -39,7 +39,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 '../utils/debugLogger';
|
||||
|
||||
import type { Protocol } from './protocol';
|
||||
import type { WKBrowserContext } from './wkBrowser';
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
export * from './utils/isomorphic/colors';
|
||||
export * from './utils/isomorphic/debug';
|
||||
export * from './utils/isomorphic/locatorGenerators';
|
||||
export * from './utils/isomorphic/manualPromise';
|
||||
export * from './utils/isomorphic/mimeType';
|
||||
|
@ -25,29 +26,27 @@ export * from './utils/isomorphic/time';
|
|||
export * from './utils/isomorphic/timeoutRunner';
|
||||
export * from './utils/isomorphic/urlMatch';
|
||||
|
||||
export * from './utils/debug';
|
||||
export * from './utils/debugLogger';
|
||||
export * from './utils/env';
|
||||
export * from './utils/hostPlatform';
|
||||
export * from './utils/isomorphic/headers';
|
||||
export * from './utils/isomorphic/semaphore';
|
||||
export * from './utils/platform';
|
||||
export * from './utils/isomorphic/stackTrace';
|
||||
export * from './utils/task';
|
||||
export * from './utils/userAgent';
|
||||
export * from './utils/zipFile';
|
||||
export * from './utils/zones';
|
||||
|
||||
export * from './server/utils/ascii';
|
||||
export * from './server/utils/comparators';
|
||||
export * from './server/utils/crypto';
|
||||
export * from './server/utils/debugLogger';
|
||||
export * from './server/utils/env';
|
||||
export * from './server/utils/eventsHelper';
|
||||
export * from './server/utils/expectUtils';
|
||||
export * from './server/utils/fileUtils';
|
||||
export * from './server/utils/hostPlatform';
|
||||
export * from './server/utils/httpServer';
|
||||
export * from './server/utils/network';
|
||||
export * from './server/utils/processLauncher';
|
||||
export * from './server/utils/profiler';
|
||||
export * from './server/utils/socksProxy';
|
||||
export * from './server/utils/spawnAsync';
|
||||
export * from './server/utils/userAgent';
|
||||
export * from './server/utils/wsServer';
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getFromENV } from './env';
|
||||
|
||||
export function assert(value: any, message?: string): asserts value {
|
||||
if (!value)
|
||||
throw new Error(message || 'Assertion error');
|
||||
|
@ -26,13 +24,18 @@ export function debugAssert(value: any, message?: string): asserts value {
|
|||
throw new Error(message);
|
||||
}
|
||||
|
||||
const debugEnv = getFromENV('PWDEBUG') || '';
|
||||
let _debugMode: string | undefined;
|
||||
|
||||
export function setDebugMode(mode: string) {
|
||||
_debugMode = mode;
|
||||
}
|
||||
|
||||
export function debugMode() {
|
||||
if (debugEnv === 'console')
|
||||
if (_debugMode === 'console')
|
||||
return 'console';
|
||||
if (debugEnv === '0' || debugEnv === 'false')
|
||||
if (_debugMode === '0' || _debugMode === 'false')
|
||||
return '';
|
||||
return debugEnv ? 'inspector' : '';
|
||||
return _debugMode ? 'inspector' : '';
|
||||
}
|
||||
|
||||
let _isUnderTest = !!process.env.PWTEST_UNDER_TEST;
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { debugMode } from '../utils';
|
||||
import { debugMode } from './debug';
|
||||
|
||||
export const DEFAULT_TIMEOUT = 30000;
|
||||
export const DEFAULT_LAUNCH_TIMEOUT = 3 * 60 * 1000; // 3 minutes
|
|
@ -19,7 +19,7 @@ import fs from 'fs';
|
|||
import type http from 'http';
|
||||
import type net from 'net';
|
||||
import * as path from 'path';
|
||||
import { getUserAgent, getPlaywrightVersion } from '../../packages/playwright-core/lib/utils/userAgent';
|
||||
import { getUserAgent, getPlaywrightVersion } from '../../packages/playwright-core/lib/server/utils/userAgent';
|
||||
import WebSocket from 'ws';
|
||||
import { expect, playwrightTest } from '../config/browserTest';
|
||||
import { parseTrace, suppressCertificateWarning } from '../config/utils';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import os from 'os';
|
||||
import url from 'url';
|
||||
import { contextTest as it, expect } from '../config/browserTest';
|
||||
import { hostPlatform } from '../../packages/playwright-core/src/utils/hostPlatform';
|
||||
import { hostPlatform } from '../../packages/playwright-core/src/server/utils/hostPlatform';
|
||||
|
||||
it('SharedArrayBuffer should work @smoke', async function({ contextFactory, httpsServer }) {
|
||||
const context = await contextFactory({ ignoreHTTPSErrors: true });
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
import { playwrightTest as test, expect } from '../../config/browserTest';
|
||||
import http from 'http';
|
||||
import fs from 'fs';
|
||||
import { getUserAgent } from '../../../packages/playwright-core/lib/utils/userAgent';
|
||||
import { getUserAgent } from '../../../packages/playwright-core/lib/server/utils/userAgent';
|
||||
import { suppressCertificateWarning } from '../../config/utils';
|
||||
|
||||
test.skip(({ mode }) => mode === 'service2');
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
import events from 'events';
|
||||
import { EventEmitter } from '../../../packages/playwright-core/lib/client/eventEmitter';
|
||||
import { setUnderTest } from '../../../packages/playwright-core/lib/utils/debug';
|
||||
import { setUnderTest } from '../../../packages/playwright-core/lib/utils/isomorphic/debug';
|
||||
import { test, expect } from '@playwright/test';
|
||||
import * as common from './utils';
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
import os from 'os';
|
||||
import * as util from 'util';
|
||||
import { getPlaywrightVersion } from '../../packages/playwright-core/lib/utils/userAgent';
|
||||
import { getPlaywrightVersion } from '../../packages/playwright-core/lib/server/utils/userAgent';
|
||||
import { expect, playwrightTest as base } from '../config/browserTest';
|
||||
import { kTargetClosedErrorMessage } from 'tests/config/errors';
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import type { Source } from '../../../packages/recorder/src/recorderTypes';
|
|||
import type { CommonFixtures, TestChildProcess } from '../../config/commonFixtures';
|
||||
import { stripAnsi } from '../../config/utils';
|
||||
import { expect } from '@playwright/test';
|
||||
import { nodePlatform } from '../../../packages/playwright-core/lib/utils/platform';
|
||||
import { nodePlatform } from '../../../packages/playwright-core/lib/server/utils/nodePlatform';
|
||||
export { expect } from '@playwright/test';
|
||||
|
||||
type CLITestArgs = {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { hostPlatform } from '../../packages/playwright-core/src/utils/hostPlatform';
|
||||
import { hostPlatform } from '../../packages/playwright-core/src/server/utils/hostPlatform';
|
||||
import { browserTest as it, expect } from '../config/browserTest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
|
|
|
@ -23,7 +23,7 @@ import { startHtmlReportServer } from '../../packages/playwright/lib/reporters/h
|
|||
import { expect as baseExpect, test as baseTest, stripAnsi } from './playwright-test-fixtures';
|
||||
import extractZip from '../../packages/playwright-core/bundles/zip/node_modules/extract-zip';
|
||||
import * as yazl from '../../packages/playwright-core/bundles/zip/node_modules/yazl';
|
||||
import { getUserAgent } from '../../packages/playwright-core/lib/utils/userAgent';
|
||||
import { getUserAgent } from '../../packages/playwright-core/lib/server/utils/userAgent';
|
||||
import { Readable } from 'stream';
|
||||
|
||||
const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION;
|
||||
|
|
Loading…
Reference in New Issue