docs(api.md): improve emulateMediaFeatures section (#5807)
This commit is contained in:
parent
ec91ecaf0b
commit
53d6fabf80
36
docs/api.md
36
docs/api.md
@ -1337,32 +1337,32 @@ List of all available devices is available in the source code: [src/DeviceDescri
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'dark' }]);
|
await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'dark' }]);
|
||||||
await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches));
|
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));
|
await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches);
|
||||||
// → false
|
// → false
|
||||||
|
|
||||||
await page.emulateMediaFeatures([{ name: 'prefers-reduced-motion', value: 'reduce' }]);
|
await page.emulateMediaFeatures([{ name: 'prefers-reduced-motion', value: 'reduce' }]);
|
||||||
await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches));
|
await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches);
|
||||||
// → true
|
// → true
|
||||||
await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches));
|
await page.evaluate(() => matchMedia('(prefers-reduced-motion: no-preference)').matches);
|
||||||
// → false
|
// → false
|
||||||
|
|
||||||
await page.emulateMediaFeatures([
|
await page.emulateMediaFeatures([
|
||||||
{ name: 'prefers-color-scheme', value: 'dark' },
|
{ name: 'prefers-color-scheme', value: 'dark' },
|
||||||
{ name: 'prefers-reduced-motion', value: 'reduce' },
|
{ name: 'prefers-reduced-motion', value: 'reduce' },
|
||||||
]);
|
]);
|
||||||
await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches));
|
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));
|
await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches);
|
||||||
// → false
|
// → false
|
||||||
await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches));
|
await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches);
|
||||||
// → true
|
// → true
|
||||||
await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches));
|
await page.evaluate(() => matchMedia('(prefers-reduced-motion: no-preference)').matches);
|
||||||
// → false
|
// → false
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1371,22 +1371,22 @@ await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').ma
|
|||||||
- returns: <[Promise]>
|
- returns: <[Promise]>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
await page.evaluate(() => matchMedia('screen').matches));
|
await page.evaluate(() => matchMedia('screen').matches);
|
||||||
// → true
|
|
||||||
await page.evaluate(() => matchMedia('print').matches));
|
|
||||||
// → true
|
// → true
|
||||||
|
await page.evaluate(() => matchMedia('print').matches);
|
||||||
|
// → false
|
||||||
|
|
||||||
await page.emulateMediaType('print');
|
await page.emulateMediaType('print');
|
||||||
await page.evaluate(() => matchMedia('screen').matches));
|
await page.evaluate(() => matchMedia('screen').matches);
|
||||||
// → false
|
// → false
|
||||||
await page.evaluate(() => matchMedia('print').matches));
|
await page.evaluate(() => matchMedia('print').matches);
|
||||||
// → true
|
// → true
|
||||||
|
|
||||||
await page.emulateMediaType(null);
|
await page.emulateMediaType(null);
|
||||||
await page.evaluate(() => matchMedia('screen').matches));
|
await page.evaluate(() => matchMedia('screen').matches);
|
||||||
// → true
|
|
||||||
await page.evaluate(() => matchMedia('print').matches));
|
|
||||||
// → true
|
// → true
|
||||||
|
await page.evaluate(() => matchMedia('print').matches);
|
||||||
|
// → false
|
||||||
```
|
```
|
||||||
|
|
||||||
#### page.emulateTimezone(timezoneId)
|
#### page.emulateTimezone(timezoneId)
|
||||||
|
Loading…
Reference in New Issue
Block a user