carlos / platform Public

console tests: time the first claim stage from domInteractive

TestDemoClaimUXHeadlessFast1280 measured 648.4 ms on CI. When the page
paints before DOMContentLoaded the first-paint entry may not be posted
yet, so the first stage was still timed late. domInteractive (parsing
done) is always before the page's script starts its 650 ms clock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ce8733bb468e50a1b72748c9d61b247fc42d1031 parent 972409a
1 file changed, +12 −5
  • internal/console/testdata/demo_claim_layout.mjs +12 −5

CI passed — run details

diff --git a/internal/console/testdata/demo_claim_layout.mjs b/internal/console/testdata/demo_claim_layout.mjs
index c742460e0..0d2ae4eeb 100644
--- a/internal/console/testdata/demo_claim_layout.mjs
+++ b/internal/console/testdata/demo_claim_layout.mjs
@@ -77,12 +77,19 @@ export const watchClaimCSP = `
const record = () => {
const stage = claim.dataset.state === 'claimed' ? 4 : Number(progress.dataset.stage);
if (stage === last) return;
- // The server-rendered stage is on screen from the first contentful
- // paint, which a cold or busy browser can reach before this event
- // fires. The page counts its 650 ms from its own paint, so timing the
- // first stage from here would short it (644.9 ms on CI, 2026-11-10).
+ // The first stage is timed from when the document finished parsing
+ // (domInteractive), which is always before the page's script starts
+ // its own 650 ms clock. This event can fire after the page has
+ // already painted and started that clock, and the first-paint entry
+ // may not be posted yet, so timing from here, or from first paint
+ // when it is missing, shorted the stage (644.9 ms and 648.4 ms on CI,
+ // 2026-11-10/11).
let time = performance.now();
- if (last === undefined) time = Math.min(time, performance.getEntriesByName('first-contentful-paint')[0]?.startTime ?? time);
+ if (last === undefined) {
+ const nav = performance.getEntriesByType('navigation')[0];
+ const paint = performance.getEntriesByName('first-contentful-paint')[0];
+ time = Math.min(time, nav?.domInteractive || time, paint?.startTime ?? time);
+ }
window.claimStageTimes.push({stage,time});
last = stage;
};