chore: update removeAllListeners docs (#32305)
Closes https://github.com/microsoft/playwright/issues/31474
This commit is contained in:
parent
67d3d5f203
commit
3d9342aa77
|
|
@ -297,8 +297,10 @@ testing frameworks should explicitly create [`method: Browser.newContext`] follo
|
|||
|
||||
## async method: Browser.removeAllListeners
|
||||
* since: v1.47
|
||||
* langs: js
|
||||
|
||||
Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
Removes all the listeners of the given type (or all registered listeners if no type given).
|
||||
Allows to wait for async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
|
||||
### param: Browser.removeAllListeners.type
|
||||
* since: v1.47
|
||||
|
|
|
|||
|
|
@ -1048,8 +1048,10 @@ Returns all open pages in the context.
|
|||
|
||||
## async method: BrowserContext.removeAllListeners
|
||||
* since: v1.47
|
||||
* langs: js
|
||||
|
||||
Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
Removes all the listeners of the given type (or all registered listeners if no type given).
|
||||
Allows to wait for async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
|
||||
### param: BrowserContext.removeAllListeners.type
|
||||
* since: v1.47
|
||||
|
|
|
|||
|
|
@ -3372,8 +3372,23 @@ By default, after calling the handler Playwright will wait until the overlay bec
|
|||
|
||||
## async method: Page.removeAllListeners
|
||||
* since: v1.47
|
||||
* langs: js
|
||||
|
||||
Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
Removes all the listeners of the given type (or all registered listeners if no type given).
|
||||
Allows to wait for async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
|
||||
**Usage**
|
||||
|
||||
```js
|
||||
page.on('request', async request => {
|
||||
const response = await request.response();
|
||||
const body = await response.body();
|
||||
console.log(body.byteLength);
|
||||
});
|
||||
await page.goto('https://playwright.dev', { waitUntil: 'domcontentloaded' });
|
||||
// Waits for all the reported 'request' events to resolve.
|
||||
await page.removeAllListeners('request', { behavior: 'wait' });
|
||||
```
|
||||
|
||||
### param: Page.removeAllListeners.type
|
||||
* since: v1.47
|
||||
|
|
|
|||
76
packages/playwright-core/types/types.d.ts
vendored
76
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -898,17 +898,55 @@ export interface Page {
|
|||
exposeBinding(name: string, playwrightBinding: (source: BindingSource, ...args: any[]) => any, options?: { handle?: boolean }): Promise<void>;
|
||||
|
||||
/**
|
||||
* Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
* Removes all the listeners of the given type (or all registered listeners if no type given). Allows to wait for
|
||||
* async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
*
|
||||
* **Usage**
|
||||
*
|
||||
* ```js
|
||||
* page.on('request', async request => {
|
||||
* const response = await request.response();
|
||||
* const body = await response.body();
|
||||
* console.log(body.byteLength);
|
||||
* });
|
||||
* await page.goto('https://playwright.dev', { waitUntil: 'domcontentloaded' });
|
||||
* // Waits for all the reported 'request' events to resolve.
|
||||
* await page.removeAllListeners('request', { behavior: 'wait' });
|
||||
* ```
|
||||
*
|
||||
* @param type
|
||||
* @param options
|
||||
*/
|
||||
removeAllListeners(type?: string): this;
|
||||
/**
|
||||
* Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
* Removes all the listeners of the given type (or all registered listeners if no type given). Allows to wait for
|
||||
* async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
*
|
||||
* **Usage**
|
||||
*
|
||||
* ```js
|
||||
* page.on('request', async request => {
|
||||
* const response = await request.response();
|
||||
* const body = await response.body();
|
||||
* console.log(body.byteLength);
|
||||
* });
|
||||
* await page.goto('https://playwright.dev', { waitUntil: 'domcontentloaded' });
|
||||
* // Waits for all the reported 'request' events to resolve.
|
||||
* await page.removeAllListeners('request', { behavior: 'wait' });
|
||||
* ```
|
||||
*
|
||||
* @param type
|
||||
* @param options
|
||||
*/
|
||||
removeAllListeners(type: string | undefined, options: { behavior?: 'wait'|'ignoreErrors'|'default' }): Promise<void>;
|
||||
removeAllListeners(type: string | undefined, options: {
|
||||
/**
|
||||
* Specifies whether to wait for already running listeners and what to do if they throw errors:
|
||||
* - `'default'` - do not wait for current listener calls (if any) to finish, if the listener throws, it may result in unhandled error
|
||||
* - `'wait'` - wait for current listener calls (if any) to finish
|
||||
* - `'ignoreErrors'` - do not wait for current listener calls (if any) to finish, all errors thrown by the listeners after removal are silently caught
|
||||
*/
|
||||
behavior?: 'wait'|'ignoreErrors'|'default'
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* Emitted when the page closes.
|
||||
*/
|
||||
|
|
@ -7734,17 +7772,27 @@ export interface BrowserContext {
|
|||
addInitScript<Arg>(script: PageFunction<Arg, any> | { path?: string, content?: string }, arg?: Arg): Promise<void>;
|
||||
|
||||
/**
|
||||
* Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
* Removes all the listeners of the given type (or all registered listeners if no type given). Allows to wait for
|
||||
* async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
* @param type
|
||||
* @param options
|
||||
*/
|
||||
removeAllListeners(type?: string): this;
|
||||
/**
|
||||
* Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
* Removes all the listeners of the given type (or all registered listeners if no type given). Allows to wait for
|
||||
* async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
* @param type
|
||||
* @param options
|
||||
*/
|
||||
removeAllListeners(type: string | undefined, options: { behavior?: 'wait'|'ignoreErrors'|'default' }): Promise<void>;
|
||||
removeAllListeners(type: string | undefined, options: {
|
||||
/**
|
||||
* Specifies whether to wait for already running listeners and what to do if they throw errors:
|
||||
* - `'default'` - do not wait for current listener calls (if any) to finish, if the listener throws, it may result in unhandled error
|
||||
* - `'wait'` - wait for current listener calls (if any) to finish
|
||||
* - `'ignoreErrors'` - do not wait for current listener calls (if any) to finish, all errors thrown by the listeners after removal are silently caught
|
||||
*/
|
||||
behavior?: 'wait'|'ignoreErrors'|'default'
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* **NOTE** Only works with Chromium browser's persistent context.
|
||||
*
|
||||
|
|
@ -9018,17 +9066,27 @@ export interface BrowserContext {
|
|||
*/
|
||||
export interface Browser {
|
||||
/**
|
||||
* Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
* Removes all the listeners of the given type (or all registered listeners if no type given). Allows to wait for
|
||||
* async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
* @param type
|
||||
* @param options
|
||||
*/
|
||||
removeAllListeners(type?: string): this;
|
||||
/**
|
||||
* Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.
|
||||
* Removes all the listeners of the given type (or all registered listeners if no type given). Allows to wait for
|
||||
* async listeners to complete or to ignore subsequent errors from these listeners.
|
||||
* @param type
|
||||
* @param options
|
||||
*/
|
||||
removeAllListeners(type: string | undefined, options: { behavior?: 'wait'|'ignoreErrors'|'default' }): Promise<void>;
|
||||
removeAllListeners(type: string | undefined, options: {
|
||||
/**
|
||||
* Specifies whether to wait for already running listeners and what to do if they throw errors:
|
||||
* - `'default'` - do not wait for current listener calls (if any) to finish, if the listener throws, it may result in unhandled error
|
||||
* - `'wait'` - wait for current listener calls (if any) to finish
|
||||
* - `'ignoreErrors'` - do not wait for current listener calls (if any) to finish, all errors thrown by the listeners after removal are silently caught
|
||||
*/
|
||||
behavior?: 'wait'|'ignoreErrors'|'default'
|
||||
}): Promise<void>;
|
||||
/**
|
||||
* Emitted when Browser gets disconnected from the browser application. This might happen because of one of the
|
||||
* following:
|
||||
|
|
|
|||
30
utils/generate_types/overrides.d.ts
vendored
30
utils/generate_types/overrides.d.ts
vendored
|
|
@ -64,7 +64,15 @@ export interface Page {
|
|||
exposeBinding(name: string, playwrightBinding: (source: BindingSource, ...args: any[]) => any, options?: { handle?: boolean }): Promise<void>;
|
||||
|
||||
removeAllListeners(type?: string): this;
|
||||
removeAllListeners(type: string | undefined, options: { behavior?: 'wait'|'ignoreErrors'|'default' }): Promise<void>;
|
||||
removeAllListeners(type: string | undefined, options: {
|
||||
/**
|
||||
* Specifies whether to wait for already running listeners and what to do if they throw errors:
|
||||
* - `'default'` - do not wait for current listener calls (if any) to finish, if the listener throws, it may result in unhandled error
|
||||
* - `'wait'` - wait for current listener calls (if any) to finish
|
||||
* - `'ignoreErrors'` - do not wait for current listener calls (if any) to finish, all errors thrown by the listeners after removal are silently caught
|
||||
*/
|
||||
behavior?: 'wait'|'ignoreErrors'|'default'
|
||||
}): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Frame {
|
||||
|
|
@ -106,12 +114,28 @@ export interface BrowserContext {
|
|||
addInitScript<Arg>(script: PageFunction<Arg, any> | { path?: string, content?: string }, arg?: Arg): Promise<void>;
|
||||
|
||||
removeAllListeners(type?: string): this;
|
||||
removeAllListeners(type: string | undefined, options: { behavior?: 'wait'|'ignoreErrors'|'default' }): Promise<void>;
|
||||
removeAllListeners(type: string | undefined, options: {
|
||||
/**
|
||||
* Specifies whether to wait for already running listeners and what to do if they throw errors:
|
||||
* - `'default'` - do not wait for current listener calls (if any) to finish, if the listener throws, it may result in unhandled error
|
||||
* - `'wait'` - wait for current listener calls (if any) to finish
|
||||
* - `'ignoreErrors'` - do not wait for current listener calls (if any) to finish, all errors thrown by the listeners after removal are silently caught
|
||||
*/
|
||||
behavior?: 'wait'|'ignoreErrors'|'default'
|
||||
}): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Browser {
|
||||
removeAllListeners(type?: string): this;
|
||||
removeAllListeners(type: string | undefined, options: { behavior?: 'wait'|'ignoreErrors'|'default' }): Promise<void>;
|
||||
removeAllListeners(type: string | undefined, options: {
|
||||
/**
|
||||
* Specifies whether to wait for already running listeners and what to do if they throw errors:
|
||||
* - `'default'` - do not wait for current listener calls (if any) to finish, if the listener throws, it may result in unhandled error
|
||||
* - `'wait'` - wait for current listener calls (if any) to finish
|
||||
* - `'ignoreErrors'` - do not wait for current listener calls (if any) to finish, all errors thrown by the listeners after removal are silently caught
|
||||
*/
|
||||
behavior?: 'wait'|'ignoreErrors'|'default'
|
||||
}): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Worker {
|
||||
|
|
|
|||
Loading…
Reference in a new issue