-
Notifications
You must be signed in to change notification settings - Fork 5k
fix: change default color-scheme to no-preference #28824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Test results for "tests 1"2 flaky21259 passed, 578 skipped Merge workflow run. |
|
The reason it's set to 'light' (see the docs) is that we want to have consistent defaults across platforms and avoid test failures due to the host system changes. If you want the color scheme not to be affected, you can explicitly set the option to |
|
I understand that it may be a by-design behavior, but it occurs in the first connect step and will turn all existing dark pages to light, additionally it cannot pass the const browser = await chromium.connectOverCDP('http://127.0.0.1:62374/', { /* connectOptions */ });the workaround i'm using, but it will cause a screen flash: await Promise.all(
browser
.contexts()
.flatMap((context) => context.pages().map((page) => page.emulateMedia({ colorScheme: 'no-preference' })))
); |
The PR fixes a bug by breaking another (way more common) behavior which we cannot afford. Also, this fixes only one option of a few, there are others like |
|
thanks for your detailed reply! ❤️ |
|
BTW, can we achieve it by passing playwright/packages/playwright-core/src/server/chromium/chromium.ts Lines 100 to 106 in 36c4c24
for example: chromium.connectOverCDP('http://127.0.0.1:62374/', {
persistent: { colorScheme: 'no-override', reducedMotion: 'no-override', /* ... */ }
});this doesn't change the default behavior |
When connecting to an existing endpoint, Playwright will enforce the page to use a
lightcolor scheme.playwright/packages/playwright-core/src/server/chromium/crPage.ts
Lines 1080 to 1093 in 76ace0f
because the default colorScheme is
lightrather thanno-preference:playwright/packages/playwright-core/src/server/page.ts
Lines 444 to 452 in 76ace0f
test code: