Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(interaction-harness): two page-freeze cases wait for the frame (#9873)

Christopher Chedeaub8f2a9feedac
diff --git a/internal/interaction-harness/src/harness.interaction.browser.spec.ts b/internal/interaction-harness/src/harness.interaction.browser.spec.ts
index 22d9014bee..0257f0a019 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);