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
2 changes: 1 addition & 1 deletion docs/src/api/class-browsercontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/We
### param: BrowserContext.route.handler
* since: v1.8
* langs: js, python
- `handler` <[function]\([Route], [Request]\)>
- `handler` <[function]\([Route], [Request]\): [Promise<any>|any]>

handler function to route the request.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/api/class-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -3138,7 +3138,7 @@ it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/We
### param: Page.route.handler
* since: v1.8
* langs: js, python
- `handler` <[function]\([Route], [Request]\)>
- `handler` <[function]\([Route], [Request]\): [Promise<any>|any]>

handler function to route the request.

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 @@ -422,7 +422,7 @@ export class Route extends ChannelOwner<channels.RouteChannel> implements api.Ro
}
}

export type RouteHandlerCallback = (route: Route, request: Request) => void;
export type RouteHandlerCallback = (route: Route, request: Request) => Promise<any> | void;

export type ResourceTiming = {
startTime: number;
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3564,7 +3564,7 @@ export interface Page {
* @param handler handler function to route the request.
* @param options
*/
route(url: string|RegExp|((url: URL) => boolean), handler: ((route: Route, request: Request) => void), options?: {
route(url: string|RegExp|((url: URL) => boolean), handler: ((route: Route, request: Request) => Promise<any>|any), options?: {
/**
* How often a route should be used. By default it will be used every time.
*/
Expand Down Expand Up @@ -8041,7 +8041,7 @@ export interface BrowserContext {
* @param handler handler function to route the request.
* @param options
*/
route(url: string|RegExp|((url: URL) => boolean), handler: ((route: Route, request: Request) => void), options?: {
route(url: string|RegExp|((url: URL) => boolean), handler: ((route: Route, request: Request) => Promise<any>|any), options?: {
/**
* How often a route should be used. By default it will be used every time.
*/
Expand Down
2 changes: 2 additions & 0 deletions utils/generate_types/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ playwright.chromium.launch().then(async browser => {
else route.continue();
});

await page.route('**/*', route => route.continue());

await page.route(str => {
return true;
}, (route, request) => {
Expand Down