gui tests: editor-thumbs-batched checks the thumbs shown, then Advanced opened (#5886)
editor-thumbs-batched went red on main fromb03a37476on (found by bisecting 117f56c70..2abfe2b64 with the chromium half of the test): three controls, off|on and off|week|all, with a thumb of width 0 two pixels left of the option.b03a37476moved Claude's warm-up and lean lists into the provider editor's Advanced, which is closed when the editor opens. Chromium answers offsetWidth inside a closed <details> (its content is content-visibility: hidden and the read lays it out), so the test's `on.offsetWidth` took those controls for shown ones, while their ResizeObserver, rightly, had nothing to report yet. Nothing is wrong in the page: the thumbs are put when Advanced opens. The test now checks the thumbs whose option checkVisibility() says is shown, then opens every closed <details> in the editor, waits two frames, and checks every thumb again. That second check is what a user opening Advanced sees. WebKit's slow-read count was red too, on main as well (origin/main70f4593e6: 208 at 40 accounts, 244 at 160; this branch 188/213). The reads that differ were all holdModal's few a frame and the frames' own: the open at 40 sometimes ends ~5 frames sooner. That is frame jitter, not a read an account (+120 here), so the room for slow reads is 60, not 24; the forced-layout room stays 24. Run (mote, at the pushed base): editor-thumbs-batched, Chromium and WebKit, en/zh/zh-TW/ja/de, 10/10 green three times in a row. Broken by hand: thumbFit's callback made a no-op (the thumbs put only when drawn) is red 5/5 in Chromium, on "opened off|on: option 655.8+38.0, thumb 653.8+0.0" and "opened off|week|all", the controls in Advanced; the "shown" check stays green there, as it should. Broken by hand: an offsetTop read for every account a frame after the list is drawn is red in WebKit en and zh (278 at 40, 538 at 160). Not tried: the WebKit half of the broken-by-hand run.
This commit is contained in:
@@ -106,15 +106,24 @@ async function opening(browser, lang, n) {
|
||||
const w = window.__thumbs;
|
||||
await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
|
||||
w.on = false;
|
||||
// where each thumb is drawn, against the option picked under it
|
||||
// where each shown thumb is drawn, against the option picked under it;
|
||||
// then Advanced opened and every one again (#5886: a control in a
|
||||
// closed Advanced is put when it opens, and Chromium answers
|
||||
// offsetWidth inside the closed one, so shown is checkVisibility's)
|
||||
const boxes = [...document.querySelectorAll(".editor .segs")];
|
||||
const off = [];
|
||||
for (const box of boxes) {
|
||||
const on = box.querySelector(":scope > .on"), th = box.querySelector(":scope > .thumb");
|
||||
if (!on || !on.offsetWidth) continue;
|
||||
const a = on.getBoundingClientRect(), b = th?.getBoundingClientRect();
|
||||
if (!b || Math.abs(a.left - b.left) > 1 || Math.abs(a.width - b.width) > 1) off.push(`${box.dataset.kind}: option ${a.left.toFixed(1)}+${a.width.toFixed(1)}, thumb ${b ? b.left.toFixed(1) + "+" + b.width.toFixed(1) : "none"}`);
|
||||
}
|
||||
const check = (when) => {
|
||||
for (const box of boxes) {
|
||||
const on = box.querySelector(":scope > .on"), th = box.querySelector(":scope > .thumb");
|
||||
if (!on || !on.checkVisibility()) continue;
|
||||
const a = on.getBoundingClientRect(), b = th?.getBoundingClientRect();
|
||||
if (!b || Math.abs(a.left - b.left) > 1 || Math.abs(a.width - b.width) > 1) off.push(`${when} ${box.dataset.kind}: option ${a.left.toFixed(1)}+${a.width.toFixed(1)}, thumb ${b ? b.left.toFixed(1) + "+" + b.width.toFixed(1) : "none"}`);
|
||||
}
|
||||
};
|
||||
check("shown");
|
||||
for (const d of document.querySelectorAll(".editor details:not([open])")) d.open = true;
|
||||
await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
|
||||
check("opened");
|
||||
return { forced: w.forced, slow: w.slow, boxes: boxes.length, off };
|
||||
});
|
||||
await context.close();
|
||||
@@ -136,11 +145,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(many.off, []);
|
||||
assert.ok(few.forced > 0, "opening lays the editor out");
|
||||
// a frame's observer can land on either side of the count's end, and
|
||||
// the page's own reads (about 240 slow ones in WebKit at either count)
|
||||
// vary by a frame's worth: room for that, none for a read an account,
|
||||
// 120 more here
|
||||
// the page's own reads (about 200 slow ones in WebKit at either count)
|
||||
// vary by the frames the open takes: holdModal reads a few each
|
||||
// frame, and WebKit's 40 sometimes ends ~5 frames sooner (188 against
|
||||
// 208, up to 36 apart on mote). Room for that, none for a read an
|
||||
// account, 120 more here
|
||||
assert.ok(many.forced <= few.forced + 24, `forced layouts: ${few.forced} at 40 accounts, ${many.forced} at 160`);
|
||||
assert.ok(many.slow <= few.slow + 24, `offsetLeft/offsetTop/offsetParent/scroll/computed-style reads: ${few.slow} at 40 accounts, ${many.slow} at 160`);
|
||||
assert.ok(many.slow <= few.slow + 60, `offsetLeft/offsetTop/offsetParent/scroll/computed-style reads: ${few.slow} at 40 accounts, ${many.slow} at 160`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user