Skip to content

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

Closed

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 runner — screen 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.

Metadata

Metadata

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