docs: hint that popup main request is accessible through BrowserContext (#30249)
Fixes #30229.
This commit is contained in:
parent
18b51308ff
commit
88f2717e87
|
|
@ -218,7 +218,7 @@ also fire for popup pages. See also [`event: Page.popup`] to receive events abou
|
||||||
|
|
||||||
The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
|
popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
|
||||||
done and its response has started loading in the popup.
|
done and its response has started loading in the popup. If you would like to route/listen to this network request, use [`method: BrowserContext.route`] and [`event: BrowserContext.request`] respectively instead of similar methods on the [Page].
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const newPagePromise = context.waitForEvent('page');
|
const newPagePromise = context.waitForEvent('page');
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,7 @@ Emitted when the page opens a new tab or window. This event is emitted in additi
|
||||||
|
|
||||||
The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
|
popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
|
||||||
done and its response has started loading in the popup.
|
done and its response has started loading in the popup. If you would like to route/listen to this network request, use [`method: BrowserContext.route`] and [`event: BrowserContext.request`] respectively instead of similar methods on the [Page].
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Start waiting for popup before clicking. Note no await.
|
// Start waiting for popup before clicking. Note no await.
|
||||||
|
|
@ -3411,6 +3411,10 @@ The handler will only be called for the first url if the response is a redirect.
|
||||||
[`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 by setting [`option: Browser.newContext.serviceWorkers`] to `'block'`.
|
[`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 by setting [`option: Browser.newContext.serviceWorkers`] to `'block'`.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
:::note
|
||||||
|
[`method: Page.route`] will not intercept the first request of a popup page. Use [`method: BrowserContext.route`] instead.
|
||||||
|
:::
|
||||||
|
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
An example of a naive handler that aborts all image requests:
|
An example of a naive handler that aborts all image requests:
|
||||||
|
|
|
||||||
61
packages/playwright-core/types/types.d.ts
vendored
61
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -1031,7 +1031,12 @@ export interface Page {
|
||||||
*
|
*
|
||||||
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
||||||
* "http://example.com" is done and its response has started loading in the popup.
|
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen
|
||||||
|
* to this network request, use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* and
|
||||||
|
* [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)
|
||||||
|
* respectively instead of similar methods on the {@link Page}.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* // Start waiting for popup before clicking. Note no await.
|
* // Start waiting for popup before clicking. Note no await.
|
||||||
|
|
@ -1326,7 +1331,12 @@ export interface Page {
|
||||||
*
|
*
|
||||||
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
||||||
* "http://example.com" is done and its response has started loading in the popup.
|
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen
|
||||||
|
* to this network request, use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* and
|
||||||
|
* [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)
|
||||||
|
* respectively instead of similar methods on the {@link Page}.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* // Start waiting for popup before clicking. Note no await.
|
* // Start waiting for popup before clicking. Note no await.
|
||||||
|
|
@ -1716,7 +1726,12 @@ export interface Page {
|
||||||
*
|
*
|
||||||
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
||||||
* "http://example.com" is done and its response has started loading in the popup.
|
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen
|
||||||
|
* to this network request, use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* and
|
||||||
|
* [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)
|
||||||
|
* respectively instead of similar methods on the {@link Page}.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* // Start waiting for popup before clicking. Note no await.
|
* // Start waiting for popup before clicking. Note no await.
|
||||||
|
|
@ -3658,6 +3673,11 @@ export interface Page {
|
||||||
* issue. We recommend disabling Service Workers when using request interception by setting
|
* issue. We recommend disabling Service Workers when using request interception by setting
|
||||||
* `Browser.newContext.serviceWorkers` to `'block'`.
|
* `Browser.newContext.serviceWorkers` to `'block'`.
|
||||||
*
|
*
|
||||||
|
* **NOTE** [page.route(url, handler[, options])](https://playwright.dev/docs/api/class-page#page-route) will not
|
||||||
|
* intercept the first request of a popup page. Use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* instead.
|
||||||
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
*
|
*
|
||||||
* An example of a naive handler that aborts all image requests:
|
* An example of a naive handler that aborts all image requests:
|
||||||
|
|
@ -4504,7 +4524,12 @@ export interface Page {
|
||||||
*
|
*
|
||||||
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
||||||
* "http://example.com" is done and its response has started loading in the popup.
|
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen
|
||||||
|
* to this network request, use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* and
|
||||||
|
* [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)
|
||||||
|
* respectively instead of similar methods on the {@link Page}.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* // Start waiting for popup before clicking. Note no await.
|
* // Start waiting for popup before clicking. Note no await.
|
||||||
|
|
@ -7745,7 +7770,12 @@ export interface BrowserContext {
|
||||||
*
|
*
|
||||||
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
||||||
* "http://example.com" is done and its response has started loading in the popup.
|
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen
|
||||||
|
* to this network request, use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* and
|
||||||
|
* [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)
|
||||||
|
* respectively instead of similar methods on the {@link Page}.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* const newPagePromise = context.waitForEvent('page');
|
* const newPagePromise = context.waitForEvent('page');
|
||||||
|
|
@ -7936,7 +7966,12 @@ export interface BrowserContext {
|
||||||
*
|
*
|
||||||
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
||||||
* "http://example.com" is done and its response has started loading in the popup.
|
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen
|
||||||
|
* to this network request, use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* and
|
||||||
|
* [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)
|
||||||
|
* respectively instead of similar methods on the {@link Page}.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* const newPagePromise = context.waitForEvent('page');
|
* const newPagePromise = context.waitForEvent('page');
|
||||||
|
|
@ -8182,7 +8217,12 @@ export interface BrowserContext {
|
||||||
*
|
*
|
||||||
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
||||||
* "http://example.com" is done and its response has started loading in the popup.
|
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen
|
||||||
|
* to this network request, use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* and
|
||||||
|
* [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)
|
||||||
|
* respectively instead of similar methods on the {@link Page}.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* const newPagePromise = context.waitForEvent('page');
|
* const newPagePromise = context.waitForEvent('page');
|
||||||
|
|
@ -8827,7 +8867,12 @@ export interface BrowserContext {
|
||||||
*
|
*
|
||||||
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
* The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
|
||||||
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
* popup with `window.open('http://example.com')`, this event will fire when the network request to
|
||||||
* "http://example.com" is done and its response has started loading in the popup.
|
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen
|
||||||
|
* to this network request, use
|
||||||
|
* [browserContext.route(url, handler[, options])](https://playwright.dev/docs/api/class-browsercontext#browser-context-route)
|
||||||
|
* and
|
||||||
|
* [browserContext.on('request')](https://playwright.dev/docs/api/class-browsercontext#browser-context-event-request)
|
||||||
|
* respectively instead of similar methods on the {@link Page}.
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* const newPagePromise = context.waitForEvent('page');
|
* const newPagePromise = context.waitForEvent('page');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue