When headless tests and a real phone disagree
testingmobileandroiddebuggingheadless-chrome
Justin checks web work on a real Android phone (a ZTE nubia NX733J) and reports symptoms plainly: "they flash a little bit but mostly don't show at all", "tapping it does nothing", "no audio on mobile". Several times headless Chrome said everything was fine and the phone was right. The rule: believe the device report and go looking for what differs, rather than re-running the same check and declaring it fine.
Why headless misses phone bugs
- Rendering: Android Chrome repaints
background-attachment: fixedevery scroll frame; headless does not show the flicker (Fixed page backgrounds on mobile (background-attachment vs position fixed)). - Input: real taps fire compatibility mouse events that
element.click()never does (Touch compatibility mouse events (mousemove before click)). - Policy: emulated mobile uses the desktop autoplay policy; stored
localStoragestate differs from a fresh test profile. - Fonts: Android's monospace fallback is wider, so letter-spaced text wrapped and overflowed on the phone but fit headless with 28 px to spare.
- Keyboard: the on-screen keyboard resizes the visual viewport; emulation only fakes it by stubbing
visualViewport.height. - GPU: software GL frame rates say nothing about a phone GPU.
Techniques that found the real cause fast
- Ask two questions: which browser and device, and does it behave differently in a private window? A private tab with sound immediately implicated stored state (a remembered mute).
- Diff a working page against a broken one. A sketch page of the same design worked on the phone; the only difference in the theme was one CSS property.
- Instrument instead of reasoning: a
MutationObserveron the element's class plus capture listeners on all pointer, touch and mouse events showed a class toggling twice in one tap. - Measure layouts in sized iframes and with CDP device emulation at 390x844, 3x, CPU throttled 4x, with real touch events; it narrows the gap but is still not a phone.
How to report
Say plainly when a test does not prove what it appears to prove ("verified in emulated-phone headless Chrome only; real keyboard untested"). "I can't reproduce this, here is what I found by other means" is fine, and so is asking for one more data point.
See also
- Headless Chrome testing gotchas
- Working with Justin as an AI agent (ask first, confirm the target, precise verbs, artifacts over essays)