refactor: align names (#10903)

This commit is contained in:
Nikolay Vitkov 2023-09-13 21:57:26 +02:00 committed by GitHub
parent ea14834fdf
commit aefbde60d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 258 additions and 258 deletions

View File

@ -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<CDPBrowser> {
const browser = new CDPBrowser(
): Promise<CdpBrowser> {
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<string, CDPBrowserContext>();
#defaultContext: CdpBrowserContext;
#contexts = new Map<string, CdpBrowserContext>();
#screenshotTaskQueue: TaskQueue;
#targetManager: TargetManager;
override get _targets(): Map<string, CDPTarget> {
override get _targets(): Map<string, CdpTarget> {
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<CDPBrowserContext> {
): Promise<CdpBrowserContext> {
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<void> => {
#onDetachedFromTarget = async (target: CdpTarget): Promise<void> => {
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;
}

View File

@ -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<CDPBrowser> {
): Promise<CdpBrowser> {
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,

View File

@ -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;
}

View File

@ -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<string, CDPTarget>();
#attachedTargetsByTargetId = new Map<string, CdpTarget>();
/**
* Tracks which sessions attach to which target.
*/
#attachedTargetsBySessionId = new Map<string, CDPTarget>();
#attachedTargetsBySessionId = new Map<string, CdpTarget>();
/**
* 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<string, CDPTarget> {
const result = new Map<string, CDPTarget>();
getAvailableTargets(): Map<string, CdpTarget> {
const result = new Map<string, CdpTarget>();
for (const [id, target] of this.#attachedTargetsByTargetId.entries()) {
if (isTargetExposed(target)) {
result.set(id, target);

View File

@ -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<CDPSessionEvents> {
#transport: ConnectionTransport;
#delay: number;
#timeout: number;
#sessions = new Map<string, CDPCDPSession>();
#sessions = new Map<string, CdpCDPSession>();
#closed = false;
#manuallyAttached = new Set<string>();
#callbacks = new CallbackRegistry();
@ -310,7 +310,7 @@ export class Connection extends EventEmitter<CDPSessionEvents> {
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,

View File

@ -22,7 +22,7 @@ import {Dialog} from '../api/Dialog.js';
/**
* @internal
*/
export class CDPDialog extends Dialog {
export class CdpDialog extends Dialog {
#client: CDPSession;
constructor(

View File

@ -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<ElementType> {
protected declare readonly handle: CDPJSHandle<ElementType>;
protected declare readonly handle: CdpJSHandle<ElementType>;
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<HTMLIFrameElement>
): Promise<CDPFrame>;
): Promise<CdpFrame>;
@throwIfDisposed()
override async contentFrame(): Promise<CDPFrame | null> {
override async contentFrame(): Promise<CdpFrame | null> {
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<Element>
this: CdpElementHandle<Element>
): Promise<void> {
await this.assertConnectedElement();
try {
@ -109,7 +109,7 @@ export class CDPElementHandle<
@throwIfDisposed()
@ElementHandle.bindIsolatedHandle
override async drag(
this: CDPElementHandle<Element>,
this: CdpElementHandle<Element>,
target: Point
): Promise<Protocol.Input.DragData> {
assert(
@ -124,7 +124,7 @@ export class CDPElementHandle<
@throwIfDisposed()
@ElementHandle.bindIsolatedHandle
override async dragEnter(
this: CDPElementHandle<Element>,
this: CdpElementHandle<Element>,
data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1}
): Promise<void> {
await this.scrollIntoViewIfNeeded();
@ -135,7 +135,7 @@ export class CDPElementHandle<
@throwIfDisposed()
@ElementHandle.bindIsolatedHandle
override async dragOver(
this: CDPElementHandle<Element>,
this: CdpElementHandle<Element>,
data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1}
): Promise<void> {
await this.scrollIntoViewIfNeeded();
@ -146,7 +146,7 @@ export class CDPElementHandle<
@throwIfDisposed()
@ElementHandle.bindIsolatedHandle
override async drop(
this: CDPElementHandle<Element>,
this: CdpElementHandle<Element>,
data: Protocol.Input.DragData = {items: [], dragOperationsMask: 1}
): Promise<void> {
await this.scrollIntoViewIfNeeded();
@ -157,8 +157,8 @@ export class CDPElementHandle<
@throwIfDisposed()
@ElementHandle.bindIsolatedHandle
override async dragAndDrop(
this: CDPElementHandle<Element>,
target: CDPElementHandle<Node>,
this: CdpElementHandle<Element>,
target: CdpElementHandle<Node>,
options?: {delay: number}
): Promise<void> {
assert(
@ -174,7 +174,7 @@ export class CDPElementHandle<
@throwIfDisposed()
@ElementHandle.bindIsolatedHandle
override async uploadFile(
this: CDPElementHandle<HTMLInputElement>,
this: CdpElementHandle<HTMLInputElement>,
...filePaths: string[]
): Promise<void> {
const isMultiple = await this.evaluate(element => {
@ -233,7 +233,7 @@ export class CDPElementHandle<
@throwIfDisposed()
@ElementHandle.bindIsolatedHandle
override async screenshot(
this: CDPElementHandle<Element>,
this: CdpElementHandle<Element>,
options: ScreenshotOptions = {}
): Promise<string | Buffer> {
let needsViewportReset = false;

View File

@ -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) {

View File

@ -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<string, CDPTarget>();
#availableTargetsByTargetId = new Map<string, CdpTarget>();
/**
* Tracks which sessions attach to which target.
*/
#availableTargetsBySessionId = new Map<string, CDPTarget>();
#availableTargetsBySessionId = new Map<string, CdpTarget>();
/**
* 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<string, CDPTarget> {
getAvailableTargets(): Map<string, CdpTarget> {
return this.#availableTargetsByTargetId;
}

View File

@ -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);
}

View File

@ -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<EventType, unknown> {
[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<FrameManagerEvents> {
#isolatedWorlds = new Set<string>();
#client: CDPSession;
_frameTree = new FrameTree<CDPFrame>();
_frameTree = new FrameTree<CdpFrame>();
/**
* Set of frame IDs stored to indicate if a frame has received a
@ -168,7 +168,7 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
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<FrameManagerEvents> {
}
}
async registerSpeculativeSession(client: CDPCDPSession): Promise<void> {
async registerSpeculativeSession(client: CdpCDPSession): Promise<void> {
await this.#networkManager.addClient(client);
}
@ -279,21 +279,21 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
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<FrameManagerEvents> {
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<FrameManagerEvents> {
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<FrameManagerEvents> {
}
}
#removeFramesRecursively(frame: CDPFrame): void {
#removeFramesRecursively(frame: CdpFrame): void {
for (const child of frame.childFrames()) {
this.#removeFramesRecursively(child);
}

View File

@ -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();
}

View File

@ -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<Buffer> | null = null;
#bodyLoadedDeferred = Deferred.create<Error | void>();
#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;
}

View File

@ -42,7 +42,7 @@ type KeyDescription = Required<
/**
* @internal
*/
export class CDPKeyboard extends Keyboard {
export class CdpKeyboard extends Keyboard {
#client: CDPSession;
#pressedKeys = new Set<string>();
@ -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;

View File

@ -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();
}
}

View File

@ -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<T = unknown> extends JSHandle<T> {
export class CdpJSHandle<T = unknown> extends JSHandle<T> {
#disposed = false;
readonly #remoteObject: Protocol.Runtime.RemoteObject;
readonly #world: IsolatedWorld;
@ -69,7 +69,7 @@ export class CDPJSHandle<T = unknown> extends JSHandle<T> {
* Either `null` or the handle itself if the handle is an
* instance of {@link ElementHandle}.
*/
override asElement(): CDPElementHandle<Node> | null {
override asElement(): CdpElementHandle<Node> | null {
return null;
}

View File

@ -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) {

View File

@ -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<NetworkRequestId, CDPHTTPRequest>();
#httpRequestsMap = new Map<NetworkRequestId, CdpHTTPRequest>();
/*
* 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);
}

View File

@ -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;
},
});

View File

@ -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<EventType, unknown> {
[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<NetworkManagerEvents> {
? 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<NetworkManagerEvents> {
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<NetworkManagerEvents> {
? 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<NetworkManagerEvents> {
#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<NetworkManagerEvents> {
extraInfo = null;
}
const response = new CDPHTTPResponse(
const response = new CdpHTTPResponse(
client,
request,
responseReceived.response,
@ -659,7 +659,7 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
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;

View File

@ -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<CDPPage> {
const page = new CDPPage(
): Promise<CdpPage> {
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;
}

View File

@ -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<Browser> {
return _connectToCDPBrowser(options);
return _connectToCdpBrowser(options);
}
}

View File

@ -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<Page>;
#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<WebWorker>;
override async worker(): Promise<WebWorker | null> {
@ -299,4 +299,4 @@ export class WorkerTarget extends CDPTarget {
/**
* @internal
*/
export class OtherTarget extends CDPTarget {}
export class OtherTarget extends CdpTarget {}

View File

@ -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<EventType, unknown> {
[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<EventType, unknown> {
* @internal
*/
export interface TargetManager extends EventEmitter<TargetManagerEvents> {
getAvailableTargets(): Map<string, CDPTarget>;
getAvailableTargets(): Map<string, CdpTarget>;
initialize(): Promise<void>;
dispose(): void;
}

View File

@ -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<Record<EventType, unknown>> {
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
);

View File

@ -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<BidiConnection> {
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<CDPSession, CDPClientAdapter<CDPSession>>();
#browser: CDPClientAdapter<CDPConnection>;
#browser: CDPClientAdapter<CdpConnection>;
constructor(cdp: CDPConnection) {
constructor(cdp: CdpConnection) {
this.#cdp = cdp;
this.#browser = new CDPClientAdapter(cdp);
}
browserClient(): CDPClientAdapter<CDPConnection> {
browserClient(): CDPClientAdapter<CdpConnection> {
return this.#browser;
}
@ -104,7 +104,7 @@ class CDPConnectionAdapter {
*
* @internal
*/
class CDPClientAdapter<T extends CDPSession | CDPConnection>
class CDPClientAdapter<T extends CDPSession | CdpConnection>
extends BidiMapper.EventEmitter<CDPEvents>
implements BidiMapper.CdpClient
{

View File

@ -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<string, CDPSessionWrapper>();
export const cdpSessions = new Map<string, CdpSessionWrapper>();
/**
* @internal
*/
export class CDPSessionWrapper extends CDPSession {
export class CdpSessionWrapper extends CDPSession {
#context: BrowsingContext;
#sessionId = Deferred.create<string>();
#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<ProtocolMapping.Commands[T]['returnType']> {
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<void> {
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<T extends keyof ProtocolMapping.Commands>(
async sendCdpCommand<T extends keyof ProtocolMapping.Commands>(
method: T,
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
): Promise<ProtocolMapping.Commands[T]['returnType']> {

View File

@ -235,7 +235,7 @@ export class BidiConnection extends EventEmitter<BidiEvents> {
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.');
}

View File

@ -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<void> {
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<void> {

View File

@ -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 {

View File

@ -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';

View File

@ -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<Node> {
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,

View File

@ -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<typeof launch>,
opts: {timeout: number; protocolTimeout: number | undefined; slowMo: number}
): Promise<Connection> {
@ -305,7 +305,7 @@ export class ProductLauncher {
/**
* @internal
*/
protected async createCDPPipeConnection(
protected async createCdpPipeConnection(
browserProcess: ReturnType<typeof launch>,
opts: {timeout: number; protocolTimeout: number | undefined; slowMo: number}
): Promise<Connection> {
@ -322,7 +322,7 @@ export class ProductLauncher {
/**
* @internal
*/
protected async createBiDiOverCDPBrowser(
protected async createBiDiOverCdpBrowser(
browserProcess: ReturnType<typeof launch>,
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,

View File

@ -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<ReturnType<typeof launch>> & {
browser: CDPBrowser;
browser: CdpBrowser;
};
beforeEach(async () => {
@ -40,7 +40,7 @@ describe('TargetManager', () => {
}),
{createPage: false}
)) as Awaited<ReturnType<typeof launch>> & {
browser: CDPBrowser;
browser: CdpBrowser;
};
});

View File

@ -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';
});
}

View File

@ -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);
});
});
});