Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: move src/rpc/client to src/client (#3581)

Dmitry Gozman9fca63f8ecf6
diff --git a/src/rpc/client/accessibility.ts b/src/client/accessibility.ts
similarity index 97%
rename from src/rpc/client/accessibility.ts
rename to src/client/accessibility.ts
index 4ac7616331..15e39dde24 100644
--- a/src/rpc/client/accessibility.ts
+++ b/src/client/accessibility.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { PageChannel, AXNode } from '../../protocol/channels';
+import { PageChannel, AXNode } from '../protocol/channels';
import { ElementHandle } from './elementHandle';
type SerializedAXNode = Omit<AXNode, 'valueString' | 'valueNumber' | 'children' | 'checked' | 'pressed'> & {
diff --git a/src/rpc/client/api.ts b/src/client/api.ts
similarity index 97%
rename from src/rpc/client/api.ts
rename to src/client/api.ts
index 6959f02e5e..a3e64ab400 100644
--- a/src/rpc/client/api.ts
+++ b/src/client/api.ts
@@ -25,7 +25,7 @@ export { Download } from './download';
export { ElementHandle } from './elementHandle';
export { FileChooser } from './fileChooser';
export { Logger } from './types';
-export { TimeoutError } from '../../utils/errors';
+export { TimeoutError } from '../utils/errors';
export { Frame } from './frame';
export { Keyboard, Mouse } from './input';
export { JSHandle } from './jsHandle';
diff --git a/src/rpc/client/browser.ts b/src/client/browser.ts
similarity index 97%
rename from src/rpc/client/browser.ts
rename to src/client/browser.ts
index 72175d9776..221ff93bb4 100644
--- a/src/rpc/client/browser.ts
+++ b/src/client/browser.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { BrowserChannel, BrowserInitializer, BrowserNewContextParams } from '../../protocol/channels';
+import { BrowserChannel, BrowserInitializer, BrowserNewContextParams } from '../protocol/channels';
import { BrowserContext } from './browserContext';
import { Page } from './page';
import { ChannelOwner } from './channelOwner';
@@ -22,7 +22,7 @@ import { Events } from './events';
import { BrowserType } from './browserType';
import { BrowserContextOptions } from './types';
import { validateHeaders } from './network';
-import { headersObjectToArray } from '../../utils/utils';
+import { headersObjectToArray } from '../utils/utils';
export class Browser extends ChannelOwner<BrowserChannel, BrowserInitializer> {
readonly _contexts = new Set<BrowserContext>();
diff --git a/src/rpc/client/browserContext.ts b/src/client/browserContext.ts
similarity index 98%
rename from src/rpc/client/browserContext.ts
rename to src/client/browserContext.ts
index 8dd4028e7e..a4101e8ebe 100644
--- a/src/rpc/client/browserContext.ts
+++ b/src/client/browserContext.ts
@@ -18,15 +18,15 @@
import * as frames from './frame';
import { Page, BindingCall } from './page';
import * as network from './network';
-import { BrowserContextChannel, BrowserContextInitializer } from '../../protocol/channels';
+import { BrowserContextChannel, BrowserContextInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
import { deprecate, evaluationScript, urlMatches } from './clientHelper';
import { Browser } from './browser';
import { Events } from './events';
-import { TimeoutSettings } from '../../utils/timeoutSettings';
+import { TimeoutSettings } from '../utils/timeoutSettings';
import { Waiter } from './waiter';
import { URLMatch, Headers, WaitForEventOptions } from './types';
-import { isUnderTest, headersObjectToArray } from '../../utils/utils';
+import { isUnderTest, headersObjectToArray } from '../utils/utils';
export class BrowserContext extends ChannelOwner<BrowserContextChannel, BrowserContextInitializer> {
_pages = new Set<Page>();
diff --git a/src/rpc/client/browserType.ts b/src/client/browserType.ts
similarity index 97%
rename from src/rpc/client/browserType.ts
rename to src/client/browserType.ts
index 69e51956ef..97395d527e 100644
--- a/src/rpc/client/browserType.ts
+++ b/src/client/browserType.ts
@@ -14,20 +14,20 @@
* limitations under the License.
*/
-import { BrowserTypeChannel, BrowserTypeInitializer, BrowserTypeLaunchParams, BrowserTypeLaunchPersistentContextParams } from '../../protocol/channels';
+import { BrowserTypeChannel, BrowserTypeInitializer, BrowserTypeLaunchParams, BrowserTypeLaunchPersistentContextParams } from '../protocol/channels';
import { Browser } from './browser';
import { BrowserContext } from './browserContext';
import { ChannelOwner } from './channelOwner';
import { LaunchOptions, LaunchServerOptions, ConnectOptions, LaunchPersistentContextOptions } from './types';
import * as WebSocket from 'ws';
import { Connection } from './connection';
-import { serializeError } from '../../protocol/serializers';
+import { serializeError } from '../protocol/serializers';
import { Events } from './events';
-import { TimeoutSettings } from '../../utils/timeoutSettings';
+import { TimeoutSettings } from '../utils/timeoutSettings';
import { ChildProcess } from 'child_process';
import { envObjectToArray } from './clientHelper';
import { validateHeaders } from './network';
-import { assert, makeWaitForNextTask, headersObjectToArray } from '../../utils/utils';
+import { assert, makeWaitForNextTask, headersObjectToArray } from '../utils/utils';
export interface BrowserServerLauncher {
launchServer(options?: LaunchServerOptions): Promise<BrowserServer>;
diff --git a/src/rpc/client/cdpSession.ts b/src/client/cdpSession.ts
similarity index 95%
rename from src/rpc/client/cdpSession.ts
rename to src/client/cdpSession.ts
index b71824c3e7..867c603bb5 100644
--- a/src/rpc/client/cdpSession.ts
+++ b/src/client/cdpSession.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import { CDPSessionChannel, CDPSessionInitializer } from '../../protocol/channels';
+import { CDPSessionChannel, CDPSessionInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
-import { Protocol } from '../../chromium/protocol';
+import { Protocol } from '../chromium/protocol';
export class CDPSession extends ChannelOwner<CDPSessionChannel, CDPSessionInitializer> {
static from(cdpSession: CDPSessionChannel): CDPSession {
diff --git a/src/rpc/client/channelOwner.ts b/src/client/channelOwner.ts
similarity index 97%
rename from src/rpc/client/channelOwner.ts
rename to src/client/channelOwner.ts
index 44fbceec96..5deba14825 100644
--- a/src/rpc/client/channelOwner.ts
+++ b/src/client/channelOwner.ts
@@ -15,10 +15,10 @@
*/
import { EventEmitter } from 'events';
-import type { Channel } from '../../protocol/channels';
+import type { Channel } from '../protocol/channels';
import type { Connection } from './connection';
import type { LoggerSink } from './types';
-import { debugLogger } from '../../utils/debugLogger';
+import { debugLogger } from '../utils/debugLogger';
export abstract class ChannelOwner<T extends Channel = Channel, Initializer = {}> extends EventEmitter {
private _connection: Connection;
diff --git a/src/rpc/client/chromiumBrowser.ts b/src/client/chromiumBrowser.ts
similarity index 100%
rename from src/rpc/client/chromiumBrowser.ts
rename to src/client/chromiumBrowser.ts
diff --git a/src/rpc/client/chromiumBrowserContext.ts b/src/client/chromiumBrowserContext.ts
similarity index 96%
rename from src/rpc/client/chromiumBrowserContext.ts
rename to src/client/chromiumBrowserContext.ts
index fd04232e11..5fd1d55f65 100644
--- a/src/rpc/client/chromiumBrowserContext.ts
+++ b/src/client/chromiumBrowserContext.ts
@@ -16,7 +16,7 @@
*/
import { Page } from './page';
-import { BrowserContextInitializer } from '../../protocol/channels';
+import { BrowserContextInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
import { CDPSession } from './cdpSession';
import { Events } from './events';
diff --git a/src/rpc/client/chromiumCoverage.ts b/src/client/chromiumCoverage.ts
similarity index 74%
rename from src/rpc/client/chromiumCoverage.ts
rename to src/client/chromiumCoverage.ts
index 20ad9c0cc4..ed9ed12ec6 100644
--- a/src/rpc/client/chromiumCoverage.ts
+++ b/src/client/chromiumCoverage.ts
@@ -14,12 +14,7 @@
* limitations under the License.
*/
-import { PageChannel, PageCrStartJSCoverageOptions, PageCrStopJSCoverageResult, PageCrStartCSSCoverageOptions, PageCrStopCSSCoverageResult } from '../../protocol/channels';
-
-let __dummyJSResult: PageCrStopJSCoverageResult;
-type PageCrStopJSCoverageResultEntries = typeof __dummyJSResult.entries;
-let __dummyCSSResult: PageCrStopCSSCoverageResult;
-type PageCrStopCSSCoverageResultEntries = typeof __dummyCSSResult.entries;
+import { PageChannel, PageCrStartJSCoverageOptions, PageCrStopJSCoverageResult, PageCrStartCSSCoverageOptions, PageCrStopCSSCoverageResult } from '../protocol/channels';
export class ChromiumCoverage {
private _channel: PageChannel;
@@ -32,7 +27,7 @@ export class ChromiumCoverage {
await this._channel.crStartJSCoverage(options);
}
- async stopJSCoverage(): Promise<PageCrStopJSCoverageResultEntries> {
+ async stopJSCoverage(): Promise<PageCrStopJSCoverageResult['entries']> {
return (await this._channel.crStopJSCoverage()).entries;
}
@@ -40,7 +35,7 @@ export class ChromiumCoverage {
await this._channel.crStartCSSCoverage(options);
}
- async stopCSSCoverage(): Promise<PageCrStopCSSCoverageResultEntries> {
+ async stopCSSCoverage(): Promise<PageCrStopCSSCoverageResult['entries']> {
return (await this._channel.crStopCSSCoverage()).entries;
}
}
diff --git a/src/rpc/client/clientHelper.ts b/src/client/clientHelper.ts
similarity index 98%
rename from src/rpc/client/clientHelper.ts
rename to src/client/clientHelper.ts
index cf13c9201d..c0a44e5afe 100644
--- a/src/rpc/client/clientHelper.ts
+++ b/src/client/clientHelper.ts
@@ -18,7 +18,7 @@
import * as types from './types';
import * as fs from 'fs';
import * as util from 'util';
-import { isString, isRegExp } from '../../utils/utils';
+import { isString, isRegExp } from '../utils/utils';
const deprecatedHits = new Set();
export function deprecate(methodName: string, message: string) {
diff --git a/src/rpc/client/connection.ts b/src/client/connection.ts
similarity index 97%
rename from src/rpc/client/connection.ts
rename to src/client/connection.ts
index 49990bfe45..2b18b0db22 100644
--- a/src/rpc/client/connection.ts
+++ b/src/client/connection.ts
@@ -27,19 +27,19 @@ import { Worker } from './worker';
import { ConsoleMessage } from './consoleMessage';
import { Dialog } from './dialog';
import { Download } from './download';
-import { parseError } from '../../protocol/serializers';
+import { parseError } from '../protocol/serializers';
import { CDPSession } from './cdpSession';
import { Playwright } from './playwright';
import { Electron, ElectronApplication } from './electron';
-import { Channel } from '../../protocol/channels';
+import { Channel } from '../protocol/channels';
import { ChromiumBrowser } from './chromiumBrowser';
import { ChromiumBrowserContext } from './chromiumBrowserContext';
import { Selectors } from './selectors';
import { Stream } from './stream';
-import { createScheme, Validator, ValidationError } from '../../protocol/validator';
+import { createScheme, Validator, ValidationError } from '../protocol/validator';
import { WebKitBrowser } from './webkitBrowser';
import { FirefoxBrowser } from './firefoxBrowser';
-import { debugLogger } from '../../utils/debugLogger';
+import { debugLogger } from '../utils/debugLogger';
class Root extends ChannelOwner<Channel, {}> {
constructor(connection: Connection) {
diff --git a/src/rpc/client/consoleMessage.ts b/src/client/consoleMessage.ts
similarity index 98%
rename from src/rpc/client/consoleMessage.ts
rename to src/client/consoleMessage.ts
index cba8e812e8..e3cad9e591 100644
--- a/src/rpc/client/consoleMessage.ts
+++ b/src/client/consoleMessage.ts
@@ -16,7 +16,7 @@
import * as util from 'util';
import { JSHandle } from './jsHandle';
-import { ConsoleMessageChannel, ConsoleMessageInitializer } from '../../protocol/channels';
+import { ConsoleMessageChannel, ConsoleMessageInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
type ConsoleMessageLocation = ConsoleMessageInitializer['location'];
diff --git a/src/rpc/client/dialog.ts b/src/client/dialog.ts
similarity index 95%
rename from src/rpc/client/dialog.ts
rename to src/client/dialog.ts
index 99564d5abe..8fc6775ebe 100644
--- a/src/rpc/client/dialog.ts
+++ b/src/client/dialog.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { DialogChannel, DialogInitializer } from '../../protocol/channels';
+import { DialogChannel, DialogInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
export class Dialog extends ChannelOwner<DialogChannel, DialogInitializer> {
diff --git a/src/rpc/client/download.ts b/src/client/download.ts
similarity index 95%
rename from src/rpc/client/download.ts
rename to src/client/download.ts
index ab08f1f3df..0231d0522f 100644
--- a/src/rpc/client/download.ts
+++ b/src/client/download.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { DownloadChannel, DownloadInitializer } from '../../protocol/channels';
+import { DownloadChannel, DownloadInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
import { Readable } from 'stream';
import { Stream } from './stream';
diff --git a/src/rpc/client/electron.ts b/src/client/electron.ts
similarity index 97%
rename from src/rpc/client/electron.ts
rename to src/client/electron.ts
index 92704276ee..b1f5ecfa3b 100644
--- a/src/rpc/client/electron.ts
+++ b/src/client/electron.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { ElectronChannel, ElectronInitializer, ElectronApplicationChannel, ElectronApplicationInitializer, ElectronLaunchParams, ElectronLaunchOptions } from '../../protocol/channels';
+import { ElectronChannel, ElectronInitializer, ElectronApplicationChannel, ElectronApplicationInitializer, ElectronLaunchParams, ElectronLaunchOptions } from '../protocol/channels';
import { BrowserContext } from './browserContext';
import { ChannelOwner } from './channelOwner';
import { Page } from './page';
import { serializeArgument, FuncOn, parseResult, SmartHandle, JSHandle } from './jsHandle';
-import { TimeoutSettings } from '../../utils/timeoutSettings';
+import { TimeoutSettings } from '../utils/timeoutSettings';
import { Waiter } from './waiter';
import { Events } from './events';
import { WaitForEventOptions, Env, LoggerSink } from './types';
diff --git a/src/rpc/client/elementHandle.ts b/src/client/elementHandle.ts
similarity index 99%
rename from src/rpc/client/elementHandle.ts
rename to src/client/elementHandle.ts
index 88181fa9db..63f9135f96 100644
--- a/src/rpc/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 { ElementHandleChannel, JSHandleInitializer, ElementHandleScrollIntoViewIfNeededOptions, ElementHandleHoverOptions, ElementHandleClickOptions, ElementHandleDblclickOptions, ElementHandleFillOptions, ElementHandleSetInputFilesOptions, ElementHandlePressOptions, ElementHandleCheckOptions, ElementHandleUncheckOptions, ElementHandleScreenshotOptions, ElementHandleTypeOptions, ElementHandleSelectTextOptions, ElementHandleWaitForSelectorOptions, ElementHandleWaitForElementStateOptions, ElementHandleSetInputFilesParams } from '../protocol/channels';
import { Frame } from './frame';
import { FuncOn, JSHandle, serializeArgument, parseResult } from './jsHandle';
import { ChannelOwner } from './channelOwner';
@@ -23,7 +23,7 @@ import * as fs from 'fs';
import * as mime from 'mime';
import * as path from 'path';
import * as util from 'util';
-import { assert, isString, mkdirIfNeeded } from '../../utils/utils';
+import { assert, isString, mkdirIfNeeded } from '../utils/utils';
const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));
diff --git a/src/rpc/client/events.ts b/src/client/events.ts
similarity index 100%
rename from src/rpc/client/events.ts
rename to src/client/events.ts
diff --git a/src/rpc/client/fileChooser.ts b/src/client/fileChooser.ts
similarity index 94%
rename from src/rpc/client/fileChooser.ts
rename to src/client/fileChooser.ts
index 4c49091175..1d3bc5d414 100644
--- a/src/rpc/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 { ElementHandleSetInputFilesOptions } from '../protocol/channels';
export class FileChooser {
private _page: Page;
diff --git a/src/rpc/client/firefoxBrowser.ts b/src/client/firefoxBrowser.ts
similarity index 100%
rename from src/rpc/client/firefoxBrowser.ts
rename to src/client/firefoxBrowser.ts
diff --git a/src/rpc/client/frame.ts b/src/client/frame.ts
similarity index 99%
rename from src/rpc/client/frame.ts
rename to src/client/frame.ts
index d96ceef22a..f46753027b 100644
--- a/src/rpc/client/frame.ts
+++ b/src/client/frame.ts
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-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 { 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 { BrowserContext } from './browserContext';
import { ChannelOwner } from './channelOwner';
import { ElementHandle, convertSelectOptionValues, convertInputFiles } from './elementHandle';
diff --git a/src/rpc/client/input.ts b/src/client/input.ts
similarity index 98%
rename from src/rpc/client/input.ts
rename to src/client/input.ts
index 1139e323cd..957a8e1510 100644
--- a/src/rpc/client/input.ts
+++ b/src/client/input.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { PageChannel, PageKeyboardTypeOptions, PageKeyboardPressOptions, PageMouseDownOptions, PageMouseUpOptions, PageMouseClickOptions } from '../../protocol/channels';
+import { PageChannel, PageKeyboardTypeOptions, PageKeyboardPressOptions, PageMouseDownOptions, PageMouseUpOptions, PageMouseClickOptions } from '../protocol/channels';
export class Keyboard {
private _channel: PageChannel;
diff --git a/src/rpc/client/jsHandle.ts b/src/client/jsHandle.ts
similarity index 97%
rename from src/rpc/client/jsHandle.ts
rename to src/client/jsHandle.ts
index 9cd35ca657..d4696d7ee9 100644
--- a/src/rpc/client/jsHandle.ts
+++ b/src/client/jsHandle.ts
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-import { JSHandleChannel, JSHandleInitializer, SerializedArgument, SerializedValue, Channel } from '../../protocol/channels';
+import { JSHandleChannel, JSHandleInitializer, SerializedArgument, SerializedValue, Channel } from '../protocol/channels';
import { ElementHandle } from './elementHandle';
import { ChannelOwner } from './channelOwner';
-import { parseSerializedValue, serializeValue } from '../../protocol/serializers';
+import { parseSerializedValue, serializeValue } from '../protocol/serializers';
type NoHandles<Arg> = Arg extends JSHandle ? never : (Arg extends object ? { [Key in keyof Arg]: NoHandles<Arg[Key]> } : Arg);
type Unboxed<Arg> =
diff --git a/src/rpc/client/network.ts b/src/client/network.ts
similarity index 98%
rename from src/rpc/client/network.ts
rename to src/client/network.ts
index 32cce3ee6f..72618e3b61 100644
--- a/src/rpc/client/network.ts
+++ b/src/client/network.ts
@@ -15,14 +15,14 @@
*/
import { URLSearchParams } from 'url';
-import { RequestChannel, ResponseChannel, RouteChannel, RequestInitializer, ResponseInitializer, RouteInitializer } from '../../protocol/channels';
+import { RequestChannel, ResponseChannel, RouteChannel, RequestInitializer, ResponseInitializer, RouteInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
import { Frame } from './frame';
import { Headers } from './types';
import * as fs from 'fs';
import * as mime from 'mime';
import * as util from 'util';
-import { isString, headersObjectToArray, headersArrayToObject } from '../../utils/utils';
+import { isString, headersObjectToArray, headersArrayToObject } from '../utils/utils';
export type NetworkCookie = {
name: string,
diff --git a/src/rpc/client/page.ts b/src/client/page.ts
similarity index 99%
rename from src/rpc/client/page.ts
rename to src/client/page.ts
index 2ec897760e..bcd49e45cc 100644
--- a/src/rpc/client/page.ts
+++ b/src/client/page.ts
@@ -16,10 +16,10 @@
*/
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 { parseError, serializeError } from '../../protocol/serializers';
+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 { parseError, serializeError } from '../protocol/serializers';
import { Accessibility } from './accessibility';
import { BrowserContext } from './browserContext';
import { ChannelOwner } from './channelOwner';
@@ -41,7 +41,7 @@ import * as fs from 'fs';
import * as util from 'util';
import { Size, URLMatch, Headers, LifecycleEvent, WaitForEventOptions, SelectOption, SelectOptionOptions, FilePayload, WaitForFunctionOptions } from './types';
import { evaluationScript, urlMatches } from './clientHelper';
-import { isString, isRegExp, isObject, mkdirIfNeeded, headersObjectToArray } from '../../utils/utils';
+import { isString, isRegExp, isObject, mkdirIfNeeded, headersObjectToArray } from '../utils/utils';
type PDFOptions = Omit<PagePdfParams, 'width' | 'height' | 'margin'> & {
width?: string | number,
diff --git a/src/rpc/client/playwright.ts b/src/client/playwright.ts
similarity index 93%
rename from src/rpc/client/playwright.ts
rename to src/client/playwright.ts
index 63b7b3d028..d93e9bb7c2 100644
--- a/src/rpc/client/playwright.ts
+++ b/src/client/playwright.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { PlaywrightChannel, PlaywrightInitializer } from '../../protocol/channels';
+import { PlaywrightChannel, PlaywrightInitializer } from '../protocol/channels';
import { BrowserType } from './browserType';
import { ChannelOwner } from './channelOwner';
import { Selectors } from './selectors';
import { Electron } from './electron';
-import { TimeoutError } from '../../utils/errors';
+import { TimeoutError } from '../utils/errors';
import { Size } from './types';
type DeviceDescriptor = {
diff --git a/src/rpc/client/selectors.ts b/src/client/selectors.ts
similarity index 95%
rename from src/rpc/client/selectors.ts
rename to src/client/selectors.ts
index 3aba2639de..c8aafcd9e0 100644
--- a/src/rpc/client/selectors.ts
+++ b/src/client/selectors.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { SelectorsChannel, SelectorsInitializer } from '../../protocol/channels';
+import { SelectorsChannel, SelectorsInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
import { ElementHandle } from './elementHandle';
import { evaluationScript } from './clientHelper';
diff --git a/src/rpc/client/stream.ts b/src/client/stream.ts
similarity index 94%
rename from src/rpc/client/stream.ts
rename to src/client/stream.ts
index f0e88dd1a2..dcc671ce32 100644
--- a/src/rpc/client/stream.ts
+++ b/src/client/stream.ts
@@ -15,7 +15,7 @@
*/
import { Readable } from 'stream';
-import { StreamChannel, StreamInitializer } from '../../protocol/channels';
+import { StreamChannel, StreamInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
export class Stream extends ChannelOwner<StreamChannel, StreamInitializer> {
diff --git a/src/rpc/client/types.ts b/src/client/types.ts
similarity index 99%
rename from src/rpc/client/types.ts
rename to src/client/types.ts
index c43b8f05a1..24b625697d 100644
--- a/src/rpc/client/types.ts
+++ b/src/client/types.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { BrowserNewContextOptions, BrowserTypeLaunchOptions } from '../../protocol/channels';
+import { BrowserNewContextOptions, BrowserTypeLaunchOptions } from '../protocol/channels';
type LoggerSeverity = 'verbose' | 'info' | 'warning' | 'error';
export interface LoggerSink {
diff --git a/src/rpc/client/waiter.ts b/src/client/waiter.ts
similarity index 97%
rename from src/rpc/client/waiter.ts
rename to src/client/waiter.ts
index 2e1d8ee427..a56ef0ec39 100644
--- a/src/rpc/client/waiter.ts
+++ b/src/client/waiter.ts
@@ -15,8 +15,8 @@
*/
import { EventEmitter } from 'events';
-import { rewriteErrorMessage } from '../../utils/stackTrace';
-import { TimeoutError } from '../../utils/errors';
+import { rewriteErrorMessage } from '../utils/stackTrace';
+import { TimeoutError } from '../utils/errors';
export class Waiter {
private _dispose: (() => void)[] = [];
diff --git a/src/rpc/client/webkitBrowser.ts b/src/client/webkitBrowser.ts
similarity index 100%
rename from src/rpc/client/webkitBrowser.ts
rename to src/client/webkitBrowser.ts
diff --git a/src/rpc/client/worker.ts b/src/client/worker.ts
similarity index 97%
rename from src/rpc/client/worker.ts
rename to src/client/worker.ts
index e3725baade..a6e3c9260e 100644
--- a/src/rpc/client/worker.ts
+++ b/src/client/worker.ts
@@ -15,7 +15,7 @@
*/
import { Events } from './events';
-import { WorkerChannel, WorkerInitializer } from '../../protocol/channels';
+import { WorkerChannel, WorkerInitializer } from '../protocol/channels';
import { ChannelOwner } from './channelOwner';
import { assertMaxArguments, Func1, JSHandle, parseResult, serializeArgument, SmartHandle } from './jsHandle';
import { Page } from './page';
diff --git a/src/rpc/browserServerImpl.ts b/src/rpc/browserServerImpl.ts
index 573ac55450..7cca64e7a7 100644
--- a/src/rpc/browserServerImpl.ts
+++ b/src/rpc/browserServerImpl.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { LaunchServerOptions } from './client/types';
+import { LaunchServerOptions } from '../client/types';
import { BrowserTypeBase } from '../server/browserType';
import * as ws from 'ws';
import { helper } from '../helper';
@@ -26,8 +26,8 @@ import { BrowserTypeDispatcher } from './server/browserTypeDispatcher';
import { BrowserDispatcher } from './server/browserDispatcher';
import { BrowserContextDispatcher } from './server/browserContextDispatcher';
import { BrowserNewContextParams, BrowserContextChannel } from '../protocol/channels';
-import { BrowserServerLauncher, BrowserServer } from './client/browserType';
-import { envObjectToArray } from './client/clientHelper';
+import { BrowserServerLauncher, BrowserServer } from '../client/browserType';
+import { envObjectToArray } from '../client/clientHelper';
export class BrowserServerLauncherImpl implements BrowserServerLauncher {
private _browserType: BrowserTypeBase;
diff --git a/src/rpc/client.ts b/src/rpc/client.ts
deleted file mode 100644
index 51f7576e9f..0000000000
--- a/src/rpc/client.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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 * as childProcess from 'child_process';
-import * as path from 'path';
-import { Connection } from './client/connection';
-import { Transport } from '../protocol/transport';
-
-(async () => {
- const spawnedProcess = childProcess.fork(path.join(__dirname, 'server'), [], { stdio: 'pipe' });
- const transport = new Transport(spawnedProcess.stdin, spawnedProcess.stdout);
- transport.onclose = () => process.exit(0);
- const connection = new Connection();
- connection.onmessage = message => transport.send(JSON.stringify(message));
- transport.onmessage = message => connection.dispatch(JSON.parse(message));
-
- const playwright = await connection.waitForObjectWithKnownName('Playwright');
- const browser = await playwright.chromium.launch({ headless: false });
- const page = await browser.newPage();
- await page.goto('https://example.com');
-})();
diff --git a/src/rpc/inprocess.ts b/src/rpc/inprocess.ts
index b12174c8a7..7a54b1f426 100644
--- a/src/rpc/inprocess.ts
+++ b/src/rpc/inprocess.ts
@@ -16,9 +16,9 @@
import { DispatcherConnection } from './server/dispatcher';
import type { Playwright as PlaywrightImpl } from '../server/playwright';
-import type { Playwright as PlaywrightAPI } from './client/playwright';
+import type { Playwright as PlaywrightAPI } from '../client/playwright';
import { PlaywrightDispatcher } from './server/playwrightDispatcher';
-import { Connection } from './client/connection';
+import { Connection } from '../client/connection';
import { BrowserServerLauncherImpl } from './browserServerImpl';
import { isUnderTest } from '../utils/utils';
diff --git a/test/coverage.js b/test/coverage.js
index 303699b440..18eb40f63e 100644
--- a/test/coverage.js
+++ b/test/coverage.js
@@ -61,8 +61,8 @@ function traceAPICoverage(apiCoverage, api, events) {
* @param {string} browserName
*/
function apiForBrowser(browserName) {
- const events = require('../lib/rpc/client/events').Events;
- const api = require('../lib/rpc/client/api');
+ const events = require('../lib/client/events').Events;
+ const api = require('../lib/client/api');
const otherBrowsers = ['chromium', 'webkit', 'firefox'].filter(name => name.toLowerCase() !== browserName.toLowerCase());
const filteredKeys = Object.keys(api).filter(apiName => {
return !otherBrowsers.some(otherName => apiName.toLowerCase().startsWith(otherName));
diff --git a/test/interception.spec.ts b/test/interception.spec.ts
index a82a379bd9..737e052730 100644
--- a/test/interception.spec.ts
+++ b/test/interception.spec.ts
@@ -17,7 +17,7 @@
import './playwright.fixtures';
-import { globToRegex } from '../lib/rpc/client/clientHelper';
+import { globToRegex } from '../lib/client/clientHelper';
import vm from 'vm';
it('should work with navigation', async({page, server}) => {
diff --git a/test/playwright.fixtures.ts b/test/playwright.fixtures.ts
index 5eeac93712..47e482033f 100644
--- a/test/playwright.fixtures.ts
+++ b/test/playwright.fixtures.ts
@@ -20,7 +20,7 @@ import os from 'os';
import childProcess from 'child_process';
import { LaunchOptions, BrowserType, Browser, BrowserContext, Page, BrowserServer } from '../index';
import { TestServer } from '../utils/testserver';
-import { Connection } from '../lib/rpc/client/connection';
+import { Connection } from '../lib/client/connection';
import { Transport } from '../lib/protocol/transport';
import { setUnderTest } from '../lib/utils/utils';
import { installCoverageHooks } from './coverage';
diff --git a/utils/check_deps.js b/utils/check_deps.js
index 08fed64bf2..46c10eb227 100644
--- a/utils/check_deps.js
+++ b/utils/check_deps.js
@@ -69,8 +69,9 @@ async function checkDeps() {
const DEPS = new Map([
['src/utils/', ['src/utils/']],
+ ['src/common/', ['src/common/']],
['src/protocol/', ['src/protocol/', 'src/utils/']],
- ['src/rpc/client/', ['src/rpc/client/', 'src/utils/', 'src/protocol/', 'src/chromium/protocol.ts']],
+ ['src/client/', ['src/client/', 'src/utils/', 'src/protocol/', 'src/chromium/protocol.ts']],
['src/', ['src/']], // Allow everything else for now.
]);
diff --git a/utils/doclint/cli.js b/utils/doclint/cli.js
index 6112a7aa8b..a54fd9bb04 100755
--- a/utils/doclint/cli.js
+++ b/utils/doclint/cli.js
@@ -66,7 +66,7 @@ async function run() {
const browser = await playwright.chromium.launch();
const page = await browser.newPage();
const checkPublicAPI = require('./check_public_api');
- const jsSources = await Source.readdir(path.join(PROJECT_DIR, 'src', 'rpc', 'client'), '', []);
+ const jsSources = await Source.readdir(path.join(PROJECT_DIR, 'src', 'client'), '', []);
messages.push(...await checkPublicAPI(page, [api], jsSources));
await browser.close();
}
diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js
index f727dc275d..ef7e5c5b82 100644
--- a/utils/generate_types/index.js
+++ b/utils/generate_types/index.js
@@ -37,7 +37,7 @@ let documentation;
const api = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'api.md'));
const {documentation: mdDocumentation} = await require('../doclint/check_public_api/MDBuilder')(page, [api]);
await browser.close();
- const sources = await Source.readdir(path.join(PROJECT_DIR, 'src', 'rpc', 'client'), '', []);
+ const sources = await Source.readdir(path.join(PROJECT_DIR, 'src', 'client'), '', []);
const {documentation: jsDocumentation} = await require('../doclint/check_public_api/JSBuilder').checkSources(sources);
documentation = mergeDocumentation(mdDocumentation, jsDocumentation);
const handledClasses = new Set();