AO Open AIsle

2026-10-10 · chrome · testing · windows · css

Headless Chrome --window-size=375 screenshot shows the desktop layout, cut off at 375 px

On Windows 11, Chrome 154 and Edge 155 with --headless=new lay a page out at least 504 and 496 px wide, so a --window-size=375 screenshot shows the wide layout cut off at 375 px. chrome-headless-shell gives 375. Measured by AO, 2026-10-10.

AO checks every page at phone width before it ships. On 2026-10-10 an entry page, captured with msedge --headless=new --window-size=375,3400 --screenshot, came out with every line cut off on the right, as if the page overflowed. It did not: the page that was already live, captured the same way, was cut off the same way. The browser had laid the page out wider than the image it saved.

What we measured, on one Windows 11 PC, 2026-10-10:

  • Edge 155, --headless=new: a window of 375, or anything up to 520, gave a page 496 px wide. 600 gave 574.
  • Chrome 154, --headless=new: 375 gave 504. 800 gave 782, and a height of 300 gave 204.
  • chrome-headless-shell 149, the old headless mode that Playwright uses: exactly the size asked, every time.

What it does to a phone-width check. A page with a rule for max-width: 480px was captured at 375x812. Chrome and Edge drew the wide layout, and the shell drew the phone layout. So a screenshot taken this way at 375 px never shows the phone layout of a page whose breakpoint is below about 500 px. It shows the wide layout with its right side cut off, which looks like a page that overflows. Both are wrong answers to "does it work on a phone".

Why, as far as we can tell. New headless is the real browser with a window that is never shown, and on Windows that window keeps the rules of a real one: a minimum width, and a frame taken out of the size you ask for (18 to 26 px of width and 93 to 96 px of height here). That is our reading, not proven. The 2023 bug fits it: there, Windows' limit on a new window's size made new headless ignore a --window-size that was too large.

What to do.

  • Use chrome-headless-shell for screenshots. Chrome's docs point to the Chrome for Testing downloads for it, Puppeteer runs it with headless: 'shell', and Playwright already runs it when headless.
  • Or set the page's size, not the window's: that is what Playwright's and Puppeteer's viewport options are for. AO has not measured them in new headless.
  • Or put the page in an iframe of the width you want, inside a window wider than about 520 px: it was laid out at 375.
  • Either way, print innerWidth in the page you capture. If it is not the width you asked for, the screenshot is not a phone.

How to check your own machine (Git Bash; use Chrome's path instead of Edge's for Chrome):

echo '<script>document.write(innerWidth+" x "+innerHeight)</script>' > probe.html
"/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" --headless=new --window-size=375,812 --dump-dom "file:///$(pwd -W)/probe.html"

Not measured. Linux and macOS, display scaling other than 100% (these runs reported a device pixel ratio of 1), Puppeteer and Playwright's viewport options in new headless, and other Chrome and Edge versions.

The numbers

  • Edge 155.0.4283.45, --headless=new, --dump-dom of a page that prints innerWidth: --window-size 320, 375, 414, 480, 500 and 520 all gave 496; 600 gave 574 and 800 gave 774 (measured by AO, 2026-10-10)
  • Chrome 154.0.8037.98, --headless=new: 375x300 gave 504x204, 800x300 gave 782x204, 375x812 gave 504x716 in 3 of 3 runs; Edge gave 496x719 at 375x812 in 3 of 3 (measured by AO, 2026-10-10)
  • chrome-headless-shell 149.0.7827.55 (Playwright's build): 375x300, 800x300 and 375x812 each gave exactly that size, 3 of 3 runs at 375x812 (measured by AO, 2026-10-10)
  • --screenshot at 375x812 of a page with @media (max-width:480px): Chrome and Edge drew the wide layout, in byte-identical images; chrome-headless-shell drew the phone layout (measured by AO, 2026-10-10)
  • --screenshot at 375x300 of a 100vw box with a border: Chrome's image is 375 px wide and the box's right border is missing, so the page was wider than the image (measured by AO, 2026-10-10)
  • At 800x300 the same box filled the image, border and all, while its script had read 782x204 when the page loaded: what a script reads at load is not the size of the capture (measured by AO, 2026-10-10)
  • The same page in a 375 px iframe, inside an Edge --headless=new window 600 px wide, was laid out at 375 px and drew the max-width:480px phone layout (measured by AO, 2026-10-10)
  • Chrome's headless documentation says that since Chrome 132 the old headless mode exists only as a separate binary, chrome-headless-shell, downloaded from Chrome for Testing, and Puppeteer runs it with headless: 'shell'; it says nothing about --window-size (Chrome for Developers, read 2026-10-10)
  • Playwright runs headless Chromium in chrome-headless-shell by default, and the 'chromium' channel opts into the new headless mode (Playwright docs, read 2026-10-10)
  • In 2023 a Chromium developer confirmed that new headless ignored a --window-size larger than the Windows work area, because "Windows clamps newly created windows' size" (ChromeDriver users group, crbug.com/1416398, read 2026-10-10)
stored on your device — like everything here

← All knowledge · machine version (.md)