2020-01-24 14:49:47 -08:00
|
|
|
/**
|
|
|
|
* 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-02-05 12:41:55 -08:00
|
|
|
import { BrowserContext } from '../browserContext';
|
|
|
|
import { BrowserServer } from './browserServer';
|
2020-01-24 14:49:47 -08:00
|
|
|
|
|
|
|
export type BrowserArgOptions = {
|
|
|
|
headless?: boolean,
|
|
|
|
args?: string[],
|
|
|
|
devtools?: boolean,
|
|
|
|
};
|
|
|
|
|
2020-03-31 16:34:59 -07:00
|
|
|
type LaunchOptionsBase = BrowserArgOptions & {
|
2020-01-24 14:49:47 -08:00
|
|
|
executablePath?: string,
|
|
|
|
ignoreDefaultArgs?: boolean | string[],
|
|
|
|
handleSIGINT?: boolean,
|
|
|
|
handleSIGTERM?: boolean,
|
|
|
|
handleSIGHUP?: boolean,
|
|
|
|
timeout?: number,
|
2020-02-18 08:56:20 -08:00
|
|
|
/**
|
|
|
|
* Whether to dump stdio of the browser, this is useful for example when
|
|
|
|
* diagnosing browser launch issues.
|
|
|
|
*/
|
2020-01-24 14:49:47 -08:00
|
|
|
dumpio?: boolean,
|
2020-02-04 19:41:38 -08:00
|
|
|
env?: {[key: string]: string} | undefined
|
2020-01-24 14:49:47 -08:00
|
|
|
};
|
|
|
|
|
2020-03-31 16:34:59 -07:00
|
|
|
export type ConnectOptions = {
|
|
|
|
wsEndpoint: string,
|
|
|
|
slowMo?: number
|
|
|
|
};
|
|
|
|
export type LaunchOptions = LaunchOptionsBase & { slowMo?: number };
|
|
|
|
export type LaunchServerOptions = LaunchOptionsBase & { port?: number };
|
2020-03-20 01:30:35 -07:00
|
|
|
export interface BrowserType<Browser> {
|
2020-01-24 14:49:47 -08:00
|
|
|
executablePath(): string;
|
2020-01-28 18:09:07 -08:00
|
|
|
name(): string;
|
2020-03-31 16:34:59 -07:00
|
|
|
launch(options?: LaunchOptions): Promise<Browser>;
|
|
|
|
launchServer(options?: LaunchServerOptions): Promise<BrowserServer>;
|
2020-03-12 01:10:48 +00:00
|
|
|
launchPersistentContext(userDataDir: string, options?: LaunchOptions): Promise<BrowserContext>;
|
2020-02-04 19:41:38 -08:00
|
|
|
connect(options: ConnectOptions): Promise<Browser>;
|
2020-01-24 14:49:47 -08:00
|
|
|
}
|