Skip to content

Commit

Permalink
test: add test reduced motion reset (#31364)
Browse files Browse the repository at this point in the history
References #31328
  • Loading branch information
aslushnikov authored Jun 18, 2024
1 parent e1e6c28 commit acf1b1f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/page/page-emulate-media.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,30 @@ it('should emulate reduced motion', async ({ page }) => {
await page.emulateMedia({ reducedMotion: null });
});

it('should keep reduced motion and color emulation after reload', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/31328' });
it.fixme(browserName === 'firefox');

// Pre-conditions
expect(await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches)).toEqual(false);
expect(await page.evaluate(() => matchMedia('(forced-colors: active)').matches)).toBe(false);

// Emulation
await page.emulateMedia({ forcedColors: 'active', reducedMotion: 'reduce' });
expect(await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches)).toEqual(true);
expect(await page.evaluate(() => matchMedia('(forced-colors: active)').matches)).toBe(true);

// Force CanonicalBrowsingContext replacement in Firefox.
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
res.end();
});
await page.goto(server.EMPTY_PAGE);

expect(await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches)).toEqual(true);
expect(await page.evaluate(() => matchMedia('(forced-colors: active)').matches)).toBe(true);
});

it('should emulate forcedColors ', async ({ page, browserName }) => {
expect(await page.evaluate(() => matchMedia('(forced-colors: none)').matches)).toBe(true);
await page.emulateMedia({ forcedColors: 'none' });
Expand Down

0 comments on commit acf1b1f

Please sign in to comment.