From 8ed6edc4ac2afba977bfae405dd9a1128008b039 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 3 Nov 2026 20:26:09 -0800 Subject: [PATCH] test(interaction-harness): two page-freeze cases wait for the frame Two page-freeze self-test cases assumed that a fixed wait covered the frame that starts a run. A busy machine can draw no frame for longer than the wait, and both cases failed once that way in a full Chromium run. The run that finishes before the freeze had not started when the freeze landed, so it was dated after the freeze (487 ms). The ten-cycle case read the run's start time before any frame, got null, and so measured a drift of the run's whole start (1224 ms). The first case now waits for the run's own end before it freezes, and the second reads the start time once the run is ready. --- .../src/harness.interaction.browser.spec.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/internal/interaction-harness/src/harness.interaction.browser.spec.ts b/internal/interaction-harness/src/harness.interaction.browser.spec.ts index 22d9014beef93..0257f0a019d20 100644 --- a/internal/interaction-harness/src/harness.interaction.browser.spec.ts +++ b/internal/interaction-harness/src/harness.interaction.browser.spec.ts @@ -4801,14 +4801,15 @@ test.describe('page freeze', () => { const box = page.locator('#box'); const watch = await watchAnimations(box); const startedAt = Date.now(); - await box.evaluate(el => { - el.animate( + // Over before the freeze, and read only after the thaw. The freeze waits + // for the run's own end. A run starts only at a frame, and a busy machine + // can draw no frame for longer than any fixed wait. + await box.evaluate(async el => { + await el.animate( [{transform: 'translateX(0px)'}, {transform: 'translateX(100px)'}], {duration: 200}, - ); + ).finished; }); - // Over before the freeze, and read only after the thaw. - await page.waitForTimeout(400); const frozenAt = Date.now(); await freezePage(page); await page.waitForTimeout(600); @@ -4832,11 +4833,13 @@ test.describe('page freeze', () => { {duration: 60_000, easing: 'linear'}, ); }); - await page.waitForTimeout(100); - // Where the run started, on the page's clock, before any freeze. - const startedAt = await page.evaluate(() => - Number((window as unknown as {run: Animation}).run.startTime), - ); + // Where the run started, on the page's clock, before any freeze. It has + // a start time only once a frame starts it, so the read waits for that. + const startedAt = await page.evaluate(async () => { + const {run} = window as unknown as {run: Animation}; + await run.ready; + return Number(run.startTime); + }); for (let cycle = 0; cycle < 10; cycle++) { await freezePage(page); await page.waitForTimeout(50);