Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/src/api/class-apirequestcontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions docs/src/api/class-locator.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions docs/src/api/class-route.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand Down
92 changes: 90 additions & 2 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13844,7 +13844,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.
Expand Down Expand Up @@ -13877,7 +13877,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.
*
Expand Down Expand Up @@ -19038,6 +19038,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.
*/
Expand Down Expand Up @@ -19175,6 +19186,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.
*/
Expand Down Expand Up @@ -19287,6 +19309,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.
*/
Expand Down Expand Up @@ -19373,6 +19406,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.
*/
Expand Down Expand Up @@ -19459,6 +19503,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.
*/
Expand Down Expand Up @@ -19587,6 +19642,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.
*/
Expand Down Expand Up @@ -19673,6 +19739,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.
*/
Expand Down Expand Up @@ -22388,6 +22465,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.
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/playwright-core/src/client/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/client/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ 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> {
return await this._frame.$$eval(this._selector, pageFunction, arg);
}

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> {
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/client/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
Expand Down
Loading
Loading