docs: add note about Service Workers and route (#8401)

This commit is contained in:
Max Schmitt 2021-08-24 15:57:35 +02:00 committed by GitHub
parent 5814a4aab8
commit d52250f2c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -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

View File

@ -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

9
types/types.d.ts vendored
View File

@ -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