Skip to content
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

[Feature]: Add prefers-contrast support to page.emulateMedia . #34240

Open
maria-gourevitch opened this issue Jan 7, 2025 · 0 comments
Open
Assignees
Labels

Comments

@maria-gourevitch
Copy link

maria-gourevitch commented Jan 7, 2025

🚀 Feature Request

Add prefers-contrast support to page.emulateMedia .

Example

test('High contrast theme has no regressions', ({page}) => {
  page.emulateMedia({prefersContrast: 'more'});
  await page.goto('https://staging.mysite.com');
  await expect(page).toHaveScreenshot();
});

test('Low contrast theme has no regressions', ({page}) => {
  page.emulateMedia({prefersContrast: 'less'});
  await page.goto('https://staging.mysite.com');
  await expect(page).toHaveScreenshot();
});

Motivation

Supporting prefers-contrast in page.emulateMedia would enable automated checking for regressions in high- and low- contrast themes. This is distinct from the already-supported (thank you!!!) forced-colors emulation: forced-colors ignores author-chosen colours in favour of colours specified by the user, while prefers-contrast allows the author to supply different CSS in response to a user-specified preference for high or low contrast.

Emulating prefers-contrast is already possible in Chromium by using CDPSession, but not in Webkit. Since MacOS/iOS/iPadOS only provides the end user a way to specify a contrast preference but not a colour scheme, and Playwright does not provide a way to emulate prefers-contrast in Webkit, site authors currently have no way of checking for regressions for users with different contrast preferences on desktop Safari, iPhone, or iPad.

Regressions in this area are unlikely to be caught incidentally, so they must be tested using time-consuming manual steps or missed. Adding prefers-contrast emulation would allow Playwright to save site maintainers even more time and catch even more errors before they make it to production and impact end users.

@maria-gourevitch maria-gourevitch changed the title [Feature]: [Feature]: Add prefers-contrast support to page.emulateMedia . Jan 7, 2025
@Skn0tt Skn0tt self-assigned this Jan 9, 2025
@Skn0tt Skn0tt added the v1.50 label Jan 9, 2025
@dgozman dgozman added v1.51 and removed v1.50 labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants