Page coverage keeps what a document ran before it unloads, and every page (#407)

The fixture took Playwright's page.coverage once, at the end: a reload
or a sign-in's redirect had by then thrown the first document's script
away with its counts, so reloadKeepingPlace read as never run though the
new-version test runs it, and the second people's pages (piper's, opal's)
were not recorded at all.

Each page a test opens, its own and those of the contexts it makes, now
records through a CDP session of the fixture's own (precise coverage,
sources fetched as each script is parsed), and every document stops at a
breakpoint in a beforeunload listener the fixture adds, where it is taken
before the document goes. Taking it on the navigation's event came after
the document had gone, and holding the document's request (Fetch, as
page.route before) held the take up behind it, the renderer answering
nothing while the navigation waited. A page or context is taken again as
it closes. Page lines 80.0% to 84.5%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkrVDqdiQEMWAkNGQ2tYA
This commit is contained in:
2026-11-07 14:37:49 +00:00
parent f5a3847a21
commit 07923d665b
2 changed files with 103 additions and 9 deletions

View File

@@ -300,8 +300,11 @@ suite stops its servers with SIGTERM in that mode, since an instrumented binary
as it exits. The same run measures the page; `npm run coverage:page` does that alone, on a build of
the page with a source map to each `web/src` file (`IPX_COVERAGE=1`, `web/concat-map.mts`), into
`target/coverage/page`. The specs take `test` and `expect` from `tests/ui/coverage.ts`, not from
`@playwright/test`, so every test is counted. The service worker, the unit tests and the
native-bridge check are not.
`@playwright/test`, so every test is counted, every page it opens (a second person's context
too), and each document before it unloads: the fixture stops it in `beforeunload` at a breakpoint
of its own to take what it ran, since a reload or sign-in otherwise throws that away (#407). The
unit tests and the native-bridge check are measured in Node first (`scripts/coverage-node.sh`);
the service worker is not.
Each run ends with `node scripts/coverage-metrics.ts`, which writes every suite's last numbers to
`/mnt/fast/appdata/node-exporter/textfile/ipx_coverage.prom`; node-exporter's textfile collector