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.
This commit is contained in:
yetone
2026-10-11 04:56:32 +08:00
parent 814a5ed73c
commit d84ed7fcfd
+5 -2
View File
@@ -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");