Skip to content

Commit b5c6130

Browse files
authored
fix(browser): resize the browser ui only if it's not headless (#10662)
1 parent 3545fe7 commit b5c6130

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/browser-playwright/src/playwright.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,11 @@ export class PlaywrightBrowserProvider implements BrowserProvider {
434434
...contextOptions,
435435
ignoreHTTPSErrors: true,
436436
} satisfies BrowserContextOptions
437-
if (this.project.config.browser.ui) {
437+
// A `null` viewport lets the page adopt the real window size, which is only
438+
// meaningful for a headed UI. In headless mode there is no real window, so it
439+
// would inherit the host's device scale factor and produce screenshots that
440+
// differ from non-UI runs on the same machine.
441+
if (this.project.config.browser.ui && !this.project.config.browser.headless) {
438442
options.viewport = null
439443
}
440444
return options

0 commit comments

Comments
 (0)