docs: use "argument: <type>" notation for events (#5626)

This commit is contained in:
Dmitry Gozman 2021-02-25 22:22:47 -08:00 committed by GitHub
parent cb0a890a09
commit 96e099aca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 44 additions and 42 deletions

View file

@ -4,7 +4,7 @@
[AndroidDevice] represents a connected device, either real hardware or emulated. Devices can be obtained using [`method: Android.devices`]. [AndroidDevice] represents a connected device, either real hardware or emulated. Devices can be obtained using [`method: Android.devices`].
## event: AndroidDevice.webView ## event: AndroidDevice.webView
- type: <[AndroidWebView]> - argument: <[AndroidWebView]>
Emitted when a new WebView instance is detected. Emitted when a new WebView instance is detected.

View file

@ -8,7 +8,7 @@
Emitted when the socket is closed. Emitted when the socket is closed.
## event: AndroidSocket.data ## event: AndroidSocket.data
- type: <[Buffer]> - argument: <[Buffer]>
Emitted when data is available to read from the socket. Emitted when data is available to read from the socket.

View file

@ -62,7 +62,7 @@ with sync_playwright() as playwright:
``` ```
## event: Browser.disconnected ## event: Browser.disconnected
- type: <[Browser]> - argument: <[Browser]>
Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following: Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
* Browser application is closed or crashed. * Browser application is closed or crashed.

View file

@ -50,7 +50,7 @@ context.close()
``` ```
## event: BrowserContext.close ## event: BrowserContext.close
- type: <[BrowserContext]> - argument: <[BrowserContext]>
Emitted when Browser context gets closed. This might happen because of one of the following: Emitted when Browser context gets closed. This might happen because of one of the following:
* Browser context is closed. * Browser context is closed.
@ -58,7 +58,7 @@ Emitted when Browser context gets closed. This might happen because of one of th
* The [`method: Browser.close`] method was called. * The [`method: Browser.close`] method was called.
## event: BrowserContext.page ## event: BrowserContext.page
- type: <[Page]> - argument: <[Page]>
The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will
also fire for popup pages. See also [`event: Page.popup`] to receive events about popups relevant to a specific page. also fire for popup pages. See also [`event: Page.popup`] to receive events about popups relevant to a specific page.

View file

@ -17,7 +17,7 @@ background_page = context.wait_for_event("backgroundpage")
``` ```
## event: ChromiumBrowserContext.backgroundPage ## event: ChromiumBrowserContext.backgroundPage
- type: <[Page]> - argument: <[Page]>
Emitted when new background page is created in the context. Emitted when new background page is created in the context.
@ -26,7 +26,7 @@ Only works with persistent context.
::: :::
## event: ChromiumBrowserContext.serviceWorker ## event: ChromiumBrowserContext.serviceWorker
- type: <[Worker]> - argument: <[Worker]>
Emitted when new service worker is created in the context. Emitted when new service worker is created in the context.

View file

@ -38,7 +38,7 @@ const { _electron: electron } = require('playwright');
This event is issued when the application closes. This event is issued when the application closes.
## event: ElectronApplication.window ## event: ElectronApplication.window
- type: <[Page]> - argument: <[Page]>
This event is issued for every window that is created **and loaded** in Electron. It contains a [Page] that can This event is issued for every window that is created **and loaded** in Electron. It contains a [Page] that can
be used for Playwright automation. be used for Playwright automation.
@ -48,7 +48,7 @@ be used for Playwright automation.
Closes Electron application. Closes Electron application.
## method: ElectronApplication.context ## method: ElectronApplication.context
- type: <[BrowserContext]> - returns: <[BrowserContext]>
This method returns browser context that can be used for setting up context-wide routing, etc. This method returns browser context that can be used for setting up context-wide routing, etc.

View file

@ -120,12 +120,12 @@ page.remove_listener("request", log_request)
``` ```
## event: Page.close ## event: Page.close
- type: <[Page]> - argument: <[Page]>
Emitted when the page closes. Emitted when the page closes.
## event: Page.console ## event: Page.console
- type: <[ConsoleMessage]> - argument: <[ConsoleMessage]>
Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`. Also
emitted if the page throws an error or a warning. emitted if the page throws an error or a warning.
@ -169,7 +169,7 @@ page.evaluate("console.log('hello', 5, {foo: 'bar'})")
``` ```
## event: Page.crash ## event: Page.crash
- type: <[Page]> - argument: <[Page]>
Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes, Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes,
ongoing and subsequent operations will throw. ongoing and subsequent operations will throw.
@ -219,7 +219,7 @@ except Error as e:
``` ```
## event: Page.dialog ## event: Page.dialog
- type: <[Dialog]> - argument: <[Dialog]>
Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Listener **must** either [`method: Dialog.accept`] or [`method: Dialog.dismiss`] the dialog - otherwise the page will [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and actions like click will never finish. Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Listener **must** either [`method: Dialog.accept`] or [`method: Dialog.dismiss`] the dialog - otherwise the page will [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and actions like click will never finish.
@ -228,13 +228,13 @@ When no [`event: Page.dialog`] listeners are present, all dialogs are automatica
::: :::
## event: Page.DOMContentLoaded ## event: Page.DOMContentLoaded
- type: <[Page]> - argument: <[Page]>
Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded)
event is dispatched. event is dispatched.
## event: Page.download ## event: Page.download
- type: <[Download]> - argument: <[Download]>
Emitted when attachment download started. User can access basic file operations on downloaded content via the passed Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
[Download] instance. [Download] instance.
@ -246,7 +246,7 @@ not performed and user has no access to the downloaded files.
::: :::
## event: Page.fileChooser ## event: Page.fileChooser
- type: <[FileChooser]> - argument: <[FileChooser]>
Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can Emitted when a file chooser is supposed to appear, such as after clicking the `<input type=file>`. Playwright can
respond to it via setting the input files using [`method: FileChooser.setFiles`] that can be uploaded after that. respond to it via setting the input files using [`method: FileChooser.setFiles`] that can be uploaded after that.
@ -268,36 +268,36 @@ page.on("filechooser", lambda file_chooser: file_chooser.set_files("/tmp/myfile.
``` ```
## event: Page.frameAttached ## event: Page.frameAttached
- type: <[Frame]> - argument: <[Frame]>
Emitted when a frame is attached. Emitted when a frame is attached.
## event: Page.frameDetached ## event: Page.frameDetached
- type: <[Frame]> - argument: <[Frame]>
Emitted when a frame is detached. Emitted when a frame is detached.
## event: Page.frameNavigated ## event: Page.frameNavigated
- type: <[Frame]> - argument: <[Frame]>
Emitted when a frame is navigated to a new url. Emitted when a frame is navigated to a new url.
## event: Page.load ## event: Page.load
- type: <[Page]> - argument: <[Page]>
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched. Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.
## event: Page.pageError ## event: Page.pageError
- type: <[Error]> - argument: <[Error]>
Emitted when an uncaught exception happens within the page. Emitted when an uncaught exception happens within the page.
## event: Page.pageError ## event: Page.pageError
* langs: csharp, java * langs: csharp, java
- type: <[string]> - argument: <[string]>
## event: Page.popup ## event: Page.popup
- type: <[Page]> - argument: <[Page]>
Emitted when the page opens a new tab or window. This event is emitted in addition to the Emitted when the page opens a new tab or window. This event is emitted in addition to the
[`event: BrowserContext.page`], but only for popups relevant to this page. [`event: BrowserContext.page`], but only for popups relevant to this page.
@ -341,13 +341,13 @@ cases).
::: :::
## event: Page.request ## event: Page.request
- type: <[Request]> - argument: <[Request]>
Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see Emitted when a page issues a request. The [request] object is read-only. In order to intercept and mutate requests, see
[`method: Page.route`] or [`method: BrowserContext.route`]. [`method: Page.route`] or [`method: BrowserContext.route`].
## event: Page.requestFailed ## event: Page.requestFailed
- type: <[Request]> - argument: <[Request]>
Emitted when a request fails, for example by timing out. Emitted when a request fails, for example by timing out.
@ -357,24 +357,24 @@ with [`event: Page.requestFinished`] event and not with [`event: Page.requestFai
::: :::
## event: Page.requestFinished ## event: Page.requestFinished
- type: <[Request]> - argument: <[Request]>
Emitted when a request finishes successfully after downloading the response body. For a successful response, the Emitted when a request finishes successfully after downloading the response body. For a successful response, the
sequence of events is `request`, `response` and `requestfinished`. sequence of events is `request`, `response` and `requestfinished`.
## event: Page.response ## event: Page.response
- type: <[Response]> - argument: <[Response]>
Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events
is `request`, `response` and `requestfinished`. is `request`, `response` and `requestfinished`.
## event: Page.webSocket ## event: Page.webSocket
- type: <[WebSocket]> - argument: <[WebSocket]>
Emitted when [WebSocket] request is sent. Emitted when [WebSocket] request is sent.
## event: Page.worker ## event: Page.worker
- type: <[Worker]> - argument: <[Worker]>
Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the
page. page.

View file

@ -3,32 +3,32 @@
The [WebSocket] class represents websocket connections in the page. The [WebSocket] class represents websocket connections in the page.
## event: WebSocket.close ## event: WebSocket.close
- type: <[WebSocket]> - argument: <[WebSocket]>
Fired when the websocket closes. Fired when the websocket closes.
## event: WebSocket.frameReceived ## event: WebSocket.frameReceived
- type: <[Object]> - argument: <[Object]>
- `payload` <[string]|[Buffer]> frame payload - `payload` <[string]|[Buffer]> frame payload
Fired when the websocket recieves a frame. Fired when the websocket recieves a frame.
## event: WebSocket.frameReceived ## event: WebSocket.frameReceived
* langs: csharp, java * langs: csharp, java
- type: <[WebSocketFrame]> - argument: <[WebSocketFrame]>
## event: WebSocket.frameSent ## event: WebSocket.frameSent
- type: <[Object]> - argument: <[Object]>
- `payload` <[string]|[Buffer]> frame payload - `payload` <[string]|[Buffer]> frame payload
Fired when the websocket sends a frame. Fired when the websocket sends a frame.
## event: WebSocket.frameSent ## event: WebSocket.frameSent
* langs: csharp, java * langs: csharp, java
- type: <[WebSocketFrame]> - argument: <[WebSocketFrame]>
## event: WebSocket.socketError ## event: WebSocket.socketError
- type: <[String]> - argument: <[String]>
Fired when the websocket has an error. Fired when the websocket has an error.

View file

@ -38,7 +38,7 @@ for worker in page.workers:
``` ```
## event: Worker.close ## event: Worker.close
- type: <[Worker]> - argument: <[Worker]>
Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is terminated. Emitted when this dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is terminated.

2
types/types.d.ts vendored
View file

@ -5158,7 +5158,7 @@ export interface Worker {
* [worker.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-worker#workerevaluatepagefunction-arg) * [worker.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-worker#workerevaluatepagefunction-arg)
* returns a non-[Serializable] value, then * returns a non-[Serializable] value, then
* [worker.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-worker#workerevaluatepagefunction-arg) * [worker.evaluate(pageFunction[, arg])](https://playwright.dev/docs/api/class-worker#workerevaluatepagefunction-arg)
* returns `undefined`. Playwright also supports transferring some additional values that are not serializable by `JSON`: * returns `undefined`. Playwright also supports transferring some additional values that are not serializable by `JSON`:
* `-0`, `NaN`, `Infinity`, `-Infinity`. * `-0`, `NaN`, `Infinity`, `-Infinity`.
* @param pageFunction Function to be evaluated in the worker context. * @param pageFunction Function to be evaluated in the worker context.
* @param arg Optional argument to pass to `pageFunction`. * @param arg Optional argument to pass to `pageFunction`.

View file

@ -194,6 +194,8 @@ function parseVariable(line) {
match = line.match(/^(returns): (.*)/); match = line.match(/^(returns): (.*)/);
if (!match) if (!match)
match = line.match(/^(type): (.*)/); match = line.match(/^(type): (.*)/);
if (!match)
match = line.match(/^(argument): (.*)/);
if (!match) if (!match)
throw new Error('Invalid argument: ' + line); throw new Error('Invalid argument: ' + line);
const name = match[1]; const name = match[1];