test(web): read crosscheck pages with the clock paused

Merged
OK
13d ago
+38-7

The web crosscheck sometimes failed on benchmark: stale-dom with getByRole button "Decoy" / "Tap me": ours match, theirs no match (seen on #1552, gone on rerun). It was a race in the harness, not a regression in the engine.

  • stale-dom remounts every row on a 1s setInterval. The crosscheck tags the engine's elements, reads Chrome's AX tree, and then asks Playwright, all on the live page. When a tick landed between those reads, Playwright was asked about tagged buttons that had already been detached.
  • Reproduced at random tick phase under 8x CPU throttle: 8/40 runs on main, the same at HEAD~4 (before #1546-#1551). None of those merges caused it.
  • Fix: openCheckPage (packages/web/tests/crosscheck/crosscheck.ts) installs Playwright's clock paused before any document loads. Timers never fire, so the engine and both oracles read the same document. React and Next.js still hydrate (their scheduler uses MessageChannel), and expected.txt is unchanged.
  • No retries or margins. Pausing the clock mid-page can't target "now" (pauseAt throws on a past time), and CDP virtual time stalled Playwright calls, so the clock is paused from the start.
  • Coverage cost: the reviewer diffed all 42 scenarios. Only overlay-trap changed, losing a close button that a 500ms timeout reveals and that was only checked when the timeout beat networkidle.
  • New fixture list rebuilt every millisecond guards the race. AGENTS.md notes that content revealed by a timer is never read.

Verified

Ran it locally: yes

  • stale-dom through crossCheck 40 times, random phase, 8x CPU throttle:
mainthis branch
8/40 runs report the two getByRole misses0/40, same 9 nodes compared
  • New fixture with the clock install removed: fails with chrome unknown / missing on the rebuilt buttons. With it: passes.
  • Full crosscheck against a local benchmark (CROSSCHECK_BENCHMARK_URL): 19/19 passed, expected.txt untouched.