From 0fe89b7da92bc9ded61a603fe76fe2bd9d4b1b49 Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:57:33 +0100 Subject: [PATCH] chore: add new UnsupportedOperation Error (#11322) --- docs/api/index.md | 1 + docs/api/puppeteer.browser.disconnect.md | 2 +- docs/api/puppeteer.browser.process.md | 2 +- docs/api/puppeteer.browser.useragent.md | 2 +- ...browsercontext.clearpermissionoverrides.md | 2 +- ...teer.browsercontext.overridepermissions.md | 5 +- docs/api/puppeteer.browsercontext.targets.md | 2 +- docs/api/puppeteer.cdpsession.connection.md | 2 +- docs/api/puppeteer.cdpsession.detach.md | 2 +- docs/api/puppeteer.cdpsession.id.md | 2 +- docs/api/puppeteer.cdpsession.send.md | 2 +- .../api/puppeteer.elementhandle.uploadfile.md | 2 +- docs/api/puppeteer.frame.isoopframe.md | 2 +- docs/api/puppeteer.frame.md | 1 - .../puppeteer.frame.waitfordeviceprompt.md | 45 ----- docs/api/puppeteer.mouse.click.md | 2 +- docs/api/puppeteer.mouse.down.md | 2 +- docs/api/puppeteer.mouse.drag.md | 2 +- docs/api/puppeteer.mouse.draganddrop.md | 2 +- docs/api/puppeteer.mouse.dragenter.md | 5 +- docs/api/puppeteer.mouse.dragover.md | 5 +- docs/api/puppeteer.mouse.drop.md | 2 +- docs/api/puppeteer.mouse.md | 2 +- docs/api/puppeteer.mouse.move.md | 2 +- docs/api/puppeteer.mouse.reset.md | 2 +- docs/api/puppeteer.mouse.up.md | 2 +- docs/api/puppeteer.mouse.wheel.md | 2 +- docs/api/puppeteer.page.authenticate.md | 2 +- docs/api/puppeteer.page.cookies.md | 2 +- docs/api/puppeteer.page.createcdpsession.md | 2 +- docs/api/puppeteer.page.createpdfstream.md | 2 +- docs/api/puppeteer.page.deletecookie.md | 2 +- .../puppeteer.page.emulatecputhrottling.md | 2 +- docs/api/puppeteer.page.emulateidlestate.md | 2 +- .../puppeteer.page.emulatemediafeatures.md | 2 +- docs/api/puppeteer.page.emulatemediatype.md | 2 +- ...puppeteer.page.emulatenetworkconditions.md | 2 +- docs/api/puppeteer.page.emulatetimezone.md | 2 +- .../puppeteer.page.emulatevisiondeficiency.md | 2 +- docs/api/puppeteer.page.goback.md | 2 +- docs/api/puppeteer.page.goforward.md | 2 +- ...uppeteer.page.isdraginterceptionenabled.md | 2 +- .../api/puppeteer.page.isjavascriptenabled.md | 2 +- .../puppeteer.page.isserviceworkerbypassed.md | 2 +- docs/api/puppeteer.page.metrics.md | 2 +- .../puppeteer.page.removeexposedfunction.md | 2 +- .../puppeteer.page.setbypassserviceworker.md | 2 +- docs/api/puppeteer.page.setcookie.md | 2 +- .../api/puppeteer.page.setdraginterception.md | 2 +- .../api/puppeteer.page.setextrahttpheaders.md | 2 +- docs/api/puppeteer.page.setgeolocation.md | 2 +- .../puppeteer.page.setjavascriptenabled.md | 2 +- docs/api/puppeteer.page.setofflinemode.md | 2 +- .../puppeteer.page.setrequestinterception.md | 2 +- docs/api/puppeteer.page.target.md | 2 +- .../api/puppeteer.page.waitfordeviceprompt.md | 2 +- docs/api/puppeteer.page.waitforfilechooser.md | 4 +- docs/api/puppeteer.page.workers.md | 2 +- docs/api/puppeteer.target.browser.md | 2 +- docs/api/puppeteer.target.browsercontext.md | 2 +- docs/api/puppeteer.target.createcdpsession.md | 2 +- docs/api/puppeteer.target.md | 2 +- docs/api/puppeteer.target.opener.md | 2 +- docs/api/puppeteer.target.type.md | 2 +- docs/api/puppeteer.target.url.md | 2 +- docs/api/puppeteer.unsupportedoperation.md | 15 ++ packages/puppeteer-core/src/api/Browser.ts | 49 +----- .../puppeteer-core/src/api/BrowserContext.ts | 16 +- packages/puppeteer-core/src/api/CDPSession.ts | 19 +-- .../puppeteer-core/src/api/ElementHandle.ts | 6 +- packages/puppeteer-core/src/api/Frame.ts | 26 +-- packages/puppeteer-core/src/api/Input.ts | 62 ++----- packages/puppeteer-core/src/api/JSHandle.ts | 4 +- packages/puppeteer-core/src/api/Page.ts | 154 ++++-------------- packages/puppeteer-core/src/api/Target.ts | 26 +-- packages/puppeteer-core/src/bidi/Browser.ts | 9 + .../puppeteer-core/src/bidi/BrowserContext.ts | 9 + .../src/bidi/BrowsingContext.ts | 4 +- .../puppeteer-core/src/bidi/ElementHandle.ts | 5 + packages/puppeteer-core/src/bidi/Frame.ts | 12 +- .../puppeteer-core/src/bidi/HTTPRequest.ts | 25 +-- .../puppeteer-core/src/bidi/HTTPResponse.ts | 5 +- packages/puppeteer-core/src/bidi/Input.ts | 22 +++ packages/puppeteer-core/src/bidi/JSHandle.ts | 3 +- packages/puppeteer-core/src/bidi/Page.ts | 101 +++++++++++- packages/puppeteer-core/src/bidi/Target.ts | 21 ++- packages/puppeteer-core/src/bidi/lifecycle.ts | 9 + packages/puppeteer-core/src/cdp/Browser.ts | 10 +- packages/puppeteer-core/src/cdp/Frame.ts | 5 + packages/puppeteer-core/src/common/Errors.ts | 8 + 90 files changed, 382 insertions(+), 425 deletions(-) delete mode 100644 docs/api/puppeteer.frame.waitfordeviceprompt.md create mode 100644 docs/api/puppeteer.unsupportedoperation.md diff --git a/docs/api/index.md b/docs/api/index.md index 54e3e92b517..21bb1ad2d6f 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -42,6 +42,7 @@ sidebar_label: API | [TimeoutError](./puppeteer.timeouterror.md) | TimeoutError is emitted whenever certain operations are terminated due to timeout. | | [Touchscreen](./puppeteer.touchscreen.md) | The Touchscreen class exposes touchscreen events. | | [Tracing](./puppeteer.tracing.md) | The Tracing class exposes the tracing audit interface. | +| [UnsupportedOperation](./puppeteer.unsupportedoperation.md) | Puppeteer will throw this error if a method is not supported by the currently used protocol | | [WebWorker](./puppeteer.webworker.md) | This class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). | ## Enumerations diff --git a/docs/api/puppeteer.browser.disconnect.md b/docs/api/puppeteer.browser.disconnect.md index b7611b72a23..5307952640c 100644 --- a/docs/api/puppeteer.browser.disconnect.md +++ b/docs/api/puppeteer.browser.disconnect.md @@ -10,7 +10,7 @@ Disconnects Puppeteer from this [browser](./puppeteer.browser.md), but leaves th ```typescript class Browser { - disconnect(): void; + abstract disconnect(): void; } ``` diff --git a/docs/api/puppeteer.browser.process.md b/docs/api/puppeteer.browser.process.md index 135de89e5fc..9c6ba3ac5da 100644 --- a/docs/api/puppeteer.browser.process.md +++ b/docs/api/puppeteer.browser.process.md @@ -10,7 +10,7 @@ Gets the associated [ChildProcess](https://nodejs.org/api/child_process.html#cla ```typescript class Browser { - process(): ChildProcess | null; + abstract process(): ChildProcess | null; } ``` diff --git a/docs/api/puppeteer.browser.useragent.md b/docs/api/puppeteer.browser.useragent.md index 2e2cb214a92..7569d6db80f 100644 --- a/docs/api/puppeteer.browser.useragent.md +++ b/docs/api/puppeteer.browser.useragent.md @@ -12,7 +12,7 @@ Gets this [browser's](./puppeteer.browser.md) original user agent. ```typescript class Browser { - userAgent(): Promise; + abstract userAgent(): Promise; } ``` diff --git a/docs/api/puppeteer.browsercontext.clearpermissionoverrides.md b/docs/api/puppeteer.browsercontext.clearpermissionoverrides.md index d86657c7046..812056db453 100644 --- a/docs/api/puppeteer.browsercontext.clearpermissionoverrides.md +++ b/docs/api/puppeteer.browsercontext.clearpermissionoverrides.md @@ -10,7 +10,7 @@ Clears all permission overrides for this [browser context](./puppeteer.browserco ```typescript class BrowserContext { - clearPermissionOverrides(): Promise; + abstract clearPermissionOverrides(): Promise; } ``` diff --git a/docs/api/puppeteer.browsercontext.overridepermissions.md b/docs/api/puppeteer.browsercontext.overridepermissions.md index d0c3ff9e7b4..9b1ed9b4872 100644 --- a/docs/api/puppeteer.browsercontext.overridepermissions.md +++ b/docs/api/puppeteer.browsercontext.overridepermissions.md @@ -10,7 +10,10 @@ Grants this [browser context](./puppeteer.browsercontext.md) the given `permissi ```typescript class BrowserContext { - overridePermissions(origin: string, permissions: Permission[]): Promise; + abstract overridePermissions( + origin: string, + permissions: Permission[] + ): Promise; } ``` diff --git a/docs/api/puppeteer.browsercontext.targets.md b/docs/api/puppeteer.browsercontext.targets.md index a5f897dc4ef..c28383de1d3 100644 --- a/docs/api/puppeteer.browsercontext.targets.md +++ b/docs/api/puppeteer.browsercontext.targets.md @@ -10,7 +10,7 @@ Gets all active [targets](./puppeteer.target.md) inside this [browser context](. ```typescript class BrowserContext { - targets(): Target[]; + abstract targets(): Target[]; } ``` diff --git a/docs/api/puppeteer.cdpsession.connection.md b/docs/api/puppeteer.cdpsession.connection.md index 1ad26479351..796f8f1c7c7 100644 --- a/docs/api/puppeteer.cdpsession.connection.md +++ b/docs/api/puppeteer.cdpsession.connection.md @@ -8,7 +8,7 @@ sidebar_label: CDPSession.connection ```typescript class CDPSession { - connection(): Connection | undefined; + abstract connection(): Connection | undefined; } ``` diff --git a/docs/api/puppeteer.cdpsession.detach.md b/docs/api/puppeteer.cdpsession.detach.md index 932410cce7f..250852a2039 100644 --- a/docs/api/puppeteer.cdpsession.detach.md +++ b/docs/api/puppeteer.cdpsession.detach.md @@ -10,7 +10,7 @@ Detaches the cdpSession from the target. Once detached, the cdpSession object wo ```typescript class CDPSession { - detach(): Promise; + abstract detach(): Promise; } ``` diff --git a/docs/api/puppeteer.cdpsession.id.md b/docs/api/puppeteer.cdpsession.id.md index 5268803fdd7..040895d6d6f 100644 --- a/docs/api/puppeteer.cdpsession.id.md +++ b/docs/api/puppeteer.cdpsession.id.md @@ -10,7 +10,7 @@ Returns the session's id. ```typescript class CDPSession { - id(): string; + abstract id(): string; } ``` diff --git a/docs/api/puppeteer.cdpsession.send.md b/docs/api/puppeteer.cdpsession.send.md index 61eade71152..9c532ef151d 100644 --- a/docs/api/puppeteer.cdpsession.send.md +++ b/docs/api/puppeteer.cdpsession.send.md @@ -8,7 +8,7 @@ sidebar_label: CDPSession.send ```typescript class CDPSession { - send( + abstract send( method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType'] ): Promise; diff --git a/docs/api/puppeteer.elementhandle.uploadfile.md b/docs/api/puppeteer.elementhandle.uploadfile.md index f9212438a82..2e3b2783ec7 100644 --- a/docs/api/puppeteer.elementhandle.uploadfile.md +++ b/docs/api/puppeteer.elementhandle.uploadfile.md @@ -10,7 +10,7 @@ Sets the value of an [input element](https://developer.mozilla.org/en-US/docs/We ```typescript class ElementHandle { - uploadFile( + abstract uploadFile( this: ElementHandle, ...paths: string[] ): Promise; diff --git a/docs/api/puppeteer.frame.isoopframe.md b/docs/api/puppeteer.frame.isoopframe.md index 222faa07b73..d8898070326 100644 --- a/docs/api/puppeteer.frame.isoopframe.md +++ b/docs/api/puppeteer.frame.isoopframe.md @@ -10,7 +10,7 @@ Is `true` if the frame is an out-of-process (OOP) frame. Otherwise, `false`. ```typescript class Frame { - isOOPFrame(): boolean; + abstract isOOPFrame(): boolean; } ``` diff --git a/docs/api/puppeteer.frame.md b/docs/api/puppeteer.frame.md index 1254fbc1e7e..92d480e371d 100644 --- a/docs/api/puppeteer.frame.md +++ b/docs/api/puppeteer.frame.md @@ -100,7 +100,6 @@ console.log(text); | [title()](./puppeteer.frame.title.md) | | The frame's title. | | [type(selector, text, options)](./puppeteer.frame.type.md) | | Sends a keydown, keypress/input, and keyup event for each character in the text. | | [url()](./puppeteer.frame.url.md) | | The frame's URL. | -| [waitForDevicePrompt(options)](./puppeteer.frame.waitfordeviceprompt.md) | |

This method is typically coupled with an action that triggers a device request from an api such as WebBluetooth.

:::caution

This must be called before the device request is made. It will not return a currently active device prompt.

:::

| | [waitForFunction(pageFunction, options, args)](./puppeteer.frame.waitforfunction.md) | | | | [waitForNavigation(options)](./puppeteer.frame.waitfornavigation.md) | |

Waits for the frame to navigate. It is useful for when you run code which will indirectly cause the frame to navigate.

Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.

| | [waitForSelector(selector, options)](./puppeteer.frame.waitforselector.md) | |

Waits for an element matching the given selector to appear in the frame.

This method works across navigations.

| diff --git a/docs/api/puppeteer.frame.waitfordeviceprompt.md b/docs/api/puppeteer.frame.waitfordeviceprompt.md deleted file mode 100644 index b9cba725281..00000000000 --- a/docs/api/puppeteer.frame.waitfordeviceprompt.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -sidebar_label: Frame.waitForDevicePrompt ---- - -# Frame.waitForDevicePrompt() method - -This method is typically coupled with an action that triggers a device request from an api such as WebBluetooth. - -:::caution - -This must be called before the device request is made. It will not return a currently active device prompt. - -::: - -#### Signature: - -```typescript -class Frame { - waitForDevicePrompt( - options?: WaitTimeoutOptions - ): Promise; -} -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | ------------------------------------------------------- | ------------ | -| options | [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) | _(Optional)_ | - -**Returns:** - -Promise<[DeviceRequestPrompt](./puppeteer.devicerequestprompt.md)> - -## Example - -```ts -const [devicePrompt] = Promise.all([ - frame.waitForDevicePrompt(), - frame.click('#connect-bluetooth'), -]); -await devicePrompt.select( - await devicePrompt.waitForDevice(({name}) => name.includes('My Device')) -); -``` diff --git a/docs/api/puppeteer.mouse.click.md b/docs/api/puppeteer.mouse.click.md index f0273bad75f..0dadd46475e 100644 --- a/docs/api/puppeteer.mouse.click.md +++ b/docs/api/puppeteer.mouse.click.md @@ -10,7 +10,7 @@ Shortcut for `mouse.move`, `mouse.down` and `mouse.up`. ```typescript class Mouse { - click( + abstract click( x: number, y: number, options?: Readonly diff --git a/docs/api/puppeteer.mouse.down.md b/docs/api/puppeteer.mouse.down.md index bf3c6f5f0cf..fc7539bd3a0 100644 --- a/docs/api/puppeteer.mouse.down.md +++ b/docs/api/puppeteer.mouse.down.md @@ -10,7 +10,7 @@ Presses the mouse. ```typescript class Mouse { - down(options?: Readonly): Promise; + abstract down(options?: Readonly): Promise; } ``` diff --git a/docs/api/puppeteer.mouse.drag.md b/docs/api/puppeteer.mouse.drag.md index 6785c461ff9..e60877c611c 100644 --- a/docs/api/puppeteer.mouse.drag.md +++ b/docs/api/puppeteer.mouse.drag.md @@ -10,7 +10,7 @@ Dispatches a `drag` event. ```typescript class Mouse { - drag(start: Point, target: Point): Promise; + abstract drag(start: Point, target: Point): Promise; } ``` diff --git a/docs/api/puppeteer.mouse.draganddrop.md b/docs/api/puppeteer.mouse.draganddrop.md index 1c2ca3c973d..1c6fcfc508f 100644 --- a/docs/api/puppeteer.mouse.draganddrop.md +++ b/docs/api/puppeteer.mouse.draganddrop.md @@ -10,7 +10,7 @@ Performs a drag, dragenter, dragover, and drop in sequence. ```typescript class Mouse { - dragAndDrop( + abstract dragAndDrop( start: Point, target: Point, options?: { diff --git a/docs/api/puppeteer.mouse.dragenter.md b/docs/api/puppeteer.mouse.dragenter.md index 989fc5adbb3..df9509865a2 100644 --- a/docs/api/puppeteer.mouse.dragenter.md +++ b/docs/api/puppeteer.mouse.dragenter.md @@ -10,7 +10,10 @@ Dispatches a `dragenter` event. ```typescript class Mouse { - dragEnter(target: Point, data: Protocol.Input.DragData): Promise; + abstract dragEnter( + target: Point, + data: Protocol.Input.DragData + ): Promise; } ``` diff --git a/docs/api/puppeteer.mouse.dragover.md b/docs/api/puppeteer.mouse.dragover.md index ee277732f13..a5640f230e4 100644 --- a/docs/api/puppeteer.mouse.dragover.md +++ b/docs/api/puppeteer.mouse.dragover.md @@ -10,7 +10,10 @@ Dispatches a `dragover` event. ```typescript class Mouse { - dragOver(target: Point, data: Protocol.Input.DragData): Promise; + abstract dragOver( + target: Point, + data: Protocol.Input.DragData + ): Promise; } ``` diff --git a/docs/api/puppeteer.mouse.drop.md b/docs/api/puppeteer.mouse.drop.md index 4098003a5a5..dd4c2d84bb9 100644 --- a/docs/api/puppeteer.mouse.drop.md +++ b/docs/api/puppeteer.mouse.drop.md @@ -10,7 +10,7 @@ Performs a dragenter, dragover, and drop in sequence. ```typescript class Mouse { - drop(target: Point, data: Protocol.Input.DragData): Promise; + abstract drop(target: Point, data: Protocol.Input.DragData): Promise; } ``` diff --git a/docs/api/puppeteer.mouse.md b/docs/api/puppeteer.mouse.md index 9f5710eb5e0..7a00ae23d4a 100644 --- a/docs/api/puppeteer.mouse.md +++ b/docs/api/puppeteer.mouse.md @@ -9,7 +9,7 @@ The Mouse class operates in main-frame CSS pixels relative to the top-left corne #### Signature: ```typescript -export declare class Mouse +export declare abstract class Mouse ``` ## Remarks diff --git a/docs/api/puppeteer.mouse.move.md b/docs/api/puppeteer.mouse.move.md index fca91421c65..2906a332ca3 100644 --- a/docs/api/puppeteer.mouse.move.md +++ b/docs/api/puppeteer.mouse.move.md @@ -10,7 +10,7 @@ Moves the mouse to the given coordinate. ```typescript class Mouse { - move( + abstract move( x: number, y: number, options?: Readonly diff --git a/docs/api/puppeteer.mouse.reset.md b/docs/api/puppeteer.mouse.reset.md index 70347535604..b0b8414a334 100644 --- a/docs/api/puppeteer.mouse.reset.md +++ b/docs/api/puppeteer.mouse.reset.md @@ -10,7 +10,7 @@ Resets the mouse to the default state: No buttons pressed; position at (0,0). ```typescript class Mouse { - reset(): Promise; + abstract reset(): Promise; } ``` diff --git a/docs/api/puppeteer.mouse.up.md b/docs/api/puppeteer.mouse.up.md index 8effca27370..156763ee9c2 100644 --- a/docs/api/puppeteer.mouse.up.md +++ b/docs/api/puppeteer.mouse.up.md @@ -10,7 +10,7 @@ Releases the mouse. ```typescript class Mouse { - up(options?: Readonly): Promise; + abstract up(options?: Readonly): Promise; } ``` diff --git a/docs/api/puppeteer.mouse.wheel.md b/docs/api/puppeteer.mouse.wheel.md index e502fdf4b3b..697d3713742 100644 --- a/docs/api/puppeteer.mouse.wheel.md +++ b/docs/api/puppeteer.mouse.wheel.md @@ -10,7 +10,7 @@ Dispatches a `mousewheel` event. ```typescript class Mouse { - wheel(options?: Readonly): Promise; + abstract wheel(options?: Readonly): Promise; } ``` diff --git a/docs/api/puppeteer.page.authenticate.md b/docs/api/puppeteer.page.authenticate.md index 51195c2bb1f..d230faa2c19 100644 --- a/docs/api/puppeteer.page.authenticate.md +++ b/docs/api/puppeteer.page.authenticate.md @@ -10,7 +10,7 @@ Provide credentials for `HTTP authentication`. ```typescript class Page { - authenticate(credentials: Credentials): Promise; + abstract authenticate(credentials: Credentials): Promise; } ``` diff --git a/docs/api/puppeteer.page.cookies.md b/docs/api/puppeteer.page.cookies.md index ae876b24574..30f145098b6 100644 --- a/docs/api/puppeteer.page.cookies.md +++ b/docs/api/puppeteer.page.cookies.md @@ -10,7 +10,7 @@ If no URLs are specified, this method returns cookies for the current page URL. ```typescript class Page { - cookies(...urls: string[]): Promise; + abstract cookies(...urls: string[]): Promise; } ``` diff --git a/docs/api/puppeteer.page.createcdpsession.md b/docs/api/puppeteer.page.createcdpsession.md index e398ddfc748..d13edda7f90 100644 --- a/docs/api/puppeteer.page.createcdpsession.md +++ b/docs/api/puppeteer.page.createcdpsession.md @@ -10,7 +10,7 @@ Creates a Chrome Devtools Protocol session attached to the page. ```typescript class Page { - createCDPSession(): Promise; + abstract createCDPSession(): Promise; } ``` diff --git a/docs/api/puppeteer.page.createpdfstream.md b/docs/api/puppeteer.page.createpdfstream.md index e84764bd54d..becfcefe9a4 100644 --- a/docs/api/puppeteer.page.createpdfstream.md +++ b/docs/api/puppeteer.page.createpdfstream.md @@ -10,7 +10,7 @@ Generates a PDF of the page with the `print` CSS media type. ```typescript class Page { - createPDFStream(options?: PDFOptions): Promise; + abstract createPDFStream(options?: PDFOptions): Promise; } ``` diff --git a/docs/api/puppeteer.page.deletecookie.md b/docs/api/puppeteer.page.deletecookie.md index 3f605bc44dd..140da6a8a48 100644 --- a/docs/api/puppeteer.page.deletecookie.md +++ b/docs/api/puppeteer.page.deletecookie.md @@ -8,7 +8,7 @@ sidebar_label: Page.deleteCookie ```typescript class Page { - deleteCookie( + abstract deleteCookie( ...cookies: Protocol.Network.DeleteCookiesRequest[] ): Promise; } diff --git a/docs/api/puppeteer.page.emulatecputhrottling.md b/docs/api/puppeteer.page.emulatecputhrottling.md index 18b20096042..8ddc81011c1 100644 --- a/docs/api/puppeteer.page.emulatecputhrottling.md +++ b/docs/api/puppeteer.page.emulatecputhrottling.md @@ -10,7 +10,7 @@ Enables CPU throttling to emulate slow CPUs. ```typescript class Page { - emulateCPUThrottling(factor: number | null): Promise; + abstract emulateCPUThrottling(factor: number | null): Promise; } ``` diff --git a/docs/api/puppeteer.page.emulateidlestate.md b/docs/api/puppeteer.page.emulateidlestate.md index c9fbe3c7023..8ea318f355e 100644 --- a/docs/api/puppeteer.page.emulateidlestate.md +++ b/docs/api/puppeteer.page.emulateidlestate.md @@ -10,7 +10,7 @@ Emulates the idle state. If no arguments set, clears idle state emulation. ```typescript class Page { - emulateIdleState(overrides?: { + abstract emulateIdleState(overrides?: { isUserActive: boolean; isScreenUnlocked: boolean; }): Promise; diff --git a/docs/api/puppeteer.page.emulatemediafeatures.md b/docs/api/puppeteer.page.emulatemediafeatures.md index 6e70ca8e80d..7a6c123c5b0 100644 --- a/docs/api/puppeteer.page.emulatemediafeatures.md +++ b/docs/api/puppeteer.page.emulatemediafeatures.md @@ -8,7 +8,7 @@ sidebar_label: Page.emulateMediaFeatures ```typescript class Page { - emulateMediaFeatures(features?: MediaFeature[]): Promise; + abstract emulateMediaFeatures(features?: MediaFeature[]): Promise; } ``` diff --git a/docs/api/puppeteer.page.emulatemediatype.md b/docs/api/puppeteer.page.emulatemediatype.md index 14b033a1b21..77030ae6200 100644 --- a/docs/api/puppeteer.page.emulatemediatype.md +++ b/docs/api/puppeteer.page.emulatemediatype.md @@ -8,7 +8,7 @@ sidebar_label: Page.emulateMediaType ```typescript class Page { - emulateMediaType(type?: string): Promise; + abstract emulateMediaType(type?: string): Promise; } ``` diff --git a/docs/api/puppeteer.page.emulatenetworkconditions.md b/docs/api/puppeteer.page.emulatenetworkconditions.md index c01d9e8531d..2a62672f4fd 100644 --- a/docs/api/puppeteer.page.emulatenetworkconditions.md +++ b/docs/api/puppeteer.page.emulatenetworkconditions.md @@ -12,7 +12,7 @@ A list of predefined network conditions can be used by importing [PredefinedNetw ```typescript class Page { - emulateNetworkConditions( + abstract emulateNetworkConditions( networkConditions: NetworkConditions | null ): Promise; } diff --git a/docs/api/puppeteer.page.emulatetimezone.md b/docs/api/puppeteer.page.emulatetimezone.md index 8208cd2677d..65bea9fb215 100644 --- a/docs/api/puppeteer.page.emulatetimezone.md +++ b/docs/api/puppeteer.page.emulatetimezone.md @@ -8,7 +8,7 @@ sidebar_label: Page.emulateTimezone ```typescript class Page { - emulateTimezone(timezoneId?: string): Promise; + abstract emulateTimezone(timezoneId?: string): Promise; } ``` diff --git a/docs/api/puppeteer.page.emulatevisiondeficiency.md b/docs/api/puppeteer.page.emulatevisiondeficiency.md index 75a63082772..574bf306bff 100644 --- a/docs/api/puppeteer.page.emulatevisiondeficiency.md +++ b/docs/api/puppeteer.page.emulatevisiondeficiency.md @@ -10,7 +10,7 @@ Simulates the given vision deficiency on the page. ```typescript class Page { - emulateVisionDeficiency( + abstract emulateVisionDeficiency( type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type'] ): Promise; } diff --git a/docs/api/puppeteer.page.goback.md b/docs/api/puppeteer.page.goback.md index 5012b63967d..223f109e326 100644 --- a/docs/api/puppeteer.page.goback.md +++ b/docs/api/puppeteer.page.goback.md @@ -10,7 +10,7 @@ This method navigate to the previous page in history. ```typescript class Page { - goBack(options?: WaitForOptions): Promise; + abstract goBack(options?: WaitForOptions): Promise; } ``` diff --git a/docs/api/puppeteer.page.goforward.md b/docs/api/puppeteer.page.goforward.md index f8873bc3a81..1db8224e48d 100644 --- a/docs/api/puppeteer.page.goforward.md +++ b/docs/api/puppeteer.page.goforward.md @@ -10,7 +10,7 @@ This method navigate to the next page in history. ```typescript class Page { - goForward(options?: WaitForOptions): Promise; + abstract goForward(options?: WaitForOptions): Promise; } ``` diff --git a/docs/api/puppeteer.page.isdraginterceptionenabled.md b/docs/api/puppeteer.page.isdraginterceptionenabled.md index b04eda2bf22..034183cb610 100644 --- a/docs/api/puppeteer.page.isdraginterceptionenabled.md +++ b/docs/api/puppeteer.page.isdraginterceptionenabled.md @@ -14,7 +14,7 @@ sidebar_label: Page.isDragInterceptionEnabled ```typescript class Page { - isDragInterceptionEnabled(): boolean; + abstract isDragInterceptionEnabled(): boolean; } ``` diff --git a/docs/api/puppeteer.page.isjavascriptenabled.md b/docs/api/puppeteer.page.isjavascriptenabled.md index 32ed419eb6b..6e2d7307a5d 100644 --- a/docs/api/puppeteer.page.isjavascriptenabled.md +++ b/docs/api/puppeteer.page.isjavascriptenabled.md @@ -10,7 +10,7 @@ sidebar_label: Page.isJavaScriptEnabled ```typescript class Page { - isJavaScriptEnabled(): boolean; + abstract isJavaScriptEnabled(): boolean; } ``` diff --git a/docs/api/puppeteer.page.isserviceworkerbypassed.md b/docs/api/puppeteer.page.isserviceworkerbypassed.md index 78f9d0fe6d0..ce4ea622cd2 100644 --- a/docs/api/puppeteer.page.isserviceworkerbypassed.md +++ b/docs/api/puppeteer.page.isserviceworkerbypassed.md @@ -10,7 +10,7 @@ sidebar_label: Page.isServiceWorkerBypassed ```typescript class Page { - isServiceWorkerBypassed(): boolean; + abstract isServiceWorkerBypassed(): boolean; } ``` diff --git a/docs/api/puppeteer.page.metrics.md b/docs/api/puppeteer.page.metrics.md index 90c34d04218..220f6917a8f 100644 --- a/docs/api/puppeteer.page.metrics.md +++ b/docs/api/puppeteer.page.metrics.md @@ -10,7 +10,7 @@ Object containing metrics as key/value pairs. ```typescript class Page { - metrics(): Promise; + abstract metrics(): Promise; } ``` diff --git a/docs/api/puppeteer.page.removeexposedfunction.md b/docs/api/puppeteer.page.removeexposedfunction.md index 1d55fa305ba..244d63fbdc1 100644 --- a/docs/api/puppeteer.page.removeexposedfunction.md +++ b/docs/api/puppeteer.page.removeexposedfunction.md @@ -10,7 +10,7 @@ The method removes a previously added function via $[Page.exposeFunction()](./pu ```typescript class Page { - removeExposedFunction(name: string): Promise; + abstract removeExposedFunction(name: string): Promise; } ``` diff --git a/docs/api/puppeteer.page.setbypassserviceworker.md b/docs/api/puppeteer.page.setbypassserviceworker.md index 34fbd40ce30..465c79a0f21 100644 --- a/docs/api/puppeteer.page.setbypassserviceworker.md +++ b/docs/api/puppeteer.page.setbypassserviceworker.md @@ -10,7 +10,7 @@ Toggles ignoring of service worker for each request. ```typescript class Page { - setBypassServiceWorker(bypass: boolean): Promise; + abstract setBypassServiceWorker(bypass: boolean): Promise; } ``` diff --git a/docs/api/puppeteer.page.setcookie.md b/docs/api/puppeteer.page.setcookie.md index 1264b319aee..841262cf4b4 100644 --- a/docs/api/puppeteer.page.setcookie.md +++ b/docs/api/puppeteer.page.setcookie.md @@ -8,7 +8,7 @@ sidebar_label: Page.setCookie ```typescript class Page { - setCookie(...cookies: Protocol.Network.CookieParam[]): Promise; + abstract setCookie(...cookies: Protocol.Network.CookieParam[]): Promise; } ``` diff --git a/docs/api/puppeteer.page.setdraginterception.md b/docs/api/puppeteer.page.setdraginterception.md index 219e271af6d..0537d87fa9c 100644 --- a/docs/api/puppeteer.page.setdraginterception.md +++ b/docs/api/puppeteer.page.setdraginterception.md @@ -12,7 +12,7 @@ sidebar_label: Page.setDragInterception ```typescript class Page { - setDragInterception(enabled: boolean): Promise; + abstract setDragInterception(enabled: boolean): Promise; } ``` diff --git a/docs/api/puppeteer.page.setextrahttpheaders.md b/docs/api/puppeteer.page.setextrahttpheaders.md index 947d5c07417..efec8a07956 100644 --- a/docs/api/puppeteer.page.setextrahttpheaders.md +++ b/docs/api/puppeteer.page.setextrahttpheaders.md @@ -22,7 +22,7 @@ page.setExtraHTTPHeaders does not guarantee the order of headers in the outgoing ```typescript class Page { - setExtraHTTPHeaders(headers: Record): Promise; + abstract setExtraHTTPHeaders(headers: Record): Promise; } ``` diff --git a/docs/api/puppeteer.page.setgeolocation.md b/docs/api/puppeteer.page.setgeolocation.md index f73dc9ca204..612f3b3f7ba 100644 --- a/docs/api/puppeteer.page.setgeolocation.md +++ b/docs/api/puppeteer.page.setgeolocation.md @@ -10,7 +10,7 @@ Sets the page's geolocation. ```typescript class Page { - setGeolocation(options: GeolocationOptions): Promise; + abstract setGeolocation(options: GeolocationOptions): Promise; } ``` diff --git a/docs/api/puppeteer.page.setjavascriptenabled.md b/docs/api/puppeteer.page.setjavascriptenabled.md index 8aaca3f216e..80debe1e078 100644 --- a/docs/api/puppeteer.page.setjavascriptenabled.md +++ b/docs/api/puppeteer.page.setjavascriptenabled.md @@ -8,7 +8,7 @@ sidebar_label: Page.setJavaScriptEnabled ```typescript class Page { - setJavaScriptEnabled(enabled: boolean): Promise; + abstract setJavaScriptEnabled(enabled: boolean): Promise; } ``` diff --git a/docs/api/puppeteer.page.setofflinemode.md b/docs/api/puppeteer.page.setofflinemode.md index 7920b6d42ba..ba1a83308b2 100644 --- a/docs/api/puppeteer.page.setofflinemode.md +++ b/docs/api/puppeteer.page.setofflinemode.md @@ -12,7 +12,7 @@ It does not change the parameters used in [Page.emulateNetworkConditions()](./pu ```typescript class Page { - setOfflineMode(enabled: boolean): Promise; + abstract setOfflineMode(enabled: boolean): Promise; } ``` diff --git a/docs/api/puppeteer.page.setrequestinterception.md b/docs/api/puppeteer.page.setrequestinterception.md index 77d9d392e25..2d768e368ba 100644 --- a/docs/api/puppeteer.page.setrequestinterception.md +++ b/docs/api/puppeteer.page.setrequestinterception.md @@ -14,7 +14,7 @@ See the [Request interception guide](https://pptr.dev/next/guides/request-interc ```typescript class Page { - setRequestInterception(value: boolean): Promise; + abstract setRequestInterception(value: boolean): Promise; } ``` diff --git a/docs/api/puppeteer.page.target.md b/docs/api/puppeteer.page.target.md index f44a26b200f..7adf929895b 100644 --- a/docs/api/puppeteer.page.target.md +++ b/docs/api/puppeteer.page.target.md @@ -10,7 +10,7 @@ A target this page was created from. ```typescript class Page { - target(): Target; + abstract target(): Target; } ``` diff --git a/docs/api/puppeteer.page.waitfordeviceprompt.md b/docs/api/puppeteer.page.waitfordeviceprompt.md index a4c402ccfe7..313b6dfc061 100644 --- a/docs/api/puppeteer.page.waitfordeviceprompt.md +++ b/docs/api/puppeteer.page.waitfordeviceprompt.md @@ -16,7 +16,7 @@ This must be called before the device request is made. It will not return a curr ```typescript class Page { - waitForDevicePrompt( + abstract waitForDevicePrompt( options?: WaitTimeoutOptions ): Promise; } diff --git a/docs/api/puppeteer.page.waitforfilechooser.md b/docs/api/puppeteer.page.waitforfilechooser.md index ba2ee47a3d1..8655ea4e52a 100644 --- a/docs/api/puppeteer.page.waitforfilechooser.md +++ b/docs/api/puppeteer.page.waitforfilechooser.md @@ -16,7 +16,9 @@ This must be called before the file chooser is launched. It will not return a cu ```typescript class Page { - waitForFileChooser(options?: WaitTimeoutOptions): Promise; + abstract waitForFileChooser( + options?: WaitTimeoutOptions + ): Promise; } ``` diff --git a/docs/api/puppeteer.page.workers.md b/docs/api/puppeteer.page.workers.md index 64143902414..cb4221730b1 100644 --- a/docs/api/puppeteer.page.workers.md +++ b/docs/api/puppeteer.page.workers.md @@ -10,7 +10,7 @@ All of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/A ```typescript class Page { - workers(): WebWorker[]; + abstract workers(): WebWorker[]; } ``` diff --git a/docs/api/puppeteer.target.browser.md b/docs/api/puppeteer.target.browser.md index 8a113a2ef91..c18b57130f8 100644 --- a/docs/api/puppeteer.target.browser.md +++ b/docs/api/puppeteer.target.browser.md @@ -10,7 +10,7 @@ Get the browser the target belongs to. ```typescript class Target { - browser(): Browser; + abstract browser(): Browser; } ``` diff --git a/docs/api/puppeteer.target.browsercontext.md b/docs/api/puppeteer.target.browsercontext.md index 05121c8fc8c..350f5b62f44 100644 --- a/docs/api/puppeteer.target.browsercontext.md +++ b/docs/api/puppeteer.target.browsercontext.md @@ -10,7 +10,7 @@ Get the browser context the target belongs to. ```typescript class Target { - browserContext(): BrowserContext; + abstract browserContext(): BrowserContext; } ``` diff --git a/docs/api/puppeteer.target.createcdpsession.md b/docs/api/puppeteer.target.createcdpsession.md index d6864001182..29998da7171 100644 --- a/docs/api/puppeteer.target.createcdpsession.md +++ b/docs/api/puppeteer.target.createcdpsession.md @@ -10,7 +10,7 @@ Creates a Chrome Devtools Protocol session attached to the target. ```typescript class Target { - createCDPSession(): Promise; + abstract createCDPSession(): Promise; } ``` diff --git a/docs/api/puppeteer.target.md b/docs/api/puppeteer.target.md index a20eef9f07a..547a6757a9c 100644 --- a/docs/api/puppeteer.target.md +++ b/docs/api/puppeteer.target.md @@ -9,7 +9,7 @@ Target represents a [CDP target](https://chromedevtools.github.io/devtools-proto #### Signature: ```typescript -export declare class Target +export declare abstract class Target ``` ## Remarks diff --git a/docs/api/puppeteer.target.opener.md b/docs/api/puppeteer.target.opener.md index 5ca920bacb7..fdb6c2b16c6 100644 --- a/docs/api/puppeteer.target.opener.md +++ b/docs/api/puppeteer.target.opener.md @@ -10,7 +10,7 @@ Get the target that opened this target. Top-level targets return `null`. ```typescript class Target { - opener(): Target | undefined; + abstract opener(): Target | undefined; } ``` diff --git a/docs/api/puppeteer.target.type.md b/docs/api/puppeteer.target.type.md index ef63849b57e..5f6da0066ff 100644 --- a/docs/api/puppeteer.target.type.md +++ b/docs/api/puppeteer.target.type.md @@ -10,7 +10,7 @@ Identifies what kind of target this is. ```typescript class Target { - type(): TargetType; + abstract type(): TargetType; } ``` diff --git a/docs/api/puppeteer.target.url.md b/docs/api/puppeteer.target.url.md index 54686e20287..a4413bfd7f4 100644 --- a/docs/api/puppeteer.target.url.md +++ b/docs/api/puppeteer.target.url.md @@ -8,7 +8,7 @@ sidebar_label: Target.url ```typescript class Target { - url(): string; + abstract url(): string; } ``` diff --git a/docs/api/puppeteer.unsupportedoperation.md b/docs/api/puppeteer.unsupportedoperation.md new file mode 100644 index 00000000000..c2af3d67efb --- /dev/null +++ b/docs/api/puppeteer.unsupportedoperation.md @@ -0,0 +1,15 @@ +--- +sidebar_label: UnsupportedOperation +--- + +# UnsupportedOperation class + +Puppeteer will throw this error if a method is not supported by the currently used protocol + +#### Signature: + +```typescript +export declare class UnsupportedOperation extends CustomError +``` + +**Extends:** [CustomError](./puppeteer.customerror.md) diff --git a/packages/puppeteer-core/src/api/Browser.ts b/packages/puppeteer-core/src/api/Browser.ts index 07853142302..1dba35dc424 100644 --- a/packages/puppeteer-core/src/api/Browser.ts +++ b/packages/puppeteer-core/src/api/Browser.ts @@ -245,20 +245,6 @@ export abstract class Browser extends EventEmitter { super(); } - /** - * @internal - */ - _attach(): Promise { - throw new Error('Not implemented'); - } - - /** - * @internal - */ - _detach(): void { - throw new Error('Not implemented'); - } - /** * Gets the associated * {@link https://nodejs.org/api/child_process.html#class-childprocess | ChildProcess}. @@ -266,16 +252,7 @@ export abstract class Browser extends EventEmitter { * @returns `null` if this instance was connected to via * {@link Puppeteer.connect}. */ - process(): ChildProcess | null { - throw new Error('Not implemented'); - } - - /** - * @internal - */ - _getIsPageTargetCallback(): IsPageTargetCallback | undefined { - throw new Error('Not implemented'); - } + abstract process(): ChildProcess | null; /** * Creates a new incognito {@link BrowserContext | browser context}. @@ -316,14 +293,6 @@ export abstract class Browser extends EventEmitter { */ abstract defaultBrowserContext(): BrowserContext; - /** - * @internal - */ - _disposeContext(contextId?: string): Promise; - _disposeContext(): Promise { - throw new Error('Not implemented'); - } - /** * Gets the WebSocket URL to connect to this {@link Browser | browser}. * @@ -346,14 +315,6 @@ export abstract class Browser extends EventEmitter { */ abstract newPage(): Promise; - /** - * @internal - */ - _createPageInContext(contextId?: string): Promise; - _createPageInContext(): Promise { - throw new Error('Not implemented'); - } - /** * Gets all active {@link Target | targets}. * @@ -439,9 +400,7 @@ export abstract class Browser extends EventEmitter { * {@link Page | Pages} can override the user agent with * {@link Page.setUserAgent}. */ - userAgent(): Promise { - throw new Error('Not implemented'); - } + abstract userAgent(): Promise; /** * Closes this {@link Browser | browser} and all associated @@ -453,9 +412,7 @@ export abstract class Browser extends EventEmitter { * Disconnects Puppeteer from this {@link Browser | browser}, but leaves the * process running. */ - disconnect(): void { - throw new Error('Not implemented'); - } + abstract disconnect(): void; /** * Whether Puppeteer is connected to this {@link Browser | browser}. diff --git a/packages/puppeteer-core/src/api/BrowserContext.ts b/packages/puppeteer-core/src/api/BrowserContext.ts index 05e36701134..02be7be7802 100644 --- a/packages/puppeteer-core/src/api/BrowserContext.ts +++ b/packages/puppeteer-core/src/api/BrowserContext.ts @@ -107,9 +107,7 @@ export abstract class BrowserContext extends EventEmitter * Gets all active {@link Target | targets} inside this * {@link BrowserContext | browser context}. */ - targets(): Target[] { - throw new Error('Not implemented'); - } + abstract targets(): Target[]; /** * Waits until a {@link Target | target} matching the given `predicate` @@ -167,10 +165,10 @@ export abstract class BrowserContext extends EventEmitter * @param permissions - An array of permissions to grant. All permissions that * are not listed here will be automatically denied. */ - overridePermissions(origin: string, permissions: Permission[]): Promise; - overridePermissions(): Promise { - throw new Error('Not implemented'); - } + abstract overridePermissions( + origin: string, + permissions: Permission[] + ): Promise; /** * Clears all permission overrides for this @@ -186,9 +184,7 @@ export abstract class BrowserContext extends EventEmitter * context.clearPermissionOverrides(); * ``` */ - clearPermissionOverrides(): Promise { - throw new Error('Not implemented'); - } + abstract clearPermissionOverrides(): Promise; /** * Creates a new {@link Page | page} in this diff --git a/packages/puppeteer-core/src/api/CDPSession.ts b/packages/puppeteer-core/src/api/CDPSession.ts index bfe39fb1c70..93f8291c2b3 100644 --- a/packages/puppeteer-core/src/api/CDPSession.ts +++ b/packages/puppeteer-core/src/api/CDPSession.ts @@ -84,9 +84,7 @@ export abstract class CDPSession extends EventEmitter { super(); } - connection(): Connection | undefined { - throw new Error('Not implemented'); - } + abstract connection(): Connection | undefined; /** * Parent session in terms of CDP's auto-attach mechanism. @@ -97,28 +95,19 @@ export abstract class CDPSession extends EventEmitter { return undefined; } - send( + abstract send( method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType'] ): Promise; - send(): Promise< - ProtocolMapping.Commands[T]['returnType'] - > { - throw new Error('Not implemented'); - } /** * Detaches the cdpSession from the target. Once detached, the cdpSession object * won't emit any events and can't be used to send messages. */ - async detach(): Promise { - throw new Error('Not implemented'); - } + abstract detach(): Promise; /** * Returns the session's id. */ - id(): string { - throw new Error('Not implemented'); - } + abstract id(): string; } diff --git a/packages/puppeteer-core/src/api/ElementHandle.ts b/packages/puppeteer-core/src/api/ElementHandle.ts index 71a42eff75a..e166f3103d0 100644 --- a/packages/puppeteer-core/src/api/ElementHandle.ts +++ b/packages/puppeteer-core/src/api/ElementHandle.ts @@ -962,14 +962,12 @@ export abstract class ElementHandle< * {@link https://nodejs.org/api/process.html#process_process_cwd | current working directory}. * For locals script connecting to remote chrome environments, paths must be * absolute. + * */ - async uploadFile( + abstract uploadFile( this: ElementHandle, ...paths: string[] ): Promise; - async uploadFile(this: ElementHandle): Promise { - throw new Error('Not implemented'); - } /** * This method scrolls element into view if needed, and then uses diff --git a/packages/puppeteer-core/src/api/Frame.ts b/packages/puppeteer-core/src/api/Frame.ts index 6695f14a6ec..4e2fca1a2e3 100644 --- a/packages/puppeteer-core/src/api/Frame.ts +++ b/packages/puppeteer-core/src/api/Frame.ts @@ -312,9 +312,7 @@ export abstract class Frame extends EventEmitter { * Is `true` if the frame is an out-of-process (OOP) frame. Otherwise, * `false`. */ - isOOPFrame(): boolean { - throw new Error('Not implemented'); - } + abstract isOOPFrame(): boolean; /** * Navigates the frame to the given `url`. @@ -1197,26 +1195,10 @@ export abstract class Frame extends EventEmitter { * await devicePrompt.waitForDevice(({name}) => name.includes('My Device')) * ); * ``` + * + * @internal */ - waitForDevicePrompt( + abstract waitForDevicePrompt( options?: WaitTimeoutOptions ): Promise; - - /** - * @internal - */ - waitForDevicePrompt(): Promise { - throw new Error('Not implemented'); - } - - /** - * @internal - */ - exposeFunction( - name: string, - fn: (...args: Args) => Awaitable - ): Promise; - exposeFunction(): Promise { - throw new Error('Not implemented'); - } } diff --git a/packages/puppeteer-core/src/api/Input.ts b/packages/puppeteer-core/src/api/Input.ts index 27ff844895b..ab462afbb1b 100644 --- a/packages/puppeteer-core/src/api/Input.ts +++ b/packages/puppeteer-core/src/api/Input.ts @@ -355,7 +355,7 @@ export type MouseButton = (typeof MouseButton)[keyof typeof MouseButton]; * * @public */ -export class Mouse { +export abstract class Mouse { /** * @internal */ @@ -365,9 +365,7 @@ export class Mouse { * Resets the mouse to the default state: No buttons pressed; position at * (0,0). */ - async reset(): Promise { - throw new Error('Not implemented'); - } + abstract reset(): Promise; /** * Moves the mouse to the given coordinate. @@ -376,34 +374,25 @@ export class Mouse { * @param y - Vertical position of the mouse. * @param options - Options to configure behavior. */ - async move( + abstract move( x: number, y: number, options?: Readonly ): Promise; - async move(): Promise { - throw new Error('Not implemented'); - } /** * Presses the mouse. * * @param options - Options to configure behavior. */ - async down(options?: Readonly): Promise; - async down(): Promise { - throw new Error('Not implemented'); - } + abstract down(options?: Readonly): Promise; /** * Releases the mouse. * * @param options - Options to configure behavior. */ - async up(options?: Readonly): Promise; - async up(): Promise { - throw new Error('Not implemented'); - } + abstract up(options?: Readonly): Promise; /** * Shortcut for `mouse.move`, `mouse.down` and `mouse.up`. @@ -412,14 +401,11 @@ export class Mouse { * @param y - Vertical position of the mouse. * @param options - Options to configure behavior. */ - async click( + abstract click( x: number, y: number, options?: Readonly ): Promise; - async click(): Promise { - throw new Error('Not implemented'); - } /** * Dispatches a `mousewheel` event. @@ -443,50 +429,41 @@ export class Mouse { * await page.mouse.wheel({deltaY: -100}); * ``` */ - async wheel(options?: Readonly): Promise; - async wheel(): Promise { - throw new Error('Not implemented'); - } + abstract wheel(options?: Readonly): Promise; /** * Dispatches a `drag` event. * @param start - starting point for drag * @param target - point to drag to */ - async drag(start: Point, target: Point): Promise; - async drag(): Promise { - throw new Error('Not implemented'); - } + abstract drag(start: Point, target: Point): Promise; /** * Dispatches a `dragenter` event. * @param target - point for emitting `dragenter` event * @param data - drag data containing items and operations mask */ - async dragEnter(target: Point, data: Protocol.Input.DragData): Promise; - async dragEnter(): Promise { - throw new Error('Not implemented'); - } + abstract dragEnter( + target: Point, + data: Protocol.Input.DragData + ): Promise; /** * Dispatches a `dragover` event. * @param target - point for emitting `dragover` event * @param data - drag data containing items and operations mask */ - async dragOver(target: Point, data: Protocol.Input.DragData): Promise; - async dragOver(): Promise { - throw new Error('Not implemented'); - } + abstract dragOver( + target: Point, + data: Protocol.Input.DragData + ): Promise; /** * Performs a dragenter, dragover, and drop in sequence. * @param target - point to drop on * @param data - drag data containing items and operations mask */ - async drop(target: Point, data: Protocol.Input.DragData): Promise; - async drop(): Promise { - throw new Error('Not implemented'); - } + abstract drop(target: Point, data: Protocol.Input.DragData): Promise; /** * Performs a drag, dragenter, dragover, and drop in sequence. @@ -496,14 +473,11 @@ export class Mouse { * if specified, is the time to wait between `dragover` and `drop` in milliseconds. * Defaults to 0. */ - async dragAndDrop( + abstract dragAndDrop( start: Point, target: Point, options?: {delay?: number} ): Promise; - async dragAndDrop(): Promise { - throw new Error('Not implemented'); - } } /** diff --git a/packages/puppeteer-core/src/api/JSHandle.ts b/packages/puppeteer-core/src/api/JSHandle.ts index 47109c181fd..1ef8021edf3 100644 --- a/packages/puppeteer-core/src/api/JSHandle.ts +++ b/packages/puppeteer-core/src/api/JSHandle.ts @@ -67,9 +67,7 @@ export abstract class JSHandle { /** * @internal */ - get disposed(): boolean { - throw new Error('Not implemented'); - } + abstract get disposed(): boolean; /** * Evaluates the given function with the current handle as its first argument. diff --git a/packages/puppeteer-core/src/api/Page.ts b/packages/puppeteer-core/src/api/Page.ts index e1193029f5b..632874651dc 100644 --- a/packages/puppeteer-core/src/api/Page.ts +++ b/packages/puppeteer-core/src/api/Page.ts @@ -620,9 +620,7 @@ export abstract class Page extends EventEmitter { /** * `true` if the service worker are being bypassed, `false` otherwise. */ - isServiceWorkerBypassed(): boolean { - throw new Error('Not implemented'); - } + abstract isServiceWorkerBypassed(): boolean; /** * `true` if drag events are being intercepted, `false` otherwise. @@ -631,16 +629,12 @@ export abstract class Page extends EventEmitter { * drag APIs found on {@link ElementHandle} to drag (or just use the * {@link Page.mouse}). */ - isDragInterceptionEnabled(): boolean { - throw new Error('Not implemented'); - } + abstract isDragInterceptionEnabled(): boolean; /** * `true` if the page has JavaScript enabled, `false` otherwise. */ - isJavaScriptEnabled(): boolean { - throw new Error('Not implemented'); - } + abstract isJavaScriptEnabled(): boolean; /** * Listen to page events. @@ -725,10 +719,9 @@ export abstract class Page extends EventEmitter { * await fileChooser.accept(['/tmp/myfile.pdf']); * ``` */ - waitForFileChooser(options?: WaitTimeoutOptions): Promise; - waitForFileChooser(): Promise { - throw new Error('Not implemented'); - } + abstract waitForFileChooser( + options?: WaitTimeoutOptions + ): Promise; /** * Sets the page's geolocation. @@ -743,17 +736,12 @@ export abstract class Page extends EventEmitter { * await page.setGeolocation({latitude: 59.95, longitude: 30.31667}); * ``` */ - async setGeolocation(options: GeolocationOptions): Promise; - async setGeolocation(): Promise { - throw new Error('Not implemented'); - } + abstract setGeolocation(options: GeolocationOptions): Promise; /** * A target this page was created from. */ - target(): Target { - throw new Error('Not implemented'); - } + abstract target(): Target; /** * Get the browser the page belongs to. @@ -776,9 +764,7 @@ export abstract class Page extends EventEmitter { /** * Creates a Chrome Devtools Protocol session attached to the page. */ - createCDPSession(): Promise { - throw new Error('Not implemented'); - } + abstract createCDPSession(): Promise; /** * {@inheritDoc Keyboard} @@ -788,9 +774,7 @@ export abstract class Page extends EventEmitter { /** * {@inheritDoc Touchscreen} */ - get touchscreen(): Touchscreen { - throw new Error('Not implemented'); - } + abstract get touchscreen(): Touchscreen; /** * {@inheritDoc Coverage} @@ -820,9 +804,7 @@ export abstract class Page extends EventEmitter { * @remarks * This does not contain ServiceWorkers */ - workers(): WebWorker[] { - throw new Error('Not implemented'); - } + abstract workers(): WebWorker[]; /** * Activating request interception enables {@link HTTPRequest.abort}, @@ -860,20 +842,14 @@ export abstract class Page extends EventEmitter { * * @param value - Whether to enable request interception. */ - async setRequestInterception(value: boolean): Promise; - async setRequestInterception(): Promise { - throw new Error('Not implemented'); - } + abstract setRequestInterception(value: boolean): Promise; /** * Toggles ignoring of service worker for each request. * * @param bypass - Whether to bypass service worker and load from network. */ - async setBypassServiceWorker(bypass: boolean): Promise; - async setBypassServiceWorker(): Promise { - throw new Error('Not implemented'); - } + abstract setBypassServiceWorker(bypass: boolean): Promise; /** * @param enabled - Whether to enable drag interception. @@ -882,10 +858,7 @@ export abstract class Page extends EventEmitter { * drag APIs found on {@link ElementHandle} to drag (or just use the * {@link Page.mouse}). */ - async setDragInterception(enabled: boolean): Promise; - async setDragInterception(): Promise { - throw new Error('Not implemented'); - } + abstract setDragInterception(enabled: boolean): Promise; /** * Sets the network connection to offline. @@ -894,10 +867,7 @@ export abstract class Page extends EventEmitter { * * @param enabled - When `true`, enables offline mode for the page. */ - setOfflineMode(enabled: boolean): Promise; - setOfflineMode(): Promise { - throw new Error('Not implemented'); - } + abstract setOfflineMode(enabled: boolean): Promise; /** * This does not affect WebSockets and WebRTC PeerConnections (see @@ -926,12 +896,9 @@ export abstract class Page extends EventEmitter { * @param networkConditions - Passing `null` disables network condition * emulation. */ - emulateNetworkConditions( + abstract emulateNetworkConditions( networkConditions: NetworkConditions | null ): Promise; - emulateNetworkConditions(): Promise { - throw new Error('Not implemented'); - } /** * This setting will change the default maximum navigation time for the @@ -1303,17 +1270,11 @@ export abstract class Page extends EventEmitter { * If no URLs are specified, this method returns cookies for the current page * URL. If URLs are specified, only cookies for those URLs are returned. */ - async cookies(...urls: string[]): Promise; - async cookies(): Promise { - throw new Error('Not implemented'); - } + abstract cookies(...urls: string[]): Promise; - async deleteCookie( + abstract deleteCookie( ...cookies: Protocol.Network.DeleteCookiesRequest[] ): Promise; - async deleteCookie(): Promise { - throw new Error('Not implemented'); - } /** * @example @@ -1322,10 +1283,7 @@ export abstract class Page extends EventEmitter { * await page.setCookie(cookieObject1, cookieObject2); * ``` */ - async setCookie(...cookies: Protocol.Network.CookieParam[]): Promise; - async setCookie(): Promise { - throw new Error('Not implemented'); - } + abstract setCookie(...cookies: Protocol.Network.CookieParam[]): Promise; /** * Adds a `