microsoft / microsoft/playwright

[Bug]: test runner silently drops the 'screen' key of device descriptors

Open
#42,679 0 comments 0 reactions 1 assignee View on GitHub

@pavelfeldman is already working on this.

Since Sep 14, 2026.

Dominant language
TypeScript
Stars
96.3k
Forks
6.5k
Avg merge
1d 6h
Merged PRs (30d)
180

Description

Version

1.63.0 (code matches current main)

Steps to reproduce

Same device descriptor, two paths, Chromium both times:

Library mode — works:

const context = await browser.newContext({ ...devices['iPhone 13'] });
// window.screen -> { width: 390, height: 844 }  ✅ matches descriptor

Test runnerscreen is dropped:

test.use({ ...devices['iPhone 13'] });
test('screen', async ({ page }) => {
  // window.screen -> { width: 390, height: 664 }  ❌ collapses to viewport
});

Control: test.use({ contextOptions: { screen: { width: 390, height: 844 } } }) produces the correct window.screen — the machinery under the runner supports it; only the option plumbing is missing.

Expected behavior

test.use({ ...devices[...] }) forwards all descriptor keys. Six of the seven are registered as TestOptions fixtures in packages/playwright/src/index.ts; screen is the only one with no fixture, no entry in the _combinedContextOptions destructure, and no if-block — and unknown use keys are silently ignored, so nothing warns.

Actual behavior

window.screen (and device-width/height media queries) reflect the viewport instead of the descriptor's screen in test-runner mode.

Additional context

Three signs this is drift rather than design: docs/src/emulation.md promises the runner simulates "screenSize"; the TestOptions.reuseContext docs (v1.62) explicitly list screen among context options that may differ between tests — referencing a test option that doesn't exist; and paramsThatAllowContextReuse in browserContext.ts already includes 'screen'. screen emulation landed in #5967 (v1.10) and the TestOptions list never picked it up.

I have a fix drafted and verified (fixture + destructure + if-chain in index.ts, the overrides-test.d.ts type, docs entry, and a runInlineTest-style regression test — red without the src change, green with it; full playwright.config.spec.ts suite passes). Per the contribution policy I'm filing this first — happy to submit the PR if this is approved for community contribution. Prepared with AI assistance (Claude); the repros and red/green runs were verified by execution.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.