microsoft / microsoft/playwright
[Bug]: test runner silently drops the 'screen' key of device descriptors
@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 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.