From aefbde60d7993c37ca5289e034f3ca90945c20ff Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:57:26 +0200 Subject: [PATCH] refactor: align names (#10903) --- packages/puppeteer-core/src/common/Browser.ts | 50 ++++++++-------- .../src/common/BrowserConnector.ts | 8 +-- .../puppeteer-core/src/common/CDPSession.ts | 14 ++--- .../src/common/ChromeTargetManager.ts | 16 ++--- .../puppeteer-core/src/common/Connection.ts | 6 +- packages/puppeteer-core/src/common/Dialog.ts | 2 +- .../src/common/ElementHandle.ts | 40 ++++++------- .../src/common/ExecutionContext.ts | 6 +- .../src/common/FirefoxTargetManager.ts | 8 +-- packages/puppeteer-core/src/common/Frame.ts | 6 +- .../puppeteer-core/src/common/FrameManager.ts | 38 ++++++------ .../puppeteer-core/src/common/HTTPRequest.ts | 8 +-- .../puppeteer-core/src/common/HTTPResponse.ts | 10 ++-- packages/puppeteer-core/src/common/Input.ts | 14 ++--- .../src/common/IsolatedWorld.ts | 10 ++-- .../puppeteer-core/src/common/JSHandle.ts | 6 +- .../src/common/LifecycleWatcher.ts | 16 ++--- .../src/common/NetworkEventManager.ts | 8 +-- .../src/common/NetworkManager.test.ts | 16 ++--- .../src/common/NetworkManager.ts | 28 ++++----- packages/puppeteer-core/src/common/Page.ts | 60 +++++++++---------- .../puppeteer-core/src/common/Puppeteer.ts | 4 +- packages/puppeteer-core/src/common/Target.ts | 18 +++--- .../src/common/TargetManager.ts | 12 ++-- .../puppeteer-core/src/common/WebWorker.ts | 6 +- .../bidi/{BidiOverCDP.ts => BidiOverCdp.ts} | 20 +++---- .../src/common/bidi/BrowsingContext.ts | 20 +++---- .../src/common/bidi/Connection.ts | 4 +- .../puppeteer-core/src/common/bidi/Page.ts | 12 ++-- .../puppeteer-core/src/common/bidi/Target.ts | 4 +- .../puppeteer-core/src/common/bidi/bidi.ts | 2 +- packages/puppeteer-core/src/common/util.ts | 12 ++-- .../src/node/ProductLauncher.ts | 18 +++--- test/src/TargetManager.spec.ts | 6 +- test/src/oopif.spec.ts | 4 +- test/src/page.spec.ts | 4 +- 36 files changed, 258 insertions(+), 258 deletions(-) rename packages/puppeteer-core/src/common/bidi/{BidiOverCDP.ts => BidiOverCdp.ts} (92%) diff --git a/packages/puppeteer-core/src/common/Browser.ts b/packages/puppeteer-core/src/common/Browser.ts index 20ed622b39f..2060f610859 100644 --- a/packages/puppeteer-core/src/common/Browser.ts +++ b/packages/puppeteer-core/src/common/Browser.ts @@ -40,7 +40,7 @@ import {Connection} from './Connection.js'; import {FirefoxTargetManager} from './FirefoxTargetManager.js'; import {Viewport} from './PuppeteerViewport.js'; import { - CDPTarget, + CdpTarget, DevToolsTarget, InitializationStatus, OtherTarget, @@ -53,7 +53,7 @@ import {TaskQueue} from './TaskQueue.js'; /** * @internal */ -export class CDPBrowser extends BrowserBase { +export class CdpBrowser extends BrowserBase { static async _create( product: 'firefox' | 'chrome' | undefined, connection: Connection, @@ -66,8 +66,8 @@ export class CDPBrowser extends BrowserBase { isPageTargetCallback?: IsPageTargetCallback, waitForInitiallyDiscoveredTargets = true, useTabTarget = USE_TAB_TARGET - ): Promise { - const browser = new CDPBrowser( + ): Promise { + const browser = new CdpBrowser( product, connection, contextIds, @@ -90,12 +90,12 @@ export class CDPBrowser extends BrowserBase { #closeCallback: BrowserCloseCallback; #targetFilterCallback: TargetFilterCallback; #isPageTargetCallback!: IsPageTargetCallback; - #defaultContext: CDPBrowserContext; - #contexts = new Map(); + #defaultContext: CdpBrowserContext; + #contexts = new Map(); #screenshotTaskQueue: TaskQueue; #targetManager: TargetManager; - override get _targets(): Map { + override get _targets(): Map { return this.#targetManager.getAvailableTargets(); } @@ -141,11 +141,11 @@ export class CDPBrowser extends BrowserBase { useTabTarget ); } - this.#defaultContext = new CDPBrowserContext(this.#connection, this); + this.#defaultContext = new CdpBrowserContext(this.#connection, this); for (const contextId of contextIds) { this.#contexts.set( contextId, - new CDPBrowserContext(this.#connection, this, contextId) + new CdpBrowserContext(this.#connection, this, contextId) ); } } @@ -243,7 +243,7 @@ export class CDPBrowser extends BrowserBase { */ override async createIncognitoBrowserContext( options: BrowserContextOptions = {} - ): Promise { + ): Promise { const {proxyServer, proxyBypassList} = options; const {browserContextId} = await this.#connection.send( @@ -253,7 +253,7 @@ export class CDPBrowser extends BrowserBase { proxyBypassList: proxyBypassList && proxyBypassList.join(','), } ); - const context = new CDPBrowserContext( + const context = new CdpBrowserContext( this.#connection, this, browserContextId @@ -266,14 +266,14 @@ export class CDPBrowser extends BrowserBase { * Returns an array of all open browser contexts. In a newly created browser, this will * return a single instance of {@link BrowserContext}. */ - override browserContexts(): CDPBrowserContext[] { + override browserContexts(): CdpBrowserContext[] { return [this.#defaultContext, ...Array.from(this.#contexts.values())]; } /** * Returns the default browser context. The default browser context cannot be closed. */ - override defaultBrowserContext(): CDPBrowserContext { + override defaultBrowserContext(): CdpBrowserContext { return this.#defaultContext; } @@ -356,7 +356,7 @@ export class CDPBrowser extends BrowserBase { ); }; - #onAttachedToTarget = async (target: CDPTarget) => { + #onAttachedToTarget = async (target: CdpTarget) => { if ( (await target._initializedDeferred.valueOrThrow()) === InitializationStatus.SUCCESS @@ -366,7 +366,7 @@ export class CDPBrowser extends BrowserBase { } }; - #onDetachedFromTarget = async (target: CDPTarget): Promise => { + #onDetachedFromTarget = async (target: CdpTarget): Promise => { target._initializedDeferred.resolve(InitializationStatus.ABORTED); target._isClosedDeferred.resolve(); if ( @@ -378,7 +378,7 @@ export class CDPBrowser extends BrowserBase { } }; - #onTargetChanged = ({target}: {target: CDPTarget}): void => { + #onTargetChanged = ({target}: {target: CdpTarget}): void => { this.emit(BrowserEvent.TargetChanged, target); target.browserContext().emit(BrowserContextEvent.TargetChanged, target); }; @@ -422,8 +422,8 @@ export class CDPBrowser extends BrowserBase { browserContextId: contextId || undefined, }); const target = (await this.waitForTarget(t => { - return (t as CDPTarget)._targetId === targetId; - })) as CDPTarget; + return (t as CdpTarget)._targetId === targetId; + })) as CdpTarget; if (!target) { throw new Error(`Missing target for page (id = ${targetId})`); } @@ -446,7 +446,7 @@ export class CDPBrowser extends BrowserBase { * All active targets inside the Browser. In case of multiple browser contexts, returns * an array with all the targets in all browser contexts. */ - override targets(): CDPTarget[] { + override targets(): CdpTarget[] { return Array.from( this.#targetManager.getAvailableTargets().values() ).filter(target => { @@ -459,7 +459,7 @@ export class CDPBrowser extends BrowserBase { /** * The target associated with the browser. */ - override target(): CDPTarget { + override target(): CdpTarget { const browserTarget = this.targets().find(target => { return target.type() === 'browser'; }); @@ -509,12 +509,12 @@ export class CDPBrowser extends BrowserBase { /** * @internal */ -export class CDPBrowserContext extends BrowserContext { +export class CdpBrowserContext extends BrowserContext { #connection: Connection; - #browser: CDPBrowser; + #browser: CdpBrowser; #id?: string; - constructor(connection: Connection, browser: CDPBrowser, contextId?: string) { + constructor(connection: Connection, browser: CdpBrowser, contextId?: string) { super(); this.#connection = connection; this.#browser = browser; @@ -528,7 +528,7 @@ export class CDPBrowserContext extends BrowserContext { /** * An array of all active targets inside the browser context. */ - override targets(): CDPTarget[] { + override targets(): CdpTarget[] { return this.#browser.targets().filter(target => { return target.browserContext() === this; }); @@ -661,7 +661,7 @@ export class CDPBrowserContext extends BrowserContext { /** * The browser this browser context belongs to. */ - override browser(): CDPBrowser { + override browser(): CdpBrowser { return this.#browser; } diff --git a/packages/puppeteer-core/src/common/BrowserConnector.ts b/packages/puppeteer-core/src/common/BrowserConnector.ts index c9916a85706..d3d51d59065 100644 --- a/packages/puppeteer-core/src/common/BrowserConnector.ts +++ b/packages/puppeteer-core/src/common/BrowserConnector.ts @@ -19,7 +19,7 @@ import {isNode} from '../environment.js'; import {assert} from '../util/assert.js'; import {isErrorLike} from '../util/ErrorLike.js'; -import {CDPBrowser} from './Browser.js'; +import {CdpBrowser} from './Browser.js'; import {Connection} from './Connection.js'; import {ConnectionTransport} from './ConnectionTransport.js'; import {getFetch} from './fetch.js'; @@ -80,9 +80,9 @@ const getWebSocketTransportClass = async () => { * * @internal */ -export async function _connectToCDPBrowser( +export async function _connectToCdpBrowser( options: BrowserConnectOptions & ConnectOptions -): Promise { +): Promise { const { browserWSEndpoint, browserURL, @@ -136,7 +136,7 @@ export async function _connectToCDPBrowser( const {browserContextIds} = await connection.send( 'Target.getBrowserContexts' ); - const browser = await CDPBrowser._create( + const browser = await CdpBrowser._create( product || 'chrome', connection, browserContextIds, diff --git a/packages/puppeteer-core/src/common/CDPSession.ts b/packages/puppeteer-core/src/common/CDPSession.ts index 81c1bd1b386..efae8f10143 100644 --- a/packages/puppeteer-core/src/common/CDPSession.ts +++ b/packages/puppeteer-core/src/common/CDPSession.ts @@ -9,19 +9,19 @@ import { createProtocolErrorMessage, } from './Connection.js'; import {TargetCloseError} from './Errors.js'; -import {CDPTarget} from './Target.js'; +import {CdpTarget} from './Target.js'; /** * @internal */ -export class CDPCDPSession extends CDPSession { +export class CdpCDPSession extends CDPSession { #sessionId: string; #targetType: string; #callbacks = new CallbackRegistry(); #connection?: Connection; #parentSessionId?: string; - #target?: CDPTarget; + #target?: CdpTarget; /** * @internal @@ -40,20 +40,20 @@ export class CDPCDPSession extends CDPSession { } /** - * Sets the CDPTarget associated with the session instance. + * Sets the {@link CdpTarget} associated with the session instance. * * @internal */ - _setTarget(target: CDPTarget): void { + _setTarget(target: CdpTarget): void { this.#target = target; } /** - * Gets the CDPTarget associated with the session instance. + * Gets the {@link CdpTarget} associated with the session instance. * * @internal */ - _target(): CDPTarget { + _target(): CdpTarget { assert(this.#target, 'Target must exist'); return this.#target; } diff --git a/packages/puppeteer-core/src/common/ChromeTargetManager.ts b/packages/puppeteer-core/src/common/ChromeTargetManager.ts index 96d483b3ed0..07ed3ed2190 100644 --- a/packages/puppeteer-core/src/common/ChromeTargetManager.ts +++ b/packages/puppeteer-core/src/common/ChromeTargetManager.ts @@ -24,7 +24,7 @@ import {Deferred} from '../util/Deferred.js'; import {Connection} from './Connection.js'; import {EventEmitter} from './EventEmitter.js'; -import {CDPTarget, InitializationStatus} from './Target.js'; +import {CdpTarget, InitializationStatus} from './Target.js'; import { TargetFactory, TargetManager, @@ -33,12 +33,12 @@ import { } from './TargetManager.js'; import {debugError} from './util.js'; -function isTargetExposed(target: CDPTarget): boolean { +function isTargetExposed(target: CdpTarget): boolean { return target.type() !== TargetType.TAB && !target._subtype(); } function isPageTargetBecomingPrimary( - target: CDPTarget, + target: CdpTarget, newTargetInfo: Protocol.Target.TargetInfo ): boolean { return Boolean(target._subtype()) && !newTargetInfo.subtype; @@ -71,11 +71,11 @@ export class ChromeTargetManager * A target is added to this map once ChromeTargetManager has created * a Target and attached at least once to it. */ - #attachedTargetsByTargetId = new Map(); + #attachedTargetsByTargetId = new Map(); /** * Tracks which sessions attach to which target. */ - #attachedTargetsBySessionId = new Map(); + #attachedTargetsBySessionId = new Map(); /** * If a target was filtered out by `targetFilterCallback`, we still receive * events about it from CDP, but we don't forward them to the rest of Puppeteer. @@ -144,7 +144,7 @@ export class ChromeTargetManager targetId, targetInfo, ] of this.#discoveredTargetsByTargetId.entries()) { - const targetForFilter = new CDPTarget( + const targetForFilter = new CdpTarget( targetInfo, undefined, undefined, @@ -192,8 +192,8 @@ export class ChromeTargetManager this.#removeAttachmentListeners(this.#connection); } - getAvailableTargets(): Map { - const result = new Map(); + getAvailableTargets(): Map { + const result = new Map(); for (const [id, target] of this.#attachedTargetsByTargetId.entries()) { if (isTargetExposed(target)) { result.set(id, target); diff --git a/packages/puppeteer-core/src/common/Connection.ts b/packages/puppeteer-core/src/common/Connection.ts index 476a1412c99..6798fa5a714 100644 --- a/packages/puppeteer-core/src/common/Connection.ts +++ b/packages/puppeteer-core/src/common/Connection.ts @@ -24,7 +24,7 @@ import { } from '../api/CDPSession.js'; import {Deferred} from '../util/Deferred.js'; -import {CDPCDPSession} from './CDPSession.js'; +import {CdpCDPSession} from './CDPSession.js'; import {ConnectionTransport} from './ConnectionTransport.js'; import {debug} from './Debug.js'; import {ProtocolError, TargetCloseError} from './Errors.js'; @@ -200,7 +200,7 @@ export class Connection extends EventEmitter { #transport: ConnectionTransport; #delay: number; #timeout: number; - #sessions = new Map(); + #sessions = new Map(); #closed = false; #manuallyAttached = new Set(); #callbacks = new CallbackRegistry(); @@ -310,7 +310,7 @@ export class Connection extends EventEmitter { const object = JSON.parse(message); if (object.method === 'Target.attachedToTarget') { const sessionId = object.params.sessionId; - const session = new CDPCDPSession( + const session = new CdpCDPSession( this, object.params.targetInfo.type, sessionId, diff --git a/packages/puppeteer-core/src/common/Dialog.ts b/packages/puppeteer-core/src/common/Dialog.ts index 68a239a3579..5404ace44b4 100644 --- a/packages/puppeteer-core/src/common/Dialog.ts +++ b/packages/puppeteer-core/src/common/Dialog.ts @@ -22,7 +22,7 @@ import {Dialog} from '../api/Dialog.js'; /** * @internal */ -export class CDPDialog extends Dialog { +export class CdpDialog extends Dialog { #client: CDPSession; constructor( diff --git a/packages/puppeteer-core/src/common/ElementHandle.ts b/packages/puppeteer-core/src/common/ElementHandle.ts index 3bceb5a7000..9c6f2baa001 100644 --- a/packages/puppeteer-core/src/common/ElementHandle.ts +++ b/packages/puppeteer-core/src/common/ElementHandle.ts @@ -22,29 +22,29 @@ import {Page, ScreenshotOptions} from '../api/Page.js'; import {assert} from '../util/assert.js'; import {throwIfDisposed} from '../util/decorators.js'; -import {CDPFrame} from './Frame.js'; +import {CdpFrame} from './Frame.js'; import {FrameManager} from './FrameManager.js'; import {IsolatedWorld} from './IsolatedWorld.js'; -import {CDPJSHandle} from './JSHandle.js'; +import {CdpJSHandle} from './JSHandle.js'; import {debugError} from './util.js'; /** - * The CDPElementHandle extends ElementHandle now to keep compatibility + * The CdpElementHandle extends ElementHandle now to keep compatibility * with `instanceof` because of that we need to have methods for - * CDPJSHandle to in this implementation as well. + * CdpJSHandle to in this implementation as well. * * @internal */ -export class CDPElementHandle< +export class CdpElementHandle< ElementType extends Node = Element, > extends ElementHandle { - protected declare readonly handle: CDPJSHandle; + protected declare readonly handle: CdpJSHandle; constructor( world: IsolatedWorld, remoteObject: Protocol.Runtime.RemoteObject ) { - super(new CDPJSHandle(world, remoteObject)); + super(new CdpJSHandle(world, remoteObject)); } override get realm(): IsolatedWorld { @@ -67,16 +67,16 @@ export class CDPElementHandle< return this.frame.page(); } - override get frame(): CDPFrame { - return this.realm.environment as CDPFrame; + override get frame(): CdpFrame { + return this.realm.environment as CdpFrame; } override async contentFrame( this: ElementHandle - ): Promise; + ): Promise; @throwIfDisposed() - override async contentFrame(): Promise { + override async contentFrame(): Promise { const nodeInfo = await this.client.send('DOM.describeNode', { objectId: this.id, }); @@ -89,7 +89,7 @@ export class CDPElementHandle< @throwIfDisposed() @ElementHandle.bindIsolatedHandle override async scrollIntoView( - this: CDPElementHandle + this: CdpElementHandle ): Promise { await this.assertConnectedElement(); try { @@ -109,7 +109,7 @@ export class CDPElementHandle< @throwIfDisposed() @ElementHandle.bindIsolatedHandle override async drag( - this: CDPElementHandle, + this: CdpElementHandle, target: Point ): Promise { assert( @@ -124,7 +124,7 @@ export class CDPElementHandle< @throwIfDisposed() @ElementHandle.bindIsolatedHandle override async dragEnter( - this: CDPElementHandle, + this: CdpElementHandle, data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1} ): Promise { await this.scrollIntoViewIfNeeded(); @@ -135,7 +135,7 @@ export class CDPElementHandle< @throwIfDisposed() @ElementHandle.bindIsolatedHandle override async dragOver( - this: CDPElementHandle, + this: CdpElementHandle, data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1} ): Promise { await this.scrollIntoViewIfNeeded(); @@ -146,7 +146,7 @@ export class CDPElementHandle< @throwIfDisposed() @ElementHandle.bindIsolatedHandle override async drop( - this: CDPElementHandle, + this: CdpElementHandle, data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1} ): Promise { await this.scrollIntoViewIfNeeded(); @@ -157,8 +157,8 @@ export class CDPElementHandle< @throwIfDisposed() @ElementHandle.bindIsolatedHandle override async dragAndDrop( - this: CDPElementHandle, - target: CDPElementHandle, + this: CdpElementHandle, + target: CdpElementHandle, options?: {delay: number} ): Promise { assert( @@ -174,7 +174,7 @@ export class CDPElementHandle< @throwIfDisposed() @ElementHandle.bindIsolatedHandle override async uploadFile( - this: CDPElementHandle, + this: CdpElementHandle, ...filePaths: string[] ): Promise { const isMultiple = await this.evaluate(element => { @@ -233,7 +233,7 @@ export class CDPElementHandle< @throwIfDisposed() @ElementHandle.bindIsolatedHandle override async screenshot( - this: CDPElementHandle, + this: CdpElementHandle, options: ScreenshotOptions = {} ): Promise { let needsViewportReset = false; diff --git a/packages/puppeteer-core/src/common/ExecutionContext.ts b/packages/puppeteer-core/src/common/ExecutionContext.ts index 859f31be903..feb64620769 100644 --- a/packages/puppeteer-core/src/common/ExecutionContext.ts +++ b/packages/puppeteer-core/src/common/ExecutionContext.ts @@ -25,9 +25,9 @@ import {stringifyFunction} from '../util/Function.js'; import {ARIAQueryHandler} from './AriaQueryHandler.js'; import {Binding} from './Binding.js'; -import {CDPElementHandle} from './ElementHandle.js'; +import {CdpElementHandle} from './ElementHandle.js'; import {IsolatedWorld} from './IsolatedWorld.js'; -import {CDPJSHandle} from './JSHandle.js'; +import {CdpJSHandle} from './JSHandle.js'; import {LazyArg} from './LazyArg.js'; import {scriptInjector} from './ScriptInjector.js'; import {EvaluateFunc, HandleFor} from './types.js'; @@ -345,7 +345,7 @@ export class ExecutionContext { return {unserializableValue: 'NaN'}; } const objectHandle = - arg && (arg instanceof CDPJSHandle || arg instanceof CDPElementHandle) + arg && (arg instanceof CdpJSHandle || arg instanceof CdpElementHandle) ? arg : null; if (objectHandle) { diff --git a/packages/puppeteer-core/src/common/FirefoxTargetManager.ts b/packages/puppeteer-core/src/common/FirefoxTargetManager.ts index 226480a2068..fb3cc5afc74 100644 --- a/packages/puppeteer-core/src/common/FirefoxTargetManager.ts +++ b/packages/puppeteer-core/src/common/FirefoxTargetManager.ts @@ -23,7 +23,7 @@ import {Deferred} from '../util/Deferred.js'; import {Connection} from './Connection.js'; import {EventEmitter} from './EventEmitter.js'; -import {CDPTarget} from './Target.js'; +import {CdpTarget} from './Target.js'; import { TargetFactory, TargetManagerEvent, @@ -67,11 +67,11 @@ export class FirefoxTargetManager * * The target is removed from here once it's been destroyed. */ - #availableTargetsByTargetId = new Map(); + #availableTargetsByTargetId = new Map(); /** * Tracks which sessions attach to which target. */ - #availableTargetsBySessionId = new Map(); + #availableTargetsBySessionId = new Map(); /** * If a target was filtered out by `targetFilterCallback`, we still receive * events about it from CDP, but we don't forward them to the rest of Puppeteer. @@ -131,7 +131,7 @@ export class FirefoxTargetManager } } - getAvailableTargets(): Map { + getAvailableTargets(): Map { return this.#availableTargetsByTargetId; } diff --git a/packages/puppeteer-core/src/common/Frame.ts b/packages/puppeteer-core/src/common/Frame.ts index 83ca8ac906a..5a030e300f8 100644 --- a/packages/puppeteer-core/src/common/Frame.ts +++ b/packages/puppeteer-core/src/common/Frame.ts @@ -37,7 +37,7 @@ import {setPageContent} from './util.js'; /** * @internal */ -export class CDPFrame extends Frame { +export class CdpFrame extends Frame { #url = ''; #detached = false; #client!: CDPSession; @@ -270,11 +270,11 @@ export class CDPFrame extends Frame { return this.#url; } - override parentFrame(): CDPFrame | null { + override parentFrame(): CdpFrame | null { return this._frameManager._frameTree.parentFrame(this._id) || null; } - override childFrames(): CDPFrame[] { + override childFrames(): CdpFrame[] { return this._frameManager._frameTree.childFrames(this._id); } diff --git a/packages/puppeteer-core/src/common/FrameManager.ts b/packages/puppeteer-core/src/common/FrameManager.ts index 701618b453a..fbb3fcd765d 100644 --- a/packages/puppeteer-core/src/common/FrameManager.ts +++ b/packages/puppeteer-core/src/common/FrameManager.ts @@ -23,17 +23,17 @@ import {assert} from '../util/assert.js'; import {Deferred} from '../util/Deferred.js'; import {isErrorLike} from '../util/ErrorLike.js'; -import {CDPCDPSession} from './CDPSession.js'; +import {CdpCDPSession} from './CDPSession.js'; import {isTargetClosedError} from './Connection.js'; import {DeviceRequestPromptManager} from './DeviceRequestPrompt.js'; import {EventEmitter, EventType} from './EventEmitter.js'; import {ExecutionContext} from './ExecutionContext.js'; -import {CDPFrame} from './Frame.js'; +import {CdpFrame} from './Frame.js'; import {FrameTree} from './FrameTree.js'; import {IsolatedWorld} from './IsolatedWorld.js'; import {MAIN_WORLD, PUPPETEER_WORLD} from './IsolatedWorlds.js'; import {NetworkManager} from './NetworkManager.js'; -import {CDPTarget} from './Target.js'; +import {CdpTarget} from './Target.js'; import {TimeoutSettings} from './TimeoutSettings.js'; import {debugError, PuppeteerURL} from './util.js'; @@ -65,12 +65,12 @@ export namespace FrameManagerEvent { */ export interface FrameManagerEvents extends Record { - [FrameManagerEvent.FrameAttached]: CDPFrame; - [FrameManagerEvent.FrameNavigated]: CDPFrame; - [FrameManagerEvent.FrameDetached]: CDPFrame; - [FrameManagerEvent.FrameSwapped]: CDPFrame; - [FrameManagerEvent.LifecycleEvent]: CDPFrame; - [FrameManagerEvent.FrameNavigatedWithinDocument]: CDPFrame; + [FrameManagerEvent.FrameAttached]: CdpFrame; + [FrameManagerEvent.FrameNavigated]: CdpFrame; + [FrameManagerEvent.FrameDetached]: CdpFrame; + [FrameManagerEvent.FrameSwapped]: CdpFrame; + [FrameManagerEvent.LifecycleEvent]: CdpFrame; + [FrameManagerEvent.FrameNavigatedWithinDocument]: CdpFrame; } const TIME_FOR_WAITING_FOR_SWAP = 100; // ms. @@ -88,7 +88,7 @@ export class FrameManager extends EventEmitter { #isolatedWorlds = new Set(); #client: CDPSession; - _frameTree = new FrameTree(); + _frameTree = new FrameTree(); /** * Set of frame IDs stored to indicate if a frame has received a @@ -168,7 +168,7 @@ export class FrameManager extends EventEmitter { this.#client = client; assert( - this.#client instanceof CDPCDPSession, + this.#client instanceof CdpCDPSession, 'CDPSession is not an instance of CDPSessionImpl.' ); const frame = this._frameTree.getMainFrame(); @@ -192,7 +192,7 @@ export class FrameManager extends EventEmitter { } } - async registerSpeculativeSession(client: CDPCDPSession): Promise { + async registerSpeculativeSession(client: CdpCDPSession): Promise { await this.#networkManager.addClient(client); } @@ -279,21 +279,21 @@ export class FrameManager extends EventEmitter { return this.#page; } - mainFrame(): CDPFrame { + mainFrame(): CdpFrame { const mainFrame = this._frameTree.getMainFrame(); assert(mainFrame, 'Requesting main frame too early!'); return mainFrame; } - frames(): CDPFrame[] { + frames(): CdpFrame[] { return Array.from(this._frameTree.frames()); } - frame(frameId: string): CDPFrame | null { + frame(frameId: string): CdpFrame | null { return this._frameTree.getById(frameId) || null; } - onAttachedToTarget(target: CDPTarget): void { + onAttachedToTarget(target: CdpTarget): void { if (target._getTargetInfo().type !== 'iframe') { return; } @@ -385,7 +385,7 @@ export class FrameManager extends EventEmitter { return; } - frame = new CDPFrame(this, frameId, parentFrameId, session); + frame = new CdpFrame(this, frameId, parentFrameId, session); this._frameTree.addFrame(frame); this.emit(FrameManagerEvent.FrameAttached, frame); } @@ -414,7 +414,7 @@ export class FrameManager extends EventEmitter { frame._id = frameId; } else { // Initial main frame navigation. - frame = new CDPFrame(this, frameId, undefined, this.#client); + frame = new CdpFrame(this, frameId, undefined, this.#client); } this._frameTree.addFrame(frame); } @@ -562,7 +562,7 @@ export class FrameManager extends EventEmitter { } } - #removeFramesRecursively(frame: CDPFrame): void { + #removeFramesRecursively(frame: CdpFrame): void { for (const child of frame.childFrames()) { this.#removeFramesRecursively(child); } diff --git a/packages/puppeteer-core/src/common/HTTPRequest.ts b/packages/puppeteer-core/src/common/HTTPRequest.ts index d4adf3f53ff..58dae7f4a73 100644 --- a/packages/puppeteer-core/src/common/HTTPRequest.ts +++ b/packages/puppeteer-core/src/common/HTTPRequest.ts @@ -37,13 +37,13 @@ import {debugError, isString} from './util.js'; /** * @internal */ -export class CDPHTTPRequest extends HTTPRequest { +export class CdpHTTPRequest extends HTTPRequest { override _requestId: string; override _interceptionId: string | undefined; override _failureText: string | null = null; override _response: HTTPResponse | null = null; override _fromMemoryCache = false; - override _redirectChain: CDPHTTPRequest[]; + override _redirectChain: CdpHTTPRequest[]; #client: CDPSession; #isNavigationRequest: boolean; @@ -100,7 +100,7 @@ export class CDPHTTPRequest extends HTTPRequest { */ type?: Protocol.Network.ResourceType; }, - redirectChain: CDPHTTPRequest[] + redirectChain: CdpHTTPRequest[] ) { super(); this.#client = client; @@ -213,7 +213,7 @@ export class CDPHTTPRequest extends HTTPRequest { return this.#initiator; } - override redirectChain(): CDPHTTPRequest[] { + override redirectChain(): CdpHTTPRequest[] { return this._redirectChain.slice(); } diff --git a/packages/puppeteer-core/src/common/HTTPResponse.ts b/packages/puppeteer-core/src/common/HTTPResponse.ts index 1d7f5fc23da..fff7c21da78 100644 --- a/packages/puppeteer-core/src/common/HTTPResponse.ts +++ b/packages/puppeteer-core/src/common/HTTPResponse.ts @@ -21,15 +21,15 @@ import {HTTPResponse, RemoteAddress} from '../api/HTTPResponse.js'; import {Deferred} from '../util/Deferred.js'; import {ProtocolError} from './Errors.js'; -import {CDPHTTPRequest} from './HTTPRequest.js'; +import {CdpHTTPRequest} from './HTTPRequest.js'; import {SecurityDetails} from './SecurityDetails.js'; /** * @internal */ -export class CDPHTTPResponse extends HTTPResponse { +export class CdpHTTPResponse extends HTTPResponse { #client: CDPSession; - #request: CDPHTTPRequest; + #request: CdpHTTPRequest; #contentPromise: Promise | null = null; #bodyLoadedDeferred = Deferred.create(); #remoteAddress: RemoteAddress; @@ -44,7 +44,7 @@ export class CDPHTTPResponse extends HTTPResponse { constructor( client: CDPSession, - request: CDPHTTPRequest, + request: CdpHTTPRequest, responsePayload: Protocol.Network.Response, extraInfo: Protocol.Network.ResponseReceivedExtraInfoEvent | null ) { @@ -168,7 +168,7 @@ export class CDPHTTPResponse extends HTTPResponse { return this.#contentPromise; } - override request(): CDPHTTPRequest { + override request(): CdpHTTPRequest { return this.#request; } diff --git a/packages/puppeteer-core/src/common/Input.ts b/packages/puppeteer-core/src/common/Input.ts index ed173ad7525..9f37927a9d4 100644 --- a/packages/puppeteer-core/src/common/Input.ts +++ b/packages/puppeteer-core/src/common/Input.ts @@ -42,7 +42,7 @@ type KeyDescription = Required< /** * @internal */ -export class CDPKeyboard extends Keyboard { +export class CdpKeyboard extends Keyboard { #client: CDPSession; #pressedKeys = new Set(); @@ -275,11 +275,11 @@ interface MouseState { /** * @internal */ -export class CDPMouse extends Mouse { +export class CdpMouse extends Mouse { #client: CDPSession; - #keyboard: CDPKeyboard; + #keyboard: CdpKeyboard; - constructor(client: CDPSession, keyboard: CDPKeyboard) { + constructor(client: CDPSession, keyboard: CdpKeyboard) { super(); this.#client = client; this.#keyboard = keyboard; @@ -557,11 +557,11 @@ export class CDPMouse extends Mouse { /** * @internal */ -export class CDPTouchscreen extends Touchscreen { +export class CdpTouchscreen extends Touchscreen { #client: CDPSession; - #keyboard: CDPKeyboard; + #keyboard: CdpKeyboard; - constructor(client: CDPSession, keyboard: CDPKeyboard) { + constructor(client: CDPSession, keyboard: CdpKeyboard) { super(); this.#client = client; this.#keyboard = keyboard; diff --git a/packages/puppeteer-core/src/common/IsolatedWorld.ts b/packages/puppeteer-core/src/common/IsolatedWorld.ts index 30ac9077b4c..903fa3d2c4f 100644 --- a/packages/puppeteer-core/src/common/IsolatedWorld.ts +++ b/packages/puppeteer-core/src/common/IsolatedWorld.ts @@ -23,7 +23,7 @@ import {Deferred} from '../util/Deferred.js'; import {Binding} from './Binding.js'; import {ExecutionContext} from './ExecutionContext.js'; -import {CDPFrame} from './Frame.js'; +import {CdpFrame} from './Frame.js'; import {MAIN_WORLD, PUPPETEER_WORLD} from './IsolatedWorlds.js'; import {TimeoutSettings} from './TimeoutSettings.js'; import {BindingPayload, EvaluateFunc, HandleFor} from './types.js'; @@ -101,10 +101,10 @@ export class IsolatedWorld extends Realm { return this.#bindings; } - readonly #frameOrWorker: CDPFrame | WebWorker; + readonly #frameOrWorker: CdpFrame | WebWorker; constructor( - frameOrWorker: CDPFrame | WebWorker, + frameOrWorker: CdpFrame | WebWorker, timeoutSettings: TimeoutSettings ) { super(timeoutSettings); @@ -112,7 +112,7 @@ export class IsolatedWorld extends Realm { this.frameUpdated(); } - get environment(): CDPFrame | WebWorker { + get environment(): CdpFrame | WebWorker { return this.#frameOrWorker; } @@ -126,7 +126,7 @@ export class IsolatedWorld extends Realm { clearContext(): void { this.#context = Deferred.create(); - if (this.#frameOrWorker instanceof CDPFrame) { + if (this.#frameOrWorker instanceof CdpFrame) { this.#frameOrWorker.clearDocumentHandle(); } } diff --git a/packages/puppeteer-core/src/common/JSHandle.ts b/packages/puppeteer-core/src/common/JSHandle.ts index abeb0bfbe03..6b92ad0dbbc 100644 --- a/packages/puppeteer-core/src/common/JSHandle.ts +++ b/packages/puppeteer-core/src/common/JSHandle.ts @@ -19,14 +19,14 @@ import {Protocol} from 'devtools-protocol'; import {CDPSession} from '../api/CDPSession.js'; import {JSHandle} from '../api/JSHandle.js'; -import type {CDPElementHandle} from './ElementHandle.js'; +import type {CdpElementHandle} from './ElementHandle.js'; import {IsolatedWorld} from './IsolatedWorld.js'; import {releaseObject, valueFromRemoteObject} from './util.js'; /** * @internal */ -export class CDPJSHandle extends JSHandle { +export class CdpJSHandle extends JSHandle { #disposed = false; readonly #remoteObject: Protocol.Runtime.RemoteObject; readonly #world: IsolatedWorld; @@ -69,7 +69,7 @@ export class CDPJSHandle extends JSHandle { * Either `null` or the handle itself if the handle is an * instance of {@link ElementHandle}. */ - override asElement(): CDPElementHandle | null { + override asElement(): CdpElementHandle | null { return null; } diff --git a/packages/puppeteer-core/src/common/LifecycleWatcher.ts b/packages/puppeteer-core/src/common/LifecycleWatcher.ts index cce245eb901..af212e8d861 100644 --- a/packages/puppeteer-core/src/common/LifecycleWatcher.ts +++ b/packages/puppeteer-core/src/common/LifecycleWatcher.ts @@ -23,9 +23,9 @@ import {Deferred} from '../util/Deferred.js'; import {TimeoutError} from './Errors.js'; import {EventSubscription} from './EventEmitter.js'; -import {CDPFrame} from './Frame.js'; +import {CdpFrame} from './Frame.js'; import {FrameManagerEvent} from './FrameManager.js'; -import {CDPHTTPRequest} from './HTTPRequest.js'; +import {CdpHTTPRequest} from './HTTPRequest.js'; import {NetworkManager, NetworkManagerEvent} from './NetworkManager.js'; /** * @public @@ -60,9 +60,9 @@ const puppeteerToProtocolLifecycle = new Map< */ export class LifecycleWatcher { #expectedLifecycle: ProtocolLifeCycleEvent[]; - #frame: CDPFrame; + #frame: CdpFrame; #timeout: number; - #navigationRequest: CDPHTTPRequest | null = null; + #navigationRequest: CdpHTTPRequest | null = null; #subscriptions = new DisposableStack(); #initialLoaderId: string; @@ -78,7 +78,7 @@ export class LifecycleWatcher { constructor( networkManager: NetworkManager, - frame: CDPFrame, + frame: CdpFrame, waitUntil: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[], timeout: number ) { @@ -168,7 +168,7 @@ export class LifecycleWatcher { this.#checkLifecycleComplete(); } - #onRequest(request: CDPHTTPRequest): void { + #onRequest(request: CdpHTTPRequest): void { if (request.frame() !== this.#frame || !request.isNavigationRequest()) { return; } @@ -183,7 +183,7 @@ export class LifecycleWatcher { } } - #onRequestFailed(request: CDPHTTPRequest): void { + #onRequestFailed(request: CdpHTTPRequest): void { if (this.#navigationRequest?._requestId !== request._requestId) { return; } @@ -260,7 +260,7 @@ export class LifecycleWatcher { } function checkLifecycle( - frame: CDPFrame, + frame: CdpFrame, expectedLifecycle: ProtocolLifeCycleEvent[] ): boolean { for (const event of expectedLifecycle) { diff --git a/packages/puppeteer-core/src/common/NetworkEventManager.ts b/packages/puppeteer-core/src/common/NetworkEventManager.ts index f5798c19766..112877e9730 100644 --- a/packages/puppeteer-core/src/common/NetworkEventManager.ts +++ b/packages/puppeteer-core/src/common/NetworkEventManager.ts @@ -16,7 +16,7 @@ import {Protocol} from 'devtools-protocol'; -import {CDPHTTPRequest} from './HTTPRequest.js'; +import {CdpHTTPRequest} from './HTTPRequest.js'; /** * @internal @@ -92,7 +92,7 @@ export class NetworkEventManager { NetworkRequestId, Protocol.Fetch.RequestPausedEvent >(); - #httpRequestsMap = new Map(); + #httpRequestsMap = new Map(); /* * The below maps are used to reconcile Network.responseReceivedExtraInfo @@ -193,13 +193,13 @@ export class NetworkEventManager { this.#requestPausedMap.set(networkRequestId, event); } - getRequest(networkRequestId: NetworkRequestId): CDPHTTPRequest | undefined { + getRequest(networkRequestId: NetworkRequestId): CdpHTTPRequest | undefined { return this.#httpRequestsMap.get(networkRequestId); } storeRequest( networkRequestId: NetworkRequestId, - request: CDPHTTPRequest + request: CdpHTTPRequest ): void { this.#httpRequestsMap.set(networkRequestId, request); } diff --git a/packages/puppeteer-core/src/common/NetworkManager.test.ts b/packages/puppeteer-core/src/common/NetworkManager.test.ts index a63652ce18a..82fae581d4c 100644 --- a/packages/puppeteer-core/src/common/NetworkManager.test.ts +++ b/packages/puppeteer-core/src/common/NetworkManager.test.ts @@ -23,7 +23,7 @@ import {HTTPRequest} from '../api/HTTPRequest.js'; import {HTTPResponse} from '../api/HTTPResponse.js'; import {EventEmitter} from './EventEmitter.js'; -import {CDPFrame} from './Frame.js'; +import {CdpFrame} from './Frame.js'; import {NetworkManager, NetworkManagerEvent} from './NetworkManager.js'; // TODO: develop a helper to generate fake network events for attributes that @@ -47,7 +47,7 @@ describe('NetworkManager', () => { it('should process extra info on multiple redirects', async () => { const mockCDPSession = new MockCDPSession(); const manager = new NetworkManager(true, { - frame(): CDPFrame | null { + frame(): CdpFrame | null { return null; }, }); @@ -483,7 +483,7 @@ describe('NetworkManager', () => { it(`should handle "double pause" (crbug.com/1196004) Fetch.requestPaused events for the same Network.requestWillBeSent event`, async () => { const mockCDPSession = new MockCDPSession(); const manager = new NetworkManager(true, { - frame(): CDPFrame | null { + frame(): CdpFrame | null { return null; }, }); @@ -567,7 +567,7 @@ describe('NetworkManager', () => { it(`should handle Network.responseReceivedExtraInfo event after Network.responseReceived event (github.com/puppeteer/puppeteer/issues/8234)`, async () => { const mockCDPSession = new MockCDPSession(); const manager = new NetworkManager(true, { - frame(): CDPFrame | null { + frame(): CdpFrame | null { return null; }, }); @@ -683,7 +683,7 @@ describe('NetworkManager', () => { it(`should resolve the response once the late responseReceivedExtraInfo event arrives`, async () => { const mockCDPSession = new MockCDPSession(); const manager = new NetworkManager(true, { - frame(): CDPFrame | null { + frame(): CdpFrame | null { return null; }, }); @@ -833,7 +833,7 @@ describe('NetworkManager', () => { it(`should send responses for iframe that don't receive loadingFinished event`, async () => { const mockCDPSession = new MockCDPSession(); const manager = new NetworkManager(true, { - frame(): CDPFrame | null { + frame(): CdpFrame | null { return null; }, }); @@ -995,7 +995,7 @@ describe('NetworkManager', () => { it(`should send responses for iframe that don't receive loadingFinished event`, async () => { const mockCDPSession = new MockCDPSession(); const manager = new NetworkManager(true, { - frame(): CDPFrame | null { + frame(): CdpFrame | null { return null; }, }); @@ -1139,7 +1139,7 @@ describe('NetworkManager', () => { it(`should handle cached redirects`, async () => { const mockCDPSession = new MockCDPSession(); const manager = new NetworkManager(true, { - frame(): CDPFrame | null { + frame(): CdpFrame | null { return null; }, }); diff --git a/packages/puppeteer-core/src/common/NetworkManager.ts b/packages/puppeteer-core/src/common/NetworkManager.ts index a97d6e5022b..b7a8d0a4208 100644 --- a/packages/puppeteer-core/src/common/NetworkManager.ts +++ b/packages/puppeteer-core/src/common/NetworkManager.ts @@ -21,8 +21,8 @@ import type {Frame} from '../api/Frame.js'; import {assert} from '../util/assert.js'; import {EventEmitter, EventSubscription, EventType} from './EventEmitter.js'; -import {CDPHTTPRequest} from './HTTPRequest.js'; -import {CDPHTTPResponse} from './HTTPResponse.js'; +import {CdpHTTPRequest} from './HTTPRequest.js'; +import {CdpHTTPResponse} from './HTTPResponse.js'; import {FetchRequestId, NetworkEventManager} from './NetworkEventManager.js'; import {debugError, isString} from './util.js'; @@ -73,11 +73,11 @@ export namespace NetworkManagerEvent { * @internal */ export interface NetworkManagerEvents extends Record { - [NetworkManagerEvent.Request]: CDPHTTPRequest; - [NetworkManagerEvent.RequestServedFromCache]: CDPHTTPRequest | undefined; - [NetworkManagerEvent.Response]: CDPHTTPResponse; - [NetworkManagerEvent.RequestFailed]: CDPHTTPRequest; - [NetworkManagerEvent.RequestFinished]: CDPHTTPRequest; + [NetworkManagerEvent.Request]: CdpHTTPRequest; + [NetworkManagerEvent.RequestServedFromCache]: CdpHTTPRequest | undefined; + [NetworkManagerEvent.Response]: CdpHTTPResponse; + [NetworkManagerEvent.RequestFailed]: CdpHTTPRequest; + [NetworkManagerEvent.RequestFinished]: CdpHTTPRequest; } /** @@ -452,7 +452,7 @@ export class NetworkManager extends EventEmitter { ? this.#frameManager.frame(event.frameId) : null; - const request = new CDPHTTPRequest( + const request = new CdpHTTPRequest( client, frame, event.requestId, @@ -469,7 +469,7 @@ export class NetworkManager extends EventEmitter { event: Protocol.Network.RequestWillBeSentEvent, fetchRequestId?: FetchRequestId ): void { - let redirectChain: CDPHTTPRequest[] = []; + let redirectChain: CdpHTTPRequest[] = []; if (event.redirectResponse) { // We want to emit a response and requestfinished for the // redirectResponse, but we can't do so unless we have a @@ -509,7 +509,7 @@ export class NetworkManager extends EventEmitter { ? this.#frameManager.frame(event.frameId) : null; - const request = new CDPHTTPRequest( + const request = new CdpHTTPRequest( client, frame, fetchRequestId, @@ -535,11 +535,11 @@ export class NetworkManager extends EventEmitter { #handleRequestRedirect( client: CDPSession, - request: CDPHTTPRequest, + request: CdpHTTPRequest, responsePayload: Protocol.Network.Response, extraInfo: Protocol.Network.ResponseReceivedExtraInfoEvent | null ): void { - const response = new CDPHTTPResponse( + const response = new CdpHTTPResponse( client, request, responsePayload, @@ -587,7 +587,7 @@ export class NetworkManager extends EventEmitter { extraInfo = null; } - const response = new CDPHTTPResponse( + const response = new CdpHTTPResponse( client, request, responseReceived.response, @@ -659,7 +659,7 @@ export class NetworkManager extends EventEmitter { this.#networkEventManager.responseExtraInfo(event.requestId).push(event); } - #forgetRequest(request: CDPHTTPRequest, events: boolean): void { + #forgetRequest(request: CdpHTTPRequest, events: boolean): void { const requestId = request._requestId; const interceptionId = request._interceptionId; diff --git a/packages/puppeteer-core/src/common/Page.ts b/packages/puppeteer-core/src/common/Page.ts index 313701a940c..110675230f4 100644 --- a/packages/puppeteer-core/src/common/Page.ts +++ b/packages/puppeteer-core/src/common/Page.ts @@ -44,18 +44,18 @@ import {isErrorLike} from '../util/ErrorLike.js'; import {Accessibility} from './Accessibility.js'; import {Binding} from './Binding.js'; -import {CDPCDPSession} from './CDPSession.js'; +import {CdpCDPSession} from './CDPSession.js'; import {isTargetClosedError} from './Connection.js'; import {ConsoleMessage, ConsoleMessageType} from './ConsoleMessage.js'; import {Coverage} from './Coverage.js'; import {DeviceRequestPrompt} from './DeviceRequestPrompt.js'; -import {CDPDialog} from './Dialog.js'; +import {CdpDialog} from './Dialog.js'; import {EmulationManager} from './EmulationManager.js'; import {TargetCloseError} from './Errors.js'; import {FileChooser} from './FileChooser.js'; -import {CDPFrame} from './Frame.js'; +import {CdpFrame} from './Frame.js'; import {FrameManager, FrameManagerEvent} from './FrameManager.js'; -import {CDPKeyboard, CDPMouse, CDPTouchscreen} from './Input.js'; +import {CdpKeyboard, CdpMouse, CdpTouchscreen} from './Input.js'; import {MAIN_WORLD} from './IsolatedWorlds.js'; import { Credentials, @@ -64,7 +64,7 @@ import { } from './NetworkManager.js'; import {PDFOptions} from './PDFOptions.js'; import {Viewport} from './PuppeteerViewport.js'; -import {CDPTarget} from './Target.js'; +import {CdpTarget} from './Target.js'; import {TargetManagerEvent} from './TargetManager.js'; import {TaskQueue} from './TaskQueue.js'; import {TimeoutSettings} from './TimeoutSettings.js'; @@ -90,15 +90,15 @@ import {WebWorker} from './WebWorker.js'; /** * @internal */ -export class CDPPage extends Page { +export class CdpPage extends Page { static async _create( client: CDPSession, - target: CDPTarget, + target: CdpTarget, ignoreHTTPSErrors: boolean, defaultViewport: Viewport | null, screenshotTaskQueue: TaskQueue - ): Promise { - const page = new CDPPage( + ): Promise { + const page = new CdpPage( client, target, ignoreHTTPSErrors, @@ -122,11 +122,11 @@ export class CDPPage extends Page { #closed = false; #client: CDPSession; #tabSession: CDPSession | undefined; - #target: CDPTarget; - #keyboard: CDPKeyboard; - #mouse: CDPMouse; + #target: CdpTarget; + #keyboard: CdpKeyboard; + #mouse: CdpMouse; #timeoutSettings = new TimeoutSettings(); - #touchscreen: CDPTouchscreen; + #touchscreen: CdpTouchscreen; #accessibility: Accessibility; #frameManager: FrameManager; #emulationManager: EmulationManager; @@ -145,19 +145,19 @@ export class CDPPage extends Page { #frameManagerHandlers = Object.freeze([ [ FrameManagerEvent.FrameAttached, - (frame: CDPFrame) => { + (frame: CdpFrame) => { this.emit(PageEvent.FrameAttached, frame); }, ], [ FrameManagerEvent.FrameDetached, - (frame: CDPFrame) => { + (frame: CdpFrame) => { this.emit(PageEvent.FrameDetached, frame); }, ], [ FrameManagerEvent.FrameNavigated, - (frame: CDPFrame) => { + (frame: CdpFrame) => { this.emit(PageEvent.FrameNavigated, frame); }, ], @@ -229,7 +229,7 @@ export class CDPPage extends Page { constructor( client: CDPSession, - target: CDPTarget, + target: CdpTarget, ignoreHTTPSErrors: boolean, screenshotTaskQueue: TaskQueue ) { @@ -237,9 +237,9 @@ export class CDPPage extends Page { this.#client = client; this.#tabSession = client.parentSession(); this.#target = target; - this.#keyboard = new CDPKeyboard(client); - this.#mouse = new CDPMouse(client, this.#keyboard); - this.#touchscreen = new CDPTouchscreen(client, this.#keyboard); + this.#keyboard = new CdpKeyboard(client); + this.#mouse = new CdpMouse(client, this.#keyboard); + this.#touchscreen = new CdpTouchscreen(client, this.#keyboard); this.#accessibility = new Accessibility(client); this.#frameManager = new FrameManager( client, @@ -258,7 +258,7 @@ export class CDPPage extends Page { this.#tabSession?.on(CDPSessionEvent.Swapped, async newSession => { this.#client = newSession; assert( - this.#client instanceof CDPCDPSession, + this.#client instanceof CdpCDPSession, 'CDPSession is not instance of CDPSessionImpl' ); this.#target = this.#client._target(); @@ -274,7 +274,7 @@ export class CDPPage extends Page { this.#setupEventListeners(); }); this.#tabSession?.on(CDPSessionEvent.Ready, session => { - assert(session instanceof CDPCDPSession); + assert(session instanceof CdpCDPSession); if (session._target()._subtype() !== 'prerender') { return; } @@ -321,7 +321,7 @@ export class CDPPage extends Page { .catch(debugError); } - #onDetachedFromTarget = (target: CDPTarget) => { + #onDetachedFromTarget = (target: CdpTarget) => { const sessionId = target._session()?.id(); const worker = this.#workers.get(sessionId!); if (!worker) { @@ -332,7 +332,7 @@ export class CDPPage extends Page { }; #onAttachedToTarget = (session: CDPSession) => { - assert(session instanceof CDPCDPSession); + assert(session instanceof CdpCDPSession); this.#frameManager.onAttachedToTarget(session._target()); if (session._target()._getTargetInfo().type === 'worker') { const worker = new WebWorker( @@ -433,7 +433,7 @@ export class CDPPage extends Page { return await this.#emulationManager.setGeolocation(options); } - override target(): CDPTarget { + override target(): CdpTarget { return this.#target; } @@ -464,15 +464,15 @@ export class CDPPage extends Page { } } - override mainFrame(): CDPFrame { + override mainFrame(): CdpFrame { return this.#frameManager.mainFrame(); } - override get keyboard(): CDPKeyboard { + override get keyboard(): CdpKeyboard { return this.#keyboard; } - override get touchscreen(): CDPTouchscreen { + override get touchscreen(): CdpTouchscreen { return this.#touchscreen; } @@ -851,7 +851,7 @@ export class CDPPage extends Page { #onDialog(event: Protocol.Page.JavascriptDialogOpeningEvent): void { const type = validateDialogType(event.type); - const dialog = new CDPDialog( + const dialog = new CdpDialog( this.#client, type, event.message, @@ -1315,7 +1315,7 @@ export class CDPPage extends Page { return this.#closed; } - override get mouse(): CDPMouse { + override get mouse(): CdpMouse { return this.#mouse; } diff --git a/packages/puppeteer-core/src/common/Puppeteer.ts b/packages/puppeteer-core/src/common/Puppeteer.ts index 068ec173f07..eb0ead6f704 100644 --- a/packages/puppeteer-core/src/common/Puppeteer.ts +++ b/packages/puppeteer-core/src/common/Puppeteer.ts @@ -18,7 +18,7 @@ import {Browser} from '../api/Browser.js'; import { BrowserConnectOptions, - _connectToCDPBrowser, + _connectToCdpBrowser, } from './BrowserConnector.js'; import {ConnectionTransport} from './ConnectionTransport.js'; import {CustomQueryHandler, customQueryHandlers} from './CustomQueryHandler.js'; @@ -142,6 +142,6 @@ export class Puppeteer { * @returns Promise which resolves to browser instance. */ connect(options: ConnectOptions): Promise { - return _connectToCDPBrowser(options); + return _connectToCdpBrowser(options); } } diff --git a/packages/puppeteer-core/src/common/Target.ts b/packages/puppeteer-core/src/common/Target.ts index 5c3a602eebf..50480de9201 100644 --- a/packages/puppeteer-core/src/common/Target.ts +++ b/packages/puppeteer-core/src/common/Target.ts @@ -23,8 +23,8 @@ import {Page, PageEvent} from '../api/Page.js'; import {Target, TargetType} from '../api/Target.js'; import {Deferred} from '../util/Deferred.js'; -import {CDPCDPSession} from './CDPSession.js'; -import {CDPPage} from './Page.js'; +import {CdpCDPSession} from './CDPSession.js'; +import {CdpPage} from './Page.js'; import {Viewport} from './PuppeteerViewport.js'; import {TargetManager} from './TargetManager.js'; import {TaskQueue} from './TaskQueue.js'; @@ -42,7 +42,7 @@ export enum InitializationStatus { /** * @internal */ -export class CDPTarget extends Target { +export class CdpTarget extends Target { #browserContext?: BrowserContext; #session?: CDPSession; #targetInfo: Protocol.Target.TargetInfo; @@ -76,7 +76,7 @@ export class CDPTarget extends Target { this.#browserContext = browserContext; this._targetId = targetInfo.targetId; this.#sessionFactory = sessionFactory; - if (this.#session && this.#session instanceof CDPCDPSession) { + if (this.#session && this.#session instanceof CdpCDPSession) { this.#session._setTarget(this); } } @@ -103,7 +103,7 @@ export class CDPTarget extends Target { throw new Error('sessionFactory is not initialized'); } return this.#sessionFactory(false).then(session => { - (session as CDPCDPSession)._setTarget(this); + (session as CdpCDPSession)._setTarget(this); return session; }); } @@ -186,7 +186,7 @@ export class CDPTarget extends Target { /** * @internal */ -export class PageTarget extends CDPTarget { +export class PageTarget extends CdpTarget { #defaultViewport?: Viewport; protected pagePromise?: Promise; #screenshotTaskQueue: TaskQueue; @@ -242,7 +242,7 @@ export class PageTarget extends CDPTarget { ? Promise.resolve(session) : this._sessionFactory()(/* isAutoAttachEmulated=*/ false) ).then(client => { - return CDPPage._create( + return CdpPage._create( client, this, this.#ignoreHTTPSErrors, @@ -272,7 +272,7 @@ export class DevToolsTarget extends PageTarget {} /** * @internal */ -export class WorkerTarget extends CDPTarget { +export class WorkerTarget extends CdpTarget { #workerPromise?: Promise; override async worker(): Promise { @@ -299,4 +299,4 @@ export class WorkerTarget extends CDPTarget { /** * @internal */ -export class OtherTarget extends CDPTarget {} +export class OtherTarget extends CdpTarget {} diff --git a/packages/puppeteer-core/src/common/TargetManager.ts b/packages/puppeteer-core/src/common/TargetManager.ts index 867640b5ae8..64d4051732a 100644 --- a/packages/puppeteer-core/src/common/TargetManager.ts +++ b/packages/puppeteer-core/src/common/TargetManager.ts @@ -19,7 +19,7 @@ import {Protocol} from 'devtools-protocol'; import {CDPSession} from '../api/CDPSession.js'; import {EventEmitter, EventType} from './EventEmitter.js'; -import {CDPTarget} from './Target.js'; +import {CdpTarget} from './Target.js'; /** * @internal @@ -28,7 +28,7 @@ export type TargetFactory = ( targetInfo: Protocol.Target.TargetInfo, session?: CDPSession, parentSession?: CDPSession -) => CDPTarget; +) => CdpTarget; /** * @internal @@ -47,11 +47,11 @@ export const enum TargetManagerEvent { * @internal */ export interface TargetManagerEvents extends Record { - [TargetManagerEvent.TargetAvailable]: CDPTarget; + [TargetManagerEvent.TargetAvailable]: CdpTarget; [TargetManagerEvent.TargetDiscovered]: Protocol.Target.TargetInfo; - [TargetManagerEvent.TargetGone]: CDPTarget; + [TargetManagerEvent.TargetGone]: CdpTarget; [TargetManagerEvent.TargetChanged]: { - target: CDPTarget; + target: CdpTarget; wasInitialized: true; previousURL: string; }; @@ -69,7 +69,7 @@ export interface TargetManagerEvents extends Record { * @internal */ export interface TargetManager extends EventEmitter { - getAvailableTargets(): Map; + getAvailableTargets(): Map; initialize(): Promise; dispose(): void; } diff --git a/packages/puppeteer-core/src/common/WebWorker.ts b/packages/puppeteer-core/src/common/WebWorker.ts index 3e0e204cc50..8ac97d3427c 100644 --- a/packages/puppeteer-core/src/common/WebWorker.ts +++ b/packages/puppeteer-core/src/common/WebWorker.ts @@ -22,7 +22,7 @@ import {ConsoleMessageType} from './ConsoleMessage.js'; import {EventEmitter, EventType} from './EventEmitter.js'; import {ExecutionContext} from './ExecutionContext.js'; import {IsolatedWorld} from './IsolatedWorld.js'; -import {CDPJSHandle} from './JSHandle.js'; +import {CdpJSHandle} from './JSHandle.js'; import {TimeoutSettings} from './TimeoutSettings.js'; import {EvaluateFunc, HandleFor} from './types.js'; import {debugError, withSourcePuppeteerURLIfNone} from './util.js'; @@ -32,7 +32,7 @@ import {debugError, withSourcePuppeteerURLIfNone} from './util.js'; */ export type ConsoleAPICalledCallback = ( eventType: ConsoleMessageType, - handles: CDPJSHandle[], + handles: CdpJSHandle[], trace?: Protocol.Runtime.StackTrace ) => void; @@ -103,7 +103,7 @@ export class WebWorker extends EventEmitter> { return consoleAPICalled( event.type, event.args.map((object: Protocol.Runtime.RemoteObject) => { - return new CDPJSHandle(this.#world, object); + return new CdpJSHandle(this.#world, object); }), event.stackTrace ); diff --git a/packages/puppeteer-core/src/common/bidi/BidiOverCDP.ts b/packages/puppeteer-core/src/common/bidi/BidiOverCdp.ts similarity index 92% rename from packages/puppeteer-core/src/common/bidi/BidiOverCDP.ts rename to packages/puppeteer-core/src/common/bidi/BidiOverCdp.ts index 5f2f8066666..d56cdc442bf 100644 --- a/packages/puppeteer-core/src/common/bidi/BidiOverCDP.ts +++ b/packages/puppeteer-core/src/common/bidi/BidiOverCdp.ts @@ -19,7 +19,7 @@ import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js'; import type {ProtocolMapping} from 'devtools-protocol/types/protocol-mapping.js'; import {CDPEvents, CDPSession} from '../../api/CDPSession.js'; -import {Connection as CDPConnection} from '../Connection.js'; +import {Connection as CdpConnection} from '../Connection.js'; import {TargetCloseError} from '../Errors.js'; import {Handler} from '../EventEmitter.js'; @@ -28,11 +28,11 @@ import {BidiConnection} from './Connection.js'; /** * @internal */ -export async function connectBidiOverCDP( - cdp: CDPConnection +export async function connectBidiOverCdp( + cdp: CdpConnection ): Promise { const transportBiDi = new NoOpTransport(); - const cdpConnectionAdapter = new CDPConnectionAdapter(cdp); + const cdpConnectionAdapter = new CdpConnectionAdapter(cdp); const pptrTransport = { send(message: string): void { // Forwards a BiDi command sent by Puppeteer to the input of the BidiServer. @@ -63,17 +63,17 @@ export async function connectBidiOverCDP( * Manages CDPSessions for BidiServer. * @internal */ -class CDPConnectionAdapter { - #cdp: CDPConnection; +class CdpConnectionAdapter { + #cdp: CdpConnection; #adapters = new Map>(); - #browser: CDPClientAdapter; + #browser: CDPClientAdapter; - constructor(cdp: CDPConnection) { + constructor(cdp: CdpConnection) { this.#cdp = cdp; this.#browser = new CDPClientAdapter(cdp); } - browserClient(): CDPClientAdapter { + browserClient(): CDPClientAdapter { return this.#browser; } @@ -104,7 +104,7 @@ class CDPConnectionAdapter { * * @internal */ -class CDPClientAdapter +class CDPClientAdapter extends BidiMapper.EventEmitter implements BidiMapper.CdpClient { diff --git a/packages/puppeteer-core/src/common/bidi/BrowsingContext.ts b/packages/puppeteer-core/src/common/bidi/BrowsingContext.ts index d971f258c2a..628d601901a 100644 --- a/packages/puppeteer-core/src/common/bidi/BrowsingContext.ts +++ b/packages/puppeteer-core/src/common/bidi/BrowsingContext.ts @@ -5,7 +5,7 @@ import {CDPSession} from '../../api/CDPSession.js'; import {WaitForOptions} from '../../api/Page.js'; import {assert} from '../../util/assert.js'; import {Deferred} from '../../util/Deferred.js'; -import {Connection as CDPConnection} from '../Connection.js'; +import {Connection as CdpConnection} from '../Connection.js'; import {ProtocolError, TargetCloseError, TimeoutError} from '../Errors.js'; import {EventType} from '../EventEmitter.js'; import {PuppeteerLifeCycleEvent} from '../LifecycleWatcher.js'; @@ -40,12 +40,12 @@ const lifeCycleToReadinessState = new Map< /** * @internal */ -export const cdpSessions = new Map(); +export const cdpSessions = new Map(); /** * @internal */ -export class CDPSessionWrapper extends CDPSession { +export class CdpSessionWrapper extends CDPSession { #context: BrowsingContext; #sessionId = Deferred.create(); #detached = false; @@ -53,7 +53,7 @@ export class CDPSessionWrapper extends CDPSession { constructor(context: BrowsingContext, sessionId?: string) { super(); this.#context = context; - if (!this.#context.supportsCDP()) { + if (!this.#context.supportsCdp()) { return; } if (sessionId) { @@ -74,7 +74,7 @@ export class CDPSessionWrapper extends CDPSession { } } - override connection(): CDPConnection | undefined { + override connection(): CdpConnection | undefined { return undefined; } @@ -82,7 +82,7 @@ export class CDPSessionWrapper extends CDPSession { method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType'] ): Promise { - if (!this.#context.supportsCDP()) { + if (!this.#context.supportsCdp()) { throw new Error( 'CDP support is required for this feature. The current browser does not support CDP.' ); @@ -103,7 +103,7 @@ export class CDPSessionWrapper extends CDPSession { override async detach(): Promise { cdpSessions.delete(this.id()); - if (!this.#detached && this.#context.supportsCDP()) { + if (!this.#detached && this.#context.supportsCdp()) { await this.#context.cdpSession.send('Target.detachFromTarget', { sessionId: this.id(), }); @@ -163,14 +163,14 @@ export class BrowsingContext extends Realm { this.#url = info.url; this.#parent = info.parent; this.#browserName = browserName; - this.#cdpSession = new CDPSessionWrapper(this, undefined); + this.#cdpSession = new CdpSessionWrapper(this, undefined); this.on('browsingContext.domContentLoaded', this.#updateUrl.bind(this)); this.on('browsingContext.fragmentNavigated', this.#updateUrl.bind(this)); this.on('browsingContext.load', this.#updateUrl.bind(this)); } - supportsCDP(): boolean { + supportsCdp(): boolean { return !this.#browserName.toLowerCase().includes('firefox'); } @@ -280,7 +280,7 @@ export class BrowsingContext extends Realm { ]); } - async sendCDPCommand( + async sendCdpCommand( method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType'] ): Promise { diff --git a/packages/puppeteer-core/src/common/bidi/Connection.ts b/packages/puppeteer-core/src/common/bidi/Connection.ts index 34d5b34eef3..b8876e2521c 100644 --- a/packages/puppeteer-core/src/common/bidi/Connection.ts +++ b/packages/puppeteer-core/src/common/bidi/Connection.ts @@ -235,7 +235,7 @@ export class BidiConnection extends EventEmitter { event.params.source.context !== undefined ) { context = this.#browsingContexts.get(event.params.source.context); - } else if (isCDPEvent(event)) { + } else if (isCdpEvent(event)) { cdpSessions .get(event.params.session) ?.emit(event.params.event, event.params.params); @@ -301,6 +301,6 @@ function createProtocolError(object: Bidi.ErrorResponse): string { return message; } -function isCDPEvent(event: Bidi.ChromiumBidi.Event): event is Bidi.Cdp.Event { +function isCdpEvent(event: Bidi.ChromiumBidi.Event): event is Bidi.Cdp.Event { return event.method.startsWith('cdp.'); } diff --git a/packages/puppeteer-core/src/common/bidi/Page.ts b/packages/puppeteer-core/src/common/bidi/Page.ts index 574d10f8b2a..af31fbfd0b6 100644 --- a/packages/puppeteer-core/src/common/bidi/Page.ts +++ b/packages/puppeteer-core/src/common/bidi/Page.ts @@ -34,7 +34,7 @@ import {Deferred} from '../../util/Deferred.js'; import {Accessibility} from '../Accessibility.js'; import {ConsoleMessage, ConsoleMessageLocation} from '../ConsoleMessage.js'; import {Coverage} from '../Coverage.js'; -import {EmulationManager as CDPEmulationManager} from '../EmulationManager.js'; +import {EmulationManager as CdpEmulationManager} from '../EmulationManager.js'; import {TargetCloseError} from '../Errors.js'; import {Handler} from '../EventEmitter.js'; import {FrameTree} from '../FrameTree.js'; @@ -58,7 +58,7 @@ import {BidiBrowserContext} from './BrowserContext.js'; import { BrowsingContext, BrowsingContextEvent, - CDPSessionWrapper, + CdpSessionWrapper, } from './BrowsingContext.js'; import {BidiConnection} from './Connection.js'; import {BidiDialog} from './Dialog.js'; @@ -134,7 +134,7 @@ export class BidiPage extends Page { ]); #tracing: Tracing; #coverage: Coverage; - #cdpEmulationManager: CDPEmulationManager; + #cdpEmulationManager: CdpEmulationManager; #emulationManager: EmulationManager; #mouse: Mouse; #touchscreen: Touchscreen; @@ -185,7 +185,7 @@ export class BidiPage extends Page { ); this.#tracing = new Tracing(this.mainFrame().context().cdpSession); this.#coverage = new Coverage(this.mainFrame().context().cdpSession); - this.#cdpEmulationManager = new CDPEmulationManager( + this.#cdpEmulationManager = new CdpEmulationManager( this.mainFrame().context().cdpSession ); this.#emulationManager = new EmulationManager(browsingContext); @@ -485,7 +485,7 @@ export class BidiPage extends Page { } override async setViewport(viewport: Viewport): Promise { - if (!this.#browsingContext.supportsCDP()) { + if (!this.#browsingContext.supportsCdp()) { await this.#emulationManager.emulateViewport(viewport); this.#viewport = viewport; return; @@ -658,7 +658,7 @@ export class BidiPage extends Page { targetId: this.mainFrame()._id, flatten: true, }); - return new CDPSessionWrapper(this.mainFrame().context(), sessionId); + return new CdpSessionWrapper(this.mainFrame().context(), sessionId); } override async bringToFront(): Promise { diff --git a/packages/puppeteer-core/src/common/bidi/Target.ts b/packages/puppeteer-core/src/common/bidi/Target.ts index 05e88d15642..03d1b47221f 100644 --- a/packages/puppeteer-core/src/common/bidi/Target.ts +++ b/packages/puppeteer-core/src/common/bidi/Target.ts @@ -20,7 +20,7 @@ import type {WebWorker} from '../WebWorker.js'; import {BidiBrowser} from './Browser.js'; import {BidiBrowserContext} from './BrowserContext.js'; -import {BrowsingContext, CDPSessionWrapper} from './BrowsingContext.js'; +import {BrowsingContext, CdpSessionWrapper} from './BrowsingContext.js'; import {BidiPage} from './Page.js'; /** @@ -95,7 +95,7 @@ export class BiDiBrowsingContextTarget extends BidiTarget { flatten: true, } ); - return new CDPSessionWrapper(this._browsingContext, sessionId); + return new CdpSessionWrapper(this._browsingContext, sessionId); } override type(): TargetType { diff --git a/packages/puppeteer-core/src/common/bidi/bidi.ts b/packages/puppeteer-core/src/common/bidi/bidi.ts index 9f809a2ea19..1b8b1a8d08f 100644 --- a/packages/puppeteer-core/src/common/bidi/bidi.ts +++ b/packages/puppeteer-core/src/common/bidi/bidi.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -export * from './BidiOverCDP.js'; +export * from './BidiOverCdp.js'; export * from './Browser.js'; export * from './BrowserContext.js'; export * from './Connection.js'; diff --git a/packages/puppeteer-core/src/common/util.ts b/packages/puppeteer-core/src/common/util.ts index 279a98cbecd..1d2d12451b4 100644 --- a/packages/puppeteer-core/src/common/util.ts +++ b/packages/puppeteer-core/src/common/util.ts @@ -29,11 +29,11 @@ import {Deferred} from '../util/Deferred.js'; import {isErrorLike} from '../util/ErrorLike.js'; import {debug} from './Debug.js'; -import {CDPElementHandle} from './ElementHandle.js'; +import {CdpElementHandle} from './ElementHandle.js'; import {TimeoutError} from './Errors.js'; import {EventSubscription} from './EventEmitter.js'; import {IsolatedWorld} from './IsolatedWorld.js'; -import {CDPJSHandle} from './JSHandle.js'; +import {CdpJSHandle} from './JSHandle.js'; import {Awaitable} from './types.js'; /** @@ -382,9 +382,9 @@ export function createCdpHandle( remoteObject: Protocol.Runtime.RemoteObject ): JSHandle | ElementHandle { if (remoteObject.subtype === 'node') { - return new CDPElementHandle(realm, remoteObject); + return new CdpElementHandle(realm, remoteObject); } - return new CDPJSHandle(realm, remoteObject); + return new CdpJSHandle(realm, remoteObject); } /** @@ -415,7 +415,7 @@ export function evaluationString( export function addPageBinding(type: string, name: string): void { // This is the CDP binding. // @ts-expect-error: In a different context. - const callCDP = globalThis[name]; + const callCdp = globalThis[name]; // We replace the CDP binding with a Puppeteer binding. Object.assign(globalThis, { @@ -430,7 +430,7 @@ export function addPageBinding(type: string, name: string): void { callPuppeteer.lastSeq = seq; callPuppeteer.args.set(seq, args); - callCDP( + callCdp( JSON.stringify({ type, name, diff --git a/packages/puppeteer-core/src/node/ProductLauncher.ts b/packages/puppeteer-core/src/node/ProductLauncher.ts index 18e7e651bc3..66b11c3a3d0 100644 --- a/packages/puppeteer-core/src/node/ProductLauncher.ts +++ b/packages/puppeteer-core/src/node/ProductLauncher.ts @@ -27,7 +27,7 @@ import { } from '@puppeteer/browsers'; import {Browser, BrowserCloseCallback} from '../api/Browser.js'; -import {CDPBrowser} from '../common/Browser.js'; +import {CdpBrowser} from '../common/Browser.js'; import {Connection} from '../common/Connection.js'; import {TimeoutError} from '../common/Errors.js'; import {NodeWebSocketTransport as WebSocketTransport} from '../common/NodeWebSocketTransport.js'; @@ -148,20 +148,20 @@ export class ProductLauncher { ); } else { if (usePipe) { - connection = await this.createCDPPipeConnection(browserProcess, { + connection = await this.createCdpPipeConnection(browserProcess, { timeout, protocolTimeout, slowMo, }); } else { - connection = await this.createCDPSocketConnection(browserProcess, { + connection = await this.createCdpSocketConnection(browserProcess, { timeout, protocolTimeout, slowMo, }); } if (protocol === 'webDriverBiDi') { - browser = await this.createBiDiOverCDPBrowser( + browser = await this.createBiDiOverCdpBrowser( browserProcess, connection, browserCloseCallback, @@ -174,7 +174,7 @@ export class ProductLauncher { } ); } else { - browser = await CDPBrowser._create( + browser = await CdpBrowser._create( this.product, connection, [], @@ -285,7 +285,7 @@ export class ProductLauncher { /** * @internal */ - protected async createCDPSocketConnection( + protected async createCdpSocketConnection( browserProcess: ReturnType, opts: {timeout: number; protocolTimeout: number | undefined; slowMo: number} ): Promise { @@ -305,7 +305,7 @@ export class ProductLauncher { /** * @internal */ - protected async createCDPPipeConnection( + protected async createCdpPipeConnection( browserProcess: ReturnType, opts: {timeout: number; protocolTimeout: number | undefined; slowMo: number} ): Promise { @@ -322,7 +322,7 @@ export class ProductLauncher { /** * @internal */ - protected async createBiDiOverCDPBrowser( + protected async createBiDiOverCdpBrowser( browserProcess: ReturnType, connection: Connection, closeCallback: BrowserCloseCallback, @@ -338,7 +338,7 @@ export class ProductLauncher { const BiDi = await import( /* webpackIgnore: true */ '../common/bidi/bidi.js' ); - const bidiConnection = await BiDi.connectBidiOverCDP(connection); + const bidiConnection = await BiDi.connectBidiOverCdp(connection); return await BiDi.BidiBrowser.create({ connection: bidiConnection, closeCallback, diff --git a/test/src/TargetManager.spec.ts b/test/src/TargetManager.spec.ts index 41d153196f9..48996c1edde 100644 --- a/test/src/TargetManager.spec.ts +++ b/test/src/TargetManager.spec.ts @@ -15,7 +15,7 @@ */ import expect from 'expect'; -import {CDPBrowser} from 'puppeteer-core/internal/common/Browser.js'; +import {CdpBrowser} from 'puppeteer-core/internal/common/Browser.js'; import {getTestState, launch} from './mocha-utils.js'; import {attachFrame} from './utils.js'; @@ -23,7 +23,7 @@ import {attachFrame} from './utils.js'; describe('TargetManager', () => { /* We use a special browser for this test as we need the --site-per-process flag */ let state: Awaited> & { - browser: CDPBrowser; + browser: CdpBrowser; }; beforeEach(async () => { @@ -40,7 +40,7 @@ describe('TargetManager', () => { }), {createPage: false} )) as Awaited> & { - browser: CDPBrowser; + browser: CdpBrowser; }; }); diff --git a/test/src/oopif.spec.ts b/test/src/oopif.spec.ts index 2611780c72b..dc2674c2910 100644 --- a/test/src/oopif.spec.ts +++ b/test/src/oopif.spec.ts @@ -16,7 +16,7 @@ import expect from 'expect'; import {BrowserContext} from 'puppeteer-core/internal/api/BrowserContext.js'; -import {CDPTarget} from 'puppeteer-core/internal/common/Target.js'; +import {CdpTarget} from 'puppeteer-core/internal/common/Target.js'; import {describeWithDebugLogs, getTestState, launch} from './mocha-utils.js'; import {attachFrame, detachFrame, navigateFrame} from './utils.js'; @@ -454,6 +454,6 @@ describeWithDebugLogs('OOPIF', function () { function oopifs(context: BrowserContext) { return context.targets().filter(target => { - return (target as CDPTarget)._getTargetInfo().type === 'iframe'; + return (target as CdpTarget)._getTargetInfo().type === 'iframe'; }); } diff --git a/test/src/page.spec.ts b/test/src/page.spec.ts index 658efed70ec..dca2e0f1ec5 100644 --- a/test/src/page.spec.ts +++ b/test/src/page.spec.ts @@ -23,7 +23,7 @@ import {KnownDevices, TimeoutError} from 'puppeteer'; import {CDPSession} from 'puppeteer-core/internal/api/CDPSession.js'; import {Metrics, Page} from 'puppeteer-core/internal/api/Page.js'; import {ConsoleMessage} from 'puppeteer-core/internal/common/ConsoleMessage.js'; -import {CDPPage} from 'puppeteer-core/internal/common/Page.js'; +import {CdpPage} from 'puppeteer-core/internal/common/Page.js'; import sinon from 'sinon'; import {getTestState, setupTestBrowserHooks} from './mocha-utils.js'; @@ -2376,7 +2376,7 @@ describe('Page', function () { describe('Page.client', function () { it('should return the client instance', async () => { const {page} = await getTestState(); - expect((page as CDPPage)._client()).toBeInstanceOf(CDPSession); + expect((page as CdpPage)._client()).toBeInstanceOf(CDPSession); }); }); });