Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat: support AbortSignal on more methods (#41547)

Simon Knott131e3dcd39d2
diff --git a/docs/src/api/class-apirequestcontext.md b/docs/src/api/class-apirequestcontext.md
index 2ddc3815f6..28399a0b03 100644
--- a/docs/src/api/class-apirequestcontext.md
+++ b/docs/src/api/class-apirequestcontext.md
@@ -184,6 +184,8 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.delete.timeout = %%-js-python-csharp-fetch-option-timeout-%%
* since: v1.16
+### option: APIRequestContext.delete.signal = %%-input-signal-%%
+
### option: APIRequestContext.delete.failOnStatusCode = %%-js-python-csharp-fetch-option-failonstatuscode-%%
* since: v1.16
@@ -361,6 +363,8 @@ If set changes the fetch method (e.g. [PUT](https://developer.mozilla.org/en-US/
### option: APIRequestContext.fetch.timeout = %%-js-python-csharp-fetch-option-timeout-%%
* since: v1.16
+### option: APIRequestContext.fetch.signal = %%-input-signal-%%
+
### option: APIRequestContext.fetch.failOnStatusCode = %%-js-python-csharp-fetch-option-failonstatuscode-%%
* since: v1.16
@@ -474,6 +478,8 @@ await request.GetAsync("https://example.com/api/getText", new() { Params = query
### option: APIRequestContext.get.timeout = %%-js-python-csharp-fetch-option-timeout-%%
* since: v1.16
+### option: APIRequestContext.get.signal = %%-input-signal-%%
+
### option: APIRequestContext.get.failOnStatusCode = %%-js-python-csharp-fetch-option-failonstatuscode-%%
* since: v1.16
@@ -539,6 +545,8 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.head.timeout = %%-js-python-csharp-fetch-option-timeout-%%
* since: v1.16
+### option: APIRequestContext.head.signal = %%-input-signal-%%
+
### option: APIRequestContext.head.failOnStatusCode = %%-js-python-csharp-fetch-option-failonstatuscode-%%
* since: v1.16
@@ -604,6 +612,8 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.patch.timeout = %%-js-python-csharp-fetch-option-timeout-%%
* since: v1.16
+### option: APIRequestContext.patch.signal = %%-input-signal-%%
+
### option: APIRequestContext.patch.failOnStatusCode = %%-js-python-csharp-fetch-option-failonstatuscode-%%
* since: v1.16
@@ -790,6 +800,8 @@ await request.PostAsync("https://example.com/api/uploadScript", new() { Multipar
### option: APIRequestContext.post.timeout = %%-js-python-csharp-fetch-option-timeout-%%
* since: v1.16
+### option: APIRequestContext.post.signal = %%-input-signal-%%
+
### option: APIRequestContext.post.failOnStatusCode = %%-js-python-csharp-fetch-option-failonstatuscode-%%
* since: v1.16
@@ -855,6 +867,8 @@ context cookies from the response. The method will automatically follow redirect
### option: APIRequestContext.put.timeout = %%-js-python-csharp-fetch-option-timeout-%%
* since: v1.16
+### option: APIRequestContext.put.signal = %%-input-signal-%%
+
### option: APIRequestContext.put.failOnStatusCode = %%-js-python-csharp-fetch-option-failonstatuscode-%%
* since: v1.16
diff --git a/docs/src/api/class-locator.md b/docs/src/api/class-locator.md
index 3cb294302d..bba1f1f9a6 100644
--- a/docs/src/api/class-locator.md
+++ b/docs/src/api/class-locator.md
@@ -1137,6 +1137,8 @@ Maximum time in milliseconds to wait for the locator before evaluating. Note tha
Maximum time in milliseconds to wait for the locator before evaluating. Note that after locator is resolved, evaluation itself is not limited by the timeout. Defaults to `0` - no timeout.
+### option: Locator.evaluate.signal = %%-input-signal-%%
+
## async method: Locator.evaluateAll
* since: v1.14
- returns: <[Serializable]>
@@ -1234,6 +1236,8 @@ Maximum time in milliseconds to wait for the locator before evaluating. Note tha
Maximum time in milliseconds to wait for the locator before evaluating. Note that after locator is resolved, evaluation itself is not limited by the timeout. Defaults to `0` - no timeout.
+### option: Locator.evaluateHandle.signal = %%-input-signal-%%
+
## async method: Locator.fill
* since: v1.14
diff --git a/docs/src/api/class-route.md b/docs/src/api/class-route.md
index 5bbe4b3f83..ccccbe556c 100644
--- a/docs/src/api/class-route.md
+++ b/docs/src/api/class-route.md
@@ -528,6 +528,8 @@ Maximum number of times network errors should be retried. Currently only `ECONNR
Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
+### option: Route.fetch.signal = %%-input-signal-%%
+
### option: Route.fetch.method
* since: v1.29
- `method` <[string]>
diff --git a/packages/playwright-client/types/types.d.ts b/packages/playwright-client/types/types.d.ts
index 6da20cd4fa..da1cec1870 100644
--- a/packages/playwright-client/types/types.d.ts
+++ b/packages/playwright-client/types/types.d.ts
@@ -13850,7 +13850,7 @@ export interface Locator {
* [`pageFunction`](https://playwright.dev/docs/api/class-locator#locator-evaluate-option-expression).
* @param options
*/
- evaluate<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number }): Promise<R>;
+ evaluate<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number, signal?: AbortSignal }): Promise<R>;
/**
* Execute JavaScript code in the page, taking the matching element as an argument, and return a
* [JSHandle](https://playwright.dev/docs/api/class-jshandle) with the result.
@@ -13883,7 +13883,7 @@ export interface Locator {
* [`pageFunction`](https://playwright.dev/docs/api/class-locator#locator-evaluate-handle-option-expression).
* @param options
*/
- evaluateHandle<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number }): Promise<SmartHandle<R>>;
+ evaluateHandle<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number, signal?: AbortSignal }): Promise<SmartHandle<R>>;
/**
* Execute JavaScript code in the page, taking all matching elements as an argument.
*
@@ -19044,6 +19044,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19181,6 +19192,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19293,6 +19315,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19379,6 +19412,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19465,6 +19509,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19593,6 +19648,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19679,6 +19745,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -22394,6 +22471,17 @@ export interface Route {
*/
postData?: string|Buffer|Serializable;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
diff --git a/packages/playwright-core/src/client/fetch.ts b/packages/playwright-core/src/client/fetch.ts
index 6439951aa4..59a729ae63 100644
--- a/packages/playwright-core/src/client/fetch.ts
+++ b/packages/playwright-core/src/client/fetch.ts
@@ -44,6 +44,7 @@ export type FetchOptions = {
form?: { [key: string]: string|number|boolean; } | FormData;
multipart?: { [key: string]: string|number|boolean|fs.ReadStream|FilePayload; } | FormData;
timeout?: number,
+ signal?: AbortSignal,
failOnStatusCode?: boolean,
ignoreHTTPSErrors?: boolean,
maxRedirects?: number,
@@ -260,7 +261,7 @@ export class APIRequestContext extends ChannelOwner<channels.APIRequestContextCh
maxRedirects: options.maxRedirects,
maxRetries: options.maxRetries,
...fixtures
- }, undefined);
+ }, options.signal);
return new APIResponse(this, result.response);
});
}
diff --git a/packages/playwright-core/src/client/locator.ts b/packages/playwright-core/src/client/locator.ts
index d5f027fa33..05d8d98f16 100644
--- a/packages/playwright-core/src/client/locator.ts
+++ b/packages/playwright-core/src/client/locator.ts
@@ -134,7 +134,7 @@ export class Locator implements api.Locator {
}
async evaluate<R, Arg>(pageFunction: structs.PageFunctionOn<SVGElement | HTMLElement, Arg, R>, arg?: Arg, options?: TimeoutOptions): Promise<R> {
- return await this._withElement(h => h.evaluate(pageFunction, arg), { title: 'Evaluate', timeout: options?.timeout });
+ return await this._withElement(h => h.evaluate(pageFunction, arg), { title: 'Evaluate', timeout: options?.timeout, signal: options?.signal });
}
async evaluateAll<R, Arg>(pageFunction: structs.PageFunctionOn<Element[], Arg, R>, arg?: Arg): Promise<R> {
@@ -142,7 +142,7 @@ export class Locator implements api.Locator {
}
async evaluateHandle<R, Arg>(pageFunction: structs.PageFunctionOn<any, Arg, R>, arg?: Arg, options?: TimeoutOptions): Promise<structs.SmartHandle<R>> {
- return await this._withElement(h => h.evaluateHandle(pageFunction, arg), { title: 'Evaluate', timeout: options?.timeout });
+ return await this._withElement(h => h.evaluateHandle(pageFunction, arg), { title: 'Evaluate', timeout: options?.timeout, signal: options?.signal });
}
async fill(value: string, options: channels.ElementHandleFillOptions & TimeoutOptions = {}): Promise<void> {
diff --git a/packages/playwright-core/src/client/network.ts b/packages/playwright-core/src/client/network.ts
index e1efd76691..6986160ee7 100644
--- a/packages/playwright-core/src/client/network.ts
+++ b/packages/playwright-core/src/client/network.ts
@@ -346,7 +346,7 @@ export class Route extends ChannelOwner<channels.RouteChannel> implements api.Ro
});
}
- async fetch(options: FallbackOverrides & { maxRedirects?: number, maxRetries?: number, timeout?: number } = {}): Promise<APIResponse> {
+ async fetch(options: FallbackOverrides & { maxRedirects?: number, maxRetries?: number, timeout?: number, signal?: AbortSignal } = {}): Promise<APIResponse> {
return await this._wrapApiCall(async () => {
return await this._context.request._innerFetch({ request: this.request(), data: options.postData, ...options });
});
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index 6da20cd4fa..da1cec1870 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -13850,7 +13850,7 @@ export interface Locator {
* [`pageFunction`](https://playwright.dev/docs/api/class-locator#locator-evaluate-option-expression).
* @param options
*/
- evaluate<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number }): Promise<R>;
+ evaluate<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number, signal?: AbortSignal }): Promise<R>;
/**
* Execute JavaScript code in the page, taking the matching element as an argument, and return a
* [JSHandle](https://playwright.dev/docs/api/class-jshandle) with the result.
@@ -13883,7 +13883,7 @@ export interface Locator {
* [`pageFunction`](https://playwright.dev/docs/api/class-locator#locator-evaluate-handle-option-expression).
* @param options
*/
- evaluateHandle<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number }): Promise<SmartHandle<R>>;
+ evaluateHandle<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number, signal?: AbortSignal }): Promise<SmartHandle<R>>;
/**
* Execute JavaScript code in the page, taking all matching elements as an argument.
*
@@ -19044,6 +19044,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19181,6 +19192,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19293,6 +19315,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19379,6 +19412,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19465,6 +19509,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19593,6 +19648,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -19679,6 +19745,17 @@ export interface APIRequestContext {
*/
params?: { [key: string]: string|number|boolean; }|URLSearchParams|string;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
@@ -22394,6 +22471,17 @@ export interface Route {
*/
postData?: string|Buffer|Serializable;
+ /**
+ * Allows to cancel the operation using an
+ * [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
+ * operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
+ * which can be changed using
+ * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
+ * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
+ * `timeout: 0` to disable the timeout entirely.
+ */
+ signal?: AbortSignal;
+
/**
* Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
*/
diff --git a/utils/generate_types/overrides.d.ts b/utils/generate_types/overrides.d.ts
index 54300f3c1e..302fd7e312 100644
--- a/utils/generate_types/overrides.d.ts
+++ b/utils/generate_types/overrides.d.ts
@@ -190,8 +190,8 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
}
export interface Locator {
- evaluate<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number }): Promise<R>;
- evaluateHandle<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number }): Promise<SmartHandle<R>>;
+ evaluate<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number, signal?: AbortSignal }): Promise<R>;
+ evaluateHandle<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, R>, arg?: Arg, options?: { timeout?: number, signal?: AbortSignal }): Promise<SmartHandle<R>>;
evaluateAll<R, Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E[], Arg, R>, arg?: Arg): Promise<R>;
waitForFunction<Arg, E extends SVGElement | HTMLElement = SVGElement | HTMLElement>(pageFunction: PageFunctionOn<E, Arg, any>, arg?: Arg, options?: { timeout?: number, signal?: AbortSignal }): Promise<void>;
elementHandle(options?: { timeout?: number }): Promise<ElementHandle<SVGElement | HTMLElement>>;