diff --git a/packages/puppeteer-core/src/common/Browser.ts b/packages/puppeteer-core/src/common/Browser.ts index 7cb84490..3d60df00 100644 --- a/packages/puppeteer-core/src/common/Browser.ts +++ b/packages/puppeteer-core/src/common/Browser.ts @@ -54,9 +54,6 @@ import {TaskQueue} from './TaskQueue.js'; * @internal */ export class CDPBrowser extends BrowserBase { - /** - * @internal - */ static async _create( product: 'firefox' | 'chrome' | undefined, connection: Connection, @@ -98,16 +95,10 @@ export class CDPBrowser extends BrowserBase { #screenshotTaskQueue: TaskQueue; #targetManager: TargetManager; - /** - * @internal - */ override get _targets(): Map { return this.#targetManager.getAvailableTargets(); } - /** - * @internal - */ constructor( product: 'chrome' | 'firefox' | undefined, connection: Connection, @@ -163,9 +154,6 @@ export class CDPBrowser extends BrowserBase { this.emit(BrowserEmittedEvents.Disconnected); }; - /** - * @internal - */ override async _attach(): Promise { this.#connection.on( ConnectionEmittedEvents.Disconnected, @@ -190,9 +178,6 @@ export class CDPBrowser extends BrowserBase { await this.#targetManager.initialize(); } - /** - * @internal - */ override _detach(): void { this.#connection.off( ConnectionEmittedEvents.Disconnected, @@ -224,9 +209,6 @@ export class CDPBrowser extends BrowserBase { return this.#process ?? null; } - /** - * @internal - */ _targetManager(): TargetManager { return this.#targetManager; } @@ -243,9 +225,6 @@ export class CDPBrowser extends BrowserBase { }); } - /** - * @internal - */ override _getIsPageTargetCallback(): IsPageTargetCallback | undefined { return this.#isPageTargetCallback; } @@ -304,9 +283,6 @@ export class CDPBrowser extends BrowserBase { return this.#defaultContext; } - /** - * @internal - */ override async _disposeContext(contextId?: string): Promise { if (!contextId) { return; @@ -452,9 +428,6 @@ export class CDPBrowser extends BrowserBase { return this.#defaultContext.newPage(); } - /** - * @internal - */ override async _createPageInContext(contextId?: string): Promise { const {targetId} = await this.#connection.send('Target.createTarget', { url: 'about:blank', @@ -553,9 +526,6 @@ export class CDPBrowserContext extends BrowserContext { #browser: CDPBrowser; #id?: string; - /** - * @internal - */ constructor(connection: Connection, browser: CDPBrowser, contextId?: string) { super(); this.#connection = connection; diff --git a/packages/puppeteer-core/src/common/CustomQueryHandler.ts b/packages/puppeteer-core/src/common/CustomQueryHandler.ts index 1114c670..db39621d 100644 --- a/packages/puppeteer-core/src/common/CustomQueryHandler.ts +++ b/packages/puppeteer-core/src/common/CustomQueryHandler.ts @@ -53,9 +53,6 @@ export class CustomQueryHandlerRegistry { [registerScript: string, Handler: typeof QueryHandler] >(); - /** - * @internal - */ get(name: string): typeof QueryHandler | undefined { const handler = this.#handlers.get(name); return handler ? handler[1] : undefined; @@ -79,8 +76,6 @@ export class CustomQueryHandlerRegistry { * @param name - Name to register under. * @param queryHandler - {@link CustomQueryHandler | Custom query handler} to * register. - * - * @internal */ register(name: string, handler: CustomQueryHandler): void { assert( @@ -141,8 +136,6 @@ export class CustomQueryHandlerRegistry { * given name. * * @throws `Error` if there is no handler under the given name. - * - * @internal */ unregister(name: string): void { const handler = this.#handlers.get(name); @@ -155,8 +148,6 @@ export class CustomQueryHandlerRegistry { /** * Gets the names of all {@link CustomQueryHandler | custom query handlers}. - * - * @internal */ names(): string[] { return [...this.#handlers.keys()]; @@ -164,8 +155,6 @@ export class CustomQueryHandlerRegistry { /** * Unregisters all custom query handlers. - * - * @internal */ clear(): void { for (const [registerScript] of this.#handlers) { diff --git a/packages/puppeteer-core/src/common/Dialog.ts b/packages/puppeteer-core/src/common/Dialog.ts index 3d971474..1fc899b8 100644 --- a/packages/puppeteer-core/src/common/Dialog.ts +++ b/packages/puppeteer-core/src/common/Dialog.ts @@ -26,9 +26,6 @@ import {CDPSession} from './Connection.js'; export class CDPDialog extends Dialog { #client: CDPSession; - /** - * @internal - */ constructor( client: CDPSession, type: Protocol.Page.DialogType, @@ -39,9 +36,6 @@ export class CDPDialog extends Dialog { this.#client = client; } - /** - * @internal - */ override async sendCommand(options: { accept: boolean; text?: string; diff --git a/packages/puppeteer-core/src/common/ElementHandle.ts b/packages/puppeteer-core/src/common/ElementHandle.ts index 69f8648c..00431e59 100644 --- a/packages/puppeteer-core/src/common/ElementHandle.ts +++ b/packages/puppeteer-core/src/common/ElementHandle.ts @@ -52,16 +52,10 @@ export class CDPElementHandle< this.#frame = frame; } - /** - * @internal - */ executionContext(): ExecutionContext { return this.handle.executionContext(); } - /** - * @internal - */ get client(): CDPSession { return this.handle.client; } diff --git a/packages/puppeteer-core/src/common/Frame.ts b/packages/puppeteer-core/src/common/Frame.ts index 728d1fc5..9c3318bb 100644 --- a/packages/puppeteer-core/src/common/Frame.ts +++ b/packages/puppeteer-core/src/common/Frame.ts @@ -240,16 +240,10 @@ export class CDPFrame extends Frame { return this.worlds[MAIN_WORLD].executionContext(); } - /** - * @internal - */ override mainRealm(): IsolatedWorld { return this.worlds[MAIN_WORLD]; } - /** - * @internal - */ override isolatedRealm(): IsolatedWorld { return this.worlds[PUPPETEER_WORLD]; } diff --git a/packages/puppeteer-core/src/common/FrameManager.ts b/packages/puppeteer-core/src/common/FrameManager.ts index aeb8a483..f413a624 100644 --- a/packages/puppeteer-core/src/common/FrameManager.ts +++ b/packages/puppeteer-core/src/common/FrameManager.ts @@ -75,9 +75,7 @@ export class FrameManager extends EventEmitter { #contextIdToContext = new Map(); #isolatedWorlds = new Set(); #client: CDPSession; - /** - * @internal - */ + _frameTree = new FrameTree(); /** @@ -299,9 +297,6 @@ export class FrameManager extends EventEmitter { void this.initialize(target._session()!); } - /** - * @internal - */ _deviceRequestPromptManager(client: CDPSession): DeviceRequestPromptManager { let manager = this.#deviceRequestPromptManagerMap.get(client); if (manager === undefined) { diff --git a/packages/puppeteer-core/src/common/Input.ts b/packages/puppeteer-core/src/common/Input.ts index 2f60499c..aacaa8e3 100644 --- a/packages/puppeteer-core/src/common/Input.ts +++ b/packages/puppeteer-core/src/common/Input.ts @@ -46,22 +46,13 @@ export class CDPKeyboard extends Keyboard { #client: CDPSession; #pressedKeys = new Set(); - /** - * @internal - */ _modifiers = 0; - /** - * @internal - */ constructor(client: CDPSession) { super(); this.#client = client; } - /** - * @internal - */ updateClient(client: CDPSession): void { this.#client = client; } @@ -288,18 +279,12 @@ export class CDPMouse extends Mouse { #client: CDPSession; #keyboard: CDPKeyboard; - /** - * @internal - */ constructor(client: CDPSession, keyboard: CDPKeyboard) { super(); this.#client = client; this.#keyboard = keyboard; } - /** - * @internal - */ updateClient(client: CDPSession): void { this.#client = client; } @@ -576,18 +561,12 @@ export class CDPTouchscreen extends Touchscreen { #client: CDPSession; #keyboard: CDPKeyboard; - /** - * @internal - */ constructor(client: CDPSession, keyboard: CDPKeyboard) { super(); this.#client = client; this.#keyboard = keyboard; } - /** - * @internal - */ updateClient(client: CDPSession): void { this.#client = client; } diff --git a/packages/puppeteer-core/src/common/Page.ts b/packages/puppeteer-core/src/common/Page.ts index 4676dad4..da4439a6 100644 --- a/packages/puppeteer-core/src/common/Page.ts +++ b/packages/puppeteer-core/src/common/Page.ts @@ -95,9 +95,6 @@ import {WebWorker} from './WebWorker.js'; * @internal */ export class CDPPage extends Page { - /** - * @internal - */ static async _create( client: CDPSession, target: CDPTarget, @@ -211,9 +208,6 @@ export class CDPPage extends Page { ['Page.fileChooserOpened', this.#onFileChooser.bind(this)], ]); - /** - * @internal - */ constructor( client: CDPSession, target: CDPTarget, @@ -379,9 +373,6 @@ export class CDPPage extends Page { this.#fileChooserDeferreds.clear(); } - /** - * @internal - */ _client(): CDPSession { return this.#client; } diff --git a/packages/puppeteer-core/src/common/Target.ts b/packages/puppeteer-core/src/common/Target.ts index 80c1f27e..f3f5d91d 100644 --- a/packages/puppeteer-core/src/common/Target.ts +++ b/packages/puppeteer-core/src/common/Target.ts @@ -50,17 +50,8 @@ export class CDPTarget extends Target { | ((isAutoAttachEmulated: boolean) => Promise) | undefined; - /** - * @internal - */ _initializedDeferred = Deferred.create(); - /** - * @internal - */ _isClosedDeferred = Deferred.create(); - /** - * @internal - */ _targetId: string; /** @@ -89,23 +80,14 @@ export class CDPTarget extends Target { } } - /** - * @internal - */ _subtype(): string | undefined { return this.#targetInfo.subtype; } - /** - * @internal - */ _session(): CDPSession | undefined { return this.#session; } - /** - * @internal - */ protected _sessionFactory(): ( isAutoAttachEmulated: boolean ) => Promise { @@ -151,9 +133,6 @@ export class CDPTarget extends Target { } } - /** - * @internal - */ _targetManager(): TargetManager { if (!this.#targetManager) { throw new Error('targetManager is not initialized'); @@ -161,9 +140,6 @@ export class CDPTarget extends Target { return this.#targetManager; } - /** - * @internal - */ _getTargetInfo(): Protocol.Target.TargetInfo { return this.#targetInfo; } @@ -190,24 +166,15 @@ export class CDPTarget extends Target { return this.browser()._targets.get(openerId); } - /** - * @internal - */ _targetInfoChanged(targetInfo: Protocol.Target.TargetInfo): void { this.#targetInfo = targetInfo; this._checkIfInitialized(); } - /** - * @internal - */ _initialize(): void { this._initializedDeferred.resolve(InitializationStatus.SUCCESS); } - /** - * @internal - */ protected _checkIfInitialized(): void { if (!this._initializedDeferred.resolved()) { this._initializedDeferred.resolve(InitializationStatus.SUCCESS); @@ -224,9 +191,6 @@ export class PageTarget extends CDPTarget { #screenshotTaskQueue: TaskQueue; #ignoreHTTPSErrors: boolean; - /** - * @internal - */ constructor( targetInfo: Protocol.Target.TargetInfo, session: CDPSession | undefined, diff --git a/packages/puppeteer-core/src/common/bidi/ElementHandle.ts b/packages/puppeteer-core/src/common/bidi/ElementHandle.ts index 904d219d..b6e2d813 100644 --- a/packages/puppeteer-core/src/common/bidi/ElementHandle.ts +++ b/packages/puppeteer-core/src/common/bidi/ElementHandle.ts @@ -56,9 +56,6 @@ export class BidiElementHandle< return this.handle.remoteValue(); } - /** - * @internal - */ assertElementHasWorld(): asserts this { // TODO: Should assert element has a Sandbox return; diff --git a/packages/puppeteer-core/src/common/bidi/Input.ts b/packages/puppeteer-core/src/common/bidi/Input.ts index 852c357c..89ed43aa 100644 --- a/packages/puppeteer-core/src/common/bidi/Input.ts +++ b/packages/puppeteer-core/src/common/bidi/Input.ts @@ -287,9 +287,6 @@ const getBidiKeyValue = (key: KeyInput) => { export class Keyboard extends BaseKeyboard { #context: BrowsingContext; - /** - * @internal - */ constructor(context: BrowsingContext) { super(); this.#context = context; @@ -463,9 +460,6 @@ export class Mouse extends BaseMouse { #context: BrowsingContext; #lastMovePoint?: Point; - /** - * @internal - */ constructor(context: BrowsingContext) { super(); this.#context = context; @@ -619,9 +613,6 @@ export class Mouse extends BaseMouse { export class Touchscreen extends BaseTouchscreen { #context: BrowsingContext; - /** - * @internal - */ constructor(context: BrowsingContext) { super(); this.#context = context; diff --git a/test/src/frame.spec.ts b/test/src/frame.spec.ts index faf7abbb..f6fa4c7e 100644 --- a/test/src/frame.spec.ts +++ b/test/src/frame.spec.ts @@ -86,17 +86,15 @@ describe('Frame specs', function () { const frame1 = (await attachFrame(page, 'frame1', server.EMPTY_PAGE))!; await detachFrame(page, 'frame1'); - let error!: Error; - await frame1 - .evaluate(() => { + let error: Error | undefined; + try { + await frame1.evaluate(() => { return 7 * 8; - }) - .catch(error_ => { - return (error = error_); }); - expect(error.message).toContain( - 'Execution context is not available in detached frame' - ); + } catch (err) { + error = err as Error; + } + expect(error?.message).toContain('Attempted to use detached Frame'); }); it('allows readonly array to be an argument', async () => {