You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(types): support objects with typed keys and values (microsoft#1752)
There are a few places in the API where we use objects as maps. This patch adds them to docs and the types.
For `env`, we accept booleans and numbers as well because they are often used for their string values.
Copy file name to clipboardExpand all lines: docs/api.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -211,7 +211,7 @@ Indicates that the browser is connected.
211
211
-`accuracy` <[number]> Non-negative accuracy value. Defaults to `0`.
212
212
-`locale` <[string]> Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules.
213
213
-`permissions` <[Array]<[string]>> A list of permissions to grant to all pages in this context. See [browserContext.grantPermissions](#browsercontextgrantpermissionspermissions-options) for more details.
214
-
-`extraHTTPHeaders` <[Object]> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
214
+
-`extraHTTPHeaders` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
215
215
-`offline` <[boolean]> Whether to emulate network being offline. Defaults to `false`.
216
216
-`httpCredentials` <[Object]> Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
217
217
-`username` <[string]>
@@ -253,7 +253,7 @@ Creates a new browser context. It won't share cookies/cache with other browser c
253
253
-`accuracy` <[number]> Non-negative accuracy value. Defaults to `0`.
254
254
-`locale` <[string]> Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules.
255
255
-`permissions` <[Array]<[string]>> A list of permissions to grant to all pages in this context. See [browserContext.grantPermissions](#browsercontextgrantpermissionspermissions-options) for more details.
256
-
-`extraHTTPHeaders` <[Object]> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
256
+
-`extraHTTPHeaders` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
257
257
-`offline` <[boolean]> Whether to emulate network being offline. Defaults to `false`.
258
258
-`httpCredentials` <[Object]> Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
259
259
-`username` <[string]>
@@ -544,7 +544,7 @@ This setting will change the default maximum time for all the methods accepting
544
544
> **NOTE**[`page.setDefaultNavigationTimeout`](#pagesetdefaultnavigationtimeouttimeout), [`page.setDefaultTimeout`](#pagesetdefaulttimeouttimeout) and [`browserContext.setDefaultNavigationTimeout`](#browsercontextsetdefaultnavigationtimeouttimeout) take priority over [`browserContext.setDefaultTimeout`](#browsercontextsetdefaulttimeouttimeout).
545
545
546
546
#### browserContext.setExtraHTTPHeaders(headers)
547
-
-`headers` <[Object]> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
547
+
-`headers` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
548
548
- returns: <[Promise]>
549
549
550
550
The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged with page-specific extra HTTP headers set with [page.setExtraHTTPHeaders()](#pagesetextrahttpheadersheaders). If page overrides a particular header, page-specific header value will be used instead of the browser context header value.
@@ -1552,7 +1552,7 @@ This setting will change the default maximum time for all the methods accepting
1552
1552
> **NOTE**[`page.setDefaultNavigationTimeout`](#pagesetdefaultnavigationtimeouttimeout) takes priority over [`page.setDefaultTimeout`](#pagesetdefaulttimeouttimeout).
1553
1553
1554
1554
#### page.setExtraHTTPHeaders(headers)
1555
-
-`headers` <[Object]> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
1555
+
-`headers` <[Object]<[string], [string]>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
1556
1556
- returns: <[Promise]>
1557
1557
1558
1558
The extra HTTP headers will be sent with every request the page initiates.
-`path` <[string]> Optional file path to respond with. The content type will be inferred from file extension. If `path` is a relative path, then it is resolved relative to [current working directory](https://nodejs.org/api/process.html#process_process_cwd).
@@ -3777,7 +3777,7 @@ This methods attaches Playwright to an existing browser instance.
3777
3777
-`handleSIGHUP` <[boolean]> Close the browser process on SIGHUP. Defaults to `true`.
3778
3778
-`logger` <[Logger]> Logger sink for Playwright logging.
3779
3779
-`timeout` <[number]> Maximum time in milliseconds to wait for the browser instance to start. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
3780
-
-`env` <[Object]> Specify environment variables that will be visible to the browser. Defaults to `process.env`.
3780
+
-`env` <[Object]<[string], [string]|[number]|[boolean]>> Specify environment variables that will be visible to the browser. Defaults to `process.env`.
3781
3781
-`devtools` <[boolean]> **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the `headless` option will be set `false`.
3782
3782
-`slowMo` <[number]> Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
3783
3783
- returns: <[Promise]<[Browser]>> Promise which resolves to browser instance.
@@ -3810,7 +3810,7 @@ const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
3810
3810
-`handleSIGHUP` <[boolean]> Close the browser process on SIGHUP. Defaults to `true`.
3811
3811
-`logger` <[Logger]> Logger sink for Playwright logging.
3812
3812
-`timeout` <[number]> Maximum time in milliseconds to wait for the browser instance to start. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
3813
-
-`env` <[Object]> Specify environment variables that will be visible to the browser. Defaults to `process.env`.
3813
+
-`env` <[Object]<[string], [string]|[number]|[boolean]>> Specify environment variables that will be visible to the browser. Defaults to `process.env`.
3814
3814
-`devtools` <[boolean]> **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the `headless` option will be set `false`.
3815
3815
-`slowMo` <[number]> Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0.
3816
3816
- returns: <[Promise]<[BrowserContext]>> Promise which resolves to the browser app instance.
@@ -3829,7 +3829,7 @@ Launches browser instance that uses persistent storage located at `userDataDir`.
3829
3829
-`handleSIGHUP` <[boolean]> Close the browser process on SIGHUP. Defaults to `true`.
3830
3830
-`logger` <[Logger]> Logger sink for Playwright logging.
3831
3831
-`timeout` <[number]> Maximum time in milliseconds to wait for the browser instance to start. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
3832
-
-`env` <[Object]> Specify environment variables that will be visible to the browser. Defaults to `process.env`.
3832
+
-`env` <[Object]<[string], [string]|[number]|[boolean]>> Specify environment variables that will be visible to the browser. Defaults to `process.env`.
3833
3833
-`devtools` <[boolean]> **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is `true`, the `headless` option will be set `false`.
3834
3834
- returns: <[Promise]<[BrowserServer]>> Promise which resolves to the browser app instance.
0 commit comments