chore: rename the world (3)

This commit is contained in:
Pavel 2019-12-19 17:03:27 -08:00
parent b20e87d9d0
commit c7d205d416
14 changed files with 44 additions and 43 deletions

View file

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license. // Licensed under the MIT license.
import * as chromium from './chromium/api'; import * as chromium from './chromium/crApi';
import * as firefox from './firefox/api'; import * as firefox from './firefox/ffApi';
import * as webkit from './webkit/api'; import * as webkit from './webkit/wkApi';
export const Chromium = chromium; export const Chromium = chromium;
export const Firefox = firefox; export const Firefox = firefox;

View file

@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license. // Licensed under the MIT license.
export { BrowserContext } from '../browserContext';
export { ConsoleMessage } from '../console'; export { ConsoleMessage } from '../console';
export { Dialog } from '../dialog'; export { Dialog } from '../dialog';
export { ElementHandle } from '../dom'; export { ElementHandle } from '../dom';
@ -9,14 +10,15 @@ export { Frame } from '../frames';
export { Keyboard, Mouse } from '../input'; export { Keyboard, Mouse } from '../input';
export { JSHandle } from '../javascript'; export { JSHandle } from '../javascript';
export { Request, Response } from '../network'; export { Request, Response } from '../network';
export { BrowserContext } from '../browserContext'; export { Page } from '../page';
export { CRSession as CDPSession } from './crConnection'; export { CRSession as CDPSession } from './crConnection';
export { CRTarget as Target } from './crTarget';
export { CRAccessibility as Accessibility } from './features/crAccessibility'; export { CRAccessibility as Accessibility } from './features/crAccessibility';
export { CRCoverage as Coverage } from './features/crCoverage'; export { CRCoverage as Coverage } from './features/crCoverage';
export { CRInterception as Interception } from './features/crInterception'; export { CRInterception as Interception } from './features/crInterception';
export { CROverrides as Overrides } from './features/crOverrides'; export { CROverrides as Overrides } from './features/crOverrides';
export { CRPdf as PDF } from './features/crPdf'; export { CRPdf as PDF } from './features/crPdf';
export { CRPermissions as Permissions } from './features/crPermissions'; export { CRPermissions as Permissions } from './features/crPermissions';
export { Worker, CRWorkers as Workers } from './features/crWorkers'; export { CRWorker as Worker, CRWorkers as Workers } from './features/crWorkers';
export { Page } from '../page';
export { CRTarget as Target } from './crTarget';

View file

@ -29,9 +29,9 @@ import * as browser from '../browser';
import * as network from '../network'; import * as network from '../network';
import { CRPermissions } from './features/crPermissions'; import { CRPermissions } from './features/crPermissions';
import { CROverrides } from './features/crOverrides'; import { CROverrides } from './features/crOverrides';
import { Worker } from './features/crWorkers'; import { CRWorker } from './features/crWorkers';
import { ConnectionTransport } from '../transport'; import { ConnectionTransport } from '../transport';
import { readProtocolStream } from './protocolHelper'; import { readProtocolStream } from './crProtocolHelper';
export class CRBrowser extends EventEmitter implements browser.Browser { export class CRBrowser extends EventEmitter implements browser.Browser {
_connection: CRConnection; _connection: CRConnection;
@ -230,7 +230,7 @@ export class CRBrowser extends EventEmitter implements browser.Browser {
return [...this._targets.values()].find(t => t.type() === 'browser'); return [...this._targets.values()].find(t => t.type() === 'browser');
} }
serviceWorker(target: CRTarget): Promise<Worker | null> { serviceWorker(target: CRTarget): Promise<CRWorker | null> {
return target._worker(); return target._worker();
} }

View file

@ -17,7 +17,7 @@
import { CRSession } from './crConnection'; import { CRSession } from './crConnection';
import { helper } from '../helper'; import { helper } from '../helper';
import { valueFromRemoteObject, getExceptionMessage, releaseObject } from './protocolHelper'; import { valueFromRemoteObject, getExceptionMessage, releaseObject } from './crProtocolHelper';
import { Protocol } from './protocol'; import { Protocol } from './protocol';
import * as js from '../javascript'; import * as js from '../javascript';

View file

@ -25,7 +25,7 @@ import { CRNetworkManager } from './crNetworkManager';
import { Page } from '../page'; import { Page } from '../page';
import { Protocol } from './protocol'; import { Protocol } from './protocol';
import { Events } from '../events'; import { Events } from '../events';
import { toConsoleMessageLocation, exceptionToError, releaseObject } from './protocolHelper'; import { toConsoleMessageLocation, exceptionToError, releaseObject } from './crProtocolHelper';
import * as dialog from '../dialog'; import * as dialog from '../dialog';
import { PageDelegate } from '../page'; import { PageDelegate } from '../page';
import { RawMouseImpl, RawKeyboardImpl } from './crInput'; import { RawMouseImpl, RawKeyboardImpl } from './crInput';

View file

@ -19,7 +19,7 @@ import { CRBrowser } from './crBrowser';
import { BrowserContext } from '../browserContext'; import { BrowserContext } from '../browserContext';
import { CRSession, CRSessionEvents } from './crConnection'; import { CRSession, CRSessionEvents } from './crConnection';
import { Events } from '../events'; import { Events } from '../events';
import { Worker } from './features/crWorkers'; import { CRWorker } from './features/crWorkers';
import { Page } from '../page'; import { Page } from '../page';
import { Protocol } from './protocol'; import { Protocol } from './protocol';
import { debugError } from '../helper'; import { debugError } from '../helper';
@ -35,7 +35,7 @@ export class CRTarget {
private _sessionFactory: () => Promise<CRSession>; private _sessionFactory: () => Promise<CRSession>;
private _pagePromise: Promise<Page> | null = null; private _pagePromise: Promise<Page> | null = null;
private _frameManager: CRFrameManager | null = null; private _frameManager: CRFrameManager | null = null;
private _workerPromise: Promise<Worker> | null = null; private _workerPromise: Promise<CRWorker> | null = null;
_initializedPromise: Promise<boolean>; _initializedPromise: Promise<boolean>;
_initializedCallback: (value?: unknown) => void; _initializedCallback: (value?: unknown) => void;
_isInitialized: boolean; _isInitialized: boolean;
@ -98,13 +98,13 @@ export class CRTarget {
return this._pagePromise; return this._pagePromise;
} }
async _worker(): Promise<Worker | null> { async _worker(): Promise<CRWorker | null> {
if (this._targetInfo.type !== 'service_worker' && this._targetInfo.type !== 'shared_worker') if (this._targetInfo.type !== 'service_worker' && this._targetInfo.type !== 'shared_worker')
return null; return null;
if (!this._workerPromise) { if (!this._workerPromise) {
// TODO(einbinder): Make workers send their console logs. // TODO(einbinder): Make workers send their console logs.
this._workerPromise = this._sessionFactory() this._workerPromise = this._sessionFactory()
.then(client => new Worker(client, this._targetInfo.url, () => { } /* consoleAPICalled */, () => { } /* exceptionThrown */)); .then(client => new CRWorker(client, this._targetInfo.url, () => { } /* consoleAPICalled */, () => { } /* exceptionThrown */));
} }
return this._workerPromise; return this._workerPromise;
} }

View file

@ -17,7 +17,7 @@
import { BrowserContext } from '../../browserContext'; import { BrowserContext } from '../../browserContext';
import { CRFrameManager } from '../crFrameManager'; import { CRFrameManager } from '../crFrameManager';
import { Page } from '../api'; import { Page } from '../crApi';
export class CROverrides { export class CROverrides {
private _context: BrowserContext; private _context: BrowserContext;

View file

@ -17,7 +17,7 @@
import { assert, helper } from '../../helper'; import { assert, helper } from '../../helper';
import { CRSession } from '../crConnection'; import { CRSession } from '../crConnection';
import { readProtocolStream } from '../protocolHelper'; import { readProtocolStream } from '../crProtocolHelper';
type PDFOptions = { type PDFOptions = {
scale?: number, scale?: number,

View file

@ -24,13 +24,13 @@ import * as types from '../../types';
import * as js from '../../javascript'; import * as js from '../../javascript';
import * as console from '../../console'; import * as console from '../../console';
import { CRExecutionContext } from '../crExecutionContext'; import { CRExecutionContext } from '../crExecutionContext';
import { toConsoleMessageLocation, exceptionToError } from '../protocolHelper'; import { toConsoleMessageLocation, exceptionToError } from '../crProtocolHelper';
type AddToConsoleCallback = (type: string, args: js.JSHandle[], location: console.ConsoleMessageLocation) => void; type AddToConsoleCallback = (type: string, args: js.JSHandle[], location: console.ConsoleMessageLocation) => void;
type HandleExceptionCallback = (error: Error) => void; type HandleExceptionCallback = (error: Error) => void;
export class CRWorkers extends EventEmitter { export class CRWorkers extends EventEmitter {
private _workers = new Map<string, Worker>(); private _workers = new Map<string, CRWorker>();
constructor(client: CRSession, addToConsole: AddToConsoleCallback, handleException: HandleExceptionCallback) { constructor(client: CRSession, addToConsole: AddToConsoleCallback, handleException: HandleExceptionCallback) {
super(); super();
@ -39,7 +39,7 @@ export class CRWorkers extends EventEmitter {
if (event.targetInfo.type !== 'worker') if (event.targetInfo.type !== 'worker')
return; return;
const session = CRConnection.fromSession(client).session(event.sessionId); const session = CRConnection.fromSession(client).session(event.sessionId);
const worker = new Worker(session, event.targetInfo.url, addToConsole, handleException); const worker = new CRWorker(session, event.targetInfo.url, addToConsole, handleException);
this._workers.set(event.sessionId, worker); this._workers.set(event.sessionId, worker);
this.emit(Events.Workers.WorkerCreated, worker); this.emit(Events.Workers.WorkerCreated, worker);
}); });
@ -52,12 +52,12 @@ export class CRWorkers extends EventEmitter {
}); });
} }
list(): Worker[] { list(): CRWorker[] {
return Array.from(this._workers.values()); return Array.from(this._workers.values());
} }
} }
export class Worker extends EventEmitter { export class CRWorker extends EventEmitter {
private _client: CRSession; private _client: CRSession;
private _url: string; private _url: string;
private _executionContextPromise: Promise<js.ExecutionContext>; private _executionContextPromise: Promise<js.ExecutionContext>;

View file

@ -1,16 +1,18 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license. // Licensed under the MIT license.
export { TimeoutError } from '../errors';
export { Keyboard, Mouse } from '../input';
export { BrowserContext } from '../browserContext'; export { BrowserContext } from '../browserContext';
export { ConsoleMessage } from '../console';
export { Dialog } from '../dialog'; export { Dialog } from '../dialog';
export { JSHandle } from '../javascript';
export { ElementHandle } from '../dom'; export { ElementHandle } from '../dom';
export { TimeoutError } from '../errors';
export { Frame } from '../frames';
export { Keyboard, Mouse } from '../input';
export { JSHandle } from '../javascript';
export { Request, Response } from '../network';
export { Page } from '../page';
export { FFAccessibility as Accessibility } from './features/ffAccessibility'; export { FFAccessibility as Accessibility } from './features/ffAccessibility';
export { FFInterception as Interception } from './features/ffInterception'; export { FFInterception as Interception } from './features/ffInterception';
export { FFPermissions as Permissions } from './features/ffPermissions'; export { FFPermissions as Permissions } from './features/ffPermissions';
export { Frame } from '../frames';
export { Request, Response } from '../network';
export { Page } from '../page';
export { ConsoleMessage } from '../console';

View file

@ -1,13 +1,14 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license. // Licensed under the MIT license.
export { TimeoutError } from '../errors';
export { BrowserContext } from '../browserContext'; export { BrowserContext } from '../browserContext';
export { JSHandle } from '../javascript'; export { ConsoleMessage } from '../console';
export { Dialog } from '../dialog';
export { ElementHandle } from '../dom'; export { ElementHandle } from '../dom';
export { TimeoutError } from '../errors';
export { Frame } from '../frames'; export { Frame } from '../frames';
export { Mouse, Keyboard } from '../input'; export { Keyboard, Mouse } from '../input';
export { JSHandle } from '../javascript';
export { Request, Response } from '../network'; export { Request, Response } from '../network';
export { Page } from '../page'; export { Page } from '../page';
export { Dialog } from '../dialog';
export { ConsoleMessage } from '../console';

View file

@ -17,7 +17,7 @@
import { WKTargetSession, isSwappedOutError } from './wkConnection'; import { WKTargetSession, isSwappedOutError } from './wkConnection';
import { helper } from '../helper'; import { helper } from '../helper';
import { valueFromRemoteObject, releaseObject } from './protocolHelper'; import { valueFromRemoteObject, releaseObject } from './wkProtocolHelper';
import { Protocol } from './protocol'; import { Protocol } from './protocol';
import * as js from '../javascript'; import * as js from '../javascript';
@ -144,7 +144,7 @@ export class WKExecutionContext implements js.ExecutionContextDelegate {
return valueFromRemoteObject(response.result); return valueFromRemoteObject(response.result);
}).catch(rewriteError); }).catch(rewriteError);
function unserializableToString(arg) { function unserializableToString(arg: any) {
if (Object.is(arg, -0)) if (Object.is(arg, -0))
return '-0'; return '-0';
if (Object.is(arg, Infinity)) if (Object.is(arg, Infinity))
@ -161,7 +161,7 @@ export class WKExecutionContext implements js.ExecutionContextDelegate {
throw new Error('Unsupported value: ' + arg + ' (' + (typeof arg) + ')'); throw new Error('Unsupported value: ' + arg + ' (' + (typeof arg) + ')');
} }
function isUnserializable(arg) { function isUnserializable(arg: any) {
if (typeof arg === 'bigint') if (typeof arg === 'bigint')
return true; return true;
if (Object.is(arg, -0)) if (Object.is(arg, -0))
@ -180,11 +180,7 @@ export class WKExecutionContext implements js.ExecutionContextDelegate {
return false; return false;
} }
/** function rewriteError(error: Error): Protocol.Runtime.evaluateReturnValue {
* @param {!Error} error
* @return {!Protocol.Runtime.evaluateReturnValue}
*/
function rewriteError(error) {
if (error.message.includes('Object couldn\'t be returned by value')) if (error.message.includes('Object couldn\'t be returned by value'))
return {result: {type: 'undefined'}}; return {result: {type: 'undefined'}};