Skip to content

Commit 5212d64

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 1800b47 commit 5212d64

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
@@ -4794,14 +4794,15 @@ test.describe('page freeze', () => {
47944794
const box = page.locator('#box');
47954795
const watch = await watchAnimations(box);
47964796
const startedAt = Date.now();
4797-
await box.evaluate(el => {
4798-
el.animate(
4797+
// Over before the freeze, and read only after the thaw. The freeze waits
4798+
// for the run's own end. A run starts only at a frame, and a busy machine
4799+
// can draw no frame for longer than any fixed wait.
4800+
await box.evaluate(async el => {
4801+
await el.animate(
47994802
[{transform: 'translateX(0px)'}, {transform: 'translateX(100px)'}],
48004803
{duration: 200},
4801-
);
4804+
).finished;
48024805
});
4803-
// Over before the freeze, and read only after the thaw.
4804-
await page.waitForTimeout(400);
48054806
const frozenAt = Date.now();
48064807
await freezePage(page);
48074808
await page.waitForTimeout(600);
@@ -4825,11 +4826,13 @@ test.describe('page freeze', () => {
48254826
{duration: 60_000, easing: 'linear'},
48264827
);
48274828
});
4828-
await page.waitForTimeout(100);
4829-
// Where the run started, on the page's clock, before any freeze.
4830-
const startedAt = await page.evaluate(() =>
4831-
Number((window as unknown as {run: Animation}).run.startTime),
4832-
);
4829+
// Where the run started, on the page's clock, before any freeze. It has
4830+
// a start time only once a frame starts it, so the read waits for that.
4831+
const startedAt = await page.evaluate(async () => {
4832+
const {run} = window as unknown as {run: Animation};
4833+
await run.ready;
4834+
return Number(run.startTime);
4835+
});
48334836
for (let cycle = 0; cycle < 10; cycle++) {
48344837
await freezePage(page);
48354838
await page.waitForTimeout(50);

0 commit comments

Comments
 (0)