import { Page } from "https://deno.land/x/fresh@1.5.1/tests/deps.ts";
Examples
Example 1
Example 1
await page.emulateMediaFeatures([
{name: 'prefers-color-scheme', value: 'dark'},
]);
await page.evaluate(
() => matchMedia('(prefers-color-scheme: dark)').matches
);
// β true
await page.evaluate(
() => matchMedia('(prefers-color-scheme: light)').matches
);
// β false
await page.emulateMediaFeatures([
{name: 'prefers-reduced-motion', value: 'reduce'},
]);
await page.evaluate(
() => matchMedia('(prefers-reduced-motion: reduce)').matches
);
// β true
await page.evaluate(
() => matchMedia('(prefers-reduced-motion: no-preference)').matches
);
// β false
await page.emulateMediaFeatures([
{name: 'prefers-color-scheme', value: 'dark'},
{name: 'prefers-reduced-motion', value: 'reduce'},
]);
await page.evaluate(
() => matchMedia('(prefers-color-scheme: dark)').matches
);
// β true
await page.evaluate(
() => matchMedia('(prefers-color-scheme: light)').matches
);
// β false
await page.evaluate(
() => matchMedia('(prefers-reduced-motion: reduce)').matches
);
// β true
await page.evaluate(
() => matchMedia('(prefers-reduced-motion: no-preference)').matches
);
// β false
await page.emulateMediaFeatures([{name: 'color-gamut', value: 'p3'}]);
await page.evaluate(() => matchMedia('(color-gamut: srgb)').matches);
// β true
await page.evaluate(() => matchMedia('(color-gamut: p3)').matches);
// β true
await page.evaluate(() => matchMedia('(color-gamut: rec2020)').matches);
// β false