test(emulation): add failing test for setting dark theme in firefox (#3149)

This commit is contained in:
Joel Einbinder 2020-07-24 14:47:32 -07:00 committed by GitHub
parent 0a57c2b39e
commit 1455cae974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -323,6 +323,38 @@ describe('Page.emulateMedia colorScheme', function() {
expect(await frame.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches)).toBe(true);
await page.close();
});
it.fail(FFOX)('should change the actual colors in css', async({page}) => {
await page.setContent(`
<style>
@media (prefers-color-scheme: dark) {
div {
background: black;
color: white;
}
}
@media (prefers-color-scheme: light) {
div {
background: white;
color: black;
}
}
</style>
<div>Hello</div>
`);
function getBackgroundColor() {
return page.$eval('div', div => window.getComputedStyle(div).backgroundColor);
}
await page.emulateMedia({ colorScheme: "light" });
expect(await getBackgroundColor()).toBe('rgb(255, 255, 255)');
await page.emulateMedia({ colorScheme: "dark" });
expect(await getBackgroundColor()).toBe('rgb(0, 0, 0)');
await page.emulateMedia({ colorScheme: "light" });
expect(await getBackgroundColor()).toBe('rgb(255, 255, 255)');
})
});
describe('BrowserContext({timezoneId})', function() {