Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: update removeAllListeners docs (#32305)
Pavel Feldman3d9342aa775a
diff --git a/docs/src/api/class-browser.md b/docs/src/api/class-browser.mdindex 0c6fd67160..59cf4c99c0 100644--- a/docs/src/api/class-browser.md+++ b/docs/src/api/class-browser.md@@ -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.47diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.mdindex eed27fc1c1..d27afc9b58 100644--- a/docs/src/api/class-browsercontext.md+++ b/docs/src/api/class-browsercontext.md@@ -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.47diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.mdindex 834c06ab10..9a3a25b225 100644--- a/docs/src/api/class-page.md+++ b/docs/src/api/class-page.md@@ -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 (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**-Removes all the listeners of the given type if the type is given. Otherwise removes all the listeners.+```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.47diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.tsindex 378c5a7151..7f3c14eff3 100644--- a/packages/playwright-core/types/types.d.ts+++ b/packages/playwright-core/types/types.d.ts@@ -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:diff --git a/utils/generate_types/overrides.d.ts b/utils/generate_types/overrides.d.tsindex 578602959a..e679bbb9cb 100644--- a/utils/generate_types/overrides.d.ts+++ b/utils/generate_types/overrides.d.ts@@ -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 {