Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: use channels as a namespace in client code (#3608)
Dmitry Gozman22e2bf122753
diff --git a/src/client/accessibility.ts b/src/client/accessibility.tsindex 15e39dde24..63c938a316 100644--- a/src/client/accessibility.ts+++ b/src/client/accessibility.ts@@ -15,17 +15,17 @@* limitations under the License.*/-import { PageChannel, AXNode } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ElementHandle } from './elementHandle';-type SerializedAXNode = Omit<AXNode, 'valueString' | 'valueNumber' | 'children' | 'checked' | 'pressed'> & {+type SerializedAXNode = Omit<channels.AXNode, 'valueString' | 'valueNumber' | 'children' | 'checked' | 'pressed'> & {value?: string|number,checked?: boolean | 'mixed',pressed?: boolean | 'mixed',children?: SerializedAXNode[]};-function axNodeFromProtocol(axNode: AXNode): SerializedAXNode {+function axNodeFromProtocol(axNode: channels.AXNode): SerializedAXNode {const result: SerializedAXNode = {...axNode,value: axNode.valueNumber !== undefined ? axNode.valueNumber : axNode.valueString,@@ -39,9 +39,9 @@ function axNodeFromProtocol(axNode: AXNode): SerializedAXNode {}export class Accessibility {- private _channel: PageChannel;+ private _channel: channels.PageChannel;- constructor(channel: PageChannel) {+ constructor(channel: channels.PageChannel) {this._channel = channel;}diff --git a/src/client/browser.ts b/src/client/browser.tsindex 221ff93bb4..0d58c38f82 100644--- a/src/client/browser.ts+++ b/src/client/browser.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { BrowserChannel, BrowserInitializer, BrowserNewContextParams } from '../protocol/channels';+import * as channels from '../protocol/channels';import { BrowserContext } from './browserContext';import { Page } from './page';import { ChannelOwner } from './channelOwner';@@ -24,22 +24,22 @@ import { BrowserContextOptions } from './types';import { validateHeaders } from './network';import { headersObjectToArray } from '../utils/utils';-export class Browser extends ChannelOwner<BrowserChannel, BrowserInitializer> {+export class Browser extends ChannelOwner<channels.BrowserChannel, channels.BrowserInitializer> {readonly _contexts = new Set<BrowserContext>();private _isConnected = true;private _isClosedOrClosing = false;private _closedPromise: Promise<void>;readonly _browserType: BrowserType;- static from(browser: BrowserChannel): Browser {+ static from(browser: channels.BrowserChannel): Browser {return (browser as any)._object;}- static fromNullable(browser: BrowserChannel | null): Browser | null {+ static fromNullable(browser: channels.BrowserChannel | null): Browser | null {return browser ? Browser.from(browser) : null;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: BrowserInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.BrowserInitializer) {super(parent, type, guid, initializer);this._browserType = parent as BrowserType;this._channel.on('close', () => this._didClose());@@ -51,7 +51,7 @@ export class Browser extends ChannelOwner<BrowserChannel, BrowserInitializer> {return this._wrapApiCall('browser.newContext', async () => {if (options.extraHTTPHeaders)validateHeaders(options.extraHTTPHeaders);- const contextOptions: BrowserNewContextParams = {+ const contextOptions: channels.BrowserNewContextParams = {...options,viewport: options.viewport === null ? undefined : options.viewport,noDefaultViewport: options.viewport === null,diff --git a/src/client/browserContext.ts b/src/client/browserContext.tsindex a4101e8ebe..bddc1b8205 100644--- a/src/client/browserContext.ts+++ b/src/client/browserContext.ts@@ -18,7 +18,7 @@import * as frames from './frame';import { Page, BindingCall } from './page';import * as network from './network';-import { BrowserContextChannel, BrowserContextInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';import { deprecate, evaluationScript, urlMatches } from './clientHelper';import { Browser } from './browser';@@ -28,7 +28,7 @@ import { Waiter } from './waiter';import { URLMatch, Headers, WaitForEventOptions } from './types';import { isUnderTest, headersObjectToArray } from '../utils/utils';-export class BrowserContext extends ChannelOwner<BrowserContextChannel, BrowserContextInitializer> {+export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel, channels.BrowserContextInitializer> {_pages = new Set<Page>();private _routes: { url: URLMatch, handler: network.RouteHandler }[] = [];readonly _browser: Browser | undefined;@@ -39,15 +39,15 @@ export class BrowserContext extends ChannelOwner<BrowserContextChannel, BrowserCprivate _isClosedOrClosing = false;private _closedPromise: Promise<void>;- static from(context: BrowserContextChannel): BrowserContext {+ static from(context: channels.BrowserContextChannel): BrowserContext {return (context as any)._object;}- static fromNullable(context: BrowserContextChannel | null): BrowserContext | null {+ static fromNullable(context: channels.BrowserContextChannel | null): BrowserContext | null {return context ? BrowserContext.from(context) : null;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: BrowserContextInitializer, browserName: string) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.BrowserContextInitializer, browserName: string) {super(parent, type, guid, initializer);if (parent instanceof Browser)this._browser = parent;diff --git a/src/client/browserType.ts b/src/client/browserType.tsindex 97395d527e..9de1dc70d2 100644--- a/src/client/browserType.ts+++ b/src/client/browserType.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { BrowserTypeChannel, BrowserTypeInitializer, BrowserTypeLaunchParams, BrowserTypeLaunchPersistentContextParams } from '../protocol/channels';+import * as channels from '../protocol/channels';import { Browser } from './browser';import { BrowserContext } from './browserContext';import { ChannelOwner } from './channelOwner';@@ -40,15 +40,15 @@ export interface BrowserServer {kill(): Promise<void>;}-export class BrowserType extends ChannelOwner<BrowserTypeChannel, BrowserTypeInitializer> {+export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, channels.BrowserTypeInitializer> {private _timeoutSettings = new TimeoutSettings();_serverLauncher?: BrowserServerLauncher;- static from(browserType: BrowserTypeChannel): BrowserType {+ static from(browserType: channels.BrowserTypeChannel): BrowserType {return (browserType as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: BrowserTypeInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.BrowserTypeInitializer) {super(parent, type, guid, initializer);}@@ -66,7 +66,7 @@ export class BrowserType extends ChannelOwner<BrowserTypeChannel, BrowserTypeInireturn this._wrapApiCall('browserType.launch', async () => {assert(!(options as any).userDataDir, 'userDataDir option is not supported in `browserType.launch`. Use `browserType.launchPersistentContext` instead');assert(!(options as any).port, 'Cannot specify a port without launching as a server.');- const launchOptions: BrowserTypeLaunchParams = {+ const launchOptions: channels.BrowserTypeLaunchParams = {...options,ignoreDefaultArgs: Array.isArray(options.ignoreDefaultArgs) ? options.ignoreDefaultArgs : undefined,ignoreAllDefaultArgs: !!options.ignoreDefaultArgs && !Array.isArray(options.ignoreDefaultArgs),@@ -90,7 +90,7 @@ export class BrowserType extends ChannelOwner<BrowserTypeChannel, BrowserTypeInireturn this._wrapApiCall('browserType.launchPersistentContext', async () => {if (options.extraHTTPHeaders)validateHeaders(options.extraHTTPHeaders);- const persistentOptions: BrowserTypeLaunchPersistentContextParams = {+ const persistentOptions: channels.BrowserTypeLaunchPersistentContextParams = {...options,viewport: options.viewport === null ? undefined : options.viewport,noDefaultViewport: options.viewport === null,diff --git a/src/client/cdpSession.ts b/src/client/cdpSession.tsindex e71a3b0eda..c3b7923950 100644--- a/src/client/cdpSession.ts+++ b/src/client/cdpSession.ts@@ -14,12 +14,12 @@* limitations under the License.*/-import { CDPSessionChannel, CDPSessionInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';import { Protocol } from '../server/chromium/protocol';-export class CDPSession extends ChannelOwner<CDPSessionChannel, CDPSessionInitializer> {- static from(cdpSession: CDPSessionChannel): CDPSession {+export class CDPSession extends ChannelOwner<channels.CDPSessionChannel, channels.CDPSessionInitializer> {+ static from(cdpSession: channels.CDPSessionChannel): CDPSession {return (cdpSession as any)._object;}@@ -29,7 +29,7 @@ export class CDPSession extends ChannelOwner<CDPSessionChannel, CDPSessionInitiaremoveListener: <T extends keyof Protocol.Events | symbol>(event: T, listener: (payload: T extends symbol ? any : Protocol.Events[T extends keyof Protocol.Events ? T : never]) => void) => this;once: <T extends keyof Protocol.Events | symbol>(event: T, listener: (payload: T extends symbol ? any : Protocol.Events[T extends keyof Protocol.Events ? T : never]) => void) => this;- constructor(parent: ChannelOwner, type: string, guid: string, initializer: CDPSessionInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.CDPSessionInitializer) {super(parent, type, guid, initializer);this._channel.on('event', ({ method, params }) => {diff --git a/src/client/channelOwner.ts b/src/client/channelOwner.tsindex 5deba14825..f8f4d4896b 100644--- a/src/client/channelOwner.ts+++ b/src/client/channelOwner.ts@@ -15,12 +15,12 @@*/import { EventEmitter } from 'events';-import type { Channel } from '../protocol/channels';+import * as channels from '../protocol/channels';import type { Connection } from './connection';-import type { LoggerSink } from './types';+import type { Logger } from './types';import { debugLogger } from '../utils/debugLogger';-export abstract class ChannelOwner<T extends Channel = Channel, Initializer = {}> extends EventEmitter {+export abstract class ChannelOwner<T extends channels.Channel = channels.Channel, Initializer = {}> extends EventEmitter {private _connection: Connection;private _parent: ChannelOwner | undefined;private _objects = new Map<string, ChannelOwner>();@@ -29,7 +29,7 @@ export abstract class ChannelOwner<T extends Channel = Channel, Initializer = {}readonly _guid: string;readonly _channel: T;readonly _initializer: Initializer;- _logger: LoggerSink | undefined;+ _logger: Logger | undefined;constructor(parent: ChannelOwner | Connection, type: string, guid: string, initializer: Initializer) {super();@@ -87,7 +87,7 @@ export abstract class ChannelOwner<T extends Channel = Channel, Initializer = {}};}- protected async _wrapApiCall<T>(apiName: string, func: () => Promise<T>, logger?: LoggerSink): Promise<T> {+ protected async _wrapApiCall<T>(apiName: string, func: () => Promise<T>, logger?: Logger): Promise<T> {const stackObject: any = {};Error.captureStackTrace(stackObject);const stack = stackObject.stack.startsWith('Error') ? stackObject.stack.substring(5) : stackObject.stack;@@ -119,7 +119,7 @@ export abstract class ChannelOwner<T extends Channel = Channel, Initializer = {}}}-function logApiCall(logger: LoggerSink | undefined, message: string) {+function logApiCall(logger: Logger | undefined, message: string) {if (logger && logger.isEnabled('api', 'info'))logger.log('api', 'info', message, [], { color: 'cyan' });debugLogger.log('api', message);diff --git a/src/client/chromiumBrowserContext.ts b/src/client/chromiumBrowserContext.tsindex 5fd1d55f65..1f9b0ccb68 100644--- a/src/client/chromiumBrowserContext.ts+++ b/src/client/chromiumBrowserContext.ts@@ -16,7 +16,7 @@*/import { Page } from './page';-import { BrowserContextInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';import { CDPSession } from './cdpSession';import { Events } from './events';@@ -27,7 +27,7 @@ export class ChromiumBrowserContext extends BrowserContext {_backgroundPages = new Set<Page>();_serviceWorkers = new Set<Worker>();- constructor(parent: ChannelOwner, type: string, guid: string, initializer: BrowserContextInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.BrowserContextInitializer) {super(parent, type, guid, initializer, 'chromium');this._channel.on('crBackgroundPage', ({ page }) => {const backgroundPage = Page.from(page);diff --git a/src/client/chromiumCoverage.ts b/src/client/chromiumCoverage.tsindex ed9ed12ec6..472e0ac6d1 100644--- a/src/client/chromiumCoverage.ts+++ b/src/client/chromiumCoverage.ts@@ -14,28 +14,28 @@* limitations under the License.*/-import { PageChannel, PageCrStartJSCoverageOptions, PageCrStopJSCoverageResult, PageCrStartCSSCoverageOptions, PageCrStopCSSCoverageResult } from '../protocol/channels';+import * as channels from '../protocol/channels';export class ChromiumCoverage {- private _channel: PageChannel;+ private _channel: channels.PageChannel;- constructor(channel: PageChannel) {+ constructor(channel: channels.PageChannel) {this._channel = channel;}- async startJSCoverage(options: PageCrStartJSCoverageOptions = {}) {+ async startJSCoverage(options: channels.PageCrStartJSCoverageOptions = {}) {await this._channel.crStartJSCoverage(options);}- async stopJSCoverage(): Promise<PageCrStopJSCoverageResult['entries']> {+ async stopJSCoverage(): Promise<channels.PageCrStopJSCoverageResult['entries']> {return (await this._channel.crStopJSCoverage()).entries;}- async startCSSCoverage(options: PageCrStartCSSCoverageOptions = {}) {+ async startCSSCoverage(options: channels.PageCrStartCSSCoverageOptions = {}) {await this._channel.crStartCSSCoverage(options);}- async stopCSSCoverage(): Promise<PageCrStopCSSCoverageResult['entries']> {+ async stopCSSCoverage(): Promise<channels.PageCrStopCSSCoverageResult['entries']> {return (await this._channel.crStopCSSCoverage()).entries;}}diff --git a/src/client/connection.ts b/src/client/connection.tsindex 2b18b0db22..11bab69ea4 100644--- a/src/client/connection.ts+++ b/src/client/connection.ts@@ -31,7 +31,7 @@ import { parseError } from '../protocol/serializers';import { CDPSession } from './cdpSession';import { Playwright } from './playwright';import { Electron, ElectronApplication } from './electron';-import { Channel } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChromiumBrowser } from './chromiumBrowser';import { ChromiumBrowserContext } from './chromiumBrowserContext';import { Selectors } from './selectors';@@ -41,7 +41,7 @@ import { WebKitBrowser } from './webkitBrowser';import { FirefoxBrowser } from './firefoxBrowser';import { debugLogger } from '../utils/debugLogger';-class Root extends ChannelOwner<Channel, {}> {+class Root extends ChannelOwner<channels.Channel, {}> {constructor(connection: Connection) {super(connection, '', '', {});}diff --git a/src/client/consoleMessage.ts b/src/client/consoleMessage.tsindex e3cad9e591..e8948c2500 100644--- a/src/client/consoleMessage.ts+++ b/src/client/consoleMessage.ts@@ -16,17 +16,17 @@import * as util from 'util';import { JSHandle } from './jsHandle';-import { ConsoleMessageChannel, ConsoleMessageInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';-type ConsoleMessageLocation = ConsoleMessageInitializer['location'];+type ConsoleMessageLocation = channels.ConsoleMessageInitializer['location'];-export class ConsoleMessage extends ChannelOwner<ConsoleMessageChannel, ConsoleMessageInitializer> {- static from(message: ConsoleMessageChannel): ConsoleMessage {+export class ConsoleMessage extends ChannelOwner<channels.ConsoleMessageChannel, channels.ConsoleMessageInitializer> {+ static from(message: channels.ConsoleMessageChannel): ConsoleMessage {return (message as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: ConsoleMessageInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.ConsoleMessageInitializer) {super(parent, type, guid, initializer);}diff --git a/src/client/dialog.ts b/src/client/dialog.tsindex 8fc6775ebe..458fcfd4e8 100644--- a/src/client/dialog.ts+++ b/src/client/dialog.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import { DialogChannel, DialogInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';-export class Dialog extends ChannelOwner<DialogChannel, DialogInitializer> {- static from(dialog: DialogChannel): Dialog {+export class Dialog extends ChannelOwner<channels.DialogChannel, channels.DialogInitializer> {+ static from(dialog: channels.DialogChannel): Dialog {return (dialog as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: DialogInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.DialogInitializer) {super(parent, type, guid, initializer);}diff --git a/src/client/download.ts b/src/client/download.tsindex 0231d0522f..cf3768d6b1 100644--- a/src/client/download.ts+++ b/src/client/download.ts@@ -14,17 +14,17 @@* limitations under the License.*/-import { DownloadChannel, DownloadInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';import { Readable } from 'stream';import { Stream } from './stream';-export class Download extends ChannelOwner<DownloadChannel, DownloadInitializer> {- static from(download: DownloadChannel): Download {+export class Download extends ChannelOwner<channels.DownloadChannel, channels.DownloadInitializer> {+ static from(download: channels.DownloadChannel): Download {return (download as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: DownloadInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.DownloadInitializer) {super(parent, type, guid, initializer);}diff --git a/src/client/electron.ts b/src/client/electron.tsindex b1f5ecfa3b..73689adfd8 100644--- a/src/client/electron.ts+++ b/src/client/electron.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { ElectronChannel, ElectronInitializer, ElectronApplicationChannel, ElectronApplicationInitializer, ElectronLaunchParams, ElectronLaunchOptions } from '../protocol/channels';+import * as channels from '../protocol/channels';import { BrowserContext } from './browserContext';import { ChannelOwner } from './channelOwner';import { Page } from './page';@@ -22,20 +22,20 @@ import { serializeArgument, FuncOn, parseResult, SmartHandle, JSHandle } from '.import { TimeoutSettings } from '../utils/timeoutSettings';import { Waiter } from './waiter';import { Events } from './events';-import { WaitForEventOptions, Env, LoggerSink } from './types';+import { WaitForEventOptions, Env, Logger } from './types';import { envObjectToArray } from './clientHelper';-type ElectronOptions = Omit<ElectronLaunchOptions, 'env'> & {+type ElectronOptions = Omit<channels.ElectronLaunchOptions, 'env'> & {env?: Env,- logger?: LoggerSink,+ logger?: Logger,};-export class Electron extends ChannelOwner<ElectronChannel, ElectronInitializer> {- static from(electron: ElectronChannel): Electron {+export class Electron extends ChannelOwner<channels.ElectronChannel, channels.ElectronInitializer> {+ static from(electron: channels.ElectronChannel): Electron {return (electron as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: ElectronInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.ElectronInitializer) {super(parent, type, guid, initializer);}@@ -43,7 +43,7 @@ export class Electron extends ChannelOwner<ElectronChannel, ElectronInitializer>const logger = options.logger;options = { ...options, logger: undefined };return this._wrapApiCall('electron.launch', async () => {- const params: ElectronLaunchParams = {+ const params: channels.ElectronLaunchParams = {...options,env: options.env ? envObjectToArray(options.env) : undefined,executablePath,@@ -53,16 +53,16 @@ export class Electron extends ChannelOwner<ElectronChannel, ElectronInitializer>}}-export class ElectronApplication extends ChannelOwner<ElectronApplicationChannel, ElectronApplicationInitializer> {+export class ElectronApplication extends ChannelOwner<channels.ElectronApplicationChannel, channels.ElectronApplicationInitializer> {private _context?: BrowserContext;private _windows = new Set<Page>();private _timeoutSettings = new TimeoutSettings();- static from(electronApplication: ElectronApplicationChannel): ElectronApplication {+ static from(electronApplication: channels.ElectronApplicationChannel): ElectronApplication {return (electronApplication as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: ElectronApplicationInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.ElectronApplicationInitializer) {super(parent, type, guid, initializer);this._channel.on('context', ({ context }) => this._context = BrowserContext.from(context));this._channel.on('window', ({ page, browserWindow }) => {diff --git a/src/client/elementHandle.ts b/src/client/elementHandle.tsindex 63f9135f96..cf0971b636 100644--- a/src/client/elementHandle.ts+++ b/src/client/elementHandle.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { ElementHandleChannel, JSHandleInitializer, ElementHandleScrollIntoViewIfNeededOptions, ElementHandleHoverOptions, ElementHandleClickOptions, ElementHandleDblclickOptions, ElementHandleFillOptions, ElementHandleSetInputFilesOptions, ElementHandlePressOptions, ElementHandleCheckOptions, ElementHandleUncheckOptions, ElementHandleScreenshotOptions, ElementHandleTypeOptions, ElementHandleSelectTextOptions, ElementHandleWaitForSelectorOptions, ElementHandleWaitForElementStateOptions, ElementHandleSetInputFilesParams } from '../protocol/channels';+import * as channels from '../protocol/channels';import { Frame } from './frame';import { FuncOn, JSHandle, serializeArgument, parseResult } from './jsHandle';import { ChannelOwner } from './channelOwner';@@ -28,19 +28,19 @@ import { assert, isString, mkdirIfNeeded } from '../utils/utils';const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));export class ElementHandle<T extends Node = Node> extends JSHandle<T> {- readonly _elementChannel: ElementHandleChannel;+ readonly _elementChannel: channels.ElementHandleChannel;- static from(handle: ElementHandleChannel): ElementHandle {+ static from(handle: channels.ElementHandleChannel): ElementHandle {return (handle as any)._object;}- static fromNullable(handle: ElementHandleChannel | undefined): ElementHandle | null {+ static fromNullable(handle: channels.ElementHandleChannel | undefined): ElementHandle | null {return handle ? ElementHandle.from(handle) : null;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: JSHandleInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.JSHandleInitializer) {super(parent, type, guid, initializer);- this._elementChannel = this._channel as ElementHandleChannel;+ this._elementChannel = this._channel as channels.ElementHandleChannel;}asElement(): ElementHandle<T> | null {@@ -91,25 +91,25 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> {});}- async scrollIntoViewIfNeeded(options: ElementHandleScrollIntoViewIfNeededOptions = {}) {+ async scrollIntoViewIfNeeded(options: channels.ElementHandleScrollIntoViewIfNeededOptions = {}) {return this._wrapApiCall('elementHandle.scrollIntoViewIfNeeded', async () => {await this._elementChannel.scrollIntoViewIfNeeded(options);});}- async hover(options: ElementHandleHoverOptions = {}): Promise<void> {+ async hover(options: channels.ElementHandleHoverOptions = {}): Promise<void> {return this._wrapApiCall('elementHandle.hover', async () => {await this._elementChannel.hover(options);});}- async click(options: ElementHandleClickOptions = {}): Promise<void> {+ async click(options: channels.ElementHandleClickOptions = {}): Promise<void> {return this._wrapApiCall('elementHandle.click', async () => {return await this._elementChannel.click(options);});}- async dblclick(options: ElementHandleDblclickOptions = {}): Promise<void> {+ async dblclick(options: channels.ElementHandleDblclickOptions = {}): Promise<void> {return this._wrapApiCall('elementHandle.dblclick', async () => {return await this._elementChannel.dblclick(options);});@@ -122,19 +122,19 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> {});}- async fill(value: string, options: ElementHandleFillOptions = {}): Promise<void> {+ async fill(value: string, options: channels.ElementHandleFillOptions = {}): Promise<void> {return this._wrapApiCall('elementHandle.fill', async () => {return await this._elementChannel.fill({ value, ...options });});}- async selectText(options: ElementHandleSelectTextOptions = {}): Promise<void> {+ async selectText(options: channels.ElementHandleSelectTextOptions = {}): Promise<void> {return this._wrapApiCall('elementHandle.selectText', async () => {await this._elementChannel.selectText(options);});}- async setInputFiles(files: string | FilePayload | string[] | FilePayload[], options: ElementHandleSetInputFilesOptions = {}) {+ async setInputFiles(files: string | FilePayload | string[] | FilePayload[], options: channels.ElementHandleSetInputFilesOptions = {}) {return this._wrapApiCall('elementHandle.setInputFiles', async () => {await this._elementChannel.setInputFiles({ files: await convertInputFiles(files), ...options });});@@ -146,25 +146,25 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> {});}- async type(text: string, options: ElementHandleTypeOptions = {}): Promise<void> {+ async type(text: string, options: channels.ElementHandleTypeOptions = {}): Promise<void> {return this._wrapApiCall('elementHandle.type', async () => {await this._elementChannel.type({ text, ...options });});}- async press(key: string, options: ElementHandlePressOptions = {}): Promise<void> {+ async press(key: string, options: channels.ElementHandlePressOptions = {}): Promise<void> {return this._wrapApiCall('elementHandle.press', async () => {await this._elementChannel.press({ key, ...options });});}- async check(options: ElementHandleCheckOptions = {}) {+ async check(options: channels.ElementHandleCheckOptions = {}) {return this._wrapApiCall('elementHandle.check', async () => {return await this._elementChannel.check(options);});}- async uncheck(options: ElementHandleUncheckOptions = {}) {+ async uncheck(options: channels.ElementHandleUncheckOptions = {}) {return this._wrapApiCall('elementHandle.uncheck', async () => {return await this._elementChannel.uncheck(options);});@@ -177,7 +177,7 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> {});}- async screenshot(options: ElementHandleScreenshotOptions & { path?: string } = {}): Promise<Buffer> {+ async screenshot(options: channels.ElementHandleScreenshotOptions & { path?: string } = {}): Promise<Buffer> {return this._wrapApiCall('elementHandle.screenshot', async () => {const type = determineScreenshotType(options);const result = await this._elementChannel.screenshot({ ...options, type });@@ -221,13 +221,13 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> {});}- async waitForElementState(state: 'visible' | 'hidden' | 'stable' | 'enabled' | 'disabled', options: ElementHandleWaitForElementStateOptions = {}): Promise<void> {+ async waitForElementState(state: 'visible' | 'hidden' | 'stable' | 'enabled' | 'disabled', options: channels.ElementHandleWaitForElementStateOptions = {}): Promise<void> {return this._wrapApiCall('elementHandle.waitForElementState', async () => {return await this._elementChannel.waitForElementState({ state, ...options });});}- async waitForSelector(selector: string, options: ElementHandleWaitForSelectorOptions = {}): Promise<ElementHandle<Element> | null> {+ async waitForSelector(selector: string, options: channels.ElementHandleWaitForSelectorOptions = {}): Promise<ElementHandle<Element> | null> {return this._wrapApiCall('elementHandle.waitForSelector', async () => {const result = await this._elementChannel.waitForSelector({ selector, ...options });return ElementHandle.fromNullable(result.element) as ElementHandle<Element> | null;@@ -235,7 +235,7 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> {}}-export function convertSelectOptionValues(values: string | ElementHandle | SelectOption | string[] | ElementHandle[] | SelectOption[] | null): { elements?: ElementHandleChannel[], options?: SelectOption[] } {+export function convertSelectOptionValues(values: string | ElementHandle | SelectOption | string[] | ElementHandle[] | SelectOption[] | null): { elements?: channels.ElementHandleChannel[], options?: SelectOption[] } {if (values === null)return {};if (!Array.isArray(values))@@ -251,7 +251,7 @@ export function convertSelectOptionValues(values: string | ElementHandle | Selecreturn { options: values as SelectOption[] };}-type SetInputFilesFiles = ElementHandleSetInputFilesParams['files'];+type SetInputFilesFiles = channels.ElementHandleSetInputFilesParams['files'];export async function convertInputFiles(files: string | FilePayload | string[] | FilePayload[]): Promise<SetInputFilesFiles> {const items: (string | FilePayload)[] = Array.isArray(files) ? files : [ files ];const filePayloads: SetInputFilesFiles = await Promise.all(items.map(async item => {diff --git a/src/client/fileChooser.ts b/src/client/fileChooser.tsindex 1d3bc5d414..923c39e02d 100644--- a/src/client/fileChooser.ts+++ b/src/client/fileChooser.ts@@ -17,7 +17,7 @@import { ElementHandle } from './elementHandle';import { Page } from './page';import { FilePayload } from './types';-import { ElementHandleSetInputFilesOptions } from '../protocol/channels';+import * as channels from '../protocol/channels';export class FileChooser {private _page: Page;@@ -42,7 +42,7 @@ export class FileChooser {return this._page;}- async setFiles(files: string | FilePayload | string[] | FilePayload[], options?: ElementHandleSetInputFilesOptions) {+ async setFiles(files: string | FilePayload | string[] | FilePayload[], options?: channels.ElementHandleSetInputFilesOptions) {return this._elementHandle.setInputFiles(files, options);}}diff --git a/src/client/frame.ts b/src/client/frame.tsindex f46753027b..e8e43f70ad 100644--- a/src/client/frame.ts+++ b/src/client/frame.ts@@ -16,7 +16,7 @@*/import { assert } from '../utils/utils';-import { FrameChannel, FrameInitializer, FrameNavigatedEvent, FrameGotoOptions, FrameWaitForSelectorOptions, FrameDispatchEventOptions, FrameSetContentOptions, FrameClickOptions, FrameDblclickOptions, FrameFillOptions, FrameFocusOptions, FrameTextContentOptions, FrameInnerTextOptions, FrameInnerHTMLOptions, FrameGetAttributeOptions, FrameHoverOptions, FrameSetInputFilesOptions, FrameTypeOptions, FramePressOptions, FrameCheckOptions, FrameUncheckOptions } from '../protocol/channels';+import * as channels from '../protocol/channels';import { BrowserContext } from './browserContext';import { ChannelOwner } from './channelOwner';import { ElementHandle, convertSelectOptionValues, convertInputFiles } from './elementHandle';@@ -40,7 +40,7 @@ export type WaitForNavigationOptions = {url?: URLMatch,};-export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {+export class Frame extends ChannelOwner<channels.FrameChannel, channels.FrameInitializer> {_eventEmitter: EventEmitter;_loadStates: Set<LifecycleEvent>;_parentFrame: Frame | null = null;@@ -50,15 +50,15 @@ export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {_childFrames = new Set<Frame>();_page: Page | undefined;- static from(frame: FrameChannel): Frame {+ static from(frame: channels.FrameChannel): Frame {return (frame as any)._object;}- static fromNullable(frame: FrameChannel | undefined): Frame | null {+ static fromNullable(frame: channels.FrameChannel | undefined): Frame | null {return frame ? Frame.from(frame) : null;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: FrameInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.FrameInitializer) {super(parent, type, guid, initializer);this._eventEmitter = new EventEmitter();this._eventEmitter.setMaxListeners(0);@@ -93,7 +93,7 @@ export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {return this._page!;}- async goto(url: string, options: FrameGotoOptions = {}): Promise<network.Response | null> {+ async goto(url: string, options: channels.FrameGotoOptions = {}): Promise<network.Response | null> {return this._wrapApiCall(this._apiName('goto'), async () => {const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);return network.Response.fromNullable((await this._channel.goto({ url, ...options, waitUntil })).response);@@ -119,7 +119,7 @@ export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {const toUrl = typeof options.url === 'string' ? ` to "${options.url}"` : '';waiter.log(`waiting for navigation${toUrl} until "${waitUntil}"`);- const navigatedEvent = await waiter.waitForEvent<FrameNavigatedEvent>(this._eventEmitter, 'navigated', event => {+ const navigatedEvent = await waiter.waitForEvent<channels.FrameNavigatedEvent>(this._eventEmitter, 'navigated', event => {// Any failed navigation results in a rejection.if (event.error)return true;@@ -193,7 +193,7 @@ export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {});}- async waitForSelector(selector: string, options: FrameWaitForSelectorOptions = {}): Promise<ElementHandle<Element> | null> {+ async waitForSelector(selector: string, options: channels.FrameWaitForSelectorOptions = {}): Promise<ElementHandle<Element> | null> {return this._wrapApiCall(this._apiName('waitForSelector'), async () => {if ((options as any).visibility)throw new Error('options.visibility is not supported, did you mean options.state?');@@ -204,7 +204,7 @@ export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {});}- async dispatchEvent(selector: string, type: string, eventInit?: any, options: FrameDispatchEventOptions = {}): Promise<void> {+ async dispatchEvent(selector: string, type: string, eventInit?: any, options: channels.FrameDispatchEventOptions = {}): Promise<void> {return this._wrapApiCall(this._apiName('dispatchEvent'), async () => {await this._channel.dispatchEvent({ selector, type, eventInit: serializeArgument(eventInit), ...options });});@@ -243,7 +243,7 @@ export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {});}- async setContent(html: string, options: FrameSetContentOptions = {}): Promise<void> {+ async setContent(html: string, options: channels.FrameSetContentOptions = {}): Promise<void> {return this._wrapApiCall(this._apiName('setContent'), async () => {const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);await this._channel.setContent({ html, ...options, waitUntil });@@ -292,57 +292,57 @@ export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {});}- async click(selector: string, options: FrameClickOptions = {}) {+ async click(selector: string, options: channels.FrameClickOptions = {}) {return this._wrapApiCall(this._apiName('click'), async () => {return await this._channel.click({ selector, ...options });});}- async dblclick(selector: string, options: FrameDblclickOptions = {}) {+ async dblclick(selector: string, options: channels.FrameDblclickOptions = {}) {return this._wrapApiCall(this._apiName('dblclick'), async () => {return await this._channel.dblclick({ selector, ...options });});}- async fill(selector: string, value: string, options: FrameFillOptions = {}) {+ async fill(selector: string, value: string, options: channels.FrameFillOptions = {}) {return this._wrapApiCall(this._apiName('fill'), async () => {return await this._channel.fill({ selector, value, ...options });});}- async focus(selector: string, options: FrameFocusOptions = {}) {+ async focus(selector: string, options: channels.FrameFocusOptions = {}) {return this._wrapApiCall(this._apiName('focus'), async () => {await this._channel.focus({ selector, ...options });});}- async textContent(selector: string, options: FrameTextContentOptions = {}): Promise<null|string> {+ async textContent(selector: string, options: channels.FrameTextContentOptions = {}): Promise<null|string> {return this._wrapApiCall(this._apiName('textContent'), async () => {const value = (await this._channel.textContent({ selector, ...options })).value;return value === undefined ? null : value;});}- async innerText(selector: string, options: FrameInnerTextOptions = {}): Promise<string> {+ async innerText(selector: string, options: channels.FrameInnerTextOptions = {}): Promise<string> {return this._wrapApiCall(this._apiName('innerText'), async () => {return (await this._channel.innerText({ selector, ...options })).value;});}- async innerHTML(selector: string, options: FrameInnerHTMLOptions = {}): Promise<string> {+ async innerHTML(selector: string, options: channels.FrameInnerHTMLOptions = {}): Promise<string> {return this._wrapApiCall(this._apiName('innerHTML'), async () => {return (await this._channel.innerHTML({ selector, ...options })).value;});}- async getAttribute(selector: string, name: string, options: FrameGetAttributeOptions = {}): Promise<string | null> {+ async getAttribute(selector: string, name: string, options: channels.FrameGetAttributeOptions = {}): Promise<string | null> {return this._wrapApiCall(this._apiName('getAttribute'), async () => {const value = (await this._channel.getAttribute({ selector, name, ...options })).value;return value === undefined ? null : value;});}- async hover(selector: string, options: FrameHoverOptions = {}) {+ async hover(selector: string, options: channels.FrameHoverOptions = {}) {return this._wrapApiCall(this._apiName('hover'), async () => {await this._channel.hover({ selector, ...options });});@@ -354,31 +354,31 @@ export class Frame extends ChannelOwner<FrameChannel, FrameInitializer> {});}- async setInputFiles(selector: string, files: string | FilePayload | string[] | FilePayload[], options: FrameSetInputFilesOptions = {}): Promise<void> {+ async setInputFiles(selector: string, files: string | FilePayload | string[] | FilePayload[], options: channels.FrameSetInputFilesOptions = {}): Promise<void> {return this._wrapApiCall(this._apiName('setInputFiles'), async () => {await this._channel.setInputFiles({ selector, files: await convertInputFiles(files), ...options });});}- async type(selector: string, text: string, options: FrameTypeOptions = {}) {+ async type(selector: string, text: string, options: channels.FrameTypeOptions = {}) {return this._wrapApiCall(this._apiName('type'), async () => {await this._channel.type({ selector, text, ...options });});}- async press(selector: string, key: string, options: FramePressOptions = {}) {+ async press(selector: string, key: string, options: channels.FramePressOptions = {}) {return this._wrapApiCall(this._apiName('press'), async () => {await this._channel.press({ selector, key, ...options });});}- async check(selector: string, options: FrameCheckOptions = {}) {+ async check(selector: string, options: channels.FrameCheckOptions = {}) {return this._wrapApiCall(this._apiName('check'), async () => {await this._channel.check({ selector, ...options });});}- async uncheck(selector: string, options: FrameUncheckOptions = {}) {+ async uncheck(selector: string, options: channels.FrameUncheckOptions = {}) {return this._wrapApiCall(this._apiName('uncheck'), async () => {await this._channel.uncheck({ selector, ...options });});diff --git a/src/client/input.ts b/src/client/input.tsindex 957a8e1510..668b08a5b4 100644--- a/src/client/input.ts+++ b/src/client/input.ts@@ -15,12 +15,12 @@* limitations under the License.*/-import { PageChannel, PageKeyboardTypeOptions, PageKeyboardPressOptions, PageMouseDownOptions, PageMouseUpOptions, PageMouseClickOptions } from '../protocol/channels';+import * as channels from '../protocol/channels';export class Keyboard {- private _channel: PageChannel;+ private _channel: channels.PageChannel;- constructor(channel: PageChannel) {+ constructor(channel: channels.PageChannel) {this._channel = channel;}@@ -36,19 +36,19 @@ export class Keyboard {await this._channel.keyboardInsertText({ text });}- async type(text: string, options: PageKeyboardTypeOptions = {}) {+ async type(text: string, options: channels.PageKeyboardTypeOptions = {}) {await this._channel.keyboardType({ text, ...options });}- async press(key: string, options: PageKeyboardPressOptions = {}) {+ async press(key: string, options: channels.PageKeyboardPressOptions = {}) {await this._channel.keyboardPress({ key, ...options });}}export class Mouse {- private _channel: PageChannel;+ private _channel: channels.PageChannel;- constructor(channel: PageChannel) {+ constructor(channel: channels.PageChannel) {this._channel = channel;}@@ -56,19 +56,19 @@ export class Mouse {await this._channel.mouseMove({ x, y, ...options });}- async down(options: PageMouseDownOptions = {}) {+ async down(options: channels.PageMouseDownOptions = {}) {await this._channel.mouseDown({ ...options });}- async up(options: PageMouseUpOptions = {}) {+ async up(options: channels.PageMouseUpOptions = {}) {await this._channel.mouseUp(options);}- async click(x: number, y: number, options: PageMouseClickOptions = {}) {+ async click(x: number, y: number, options: channels.PageMouseClickOptions = {}) {await this._channel.mouseClick({ x, y, ...options });}- async dblclick(x: number, y: number, options: Omit<PageMouseClickOptions, 'clickCount'> = {}) {+ async dblclick(x: number, y: number, options: Omit<channels.PageMouseClickOptions, 'clickCount'> = {}) {await this.click(x, y, { ...options, clickCount: 2 });}}diff --git a/src/client/jsHandle.ts b/src/client/jsHandle.tsindex d4696d7ee9..55ff3e7c36 100644--- a/src/client/jsHandle.ts+++ b/src/client/jsHandle.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { JSHandleChannel, JSHandleInitializer, SerializedArgument, SerializedValue, Channel } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ElementHandle } from './elementHandle';import { ChannelOwner } from './channelOwner';import { parseSerializedValue, serializeValue } from '../protocol/serializers';@@ -35,14 +35,14 @@ export type Func1<Arg, R> = string | ((arg: Unboxed<Arg>) => R | Promise<R>);export type FuncOn<On, Arg2, R> = string | ((on: On, arg2: Unboxed<Arg2>) => R | Promise<R>);export type SmartHandle<T> = T extends Node ? ElementHandle<T> : JSHandle<T>;-export class JSHandle<T = any> extends ChannelOwner<JSHandleChannel, JSHandleInitializer> {+export class JSHandle<T = any> extends ChannelOwner<channels.JSHandleChannel, channels.JSHandleInitializer> {private _preview: string;- static from(handle: JSHandleChannel): JSHandle {+ static from(handle: channels.JSHandleChannel): JSHandle {return (handle as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: JSHandleInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.JSHandleInitializer) {super(parent, type, guid, initializer);this._preview = this._initializer.preview;this._channel.on('previewUpdated', ({preview}) => this._preview = preview);@@ -93,9 +93,9 @@ export class JSHandle<T = any> extends ChannelOwner<JSHandleChannel, JSHandleIni// This function takes care of converting all JSHandles to their channels,// so that generic channel serializer converts them to guids.-export function serializeArgument(arg: any): SerializedArgument {- const handles: Channel[] = [];- const pushHandle = (channel: Channel): number => {+export function serializeArgument(arg: any): channels.SerializedArgument {+ const handles: channels.Channel[] = [];+ const pushHandle = (channel: channels.Channel): number => {handles.push(channel);return handles.length - 1;};@@ -107,7 +107,7 @@ export function serializeArgument(arg: any): SerializedArgument {return { value, handles };}-export function parseResult(value: SerializedValue): any {+export function parseResult(value: channels.SerializedValue): any {return parseSerializedValue(value, undefined);}diff --git a/src/client/network.ts b/src/client/network.tsindex 72618e3b61..67593a9fa0 100644--- a/src/client/network.ts+++ b/src/client/network.ts@@ -15,7 +15,7 @@*/import { URLSearchParams } from 'url';-import { RequestChannel, ResponseChannel, RouteChannel, RequestInitializer, ResponseInitializer, RouteInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';import { Frame } from './frame';import { Headers } from './types';@@ -47,22 +47,22 @@ export type SetNetworkCookieParam = {sameSite?: 'Strict' | 'Lax' | 'None'};-export class Request extends ChannelOwner<RequestChannel, RequestInitializer> {+export class Request extends ChannelOwner<channels.RequestChannel, channels.RequestInitializer> {private _redirectedFrom: Request | null = null;private _redirectedTo: Request | null = null;_failureText: string | null = null;private _headers: Headers;private _postData: Buffer | null;- static from(request: RequestChannel): Request {+ static from(request: channels.RequestChannel): Request {return (request as any)._object;}- static fromNullable(request: RequestChannel | undefined): Request | null {+ static fromNullable(request: channels.RequestChannel | undefined): Request | null {return request ? Request.from(request) : null;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: RequestInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.RequestInitializer) {super(parent, type, guid, initializer);this._redirectedFrom = Request.fromNullable(initializer.redirectedFrom);if (this._redirectedFrom)@@ -148,12 +148,12 @@ export class Request extends ChannelOwner<RequestChannel, RequestInitializer> {}}-export class Route extends ChannelOwner<RouteChannel, RouteInitializer> {- static from(route: RouteChannel): Route {+export class Route extends ChannelOwner<channels.RouteChannel, channels.RouteInitializer> {+ static from(route: channels.RouteChannel): Route {return (route as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: RouteInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.RouteInitializer) {super(parent, type, guid, initializer);}@@ -214,18 +214,18 @@ export class Route extends ChannelOwner<RouteChannel, RouteInitializer> {export type RouteHandler = (route: Route, request: Request) => void;-export class Response extends ChannelOwner<ResponseChannel, ResponseInitializer> {+export class Response extends ChannelOwner<channels.ResponseChannel, channels.ResponseInitializer> {private _headers: Headers;- static from(response: ResponseChannel): Response {+ static from(response: channels.ResponseChannel): Response {return (response as any)._object;}- static fromNullable(response: ResponseChannel | undefined): Response | null {+ static fromNullable(response: channels.ResponseChannel | undefined): Response | null {return response ? Response.from(response) : null;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: ResponseInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.ResponseInitializer) {super(parent, type, guid, initializer);this._headers = headersArrayToObject(initializer.headers, true /* lowerCase */);}diff --git a/src/client/page.ts b/src/client/page.tsindex bcd49e45cc..fd0bed3493 100644--- a/src/client/page.ts+++ b/src/client/page.ts@@ -18,7 +18,7 @@import { Events } from './events';import { assert } from '../utils/utils';import { TimeoutSettings } from '../utils/timeoutSettings';-import { BindingCallChannel, BindingCallInitializer, PageChannel, PageInitializer, PagePdfParams, FrameWaitForSelectorOptions, FrameDispatchEventOptions, FrameSetContentOptions, FrameGotoOptions, PageReloadOptions, PageGoBackOptions, PageGoForwardOptions, PageScreenshotOptions, FrameClickOptions, FrameDblclickOptions, FrameFillOptions, FrameFocusOptions, FrameTextContentOptions, FrameInnerTextOptions, FrameInnerHTMLOptions, FrameGetAttributeOptions, FrameHoverOptions, FrameSetInputFilesOptions, FrameTypeOptions, FramePressOptions, FrameCheckOptions, FrameUncheckOptions } from '../protocol/channels';+import * as channels from '../protocol/channels';import { parseError, serializeError } from '../protocol/serializers';import { Accessibility } from './accessibility';import { BrowserContext } from './browserContext';@@ -43,7 +43,7 @@ import { Size, URLMatch, Headers, LifecycleEvent, WaitForEventOptions, SelectOptimport { evaluationScript, urlMatches } from './clientHelper';import { isString, isRegExp, isObject, mkdirIfNeeded, headersObjectToArray } from '../utils/utils';-type PDFOptions = Omit<PagePdfParams, 'width' | 'height' | 'margin'> & {+type PDFOptions = Omit<channels.PagePdfParams, 'width' | 'height' | 'margin'> & {width?: string | number,height?: string | number,margin?: {@@ -58,7 +58,7 @@ type Listener = (...args: any[]) => void;const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));-export class Page extends ChannelOwner<PageChannel, PageInitializer> {+export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitializer> {private _browserContext: BrowserContext;_ownedContext: BrowserContext | undefined;@@ -79,15 +79,15 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {readonly _timeoutSettings: TimeoutSettings;_isPageCall = false;- static from(page: PageChannel): Page {+ static from(page: channels.PageChannel): Page {return (page as any)._object;}- static fromNullable(page: PageChannel | undefined): Page | null {+ static fromNullable(page: channels.PageChannel | undefined): Page | null {return page ? Page.from(page) : null;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: PageInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.PageInitializer) {super(parent, type, guid, initializer);this.setMaxListeners(0);this._browserContext = parent as BrowserContext;@@ -235,11 +235,11 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {return this._attributeToPage(() => this._mainFrame.$(selector));}- async waitForSelector(selector: string, options?: FrameWaitForSelectorOptions): Promise<ElementHandle<Element> | null> {+ async waitForSelector(selector: string, options?: channels.FrameWaitForSelectorOptions): Promise<ElementHandle<Element> | null> {return this._attributeToPage(() => this._mainFrame.waitForSelector(selector, options));}- async dispatchEvent(selector: string, type: string, eventInit?: any, options?: FrameDispatchEventOptions): Promise<void> {+ async dispatchEvent(selector: string, type: string, eventInit?: any, options?: channels.FrameDispatchEventOptions): Promise<void> {return this._attributeToPage(() => this._mainFrame.dispatchEvent(selector, type, eventInit, options));}@@ -306,15 +306,15 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {return this._attributeToPage(() => this._mainFrame.content());}- async setContent(html: string, options?: FrameSetContentOptions): Promise<void> {+ async setContent(html: string, options?: channels.FrameSetContentOptions): Promise<void> {return this._attributeToPage(() => this._mainFrame.setContent(html, options));}- async goto(url: string, options?: FrameGotoOptions): Promise<Response | null> {+ async goto(url: string, options?: channels.FrameGotoOptions): Promise<Response | null> {return this._attributeToPage(() => this._mainFrame.goto(url, options));}- async reload(options: PageReloadOptions = {}): Promise<Response | null> {+ async reload(options: channels.PageReloadOptions = {}): Promise<Response | null> {return this._wrapApiCall('page.reload', async () => {const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);return Response.fromNullable((await this._channel.reload({ ...options, waitUntil })).response);@@ -361,14 +361,14 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {return result;}- async goBack(options: PageGoBackOptions = {}): Promise<Response | null> {+ async goBack(options: channels.PageGoBackOptions = {}): Promise<Response | null> {return this._wrapApiCall('page.goBack', async () => {const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);return Response.fromNullable((await this._channel.goBack({ ...options, waitUntil })).response);});}- async goForward(options: PageGoForwardOptions = {}): Promise<Response | null> {+ async goForward(options: channels.PageGoForwardOptions = {}): Promise<Response | null> {return this._wrapApiCall('page.goForward', async () => {const waitUntil = verifyLoadState('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);return Response.fromNullable((await this._channel.goForward({ ...options, waitUntil })).response);@@ -425,7 +425,7 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {});}- async screenshot(options: PageScreenshotOptions & { path?: string } = {}): Promise<Buffer> {+ async screenshot(options: channels.PageScreenshotOptions & { path?: string } = {}): Promise<Buffer> {return this._wrapApiCall('page.screenshot', async () => {const type = determineScreenshotType(options);const result = await this._channel.screenshot({ ...options, type });@@ -460,39 +460,39 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {return this._closed;}- async click(selector: string, options?: FrameClickOptions) {+ async click(selector: string, options?: channels.FrameClickOptions) {return this._attributeToPage(() => this._mainFrame.click(selector, options));}- async dblclick(selector: string, options?: FrameDblclickOptions) {+ async dblclick(selector: string, options?: channels.FrameDblclickOptions) {return this._attributeToPage(() => this._mainFrame.dblclick(selector, options));}- async fill(selector: string, value: string, options?: FrameFillOptions) {+ async fill(selector: string, value: string, options?: channels.FrameFillOptions) {return this._attributeToPage(() => this._mainFrame.fill(selector, value, options));}- async focus(selector: string, options?: FrameFocusOptions) {+ async focus(selector: string, options?: channels.FrameFocusOptions) {return this._attributeToPage(() => this._mainFrame.focus(selector, options));}- async textContent(selector: string, options?: FrameTextContentOptions): Promise<null|string> {+ async textContent(selector: string, options?: channels.FrameTextContentOptions): Promise<null|string> {return this._attributeToPage(() => this._mainFrame.textContent(selector, options));}- async innerText(selector: string, options?: FrameInnerTextOptions): Promise<string> {+ async innerText(selector: string, options?: channels.FrameInnerTextOptions): Promise<string> {return this._attributeToPage(() => this._mainFrame.innerText(selector, options));}- async innerHTML(selector: string, options?: FrameInnerHTMLOptions): Promise<string> {+ async innerHTML(selector: string, options?: channels.FrameInnerHTMLOptions): Promise<string> {return this._attributeToPage(() => this._mainFrame.innerHTML(selector, options));}- async getAttribute(selector: string, name: string, options?: FrameGetAttributeOptions): Promise<string | null> {+ async getAttribute(selector: string, name: string, options?: channels.FrameGetAttributeOptions): Promise<string | null> {return this._attributeToPage(() => this._mainFrame.getAttribute(selector, name, options));}- async hover(selector: string, options?: FrameHoverOptions) {+ async hover(selector: string, options?: channels.FrameHoverOptions) {return this._attributeToPage(() => this._mainFrame.hover(selector, options));}@@ -500,23 +500,23 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {return this._attributeToPage(() => this._mainFrame.selectOption(selector, values, options));}- async setInputFiles(selector: string, files: string | FilePayload | string[] | FilePayload[], options?: FrameSetInputFilesOptions): Promise<void> {+ async setInputFiles(selector: string, files: string | FilePayload | string[] | FilePayload[], options?: channels.FrameSetInputFilesOptions): Promise<void> {return this._attributeToPage(() => this._mainFrame.setInputFiles(selector, files, options));}- async type(selector: string, text: string, options?: FrameTypeOptions) {+ async type(selector: string, text: string, options?: channels.FrameTypeOptions) {return this._attributeToPage(() => this._mainFrame.type(selector, text, options));}- async press(selector: string, key: string, options?: FramePressOptions) {+ async press(selector: string, key: string, options?: channels.FramePressOptions) {return this._attributeToPage(() => this._mainFrame.press(selector, key, options));}- async check(selector: string, options?: FrameCheckOptions) {+ async check(selector: string, options?: channels.FrameCheckOptions) {return this._attributeToPage(() => this._mainFrame.check(selector, options));}- async uncheck(selector: string, options?: FrameUncheckOptions) {+ async uncheck(selector: string, options?: channels.FrameUncheckOptions) {return this._attributeToPage(() => this._mainFrame.uncheck(selector, options));}@@ -567,7 +567,7 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {}async _pdf(options: PDFOptions = {}): Promise<Buffer> {- const transportOptions: PagePdfParams = { ...options } as PagePdfParams;+ const transportOptions: channels.PagePdfParams = { ...options } as channels.PagePdfParams;if (transportOptions.margin)transportOptions.margin = { ...transportOptions.margin };if (typeof options.width === 'number')@@ -587,12 +587,12 @@ export class Page extends ChannelOwner<PageChannel, PageInitializer> {}}-export class BindingCall extends ChannelOwner<BindingCallChannel, BindingCallInitializer> {- static from(channel: BindingCallChannel): BindingCall {+export class BindingCall extends ChannelOwner<channels.BindingCallChannel, channels.BindingCallInitializer> {+ static from(channel: channels.BindingCallChannel): BindingCall {return (channel as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: BindingCallInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.BindingCallInitializer) {super(parent, type, guid, initializer);}diff --git a/src/client/playwright.ts b/src/client/playwright.tsindex d93e9bb7c2..159256ed80 100644--- a/src/client/playwright.ts+++ b/src/client/playwright.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import { PlaywrightChannel, PlaywrightInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { BrowserType } from './browserType';import { ChannelOwner } from './channelOwner';import { Selectors } from './selectors';@@ -31,7 +31,7 @@ type DeviceDescriptor = {};type Devices = { [name: string]: DeviceDescriptor };-export class Playwright extends ChannelOwner<PlaywrightChannel, PlaywrightInitializer> {+export class Playwright extends ChannelOwner<channels.PlaywrightChannel, channels.PlaywrightInitializer> {readonly chromium: BrowserType;readonly firefox: BrowserType;readonly webkit: BrowserType;@@ -39,7 +39,7 @@ export class Playwright extends ChannelOwner<PlaywrightChannel, PlaywrightInitiareadonly selectors: Selectors;readonly errors: { TimeoutError: typeof TimeoutError };- constructor(parent: ChannelOwner, type: string, guid: string, initializer: PlaywrightInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.PlaywrightInitializer) {super(parent, type, guid, initializer);this.chromium = BrowserType.from(initializer.chromium);this.firefox = BrowserType.from(initializer.firefox);diff --git a/src/client/selectors.ts b/src/client/selectors.tsindex c8aafcd9e0..8d2f652772 100644--- a/src/client/selectors.ts+++ b/src/client/selectors.ts@@ -14,17 +14,17 @@* limitations under the License.*/-import { SelectorsChannel, SelectorsInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';import { ElementHandle } from './elementHandle';import { evaluationScript } from './clientHelper';-export class Selectors extends ChannelOwner<SelectorsChannel, SelectorsInitializer> {- static from(selectors: SelectorsChannel): Selectors {+export class Selectors extends ChannelOwner<channels.SelectorsChannel, channels.SelectorsInitializer> {+ static from(selectors: channels.SelectorsChannel): Selectors {return (selectors as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: SelectorsInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.SelectorsInitializer) {super(parent, type, guid, initializer);}diff --git a/src/client/stream.ts b/src/client/stream.tsindex dcc671ce32..5e030fb2a3 100644--- a/src/client/stream.ts+++ b/src/client/stream.ts@@ -15,15 +15,15 @@*/import { Readable } from 'stream';-import { StreamChannel, StreamInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';-export class Stream extends ChannelOwner<StreamChannel, StreamInitializer> {- static from(Stream: StreamChannel): Stream {+export class Stream extends ChannelOwner<channels.StreamChannel, channels.StreamInitializer> {+ static from(Stream: channels.StreamChannel): Stream {return (Stream as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: StreamInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.StreamInitializer) {super(parent, type, guid, initializer);}@@ -33,9 +33,9 @@ export class Stream extends ChannelOwner<StreamChannel, StreamInitializer> {}class StreamImpl extends Readable {- private _channel: StreamChannel;+ private _channel: channels.StreamChannel;- constructor(channel: StreamChannel) {+ constructor(channel: channels.StreamChannel) {super();this._channel = channel;}diff --git a/src/client/types.ts b/src/client/types.tsindex 24b625697d..9891da5ef5 100644--- a/src/client/types.ts+++ b/src/client/types.ts@@ -15,15 +15,13 @@* limitations under the License.*/-import { BrowserNewContextOptions, BrowserTypeLaunchOptions } from '../protocol/channels';+import * as channels from '../protocol/channels';type LoggerSeverity = 'verbose' | 'info' | 'warning' | 'error';-export interface LoggerSink {+export interface Logger {isEnabled(name: string, severity: LoggerSeverity): boolean;log(name: string, severity: LoggerSeverity, message: string | Error, args: any[], hints: { color?: string }): void;}-// This is a workaround for the documentation generation.-export interface Logger extends LoggerSink {}export type Size = { width: number, height: number };export type Point = { x: number, y: number };@@ -42,21 +40,21 @@ export type FilePayload = { name: string, mimeType: string, buffer: Buffer };export type LifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle';export const kLifecycleEvents: Set<LifecycleEvent> = new Set(['load', 'domcontentloaded', 'networkidle']);-export type BrowserContextOptions = Omit<BrowserNewContextOptions, 'viewport' | 'noDefaultViewport' | 'extraHTTPHeaders'> & {+export type BrowserContextOptions = Omit<channels.BrowserNewContextOptions, 'viewport' | 'noDefaultViewport' | 'extraHTTPHeaders'> & {viewport?: Size | null,extraHTTPHeaders?: Headers,- logger?: LoggerSink,+ logger?: Logger,};type LaunchOverrides = {ignoreDefaultArgs?: boolean | string[],env?: Env,- logger?: LoggerSink,+ logger?: Logger,};type FirefoxUserPrefs = {firefoxUserPrefs?: { [key: string]: string | number | boolean },};-type LaunchOptionsBase = Omit<BrowserTypeLaunchOptions, 'ignoreAllDefaultArgs' | 'ignoreDefaultArgs' | 'env' | 'firefoxUserPrefs'> & LaunchOverrides;+type LaunchOptionsBase = Omit<channels.BrowserTypeLaunchOptions, 'ignoreAllDefaultArgs' | 'ignoreDefaultArgs' | 'env' | 'firefoxUserPrefs'> & LaunchOverrides;export type LaunchOptions = LaunchOptionsBase & FirefoxUserPrefs;export type LaunchPersistentContextOptions = LaunchOptionsBase & BrowserContextOptions;@@ -64,7 +62,7 @@ export type ConnectOptions = {wsEndpoint: string,slowMo?: number,timeout?: number,- logger?: LoggerSink,+ logger?: Logger,};export type LaunchServerOptions = {executablePath?: string,@@ -86,5 +84,5 @@ export type LaunchServerOptions = {downloadsPath?: string,chromiumSandbox?: boolean,port?: number,- logger?: LoggerSink,+ logger?: Logger,} & FirefoxUserPrefs;diff --git a/src/client/worker.ts b/src/client/worker.tsindex a6e3c9260e..cbd14378b6 100644--- a/src/client/worker.ts+++ b/src/client/worker.ts@@ -15,22 +15,22 @@*/import { Events } from './events';-import { WorkerChannel, WorkerInitializer } from '../protocol/channels';+import * as channels from '../protocol/channels';import { ChannelOwner } from './channelOwner';import { assertMaxArguments, Func1, JSHandle, parseResult, serializeArgument, SmartHandle } from './jsHandle';import { Page } from './page';import { BrowserContext } from './browserContext';import { ChromiumBrowserContext } from './chromiumBrowserContext';-export class Worker extends ChannelOwner<WorkerChannel, WorkerInitializer> {+export class Worker extends ChannelOwner<channels.WorkerChannel, channels.WorkerInitializer> {_page: Page | undefined; // Set for web workers._context: BrowserContext | undefined; // Set for service workers.- static from(worker: WorkerChannel): Worker {+ static from(worker: channels.WorkerChannel): Worker {return (worker as any)._object;}- constructor(parent: ChannelOwner, type: string, guid: string, initializer: WorkerInitializer) {+ constructor(parent: ChannelOwner, type: string, guid: string, initializer: channels.WorkerInitializer) {super(parent, type, guid, initializer);this._channel.on('close', () => {if (this._page)