chore: return Promise<any> in {page,context}.route (#20005)
Fixes https://github.com/microsoft/playwright/issues/19855 Closes https://github.com/microsoft/playwright/pull/19856
This commit is contained in:
parent
e2a2196e6a
commit
0fe327c21b
|
|
@ -1060,7 +1060,7 @@ it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/We
|
||||||
### param: BrowserContext.route.handler
|
### param: BrowserContext.route.handler
|
||||||
* since: v1.8
|
* since: v1.8
|
||||||
* langs: js, python
|
* langs: js, python
|
||||||
- `handler` <[function]\([Route], [Request]\)>
|
- `handler` <[function]\([Route], [Request]\): [Promise<any>|any]>
|
||||||
|
|
||||||
handler function to route the request.
|
handler function to route the request.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3138,7 +3138,7 @@ it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/We
|
||||||
### param: Page.route.handler
|
### param: Page.route.handler
|
||||||
* since: v1.8
|
* since: v1.8
|
||||||
* langs: js, python
|
* langs: js, python
|
||||||
- `handler` <[function]\([Route], [Request]\)>
|
- `handler` <[function]\([Route], [Request]\): [Promise<any>|any]>
|
||||||
|
|
||||||
handler function to route the request.
|
handler function to route the request.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 = {
|
export type ResourceTiming = {
|
||||||
startTime: number;
|
startTime: number;
|
||||||
|
|
|
||||||
4
packages/playwright-core/types/types.d.ts
vendored
4
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -3564,7 +3564,7 @@ export interface Page {
|
||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @param options
|
* @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.
|
* How often a route should be used. By default it will be used every time.
|
||||||
*/
|
*/
|
||||||
|
|
@ -8041,7 +8041,7 @@ export interface BrowserContext {
|
||||||
* @param handler handler function to route the request.
|
* @param handler handler function to route the request.
|
||||||
* @param options
|
* @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.
|
* How often a route should be used. By default it will be used every time.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,8 @@ playwright.chromium.launch().then(async browser => {
|
||||||
else route.continue();
|
else route.continue();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await page.route('**/*', route => route.continue());
|
||||||
|
|
||||||
await page.route(str => {
|
await page.route(str => {
|
||||||
return true;
|
return true;
|
||||||
}, (route, request) => {
|
}, (route, request) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue