2020-07-30 02:26:59 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
|
* Modifications 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-08-25 02:05:16 +02:00
|
|
|
import * as channels from '../protocol/channels';
|
2021-09-01 01:34:52 +02:00
|
|
|
import type { Size } from '../common/types';
|
|
|
|
|
import type { ParsedStackTrace } from '../utils/stackTrace';
|
|
|
|
|
export { Size, Point, Rect, Quad, URLMatch, TimeoutOptions } from '../common/types';
|
2020-07-30 02:26:59 +02:00
|
|
|
|
|
|
|
|
type LoggerSeverity = 'verbose' | 'info' | 'warning' | 'error';
|
2020-08-25 02:05:16 +02:00
|
|
|
export interface Logger {
|
2020-07-30 02:26:59 +02:00
|
|
|
isEnabled(name: string, severity: LoggerSeverity): boolean;
|
|
|
|
|
log(name: string, severity: LoggerSeverity, message: string | Error, args: any[], hints: { color?: string }): void;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 01:07:02 +02:00
|
|
|
export interface ClientSideInstrumentation {
|
2021-09-01 01:34:52 +02:00
|
|
|
onApiCall(stackTrace: ParsedStackTrace): (error?: Error) => void;
|
2021-07-31 01:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
2021-07-28 00:27:36 +02:00
|
|
|
export type StrictOptions = { strict?: boolean };
|
2020-07-30 02:26:59 +02:00
|
|
|
export type Headers = { [key: string]: string };
|
|
|
|
|
export type Env = { [key: string]: string | number | boolean | undefined };
|
|
|
|
|
|
|
|
|
|
export type WaitForEventOptions = Function | { predicate?: Function, timeout?: number };
|
|
|
|
|
export type WaitForFunctionOptions = { timeout?: number, polling?: 'raf' | number };
|
|
|
|
|
|
|
|
|
|
export type SelectOption = { value?: string, label?: string, index?: number };
|
2021-06-24 17:18:09 +02:00
|
|
|
export type SelectOptionOptions = { force?: boolean, timeout?: number, noWaitAfter?: boolean };
|
2020-07-30 02:26:59 +02:00
|
|
|
export type FilePayload = { name: string, mimeType: string, buffer: Buffer };
|
2020-11-13 23:24:53 +01:00
|
|
|
export type StorageState = {
|
|
|
|
|
cookies: channels.NetworkCookie[],
|
|
|
|
|
origins: channels.OriginStorage[]
|
|
|
|
|
};
|
|
|
|
|
export type SetStorageState = {
|
|
|
|
|
cookies?: channels.SetNetworkCookie[],
|
|
|
|
|
origins?: channels.OriginStorage[]
|
|
|
|
|
};
|
2020-07-30 02:26:59 +02:00
|
|
|
|
|
|
|
|
export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle';
|
|
|
|
|
export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle']);
|
|
|
|
|
|
2020-12-15 01:03:52 +01:00
|
|
|
export type BrowserContextOptions = Omit<channels.BrowserNewContextOptions, 'viewport' | 'noDefaultViewport' | 'extraHTTPHeaders' | 'storageState'> & {
|
2020-07-30 02:26:59 +02:00
|
|
|
viewport?: Size | null,
|
|
|
|
|
extraHTTPHeaders?: Headers,
|
2020-08-25 02:05:16 +02:00
|
|
|
logger?: Logger,
|
2020-11-03 04:42:05 +01:00
|
|
|
videosPath?: string,
|
|
|
|
|
videoSize?: Size,
|
2020-12-15 01:03:52 +01:00
|
|
|
storageState?: string | channels.BrowserNewContextOptions['storageState'],
|
2020-07-30 02:26:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type LaunchOverrides = {
|
|
|
|
|
ignoreDefaultArgs?: boolean | string[],
|
|
|
|
|
env?: Env,
|
2020-08-25 02:05:16 +02:00
|
|
|
logger?: Logger,
|
2020-07-30 02:26:59 +02:00
|
|
|
};
|
2020-08-01 02:00:36 +02:00
|
|
|
type FirefoxUserPrefs = {
|
|
|
|
|
firefoxUserPrefs?: { [key: string]: string | number | boolean },
|
|
|
|
|
};
|
2020-08-25 02:05:16 +02:00
|
|
|
type LaunchOptionsBase = Omit<channels.BrowserTypeLaunchOptions, 'ignoreAllDefaultArgs' | 'ignoreDefaultArgs' | 'env' | 'firefoxUserPrefs'> & LaunchOverrides;
|
2020-08-01 02:00:36 +02:00
|
|
|
export type LaunchOptions = LaunchOptionsBase & FirefoxUserPrefs;
|
2020-11-13 23:24:53 +01:00
|
|
|
export type LaunchPersistentContextOptions = Omit<LaunchOptionsBase & BrowserContextOptions, 'storageState'>;
|
2020-08-13 22:24:49 +02:00
|
|
|
|
|
|
|
|
export type ConnectOptions = {
|
|
|
|
|
wsEndpoint: string,
|
2021-04-23 23:52:27 +02:00
|
|
|
headers?: { [key: string]: string; };
|
2020-08-13 22:24:49 +02:00
|
|
|
slowMo?: number,
|
|
|
|
|
timeout?: number,
|
2020-08-25 02:05:16 +02:00
|
|
|
logger?: Logger,
|
2020-08-13 22:24:49 +02:00
|
|
|
};
|
|
|
|
|
export type LaunchServerOptions = {
|
2021-04-21 21:23:08 +02:00
|
|
|
channel?: channels.BrowserTypeLaunchOptions['channel'],
|
2020-08-13 22:24:49 +02:00
|
|
|
executablePath?: string,
|
|
|
|
|
args?: string[],
|
|
|
|
|
ignoreDefaultArgs?: boolean | string[],
|
|
|
|
|
handleSIGINT?: boolean,
|
|
|
|
|
handleSIGTERM?: boolean,
|
|
|
|
|
handleSIGHUP?: boolean,
|
|
|
|
|
timeout?: number,
|
|
|
|
|
env?: Env,
|
|
|
|
|
headless?: boolean,
|
|
|
|
|
devtools?: boolean,
|
|
|
|
|
proxy?: {
|
|
|
|
|
server: string,
|
|
|
|
|
bypass?: string,
|
|
|
|
|
username?: string,
|
|
|
|
|
password?: string
|
|
|
|
|
},
|
|
|
|
|
downloadsPath?: string,
|
|
|
|
|
chromiumSandbox?: boolean,
|
|
|
|
|
port?: number,
|
2021-08-22 18:04:47 +02:00
|
|
|
wsPath?: string,
|
2020-08-25 02:05:16 +02:00
|
|
|
logger?: Logger,
|
2020-08-13 22:24:49 +02:00
|
|
|
} & FirefoxUserPrefs;
|
2020-10-19 08:00:28 +02:00
|
|
|
|
|
|
|
|
export type SelectorEngine = {
|
|
|
|
|
/**
|
|
|
|
|
* Returns the first element matching given selector in the root's subtree.
|
|
|
|
|
*/
|
|
|
|
|
query(root: HTMLElement, selector: string): HTMLElement | null;
|
|
|
|
|
/**
|
|
|
|
|
* Returns all elements matching given selector in the root's subtree.
|
|
|
|
|
*/
|
|
|
|
|
queryAll(root: HTMLElement, selector: string): HTMLElement[];
|
|
|
|
|
};
|
2021-06-17 22:04:55 +02:00
|
|
|
|
|
|
|
|
export type RemoteAddr = channels.RemoteAddr;
|
|
|
|
|
export type SecurityDetails = channels.SecurityDetails;
|