Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test(emulation): should update settings during navigation (#457)

Dmitry Gozman15b05e43bcfd
diff --git a/test/emulation.spec.js b/test/emulation.spec.js
index f2a8733903..2e10670ee5 100644
--- a/test/emulation.spec.js
+++ b/test/emulation.spec.js
@@ -168,6 +168,16 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROME
await page.emulateMedia({ colorScheme: 'bad' }).catch(e => error = e);
expect(error.message).toBe('Unsupported color scheme: bad');
});
+ it.skip(FFOX)('should work during navigation', async({page, server}) => {
+ await page.emulateMedia({ colorScheme: 'light' });
+ const navigated = page.goto(server.EMPTY_PAGE);
+ for (let i = 0; i < 9; i++) {
+ page.emulateMedia({ colorScheme: ['dark', 'light'][i & 1] });
+ await new Promise(f => setTimeout(f, 1));
+ }
+ await navigated;
+ expect(await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true);
+ });
});
describe.skip(FFOX || WEBKIT)('BrowserContext({timezoneId})', function() {