UNPKG

3.03 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
6 * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
7 * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
8 * Google as part of the polymer project is also subject to an additional IP
9 * rights grant found at http://polymer.github.io/PATENTS.txt
10 */
11import * as webdriver from 'selenium-webdriver';
12/** Tachometer browser names. Often but not always equal to WebDriver's. */
13export declare type BrowserName = 'chrome' | 'firefox' | 'safari' | 'edge' | 'ie';
14/** Browsers we can drive. */
15export declare const supportedBrowsers: Set<BrowserName>;
16/** Browsers for which we can find the first contentful paint (FCP) time. */
17export declare const fcpBrowsers: Set<BrowserName>;
18export interface BrowserConfig {
19 /** Name of the browser. */
20 name: BrowserName;
21 /** Whether to run in headless mode. */
22 headless: boolean;
23 /** A remote WebDriver server to launch the browser from. */
24 remoteUrl?: string;
25 /** Launch the browser window with these dimensions. */
26 windowSize: WindowSize;
27 /** Path to custom browser binary. */
28 binary?: string;
29 /** Additional binary arguments. */
30 addArguments?: string[];
31 /** WebDriver default binary arguments to omit. */
32 removeArguments?: string[];
33 /** CPU Throttling rate. (1 is no throttle, 2 is 2x slowdown, etc). */
34 cpuThrottlingRate?: number;
35 /** Advanced preferences usually set from the about:config page. */
36 preferences?: {
37 [name: string]: string | number | boolean;
38 };
39}
40export interface WindowSize {
41 width: number;
42 height: number;
43}
44/**
45 * Create a deterministic unique string key for the given BrowserConfig.
46 */
47export declare function browserSignature(config: BrowserConfig): string;
48declare type BrowserConfigWithoutWindowSize = Pick<BrowserConfig, Exclude<keyof BrowserConfig, 'windowSize'>>;
49/**
50 * Parse and validate a browser string specification. Examples:
51 *
52 * chrome
53 * chrome-headless
54 * chrome@<remote-selenium-server>
55 */
56export declare function parseBrowserConfigString(str: string): BrowserConfigWithoutWindowSize;
57/**
58 * Throw if any property of the given BrowserConfig is invalid.
59 */
60export declare function validateBrowserConfig({ name, headless, remoteUrl, windowSize, }: BrowserConfig): void;
61/**
62 * Configure a WebDriver suitable for benchmarking the given browser.
63 */
64export declare function makeDriver(config: BrowserConfig): Promise<webdriver.WebDriver>;
65/**
66 * Open a new tab and switch to it. Assumes that the driver is on a page that
67 * hasn't replaced `window.open` (e.g. the initial blank tab that we always
68 * switch back to after running a benchmark).
69 */
70export declare function openAndSwitchToNewTab(driver: webdriver.WebDriver, config: BrowserConfig): Promise<void>;
71export {};