chore: use utils via index export (4) (#13404)
This commit is contained in:
parent
40d5e3a3c9
commit
a3c02222bf
|
|
@ -14,5 +14,20 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require('./lib/utils/verifyNodeJsVersion');
|
const currentNodeVersion = process.versions.node;
|
||||||
|
const semver = currentNodeVersion.split('.');
|
||||||
|
const [major] = [+semver[0]];
|
||||||
|
|
||||||
|
if (major < 12) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(
|
||||||
|
'You are running Node.js ' +
|
||||||
|
currentNodeVersion +
|
||||||
|
'.\n' +
|
||||||
|
'Playwright requires Node.js 12 or higher. \n' +
|
||||||
|
'Please update your version of Node.js.'
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = require('./lib/inprocess');
|
module.exports = require('./lib/inprocess');
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
[*]
|
[*]
|
||||||
../../
|
../../
|
||||||
../client
|
../client
|
||||||
|
../common
|
||||||
../debug/injected
|
../debug/injected
|
||||||
../generated/
|
../generated/
|
||||||
../grid
|
../grid
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ import type { Page } from '../client/page';
|
||||||
import type { BrowserType } from '../client/browserType';
|
import type { BrowserType } from '../client/browserType';
|
||||||
import type { BrowserContextOptions, LaunchOptions } from '../client/types';
|
import type { BrowserContextOptions, LaunchOptions } from '../client/types';
|
||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import { spawnAsync, getPlaywrightVersion, wrapInASCIIBox } from '../utils';
|
import { getPlaywrightVersion } from '../common/userAgent';
|
||||||
|
import { spawnAsync, wrapInASCIIBox } from '../utils';
|
||||||
import { launchGridAgent } from '../grid/gridAgent';
|
import { launchGridAgent } from '../grid/gridAgent';
|
||||||
import type { GridFactory } from '../grid/gridServer';
|
import type { GridFactory } from '../grid/gridServer';
|
||||||
import { GridServer } from '../grid/gridServer';
|
import { GridServer } from '../grid/gridServer';
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
[*]
|
[*]
|
||||||
|
../common/
|
||||||
../protocol/
|
../protocol/
|
||||||
../utils/
|
../utils/
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import { ChannelOwner } from './channelOwner';
|
||||||
import type * as api from '../../types/types';
|
import type * as api from '../../types/types';
|
||||||
import type * as types from './types';
|
import type * as types from './types';
|
||||||
import type { Page } from './page';
|
import type { Page } from './page';
|
||||||
import { TimeoutSettings } from '../utils/timeoutSettings';
|
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||||
import { Waiter } from './waiter';
|
import { Waiter } from './waiter';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export { Locator, FrameLocator } from './locator';
|
||||||
export { ElementHandle } from './elementHandle';
|
export { ElementHandle } from './elementHandle';
|
||||||
export { FileChooser } from './fileChooser';
|
export { FileChooser } from './fileChooser';
|
||||||
export type { Logger } from './types';
|
export type { Logger } from './types';
|
||||||
export { TimeoutError } from '../utils/errors';
|
export { TimeoutError } from '../common/errors';
|
||||||
export { Frame } from './frame';
|
export { Frame } from './frame';
|
||||||
export { Keyboard, Mouse, Touchscreen } from './input';
|
export { Keyboard, Mouse, Touchscreen } from './input';
|
||||||
export { JSHandle } from './jsHandle';
|
export { JSHandle } from './jsHandle';
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import type { Page } from './page';
|
||||||
import { ChannelOwner } from './channelOwner';
|
import { ChannelOwner } from './channelOwner';
|
||||||
import { Events } from './events';
|
import { Events } from './events';
|
||||||
import type { BrowserContextOptions } from './types';
|
import type { BrowserContextOptions } from './types';
|
||||||
import { isSafeCloseError, kBrowserClosedError } from '../utils/errors';
|
import { isSafeCloseError, kBrowserClosedError } from '../common/errors';
|
||||||
import type * as api from '../../types/types';
|
import type * as api from '../../types/types';
|
||||||
import { CDPSession } from './cdpSession';
|
import { CDPSession } from './cdpSession';
|
||||||
import type { BrowserType } from './browserType';
|
import type { BrowserType } from './browserType';
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,11 @@ import { evaluationScript } from './clientHelper';
|
||||||
import { Browser } from './browser';
|
import { Browser } from './browser';
|
||||||
import { Worker } from './worker';
|
import { Worker } from './worker';
|
||||||
import { Events } from './events';
|
import { Events } from './events';
|
||||||
import { TimeoutSettings } from '../utils/timeoutSettings';
|
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||||
import { Waiter } from './waiter';
|
import { Waiter } from './waiter';
|
||||||
import type { URLMatch, Headers, WaitForEventOptions, BrowserContextOptions, StorageState, LaunchOptions } from './types';
|
import type { URLMatch, Headers, WaitForEventOptions, BrowserContextOptions, StorageState, LaunchOptions } from './types';
|
||||||
import { headersObjectToArray, mkdirIfNeeded } from '../utils';
|
import { headersObjectToArray, mkdirIfNeeded } from '../utils';
|
||||||
import { isSafeCloseError } from '../utils/errors';
|
import { isSafeCloseError } from '../common/errors';
|
||||||
import type * as api from '../../types/types';
|
import type * as api from '../../types/types';
|
||||||
import type * as structs from '../../types/structs';
|
import type * as structs from '../../types/structs';
|
||||||
import { CDPSession } from './cdpSession';
|
import { CDPSession } from './cdpSession';
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import type { ChildProcess } from 'child_process';
|
||||||
import { envObjectToArray } from './clientHelper';
|
import { envObjectToArray } from './clientHelper';
|
||||||
import { assert, headersObjectToArray, monotonicTime } from '../utils';
|
import { assert, headersObjectToArray, monotonicTime } from '../utils';
|
||||||
import type * as api from '../../types/types';
|
import type * as api from '../../types/types';
|
||||||
import { kBrowserClosedError } from '../utils/errors';
|
import { kBrowserClosedError } from '../common/errors';
|
||||||
import { raceAgainstTimeout } from '../utils';
|
import { raceAgainstTimeout } from '../utils';
|
||||||
import type { Playwright } from './playwright';
|
import type { Playwright } from './playwright';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,10 @@ import { EventEmitter } from 'events';
|
||||||
import type * as channels from '../protocol/channels';
|
import type * as channels from '../protocol/channels';
|
||||||
import type { Validator } from '../protocol/validator';
|
import type { Validator } from '../protocol/validator';
|
||||||
import { createScheme, ValidationError } from '../protocol/validator';
|
import { createScheme, ValidationError } from '../protocol/validator';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
import type { ParsedStackTrace } from '../utils/stackTrace';
|
import type { ParsedStackTrace } from '../utils/stackTrace';
|
||||||
import { captureRawStack, captureStackTrace } from '../utils/stackTrace';
|
import { captureRawStack, captureStackTrace } from '../utils/stackTrace';
|
||||||
import { isUnderTest } from '../utils';
|
import { isUnderTest, zones } from '../utils';
|
||||||
import { zones } from '../utils/zones';
|
|
||||||
import type { ClientInstrumentation } from './clientInstrumentation';
|
import type { ClientInstrumentation } from './clientInstrumentation';
|
||||||
import type { Connection } from './connection';
|
import type { Connection } from './connection';
|
||||||
import type { Logger } from './types';
|
import type { Logger } from './types';
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import { Electron, ElectronApplication } from './electron';
|
||||||
import type * as channels from '../protocol/channels';
|
import type * as channels from '../protocol/channels';
|
||||||
import { Stream } from './stream';
|
import { Stream } from './stream';
|
||||||
import { WritableStream } from './writableStream';
|
import { WritableStream } from './writableStream';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
import { SelectorsOwner } from './selectors';
|
import { SelectorsOwner } from './selectors';
|
||||||
import { Android, AndroidSocket, AndroidDevice } from './android';
|
import { Android, AndroidSocket, AndroidDevice } from './android';
|
||||||
import type { ParsedStackTrace } from '../utils/stackTrace';
|
import type { ParsedStackTrace } from '../utils/stackTrace';
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import type * as childProcess from 'child_process';
|
||||||
import type * as structs from '../../types/structs';
|
import type * as structs from '../../types/structs';
|
||||||
import type * as api from '../../types/types';
|
import type * as api from '../../types/types';
|
||||||
import type * as channels from '../protocol/channels';
|
import type * as channels from '../protocol/channels';
|
||||||
import { TimeoutSettings } from '../utils/timeoutSettings';
|
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||||
import { headersObjectToArray } from '../utils';
|
import { headersObjectToArray } from '../utils';
|
||||||
import { BrowserContext } from './browserContext';
|
import { BrowserContext } from './browserContext';
|
||||||
import { ChannelOwner } from './channelOwner';
|
import { ChannelOwner } from './channelOwner';
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import type { BrowserContext } from './browserContext';
|
||||||
import { WritableStream } from './writableStream';
|
import { WritableStream } from './writableStream';
|
||||||
import { pipeline } from 'stream';
|
import { pipeline } from 'stream';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
|
|
||||||
const pipelineAsync = promisify(pipeline);
|
const pipelineAsync = promisify(pipeline);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import type { Serializable } from '../../types/structs';
|
||||||
import type * as api from '../../types/types';
|
import type * as api from '../../types/types';
|
||||||
import type { HeadersArray } from '../common/types';
|
import type { HeadersArray } from '../common/types';
|
||||||
import type * as channels from '../protocol/channels';
|
import type * as channels from '../protocol/channels';
|
||||||
import { kBrowserOrContextClosedError } from '../utils/errors';
|
import { kBrowserOrContextClosedError } from '../common/errors';
|
||||||
import { assert, headersObjectToArray, isFilePayload, isString, mkdirIfNeeded, objectToArray } from '../utils';
|
import { assert, headersObjectToArray, isFilePayload, isString, mkdirIfNeeded, objectToArray } from '../utils';
|
||||||
import { ChannelOwner } from './channelOwner';
|
import { ChannelOwner } from './channelOwner';
|
||||||
import * as network from './network';
|
import * as network from './network';
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import { kLifecycleEvents } from './types';
|
||||||
import { urlMatches } from './clientHelper';
|
import { urlMatches } from './clientHelper';
|
||||||
import type * as api from '../../types/types';
|
import type * as api from '../../types/types';
|
||||||
import type * as structs from '../../types/structs';
|
import type * as structs from '../../types/structs';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
|
|
||||||
export type WaitForNavigationOptions = {
|
export type WaitForNavigationOptions = {
|
||||||
timeout?: number,
|
timeout?: number,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
import { Events } from './events';
|
import { Events } from './events';
|
||||||
import { assert } from '../utils';
|
import { assert } from '../utils';
|
||||||
import { TimeoutSettings } from '../utils/timeoutSettings';
|
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||||
import type { ParsedStackTrace } from '../utils/stackTrace';
|
import type { ParsedStackTrace } from '../utils/stackTrace';
|
||||||
import type * as channels from '../protocol/channels';
|
import type * as channels from '../protocol/channels';
|
||||||
import { parseError, serializeError } from '../protocol/serializers';
|
import { parseError, serializeError } from '../protocol/serializers';
|
||||||
|
|
@ -47,7 +47,7 @@ import path from 'path';
|
||||||
import type { Size, URLMatch, Headers, LifecycleEvent, WaitForEventOptions, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions } from './types';
|
import type { Size, URLMatch, Headers, LifecycleEvent, WaitForEventOptions, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions } from './types';
|
||||||
import { evaluationScript, urlMatches } from './clientHelper';
|
import { evaluationScript, urlMatches } from './clientHelper';
|
||||||
import { isString, isRegExp, isObject, mkdirIfNeeded, headersObjectToArray } from '../utils';
|
import { isString, isRegExp, isObject, mkdirIfNeeded, headersObjectToArray } from '../utils';
|
||||||
import { isSafeCloseError } from '../utils/errors';
|
import { isSafeCloseError } from '../common/errors';
|
||||||
import { Video } from './video';
|
import { Video } from './video';
|
||||||
import { Artifact } from './artifact';
|
import { Artifact } from './artifact';
|
||||||
import type { APIRequestContext } from './fetch';
|
import type { APIRequestContext } from './fetch';
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type * as channels from '../protocol/channels';
|
import type * as channels from '../protocol/channels';
|
||||||
import { TimeoutError } from '../utils/errors';
|
import { TimeoutError } from '../common/errors';
|
||||||
import * as socks from '../utils/socksProxy';
|
import * as socks from '../common/socksProxy';
|
||||||
import { Android } from './android';
|
import { Android } from './android';
|
||||||
import { BrowserType } from './browserType';
|
import { BrowserType } from './browserType';
|
||||||
import { ChannelOwner } from './channelOwner';
|
import { ChannelOwner } from './channelOwner';
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import type { EventEmitter } from 'events';
|
import type { EventEmitter } from 'events';
|
||||||
import { rewriteErrorMessage } from '../utils/stackTrace';
|
import { rewriteErrorMessage } from '../utils/stackTrace';
|
||||||
import { TimeoutError } from '../utils/errors';
|
import { TimeoutError } from '../common/errors';
|
||||||
import { createGuid } from '../utils';
|
import { createGuid } from '../utils';
|
||||||
import type * as channels from '../protocol/channels';
|
import type * as channels from '../protocol/channels';
|
||||||
import type { ChannelOwner } from './channelOwner';
|
import type { ChannelOwner } from './channelOwner';
|
||||||
|
|
|
||||||
2
packages/playwright-core/src/common/DEPS.list
Normal file
2
packages/playwright-core/src/common/DEPS.list
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[*]
|
||||||
|
../utils/
|
||||||
|
|
@ -21,7 +21,7 @@ import net from 'net';
|
||||||
import util from 'util';
|
import util from 'util';
|
||||||
import { debugLogger } from './debugLogger';
|
import { debugLogger } from './debugLogger';
|
||||||
import { createSocket } from './netUtils';
|
import { createSocket } from './netUtils';
|
||||||
import { assert, createGuid } from './';
|
import { assert, createGuid } from '../utils';
|
||||||
|
|
||||||
const dnsLookupAsync = util.promisify(dns.lookup);
|
const dnsLookupAsync = util.promisify(dns.lookup);
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { debugMode } from './';
|
import { debugMode } from '../utils';
|
||||||
|
|
||||||
export const DEFAULT_TIMEOUT = 30000;
|
export const DEFAULT_TIMEOUT = 30000;
|
||||||
|
|
||||||
81
packages/playwright-core/src/common/userAgent.ts
Normal file
81
packages/playwright-core/src/common/userAgent.ts
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) Microsoft Corporation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
import { parseOSReleaseText } from '../utils/ubuntuVersion';
|
||||||
|
|
||||||
|
let cachedUserAgent: string | undefined;
|
||||||
|
|
||||||
|
export function getUserAgent(): string {
|
||||||
|
if (cachedUserAgent)
|
||||||
|
return cachedUserAgent;
|
||||||
|
try {
|
||||||
|
cachedUserAgent = determineUserAgent();
|
||||||
|
} catch (e) {
|
||||||
|
cachedUserAgent = 'Playwright/unknown';
|
||||||
|
}
|
||||||
|
return cachedUserAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function determineUserAgent(): string {
|
||||||
|
let osIdentifier = 'unknown';
|
||||||
|
let osVersion = 'unknown';
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
const version = os.release().split('.');
|
||||||
|
osIdentifier = 'windows';
|
||||||
|
osVersion = `${version[0]}.${version[1]}`;
|
||||||
|
} else if (process.platform === 'darwin') {
|
||||||
|
const version = execSync('sw_vers -productVersion', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim().split('.');
|
||||||
|
osIdentifier = 'macOS';
|
||||||
|
osVersion = `${version[0]}.${version[1]}`;
|
||||||
|
} else if (process.platform === 'linux') {
|
||||||
|
try {
|
||||||
|
// List of /etc/os-release values for different distributions could be
|
||||||
|
// found here: https://gist.github.com/aslushnikov/8ceddb8288e4cf9db3039c02e0f4fb75
|
||||||
|
const osReleaseText = fs.readFileSync('/etc/os-release', 'utf8');
|
||||||
|
const fields = parseOSReleaseText(osReleaseText);
|
||||||
|
osIdentifier = fields.get('id') || 'unknown';
|
||||||
|
osVersion = fields.get('version_id') || 'unknown';
|
||||||
|
} catch (e) {
|
||||||
|
// Linux distribution without /etc/os-release.
|
||||||
|
// Default to linux/unknown.
|
||||||
|
osIdentifier = 'linux';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const { langName, langVersion } = getClientLanguage();
|
||||||
|
return `Playwright/${getPlaywrightVersion()} (${os.arch()}; ${osIdentifier} ${osVersion}) ${langName}/${langVersion}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getClientLanguage(): { langName: string, langVersion: string } {
|
||||||
|
let langName = 'unknown';
|
||||||
|
let langVersion = 'unknown';
|
||||||
|
if (!process.env.PW_LANG_NAME) {
|
||||||
|
langName = 'node';
|
||||||
|
langVersion = process.version.substring(1).split('.').slice(0, 2).join('.');
|
||||||
|
} else if (['node', 'python', 'java', 'csharp'].includes(process.env.PW_LANG_NAME)) {
|
||||||
|
langName = process.env.PW_LANG_NAME;
|
||||||
|
langVersion = process.env.PW_LANG_NAME_VERSION ?? 'unknown';
|
||||||
|
}
|
||||||
|
return { langName, langVersion };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPlaywrightVersion(majorMinorOnly = false) {
|
||||||
|
const packageJson = require('./../../package.json');
|
||||||
|
return majorMinorOnly ? packageJson.version.split('.').slice(0, 2).join('.') : packageJson.version;
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
[*]
|
[*]
|
||||||
../client/
|
../client/
|
||||||
|
../common/
|
||||||
../dispatchers/
|
../dispatchers/
|
||||||
../remote/
|
../remote/
|
||||||
../server/
|
../server/
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
import WebSocket from 'ws';
|
import WebSocket from 'ws';
|
||||||
import { fork } from 'child_process';
|
import { fork } from 'child_process';
|
||||||
import { getPlaywrightVersion } from '../utils';
|
import { getPlaywrightVersion } from '../common/userAgent';
|
||||||
|
|
||||||
export function launchGridAgent(agentId: string, gridURL: string) {
|
export function launchGridAgent(agentId: string, gridURL: string) {
|
||||||
const log = debug(`pw:grid:agent:${agentId}`);
|
const log = debug(`pw:grid:agent:${agentId}`);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
import WebSocket from 'ws';
|
import WebSocket from 'ws';
|
||||||
import { Connection } from '../client/connection';
|
import { Connection } from '../client/connection';
|
||||||
import type { Playwright } from '../client/playwright';
|
import type { Playwright } from '../client/playwright';
|
||||||
import { getPlaywrightVersion } from '../utils';
|
import { getPlaywrightVersion } from '../common/userAgent';
|
||||||
|
|
||||||
export class GridClient {
|
export class GridClient {
|
||||||
private _ws: WebSocket;
|
private _ws: WebSocket;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ import { URL } from 'url';
|
||||||
import type { Server as WebSocketServer } from 'ws';
|
import type { Server as WebSocketServer } from 'ws';
|
||||||
import type WebSocket from 'ws';
|
import type WebSocket from 'ws';
|
||||||
import { HttpServer } from '../utils/httpServer';
|
import { HttpServer } from '../utils/httpServer';
|
||||||
import { assert, createGuid, getPlaywrightVersion } from '../utils';
|
import { assert, createGuid } from '../utils';
|
||||||
|
import { getPlaywrightVersion } from '../common/userAgent';
|
||||||
|
|
||||||
export type GridAgentLaunchOptions = {
|
export type GridAgentLaunchOptions = {
|
||||||
agentId: string,
|
agentId: string,
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import WebSocket from 'ws';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
import { createPlaywright, PlaywrightDispatcher, DispatcherConnection, Root } from '../server';
|
import { createPlaywright, PlaywrightDispatcher, DispatcherConnection, Root } from '../server';
|
||||||
import { gracefullyCloseAll } from '../utils/processLauncher';
|
import { gracefullyCloseAll } from '../utils/processLauncher';
|
||||||
import { SocksProxy } from '../utils/socksProxy';
|
import { SocksProxy } from '../common/socksProxy';
|
||||||
|
|
||||||
function launchGridWorker(gridURL: string, agentId: string, workerId: string) {
|
function launchGridWorker(gridURL: string, agentId: string, workerId: string) {
|
||||||
const log = debug(`pw:grid:worker:${workerId}`);
|
const log = debug(`pw:grid:worker:${workerId}`);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
[*]
|
[*]
|
||||||
|
../common/
|
||||||
../utils/
|
../utils/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TimeoutError } from '../utils/errors';
|
import { TimeoutError } from '../common/errors';
|
||||||
import type { SerializedError, SerializedValue } from './channels';
|
import type { SerializedError, SerializedValue } from './channels';
|
||||||
|
|
||||||
export function serializeError(e: any): SerializedError {
|
export function serializeError(e: any): SerializedError {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
[*]
|
[*]
|
||||||
../client/
|
../client/
|
||||||
|
../common/
|
||||||
../dispatchers/
|
../dispatchers/
|
||||||
../server/
|
../server/
|
||||||
../utils/
|
../utils/
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import { Browser } from '../server/browser';
|
||||||
import { serverSideCallMetadata } from '../server/instrumentation';
|
import { serverSideCallMetadata } from '../server/instrumentation';
|
||||||
import { gracefullyCloseAll } from '../utils/processLauncher';
|
import { gracefullyCloseAll } from '../utils/processLauncher';
|
||||||
import { registry } from '../server';
|
import { registry } from '../server';
|
||||||
import { SocksProxy } from '../utils/socksProxy';
|
import { SocksProxy } from '../common/socksProxy';
|
||||||
|
|
||||||
export class PlaywrightConnection {
|
export class PlaywrightConnection {
|
||||||
private _ws: WebSocket;
|
private _ws: WebSocket;
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
[*]
|
[*]
|
||||||
|
../common/
|
||||||
../generated/
|
../generated/
|
||||||
../protocol/
|
../protocol/
|
||||||
../utils/
|
../utils/
|
||||||
./
|
./
|
||||||
common/
|
./common/
|
||||||
injected/
|
./injected/
|
||||||
supplements/
|
./supplements/
|
||||||
trace/recorder/tracing.ts
|
./trace/recorder/tracing.ts
|
||||||
|
|
||||||
[browserContext.ts]
|
[browserContext.ts]
|
||||||
supplements/har/
|
./supplements/har/
|
||||||
|
|
||||||
[playwright.ts]
|
[playwright.ts]
|
||||||
android/
|
./android/
|
||||||
chromium/
|
./chromium/
|
||||||
electron/
|
./electron/
|
||||||
firefox/
|
./firefox/
|
||||||
webkit/
|
./webkit/
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
[*]
|
[*]
|
||||||
../
|
../
|
||||||
|
../../common/
|
||||||
../../protocol/
|
../../protocol/
|
||||||
../../utils/
|
../../utils/
|
||||||
../chromium/
|
../chromium/
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ import { ProgressController } from '../progress';
|
||||||
import { CRBrowser } from '../chromium/crBrowser';
|
import { CRBrowser } from '../chromium/crBrowser';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import { PipeTransport } from '../../protocol/transport';
|
import { PipeTransport } from '../../protocol/transport';
|
||||||
import { RecentLogsCollector } from '../../utils/debugLogger';
|
import { RecentLogsCollector } from '../../common/debugLogger';
|
||||||
import { gracefullyCloseSet } from '../../utils/processLauncher';
|
import { gracefullyCloseSet } from '../../utils/processLauncher';
|
||||||
import { TimeoutSettings } from '../../utils/timeoutSettings';
|
import { TimeoutSettings } from '../../common/timeoutSettings';
|
||||||
import type { AndroidWebView } from '../../protocol/channels';
|
import type { AndroidWebView } from '../../protocol/channels';
|
||||||
import { SdkObject, serverSideCallMetadata } from '../instrumentation';
|
import { SdkObject, serverSideCallMetadata } from '../instrumentation';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import { Page } from './page';
|
||||||
import { Download } from './download';
|
import { Download } from './download';
|
||||||
import type { ProxySettings } from './types';
|
import type { ProxySettings } from './types';
|
||||||
import type { ChildProcess } from 'child_process';
|
import type { ChildProcess } from 'child_process';
|
||||||
import type { RecentLogsCollector } from '../utils/debugLogger';
|
import type { RecentLogsCollector } from '../common/debugLogger';
|
||||||
import type { CallMetadata } from './instrumentation';
|
import type { CallMetadata } from './instrumentation';
|
||||||
import { SdkObject } from './instrumentation';
|
import { SdkObject } from './instrumentation';
|
||||||
import { Artifact } from './artifact';
|
import { Artifact } from './artifact';
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import { TimeoutSettings } from '../utils/timeoutSettings';
|
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||||
import { debugMode, mkdirIfNeeded, createGuid } from '../utils';
|
import { debugMode, mkdirIfNeeded, createGuid } from '../utils';
|
||||||
import type { Browser, BrowserOptions } from './browser';
|
import type { Browser, BrowserOptions } from './browser';
|
||||||
import type { Download } from './download';
|
import type { Download } from './download';
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ import { PipeTransport } from './pipeTransport';
|
||||||
import type { Progress } from './progress';
|
import type { Progress } from './progress';
|
||||||
import { ProgressController } from './progress';
|
import { ProgressController } from './progress';
|
||||||
import type * as types from './types';
|
import type * as types from './types';
|
||||||
import { DEFAULT_TIMEOUT, TimeoutSettings } from '../utils/timeoutSettings';
|
import { DEFAULT_TIMEOUT, TimeoutSettings } from '../common/timeoutSettings';
|
||||||
import { debugMode, existsAsync } from '../utils';
|
import { debugMode, existsAsync } from '../utils';
|
||||||
import { helper } from './helper';
|
import { helper } from './helper';
|
||||||
import { RecentLogsCollector } from '../utils/debugLogger';
|
import { RecentLogsCollector } from '../common/debugLogger';
|
||||||
import type { CallMetadata } from './instrumentation';
|
import type { CallMetadata } from './instrumentation';
|
||||||
import { SdkObject } from './instrumentation';
|
import { SdkObject } from './instrumentation';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,14 @@ import { CRDevTools } from './crDevTools';
|
||||||
import type { BrowserOptions, BrowserProcess, PlaywrightOptions } from '../browser';
|
import type { BrowserOptions, BrowserProcess, PlaywrightOptions } from '../browser';
|
||||||
import { Browser } from '../browser';
|
import { Browser } from '../browser';
|
||||||
import type * as types from '../types';
|
import type * as types from '../types';
|
||||||
import type { HTTPRequestParams } from '../../utils';
|
import type { HTTPRequestParams } from '../../common/netUtils';
|
||||||
import { fetchData } from '../../utils';
|
import { fetchData } from '../../common/netUtils';
|
||||||
import { debugMode, getUserAgent, headersArrayToObject, removeFolders, streamToString, wrapInASCIIBox } from '../../utils';
|
import { getUserAgent } from '../../common/userAgent';
|
||||||
import { RecentLogsCollector } from '../../utils/debugLogger';
|
import { debugMode, headersArrayToObject, removeFolders, streamToString, wrapInASCIIBox } from '../../utils';
|
||||||
|
import { RecentLogsCollector } from '../../common/debugLogger';
|
||||||
import type { Progress } from '../progress';
|
import type { Progress } from '../progress';
|
||||||
import { ProgressController } from '../progress';
|
import { ProgressController } from '../progress';
|
||||||
import { TimeoutSettings } from '../../utils/timeoutSettings';
|
import { TimeoutSettings } from '../../common/timeoutSettings';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import type { CallMetadata } from '../instrumentation';
|
import type { CallMetadata } from '../instrumentation';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../
|
||||||
import type { Protocol } from './protocol';
|
import type { Protocol } from './protocol';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
import type { RecentLogsCollector } from '../../utils/debugLogger';
|
import type { RecentLogsCollector } from '../../common/debugLogger';
|
||||||
import { debugLogger } from '../../utils/debugLogger';
|
import { debugLogger } from '../../common/debugLogger';
|
||||||
import type { ProtocolLogger } from '../types';
|
import type { ProtocolLogger } from '../types';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import { ProtocolError } from '../protocolError';
|
import { ProtocolError } from '../protocolError';
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { CRSession } from './crConnection';
|
import type { CRSession } from './crConnection';
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import type { Protocol } from './protocol';
|
import type { Protocol } from './protocol';
|
||||||
import type * as types from '../types';
|
import type * as types from '../types';
|
||||||
import { assert } from '../../utils';
|
import { assert } from '../../utils';
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
import type { CRSession } from './crConnection';
|
import type { CRSession } from './crConnection';
|
||||||
import type { Page } from '../page';
|
import type { Page } from '../page';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import type { Protocol } from './protocol';
|
import type { Protocol } from './protocol';
|
||||||
import * as network from '../network';
|
import * as network from '../network';
|
||||||
import type * as frames from '../frames';
|
import type * as frames from '../frames';
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import { registry } from '../registry';
|
import { registry } from '../registry';
|
||||||
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
import { assert, createGuid, headersArrayToObject } from '../../utils';
|
import { assert, createGuid, headersArrayToObject } from '../../utils';
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1 @@
|
||||||
[*]
|
[*]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
[*]
|
[*]
|
||||||
|
../../common/
|
||||||
../../protocol/
|
../../protocol/
|
||||||
../../utils/
|
../../utils/
|
||||||
../**
|
../**
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ import { Dispatcher } from './dispatcher';
|
||||||
import { BrowserContextDispatcher } from './browserContextDispatcher';
|
import { BrowserContextDispatcher } from './browserContextDispatcher';
|
||||||
import type { CallMetadata } from '../instrumentation';
|
import type { CallMetadata } from '../instrumentation';
|
||||||
import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher';
|
import { JsonPipeDispatcher } from '../dispatchers/jsonPipeDispatcher';
|
||||||
import { getUserAgent } from '../../utils';
|
import { getUserAgent } from '../../common/userAgent';
|
||||||
import * as socks from '../../utils/socksProxy';
|
import * as socks from '../../common/socksProxy';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import { ProgressController } from '../progress';
|
import { ProgressController } from '../progress';
|
||||||
import { WebSocketTransport } from '../transport';
|
import { WebSocketTransport } from '../transport';
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import type { Validator } from '../../protocol/validator';
|
||||||
import { createScheme, ValidationError } from '../../protocol/validator';
|
import { createScheme, ValidationError } from '../../protocol/validator';
|
||||||
import { assert, debugAssert, isUnderTest, monotonicTime } from '../../utils';
|
import { assert, debugAssert, isUnderTest, monotonicTime } from '../../utils';
|
||||||
import { tOptional } from '../../protocol/validatorPrimitives';
|
import { tOptional } from '../../protocol/validatorPrimitives';
|
||||||
import { kBrowserOrContextClosedError } from '../../utils/errors';
|
import { kBrowserOrContextClosedError } from '../../common/errors';
|
||||||
import type { CallMetadata } from '../instrumentation';
|
import type { CallMetadata } from '../instrumentation';
|
||||||
import { SdkObject } from '../instrumentation';
|
import { SdkObject } from '../instrumentation';
|
||||||
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ import type * as channels from '../../protocol/channels';
|
||||||
import type { Browser } from '../browser';
|
import type { Browser } from '../browser';
|
||||||
import { GlobalAPIRequestContext } from '../fetch';
|
import { GlobalAPIRequestContext } from '../fetch';
|
||||||
import type { Playwright } from '../playwright';
|
import type { Playwright } from '../playwright';
|
||||||
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../../utils/socksProxy';
|
import type { SocksSocketClosedPayload, SocksSocketDataPayload, SocksSocketRequestedPayload } from '../../common/socksProxy';
|
||||||
import { SocksProxy } from '../../utils/socksProxy';
|
import { SocksProxy } from '../../common/socksProxy';
|
||||||
import type * as types from '../types';
|
import type * as types from '../types';
|
||||||
import { AndroidDispatcher } from './androidDispatcher';
|
import { AndroidDispatcher } from './androidDispatcher';
|
||||||
import { BrowserTypeDispatcher } from './browserTypeDispatcher';
|
import { BrowserTypeDispatcher } from './browserTypeDispatcher';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
[*]
|
[*]
|
||||||
../
|
../
|
||||||
|
../../common/
|
||||||
../../utils/
|
../../utils/
|
||||||
../chromium/
|
../chromium/
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import type { CRPage } from '../chromium/crPage';
|
||||||
import { CRExecutionContext } from '../chromium/crExecutionContext';
|
import { CRExecutionContext } from '../chromium/crExecutionContext';
|
||||||
import * as js from '../javascript';
|
import * as js from '../javascript';
|
||||||
import type { Page } from '../page';
|
import type { Page } from '../page';
|
||||||
import { TimeoutSettings } from '../../utils/timeoutSettings';
|
import { TimeoutSettings } from '../../common/timeoutSettings';
|
||||||
import { wrapInASCIIBox } from '../../utils';
|
import { wrapInASCIIBox } from '../../utils';
|
||||||
import { WebSocketTransport } from '../transport';
|
import { WebSocketTransport } from '../transport';
|
||||||
import { launchProcess, envArrayToObject } from '../../utils/processLauncher';
|
import { launchProcess, envArrayToObject } from '../../utils/processLauncher';
|
||||||
|
|
@ -34,11 +34,11 @@ import type { BrowserWindow } from 'electron';
|
||||||
import type { Progress } from '../progress';
|
import type { Progress } from '../progress';
|
||||||
import { ProgressController } from '../progress';
|
import { ProgressController } from '../progress';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import type { BrowserOptions, BrowserProcess, PlaywrightOptions } from '../browser';
|
import type { BrowserOptions, BrowserProcess, PlaywrightOptions } from '../browser';
|
||||||
import type * as childProcess from 'child_process';
|
import type * as childProcess from 'child_process';
|
||||||
import * as readline from 'readline';
|
import * as readline from 'readline';
|
||||||
import { RecentLogsCollector } from '../../utils/debugLogger';
|
import { RecentLogsCollector } from '../../common/debugLogger';
|
||||||
import { serverSideCallMetadata, SdkObject } from '../instrumentation';
|
import { serverSideCallMetadata, SdkObject } from '../instrumentation';
|
||||||
import type * as channels from '../../protocol/channels';
|
import type * as channels from '../../protocol/channels';
|
||||||
import type { BrowserContextOptions } from '../types';
|
import type { BrowserContextOptions } from '../types';
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,9 @@ import url from 'url';
|
||||||
import zlib from 'zlib';
|
import zlib from 'zlib';
|
||||||
import type { HTTPCredentials } from '../../types/types';
|
import type { HTTPCredentials } from '../../types/types';
|
||||||
import type * as channels from '../protocol/channels';
|
import type * as channels from '../protocol/channels';
|
||||||
import { TimeoutSettings } from '../utils/timeoutSettings';
|
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||||
import { assert, createGuid, getUserAgent, monotonicTime } from '../utils';
|
import { getUserAgent } from '../common/userAgent';
|
||||||
|
import { assert, createGuid, monotonicTime } from '../utils';
|
||||||
import { BrowserContext } from './browserContext';
|
import { BrowserContext } from './browserContext';
|
||||||
import { CookieStore, domainMatches } from './cookieStore';
|
import { CookieStore, domainMatches } from './cookieStore';
|
||||||
import { MultipartFormData } from './formData';
|
import { MultipartFormData } from './formData';
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { kBrowserClosedError } from '../../utils/errors';
|
import { kBrowserClosedError } from '../../common/errors';
|
||||||
import { assert } from '../../utils';
|
import { assert } from '../../utils';
|
||||||
import type { BrowserOptions } from '../browser';
|
import type { BrowserOptions } from '../browser';
|
||||||
import { Browser } from '../browser';
|
import { Browser } from '../browser';
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ import { assert } from '../../utils';
|
||||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
||||||
import type { Protocol } from './protocol';
|
import type { Protocol } from './protocol';
|
||||||
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
import type { RecentLogsCollector } from '../../utils/debugLogger';
|
import type { RecentLogsCollector } from '../../common/debugLogger';
|
||||||
import { debugLogger } from '../../utils/debugLogger';
|
import { debugLogger } from '../../common/debugLogger';
|
||||||
import type { ProtocolLogger } from '../types';
|
import type { ProtocolLogger } from '../types';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import { ProtocolError } from '../protocolError';
|
import { ProtocolError } from '../protocolError';
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import type { FFSession } from './ffConnection';
|
import type { FFSession } from './ffConnection';
|
||||||
import type { Page } from '../page';
|
import type { Page } from '../page';
|
||||||
import * as network from '../network';
|
import * as network from '../network';
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
import * as dialog from '../dialog';
|
import * as dialog from '../dialog';
|
||||||
import * as dom from '../dom';
|
import * as dom from '../dom';
|
||||||
import type * as frames from '../frames';
|
import type * as frames from '../frames';
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import { assert } from '../../utils';
|
import { assert } from '../../utils';
|
||||||
import type { PageBinding, PageDelegate } from '../page';
|
import type { PageBinding, PageDelegate } from '../page';
|
||||||
import { Page, Worker } from '../page';
|
import { Page, Worker } from '../page';
|
||||||
|
|
@ -33,7 +33,7 @@ import { FFNetworkManager } from './ffNetworkManager';
|
||||||
import type { Protocol } from './protocol';
|
import type { Protocol } from './protocol';
|
||||||
import type { Progress } from '../progress';
|
import type { Progress } from '../progress';
|
||||||
import { splitErrorMessage } from '../../utils/stackTrace';
|
import { splitErrorMessage } from '../../utils/stackTrace';
|
||||||
import { debugLogger } from '../../utils/debugLogger';
|
import { debugLogger } from '../../common/debugLogger';
|
||||||
import { ManualPromise } from '../../utils';
|
import { ManualPromise } from '../../utils';
|
||||||
|
|
||||||
export const UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
export const UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ import type * as channels from '../protocol/channels';
|
||||||
import type { ConsoleMessage } from './console';
|
import type { ConsoleMessage } from './console';
|
||||||
import * as dom from './dom';
|
import * as dom from './dom';
|
||||||
import { helper } from './helper';
|
import { helper } from './helper';
|
||||||
import type { RegisteredListener } from '../utils/eventsHelper';
|
import type { RegisteredListener } from '../utils';
|
||||||
import { eventsHelper } from '../utils/eventsHelper';
|
import { eventsHelper } from '../utils';
|
||||||
import * as js from './javascript';
|
import * as js from './javascript';
|
||||||
import * as network from './network';
|
import * as network from './network';
|
||||||
import type { Dialog } from './dialog';
|
import type { Dialog } from './dialog';
|
||||||
|
|
@ -31,7 +31,7 @@ import type { Progress } from './progress';
|
||||||
import { ProgressController } from './progress';
|
import { ProgressController } from './progress';
|
||||||
import { assert, constructURLBasedOnBaseURL, makeWaitForNextTask } from '../utils';
|
import { assert, constructURLBasedOnBaseURL, makeWaitForNextTask } from '../utils';
|
||||||
import { ManualPromise } from '../utils';
|
import { ManualPromise } from '../utils';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
import type { CallMetadata } from './instrumentation';
|
import type { CallMetadata } from './instrumentation';
|
||||||
import { serverSideCallMetadata, SdkObject } from './instrumentation';
|
import { serverSideCallMetadata, SdkObject } from './instrumentation';
|
||||||
import { type InjectedScript } from './injected/injectedScript';
|
import { type InjectedScript } from './injected/injectedScript';
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
import type { EventEmitter } from 'events';
|
import type { EventEmitter } from 'events';
|
||||||
import type * as types from './types';
|
import type * as types from './types';
|
||||||
import type { Progress } from './progress';
|
import type { Progress } from './progress';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
import type { RegisteredListener } from '../utils/eventsHelper';
|
import type { RegisteredListener } from '../utils';
|
||||||
import { eventsHelper } from '../utils/eventsHelper';
|
import { eventsHelper } from '../utils';
|
||||||
|
|
||||||
class Helper {
|
class Helper {
|
||||||
static completeUserURL(urlString: string): string {
|
static completeUserURL(urlString: string): string {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import * as js from './javascript';
|
||||||
import * as network from './network';
|
import * as network from './network';
|
||||||
import type { ScreenshotOptions } from './screenshotter';
|
import type { ScreenshotOptions } from './screenshotter';
|
||||||
import { Screenshotter } from './screenshotter';
|
import { Screenshotter } from './screenshotter';
|
||||||
import { TimeoutSettings } from '../utils/timeoutSettings';
|
import { TimeoutSettings } from '../common/timeoutSettings';
|
||||||
import type * as types from './types';
|
import type * as types from './types';
|
||||||
import { BrowserContext } from './browserContext';
|
import { BrowserContext } from './browserContext';
|
||||||
import { ConsoleMessage } from './console';
|
import { ConsoleMessage } from './console';
|
||||||
|
|
@ -32,7 +32,7 @@ import type { Progress } from './progress';
|
||||||
import { ProgressController } from './progress';
|
import { ProgressController } from './progress';
|
||||||
import { assert, isError } from '../utils';
|
import { assert, isError } from '../utils';
|
||||||
import { ManualPromise } from '../utils';
|
import { ManualPromise } from '../utils';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
import type { ImageComparatorOptions } from '../utils/comparators';
|
import type { ImageComparatorOptions } from '../utils/comparators';
|
||||||
import { getComparator } from '../utils/comparators';
|
import { getComparator } from '../utils/comparators';
|
||||||
import type { SelectorInfo, Selectors } from './selectors';
|
import type { SelectorInfo, Selectors } from './selectors';
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from './transport';
|
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from './transport';
|
||||||
import { makeWaitForNextTask } from '../utils';
|
import { makeWaitForNextTask } from '../utils';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
|
|
||||||
export class PipeTransport implements ConnectionTransport {
|
export class PipeTransport implements ConnectionTransport {
|
||||||
private _pipeWrite: NodeJS.WritableStream;
|
private _pipeWrite: NodeJS.WritableStream;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { Selectors } from './selectors';
|
||||||
import { WebKit } from './webkit/webkit';
|
import { WebKit } from './webkit/webkit';
|
||||||
import type { CallMetadata } from './instrumentation';
|
import type { CallMetadata } from './instrumentation';
|
||||||
import { createInstrumentation, SdkObject } from './instrumentation';
|
import { createInstrumentation, SdkObject } from './instrumentation';
|
||||||
import { debugLogger } from '../utils/debugLogger';
|
import { debugLogger } from '../common/debugLogger';
|
||||||
import type { Page } from './page';
|
import type { Page } from './page';
|
||||||
|
|
||||||
export class Playwright extends SdkObject {
|
export class Playwright extends SdkObject {
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TimeoutError } from '../utils/errors';
|
import { TimeoutError } from '../common/errors';
|
||||||
import { assert, monotonicTime } from '../utils';
|
import { assert, monotonicTime } from '../utils';
|
||||||
import type { LogName } from '../utils/debugLogger';
|
import type { LogName } from '../common/debugLogger';
|
||||||
import type { CallMetadata, Instrumentation, SdkObject } from './instrumentation';
|
import type { CallMetadata, Instrumentation, SdkObject } from './instrumentation';
|
||||||
import type { ElementHandle } from './dom';
|
import type { ElementHandle } from './dom';
|
||||||
import { ManualPromise } from '../utils';
|
import { ManualPromise } from '../utils';
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,9 @@ import extract from 'extract-zip';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { existsAsync, getUserAgent } from '../../utils';
|
import { getUserAgent } from '../../common/userAgent';
|
||||||
import { debugLogger } from '../../utils/debugLogger';
|
import { existsAsync } from '../../utils';
|
||||||
|
import { debugLogger } from '../../common/debugLogger';
|
||||||
import { download } from './download';
|
import { download } from './download';
|
||||||
|
|
||||||
export async function downloadBrowserWithProgressBar(title: string, browserDirectory: string, executablePath: string, downloadURL: string, downloadFileName: string): Promise<boolean> {
|
export async function downloadBrowserWithProgressBar(title: string, browserDirectory: string, executablePath: string, downloadURL: string, downloadFileName: string): Promise<boolean> {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import * as utils from '../../utils';
|
||||||
import { buildPlaywrightCLICommand } from '.';
|
import { buildPlaywrightCLICommand } from '.';
|
||||||
import { deps } from './nativeDeps';
|
import { deps } from './nativeDeps';
|
||||||
import { getUbuntuVersion } from '../../utils/ubuntuVersion';
|
import { getUbuntuVersion } from '../../utils/ubuntuVersion';
|
||||||
|
import { getPlaywrightVersion } from '../../common/userAgent';
|
||||||
|
|
||||||
const BIN_DIRECTORY = path.join(__dirname, '..', '..', '..', 'bin');
|
const BIN_DIRECTORY = path.join(__dirname, '..', '..', '..', 'bin');
|
||||||
const packageJSON = require('../../../package.json');
|
const packageJSON = require('../../../package.json');
|
||||||
|
|
@ -207,10 +208,10 @@ export async function validateDependenciesLinux(sdkLanguage: string, linuxLddDir
|
||||||
];
|
];
|
||||||
// Ignore patch versions when comparing docker container version and Playwright version:
|
// Ignore patch versions when comparing docker container version and Playwright version:
|
||||||
// we **NEVER** roll browsers in patch releases, so native dependencies do not change.
|
// we **NEVER** roll browsers in patch releases, so native dependencies do not change.
|
||||||
if (dockerInfo && !dockerInfo.driverVersion.startsWith(utils.getPlaywrightVersion(true /* majorMinorOnly */) + '.')) {
|
if (dockerInfo && !dockerInfo.driverVersion.startsWith(getPlaywrightVersion(true /* majorMinorOnly */) + '.')) {
|
||||||
// We are running in a docker container with unmatching version.
|
// We are running in a docker container with unmatching version.
|
||||||
// In this case, we know how to install dependencies in it.
|
// In this case, we know how to install dependencies in it.
|
||||||
const pwVersion = utils.getPlaywrightVersion();
|
const pwVersion = getPlaywrightVersion();
|
||||||
const requiredDockerImage = dockerInfo.dockerImageName.replace(dockerInfo.driverVersion, pwVersion);
|
const requiredDockerImage = dockerInfo.dockerImageName.replace(dockerInfo.driverVersion, pwVersion);
|
||||||
errorLines.push(...[
|
errorLines.push(...[
|
||||||
`This is most likely due to docker image version not matching Playwright version:`,
|
`This is most likely due to docker image version not matching Playwright version:`,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import ProgressBar from 'progress';
|
import ProgressBar from 'progress';
|
||||||
import { httpRequest } from '../../utils';
|
import { httpRequest } from '../../common/netUtils';
|
||||||
|
|
||||||
type OnProgressCallback = (downloadedBytes: number, totalBytes: number) => void;
|
type OnProgressCallback = (downloadedBytes: number, totalBytes: number) => void;
|
||||||
type DownloadFileLogger = (message: string) => void;
|
type DownloadFileLogger = (message: string) => void;
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,9 @@ import * as util from 'util';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import lockfile from 'proper-lockfile';
|
import lockfile from 'proper-lockfile';
|
||||||
import { getUbuntuVersion } from '../../utils/ubuntuVersion';
|
import { getUbuntuVersion } from '../../utils/ubuntuVersion';
|
||||||
import { fetchData } from '../../utils';
|
import { fetchData } from '../../common/netUtils';
|
||||||
import { getFromENV, getAsBooleanFromENV, getClientLanguage, calculateSha1, removeFolders, existsAsync, hostPlatform, canAccessFile, spawnAsync, wrapInASCIIBox, transformCommandsForRoot } from '../../utils';
|
import { getClientLanguage } from '../../common/userAgent';
|
||||||
|
import { getFromENV, getAsBooleanFromENV, calculateSha1, removeFolders, existsAsync, hostPlatform, canAccessFile, spawnAsync, wrapInASCIIBox, transformCommandsForRoot } from '../../utils';
|
||||||
import type { DependencyGroup } from './dependencies';
|
import type { DependencyGroup } from './dependencies';
|
||||||
import { installDependenciesLinux, installDependenciesWindows, validateDependenciesLinux, validateDependenciesWindows } from './dependencies';
|
import { installDependenciesLinux, installDependenciesWindows, validateDependenciesLinux, validateDependenciesWindows } from './dependencies';
|
||||||
import { downloadBrowserWithProgressBar, logPolitely } from './browserFetcher';
|
import { downloadBrowserWithProgressBar, logPolitely } from './browserFetcher';
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ import * as network from '../../network';
|
||||||
import { Page } from '../../page';
|
import { Page } from '../../page';
|
||||||
import type * as har from './har';
|
import type * as har from './har';
|
||||||
import { calculateSha1, monotonicTime } from '../../../utils';
|
import { calculateSha1, monotonicTime } from '../../../utils';
|
||||||
import type { RegisteredListener } from '../../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../../utils';
|
||||||
import { eventsHelper } from '../../../utils/eventsHelper';
|
import { eventsHelper } from '../../../utils';
|
||||||
import * as mime from 'mime';
|
import * as mime from 'mime';
|
||||||
import { ManualPromise } from '../../../utils';
|
import { ManualPromise } from '../../../utils';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
[*]
|
[*]
|
||||||
../../
|
../../
|
||||||
|
../../../common/
|
||||||
../../../protocol/
|
../../../protocol/
|
||||||
../../../utils/
|
../../../utils/
|
||||||
../../supplements/har/
|
../../supplements/har/
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
import { BrowserContext } from '../../browserContext';
|
import { BrowserContext } from '../../browserContext';
|
||||||
import { Page } from '../../page';
|
import { Page } from '../../page';
|
||||||
import type { RegisteredListener } from '../../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../../utils';
|
||||||
import { eventsHelper } from '../../../utils/eventsHelper';
|
import { eventsHelper } from '../../../utils';
|
||||||
import { debugLogger } from '../../../utils/debugLogger';
|
import { debugLogger } from '../../../common/debugLogger';
|
||||||
import type { Frame } from '../../frames';
|
import type { Frame } from '../../frames';
|
||||||
import type { SnapshotData } from './snapshotterInjected';
|
import type { SnapshotData } from './snapshotterInjected';
|
||||||
import { frameSnapshotStreamer } from './snapshotterInjected';
|
import { frameSnapshotStreamer } from './snapshotterInjected';
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ import type { NameValue } from '../../../common/types';
|
||||||
import type { TracingTracingStopChunkParams } from '../../../protocol/channels';
|
import type { TracingTracingStopChunkParams } from '../../../protocol/channels';
|
||||||
import { commandsWithTracingSnapshots } from '../../../protocol/channels';
|
import { commandsWithTracingSnapshots } from '../../../protocol/channels';
|
||||||
import { ManualPromise } from '../../../utils';
|
import { ManualPromise } from '../../../utils';
|
||||||
import type { RegisteredListener } from '../../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../../utils';
|
||||||
import { eventsHelper } from '../../../utils/eventsHelper';
|
import { eventsHelper } from '../../../utils';
|
||||||
import { assert, calculateSha1, createGuid, mkdirIfNeeded, monotonicTime, removeFolders } from '../../../utils';
|
import { assert, calculateSha1, createGuid, mkdirIfNeeded, monotonicTime, removeFolders } from '../../../utils';
|
||||||
import { Artifact } from '../../artifact';
|
import { Artifact } from '../../artifact';
|
||||||
import { BrowserContext } from '../../browserContext';
|
import { BrowserContext } from '../../browserContext';
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,8 @@
|
||||||
import type { BrowserOptions } from '../browser';
|
import type { BrowserOptions } from '../browser';
|
||||||
import { Browser } from '../browser';
|
import { Browser } from '../browser';
|
||||||
import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext';
|
import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext';
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { assert, eventsHelper } from '../../utils';
|
||||||
import { assert } from '../../utils';
|
|
||||||
import * as network from '../network';
|
import * as network from '../network';
|
||||||
import type { Page, PageBinding, PageDelegate } from '../page';
|
import type { Page, PageBinding, PageDelegate } from '../page';
|
||||||
import type { ConnectionTransport } from '../transport';
|
import type { ConnectionTransport } from '../transport';
|
||||||
|
|
@ -29,7 +28,7 @@ import type { Protocol } from './protocol';
|
||||||
import type { PageProxyMessageReceivedPayload } from './wkConnection';
|
import type { PageProxyMessageReceivedPayload } from './wkConnection';
|
||||||
import { kPageProxyMessageReceived, WKConnection, WKSession } from './wkConnection';
|
import { kPageProxyMessageReceived, WKConnection, WKSession } from './wkConnection';
|
||||||
import { WKPage } from './wkPage';
|
import { WKPage } from './wkPage';
|
||||||
import { kBrowserClosedError } from '../../utils/errors';
|
import { kBrowserClosedError } from '../../common/errors';
|
||||||
|
|
||||||
const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15';
|
const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15';
|
||||||
const BROWSER_VERSION = '15.4';
|
const BROWSER_VERSION = '15.4';
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ import { assert } from '../../utils';
|
||||||
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
import type { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
|
||||||
import type { Protocol } from './protocol';
|
import type { Protocol } from './protocol';
|
||||||
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
import { rewriteErrorMessage } from '../../utils/stackTrace';
|
||||||
import type { RecentLogsCollector } from '../../utils/debugLogger';
|
import type { RecentLogsCollector } from '../../common/debugLogger';
|
||||||
import { debugLogger } from '../../utils/debugLogger';
|
import { debugLogger } from '../../common/debugLogger';
|
||||||
import type { ProtocolLogger } from '../types';
|
import type { ProtocolLogger } from '../types';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import { kBrowserClosedError } from '../../utils/errors';
|
import { kBrowserClosedError } from '../../common/errors';
|
||||||
import { ProtocolError } from '../protocolError';
|
import { ProtocolError } from '../protocolError';
|
||||||
|
|
||||||
// WKPlaywright uses this special id to issue Browser.close command which we
|
// WKPlaywright uses this special id to issue Browser.close command which we
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ import type * as accessibility from '../accessibility';
|
||||||
import * as dialog from '../dialog';
|
import * as dialog from '../dialog';
|
||||||
import * as dom from '../dom';
|
import * as dom from '../dom';
|
||||||
import type * as frames from '../frames';
|
import type * as frames from '../frames';
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import { helper } from '../helper';
|
import { helper } from '../helper';
|
||||||
import type { JSHandle } from '../javascript';
|
import type { JSHandle } from '../javascript';
|
||||||
import * as network from '../network';
|
import * as network from '../network';
|
||||||
|
|
@ -42,7 +42,7 @@ import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './wkInput';
|
||||||
import { WKInterceptableRequest, WKRouteImpl } from './wkInterceptableRequest';
|
import { WKInterceptableRequest, WKRouteImpl } from './wkInterceptableRequest';
|
||||||
import { WKProvisionalPage } from './wkProvisionalPage';
|
import { WKProvisionalPage } from './wkProvisionalPage';
|
||||||
import { WKWorkers } from './wkWorkers';
|
import { WKWorkers } from './wkWorkers';
|
||||||
import { debugLogger } from '../../utils/debugLogger';
|
import { debugLogger } from '../../common/debugLogger';
|
||||||
import { ManualPromise } from '../../utils';
|
import { ManualPromise } from '../../utils';
|
||||||
|
|
||||||
const UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
const UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
import type { WKSession } from './wkConnection';
|
import type { WKSession } from './wkConnection';
|
||||||
import type { WKPage } from './wkPage';
|
import type { WKPage } from './wkPage';
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import type { Protocol } from './protocol';
|
import type { Protocol } from './protocol';
|
||||||
import { assert } from '../../utils';
|
import { assert } from '../../utils';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { RegisteredListener } from '../../utils/eventsHelper';
|
import type { RegisteredListener } from '../../utils';
|
||||||
import { eventsHelper } from '../../utils/eventsHelper';
|
import { eventsHelper } from '../../utils';
|
||||||
import type { Page } from '../page';
|
import type { Page } from '../page';
|
||||||
import { Worker } from '../page';
|
import { Worker } from '../page';
|
||||||
import type { Protocol } from './protocol';
|
import type { Protocol } from './protocol';
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { SpawnOptions } from 'child_process';
|
import type { SpawnOptions } from 'child_process';
|
||||||
import { execSync, spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
@ -24,13 +24,14 @@ import removeFolder from 'rimraf';
|
||||||
import type stream from 'stream';
|
import type stream from 'stream';
|
||||||
import * as URL from 'url';
|
import * as URL from 'url';
|
||||||
import type { NameValue } from '../protocol/channels';
|
import type { NameValue } from '../protocol/channels';
|
||||||
import { getUbuntuVersionSync, parseOSReleaseText } from './ubuntuVersion';
|
import { getUbuntuVersionSync } from './ubuntuVersion';
|
||||||
|
|
||||||
|
export { eventsHelper } from './eventsHelper';
|
||||||
|
export type { RegisteredListener } from './eventsHelper';
|
||||||
export { ManualPromise } from './manualPromise';
|
export { ManualPromise } from './manualPromise';
|
||||||
export { MultiMap } from './multimap';
|
export { MultiMap } from './multimap';
|
||||||
export { raceAgainstTimeout, TimeoutRunner, TimeoutRunnerError } from './timeoutRunner';
|
export { raceAgainstTimeout, TimeoutRunner, TimeoutRunnerError } from './timeoutRunner';
|
||||||
export type { HTTPRequestParams } from './netUtils';
|
export { zones } from './zones';
|
||||||
export { httpRequest, fetchData } from './netUtils';
|
|
||||||
|
|
||||||
export const existsAsync = (path: string): Promise<boolean> => new Promise(resolve => fs.stat(path, err => resolve(!err)));
|
export const existsAsync = (path: string): Promise<boolean> => new Promise(resolve => fs.stat(path, err => resolve(!err)));
|
||||||
|
|
||||||
|
|
@ -235,66 +236,6 @@ export function canAccessFile(file: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let cachedUserAgent: string | undefined;
|
|
||||||
export function getUserAgent(): string {
|
|
||||||
if (cachedUserAgent)
|
|
||||||
return cachedUserAgent;
|
|
||||||
try {
|
|
||||||
cachedUserAgent = determineUserAgent();
|
|
||||||
} catch (e) {
|
|
||||||
cachedUserAgent = 'Playwright/unknown';
|
|
||||||
}
|
|
||||||
return cachedUserAgent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function determineUserAgent(): string {
|
|
||||||
let osIdentifier = 'unknown';
|
|
||||||
let osVersion = 'unknown';
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
const version = os.release().split('.');
|
|
||||||
osIdentifier = 'windows';
|
|
||||||
osVersion = `${version[0]}.${version[1]}`;
|
|
||||||
} else if (process.platform === 'darwin') {
|
|
||||||
const version = execSync('sw_vers -productVersion', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim().split('.');
|
|
||||||
osIdentifier = 'macOS';
|
|
||||||
osVersion = `${version[0]}.${version[1]}`;
|
|
||||||
} else if (process.platform === 'linux') {
|
|
||||||
try {
|
|
||||||
// List of /etc/os-release values for different distributions could be
|
|
||||||
// found here: https://gist.github.com/aslushnikov/8ceddb8288e4cf9db3039c02e0f4fb75
|
|
||||||
const osReleaseText = fs.readFileSync('/etc/os-release', 'utf8');
|
|
||||||
const fields = parseOSReleaseText(osReleaseText);
|
|
||||||
osIdentifier = fields.get('id') || 'unknown';
|
|
||||||
osVersion = fields.get('version_id') || 'unknown';
|
|
||||||
} catch (e) {
|
|
||||||
// Linux distribution without /etc/os-release.
|
|
||||||
// Default to linux/unknown.
|
|
||||||
osIdentifier = 'linux';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { langName, langVersion } = getClientLanguage();
|
|
||||||
return `Playwright/${getPlaywrightVersion()} (${os.arch()}; ${osIdentifier} ${osVersion}) ${langName}/${langVersion}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getClientLanguage(): { langName: string, langVersion: string } {
|
|
||||||
let langName = 'unknown';
|
|
||||||
let langVersion = 'unknown';
|
|
||||||
if (!process.env.PW_LANG_NAME) {
|
|
||||||
langName = 'node';
|
|
||||||
langVersion = process.version.substring(1).split('.').slice(0, 2).join('.');
|
|
||||||
} else if (['node', 'python', 'java', 'csharp'].includes(process.env.PW_LANG_NAME)) {
|
|
||||||
langName = process.env.PW_LANG_NAME;
|
|
||||||
langVersion = process.env.PW_LANG_NAME_VERSION ?? 'unknown';
|
|
||||||
}
|
|
||||||
return { langName, langVersion };
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getPlaywrightVersion(majorMinorOnly = false) {
|
|
||||||
const packageJson = require('./../../package.json');
|
|
||||||
return majorMinorOnly ? packageJson.version.split('.').slice(0, 2).join('.') : packageJson.version;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function constructURLBasedOnBaseURL(baseURL: string | undefined, givenURL: string): string {
|
export function constructURLBasedOnBaseURL(baseURL: string | undefined, givenURL: string): string {
|
||||||
try {
|
try {
|
||||||
return (new URL.URL(givenURL, baseURL)).toString();
|
return (new URL.URL(givenURL, baseURL)).toString();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import type { StackFrame } from '../protocol/channels';
|
|
||||||
import StackUtils from 'stack-utils';
|
import StackUtils from 'stack-utils';
|
||||||
import { isUnderTest } from './';
|
import { isUnderTest } from './';
|
||||||
|
|
||||||
|
|
@ -38,6 +37,13 @@ const TEST_DIR_LIB = path.resolve(CORE_DIR, '..', '@playwright', 'test');
|
||||||
const COVERAGE_PATH = path.join(CORE_DIR, '..', '..', 'tests', 'config', 'coverage.js');
|
const COVERAGE_PATH = path.join(CORE_DIR, '..', '..', 'tests', 'config', 'coverage.js');
|
||||||
const WS_LIB = path.relative(process.cwd(), path.dirname(require.resolve('ws')));
|
const WS_LIB = path.relative(process.cwd(), path.dirname(require.resolve('ws')));
|
||||||
|
|
||||||
|
export type StackFrame = {
|
||||||
|
file: string,
|
||||||
|
line?: number,
|
||||||
|
column?: number,
|
||||||
|
function?: string,
|
||||||
|
};
|
||||||
|
|
||||||
export type ParsedStackTrace = {
|
export type ParsedStackTrace = {
|
||||||
allFrames: StackFrame[];
|
allFrames: StackFrame[];
|
||||||
frames: StackFrame[];
|
frames: StackFrame[];
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) Microsoft Corporation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const currentNodeVersion = process.versions.node;
|
|
||||||
const semver = currentNodeVersion.split('.');
|
|
||||||
const [major] = [+semver[0]];
|
|
||||||
|
|
||||||
if (major < 12) {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.error(
|
|
||||||
'You are running Node.js ' +
|
|
||||||
currentNodeVersion +
|
|
||||||
'.\n' +
|
|
||||||
'Playwright requires Node.js 12 or higher. \n' +
|
|
||||||
'Please update your version of Node.js.'
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
export {};
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { getUserAgent } from '../../packages/playwright-core/lib/utils';
|
import { getUserAgent } from '../../packages/playwright-core/lib/common/userAgent';
|
||||||
import WebSocket from 'ws';
|
import WebSocket from 'ws';
|
||||||
import { expect, playwrightTest as test } from '../config/browserTest';
|
import { expect, playwrightTest as test } from '../config/browserTest';
|
||||||
import { parseTrace, suppressCertificateWarning } from '../config/utils';
|
import { parseTrace, suppressCertificateWarning } from '../config/utils';
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import { contextTest as test, expect } from '../../config/browserTest';
|
||||||
import { playwrightTest } from '../../config/browserTest';
|
import { playwrightTest } from '../../config/browserTest';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { getUserAgent } from '../../../packages/playwright-core/lib/utils';
|
import { getUserAgent } from '../../../packages/playwright-core/lib/common/userAgent';
|
||||||
import { suppressCertificateWarning } from '../../config/utils';
|
import { suppressCertificateWarning } from '../../config/utils';
|
||||||
|
|
||||||
test('should create a worker from a service worker', async ({ page, server }) => {
|
test('should create a worker from a service worker', async ({ page, server }) => {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
import { getPlaywrightVersion } from '../../packages/playwright-core/lib/utils';
|
import { getPlaywrightVersion } from '../../packages/playwright-core/lib/common/userAgent';
|
||||||
import { expect, playwrightTest as it } from '../config/browserTest';
|
import { expect, playwrightTest as it } from '../config/browserTest';
|
||||||
|
|
||||||
it.skip(({ mode }) => mode !== 'default');
|
it.skip(({ mode }) => mode !== 'default');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue