diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md index 371ca53b90..690a1ed1e1 100644 --- a/docs/src/api/class-browsercontext.md +++ b/docs/src/api/class-browsercontext.md @@ -854,6 +854,10 @@ Returns all open pages in the context. Routing provides the capability to modify network requests that are made by any page in the browser context. Once route is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted. +:::note +[`method: Page.route`] will not intercept requests intercepted by Service Worker. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);` +::: + An example of a naive handler that aborts all image requests: ```js diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md index 92ce9b0c63..aa66b9dd5d 100644 --- a/docs/src/api/class-page.md +++ b/docs/src/api/class-page.md @@ -2410,6 +2410,10 @@ Once routing is enabled, every request matching the url pattern will stall unles The handler will only be called for the first url if the response is a redirect. ::: +:::note +[`method: Page.route`] will not intercept requests intercepted by Service Worker. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);` +::: + An example of a naive handler that aborts all image requests: ```js diff --git a/types/types.d.ts b/types/types.d.ts index 8fdce55a3a..2f29346461 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -2339,6 +2339,10 @@ export interface Page { * Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted. * * > NOTE: The handler will only be called for the first url if the response is a redirect. + * > NOTE: [page.route(url, handler)](https://playwright.dev/docs/api/class-page#page-route) will not intercept requests + * intercepted by Service Worker. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend + * disabling Service Workers when using request interception. Via `await context.addInitScript(() => delete + * window.navigator.serviceWorker);` * * An example of a naive handler that aborts all image requests: * @@ -5496,6 +5500,11 @@ export interface BrowserContext { * Routing provides the capability to modify network requests that are made by any page in the browser context. Once route * is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted. * + * > NOTE: [page.route(url, handler)](https://playwright.dev/docs/api/class-page#page-route) will not intercept requests + * intercepted by Service Worker. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend + * disabling Service Workers when using request interception. Via `await context.addInitScript(() => delete + * window.navigator.serviceWorker);` + * * An example of a naive handler that aborts all image requests: * * ```js