Skip to content

Commit 8ed6edc

Browse files
committed
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.
1 parent bd69bed commit 8ed6edc

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎internal/interaction-harness/src/harness.interaction.browser.spec.ts‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4801,14 +4801,15 @@ test.describe('page freeze', () => {
48014801
const box = page.locator('#box');
48024802
const watch = await watchAnimations(box);
48034803
const startedAt = Date.now();
4804-
await box.evaluate(el => {
4805-
el.animate(
4804+
// Over before the freeze, and read only after the thaw. The freeze waits
4805+
// for the run's own end. A run starts only at a frame, and a busy machine
4806+
// can draw no frame for longer than any fixed wait.
4807+
await box.evaluate(async el => {
4808+
await el.animate(
48064809
[{transform: 'translateX(0px)'}, {transform: 'translateX(100px)'}],
48074810
{duration: 200},
4808-
);
4811+
).finished;
48094812
});
4810-
// Over before the freeze, and read only after the thaw.
4811-
await page.waitForTimeout(400);
48124813
const frozenAt = Date.now();
48134814
await freezePage(page);
48144815
await page.waitForTimeout(600);
@@ -4832,11 +4833,13 @@ test.describe('page freeze', () => {
48324833
{duration: 60_000, easing: 'linear'},
48334834
);
48344835
});
4835-
await page.waitForTimeout(100);
4836-
// Where the run started, on the page's clock, before any freeze.
4837-
const startedAt = await page.evaluate(() =>
4838-
Number((window as unknown as {run: Animation}).run.startTime),
4839-
);
4836+
// Where the run started, on the page's clock, before any freeze. It has
4837+
// a start time only once a frame starts it, so the read waits for that.
4838+
const startedAt = await page.evaluate(async () => {
4839+
const {run} = window as unknown as {run: Animation};
4840+
await run.ready;
4841+
return Number(run.startTime);
4842+
});
48404843
for (let cycle = 0; cycle < 10; cycle++) {
48414844
await freezePage(page);
48424845
await page.waitForTimeout(50);

0 commit comments

Comments
 (0)