Skip to content

Commit ea7e91f

Browse files
committed
Use timeout fallback for contentvisibilityautostatechange in Safari
1 parent f0a2678 commit ea7e91f

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

experimental/tests.mjs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,8 @@ export const ExperimentalSuites = freezeSuites([
201201
for (const width of widths) {
202202
page.setWidth(width);
203203
page.layout();
204-
if (width === MATCH_MEDIA_QUERY_BREAKPOINT) {
205-
await Promise.race([
206-
resizeWorkPromise,
207-
new Promise((_, reject) => setTimeout(() => reject(new Error("[diag] ReduceWidthIn5Steps: resize-work-complete timed out after 30s")), 30000)),
208-
]);
209-
}
204+
if (width === MATCH_MEDIA_QUERY_BREAKPOINT)
205+
await resizeWorkPromise;
210206
}
211207

212208
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
@@ -250,15 +246,12 @@ export const ExperimentalSuites = freezeSuites([
250246
page.scrollTo(0, page.scrollY + videoRect.top);
251247
page.layout();
252248

253-
console.log("[diag] ScrollToChatAndSendMessages: awaiting cvWorkComplete");
254-
await Promise.race([
255-
cvWorkComplete,
256-
new Promise((_, reject) => setTimeout(() => reject(new Error("[diag] ScrollToChatAndSendMessages: video-grid-content-visibility-complete timed out after 30s")), 30000)),
257-
]);
258-
console.log("[diag] ScrollToChatAndSendMessages: done");
249+
// contentvisibilityautostatechange may not fire reliably on all
250+
// browsers in iframe contexts. Use a timeout to avoid hanging.
251+
const timeout = new Promise((resolve) => setTimeout(resolve, 10000));
252+
await Promise.race([cvWorkComplete, timeout]);
259253
}),
260254
new BenchmarkTestStep("IncreaseWidthIn5Steps", async (page) => {
261-
console.log("[diag] IncreaseWidthIn5Steps: start");
262255
const widths = [560, 640, 704, 768, 800];
263256
const MATCH_MEDIA_QUERY_BREAKPOINT = 704;
264257

0 commit comments

Comments
 (0)