From f4e584ea0820d2aa9a2de916b58fc1d073a7554e Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Sun, 26 Jul 2020 21:27:09 -0700 Subject: [PATCH] feat(rpc): align class names with api docs (#3164) --- .../{coverage.ts => chromiumCoverage.ts} | 2 +- src/rpc/client/connection.ts | 6 ++++++ src/rpc/client/firefoxBrowser.ts | 20 +++++++++++++++++++ src/rpc/client/page.ts | 6 +++--- src/rpc/client/webkitBrowser.ts | 20 +++++++++++++++++++ 5 files changed, 50 insertions(+), 4 deletions(-) rename src/rpc/client/{coverage.ts => chromiumCoverage.ts} (97%) create mode 100644 src/rpc/client/firefoxBrowser.ts create mode 100644 src/rpc/client/webkitBrowser.ts diff --git a/src/rpc/client/coverage.ts b/src/rpc/client/chromiumCoverage.ts similarity index 97% rename from src/rpc/client/coverage.ts rename to src/rpc/client/chromiumCoverage.ts index 58497a8237..9bcdde38eb 100644 --- a/src/rpc/client/coverage.ts +++ b/src/rpc/client/chromiumCoverage.ts @@ -17,7 +17,7 @@ import * as types from '../../types'; import { PageChannel } from '../channels'; -export class Coverage { +export class ChromiumCoverage { private _channel: PageChannel; constructor(channel: PageChannel) { diff --git a/src/rpc/client/connection.ts b/src/rpc/client/connection.ts index 74767a362f..9f95bca692 100644 --- a/src/rpc/client/connection.ts +++ b/src/rpc/client/connection.ts @@ -39,6 +39,8 @@ import { ChromiumBrowserContext } from './chromiumBrowserContext'; import { Selectors } from './selectors'; import { Stream } from './stream'; import { createScheme, Validator, ValidationError } from '../validator'; +import { WebKitBrowser } from './webkitBrowser'; +import { FirefoxBrowser } from './firefoxBrowser'; class Root extends ChannelOwner { constructor(connection: Connection) { @@ -126,6 +128,10 @@ export class Connection { case 'Browser': if ((parent as BrowserType).name() === 'chromium') result = new ChromiumBrowser(parent, type, guid, initializer); + else if ((parent as BrowserType).name() === 'webkit') + result = new WebKitBrowser(parent, type, guid, initializer); + else if ((parent as BrowserType).name() === 'firefox') + result = new FirefoxBrowser(parent, type, guid, initializer); else result = new Browser(parent, type, guid, initializer); break; diff --git a/src/rpc/client/firefoxBrowser.ts b/src/rpc/client/firefoxBrowser.ts new file mode 100644 index 0000000000..a55e0f059b --- /dev/null +++ b/src/rpc/client/firefoxBrowser.ts @@ -0,0 +1,20 @@ +/** + * 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 { Browser } from './browser'; + +export class FirefoxBrowser extends Browser { +} diff --git a/src/rpc/client/page.ts b/src/rpc/client/page.ts index 2c7b06e557..4433f690ab 100644 --- a/src/rpc/client/page.ts +++ b/src/rpc/client/page.ts @@ -35,7 +35,7 @@ import { Func1, FuncOn, SmartHandle, serializeArgument, parseResult } from './js import { Request, Response, Route, RouteHandler } from './network'; import { FileChooser } from './fileChooser'; import { Buffer } from 'buffer'; -import { Coverage } from './coverage'; +import { ChromiumCoverage } from './chromiumCoverage'; import { Waiter } from './waiter'; import * as fs from 'fs'; @@ -57,7 +57,7 @@ export class Page extends ChannelOwner { readonly accessibility: Accessibility; readonly keyboard: Keyboard; readonly mouse: Mouse; - coverage: Coverage | null = null; + coverage: ChromiumCoverage | null = null; pdf?: (options?: types.PDFOptions) => Promise; readonly _bindings = new Map(); @@ -109,7 +109,7 @@ export class Page extends ChannelOwner { this._channel.on('worker', ({ worker }) => this._onWorker(Worker.from(worker))); if (this._browserContext._browserName === 'chromium') { - this.coverage = new Coverage(this._channel); + this.coverage = new ChromiumCoverage(this._channel); this.pdf = options => this._pdf(options); } } diff --git a/src/rpc/client/webkitBrowser.ts b/src/rpc/client/webkitBrowser.ts new file mode 100644 index 0000000000..15a25a07af --- /dev/null +++ b/src/rpc/client/webkitBrowser.ts @@ -0,0 +1,20 @@ +/** + * 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 { Browser } from './browser'; + +export class WebKitBrowser extends Browser { +}