From d84ed7fcfd4e5797f1aa19da7edc6665e477bffd Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 11 Oct 2026 03:01:41 +0800 Subject: [PATCH] gui tests: checkbox-look reads a ticked box's colour once its own transition ends checkbox-look failed about 1 run in 3 in Chromium dark when run alone ("a ticked box is filled with the accent": rgb(35, 35, 39), the card, against the accent). At the failing read the box was checked and matched :checked, and the :checked rule was the winning one. The box still showed a background-color transition at currentTime 0. The reduced-motion rule (app.css: `*, *::before, *::after { transition-duration: .01ms !important }`) makes every property transition for .01ms, not none, and Chromium under load can still hold that transition at its start two animation frames after the click. The test read the colour after two rAFs. It now waits one frame and then for the box's own getAnimations() to finish. The app is right, and a user sees the fill within .01ms. Run: a copy with the dark case six times, en only, in Chromium. Before, 11 of 18 failed; after, 30 of 30 passed. checkbox-look.test.cjs in Chromium and WebKit (en and zh, light and dark) passed 4/4 each. With the :checked fill taken out of the served app.css, it fails 4/4 in both engines. --- internal/gui/tests/checkbox-look.test.cjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/gui/tests/checkbox-look.test.cjs b/internal/gui/tests/checkbox-look.test.cjs index 8b6d0c1c5..6189d3b5e 100644 --- a/internal/gui/tests/checkbox-look.test.cjs +++ b/internal/gui/tests/checkbox-look.test.cjs @@ -97,9 +97,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", await page.locator("#nav").getByRole("button", { name: nav[lang], exact: true }).click(); const view = page.locator("#view-sessions"); await view.locator('.row.sm-sess[data-id="a-login"]').waitFor(); - // read after a frame: the page's reduced-motion transitions still take one + // read once the box's own transitions end: reduced motion makes every + // transition .01ms, not none, and Chromium under load can still show + // one at its start two frames after the click const look = (l) => l.evaluate(async (e) => { - for (let i = 0; i < 2; i++) await new Promise((r) => requestAnimationFrame(r)); + await new Promise((r) => requestAnimationFrame(r)); + await Promise.all(e.getAnimations().map((a) => a.finished)); const s = getComputedStyle(e), card = getComputedStyle(document.documentElement).getPropertyValue("--card").trim(); const accent = getComputedStyle(document.documentElement).getPropertyValue("--accent").trim(); const probe = document.createElement("i");