Skip to content

[BUG] Chromium headless doesn't have a default prefers-color-scheme #1499

@mxschmitt

Description

@mxschmitt

Context:

  • Playwright Version: current tip of tree: c0c9b7f
  • Operating System: macOS and also reproducible on Linux

Code Snippet

Example on Try Playwright: https://try.playwright.tech/?s=6haon

const playwright = require("playwright");

(async () => {
  for (const browserType of ['chromium', 'webkit', 'firefox']) {
    const browser = await playwright[browserType].launch();
    const context = await browser.newContext();
    const page = await context.newPage();
    console.log(await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches));

    await browser.close();
  }
})();

Describe the bug

WebKit and Firefox have a default prefers-color-scheme but headless Chromium not.

The issue is also persistent in Puppeteer.

Expected

true
true
true

Actual

false
true
true

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions