Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: add test reduced motion reset (#31364)
Andrey Lushnikovacf1b1f88c69
diff --git a/tests/page/page-emulate-media.spec.ts b/tests/page/page-emulate-media.spec.tsindex 85caa1dc8f..d1ba297ae4 100644--- a/tests/page/page-emulate-media.spec.ts+++ b/tests/page/page-emulate-media.spec.ts@@ -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' });