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
Reapply "feat: add `AbortSignal` support to client-side Waiter methods" (#41257)
Simon Knott485ec25d693b
diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.mdindex c5e504b484..518b2f6059 100644--- a/docs/src/api/class-browsercontext.md+++ b/docs/src/api/class-browsercontext.md@@ -1713,6 +1713,7 @@ Receives the [ConsoleMessage] object and resolves to truthy value when the waiti### option: BrowserContext.waitForConsoleMessage.timeout = %%-wait-for-event-timeout-%%* since: v1.34+### option: BrowserContext.waitForConsoleMessage.signal = %%-wait-for-event-signal-%%### param: BrowserContext.waitForConsoleMessage.callback = %%-java-wait-for-event-callback-%%* since: v1.34@@ -1782,6 +1783,7 @@ Either a predicate that receives an event or an options object. Optional.### option: BrowserContext.waitForEvent.timeout = %%-wait-for-event-timeout-%%* since: v1.8+### option: BrowserContext.waitForEvent.signal = %%-wait-for-event-signal-%%## async method: BrowserContext.waitForPage* since: v1.9@@ -1811,6 +1813,7 @@ Receives the [Page] object and resolves to truthy value when the waiting should### option: BrowserContext.waitForPage.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: BrowserContext.waitForPage.signal = %%-wait-for-event-signal-%%### param: BrowserContext.waitForPage.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -1837,3 +1840,4 @@ Will throw an error if the browser context is closed before the `event` is fired### option: BrowserContext.waitForEvent2.timeout = %%-wait-for-event-timeout-%%* since: v1.8+### option: BrowserContext.waitForEvent2.signal = %%-wait-for-event-signal-%%diff --git a/docs/src/api/class-frame.md b/docs/src/api/class-frame.mdindex c73aa88e7b..153a09ddaa 100644--- a/docs/src/api/class-frame.md+++ b/docs/src/api/class-frame.md@@ -2010,6 +2010,7 @@ await frame.WaitForLoadStateAsync(); // Defaults to LoadState.Load### option: Frame.waitForLoadState.timeout = %%-navigation-timeout-js-%%* since: v1.8+### option: Frame.waitForLoadState.signal = %%-wait-for-event-signal-%%## async method: Frame.waitForNavigation* since: v1.8@@ -2093,6 +2094,7 @@ a navigation.### option: Frame.waitForNavigation.timeout = %%-navigation-timeout-js-%%* since: v1.8+### option: Frame.waitForNavigation.signal = %%-wait-for-event-signal-%%### param: Frame.waitForNavigation.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -2289,6 +2291,7 @@ await frame.WaitForURLAsync("**/target.html");### option: Frame.waitForURL.timeout = %%-navigation-timeout-js-%%* since: v1.11+### option: Frame.waitForURL.signal = %%-wait-for-event-signal-%%### option: Frame.waitForURL.waitUntil = %%-navigation-wait-until-%%* since: v1.11diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.mdindex 606bab5d35..098d83af72 100644--- a/docs/src/api/class-page.md+++ b/docs/src/api/class-page.md@@ -4507,6 +4507,7 @@ Performs action and waits for the Page to close.### option: Page.waitForClose.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: Page.waitForClose.signal = %%-wait-for-event-signal-%%### param: Page.waitForClose.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -4538,6 +4539,7 @@ Receives the [ConsoleMessage] object and resolves to truthy value when the waiti### option: Page.waitForConsoleMessage.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: Page.waitForConsoleMessage.signal = %%-wait-for-event-signal-%%### param: Page.waitForConsoleMessage.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -4569,6 +4571,7 @@ Receives the [Download] object and resolves to truthy value when the waiting sho### option: Page.waitForDownload.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: Page.waitForDownload.signal = %%-wait-for-event-signal-%%### param: Page.waitForDownload.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -4625,6 +4628,7 @@ Either a predicate that receives an event or an options object. Optional.### option: Page.waitForEvent.timeout = %%-wait-for-event-timeout-%%* since: v1.8+### option: Page.waitForEvent.signal = %%-wait-for-event-signal-%%## async method: Page.waitForFileChooser* since: v1.9@@ -4653,6 +4657,7 @@ Receives the [FileChooser] object and resolves to truthy value when the waiting### option: Page.waitForFileChooser.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: Page.waitForFileChooser.signal = %%-wait-for-event-signal-%%### param: Page.waitForFileChooser.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -4890,6 +4895,7 @@ Console.WriteLine(await popup.TitleAsync()); // popup is ready to use.### option: Page.waitForLoadState.timeout = %%-navigation-timeout-js-%%* since: v1.8+### option: Page.waitForLoadState.signal = %%-wait-for-event-signal-%%## async method: Page.waitForNavigation* since: v1.8@@ -4976,6 +4982,7 @@ a navigation.### option: Page.waitForNavigation.timeout = %%-navigation-timeout-js-%%* since: v1.8+### option: Page.waitForNavigation.signal = %%-wait-for-event-signal-%%### param: Page.waitForNavigation.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -5007,6 +5014,7 @@ Receives the [Page] object and resolves to truthy value when the waiting should### option: Page.waitForPopup.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: Page.waitForPopup.signal = %%-wait-for-event-signal-%%### param: Page.waitForPopup.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -5116,6 +5124,8 @@ Request URL string, regex or predicate receiving [Request] object.Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can bechanged by using the [`method: Page.setDefaultTimeout`] method.+### option: Page.waitForRequest.signal = %%-wait-for-event-signal-%%+### param: Page.waitForRequest.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -5146,6 +5156,7 @@ Receives the [Request] object and resolves to truthy value when the waiting shou### option: Page.waitForRequestFinished.timeout = %%-wait-for-event-timeout-%%* since: v1.12+### option: Page.waitForRequestFinished.signal = %%-wait-for-event-signal-%%### param: Page.waitForRequestFinished.callback = %%-java-wait-for-event-callback-%%* since: v1.12@@ -5262,6 +5273,8 @@ it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/WeMaximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can bechanged by using the [`method: BrowserContext.setDefaultTimeout`] or [`method: Page.setDefaultTimeout`] methods.+### option: Page.waitForResponse.signal = %%-wait-for-event-signal-%%+### param: Page.waitForResponse.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -5513,6 +5526,7 @@ await page.WaitForURLAsync("**/target.html");### option: Page.waitForURL.timeout = %%-navigation-timeout-js-%%* since: v1.11+### option: Page.waitForURL.signal = %%-wait-for-event-signal-%%### option: Page.waitForURL.waitUntil = %%-navigation-wait-until-%%* since: v1.11@@ -5544,6 +5558,7 @@ Receives the [WebSocket] object and resolves to truthy value when the waiting sh### option: Page.waitForWebSocket.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: Page.waitForWebSocket.signal = %%-wait-for-event-signal-%%### param: Page.waitForWebSocket.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -5575,6 +5590,7 @@ Receives the [Worker] object and resolves to truthy value when the waiting shoul### option: Page.waitForWorker.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: Page.waitForWorker.signal = %%-wait-for-event-signal-%%### param: Page.waitForWorker.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -5612,3 +5628,4 @@ Will throw an error if the page is closed before the `event` is fired.### option: Page.waitForEvent2.timeout = %%-wait-for-event-timeout-%%* since: v1.8+### option: Page.waitForEvent2.signal = %%-wait-for-event-signal-%%diff --git a/docs/src/api/class-websocket.md b/docs/src/api/class-websocket.mdindex e33740eaca..354de8f874 100644--- a/docs/src/api/class-websocket.md+++ b/docs/src/api/class-websocket.md@@ -97,6 +97,7 @@ Either a predicate that receives an event or an options object. Optional.### option: WebSocket.waitForEvent.timeout = %%-wait-for-event-timeout-%%* since: v1.8+### option: WebSocket.waitForEvent.signal = %%-wait-for-event-signal-%%## async method: WebSocket.waitForFrameReceived* since: v1.10@@ -115,6 +116,7 @@ Receives the [WebSocketFrame] object and resolves to truthy value when the waiti### option: WebSocket.waitForFrameReceived.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: WebSocket.waitForFrameReceived.signal = %%-wait-for-event-signal-%%### param: WebSocket.waitForFrameReceived.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -136,6 +138,7 @@ Receives the [WebSocketFrame] object and resolves to truthy value when the waiti### option: WebSocket.waitForFrameSent.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: WebSocket.waitForFrameSent.signal = %%-wait-for-event-signal-%%### param: WebSocket.waitForFrameSent.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -162,3 +165,4 @@ Will throw an error if the socket is closed before the `event` is fired.### option: WebSocket.waitForEvent2.timeout = %%-wait-for-event-timeout-%%* since: v1.8+### option: WebSocket.waitForEvent2.signal = %%-wait-for-event-signal-%%diff --git a/docs/src/api/class-worker.md b/docs/src/api/class-worker.mdindex 5fc5992aff..9c7160335a 100644--- a/docs/src/api/class-worker.md+++ b/docs/src/api/class-worker.md@@ -126,6 +126,7 @@ Performs action and waits for the Worker to close.### option: Worker.waitForClose.timeout = %%-wait-for-event-timeout-%%* since: v1.9+### option: Worker.waitForClose.signal = %%-wait-for-event-signal-%%### param: Worker.waitForClose.callback = %%-java-wait-for-event-callback-%%* since: v1.9@@ -145,6 +146,7 @@ Receives the [ConsoleMessage] object and resolves to true when the waiting shoul### option: Worker.waitForConsoleMessage.timeout = %%-wait-for-event-timeout-%%* since: v1.57+### option: Worker.waitForConsoleMessage.signal = %%-wait-for-event-signal-%%### param: Worker.waitForConsoleMessage.callback = %%-java-wait-for-event-callback-%%* since: v1.57@@ -203,3 +205,4 @@ Either a predicate that receives an event or an options object. Optional.### option: Worker.waitForEvent.timeout = %%-wait-for-event-timeout-%%* since: v1.57+### option: Worker.waitForEvent.signal = %%-wait-for-event-signal-%%diff --git a/docs/src/api/params.md b/docs/src/api/params.mdindex 118b38b282..0e885a7aa3 100644--- a/docs/src/api/params.md+++ b/docs/src/api/params.md@@ -991,6 +991,14 @@ Receives the event data and resolves to truthy value when the waiting should resMaximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.The default value can be changed by using the [`method: BrowserContext.setDefaultTimeout`].+## wait-for-event-signal+* langs: js+* since: v1.61+- `signal` <[AbortSignal]>++Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will throw an error.+Note that providing a signal does not disable the default timeout; pass `timeout: 0` to disable the timeout entirely.+## android-timeout* langs: js- `timeout` <[float]>diff --git a/packages/playwright-client/types/types.d.ts b/packages/playwright-client/types/types.d.tsindex 0bff9d367c..67f1246e56 100644--- a/packages/playwright-client/types/types.d.ts+++ b/packages/playwright-client/types/types.d.ts@@ -4787,7 +4787,7 @@ export interface Page {/*** Emitted when the page closes.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`.@@ -4808,7 +4808,7 @@ export interface Page {* ```**/- waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;/*** Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page@@ -4828,7 +4828,7 @@ export interface Page {* ```**/- waitForEvent(event: 'crash', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'crash', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Listener **must**@@ -4848,19 +4848,19 @@ export interface Page {* listeners are present, all dialogs are automatically dismissed.**/- waitForEvent(event: 'dialog', optionsOrPredicate?: { predicate?: (dialog: Dialog) => boolean | Promise<boolean>, timeout?: number } | ((dialog: Dialog) => boolean | Promise<boolean>)): Promise<Dialog>;+ waitForEvent(event: 'dialog', optionsOrPredicate?: { predicate?: (dialog: Dialog) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((dialog: Dialog) => boolean | Promise<boolean>)): Promise<Dialog>;/*** Emitted when the JavaScript* [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched.*/- waitForEvent(event: 'domcontentloaded', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'domcontentloaded', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when attachment download started. User can access basic file operations on downloaded content via the* passed [Download](https://playwright.dev/docs/api/class-download) instance.*/- waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise<boolean>, timeout?: number } | ((download: Download) => boolean | Promise<boolean>)): Promise<Download>;+ waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((download: Download) => boolean | Promise<boolean>)): Promise<Download>;/*** Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can@@ -4875,27 +4875,27 @@ export interface Page {* ```**/- waitForEvent(event: 'filechooser', optionsOrPredicate?: { predicate?: (fileChooser: FileChooser) => boolean | Promise<boolean>, timeout?: number } | ((fileChooser: FileChooser) => boolean | Promise<boolean>)): Promise<FileChooser>;+ waitForEvent(event: 'filechooser', optionsOrPredicate?: { predicate?: (fileChooser: FileChooser) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((fileChooser: FileChooser) => boolean | Promise<boolean>)): Promise<FileChooser>;/*** Emitted when a frame is attached.*/- waitForEvent(event: 'frameattached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'frameattached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when a frame is detached.*/- waitForEvent(event: 'framedetached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'framedetached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when a frame is navigated to a new url.*/- waitForEvent(event: 'framenavigated', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'framenavigated', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.*/- waitForEvent(event: 'load', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'load', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when an uncaught exception happens within the page.@@ -4911,7 +4911,7 @@ export interface Page {* ```**/- waitForEvent(event: 'pageerror', optionsOrPredicate?: { predicate?: (error: Error) => boolean | Promise<boolean>, timeout?: number } | ((error: Error) => boolean | Promise<boolean>)): Promise<Error>;+ waitForEvent(event: 'pageerror', optionsOrPredicate?: { predicate?: (error: Error) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((error: Error) => boolean | Promise<boolean>)): Promise<Error>;/*** Emitted when the page opens a new tab or window. This event is emitted in addition to the@@ -4940,14 +4940,14 @@ export interface Page {* wait until the page gets to a particular state (you should not need it in most cases).**/- waitForEvent(event: 'popup', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'popup', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests,* see [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route) or* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route).*/- waitForEvent(event: 'request', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'request', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when a request fails, for example by timing out.@@ -4966,30 +4966,30 @@ export interface Page {* error net::ERR_FAILED.**/- waitForEvent(event: 'requestfailed', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'requestfailed', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when a request finishes successfully after downloading the response body. For a successful response, the* sequence of events is `request`, `response` and `requestfinished`.*/- waitForEvent(event: 'requestfinished', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'requestfinished', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when [response] status and headers are received for a request. For a successful response, the sequence of* events is `request`, `response` and `requestfinished`.*/- waitForEvent(event: 'response', optionsOrPredicate?: { predicate?: (response: Response) => boolean | Promise<boolean>, timeout?: number } | ((response: Response) => boolean | Promise<boolean>)): Promise<Response>;+ waitForEvent(event: 'response', optionsOrPredicate?: { predicate?: (response: Response) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((response: Response) => boolean | Promise<boolean>)): Promise<Response>;/*** Emitted when [WebSocket](https://playwright.dev/docs/api/class-websocket) request is sent.*/- waitForEvent(event: 'websocket', optionsOrPredicate?: { predicate?: (webSocket: WebSocket) => boolean | Promise<boolean>, timeout?: number } | ((webSocket: WebSocket) => boolean | Promise<boolean>)): Promise<WebSocket>;+ waitForEvent(event: 'websocket', optionsOrPredicate?: { predicate?: (webSocket: WebSocket) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((webSocket: WebSocket) => boolean | Promise<boolean>)): Promise<WebSocket>;/*** Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned* by the page.*/- waitForEvent(event: 'worker', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;+ waitForEvent(event: 'worker', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;/**@@ -5026,6 +5026,14 @@ export interface Page {* @param options*/waitForLoadState(state?: "load"|"domcontentloaded"|"networkidle", options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -5063,6 +5071,14 @@ export interface Page {* @param options*/waitForNavigation(options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -5116,6 +5132,14 @@ export interface Page {* @param options*/waitForRequest(urlOrPredicate: string|RegExp|((request: Request) => boolean|Promise<boolean>), options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can* be changed by using the@@ -5152,6 +5176,14 @@ export interface Page {* @param options*/waitForResponse(urlOrPredicate: string|RegExp|((response: Response) => boolean|Promise<boolean>), options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can* be changed by using the@@ -5198,6 +5230,14 @@ export interface Page {* @param options*/waitForURL(url: string|RegExp|URLPattern|((url: URL) => boolean), options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -8023,6 +8063,14 @@ export interface Frame {* @param options*/waitForLoadState(state?: "load"|"domcontentloaded"|"networkidle", options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -8059,6 +8107,14 @@ export interface Frame {* @param options*/waitForNavigation(options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -8117,6 +8173,14 @@ export interface Frame {* @param options*/waitForURL(url: string|RegExp|URLPattern|((url: URL) => boolean), options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -9723,7 +9787,7 @@ export interface BrowserContext {/*** This event is not emitted.*/- waitForEvent(event: 'backgroundpage', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'backgroundpage', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when Browser context gets closed. This might happen because of one of the following:@@ -9731,7 +9795,7 @@ export interface BrowserContext {* - Browser application is closed or crashed.* - The [browser.close([options])](https://playwright.dev/docs/api/class-browser#browser-close) method was called.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (browserContext: BrowserContext) => boolean | Promise<boolean>, timeout?: number } | ((browserContext: BrowserContext) => boolean | Promise<boolean>)): Promise<BrowserContext>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (browserContext: BrowserContext) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((browserContext: BrowserContext) => boolean | Promise<boolean>)): Promise<BrowserContext>;/*** Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`.@@ -9752,7 +9816,7 @@ export interface BrowserContext {* ```**/- waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;/*** Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Listener **must**@@ -9774,7 +9838,7 @@ export interface BrowserContext {* listeners are present, all dialogs are automatically dismissed.**/- waitForEvent(event: 'dialog', optionsOrPredicate?: { predicate?: (dialog: Dialog) => boolean | Promise<boolean>, timeout?: number } | ((dialog: Dialog) => boolean | Promise<boolean>)): Promise<Dialog>;+ waitForEvent(event: 'dialog', optionsOrPredicate?: { predicate?: (dialog: Dialog) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((dialog: Dialog) => boolean | Promise<boolean>)): Promise<Dialog>;/*** Emitted when attachment download started in any page belonging to this context. User can access basic file@@ -9782,28 +9846,28 @@ export interface BrowserContext {* instance. See also [page.on('download')](https://playwright.dev/docs/api/class-page#page-event-download) to receive* events about a specific page.*/- waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise<boolean>, timeout?: number } | ((download: Download) => boolean | Promise<boolean>)): Promise<Download>;+ waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((download: Download) => boolean | Promise<boolean>)): Promise<Download>;/*** Emitted when a frame is attached in any page belonging to this context. See also* [page.on('frameattached')](https://playwright.dev/docs/api/class-page#page-event-frame-attached) to receive events* about a specific page.*/- waitForEvent(event: 'frameattached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'frameattached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when a frame is detached in any page belonging to this context. See also* [page.on('framedetached')](https://playwright.dev/docs/api/class-page#page-event-frame-detached) to receive events* about a specific page.*/- waitForEvent(event: 'framedetached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'framedetached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when a frame is navigated to a new url in any page belonging to this context. See also* [page.on('framenavigated')](https://playwright.dev/docs/api/class-page#page-event-frame-navigated) to receive* events about navigations in a specific page.*/- waitForEvent(event: 'framenavigated', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'framenavigated', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event@@ -9832,14 +9896,14 @@ export interface BrowserContext {* wait until the page gets to a particular state (you should not need it in most cases).**/- waitForEvent(event: 'page', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'page', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when a page in this context is closed. See also* [page.on('close')](https://playwright.dev/docs/api/class-page#page-event-close) to receive events about a specific* page.*/- waitForEvent(event: 'pageclose', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'pageclose', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched@@ -9847,7 +9911,7 @@ export interface BrowserContext {* [page.on('load')](https://playwright.dev/docs/api/class-page#page-event-load) to receive events about a specific* page.*/- waitForEvent(event: 'pageload', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'pageload', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To@@ -9858,7 +9922,7 @@ export interface BrowserContext {* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)* or [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route).*/- waitForEvent(event: 'request', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'request', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when a request fails, for example by timing out. To only listen for failed requests from a particular page,@@ -9871,7 +9935,7 @@ export interface BrowserContext {* [browserContext.on('requestfailed')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request-failed).**/- waitForEvent(event: 'requestfailed', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'requestfailed', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when a request finishes successfully after downloading the response body. For a successful response, the@@ -9879,27 +9943,27 @@ export interface BrowserContext {* particular page, use* [page.on('requestfinished')](https://playwright.dev/docs/api/class-page#page-event-request-finished).*/- waitForEvent(event: 'requestfinished', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'requestfinished', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when [response] status and headers are received for a request. For a successful response, the sequence of* events is `request`, `response` and `requestfinished`. To listen for response events from a particular page, use* [page.on('response')](https://playwright.dev/docs/api/class-page#page-event-response).*/- waitForEvent(event: 'response', optionsOrPredicate?: { predicate?: (response: Response) => boolean | Promise<boolean>, timeout?: number } | ((response: Response) => boolean | Promise<boolean>)): Promise<Response>;+ waitForEvent(event: 'response', optionsOrPredicate?: { predicate?: (response: Response) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((response: Response) => boolean | Promise<boolean>)): Promise<Response>;/*** **NOTE** Service workers are only supported on Chromium-based browsers.** Emitted when new service worker is created in the context.*/- waitForEvent(event: 'serviceworker', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;+ waitForEvent(event: 'serviceworker', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;/*** Emitted when exception is unhandled in any of the pages in this context. To listen for errors from a particular* page, use [page.on('pageerror')](https://playwright.dev/docs/api/class-page#page-event-page-error) instead.*/- waitForEvent(event: 'weberror', optionsOrPredicate?: { predicate?: (webError: WebError) => boolean | Promise<boolean>, timeout?: number } | ((webError: WebError) => boolean | Promise<boolean>)): Promise<WebError>;+ waitForEvent(event: 'weberror', optionsOrPredicate?: { predicate?: (webError: WebError) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((webError: WebError) => boolean | Promise<boolean>)): Promise<WebError>;/**@@ -10866,12 +10930,12 @@ export interface Worker {* Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is* terminated.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;/*** Emitted when JavaScript within the worker calls one of console API methods, e.g. `console.log` or `console.dir`.*/- waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;}@@ -17094,7 +17158,7 @@ export interface ElectronApplication {/*** This event is issued when the application process has been terminated.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: () => boolean | Promise<boolean>, timeout?: number } | (() => boolean | Promise<boolean>)): Promise<void>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: () => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | (() => boolean | Promise<boolean>)): Promise<void>;/*** Emitted when JavaScript within the Electron main process calls one of console API methods, e.g. `console.log` or@@ -17116,13 +17180,13 @@ export interface ElectronApplication {* ```**/- waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;/*** This event is issued for every window that is created **and loaded** in Electron. It contains a* [Page](https://playwright.dev/docs/api/class-page) that can be used for Playwright automation.*/- waitForEvent(event: 'window', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'window', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/**@@ -21611,7 +21675,7 @@ export interface WebSocket {/*** Fired when the websocket closes.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (webSocket: WebSocket) => boolean | Promise<boolean>, timeout?: number } | ((webSocket: WebSocket) => boolean | Promise<boolean>)): Promise<WebSocket>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (webSocket: WebSocket) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((webSocket: WebSocket) => boolean | Promise<boolean>)): Promise<WebSocket>;/*** Fired when the websocket receives a frame.@@ -21621,7 +21685,7 @@ export interface WebSocket {* frame payload*/payload: string|Buffer;- }) => boolean | Promise<boolean>, timeout?: number } | ((data: {+ }) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((data: {/*** frame payload*/@@ -21641,7 +21705,7 @@ export interface WebSocket {* frame payload*/payload: string|Buffer;- }) => boolean | Promise<boolean>, timeout?: number } | ((data: {+ }) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((data: {/*** frame payload*/@@ -21656,7 +21720,7 @@ export interface WebSocket {/*** Fired when the websocket has an error.*/- waitForEvent(event: 'socketerror', optionsOrPredicate?: { predicate?: (string: string) => boolean | Promise<boolean>, timeout?: number } | ((string: string) => boolean | Promise<boolean>)): Promise<string>;+ waitForEvent(event: 'socketerror', optionsOrPredicate?: { predicate?: (string: string) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((string: string) => boolean | Promise<boolean>)): Promise<string>;}@@ -23008,12 +23072,12 @@ export interface AndroidDevice {/*** Emitted when the device connection gets closed.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (androidDevice: AndroidDevice) => boolean | Promise<boolean>, timeout?: number } | ((androidDevice: AndroidDevice) => boolean | Promise<boolean>)): Promise<AndroidDevice>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (androidDevice: AndroidDevice) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((androidDevice: AndroidDevice) => boolean | Promise<boolean>)): Promise<AndroidDevice>;/*** Emitted when a new WebView instance is detected.*/- waitForEvent(event: 'webview', optionsOrPredicate?: { predicate?: (androidWebView: AndroidWebView) => boolean | Promise<boolean>, timeout?: number } | ((androidWebView: AndroidWebView) => boolean | Promise<boolean>)): Promise<AndroidWebView>;+ waitForEvent(event: 'webview', optionsOrPredicate?: { predicate?: (androidWebView: AndroidWebView) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((androidWebView: AndroidWebView) => boolean | Promise<boolean>)): Promise<AndroidWebView>;/**diff --git a/packages/playwright-core/src/client/android.ts b/packages/playwright-core/src/client/android.tsindex 9a63c601ef..3f6ad60f04 100644--- a/packages/playwright-core/src/client/android.ts+++ b/packages/playwright-core/src/client/android.ts@@ -273,8 +273,10 @@ export class AndroidDevice extends ChannelOwner<channels.AndroidDeviceChannel> ireturn await this._wrapApiCall(async () => {const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;+ const signal = typeof optionsOrPredicate === 'function' ? undefined : (optionsOrPredicate as types.TimeoutOptions).signal;const waiter = Waiter.createForEvent(this, event);waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);+ waiter.rejectOnSignal(signal);if (event !== Events.AndroidDevice.Close)waiter.rejectOnEvent(this, Events.AndroidDevice.Close, () => new TargetClosedError());const result = await waiter.waitForEvent(this, event, predicate as any);diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.tsindex 31accbf0cb..ff4b4241de 100644--- a/packages/playwright-core/src/client/browserContext.ts+++ b/packages/playwright-core/src/client/browserContext.ts@@ -43,7 +43,7 @@ import { Worker } from './worker';import { TimeoutSettings } from './timeoutSettings';import { mkdirIfNeeded } from './fileUtils';-import type { BrowserContextOptions, Headers, SetStorageState, StorageState, WaitForEventOptions } from './types';+import type { BrowserContextOptions, Headers, SetStorageState, StorageState, TimeoutOptions, WaitForEventOptions } from './types';import type * as structs from '../../types/structs';import type * as api from '../../types/types';import type { URLMatch } from '@isomorphic/urlMatch';@@ -447,8 +447,10 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>return await this._wrapApiCall(async () => {const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;+ const signal = typeof optionsOrPredicate === 'function' ? undefined : (optionsOrPredicate as TimeoutOptions).signal;const waiter = Waiter.createForEvent(this, event);waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);+ waiter.rejectOnSignal(signal);if (event !== Events.BrowserContext.Close)waiter.rejectOnEvent(this, Events.BrowserContext.Close, () => new TargetClosedError(this._effectiveCloseReason()));const result = await waiter.waitForEvent(this, event, predicate as any);diff --git a/packages/playwright-core/src/client/electron.ts b/packages/playwright-core/src/client/electron.tsindex 2399aa61ff..f83be02946 100644--- a/packages/playwright-core/src/client/electron.ts+++ b/packages/playwright-core/src/client/electron.ts@@ -25,7 +25,7 @@ import { Waiter } from './waiter';import { TimeoutSettings } from './timeoutSettings';import type { Page } from './page';-import type { BrowserContextOptions, Headers, WaitForEventOptions } from './types';+import type { BrowserContextOptions, Headers, TimeoutOptions, WaitForEventOptions } from './types';import type * as structs from '../../types/structs';import type * as api from '../../types/types';import type * as channels from '@protocol/channels';@@ -114,7 +114,7 @@ export class ElectronApplication extends ChannelOwner<channels.ElectronApplicatireturn [...this._windows];}- async firstWindow(options?: { timeout?: number }): Promise<Page> {+ async firstWindow(options?: TimeoutOptions): Promise<Page> {if (this._windows.size)return this._windows.values().next().value!;return await this.waitForEvent('window', options);@@ -142,8 +142,10 @@ export class ElectronApplication extends ChannelOwner<channels.ElectronApplicatireturn await this._wrapApiCall(async () => {const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;+ const signal = typeof optionsOrPredicate === 'function' ? undefined : (optionsOrPredicate as TimeoutOptions).signal;const waiter = Waiter.createForEvent(this, event);waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);+ waiter.rejectOnSignal(signal);if (event !== Events.ElectronApplication.Close)waiter.rejectOnEvent(this, Events.ElectronApplication.Close, () => new TargetClosedError());const result = await waiter.waitForEvent(this, event, predicate as any);diff --git a/packages/playwright-core/src/client/frame.ts b/packages/playwright-core/src/client/frame.tsindex bb116238ea..bb28e67377 100644--- a/packages/playwright-core/src/client/frame.ts+++ b/packages/playwright-core/src/client/frame.ts@@ -44,6 +44,7 @@ export type WaitForNavigationOptions = {timeout?: number,waitUntil?: LifecycleEvent,url?: URLMatch,+ signal?: AbortSignal,};export class Frame extends ChannelOwner<channels.FrameChannel> implements api.Frame {@@ -118,7 +119,7 @@ export class Frame extends ChannelOwner<channels.FrameChannel> implements api.Frreturn network.Response.fromNullable((await this._channel.goto({ url, ...options, waitUntil, timeout: this._navigationTimeout(options) })).response);}- private _setupNavigationWaiter(options: { timeout?: number }): Waiter {+ private _setupNavigationWaiter(options: TimeoutOptions): Waiter {const waiter = new Waiter(this._page!, '');if (this._page!.isClosed())waiter.rejectImmediately(this._page!._closeErrorWithReason());@@ -127,6 +128,7 @@ export class Frame extends ChannelOwner<channels.FrameChannel> implements api.Frwaiter.rejectOnEvent<Frame>(this._page!, Events.Page.FrameDetached, new Error('Navigating frame was detached!'), frame => frame === this);const timeout = this._page!._timeoutSettings.navigationTimeout(options);waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded.`);+ waiter.rejectOnSignal(options.signal);return waiter;}@@ -165,10 +167,10 @@ export class Frame extends ChannelOwner<channels.FrameChannel> implements api.Fr}, { title: 'Wait for navigation' });}- async waitForLoadState(state: LifecycleEvent = 'load', options: { timeout?: number } = {}): Promise<void> {+ async waitForLoadState(state: LifecycleEvent = 'load', options?: TimeoutOptions): Promise<void> {state = verifyLoadState('state', state);return await this._page!._wrapApiCall(async () => {- const waiter = this._setupNavigationWaiter(options);+ const waiter = this._setupNavigationWaiter(options ?? {});if (this._loadStates.has(state)) {waiter.log(` not waiting, "${state}" event already fired`);} else {@@ -181,11 +183,12 @@ export class Frame extends ChannelOwner<channels.FrameChannel> implements api.Fr}, { title: `Wait for load state "${state}"` });}- async waitForURL(url: URLMatch, options: { waitUntil?: LifecycleEvent, timeout?: number } = {}): Promise<void> {+ async waitForURL(url: URLMatch, options?: { waitUntil?: LifecycleEvent } & TimeoutOptions): Promise<void> {+ const waitOptions = options ?? {};if (urlMatches(this._page?.context()._options.baseURL, this.url(), url))- return await this.waitForLoadState(options.waitUntil, options);+ return await this.waitForLoadState(waitOptions.waitUntil, waitOptions);- await this.waitForNavigation({ url, ...options });+ await this.waitForNavigation({ url, ...waitOptions });}async frameElement(): Promise<ElementHandle> {diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.tsindex 08ce06bf09..49ab620c19 100644--- a/packages/playwright-core/src/client/network.ts+++ b/packages/playwright-core/src/client/network.ts@@ -32,7 +32,7 @@ import { ChannelOwner } from './channelOwner';import type { BrowserContext } from './browserContext';import type { Page } from './page';-import type { Headers, RemoteAddr, SecurityDetails, WaitForEventOptions } from './types';+import type { Headers, RemoteAddr, SecurityDetails, TimeoutOptions, WaitForEventOptions } from './types';import type { Serializable } from '../../types/structs';import type * as api from '../../types/types';import type { HeadersArray } from '@isomorphic/types';@@ -802,8 +802,10 @@ export class WebSocket extends ChannelOwner<channels.WebSocketChannel> implementreturn await this._wrapApiCall(async () => {const timeout = this._page._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;+ const signal = typeof optionsOrPredicate === 'function' ? undefined : (optionsOrPredicate as TimeoutOptions).signal;const waiter = Waiter.createForEvent(this, event);waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);+ waiter.rejectOnSignal(signal);if (event !== Events.WebSocket.Error)waiter.rejectOnEvent(this, Events.WebSocket.Error, new Error('Socket error'));if (event !== Events.WebSocket.Close)diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.tsindex 6da37f9f5b..b45b623083 100644--- a/packages/playwright-core/src/client/page.ts+++ b/packages/playwright-core/src/client/page.ts@@ -449,7 +449,7 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page};const trimmedUrl = trimUrl(urlOrPredicate);const logLine = trimmedUrl ? `waiting for request ${trimmedUrl}` : undefined;- return await this._waitForEvent(Events.Page.Request, { predicate, timeout: options.timeout }, logLine);+ return await this._waitForEvent(Events.Page.Request, { predicate, timeout: options.timeout, signal: options.signal }, logLine);}async waitForResponse(urlOrPredicate: string | RegExp | ((r: Response) => boolean | Promise<boolean>), options: TimeoutOptions = {}): Promise<Response> {@@ -460,7 +460,7 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page};const trimmedUrl = trimUrl(urlOrPredicate);const logLine = trimmedUrl ? `waiting for response ${trimmedUrl}` : undefined;- return await this._waitForEvent(Events.Page.Response, { predicate, timeout: options.timeout }, logLine);+ return await this._waitForEvent(Events.Page.Response, { predicate, timeout: options.timeout, signal: options.signal }, logLine);}async waitForEvent(event: string, optionsOrPredicate: WaitForEventOptions = {}): Promise<any> {@@ -475,10 +475,12 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Pagereturn await this._wrapApiCall(async () => {const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;+ const signal = typeof optionsOrPredicate === 'function' ? undefined : (optionsOrPredicate as TimeoutOptions).signal;const waiter = Waiter.createForEvent(this, event);if (logLine)waiter.log(logLine);waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);+ waiter.rejectOnSignal(signal);if (event !== Events.Page.Crash)waiter.rejectOnEvent(this, Events.Page.Crash, new Error('Page crashed'));if (event !== Events.Page.Close)diff --git a/packages/playwright-core/src/client/types.ts b/packages/playwright-core/src/client/types.tsindex cb90ec932f..cf7bedd7af 100644--- a/packages/playwright-core/src/client/types.ts+++ b/packages/playwright-core/src/client/types.ts@@ -25,7 +25,7 @@ export interface Logger {log(name: string, severity: LoggerSeverity, message: string | Error, args: any[], hints: { color?: string }): void;}-export type TimeoutOptions = { timeout?: number };+export type TimeoutOptions = { timeout?: number, signal?: AbortSignal };export type StrictOptions = { strict?: boolean };export type Headers = { [key: string]: string };diff --git a/packages/playwright-core/src/client/waiter.ts b/packages/playwright-core/src/client/waiter.tsindex e2b63c8900..e53aeae27d 100644--- a/packages/playwright-core/src/client/waiter.ts+++ b/packages/playwright-core/src/client/waiter.ts@@ -85,6 +85,20 @@ export class Waiter {this._rejectOn(promise.then(() => { throw new TimeoutError(message); }), dispose);}+ rejectOnSignal(signal: AbortSignal | undefined) {+ if (!signal)+ return;+ if (signal.aborted) {+ this.rejectImmediately(signalToError(signal));+ return;+ }+ let rejectPromise: (e: any) => void;+ const promise = new Promise<void>((_, reject) => { rejectPromise = reject; });+ const listener = () => rejectPromise!(signalToError(signal));+ signal.addEventListener('abort', listener, { once: true });+ this._rejectOn(promise, () => signal.removeEventListener('abort', listener));+ }+rejectImmediately(error: Error) {this._immediateError = error;}@@ -146,6 +160,14 @@ function waitForEvent<T = void>(emitter: EventEmitter, event: string, savedZone:return { promise, dispose };}+function signalToError(signal: AbortSignal): Error {+ const reason = signal.reason;+ if (reason instanceof Error)+ return reason;+ const message = typeof reason?.message === 'string' ? reason.message : reason;+ return new Error(String(message ?? 'The operation was aborted'));+}+function waitForTimeout(timeout: number): { promise: Promise<void>, dispose: () => void } {let timeoutId: any;const promise = new Promise<void>(resolve => timeoutId = setTimeout(resolve, timeout));diff --git a/packages/playwright-core/src/client/worker.ts b/packages/playwright-core/src/client/worker.tsindex ee98e35779..1d11e65b21 100644--- a/packages/playwright-core/src/client/worker.ts+++ b/packages/playwright-core/src/client/worker.ts@@ -28,7 +28,7 @@ import type { Page } from './page';import type * as structs from '../../types/structs';import type * as api from '../../types/types';import type * as channels from '@protocol/channels';-import type { WaitForEventOptions } from './types';+import type { TimeoutOptions, WaitForEventOptions } from './types';export class Worker extends ChannelOwner<channels.WorkerChannel> implements api.Worker {@@ -91,8 +91,10 @@ export class Worker extends ChannelOwner<channels.WorkerChannel> implements api.const timeoutSettings = this._page?._timeoutSettings ?? this._context?._timeoutSettings ?? new TimeoutSettings(this._platform);const timeout = timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;+ const signal = typeof optionsOrPredicate === 'function' ? undefined : (optionsOrPredicate as TimeoutOptions).signal;const waiter = Waiter.createForEvent(this, event);waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);+ waiter.rejectOnSignal(signal);if (event !== Events.Worker.Close)waiter.rejectOnEvent(this, Events.Worker.Close, () => this._closeErrorWithReason());const result = await waiter.waitForEvent(this, event, predicate as any);diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.tsindex 0bff9d367c..67f1246e56 100644--- a/packages/playwright-core/types/types.d.ts+++ b/packages/playwright-core/types/types.d.ts@@ -4787,7 +4787,7 @@ export interface Page {/*** Emitted when the page closes.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`.@@ -4808,7 +4808,7 @@ export interface Page {* ```**/- waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;/*** Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page@@ -4828,7 +4828,7 @@ export interface Page {* ```**/- waitForEvent(event: 'crash', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'crash', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Listener **must**@@ -4848,19 +4848,19 @@ export interface Page {* listeners are present, all dialogs are automatically dismissed.**/- waitForEvent(event: 'dialog', optionsOrPredicate?: { predicate?: (dialog: Dialog) => boolean | Promise<boolean>, timeout?: number } | ((dialog: Dialog) => boolean | Promise<boolean>)): Promise<Dialog>;+ waitForEvent(event: 'dialog', optionsOrPredicate?: { predicate?: (dialog: Dialog) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((dialog: Dialog) => boolean | Promise<boolean>)): Promise<Dialog>;/*** Emitted when the JavaScript* [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched.*/- waitForEvent(event: 'domcontentloaded', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'domcontentloaded', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when attachment download started. User can access basic file operations on downloaded content via the* passed [Download](https://playwright.dev/docs/api/class-download) instance.*/- waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise<boolean>, timeout?: number } | ((download: Download) => boolean | Promise<boolean>)): Promise<Download>;+ waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((download: Download) => boolean | Promise<boolean>)): Promise<Download>;/*** Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can@@ -4875,27 +4875,27 @@ export interface Page {* ```**/- waitForEvent(event: 'filechooser', optionsOrPredicate?: { predicate?: (fileChooser: FileChooser) => boolean | Promise<boolean>, timeout?: number } | ((fileChooser: FileChooser) => boolean | Promise<boolean>)): Promise<FileChooser>;+ waitForEvent(event: 'filechooser', optionsOrPredicate?: { predicate?: (fileChooser: FileChooser) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((fileChooser: FileChooser) => boolean | Promise<boolean>)): Promise<FileChooser>;/*** Emitted when a frame is attached.*/- waitForEvent(event: 'frameattached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'frameattached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when a frame is detached.*/- waitForEvent(event: 'framedetached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'framedetached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when a frame is navigated to a new url.*/- waitForEvent(event: 'framenavigated', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'framenavigated', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.*/- waitForEvent(event: 'load', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'load', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when an uncaught exception happens within the page.@@ -4911,7 +4911,7 @@ export interface Page {* ```**/- waitForEvent(event: 'pageerror', optionsOrPredicate?: { predicate?: (error: Error) => boolean | Promise<boolean>, timeout?: number } | ((error: Error) => boolean | Promise<boolean>)): Promise<Error>;+ waitForEvent(event: 'pageerror', optionsOrPredicate?: { predicate?: (error: Error) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((error: Error) => boolean | Promise<boolean>)): Promise<Error>;/*** Emitted when the page opens a new tab or window. This event is emitted in addition to the@@ -4940,14 +4940,14 @@ export interface Page {* wait until the page gets to a particular state (you should not need it in most cases).**/- waitForEvent(event: 'popup', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'popup', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests,* see [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route) or* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route).*/- waitForEvent(event: 'request', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'request', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when a request fails, for example by timing out.@@ -4966,30 +4966,30 @@ export interface Page {* error net::ERR_FAILED.**/- waitForEvent(event: 'requestfailed', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'requestfailed', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when a request finishes successfully after downloading the response body. For a successful response, the* sequence of events is `request`, `response` and `requestfinished`.*/- waitForEvent(event: 'requestfinished', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'requestfinished', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when [response] status and headers are received for a request. For a successful response, the sequence of* events is `request`, `response` and `requestfinished`.*/- waitForEvent(event: 'response', optionsOrPredicate?: { predicate?: (response: Response) => boolean | Promise<boolean>, timeout?: number } | ((response: Response) => boolean | Promise<boolean>)): Promise<Response>;+ waitForEvent(event: 'response', optionsOrPredicate?: { predicate?: (response: Response) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((response: Response) => boolean | Promise<boolean>)): Promise<Response>;/*** Emitted when [WebSocket](https://playwright.dev/docs/api/class-websocket) request is sent.*/- waitForEvent(event: 'websocket', optionsOrPredicate?: { predicate?: (webSocket: WebSocket) => boolean | Promise<boolean>, timeout?: number } | ((webSocket: WebSocket) => boolean | Promise<boolean>)): Promise<WebSocket>;+ waitForEvent(event: 'websocket', optionsOrPredicate?: { predicate?: (webSocket: WebSocket) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((webSocket: WebSocket) => boolean | Promise<boolean>)): Promise<WebSocket>;/*** Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned* by the page.*/- waitForEvent(event: 'worker', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;+ waitForEvent(event: 'worker', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;/**@@ -5026,6 +5026,14 @@ export interface Page {* @param options*/waitForLoadState(state?: "load"|"domcontentloaded"|"networkidle", options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -5063,6 +5071,14 @@ export interface Page {* @param options*/waitForNavigation(options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -5116,6 +5132,14 @@ export interface Page {* @param options*/waitForRequest(urlOrPredicate: string|RegExp|((request: Request) => boolean|Promise<boolean>), options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can* be changed by using the@@ -5152,6 +5176,14 @@ export interface Page {* @param options*/waitForResponse(urlOrPredicate: string|RegExp|((response: Response) => boolean|Promise<boolean>), options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can* be changed by using the@@ -5198,6 +5230,14 @@ export interface Page {* @param options*/waitForURL(url: string|RegExp|URLPattern|((url: URL) => boolean), options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -8023,6 +8063,14 @@ export interface Frame {* @param options*/waitForLoadState(state?: "load"|"domcontentloaded"|"networkidle", options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -8059,6 +8107,14 @@ export interface Frame {* @param options*/waitForNavigation(options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -8117,6 +8173,14 @@ export interface Frame {* @param options*/waitForURL(url: string|RegExp|URLPattern|((url: URL) => boolean), options?: {+ /**+ * Allows to cancel the waiting using an+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the+ * waiting will be aborted and the operation will throw an error. Note that providing a signal does not disable the+ * default timeout; pass `timeout: 0` to disable the timeout entirely.+ */+ signal?: AbortSignal;+/*** Maximum operation time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via* `navigationTimeout` option in the config, or by using the@@ -9723,7 +9787,7 @@ export interface BrowserContext {/*** This event is not emitted.*/- waitForEvent(event: 'backgroundpage', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'backgroundpage', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when Browser context gets closed. This might happen because of one of the following:@@ -9731,7 +9795,7 @@ export interface BrowserContext {* - Browser application is closed or crashed.* - The [browser.close([options])](https://playwright.dev/docs/api/class-browser#browser-close) method was called.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (browserContext: BrowserContext) => boolean | Promise<boolean>, timeout?: number } | ((browserContext: BrowserContext) => boolean | Promise<boolean>)): Promise<BrowserContext>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (browserContext: BrowserContext) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((browserContext: BrowserContext) => boolean | Promise<boolean>)): Promise<BrowserContext>;/*** Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`.@@ -9752,7 +9816,7 @@ export interface BrowserContext {* ```**/- waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;/*** Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Listener **must**@@ -9774,7 +9838,7 @@ export interface BrowserContext {* listeners are present, all dialogs are automatically dismissed.**/- waitForEvent(event: 'dialog', optionsOrPredicate?: { predicate?: (dialog: Dialog) => boolean | Promise<boolean>, timeout?: number } | ((dialog: Dialog) => boolean | Promise<boolean>)): Promise<Dialog>;+ waitForEvent(event: 'dialog', optionsOrPredicate?: { predicate?: (dialog: Dialog) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((dialog: Dialog) => boolean | Promise<boolean>)): Promise<Dialog>;/*** Emitted when attachment download started in any page belonging to this context. User can access basic file@@ -9782,28 +9846,28 @@ export interface BrowserContext {* instance. See also [page.on('download')](https://playwright.dev/docs/api/class-page#page-event-download) to receive* events about a specific page.*/- waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise<boolean>, timeout?: number } | ((download: Download) => boolean | Promise<boolean>)): Promise<Download>;+ waitForEvent(event: 'download', optionsOrPredicate?: { predicate?: (download: Download) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((download: Download) => boolean | Promise<boolean>)): Promise<Download>;/*** Emitted when a frame is attached in any page belonging to this context. See also* [page.on('frameattached')](https://playwright.dev/docs/api/class-page#page-event-frame-attached) to receive events* about a specific page.*/- waitForEvent(event: 'frameattached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'frameattached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when a frame is detached in any page belonging to this context. See also* [page.on('framedetached')](https://playwright.dev/docs/api/class-page#page-event-frame-detached) to receive events* about a specific page.*/- waitForEvent(event: 'framedetached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'framedetached', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** Emitted when a frame is navigated to a new url in any page belonging to this context. See also* [page.on('framenavigated')](https://playwright.dev/docs/api/class-page#page-event-frame-navigated) to receive* events about navigations in a specific page.*/- waitForEvent(event: 'framenavigated', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;+ waitForEvent(event: 'framenavigated', optionsOrPredicate?: { predicate?: (frame: Frame) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((frame: Frame) => boolean | Promise<boolean>)): Promise<Frame>;/*** The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event@@ -9832,14 +9896,14 @@ export interface BrowserContext {* wait until the page gets to a particular state (you should not need it in most cases).**/- waitForEvent(event: 'page', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'page', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when a page in this context is closed. See also* [page.on('close')](https://playwright.dev/docs/api/class-page#page-event-close) to receive events about a specific* page.*/- waitForEvent(event: 'pageclose', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'pageclose', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched@@ -9847,7 +9911,7 @@ export interface BrowserContext {* [page.on('load')](https://playwright.dev/docs/api/class-page#page-event-load) to receive events about a specific* page.*/- waitForEvent(event: 'pageload', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'pageload', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/*** Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To@@ -9858,7 +9922,7 @@ export interface BrowserContext {* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)* or [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route).*/- waitForEvent(event: 'request', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'request', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when a request fails, for example by timing out. To only listen for failed requests from a particular page,@@ -9871,7 +9935,7 @@ export interface BrowserContext {* [browserContext.on('requestfailed')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request-failed).**/- waitForEvent(event: 'requestfailed', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'requestfailed', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when a request finishes successfully after downloading the response body. For a successful response, the@@ -9879,27 +9943,27 @@ export interface BrowserContext {* particular page, use* [page.on('requestfinished')](https://playwright.dev/docs/api/class-page#page-event-request-finished).*/- waitForEvent(event: 'requestfinished', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;+ waitForEvent(event: 'requestfinished', optionsOrPredicate?: { predicate?: (request: Request) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((request: Request) => boolean | Promise<boolean>)): Promise<Request>;/*** Emitted when [response] status and headers are received for a request. For a successful response, the sequence of* events is `request`, `response` and `requestfinished`. To listen for response events from a particular page, use* [page.on('response')](https://playwright.dev/docs/api/class-page#page-event-response).*/- waitForEvent(event: 'response', optionsOrPredicate?: { predicate?: (response: Response) => boolean | Promise<boolean>, timeout?: number } | ((response: Response) => boolean | Promise<boolean>)): Promise<Response>;+ waitForEvent(event: 'response', optionsOrPredicate?: { predicate?: (response: Response) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((response: Response) => boolean | Promise<boolean>)): Promise<Response>;/*** **NOTE** Service workers are only supported on Chromium-based browsers.** Emitted when new service worker is created in the context.*/- waitForEvent(event: 'serviceworker', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;+ waitForEvent(event: 'serviceworker', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;/*** Emitted when exception is unhandled in any of the pages in this context. To listen for errors from a particular* page, use [page.on('pageerror')](https://playwright.dev/docs/api/class-page#page-event-page-error) instead.*/- waitForEvent(event: 'weberror', optionsOrPredicate?: { predicate?: (webError: WebError) => boolean | Promise<boolean>, timeout?: number } | ((webError: WebError) => boolean | Promise<boolean>)): Promise<WebError>;+ waitForEvent(event: 'weberror', optionsOrPredicate?: { predicate?: (webError: WebError) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((webError: WebError) => boolean | Promise<boolean>)): Promise<WebError>;/**@@ -10866,12 +10930,12 @@ export interface Worker {* Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is* terminated.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (worker: Worker) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((worker: Worker) => boolean | Promise<boolean>)): Promise<Worker>;/*** Emitted when JavaScript within the worker calls one of console API methods, e.g. `console.log` or `console.dir`.*/- waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;}@@ -17094,7 +17158,7 @@ export interface ElectronApplication {/*** This event is issued when the application process has been terminated.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: () => boolean | Promise<boolean>, timeout?: number } | (() => boolean | Promise<boolean>)): Promise<void>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: () => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | (() => boolean | Promise<boolean>)): Promise<void>;/*** Emitted when JavaScript within the Electron main process calls one of console API methods, e.g. `console.log` or@@ -17116,13 +17180,13 @@ export interface ElectronApplication {* ```**/- waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;+ waitForEvent(event: 'console', optionsOrPredicate?: { predicate?: (consoleMessage: ConsoleMessage) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((consoleMessage: ConsoleMessage) => boolean | Promise<boolean>)): Promise<ConsoleMessage>;/*** This event is issued for every window that is created **and loaded** in Electron. It contains a* [Page](https://playwright.dev/docs/api/class-page) that can be used for Playwright automation.*/- waitForEvent(event: 'window', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;+ waitForEvent(event: 'window', optionsOrPredicate?: { predicate?: (page: Page) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((page: Page) => boolean | Promise<boolean>)): Promise<Page>;/**@@ -21611,7 +21675,7 @@ export interface WebSocket {/*** Fired when the websocket closes.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (webSocket: WebSocket) => boolean | Promise<boolean>, timeout?: number } | ((webSocket: WebSocket) => boolean | Promise<boolean>)): Promise<WebSocket>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (webSocket: WebSocket) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((webSocket: WebSocket) => boolean | Promise<boolean>)): Promise<WebSocket>;/*** Fired when the websocket receives a frame.@@ -21621,7 +21685,7 @@ export interface WebSocket {* frame payload*/payload: string|Buffer;- }) => boolean | Promise<boolean>, timeout?: number } | ((data: {+ }) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((data: {/*** frame payload*/@@ -21641,7 +21705,7 @@ export interface WebSocket {* frame payload*/payload: string|Buffer;- }) => boolean | Promise<boolean>, timeout?: number } | ((data: {+ }) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((data: {/*** frame payload*/@@ -21656,7 +21720,7 @@ export interface WebSocket {/*** Fired when the websocket has an error.*/- waitForEvent(event: 'socketerror', optionsOrPredicate?: { predicate?: (string: string) => boolean | Promise<boolean>, timeout?: number } | ((string: string) => boolean | Promise<boolean>)): Promise<string>;+ waitForEvent(event: 'socketerror', optionsOrPredicate?: { predicate?: (string: string) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((string: string) => boolean | Promise<boolean>)): Promise<string>;}@@ -23008,12 +23072,12 @@ export interface AndroidDevice {/*** Emitted when the device connection gets closed.*/- waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (androidDevice: AndroidDevice) => boolean | Promise<boolean>, timeout?: number } | ((androidDevice: AndroidDevice) => boolean | Promise<boolean>)): Promise<AndroidDevice>;+ waitForEvent(event: 'close', optionsOrPredicate?: { predicate?: (androidDevice: AndroidDevice) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((androidDevice: AndroidDevice) => boolean | Promise<boolean>)): Promise<AndroidDevice>;/*** Emitted when a new WebView instance is detected.*/- waitForEvent(event: 'webview', optionsOrPredicate?: { predicate?: (androidWebView: AndroidWebView) => boolean | Promise<boolean>, timeout?: number } | ((androidWebView: AndroidWebView) => boolean | Promise<boolean>)): Promise<AndroidWebView>;+ waitForEvent(event: 'webview', optionsOrPredicate?: { predicate?: (androidWebView: AndroidWebView) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((androidWebView: AndroidWebView) => boolean | Promise<boolean>)): Promise<AndroidWebView>;/**diff --git a/tests/page/page-filechooser.spec.ts b/tests/page/page-filechooser.spec.tsindex aa89ec3964..478c97f2b5 100644--- a/tests/page/page-filechooser.spec.ts+++ b/tests/page/page-filechooser.spec.ts@@ -217,6 +217,13 @@ test('should work with no timeout', async ({ page, server }) => {expect(chooser).toBeTruthy();});+test('should abort with signal', async ({ page }) => {+ const controller = new AbortController();+ const promise = page.waitForEvent('filechooser', { signal: controller.signal });+ controller.abort('Aborted by user');+ await expect(promise).rejects.toThrow('Aborted by user');+});+test('should return the same file chooser when there are many watchdogs simultaneously', async ({ page, server }) => {await page.setContent(`<input type=file>`);const [fileChooser1, fileChooser2] = await Promise.all([diff --git a/utils/generate_types/index.js b/utils/generate_types/index.jsindex dc811837eb..c0cf8c46b9 100644--- a/utils/generate_types/index.js+++ b/utils/generate_types/index.js@@ -288,7 +288,7 @@ class TypesGenerator {for (const { eventName, params, comment, type } of eventDescriptions) {if (comment)parts.push(this.writeComment(comment, indent));- parts.push(` ${member.alias}(event: '${eventName}', optionsOrPredicate?: { predicate?: (${params}) => boolean | Promise<boolean>, timeout?: number } | ((${params}) => boolean | Promise<boolean>)): Promise<${type}>;\n`);+ parts.push(` ${member.alias}(event: '${eventName}', optionsOrPredicate?: { predicate?: (${params}) => boolean | Promise<boolean>, timeout?: number, signal?: AbortSignal } | ((${params}) => boolean | Promise<boolean>)): Promise<${type}>;\n`);}return parts.join('\n');