test(e2e): count only the visible part of a star and a control as cover

At 390 px with the radio spot open on Agents Orbit, the STARS probe reported the legend star covered by the radio search field and its clear button. Both sit scrolled out of view inside the radio spot's overflow box, and a hit test at their points returns the legend, so nothing covers the star. The probe now intersects each box with every clipping ancestor before it measures overlap; it can only shrink a box, so a visible overlap is still reported.

🎯 Fix: 93 %
💥 Break: 4 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 89
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 23:18:07 +00:00
1 parent c202429cf9
commit 459d8a82e0
1 file changed
+28 -3
+28 -3
View File
@@ -110,16 +110,41 @@ STARS = """(async () => {@HELPERS@@HOME@
const CONTROLS = 'button, a[href], input, select, textarea, summary, [role="button"], [role="tab"], [tabindex]:not([tabindex="-1"])'; const CONTROLS = 'button, a[href], input, select, textarea, summary, [role="button"], [role="tab"], [tabindex]:not([tabindex="-1"])';
const shown = (node) => node.getClientRects().length > 0 && getComputedStyle(node).visibility !== "hidden" && !node.closest("details:not([open]) > :not(summary)"); const shown = (node) => node.getClientRects().length > 0 && getComputedStyle(node).visibility !== "hidden" && !node.closest("details:not([open]) > :not(summary)");
const overlap = (a, b) => Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left)) * Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top)); const overlap = (a, b) => Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left)) * Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));
const XHTML = "http://www.w3.org/1999/xhtml";
const clipped = (node) => {
const box = node.getBoundingClientRect();
const drawn = {left: box.left, top: box.top, right: box.right, bottom: box.bottom};
let position = getComputedStyle(node).position;
for (let at = node.parentElement; at && at !== document.body && position !== "fixed"; at = at.parentElement) {
const look = getComputedStyle(at);
if (at.namespaceURI !== XHTML || ["inline", "contents"].includes(look.display) || (position === "absolute" && look.position === "static")) {
continue;
}
position = look.position;
const edge = at.getBoundingClientRect();
const left = edge.left + at.clientLeft;
const top = edge.top + at.clientTop;
if (look.overflowX !== "visible") {
drawn.left = Math.max(drawn.left, left);
drawn.right = Math.min(drawn.right, left + at.clientWidth);
}
if (look.overflowY !== "visible") {
drawn.top = Math.max(drawn.top, top);
drawn.bottom = Math.min(drawn.bottom, top + at.clientHeight);
}
}
return drawn;
};
const layer = (node) => node.closest("dialog[open]"); const layer = (node) => node.closest("dialog[open]");
const count = (where) => { const count = (where) => {
const owners = all("[data-panel], [data-item]").filter((node) => node.namespaceURI === "http://www.w3.org/1999/xhtml"); const owners = all("[data-panel], [data-item]").filter((node) => node.namespaceURI === XHTML);
seen.push([where, owners.length]); seen.push([where, owners.length]);
missing.push(...owners.filter((node) => !ownStar(node)).map((node) => `${where}: ${node.outerHTML.slice(0, 120)}`)); missing.push(...owners.filter((node) => !ownStar(node)).map((node) => `${where}: ${node.outerHTML.slice(0, 120)}`));
const controls = all(CONTROLS).filter(shown); const controls = all(CONTROLS).filter(shown);
for (const star of all(".star").filter(shown)) { for (const star of all(".star").filter(shown)) {
const box = star.getBoundingClientRect(); const box = clipped(star);
for (const other of controls) { for (const other of controls) {
if (other !== star && !other.contains(star) && !star.contains(other) && layer(other) === layer(star) && overlap(box, other.getBoundingClientRect()) > 1) { if (other !== star && !other.contains(star) && !star.contains(other) && layer(other) === layer(star) && overlap(box, clipped(other)) > 1) {
covered.push(`${where}: ${star.title} over ${other.outerHTML.slice(0, 100)}`); covered.push(`${where}: ${star.title} over ${other.outerHTML.slice(0, 100)}`);
} }
} }