chore: add new UnsupportedOperation Error (#11322)

This commit is contained in:
Nikolay Vitkov 2023-11-09 13:57:33 +01:00 committed by GitHub
parent 245f38234d
commit 0fe89b7da9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
90 changed files with 382 additions and 425 deletions

View File

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

View File

@ -10,7 +10,7 @@ Disconnects Puppeteer from this [browser](./puppeteer.browser.md), but leaves th
```typescript
class Browser {
disconnect(): void;
abstract disconnect(): void;
}
```

View File

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

View File

@ -12,7 +12,7 @@ Gets this [browser's](./puppeteer.browser.md) original user agent.
```typescript
class Browser {
userAgent(): Promise<string>;
abstract userAgent(): Promise<string>;
}
```

View File

@ -10,7 +10,7 @@ Clears all permission overrides for this [browser context](./puppeteer.browserco
```typescript
class BrowserContext {
clearPermissionOverrides(): Promise<void>;
abstract clearPermissionOverrides(): Promise<void>;
}
```

View File

@ -10,7 +10,10 @@ Grants this [browser context](./puppeteer.browsercontext.md) the given `permissi
```typescript
class BrowserContext {
overridePermissions(origin: string, permissions: Permission[]): Promise<void>;
abstract overridePermissions(
origin: string,
permissions: Permission[]
): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Gets all active [targets](./puppeteer.target.md) inside this [browser context](.
```typescript
class BrowserContext {
targets(): Target[];
abstract targets(): Target[];
}
```

View File

@ -8,7 +8,7 @@ sidebar_label: CDPSession.connection
```typescript
class CDPSession {
connection(): Connection | undefined;
abstract connection(): Connection | undefined;
}
```

View File

@ -10,7 +10,7 @@ Detaches the cdpSession from the target. Once detached, the cdpSession object wo
```typescript
class CDPSession {
detach(): Promise<void>;
abstract detach(): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Returns the session's id.
```typescript
class CDPSession {
id(): string;
abstract id(): string;
}
```

View File

@ -8,7 +8,7 @@ sidebar_label: CDPSession.send
```typescript
class CDPSession {
send<T extends keyof ProtocolMapping.Commands>(
abstract send<T extends keyof ProtocolMapping.Commands>(
method: T,
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
): Promise<ProtocolMapping.Commands[T]['returnType']>;

View File

@ -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<HTMLInputElement>,
...paths: string[]
): Promise<void>;

View File

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

View File

@ -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 <code>keydown</code>, <code>keypress</code>/<code>input</code>, and <code>keyup</code> event for each character in the text. |
| [url()](./puppeteer.frame.url.md) | | The frame's URL. |
| [waitForDevicePrompt(options)](./puppeteer.frame.waitfordeviceprompt.md) | | <p>This method is typically coupled with an action that triggers a device request from an api such as WebBluetooth.</p><p>:::caution</p><p>This must be called before the device request is made. It will not return a currently active device prompt.</p><p>:::</p> |
| [waitForFunction(pageFunction, options, args)](./puppeteer.frame.waitforfunction.md) | | |
| [waitForNavigation(options)](./puppeteer.frame.waitfornavigation.md) | | <p>Waits for the frame to navigate. It is useful for when you run code which will indirectly cause the frame to navigate.</p><p>Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.</p> |
| [waitForSelector(selector, options)](./puppeteer.frame.waitforselector.md) | | <p>Waits for an element matching the given selector to appear in the frame.</p><p>This method works across navigations.</p> |

View File

@ -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<DeviceRequestPrompt>;
}
```
## Parameters
| Parameter | Type | Description |
| --------- | ------------------------------------------------------- | ------------ |
| options | [WaitTimeoutOptions](./puppeteer.waittimeoutoptions.md) | _(Optional)_ |
**Returns:**
Promise&lt;[DeviceRequestPrompt](./puppeteer.devicerequestprompt.md)&gt;
## Example
```ts
const [devicePrompt] = Promise.all([
frame.waitForDevicePrompt(),
frame.click('#connect-bluetooth'),
]);
await devicePrompt.select(
await devicePrompt.waitForDevice(({name}) => name.includes('My Device'))
);
```

View File

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

View File

@ -10,7 +10,7 @@ Presses the mouse.
```typescript
class Mouse {
down(options?: Readonly<MouseOptions>): Promise<void>;
abstract down(options?: Readonly<MouseOptions>): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Dispatches a `drag` event.
```typescript
class Mouse {
drag(start: Point, target: Point): Promise<Protocol.Input.DragData>;
abstract drag(start: Point, target: Point): Promise<Protocol.Input.DragData>;
}
```

View File

@ -10,7 +10,7 @@ Performs a drag, dragenter, dragover, and drop in sequence.
```typescript
class Mouse {
dragAndDrop(
abstract dragAndDrop(
start: Point,
target: Point,
options?: {

View File

@ -10,7 +10,10 @@ Dispatches a `dragenter` event.
```typescript
class Mouse {
dragEnter(target: Point, data: Protocol.Input.DragData): Promise<void>;
abstract dragEnter(
target: Point,
data: Protocol.Input.DragData
): Promise<void>;
}
```

View File

@ -10,7 +10,10 @@ Dispatches a `dragover` event.
```typescript
class Mouse {
dragOver(target: Point, data: Protocol.Input.DragData): Promise<void>;
abstract dragOver(
target: Point,
data: Protocol.Input.DragData
): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Performs a dragenter, dragover, and drop in sequence.
```typescript
class Mouse {
drop(target: Point, data: Protocol.Input.DragData): Promise<void>;
abstract drop(target: Point, data: Protocol.Input.DragData): Promise<void>;
}
```

View File

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

View File

@ -10,7 +10,7 @@ Moves the mouse to the given coordinate.
```typescript
class Mouse {
move(
abstract move(
x: number,
y: number,
options?: Readonly<MouseMoveOptions>

View File

@ -10,7 +10,7 @@ Resets the mouse to the default state: No buttons pressed; position at (0,0).
```typescript
class Mouse {
reset(): Promise<void>;
abstract reset(): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Releases the mouse.
```typescript
class Mouse {
up(options?: Readonly<MouseOptions>): Promise<void>;
abstract up(options?: Readonly<MouseOptions>): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Dispatches a `mousewheel` event.
```typescript
class Mouse {
wheel(options?: Readonly<MouseWheelOptions>): Promise<void>;
abstract wheel(options?: Readonly<MouseWheelOptions>): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Provide credentials for `HTTP authentication`.
```typescript
class Page {
authenticate(credentials: Credentials): Promise<void>;
abstract authenticate(credentials: Credentials): Promise<void>;
}
```

View File

@ -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<Protocol.Network.Cookie[]>;
abstract cookies(...urls: string[]): Promise<Protocol.Network.Cookie[]>;
}
```

View File

@ -10,7 +10,7 @@ Creates a Chrome Devtools Protocol session attached to the page.
```typescript
class Page {
createCDPSession(): Promise<CDPSession>;
abstract createCDPSession(): Promise<CDPSession>;
}
```

View File

@ -10,7 +10,7 @@ Generates a PDF of the page with the `print` CSS media type.
```typescript
class Page {
createPDFStream(options?: PDFOptions): Promise<Readable>;
abstract createPDFStream(options?: PDFOptions): Promise<Readable>;
}
```

View File

@ -8,7 +8,7 @@ sidebar_label: Page.deleteCookie
```typescript
class Page {
deleteCookie(
abstract deleteCookie(
...cookies: Protocol.Network.DeleteCookiesRequest[]
): Promise<void>;
}

View File

@ -10,7 +10,7 @@ Enables CPU throttling to emulate slow CPUs.
```typescript
class Page {
emulateCPUThrottling(factor: number | null): Promise<void>;
abstract emulateCPUThrottling(factor: number | null): Promise<void>;
}
```

View File

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

View File

@ -8,7 +8,7 @@ sidebar_label: Page.emulateMediaFeatures
```typescript
class Page {
emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
abstract emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
}
```

View File

@ -8,7 +8,7 @@ sidebar_label: Page.emulateMediaType
```typescript
class Page {
emulateMediaType(type?: string): Promise<void>;
abstract emulateMediaType(type?: string): Promise<void>;
}
```

View File

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

View File

@ -8,7 +8,7 @@ sidebar_label: Page.emulateTimezone
```typescript
class Page {
emulateTimezone(timezoneId?: string): Promise<void>;
abstract emulateTimezone(timezoneId?: string): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Simulates the given vision deficiency on the page.
```typescript
class Page {
emulateVisionDeficiency(
abstract emulateVisionDeficiency(
type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']
): Promise<void>;
}

View File

@ -10,7 +10,7 @@ This method navigate to the previous page in history.
```typescript
class Page {
goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
abstract goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
}
```

View File

@ -10,7 +10,7 @@ This method navigate to the next page in history.
```typescript
class Page {
goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
abstract goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
}
```

View File

@ -14,7 +14,7 @@ sidebar_label: Page.isDragInterceptionEnabled
```typescript
class Page {
isDragInterceptionEnabled(): boolean;
abstract isDragInterceptionEnabled(): boolean;
}
```

View File

@ -10,7 +10,7 @@ sidebar_label: Page.isJavaScriptEnabled
```typescript
class Page {
isJavaScriptEnabled(): boolean;
abstract isJavaScriptEnabled(): boolean;
}
```

View File

@ -10,7 +10,7 @@ sidebar_label: Page.isServiceWorkerBypassed
```typescript
class Page {
isServiceWorkerBypassed(): boolean;
abstract isServiceWorkerBypassed(): boolean;
}
```

View File

@ -10,7 +10,7 @@ Object containing metrics as key/value pairs.
```typescript
class Page {
metrics(): Promise<Metrics>;
abstract metrics(): Promise<Metrics>;
}
```

View File

@ -10,7 +10,7 @@ The method removes a previously added function via $[Page.exposeFunction()](./pu
```typescript
class Page {
removeExposedFunction(name: string): Promise<void>;
abstract removeExposedFunction(name: string): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Toggles ignoring of service worker for each request.
```typescript
class Page {
setBypassServiceWorker(bypass: boolean): Promise<void>;
abstract setBypassServiceWorker(bypass: boolean): Promise<void>;
}
```

View File

@ -8,7 +8,7 @@ sidebar_label: Page.setCookie
```typescript
class Page {
setCookie(...cookies: Protocol.Network.CookieParam[]): Promise<void>;
abstract setCookie(...cookies: Protocol.Network.CookieParam[]): Promise<void>;
}
```

View File

@ -12,7 +12,7 @@ sidebar_label: Page.setDragInterception
```typescript
class Page {
setDragInterception(enabled: boolean): Promise<void>;
abstract setDragInterception(enabled: boolean): Promise<void>;
}
```

View File

@ -22,7 +22,7 @@ page.setExtraHTTPHeaders does not guarantee the order of headers in the outgoing
```typescript
class Page {
setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
abstract setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ Sets the page's geolocation.
```typescript
class Page {
setGeolocation(options: GeolocationOptions): Promise<void>;
abstract setGeolocation(options: GeolocationOptions): Promise<void>;
}
```

View File

@ -8,7 +8,7 @@ sidebar_label: Page.setJavaScriptEnabled
```typescript
class Page {
setJavaScriptEnabled(enabled: boolean): Promise<void>;
abstract setJavaScriptEnabled(enabled: boolean): Promise<void>;
}
```

View File

@ -12,7 +12,7 @@ It does not change the parameters used in [Page.emulateNetworkConditions()](./pu
```typescript
class Page {
setOfflineMode(enabled: boolean): Promise<void>;
abstract setOfflineMode(enabled: boolean): Promise<void>;
}
```

View File

@ -14,7 +14,7 @@ See the [Request interception guide](https://pptr.dev/next/guides/request-interc
```typescript
class Page {
setRequestInterception(value: boolean): Promise<void>;
abstract setRequestInterception(value: boolean): Promise<void>;
}
```

View File

@ -10,7 +10,7 @@ A target this page was created from.
```typescript
class Page {
target(): Target;
abstract target(): Target;
}
```

View File

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

View File

@ -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<FileChooser>;
abstract waitForFileChooser(
options?: WaitTimeoutOptions
): Promise<FileChooser>;
}
```

View File

@ -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[];
}
```

View File

@ -10,7 +10,7 @@ Get the browser the target belongs to.
```typescript
class Target {
browser(): Browser;
abstract browser(): Browser;
}
```

View File

@ -10,7 +10,7 @@ Get the browser context the target belongs to.
```typescript
class Target {
browserContext(): BrowserContext;
abstract browserContext(): BrowserContext;
}
```

View File

@ -10,7 +10,7 @@ Creates a Chrome Devtools Protocol session attached to the target.
```typescript
class Target {
createCDPSession(): Promise<CDPSession>;
abstract createCDPSession(): Promise<CDPSession>;
}
```

View File

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

View File

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

View File

@ -10,7 +10,7 @@ Identifies what kind of target this is.
```typescript
class Target {
type(): TargetType;
abstract type(): TargetType;
}
```

View File

@ -8,7 +8,7 @@ sidebar_label: Target.url
```typescript
class Target {
url(): string;
abstract url(): string;
}
```

View File

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

View File

@ -245,20 +245,6 @@ export abstract class Browser extends EventEmitter<BrowserEvents> {
super();
}
/**
* @internal
*/
_attach(): Promise<void> {
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<BrowserEvents> {
* @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<BrowserEvents> {
*/
abstract defaultBrowserContext(): BrowserContext;
/**
* @internal
*/
_disposeContext(contextId?: string): Promise<void>;
_disposeContext(): Promise<void> {
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<BrowserEvents> {
*/
abstract newPage(): Promise<Page>;
/**
* @internal
*/
_createPageInContext(contextId?: string): Promise<Page>;
_createPageInContext(): Promise<Page> {
throw new Error('Not implemented');
}
/**
* Gets all active {@link Target | targets}.
*
@ -439,9 +400,7 @@ export abstract class Browser extends EventEmitter<BrowserEvents> {
* {@link Page | Pages} can override the user agent with
* {@link Page.setUserAgent}.
*/
userAgent(): Promise<string> {
throw new Error('Not implemented');
}
abstract userAgent(): Promise<string>;
/**
* Closes this {@link Browser | browser} and all associated
@ -453,9 +412,7 @@ export abstract class Browser extends EventEmitter<BrowserEvents> {
* 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}.

View File

@ -107,9 +107,7 @@ export abstract class BrowserContext extends EventEmitter<BrowserContextEvents>
* 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<BrowserContextEvents>
* @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<void>;
overridePermissions(): Promise<void> {
throw new Error('Not implemented');
}
abstract overridePermissions(
origin: string,
permissions: Permission[]
): Promise<void>;
/**
* Clears all permission overrides for this
@ -186,9 +184,7 @@ export abstract class BrowserContext extends EventEmitter<BrowserContextEvents>
* context.clearPermissionOverrides();
* ```
*/
clearPermissionOverrides(): Promise<void> {
throw new Error('Not implemented');
}
abstract clearPermissionOverrides(): Promise<void>;
/**
* Creates a new {@link Page | page} in this

View File

@ -84,9 +84,7 @@ export abstract class CDPSession extends EventEmitter<CDPSessionEvents> {
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<CDPSessionEvents> {
return undefined;
}
send<T extends keyof ProtocolMapping.Commands>(
abstract send<T extends keyof ProtocolMapping.Commands>(
method: T,
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
): Promise<ProtocolMapping.Commands[T]['returnType']>;
send<T extends keyof ProtocolMapping.Commands>(): 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<void> {
throw new Error('Not implemented');
}
abstract detach(): Promise<void>;
/**
* Returns the session's id.
*/
id(): string {
throw new Error('Not implemented');
}
abstract id(): string;
}

View File

@ -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<HTMLInputElement>,
...paths: string[]
): Promise<void>;
async uploadFile(this: ElementHandle<HTMLInputElement>): Promise<void> {
throw new Error('Not implemented');
}
/**
* This method scrolls element into view if needed, and then uses

View File

@ -312,9 +312,7 @@ export abstract class Frame extends EventEmitter<FrameEvents> {
* 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<FrameEvents> {
* await devicePrompt.waitForDevice(({name}) => name.includes('My Device'))
* );
* ```
*
* @internal
*/
waitForDevicePrompt(
abstract waitForDevicePrompt(
options?: WaitTimeoutOptions
): Promise<DeviceRequestPrompt>;
/**
* @internal
*/
waitForDevicePrompt(): Promise<DeviceRequestPrompt> {
throw new Error('Not implemented');
}
/**
* @internal
*/
exposeFunction<Args extends unknown[], Ret>(
name: string,
fn: (...args: Args) => Awaitable<Ret>
): Promise<void>;
exposeFunction(): Promise<void> {
throw new Error('Not implemented');
}
}

View File

@ -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<void> {
throw new Error('Not implemented');
}
abstract reset(): Promise<void>;
/**
* 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<MouseMoveOptions>
): Promise<void>;
async move(): Promise<void> {
throw new Error('Not implemented');
}
/**
* Presses the mouse.
*
* @param options - Options to configure behavior.
*/
async down(options?: Readonly<MouseOptions>): Promise<void>;
async down(): Promise<void> {
throw new Error('Not implemented');
}
abstract down(options?: Readonly<MouseOptions>): Promise<void>;
/**
* Releases the mouse.
*
* @param options - Options to configure behavior.
*/
async up(options?: Readonly<MouseOptions>): Promise<void>;
async up(): Promise<void> {
throw new Error('Not implemented');
}
abstract up(options?: Readonly<MouseOptions>): Promise<void>;
/**
* 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<MouseClickOptions>
): Promise<void>;
async click(): Promise<void> {
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<MouseWheelOptions>): Promise<void>;
async wheel(): Promise<void> {
throw new Error('Not implemented');
}
abstract wheel(options?: Readonly<MouseWheelOptions>): Promise<void>;
/**
* Dispatches a `drag` event.
* @param start - starting point for drag
* @param target - point to drag to
*/
async drag(start: Point, target: Point): Promise<Protocol.Input.DragData>;
async drag(): Promise<Protocol.Input.DragData> {
throw new Error('Not implemented');
}
abstract drag(start: Point, target: Point): Promise<Protocol.Input.DragData>;
/**
* 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<void>;
async dragEnter(): Promise<void> {
throw new Error('Not implemented');
}
abstract dragEnter(
target: Point,
data: Protocol.Input.DragData
): Promise<void>;
/**
* 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<void>;
async dragOver(): Promise<void> {
throw new Error('Not implemented');
}
abstract dragOver(
target: Point,
data: Protocol.Input.DragData
): Promise<void>;
/**
* 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<void>;
async drop(): Promise<void> {
throw new Error('Not implemented');
}
abstract drop(target: Point, data: Protocol.Input.DragData): Promise<void>;
/**
* 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<void>;
async dragAndDrop(): Promise<void> {
throw new Error('Not implemented');
}
}
/**

View File

@ -67,9 +67,7 @@ export abstract class JSHandle<T = unknown> {
/**
* @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.

View File

@ -620,9 +620,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
/**
* `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<PageEvents> {
* 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<PageEvents> {
* await fileChooser.accept(['/tmp/myfile.pdf']);
* ```
*/
waitForFileChooser(options?: WaitTimeoutOptions): Promise<FileChooser>;
waitForFileChooser(): Promise<FileChooser> {
throw new Error('Not implemented');
}
abstract waitForFileChooser(
options?: WaitTimeoutOptions
): Promise<FileChooser>;
/**
* Sets the page's geolocation.
@ -743,17 +736,12 @@ export abstract class Page extends EventEmitter<PageEvents> {
* await page.setGeolocation({latitude: 59.95, longitude: 30.31667});
* ```
*/
async setGeolocation(options: GeolocationOptions): Promise<void>;
async setGeolocation(): Promise<void> {
throw new Error('Not implemented');
}
abstract setGeolocation(options: GeolocationOptions): Promise<void>;
/**
* 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<PageEvents> {
/**
* Creates a Chrome Devtools Protocol session attached to the page.
*/
createCDPSession(): Promise<CDPSession> {
throw new Error('Not implemented');
}
abstract createCDPSession(): Promise<CDPSession>;
/**
* {@inheritDoc Keyboard}
@ -788,9 +774,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
/**
* {@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<PageEvents> {
* @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<PageEvents> {
*
* @param value - Whether to enable request interception.
*/
async setRequestInterception(value: boolean): Promise<void>;
async setRequestInterception(): Promise<void> {
throw new Error('Not implemented');
}
abstract setRequestInterception(value: boolean): Promise<void>;
/**
* Toggles ignoring of service worker for each request.
*
* @param bypass - Whether to bypass service worker and load from network.
*/
async setBypassServiceWorker(bypass: boolean): Promise<void>;
async setBypassServiceWorker(): Promise<void> {
throw new Error('Not implemented');
}
abstract setBypassServiceWorker(bypass: boolean): Promise<void>;
/**
* @param enabled - Whether to enable drag interception.
@ -882,10 +858,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* drag APIs found on {@link ElementHandle} to drag (or just use the
* {@link Page.mouse}).
*/
async setDragInterception(enabled: boolean): Promise<void>;
async setDragInterception(): Promise<void> {
throw new Error('Not implemented');
}
abstract setDragInterception(enabled: boolean): Promise<void>;
/**
* Sets the network connection to offline.
@ -894,10 +867,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @param enabled - When `true`, enables offline mode for the page.
*/
setOfflineMode(enabled: boolean): Promise<void>;
setOfflineMode(): Promise<void> {
throw new Error('Not implemented');
}
abstract setOfflineMode(enabled: boolean): Promise<void>;
/**
* This does not affect WebSockets and WebRTC PeerConnections (see
@ -926,12 +896,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @param networkConditions - Passing `null` disables network condition
* emulation.
*/
emulateNetworkConditions(
abstract emulateNetworkConditions(
networkConditions: NetworkConditions | null
): Promise<void>;
emulateNetworkConditions(): Promise<void> {
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<PageEvents> {
* 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<Protocol.Network.Cookie[]>;
async cookies(): Promise<Protocol.Network.Cookie[]> {
throw new Error('Not implemented');
}
abstract cookies(...urls: string[]): Promise<Protocol.Network.Cookie[]>;
async deleteCookie(
abstract deleteCookie(
...cookies: Protocol.Network.DeleteCookiesRequest[]
): Promise<void>;
async deleteCookie(): Promise<void> {
throw new Error('Not implemented');
}
/**
* @example
@ -1322,10 +1283,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* await page.setCookie(cookieObject1, cookieObject2);
* ```
*/
async setCookie(...cookies: Protocol.Network.CookieParam[]): Promise<void>;
async setCookie(): Promise<void> {
throw new Error('Not implemented');
}
abstract setCookie(...cookies: Protocol.Network.CookieParam[]): Promise<void>;
/**
* Adds a `<script>` tag into the page with the desired URL or content.
@ -1445,10 +1403,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* The method removes a previously added function via ${@link Page.exposeFunction}
* called `name` from the page's `window` object.
*/
async removeExposedFunction(name: string): Promise<void>;
async removeExposedFunction(): Promise<void> {
throw new Error('Not implemented');
}
abstract removeExposedFunction(name: string): Promise<void>;
/**
* Provide credentials for `HTTP authentication`.
@ -1456,10 +1411,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @remarks
* To disable authentication, pass `null`.
*/
async authenticate(credentials: Credentials): Promise<void>;
async authenticate(): Promise<void> {
throw new Error('Not implemented');
}
abstract authenticate(credentials: Credentials): Promise<void>;
/**
* The extra HTTP headers will be sent with every request the page initiates.
@ -1481,10 +1433,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* @param headers - An object containing additional HTTP headers to be sent
* with every request. All header values must be strings.
*/
async setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
async setExtraHTTPHeaders(): Promise<void> {
throw new Error('Not implemented');
}
abstract setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
/**
* @param userAgent - Specific user agent to use in this page
@ -1533,9 +1482,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* All timestamps are in monotonic time: monotonically increasing time
* in seconds since an arbitrary point in the past.
*/
async metrics(): Promise<Metrics> {
throw new Error('Not implemented');
}
abstract metrics(): Promise<Metrics>;
/**
* The page's URL.
@ -1838,10 +1785,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* - `networkidle2` : consider navigation to be finished when there are no
* more than 2 network connections for at least `500` ms.
*/
async goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
async goBack(): Promise<HTTPResponse | null> {
throw new Error('Not implemented');
}
abstract goBack(options?: WaitForOptions): Promise<HTTPResponse | null>;
/**
* This method navigate to the next page in history.
@ -1869,10 +1813,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* - `networkidle2` : consider navigation to be finished when there are no
* more than 2 network connections for at least `500` ms.
*/
async goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
async goForward(): Promise<HTTPResponse | null> {
throw new Error('Not implemented');
}
abstract goForward(options?: WaitForOptions): Promise<HTTPResponse | null>;
/**
* Brings page to front (activates tab).
@ -1922,10 +1863,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* NOTE: changing this value won't affect scripts that have already been run.
* It will take full effect on the next navigation.
*/
async setJavaScriptEnabled(enabled: boolean): Promise<void>;
async setJavaScriptEnabled(): Promise<void> {
throw new Error('Not implemented');
}
abstract setJavaScriptEnabled(enabled: boolean): Promise<void>;
/**
* Toggles bypassing page's Content-Security-Policy.
@ -1962,19 +1900,13 @@ export abstract class Page extends EventEmitter<PageEvents> {
* // → false
* ```
*/
async emulateMediaType(type?: string): Promise<void>;
async emulateMediaType(): Promise<void> {
throw new Error('Not implemented');
}
abstract emulateMediaType(type?: string): Promise<void>;
/**
* Enables CPU throttling to emulate slow CPUs.
* @param factor - slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
*/
async emulateCPUThrottling(factor: number | null): Promise<void>;
async emulateCPUThrottling(): Promise<void> {
throw new Error('Not implemented');
}
abstract emulateCPUThrottling(factor: number | null): Promise<void>;
/**
* @param features - `<?Array<Object>>` Given an array of media feature
@ -2037,10 +1969,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* // → false
* ```
*/
async emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
async emulateMediaFeatures(): Promise<void> {
throw new Error('Not implemented');
}
abstract emulateMediaFeatures(features?: MediaFeature[]): Promise<void>;
/**
* @param timezoneId - Changes the timezone of the page. See
@ -2048,10 +1977,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
* for a list of supported timezone IDs. Passing
* `null` disables timezone emulation.
*/
async emulateTimezone(timezoneId?: string): Promise<void>;
async emulateTimezone(): Promise<void> {
throw new Error('Not implemented');
}
abstract emulateTimezone(timezoneId?: string): Promise<void>;
/**
* Emulates the idle state.
@ -2072,13 +1998,10 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @param overrides - Mock idle state. If not set, clears idle overrides
*/
async emulateIdleState(overrides?: {
abstract emulateIdleState(overrides?: {
isUserActive: boolean;
isScreenUnlocked: boolean;
}): Promise<void>;
async emulateIdleState(): Promise<void> {
throw new Error('Not implemented');
}
/**
* Simulates the given vision deficiency on the page.
@ -2108,12 +2031,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @param type - the type of deficiency to simulate, or `'none'` to reset.
*/
async emulateVisionDeficiency(
abstract emulateVisionDeficiency(
type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']
): Promise<void>;
async emulateVisionDeficiency(): Promise<void> {
throw new Error('Not implemented');
}
/**
* `page.setViewport` will resize the page. A lot of websites don't expect
@ -2734,10 +2654,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
*
* @param options - options for generating the PDF.
*/
async createPDFStream(options?: PDFOptions): Promise<Readable>;
async createPDFStream(): Promise<Readable> {
throw new Error('Not implemented');
}
abstract createPDFStream(options?: PDFOptions): Promise<Readable>;
/**
* {@inheritDoc Page.createPDFStream}
@ -3139,12 +3056,9 @@ export abstract class Page extends EventEmitter<PageEvents> {
* );
* ```
*/
waitForDevicePrompt(
abstract waitForDevicePrompt(
options?: WaitTimeoutOptions
): Promise<DeviceRequestPrompt>;
waitForDevicePrompt(): Promise<DeviceRequestPrompt> {
throw new Error('Not implemented');
}
/** @internal */
[disposeSymbol](): void {

View File

@ -45,7 +45,7 @@ export enum TargetType {
* worker.
* @public
*/
export class Target {
export abstract class Target {
/**
* @internal
*/
@ -66,16 +66,12 @@ export class Target {
return null;
}
url(): string {
throw new Error('not implemented');
}
abstract url(): string;
/**
* Creates a Chrome Devtools Protocol session attached to the target.
*/
createCDPSession(): Promise<CDPSession> {
throw new Error('not implemented');
}
abstract createCDPSession(): Promise<CDPSession>;
/**
* Identifies what kind of target this is.
@ -84,28 +80,20 @@ export class Target {
*
* See {@link https://developer.chrome.com/extensions/background_pages | docs} for more info about background pages.
*/
type(): TargetType {
throw new Error('not implemented');
}
abstract type(): TargetType;
/**
* Get the browser the target belongs to.
*/
browser(): Browser {
throw new Error('not implemented');
}
abstract browser(): Browser;
/**
* Get the browser context the target belongs to.
*/
browserContext(): BrowserContext {
throw new Error('not implemented');
}
abstract browserContext(): BrowserContext;
/**
* Get the target that opened this target. Top-level targets return `null`.
*/
opener(): Target | undefined {
throw new Error('not implemented');
}
abstract opener(): Target | undefined;
}

View File

@ -27,6 +27,7 @@ import {
import {BrowserContextEvent} from '../api/BrowserContext.js';
import type {Page} from '../api/Page.js';
import type {Target} from '../api/Target.js';
import {UnsupportedOperation} from '../common/Errors.js';
import type {Handler} from '../common/EventEmitter.js';
import {debugError} from '../common/util.js';
import type {Viewport} from '../common/Viewport.js';
@ -165,6 +166,10 @@ export class BidiBrowser extends Browser {
}
}
override userAgent(): Promise<string> {
throw new UnsupportedOperation();
}
#onContextDomLoaded(event: Bidi.BrowsingContext.Info) {
const target = this.#targets.get(event.context);
if (target) {
@ -315,4 +320,8 @@ export class BidiBrowser extends Browser {
override target(): Target {
return this.#browserTarget;
}
override disconnect(): void {
this;
}
}

View File

@ -20,6 +20,7 @@ import type {WaitForTargetOptions} from '../api/Browser.js';
import {BrowserContext} from '../api/BrowserContext.js';
import type {Page} from '../api/Page.js';
import type {Target} from '../api/Target.js';
import {UnsupportedOperation} from '../common/Errors.js';
import type {Viewport} from '../common/Viewport.js';
import type {BidiBrowser} from './Browser.js';
@ -124,4 +125,12 @@ export class BidiBrowserContext extends BrowserContext {
override isIncognito(): boolean {
return !this.#isDefault;
}
override overridePermissions(): Promise<void> {
throw new UnsupportedOperation();
}
override clearPermissionOverrides(): Promise<void> {
throw new UnsupportedOperation();
}
}

View File

@ -3,7 +3,7 @@ import type ProtocolMapping from 'devtools-protocol/types/protocol-mapping.js';
import {CDPSession} from '../api/CDPSession.js';
import type {Connection as CdpConnection} from '../cdp/Connection.js';
import {TargetCloseError} from '../common/Errors.js';
import {TargetCloseError, UnsupportedOperation} from '../common/Errors.js';
import type {EventType} from '../common/EventEmitter.js';
import {debugError} from '../common/util.js';
import {Deferred} from '../util/Deferred.js';
@ -57,7 +57,7 @@ export class CdpSessionWrapper extends CDPSession {
...paramArgs: ProtocolMapping.Commands[T]['paramsType']
): Promise<ProtocolMapping.Commands[T]['returnType']> {
if (!this.#context.supportsCdp()) {
throw new Error(
throw new UnsupportedOperation(
'CDP support is required for this feature. The current browser does not support CDP.'
);
}

View File

@ -17,6 +17,7 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import {type AutofillData, ElementHandle} from '../api/ElementHandle.js';
import {UnsupportedOperation} from '../common/Errors.js';
import {throwIfDisposed} from '../util/decorators.js';
import type {BidiFrame} from './Frame.js';
@ -89,4 +90,8 @@ export class BidiElementHandle<
}
return null;
}
override uploadFile(this: ElementHandle<HTMLInputElement>): Promise<void> {
throw new UnsupportedOperation();
}
}

View File

@ -34,9 +34,11 @@ import {
type WaitForOptions,
throwIfDetached,
} from '../api/Frame.js';
import {UnsupportedOperation} from '../common/Errors.js';
import type {TimeoutSettings} from '../common/TimeoutSettings.js';
import type {Awaitable} from '../common/types.js';
import {UTILITY_WORLD_NAME, setPageContent, timeout} from '../common/util.js';
import type {DeviceRequestPrompt} from '../puppeteer-core.js';
import {Deferred} from '../util/Deferred.js';
import {disposeSymbol} from '../util/disposable.js';
@ -109,6 +111,10 @@ export class BidiFrame extends Frame {
return this.#page;
}
override isOOPFrame(): boolean {
throw new UnsupportedOperation();
}
override url(): string {
return this.#context.url;
}
@ -227,6 +233,10 @@ export class BidiFrame extends Frame {
return this.#page.getNavigationResponse(response?.result.navigation);
}
override waitForDevicePrompt(): Promise<DeviceRequestPrompt> {
throw new UnsupportedOperation();
}
override get detached(): boolean {
return this.#disposed;
}
@ -243,7 +253,7 @@ export class BidiFrame extends Frame {
}
#exposedFunctions = new Map<string, ExposeableFunction<never[], unknown>>();
override async exposeFunction<Args extends unknown[], Ret>(
async exposeFunction<Args extends unknown[], Ret>(
name: string,
apply: (...args: Args) => Awaitable<Ret>
): Promise<void> {

View File

@ -16,6 +16,7 @@
import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type {Protocol} from 'devtools-protocol';
import type {CDPSession} from '../api/CDPSession.js';
import type {Frame} from '../api/Frame.js';
import type {
ContinueRequestOverrides,
@ -23,7 +24,7 @@ import type {
ResponseForRequest,
} from '../api/HTTPRequest.js';
import {HTTPRequest, type ResourceType} from '../api/HTTPRequest.js';
import type {CDPSession} from '../puppeteer-core.js';
import {UnsupportedOperation} from '../common/Errors.js';
import type {BidiHTTPResponse} from './HTTPResponse.js';
@ -72,7 +73,7 @@ export class BidiHTTPRequest extends HTTPRequest {
}
override get client(): CDPSession {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override url(): string {
@ -123,47 +124,47 @@ export class BidiHTTPRequest extends HTTPRequest {
}
override continueRequestOverrides(): ContinueRequestOverrides {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override async continue(
_overrides: ContinueRequestOverrides = {}
): Promise<void> {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override responseForRequest(): Partial<ResponseForRequest> {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override abortErrorReason(): Protocol.Network.ErrorReason | null {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override interceptResolutionState(): InterceptResolutionState {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override isInterceptResolutionHandled(): boolean {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override async finalizeInterceptions(): Promise<void> {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override abort(): Promise<void> {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override respond(
_response: Partial<ResponseForRequest>,
_priority?: number
): Promise<void> {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override failure(): {errorText: string} | null {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
}

View File

@ -21,6 +21,7 @@ import {
HTTPResponse as HTTPResponse,
type RemoteAddress,
} from '../api/HTTPResponse.js';
import {UnsupportedOperation} from '../common/Errors.js';
import type {SecurityDetails} from '../common/SecurityDetails.js';
import type {BidiHTTPRequest} from './HTTPRequest.js';
@ -108,10 +109,10 @@ export class BidiHTTPResponse extends HTTPResponse {
}
override securityDetails(): SecurityDetails | null {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
override buffer(): Promise<Buffer> {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
}

View File

@ -15,6 +15,7 @@
*/
import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type Protocol from 'devtools-protocol';
import type {Point} from '../api/ElementHandle.js';
import {
@ -30,6 +31,7 @@ import {
type MouseOptions,
type MouseWheelOptions,
} from '../api/Input.js';
import {UnsupportedOperation} from '../common/Errors.js';
import type {KeyInput} from '../common/USKeyboardLayout.js';
import type {BrowsingContext} from './BrowsingContext.js';
@ -627,6 +629,26 @@ export class BidiMouse extends Mouse {
],
});
}
override drag(): Promise<Protocol.Input.DragData> {
throw new UnsupportedOperation();
}
override dragOver(): Promise<void> {
throw new UnsupportedOperation();
}
override dragEnter(): Promise<void> {
throw new UnsupportedOperation();
}
override drop(): Promise<void> {
throw new UnsupportedOperation();
}
override dragAndDrop(): Promise<void> {
throw new UnsupportedOperation();
}
}
/**

View File

@ -18,6 +18,7 @@ import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js';
import type {ElementHandle} from '../api/ElementHandle.js';
import {JSHandle} from '../api/JSHandle.js';
import {UnsupportedOperation} from '../common/Errors.js';
import {BidiDeserializer} from './Deserializer.js';
import type {BidiRealm} from './Realm.js';
@ -105,6 +106,6 @@ export class BidiJSHandle<T = unknown> extends JSHandle<T> {
}
override remoteObject(): never {
throw new Error('Not available in WebDriver BiDi');
throw new UnsupportedOperation('Not available in WebDriver BiDi');
}
}

View File

@ -30,6 +30,7 @@ import {
} from '../../third_party/rxjs/rxjs.js';
import type {CDPSession} from '../api/CDPSession.js';
import type {WaitForOptions} from '../api/Frame.js';
import type {Metrics} from '../api/Page.js';
import {
Page,
PageEvent,
@ -38,17 +39,20 @@ import {
type NewDocumentScriptEvaluation,
type ScreenshotOptions,
} from '../api/Page.js';
import type {Target} from '../api/Target.js';
import {Accessibility} from '../cdp/Accessibility.js';
import {Coverage} from '../cdp/Coverage.js';
import {EmulationManager as CdpEmulationManager} from '../cdp/EmulationManager.js';
import {FrameTree} from '../cdp/FrameTree.js';
import {Tracing} from '../cdp/Tracing.js';
import type {WebWorker} from '../cdp/WebWorker.js';
import {
ConsoleMessage,
type ConsoleMessageLocation,
} from '../common/ConsoleMessage.js';
import {TargetCloseError} from '../common/Errors.js';
import {TargetCloseError, UnsupportedOperation} from '../common/Errors.js';
import type {Handler} from '../common/EventEmitter.js';
import type {FileChooser} from '../common/FileChooser.js';
import {NetworkManagerEvent} from '../common/NetworkManagerEvents.js';
import type {PDFOptions} from '../common/PDFOptions.js';
import type {Awaitable} from '../common/types.js';
@ -61,6 +65,7 @@ import {
waitForHTTP,
} from '../common/util.js';
import type {Viewport} from '../common/Viewport.js';
import type {DeviceRequestPrompt, HTTPResponse} from '../puppeteer-core.js';
import {assert} from '../util/assert.js';
import {Deferred} from '../util/Deferred.js';
import {disposeSymbol} from '../util/disposable.js';
@ -649,29 +654,34 @@ export class BidiPage extends Page {
const {clip, type, captureBeyondViewport, allowViewportExpansion, quality} =
options;
if (captureBeyondViewport && !allowViewportExpansion) {
throw new Error(
throw new UnsupportedOperation(
`BiDi does not support 'captureBeyondViewport'. Use 'allowViewportExpansion'.`
);
}
if (options.omitBackground !== undefined && options.omitBackground) {
throw new Error(`BiDi does not support 'omitBackground'.`);
throw new UnsupportedOperation(`BiDi does not support 'omitBackground'.`);
}
if (options.optimizeForSpeed !== undefined && options.optimizeForSpeed) {
throw new Error(`BiDi does not support 'optimizeForSpeed'.`);
throw new UnsupportedOperation(
`BiDi does not support 'optimizeForSpeed'.`
);
}
if (options.fromSurface !== undefined && !options.fromSurface) {
throw new Error(`BiDi does not support 'fromSurface'.`);
throw new UnsupportedOperation(`BiDi does not support 'fromSurface'.`);
}
if (clip !== undefined && clip.scale !== undefined && clip.scale !== 1) {
throw new Error(`BiDi does not support 'scale' in 'clip'.`);
throw new UnsupportedOperation(
`BiDi does not support 'scale' in 'clip'.`
);
}
const {
result: {data},
} = await this.#connection.send('browsingContext.captureScreenshot', {
context: this.mainFrame()._id,
format: {
type: `image/${type}`,
...(quality === undefined ? {} : {quality: quality / 100}),
quality: quality ? quality / 100 : undefined,
},
clip: clip && {
type: 'box',
@ -817,6 +827,83 @@ export class BidiPage extends Page {
cacheDisabled: !enabled,
});
}
override isServiceWorkerBypassed(): boolean {
throw new UnsupportedOperation();
}
override target(): Target {
throw new UnsupportedOperation();
}
override waitForFileChooser(): Promise<FileChooser> {
throw new UnsupportedOperation();
}
override workers(): WebWorker[] {
throw new UnsupportedOperation();
}
override setRequestInterception(): Promise<void> {
throw new UnsupportedOperation();
}
override setDragInterception(): Promise<void> {
throw new UnsupportedOperation();
}
override setBypassServiceWorker(): Promise<void> {
throw new UnsupportedOperation();
}
override setOfflineMode(): Promise<void> {
throw new UnsupportedOperation();
}
override emulateNetworkConditions(): Promise<void> {
throw new UnsupportedOperation();
}
override cookies(): Promise<Protocol.Network.Cookie[]> {
throw new UnsupportedOperation();
}
override setCookie(): Promise<void> {
throw new UnsupportedOperation();
}
override deleteCookie(): Promise<void> {
throw new UnsupportedOperation();
}
override removeExposedFunction(): Promise<void> {
// TODO: Quick win?
throw new UnsupportedOperation();
}
override authenticate(): Promise<void> {
throw new UnsupportedOperation();
}
override setExtraHTTPHeaders(): Promise<void> {
throw new UnsupportedOperation();
}
override metrics(): Promise<Metrics> {
throw new UnsupportedOperation();
}
override goBack(): Promise<HTTPResponse | null> {
throw new UnsupportedOperation();
}
override goForward(): Promise<HTTPResponse | null> {
throw new UnsupportedOperation();
}
override waitForDevicePrompt(): Promise<DeviceRequestPrompt> {
throw new UnsupportedOperation();
}
}
function isConsoleLogEntry(

View File

@ -16,6 +16,7 @@
import type {CDPSession} from '../api/CDPSession.js';
import {Target, TargetType} from '../api/Target.js';
import {UnsupportedOperation} from '../common/Errors.js';
import type {BidiBrowser} from './Browser.js';
import type {BidiBrowserContext} from './BrowserContext.js';
@ -33,6 +34,10 @@ export class BidiTarget extends Target {
this._browserContext = browserContext;
}
_setBrowserContext(browserContext: BidiBrowserContext): void {
this._browserContext = browserContext;
}
override async worker(): Promise<null> {
return null;
}
@ -46,11 +51,19 @@ export class BidiTarget extends Target {
}
override opener(): Target | undefined {
throw new Error('Not implemented');
throw new UnsupportedOperation();
}
_setBrowserContext(browserContext: BidiBrowserContext): void {
this._browserContext = browserContext;
override url(): string {
throw new UnsupportedOperation();
}
override createCDPSession(): Promise<CDPSession> {
throw new UnsupportedOperation();
}
override type(): TargetType {
throw new UnsupportedOperation();
}
}
@ -117,7 +130,7 @@ export class BiDiPageTarget extends BiDiBrowsingContextTarget {
this.#page = new BidiPage(browsingContext, browserContext);
}
override async page(): Promise<BidiPage | null> {
override async page(): Promise<BidiPage> {
return this.#page;
}

View File

@ -24,6 +24,9 @@ import {catchError} from '../../third_party/rxjs/rxjs.js';
import type {PuppeteerLifeCycleEvent} from '../cdp/LifecycleWatcher.js';
import {ProtocolError, TimeoutError} from '../common/Errors.js';
/**
* @internal
*/
export type BiDiNetworkIdle = Extract<
PuppeteerLifeCycleEvent,
'networkidle0' | 'networkidle2'
@ -94,6 +97,9 @@ export const lifeCycleToSubscribedEvent = new Map<
['domcontentloaded', 'browsingContext.domContentLoaded'],
]);
/**
* @internal
*/
export function getBiDiLifecycleEvent(
event: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]
): [
@ -105,6 +111,9 @@ export function getBiDiLifecycleEvent(
return [bidiEvent, lifeCycles[1]];
}
/**
* @internal
*/
export function rewriteNavigationError<T, R extends ObservableInput<T>>(
message: string,
ms: number

View File

@ -143,7 +143,7 @@ export class CdpBrowser extends BrowserBase {
this.emit(BrowserEvent.Disconnected, undefined);
};
override async _attach(): Promise<void> {
async _attach(): Promise<void> {
this.#connection.on(CDPSessionEvent.Disconnected, this.#emitDisconnected);
this.#targetManager.on(
TargetManagerEvent.TargetAvailable,
@ -164,7 +164,7 @@ export class CdpBrowser extends BrowserBase {
await this.#targetManager.initialize();
}
override _detach(): void {
_detach(): void {
this.#connection.off(CDPSessionEvent.Disconnected, this.#emitDisconnected);
this.#targetManager.off(
TargetManagerEvent.TargetAvailable,
@ -204,7 +204,7 @@ export class CdpBrowser extends BrowserBase {
});
}
override _getIsPageTargetCallback(): IsPageTargetCallback | undefined {
_getIsPageTargetCallback(): IsPageTargetCallback | undefined {
return this.#isPageTargetCallback;
}
@ -237,7 +237,7 @@ export class CdpBrowser extends BrowserBase {
return this.#defaultContext;
}
override async _disposeContext(contextId?: string): Promise<void> {
async _disposeContext(contextId?: string): Promise<void> {
if (!contextId) {
return;
}
@ -349,7 +349,7 @@ export class CdpBrowser extends BrowserBase {
return await this.#defaultContext.newPage();
}
override async _createPageInContext(contextId?: string): Promise<Page> {
async _createPageInContext(contextId?: string): Promise<Page> {
const {targetId} = await this.#connection.send('Target.createTarget', {
url: 'about:blank',
browserContextId: contextId || undefined,

View File

@ -20,6 +20,7 @@ import type {CDPSession} from '../api/CDPSession.js';
import {Frame, FrameEvent, throwIfDetached} from '../api/Frame.js';
import type {HTTPResponse} from '../api/HTTPResponse.js';
import type {WaitTimeoutOptions} from '../api/Page.js';
import {UnsupportedOperation} from '../common/Errors.js';
import {setPageContent} from '../common/util.js';
import {Deferred} from '../util/Deferred.js';
import {disposeSymbol} from '../util/disposable.js';
@ -347,4 +348,8 @@ export class CdpFrame extends Frame {
this.worlds[MAIN_WORLD][disposeSymbol]();
this.worlds[PUPPETEER_WORLD][disposeSymbol]();
}
exposeFunction(): Promise<void> {
throw new UnsupportedOperation();
}
}

View File

@ -80,6 +80,14 @@ export class ProtocolError extends CustomError {
}
}
/**
* Puppeteer will throw this error if a method is not
* supported by the currently used protocol
*
* @public
*/
export class UnsupportedOperation extends CustomError {}
/**
* @internal
*/