Open satelllte opened 5 days ago
What's interesting here is that Safari is the only browser that still supports no-preference
: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme#browser_compatibility
Alright, we've looked into it more. no-preference
was part of an earlier version of the color schemes CSS spec, but was never implemented broadly. Safari initially added support, but then removed it. I've opened an issue with MDN to update it there.
I'll add a note about this to the Playwright docs.
This also means that what you're seeing is the intended behaviour: Browsers don't know what "no-preference" is, so they fall back to the system setting.
Thank you! That were interesting findings.
Version
1.47.2
Steps to reproduce
Here's a minimal reproduction test:
Here's real-life example: satelllte/space • tests-e2e/theme.spec.ts
Expected behavior
I believe it's expected to have a consistent color preference in any browser, even if
no-preference
color scheme is set explicitly for the test.Actual behavior
If dark theme preference is set in macOS, but the test sets
no-preference
color scheme, it still falls back to the system and chooses the dark one instead of light.Additional context
Here's a short log example when you run the test code snippet from above:
Environment