fix(emulate media): document "no-preference" as deprecated (#32881)
Closes https://github.com/microsoft/playwright/issues/32862. `prefers-color-scheme: no-preference` was removed from browsers. This PR marks it as deprecated in our docs and removes all mentions. --------- Signed-off-by: Simon Knott <info@simonknott.de> Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
This commit is contained in:
Родитель
80ff7c396a
Коммит
40670e6ffd
|
@ -1217,8 +1217,6 @@ await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
|
||||||
// → true
|
// → true
|
||||||
await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
|
await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
|
||||||
// → false
|
// → false
|
||||||
await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches);
|
|
||||||
// → false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
@ -1227,8 +1225,6 @@ page.evaluate("() => matchMedia('(prefers-color-scheme: dark)').matches");
|
||||||
// → true
|
// → true
|
||||||
page.evaluate("() => matchMedia('(prefers-color-scheme: light)').matches");
|
page.evaluate("() => matchMedia('(prefers-color-scheme: light)').matches");
|
||||||
// → false
|
// → false
|
||||||
page.evaluate("() => matchMedia('(prefers-color-scheme: no-preference)').matches");
|
|
||||||
// → false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```python async
|
```python async
|
||||||
|
@ -1237,8 +1233,6 @@ await page.evaluate("matchMedia('(prefers-color-scheme: dark)').matches")
|
||||||
# → True
|
# → True
|
||||||
await page.evaluate("matchMedia('(prefers-color-scheme: light)').matches")
|
await page.evaluate("matchMedia('(prefers-color-scheme: light)').matches")
|
||||||
# → False
|
# → False
|
||||||
await page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
|
|
||||||
# → False
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```python sync
|
```python sync
|
||||||
|
@ -1247,7 +1241,6 @@ page.evaluate("matchMedia('(prefers-color-scheme: dark)').matches")
|
||||||
# → True
|
# → True
|
||||||
page.evaluate("matchMedia('(prefers-color-scheme: light)').matches")
|
page.evaluate("matchMedia('(prefers-color-scheme: light)').matches")
|
||||||
# → False
|
# → False
|
||||||
page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
|
@ -1256,8 +1249,6 @@ await page.EvaluateAsync("matchMedia('(prefers-color-scheme: dark)').matches");
|
||||||
// → true
|
// → true
|
||||||
await page.EvaluateAsync("matchMedia('(prefers-color-scheme: light)').matches");
|
await page.EvaluateAsync("matchMedia('(prefers-color-scheme: light)').matches");
|
||||||
// → false
|
// → false
|
||||||
await page.EvaluateAsync("matchMedia('(prefers-color-scheme: no-preference)').matches");
|
|
||||||
// → false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### option: Page.emulateMedia.media
|
### option: Page.emulateMedia.media
|
||||||
|
@ -1281,16 +1272,16 @@ Passing `'Null'` disables CSS media emulation.
|
||||||
* langs: js, java
|
* langs: js, java
|
||||||
- `colorScheme` <null|[ColorScheme]<"light"|"dark"|"no-preference">>
|
- `colorScheme` <null|[ColorScheme]<"light"|"dark"|"no-preference">>
|
||||||
|
|
||||||
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
|
Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) media feature, supported values are `'light'` and `'dark'`. Passing
|
||||||
`null` disables color scheme emulation.
|
`null` disables color scheme emulation. `'no-preference'` is deprecated.
|
||||||
|
|
||||||
### option: Page.emulateMedia.colorScheme
|
### option: Page.emulateMedia.colorScheme
|
||||||
* since: v1.9
|
* since: v1.9
|
||||||
* langs: csharp, python
|
* langs: csharp, python
|
||||||
- `colorScheme` <[ColorScheme]<"light"|"dark"|"no-preference"|"null">>
|
- `colorScheme` <[ColorScheme]<"light"|"dark"|"no-preference"|"null">>
|
||||||
|
|
||||||
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
|
Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) media feature, supported values are `'light'` and `'dark'`. Passing
|
||||||
`'Null'` disables color scheme emulation.
|
`'Null'` disables color scheme emulation. `'no-preference'` is deprecated.
|
||||||
|
|
||||||
### option: Page.emulateMedia.reducedMotion
|
### option: Page.emulateMedia.reducedMotion
|
||||||
* since: v1.12
|
* since: v1.12
|
||||||
|
|
|
@ -639,14 +639,14 @@ If no origin is specified, the username and password are sent to any servers upo
|
||||||
* langs: js, java
|
* langs: js, java
|
||||||
- `colorScheme` <null|[ColorScheme]<"light"|"dark"|"no-preference">>
|
- `colorScheme` <null|[ColorScheme]<"light"|"dark"|"no-preference">>
|
||||||
|
|
||||||
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
|
Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) media feature, supported values are `'light'` and `'dark'`. See
|
||||||
[`method: Page.emulateMedia`] for more details. Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
[`method: Page.emulateMedia`] for more details. Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
||||||
|
|
||||||
## context-option-colorscheme-csharp-python
|
## context-option-colorscheme-csharp-python
|
||||||
* langs: csharp, python
|
* langs: csharp, python
|
||||||
- `colorScheme` <[ColorScheme]<"light"|"dark"|"no-preference"|"null">>
|
- `colorScheme` <[ColorScheme]<"light"|"dark"|"no-preference"|"null">>
|
||||||
|
|
||||||
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
|
Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) media feature, supported values are `'light'` and `'dark'`. See
|
||||||
[`method: Page.emulateMedia`] for more details. Passing `'null'` resets emulation to system defaults. Defaults to `'light'`.
|
[`method: Page.emulateMedia`] for more details. Passing `'null'` resets emulation to system defaults. Defaults to `'light'`.
|
||||||
|
|
||||||
## context-option-reducedMotion
|
## context-option-reducedMotion
|
||||||
|
|
|
@ -558,7 +558,7 @@ await context.SetGeolocationAsync(new Geolocation() { Longitude = 48.858455, Lat
|
||||||
**Note** you can only change geolocation for all pages in the context.
|
**Note** you can only change geolocation for all pages in the context.
|
||||||
## Color Scheme and Media
|
## Color Scheme and Media
|
||||||
|
|
||||||
Emulate the users `"colorScheme"`. Supported values are 'light', 'dark', 'no-preference'. You can also emulate the media type with [`method: Page.emulateMedia`].
|
Emulate the users `"colorScheme"`. Supported values are 'light' and 'dark'. You can also emulate the media type with [`method: Page.emulateMedia`].
|
||||||
|
|
||||||
```js title="playwright.config.ts"
|
```js title="playwright.config.ts"
|
||||||
import { defineConfig } from '@playwright/test';
|
import { defineConfig } from '@playwright/test';
|
||||||
|
|
|
@ -64,7 +64,7 @@ export default defineConfig({
|
||||||
|
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
| :- | :- |
|
| :- | :- |
|
||||||
| [`property: TestOptions.colorScheme`] | [Emulates](./emulation.md#color-scheme-and-media) `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'` |
|
| [`property: TestOptions.colorScheme`] | [Emulates](./emulation.md#color-scheme-and-media) `'prefers-colors-scheme'` media feature, supported values are `'light'` and `'dark'` |
|
||||||
| [`property: TestOptions.geolocation`] | Context [geolocation](./emulation.md#geolocation). |
|
| [`property: TestOptions.geolocation`] | Context [geolocation](./emulation.md#geolocation). |
|
||||||
| [`property: TestOptions.locale`] | [Emulates](./emulation.md#locale--timezone) the user locale, for example `en-GB`, `de-DE`, etc. |
|
| [`property: TestOptions.locale`] | [Emulates](./emulation.md#locale--timezone) the user locale, for example `en-GB`, `de-DE`, etc. |
|
||||||
| [`property: TestOptions.permissions`] | A list of [permissions](./emulation.md#permissions) to grant to all pages in the context. |
|
| [`property: TestOptions.permissions`] | A list of [permissions](./emulation.md#permissions) to grant to all pages in the context. |
|
||||||
|
|
|
@ -2553,16 +2553,15 @@ export interface Page {
|
||||||
* // → true
|
* // → true
|
||||||
* await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
|
* await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
|
||||||
* // → false
|
* // → false
|
||||||
* await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches);
|
|
||||||
* // → false
|
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
emulateMedia(options?: {
|
emulateMedia(options?: {
|
||||||
/**
|
/**
|
||||||
* Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`.
|
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
|
||||||
* Passing `null` disables color scheme emulation.
|
* media feature, supported values are `'light'` and `'dark'`. Passing `null` disables color scheme emulation.
|
||||||
|
* `'no-preference'` is deprecated.
|
||||||
*/
|
*/
|
||||||
colorScheme?: null|"light"|"dark"|"no-preference";
|
colorScheme?: null|"light"|"dark"|"no-preference";
|
||||||
|
|
||||||
|
@ -9761,7 +9760,8 @@ export interface Browser {
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
|
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
|
||||||
|
* media feature, supported values are `'light'` and `'dark'`. See
|
||||||
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
||||||
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
||||||
*/
|
*/
|
||||||
|
@ -14726,7 +14726,8 @@ export interface BrowserType<Unused = {}> {
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
|
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
|
||||||
|
* media feature, supported values are `'light'` and `'dark'`. See
|
||||||
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
||||||
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
||||||
*/
|
*/
|
||||||
|
@ -16522,7 +16523,8 @@ export interface AndroidDevice {
|
||||||
bypassCSP?: boolean;
|
bypassCSP?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
|
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
|
||||||
|
* media feature, supported values are `'light'` and `'dark'`. See
|
||||||
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
||||||
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
||||||
*/
|
*/
|
||||||
|
@ -18998,7 +19000,8 @@ export interface Electron {
|
||||||
bypassCSP?: boolean;
|
bypassCSP?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
|
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
|
||||||
|
* media feature, supported values are `'light'` and `'dark'`. See
|
||||||
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
||||||
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
||||||
*/
|
*/
|
||||||
|
@ -21820,7 +21823,8 @@ export interface BrowserContextOptions {
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
|
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
|
||||||
|
* media feature, supported values are `'light'` and `'dark'`. See
|
||||||
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
||||||
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5225,7 +5225,8 @@ export interface PlaywrightTestOptions {
|
||||||
*/
|
*/
|
||||||
bypassCSP: boolean;
|
bypassCSP: boolean;
|
||||||
/**
|
/**
|
||||||
* Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
|
* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme)
|
||||||
|
* media feature, supported values are `'light'` and `'dark'`. See
|
||||||
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) for more details.
|
||||||
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
* Passing `null` resets emulation to system defaults. Defaults to `'light'`.
|
||||||
*
|
*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче