Skip to content

Automate browser based workflows with AI

Add final Gate 2 QA report (#8989)

Aaron Perez273cef5a9a9a
diff --git a/skyvern/forge/taskv3/loop.py b/skyvern/forge/taskv3/loop.py
index cfc090fe1..376f485d5 100644
--- a/skyvern/forge/taskv3/loop.py
+++ b/skyvern/forge/taskv3/loop.py
@@ -2245,7 +2245,7 @@ OBSERVE_SUMMARY_FIELDS = frozenset(
"phantom_dropped",
"iframes_in_component_roots",
"undiscovered_roots",
- "omitted_unnameable",
+ "listed_by_handle_only",
"invalid_fields",
"markers_minted",
"markers_reused",
diff --git a/skyvern/forge/taskv3/tools.py b/skyvern/forge/taskv3/tools.py
index 833d610e4..f97d9d325 100644
--- a/skyvern/forge/taskv3/tools.py
+++ b/skyvern/forge/taskv3/tools.py
@@ -176,8 +176,8 @@ _OBSERVE_DESCRIPTION_BASE = (
"Snapshot the page's visible interactive elements (raw DOM) with a handle, label, type, value, and "
"options for each. Each element line starts with its address, `ref=N`; pass that exact string (e.g. "
"ref=12, no brackets) as the selector argument of click/hover/type/select_option/etc to act on it. A "
- "ref names the element this reading described and keeps working while that element is on the page, "
- "including across a re-render that replaces it. If it becomes ambiguous or is gone, the tool errors "
+ "ref names the element this reading described and keeps working while that element is on the page. "
+ "If it becomes ambiguous or is gone, the tool errors "
"instead of acting on something else — re-observe and use a ref from the new reading. "
)
_OBSERVE_DESCRIPTION_FRAME_REACH = (
@@ -9355,6 +9355,24 @@ async (__tv3TextArgs) => {
const t = String(el.tagName || '').toLowerCase();
return /^[a-z][a-z0-9_-]*$/.test(t) ? t : null;
};
+ // A handle-only record's line-to-handle binding: its child position at every step up to the document,
+ // crossing each shadow root at its host. Playwright's engine reads it at act time outside the page's
+ // realm, as it does a named record's selector, so a page that swaps the elements behind two lines is refused.
+ const positionPath = (el) => {
+ const steps = [];
+ try {
+ for (let n = el; n && n.nodeType === 1; ) {
+ const t = safeTag(n);
+ if (!t) return '';
+ let k = 1;
+ for (let s = n.previousElementSibling; s; s = s.previousElementSibling) k++;
+ steps.push(t + ':nth-child(' + k + ')');
+ const p = n.parentNode;
+ n = p && p.nodeType === 11 ? p.host : p;
+ }
+ } catch (e) { return ''; }
+ return steps.reverse().join(' > ');
+ };
// Where the page itself puts a control, for a renderer that has found two element lines rendering
// the same bytes. Nearest first: the control's own identity, then each enclosing element carrying
// one, then the heading the page files it under. Attributes are read off Element.prototype and
@@ -9690,26 +9708,22 @@ async (__tv3TextArgs) => {
// Naming a host is paid once per walk: the same anchor serves every control under it, and a
// marker written for the first is reused, not re-minted, for the rest.
const anchorByHost = new Map();
- // Anchoring is bounded per walk. A control that cannot be named does not spend the element
- // budget, so without this a page of thousands of unnameable component controls would spend the
- // evaluate's whole time bound on tails that all fail.
+ // Anchoring is bounded per walk. An unnamed pointer-styled control does not spend the element
+ // budget, so without this a page of thousands of them would spend the evaluate's whole time bound
+ // on tails that all fail.
let anchorAttempts = 0;
const _ANCHOR_ATTEMPTS = 3000;
const _ANCHORED_MAX_LEN = 400;
- // Set when the LAST refusal was ours (a budget) rather than the page's, so the omission is
- // reported as such and not as a claim about the control.
- let anchorRefusedByBudget = false;
// The host and tail of the last selector hostAnchored composed, kept so the record can be
// re-resolved under its host later (a composed selector straddles a root; only scoped counting sees it).
let lastAnchor = null;
const hostAnchored = (el, host, depth) => {
depth = depth || 0;
- if (depth === 0) anchorRefusedByBudget = false;
if (!host) return null;
- if (depth > 8) { anchorRefusedByBudget = true; return null; }
+ if (depth > 8) return null;
// A host already named this walk costs a lookup, not an attempt; the budget is charged for
// naming a host, which is the part that walks the page.
- if (!anchorByHost.has(host) && ++anchorAttempts > _ANCHOR_ATTEMPTS) { anchorRefusedByBudget = true; return null; }
+ if (!anchorByHost.has(host) && ++anchorAttempts > _ANCHOR_ATTEMPTS) return null;
let tails = [];
if (el.id) {
const raw = String(el.id);
@@ -9728,9 +9742,7 @@ async (__tv3TextArgs) => {
const cached = anchorByHost.get(host);
hostSel = cached.sel;
hostTrail = cached.trail;
- if (!hostSel && cached.budget) anchorRefusedByBudget = true;
} else {
- const budgetBefore = anchorRefusedByBudget;
// naturalSelector reports its cause through shared state; the control's own cause is already
// settled by the time we get here and must survive naming the host.
const why = naturalWhy;
@@ -9774,9 +9786,8 @@ async (__tv3TextArgs) => {
naturalWhy = why;
checkInconclusive = inconclusive;
// A refusal reached through the recursion may be the depth bound, which a control whose own
- // host this is would not hit; only a top-level or successful answer is worth remembering. A
- // refusal that was a budget stays a budget on every later hit.
- if (hostSel || depth === 0) anchorByHost.set(host, { sel: hostSel, trail: hostTrail, budget: !hostSel && anchorRefusedByBudget && !budgetBefore });
+ // host this is would not hit; only a top-level or successful answer is worth remembering.
+ if (hostSel || depth === 0) anchorByHost.set(host, { sel: hostSel, trail: hostTrail });
}
if (!hostSel) return null;
// Naming the host may have written to it, and a component can re-render its root on any
@@ -9784,7 +9795,7 @@ async (__tv3TextArgs) => {
// or a replacement control would inherit this one's label and state.
if (!scopedResolvesTo(host, ctrl, el)) return null;
const sel = hostSel + ' ' + ctrl;
- if (sel.length > _ANCHORED_MAX_LEN) { anchorRefusedByBudget = true; return null; }
+ if (sel.length > _ANCHORED_MAX_LEN) return null;
// The whole chain that produced the selector, each link verified where it was taken, so the
// record can be re-validated link by link: the tail under its host, and the host by its own name.
lastAnchor = { sel: sel, trail: [{ scope: host, ctrl: ctrl, target: el }].concat(hostTrail) };
@@ -9817,8 +9828,7 @@ async (__tv3TextArgs) => {
if (!textOnly) return '';
return String(host.innerText || '').replace(/\s+/g, ' ').trim().slice(0, _RETAIN_WIDTH);
};
- // Controls inside a component that we could not name, split by CAUSE: these need different
- // fixes, and one merged tally would send the follow-up after the wrong one.
+ // Why naturalSelector could not name a control inside a component:
// anonymous -- no id/name/data-testid at all
// duplicated -- has one, but shadow encapsulation lets every instance reuse it, so the
// cross-root count is >1 and no unscoped selector can single this one out
@@ -9854,11 +9864,6 @@ async (__tv3TextArgs) => {
// the host's marker after the walk drops each of those controls, not the host.
const anchorsMinted = [];
const anchorRecords = [];
- let unnamedAnonymous = 0;
- let unnamedBudget = 0;
- let unnamedDuplicated = 0;
- let unnamedUnverifiable = 0;
- let unnamedUnsafe = 0;
let i = 0;
let dropped = 0;
// Two counters, deliberately: hiddenKept bounds the retention work and is spent the moment a
@@ -10149,19 +10154,13 @@ async (__tv3TextArgs) => {
}
if (pointerRoot && pointerListed + (_pointerState.held.has(el) ? pointerReserved : 0) >= _POINTER_ROOT_CAP) { pointerCapped++; continue; }
let selector = naturalSelector(el);
+ let bind = '';
if (!selector) {
- // We do not write inside a shadow root. Setting a marker there is a mutation of the
- // component's own subtree, and every mechanism that wrote one and then tried to manage the
- // consequences failed: the mark provokes the re-render that destroys it, and because the mark
- // IS the handle we hand out it cannot move off-DOM. Verifying it needed a wait, every clock
- // belongs to the page, and a fixed wait was accurate under 50 ms and silently wrong past it.
- // Worse, a marker that churns every observe makes the payload differ every turn, which
- // defeats the loop's perception-stall terminator -- so the page burned the whole budget where
- // the base engine terminated cleanly. Not writing restores that behavior exactly. A control
- // with an id, name or data-testid of its own is unaffected, which is the ordinary case.
+ // Observe never writes inside a shadow root: a mark there provokes the re-render that destroys
+ // it. A control no verified selector names is listed by its live handle alone, so a replaced
+ // node goes stale instead of being re-found.
if (host) {
anchorsMinted.length = 0;
- anchorRefusedByBudget = false;
lastAnchor = null;
if (naturalWhy === 'duplicated' || naturalWhy === 'anonymous') selector = hostAnchored(el, host);
// A host marked during this attempt is accounted for whether or not the attempt produced a
@@ -10171,12 +10170,9 @@ async (__tv3TextArgs) => {
for (const a of anchorRecords) { if (selector.indexOf(attr('data-tv3', a.m)) === 0) { a.ctrls.push({ el: el, rec: null }); anchorRecs.push(a); } }
} else {
if (pointerRoot) { pointerDropped++; continue; }
- if (anchorRefusedByBudget) unnamedBudget++;
- else if (naturalWhy === 'duplicated') unnamedDuplicated++;
- else if (naturalWhy === 'unverifiable') unnamedUnverifiable++;
- else if (naturalWhy === 'unsafe') unnamedUnsafe++;
- else unnamedAnonymous++;
- continue;
+ selector = '';
+ bind = positionPath(el);
+ if (!bind) { dropped++; continue; }
}
} else {
const writtenBefore = markersWritten;
@@ -10206,6 +10202,7 @@ async (__tv3TextArgs) => {
// provenance before the display cap lands. A tighter cap here would truncate the URL past
// recognition and leak its signing tail.
const rec = { i, tag: el.tagName.toLowerCase(), type: (_typed && el.type) || null, selector, label: label.slice(0, _RETAIN_WIDTH) };
+ if (bind) rec.bind = bind;
if (pointerRoot) rec.pointerRoot = true;
if (iconRoot) rec.icon = true;
if (pointerRoot && _pointerState.held.has(el)) rec.pointerHeld = true;
@@ -10451,7 +10448,7 @@ async (__tv3TextArgs) => {
if (link.ctrl) { if (!scopedResolvesTo(link.scope, link.ctrl, link.target)) { ok = false; break; } }
else { checkInconclusive = false; if (!resolvesTo(link.sel, link.target) && !checkInconclusive) { ok = false; break; } }
}
- } else { checkInconclusive = false; ok = resolvesTo(rec.selector, el) || checkInconclusive; }
+ } else if (rec.selector) { checkInconclusive = false; ok = resolvesTo(rec.selector, el) || checkInconclusive; }
}
if (!ok) {
// Dropped from the digest, but the control can still BE there -- a page that changes a second
@@ -10982,7 +10979,7 @@ async (__tv3TextArgs) => {
} catch (e) { /* a count the page broke is not worth the reading */ }
let readyState = '';
try { readyState = String(_getter(Document.prototype, 'readyState').call(document)); } catch (e) { readyState = ''; }
- const payload = _ownStringify({ textDelta: textDelta, refsFresh: refsFresh, flutter: __OBSERVE_FLUTTER__, url: location.href, title: document.title, text: texts, textFull: texts.map((t) => { const f = fullText.get(t); return f && f !== t ? f : null; }), textTruncated: textFull, textDropped: textDropped, iframes: iframeInfo, frameCensus: frameCensus, dropped: dropped, truncated: truncated, iconsTruncated: iconsTruncated, truncatedInComponents: truncatedInComponents, pointerCapped: pointerCapped, pointerTruncated: pointerTruncated, pointerDropped: pointerDropped, pointerListed: pointerListed, pointerScanStopped: _pointerState.scanStopped ? 1 : 0, pointerScanFailed: _pointerState.scanFailed ? 1 : 0, unnamedAnonymous: unnamedAnonymous, unnamedBudget: unnamedBudget, unnamedDuplicated: unnamedDuplicated, unnamedUnverifiable: unnamedUnverifiable, unnamedUnsafe: unnamedUnsafe, unreadableRoot: sawUnreadableRoot, undiscoveredRoots: undiscoveredRoots, rootCount: allRoots.length - 1, hiddenListed: hiddenListed, hiddenDropped: hiddenDropped, hiddenDroppedOffCanvas: hiddenDroppedOffCanvas, hiddenDroppedVisibility: hiddenDroppedVisibility, hiddenDroppedZeroRect: hiddenDroppedZeroRect, hiddenDroppedOffViewport: hiddenDroppedOffViewport, offViewportUnreachableUnnamed: offViewportUnreachableUnnamed, offViewportUnnamedHostExempt: offViewportUnnamedHostExempt, phantomDropped: phantomDropped, markersMinted: markersWritten, markersReused: markersReused, pageMutated: mutated, modalOpen: modalOpen, modalListed: modalListed, modalTruncated: modalTruncated, readyState: readyState, elements: out });
+ const payload = _ownStringify({ textDelta: textDelta, refsFresh: refsFresh, flutter: __OBSERVE_FLUTTER__, url: location.href, title: document.title, text: texts, textFull: texts.map((t) => { const f = fullText.get(t); return f && f !== t ? f : null; }), textTruncated: textFull, textDropped: textDropped, iframes: iframeInfo, frameCensus: frameCensus, dropped: dropped, truncated: truncated, iconsTruncated: iconsTruncated, truncatedInComponents: truncatedInComponents, pointerCapped: pointerCapped, pointerTruncated: pointerTruncated, pointerDropped: pointerDropped, pointerListed: pointerListed, pointerScanStopped: _pointerState.scanStopped ? 1 : 0, pointerScanFailed: _pointerState.scanFailed ? 1 : 0, unreadableRoot: sawUnreadableRoot, undiscoveredRoots: undiscoveredRoots, rootCount: allRoots.length - 1, hiddenListed: hiddenListed, hiddenDropped: hiddenDropped, hiddenDroppedOffCanvas: hiddenDroppedOffCanvas, hiddenDroppedVisibility: hiddenDroppedVisibility, hiddenDroppedZeroRect: hiddenDroppedZeroRect, hiddenDroppedOffViewport: hiddenDroppedOffViewport, offViewportUnreachableUnnamed: offViewportUnreachableUnnamed, offViewportUnnamedHostExempt: offViewportUnnamedHostExempt, phantomDropped: phantomDropped, markersMinted: markersWritten, markersReused: markersReused, pageMutated: mutated, modalOpen: modalOpen, modalListed: modalListed, modalTruncated: modalTruncated, readyState: readyState, elements: out });
return __OBSERVE_RETURN__;
}
"""
@@ -12336,11 +12333,6 @@ _OBSERVE_SUMMED_KEYS = (
"pointerListed",
"pointerScanStopped",
"pointerScanFailed",
- "unnamedAnonymous",
- "unnamedBudget",
- "unnamedDuplicated",
- "unnamedUnverifiable",
- "unnamedUnsafe",
"undiscoveredRoots",
"rootCount",
"hiddenListed",
@@ -13131,6 +13123,7 @@ def build_browser_tools(
"handle": handles[_idx],
"tag": _tag,
"selector": e.get("selector") or "",
+ "binding": "" if e.get("selector") else str(e.get("bind") or ""),
# The frame this element was read from, and the document that frame was showing. Both
# server-held: nothing frame-shaped is ever put in a selector, so the model has nothing
# frame-shaped to mistranscribe.
@@ -13141,30 +13134,6 @@ def build_browser_tools(
"option": _mask_refs(str(e.get("label") or "")),
"choice": next((c for c in (e.get("role"), e.get("type")) if c in ("radio", "checkbox")), ""),
}
- omitted_anonymous = data.get("unnamedAnonymous") or 0
- omitted_duplicated = data.get("unnamedDuplicated") or 0
- omitted_unverifiable = data.get("unnamedUnverifiable") or 0
- omitted_unsafe = data.get("unnamedUnsafe") or 0
- omitted_budget = data.get("unnamedBudget") or 0
- omitted_in_components = (
- omitted_anonymous + omitted_duplicated + omitted_unverifiable + omitted_unsafe + omitted_budget
- )
- if omitted_in_components:
- # Sizes the capability this deliberately gives up, split by cause because the causes have
- # different fixes: `duplicated` is answered by host-anchored selectors with executor-side
- # verification (the SKY-14710 family), `anonymous` only by that same path, and neither by
- # another in-root identity mechanism. Merging them would over-report one and under-report
- # the other, and the follow-up would be chosen off the wrong number.
- LOG.info(
- "taskv3 observe omitted component controls it could not name",
- omitted_in_components=omitted_in_components,
- omitted_anonymous=omitted_anonymous,
- omitted_duplicated=omitted_duplicated,
- omitted_unverifiable=omitted_unverifiable,
- omitted_unsafe=omitted_unsafe,
- omitted_budget=omitted_budget,
- listed=len(elements),
- )
# Compact rendering keeps the persistent-conversation prefix small (cost is ~linear in it).
raw_url = _mask_refs(str(data.get("url") or ""))
# Stripping forgery chars is not truncation: only the cap changes what the URL points at, so
@@ -13313,12 +13282,10 @@ def build_browser_tools(
# a page that genuinely has no controls.
lines.append(f"note: {dropped} element(s) could not be described and are not listed below")
if data.get("unreadableRoot"):
- # The condition itself, not just its consequences: a root that throws makes uniqueness
- # unverifiable everywhere, so unnamed elements are dropped rather than given a name we
- # could not check. Left unsaid, that reads as a page with fewer controls than it has.
+ # The condition itself, not just its consequences: a root that throws makes selector
+ # uniqueness unverifiable everywhere on the page.
lines.append(
- "note: part of this page could not be queried, so selector uniqueness could not be "
- "verified here; elements we could not name are not listed"
+ "note: part of this page could not be queried, so selector uniqueness could not be verified here"
)
if data.get("textTruncated"):
# Every other cap in this payload names itself. This one binds far more often now that
@@ -13355,31 +13322,6 @@ def build_browser_tools(
lines.append(
f"note: {count}more pointer-styled element(s) without a control role are not listed: {'; '.join(why)}"
)
- if omitted_in_components:
- # A statement about OUR limitation, not about the page: naming these would mean writing
- # into the component's own root, which provokes the re-render that destroys the mark. No
- # remedy is offered because there is none the model can perform — re-observing returns
- # the same omission. Split by cause: saying "no id of their own" about a control that has
- # one, and whose id is merely reused by a sibling instance, tells the model something
- # false about the page to describe a limitation of ours.
- why = []
- if omitted_anonymous:
- why.append(f"{omitted_anonymous} have no id, name or data-testid of their own")
- if omitted_duplicated:
- why.append(
- f"{omitted_duplicated} have one that is reused by another instance of the same "
- "component, so it does not identify a single element"
- )
- if omitted_unverifiable:
- why.append(f"{omitted_unverifiable} could not be verified because a component root was unreadable")
- if omitted_unsafe:
- why.append(f"{omitted_unsafe} carry an identifier we cannot render safely")
- if omitted_budget:
- why.append(f"{omitted_budget} exceeded the naming budget for this page")
- lines.append(
- f"note: {omitted_in_components} control(s) inside components are not listed because we "
- f"have no selector that identifies them: {'; '.join(why)}"
- )
bodies: list[str] = []
@@ -13556,7 +13498,7 @@ def build_browser_tools(
"phantom_dropped": phantom_dropped,
"iframes_in_component_roots": iframe_info.get("inComponents") or 0,
"undiscovered_roots": data.get("undiscoveredRoots") or 0,
- "omitted_unnameable": omitted_in_components,
+ "listed_by_handle_only": sum(1 for e in elements if not e.get("selector")),
"invalid_fields": sum(1 for e in elements if e.get("invalid")),
"markers_minted": data.get("markersMinted") or 0,
"markers_reused": data.get("markersReused") or 0,
@@ -21816,16 +21758,20 @@ def build_browser_tools(
# act time on count()==1 with no comparison of the resolved node to what the model was
# shown -- the same class, with none of the three checks here. Pinned by
# test_a_coupled_transposition_is_the_one_form_still_open_and_this_pins_it.
- if not remembered:
+ #
+ # A ref listed by its handle alone is held to its child-position path instead. That path is
+ # never used to find a node to act on, so a replaced node still goes stale.
+ binding = remembered or str(entry.get("binding") or "")
+ if not binding:
return True
try:
- if await _holders(realm, f"{remembered}{act_selector}") == 1:
+ if await _holders(realm, f"{binding}{act_selector}") == 1:
return True
# A remembered selector that names NOTHING is simply stale -- a marker the page moved
# or rolled back, an id it dropped. It is not evidence about the handle, which is live
# and alone, so the handle stands. Only a selector naming something that is NOT this
# handle is evidence of a swap.
- return await _holders(realm, remembered) == 0
+ return await _holders(realm, binding) == 0
except Exception:
return False
@@ -22103,7 +22049,9 @@ def build_browser_tools(
# In place, for the same reason act-by-mark does it: the persisted action's element_id,
# the submit watch, the repeat guard's key and the nudge all read this dict AFTER dispatch.
args["selector"] = resolved
- durable = str((_observe_manifest.get(ref) or {}).get("selector") or "")
+ _entry = _observe_manifest.get(ref) or {}
+ # A handle-only ref hands back its child-position path; nothing that reads it acts on it.
+ durable = str(_entry.get("selector") or "") or str(_entry.get("binding") or "")
# Handed on for the same reason the typed-selector branch does it: the ref was validated
# against THIS page, and letting preflight resolve again lets a popup that became the working
# page in between become the one acted on. Cleared in the finally, so it cannot outlive the
diff --git a/tests/unit/test_taskv3_loop.py b/tests/unit/test_taskv3_loop.py
index d1b618d03..085be9c43 100644
--- a/tests/unit/test_taskv3_loop.py
+++ b/tests/unit/test_taskv3_loop.py
@@ -5346,7 +5346,7 @@ _OBSERVE_SUMMARY_FIELDS = (
"hidden_listed",
"iframes_in_component_roots",
"undiscovered_roots",
- "omitted_unnameable",
+ "listed_by_handle_only",
"invalid_fields",
"markers_minted",
"markers_reused",
diff --git a/tests/unit/test_taskv3_tools.py b/tests/unit/test_taskv3_tools.py
index 8190be915..aa5ce1609 100644
--- a/tests/unit/test_taskv3_tools.py
+++ b/tests/unit/test_taskv3_tools.py
@@ -3657,7 +3657,7 @@ async def test_observe_result_carries_count_only_summary_for_the_call_record() -
"phantom_dropped",
"iframes_in_component_roots",
"undiscovered_roots",
- "omitted_unnameable",
+ "listed_by_handle_only",
"invalid_fields",
"markers_minted",
"markers_reused",
@@ -3695,7 +3695,7 @@ async def test_observe_result_carries_count_only_summary_for_the_call_record() -
assert summary["hidden_listed"] == 1
assert summary["iframes_in_component_roots"] == 1
assert summary["text_dropped"] > 0
- assert summary["omitted_unnameable"] == 1
+ assert summary["listed_by_handle_only"] == 1
assert summary["markers_minted"] == 1 and summary["markers_reused"] == 0
# The census rides this same record, so it is pinned to values here rather than to key names:
# `set_content` leaves the page on about:blank, where `location.origin` is "null" and the
@@ -13940,10 +13940,9 @@ class _AliasTypeaheadPage(_FakeAliasPage):
@_skip_no_browser
@pytest.mark.asyncio
-async def test_observe_reports_a_control_past_the_anchoring_depth_as_our_budget() -> None:
+async def test_a_control_past_the_anchoring_depth_is_listed_and_clickable() -> None:
# Ten anonymous hosts deep, each inside the previous one's root: the chain to a markable host
- # exceeds the recursion bound. That is our limit, not a fact about the control, and the note
- # says so instead of claiming the control has no identity.
+ # exceeds the recursion bound, so no selector names the control and only its handle reaches it.
async with _live_page(
"""<x-l0></x-l0>
<script>
@@ -13953,15 +13952,16 @@ async def test_observe_reports_a_control_past_the_anchoring_depth_as_our_budget(
r.innerHTML = '<x-l' + d + '></x-l' + d + '>';
host = r.querySelector('x-l' + d);
}
- host.attachShadow({mode: 'open'}).innerHTML = '<button type="button" style="width:80px;height:20px">Deep</button>';
+ host.attachShadow({mode: 'open'}).innerHTML =
+ '<button type="button" onclick="window.deepHit = true" style="width:80px;height:20px">Deep</button>';
</script>"""
) as page:
tools = build_browser_tools(_fixed_page_provider(page))
r = await _tool(tools, "observe").handler({})
assert r.status == "ok"
- assert "Deep" not in r.content, r.content
- assert "1 exceeded the naming budget for this page" in r.content, r.content
- assert "have no id, name or data-testid" not in r.content, r.content
+ clicked = await _tool(tools, "click").handler({"selector": _ref_line(r.content, "'Deep'")})
+ assert clicked.status == "ok", clicked.content
+ assert await page.evaluate("() => window.deepHit") is True
@_skip_no_browser
@@ -14239,33 +14239,33 @@ async def test_observe_lists_skinned_checkbox_with_visible_label() -> None:
@_skip_no_browser
@pytest.mark.asyncio
-async def test_observe_reports_a_reused_component_id_as_reused_not_as_anonymous() -> None:
+async def test_a_reused_component_id_is_listed_and_typed_per_instance() -> None:
# A design system hard-codes the same internal id in every instance, because shadow encapsulation
# scopes ids to their own root, so both instances resolve to a cross-root count of 2. Anchoring on
# the host recovers that whenever something under the host singles the control out; here each
- # instance slots a light-DOM twin of its own control beside it, so nothing does, which is what
- # leaves the controls unnamed and keeps this the case the note has to describe correctly. The
- # note must say "reused", not "no id of their own", because saying the latter about a control
- # that DOES have an id misdescribes the page.
+ # instance slots a light-DOM twin of its own control beside it, so nothing does, and each inner
+ # control is reachable only through its own handle.
async with _live_page(
"""<ds-form-field><input id="first-name" name="firstName" style="width:80px;height:20px"></ds-form-field>
<ds-form-field><input id="first-name" name="firstName" style="width:80px;height:20px"></ds-form-field>
<script>
- for (const h of document.querySelectorAll('ds-form-field')) {
- h.attachShadow({mode: 'open'}).innerHTML =
- '<slot></slot><input id="first-name" name="firstName" style="width:80px;height:20px">';
- }
+ document.querySelectorAll('ds-form-field').forEach((h, i) => {
+ h.attachShadow({mode: 'open'}).innerHTML = '<slot></slot><input id="first-name" name="firstName"'
+ + ' placeholder="Inner ' + (i + 1) + '" style="width:80px;height:20px">';
+ });
</script>"""
) as page:
tools = build_browser_tools(_fixed_page_provider(page))
r = await _tool(tools, "observe").handler({})
assert "#first-name" not in r.content, "a reused in-component id must not be listed as a selector"
- assert (
- "note: 2 control(s) inside components are not listed because we have no selector that "
- "identifies them: 2 have one that is reused by another instance of the same component, "
- "so it does not identify a single element"
- ) in r.content
- assert "have no id, name or data-testid of their own" not in r.content, r.content
+ assert _ref_line(r.content, "'Inner 1'")
+ typed = await _tool(tools, "type").handler({"selector": _ref_line(r.content, "'Inner 2'"), "text": "SECOND"})
+ assert typed.status == "ok", typed.content
+ values = await page.evaluate(
+ "() => Array.from(document.querySelectorAll('ds-form-field'))"
+ ".flatMap((h) => [h.querySelector('input').value, h.shadowRoot.querySelector('input').value])"
+ )
+ assert values == ["", "", "", "SECOND"]
# No <label> anywhere, deliberately: an earlier version of this fix keyed on "does the field have a
@@ -19109,8 +19109,9 @@ async def test_a_root_only_the_marker_gather_reaches_is_still_disclosed() -> Non
r = await _tool(tools, "observe").handler({})
# Armed only on the no-mint route: a minted marker re-checks uniqueness after the write and
# would reach the throwing root by that path instead, disclosing it for the wrong reason.
- assert "[data-tv3=" not in r.content, r.content
- assert "2 have one that is reused by another instance" in r.content, r.content
+ assert r.data["summary"]["listed_by_handle_only"] == 2, r.data["summary"]
+ assert r.data["summary"]["markers_minted"] == 0, r.data["summary"]
+ assert len(re.findall(r"^ref=\d+ .*'Go'$", r.content, re.M)) == 2, r.content
assert "part of this page could not be queried" in r.content, r.content
@@ -19569,8 +19570,9 @@ async def test_a_duplicated_identity_is_detected_however_deeply_it_is_nested() -
}
host.attachShadow({mode: 'open'}).innerHTML =
'<style>button{display:block;width:120px;height:22px}</style>'
- + '<button id="ctrl">' + text + '</button>';
+ + '<button id="ctrl" onclick="window.hits.push(this.textContent)">' + text + '</button>';
}
+ window.hits = [];
nest('deep', 12, 'DECOY');
nest('shallow', 2, 'INTENDED');
</script>"""
@@ -19584,9 +19586,11 @@ async def test_a_duplicated_identity_is_detected_however_deeply_it_is_nested() -
assert await page.locator(sel).count() == 1, (
f"{sel!r} denotes {await page.locator(sel).count()}:\n{r.content}"
)
- # Named would be the wrong-element click; counted as a duplicate is the honest answer.
+ # Named would be the wrong-element click; each is reached through its own handle instead.
assert "#ctrl" not in r.content, r.content
- assert "2 have one that is reused by another instance" in r.content, r.content
+ clicked = await _tool(tools, "click").handler({"selector": _ref_line(r.content, "'INTENDED'")})
+ assert clicked.status == "ok", clicked.content
+ assert await page.evaluate("() => window.hits") == ["INTENDED"]
@_skip_no_browser
@@ -20070,42 +20074,39 @@ async def test_heading_digest_is_not_fed_by_a_named_getter_host() -> None:
@_skip_no_browser
@pytest.mark.asyncio
-async def test_observe_discloses_controls_it_cannot_name_inside_components() -> None:
+async def test_observe_lists_a_component_control_no_selector_names_by_its_handle() -> None:
# We do not write a marker inside a shadow root, so a component's control with no id or name of
# its own is named through its host -- unless nothing under the host singles it out: here the
- # host slots a light-DOM twin beside its own button, so every host-anchored tail matches both.
- # The omission is disclosed rather than letting the component read as empty — and the note
- # states OUR limitation, not a claim about the page, and offers no remedy, because re-observing
- # returns the same omission.
+ # host slots a light-DOM twin beside its own button, so every host-anchored tail matches both,
+ # and the inner button is listed by its live handle alone.
async with _live_page(
"""<button id="light-ok">Light Button</button>
- <x-anon id="a"><button id="twin" type="button" style="width:80px;height:20px">Twin</button></x-anon>
+ <x-anon id="a"><button id="twin" type="button" onclick="window.hits.push('Twin')"
+ style="width:80px;height:20px">Twin</button></x-anon>
<script>
- document.getElementById('a').attachShadow({mode:'open'}).innerHTML =
- '<slot></slot><button type="button" style="width:80px;height:20px">Inner Go</button>';
+ window.hits = [];
+ document.getElementById('a').attachShadow({mode:'open'}).innerHTML = '<slot></slot><button type="button"'
+ + ' onclick="window.hits.push(this.textContent)" style="width:80px;height:20px">Inner Go</button>';
</script>"""
) as page:
tools = build_browser_tools(_fixed_page_provider(page))
first = await _tool(tools, "observe").handler({})
assert first.status == "ok"
assert _ref_line(first.content, "Light Button")
- assert "Inner Go" not in first.content
# "no marker may be written inside a component" is a property of the internal selector mint,
# no longer anything the digest shows the model; read the raw per-element selectors.
assert not any(e["selector"].startswith('[data-tv3="') for e in (await _observe_data(page))["elements"]), (
"no marker may be written inside a component"
)
- assert (
- "1 control(s) inside components are not listed because we have no selector that "
- "identifies them: 1 have no id, name or data-testid of their own"
- ) in first.content
- assert "re-observe" not in first.content, "no remedy is offered because none exists"
# Byte-identical across turns: the loop's perception-stall terminator compares whole
# payloads, and a churning marker is what previously disabled it on exactly this page.
again = await _tool(tools, "observe").handler({})
assert first.content == again.content
+ clicked = await _tool(tools, "click").handler({"selector": _ref_line(again.content, "Inner Go")})
+ assert clicked.status == "ok", clicked.content
+ assert await page.evaluate("() => window.hits") == ["Inner Go"]
- # And a component whose control HAS an id is listed as normal, with no note at all.
+ # And a component whose control HAS an id is named by it, not listed by handle.
async with _live_page(
"""<x-named id="n"></x-named>
<script>
@@ -20116,43 +20117,86 @@ async def test_observe_discloses_controls_it_cannot_name_inside_components() ->
tools = build_browser_tools(_fixed_page_provider(page))
r = await _tool(tools, "observe").handler({})
assert _ref_line(r.content, "Named")
- assert "not listed because we have no selector" not in r.content
+ assert r.data["summary"]["listed_by_handle_only"] == 0
+
+
+_ANONYMOUS_MENU_VIEWER_HTML = """<x-viewer id="viewer"></x-viewer>
+<script>
+window.__clicked = [];
+const root = document.getElementById('viewer').attachShadow({mode: 'open'});
+root.innerHTML = '<div class="panel"></div><div class="toolbar">' +
+ ['Zoom out', 'Zoom in', 'Print', 'Menu'].map((n) =>
+ '<div><button type="button" class="btn ui" aria-label="' + n + '" style="width:40px;height:24px"></button></div>'
+ ).join('') + '</div>';
+const panel = root.querySelector('.panel');
+const menu = root.querySelector('button[aria-label="Menu"]');
+menu.addEventListener('click', () => {
+ if (!menu.classList.toggle('active')) { panel.innerHTML = ''; return; }
+ panel.innerHTML = ['Download', 'Save As'].map((t) =>
+ '<div><button type="button"><svg aria-hidden="true" width="10" height="10"></svg><span>' + t + '</span></button></div>'
+ ).join('');
+ for (const b of panel.querySelectorAll('button')) {
+ b.addEventListener('click', () => { window.__clicked.push(b.textContent); menu.click(); });
+ }
+});
+</script>"""
@_skip_no_browser
@pytest.mark.asyncio
-async def test_observe_logs_omission_only_when_something_was_actually_omitted() -> None:
- # The LOG.info call is gated on a non-zero count; pin both directions, not just the firing case —
- # a page that omits nothing must not emit this event at all. The log is also the instrument this
- # limitation will be sized by in production, so its counts must equal the note's own counts.
- event = "taskv3 observe omitted component controls it could not name"
-
- async with _live_page("<button id='go'>Go</button>") as page:
+async def test_observe_lists_anonymous_menu_rows_inside_a_component_by_handle() -> None:
+ # Every toolbar button shares its tag, type, class and position in its own wrapper, and the rows
+ # differ only by text, so no selector scoped under the host names any of them.
+ async with _live_page(_ANONYMOUS_MENU_VIEWER_HTML, init_script=_WRITE_PROBE_JS) as page:
tools = build_browser_tools(_fixed_page_provider(page))
- with capture_logs() as logs:
- await _tool(tools, "observe").handler({})
- assert not [entry for entry in logs if entry["event"] == event], logs
+ observe, click = _tool(tools, "observe").handler, _tool(tools, "click").handler
+ closed = await observe({})
+ menu = _ref_line(closed.content, "'Menu'")
+ assert (await observe({})).content == closed.content
+ residue = await page.evaluate(
+ "() => Array.from(document.getElementById('viewer').shadowRoot.querySelectorAll('*'))"
+ ".flatMap((e) => e.getAttributeNames().filter((n) => n.startsWith('data-tv3')))"
+ )
+ assert residue == []
+ assert not [w for w in await page.evaluate("() => window.__tv3_writes") if w["inRoot"] is not False]
+
+ assert (await click({"selector": menu})).status == "ok"
+ opened = await observe({})
+ assert _ref_line(opened.content, "'Menu'") == menu, opened.content
+ download = _ref_line(opened.content, "'Download'")
+ assert _ref_line(opened.content, "'Save As'") != download
+
+ hit = await click({"selector": download})
+ assert hit.status == "ok", hit.content
+ assert await page.evaluate("() => window.__clicked") == ["Download"]
+
+ gone = await click({"selector": download})
+ assert gone.error_class == "stale_ref", gone.content
+ assert await page.evaluate("() => window.__clicked") == ["Download"]
+
+@_skip_no_browser
+async def test_a_handle_only_control_survives_a_walk_the_page_mutated() -> None:
+ # The page answers our light-DOM marker write with a change of its own, so every record is
+ # re-checked after the walk; one with no selector has nothing to re-resolve and must not read as
+ # an unreadable root.
async with _live_page(
- """<x-anon id="a"><button id="twin" type="button" style="width:80px;height:20px">Twin</button></x-anon>
+ """<x-anon id="a"><button type="button" style="width:80px;height:20px">Twin</button></x-anon>
<script>
+ new MutationObserver((recs) => {
+ if (recs.some((m) => m.attributeName === 'data-tv3')) document.body.setAttribute('data-seen', '1');
+ }).observe(document.body, {subtree: true, attributes: true});
document.getElementById('a').attachShadow({mode:'open'}).innerHTML =
'<slot></slot><button type="button" style="width:80px;height:20px">Inner Go</button>';
</script>"""
) as page:
tools = build_browser_tools(_fixed_page_provider(page))
- with capture_logs() as logs:
- r = await _tool(tools, "observe").handler({})
- omissions = [entry for entry in logs if entry["event"] == event]
- assert len(omissions) == 1, logs
- entry = omissions[0]
- assert entry["omitted_anonymous"] == 1
- assert entry["omitted_duplicated"] == 0
- assert entry["omitted_unverifiable"] == 0
- assert entry["omitted_unsafe"] == 0
- assert entry["omitted_in_components"] == 1
- note = next(ln for ln in r.content.splitlines() if "not listed because we have no selector" in ln)
- assert f"{entry['omitted_anonymous']} have no id, name or data-testid of their own" in note
+ r = await _tool(tools, "observe").handler({})
+ assert await page.evaluate("() => document.body.getAttribute('data-seen')") == "1"
+ assert _ref_line(r.content, "Inner Go")
+ assert r.data["summary"]["listed_by_handle_only"] == 1, r.data["summary"]
+ assert "could not be verified" not in r.content, r.content
@_skip_no_browser
@@ -20459,8 +20503,7 @@ async def test_one_unreadable_root_does_not_cost_every_selector_on_the_page() ->
# The condition itself must be disclosed too, not just its consequence (markers instead of
# ids) — a reader who never sees this note has no way to tell the page just has few ids.
assert (
- "note: part of this page could not be queried, so selector uniqueness could not be "
- "verified here; elements we could not name are not listed"
+ "note: part of this page could not be queried, so selector uniqueness could not be verified here\n"
) in first.content
@@ -20569,16 +20612,19 @@ async def test_select_option_drives_a_hidden_native_select_inside_an_open_shadow
)
-# Two dropzones of the same component reuse one id, so neither is nameable and both are dropped
-# AFTER the styled-proxy gate already counted them. The note must count what it listed, not what it
-# retained, or it reports controls the model cannot find any line for.
+# Dropzones of one component that reuse an internal id. The note must count what it listed, not
+# what it retained, or it reports controls the model cannot find any line for.
_SHARED_ID_DROPZONES_HTML = """
<!doctype html><html><body>
<ds-drop id="dz-single"></ds-drop>
<ds-drop id="dz-a"></ds-drop>
<ds-drop id="dz-b"></ds-drop>
<ds-drop class="anon"></ds-drop>
+ <label style="display:inline-block;width:240px;height:40px">Upload references<input type="file" class="refused" style="position:absolute;width:0;height:0;opacity:0"></label>
<script>
+ // A light-DOM control that swallows our marker write passes the hidden-native gate and is then
+ // dropped unnamed, so it is the one control retained but never listed.
+ document.querySelector('input.refused').setAttribute = function () {};
// An immediate-upload form: attaching a file dispatches an upload request. Absolute URL so the
// request is dispatched (and observed) even though it fails against no server.
function upl() { fetch('https://api.example.test/upload', {method: 'POST', body: new FormData()}).catch(function () {}); }
@@ -20594,8 +20640,7 @@ _SHARED_ID_DROPZONES_HTML = """
mk('dz-a', 'resume', 'Upload resume');
mk('dz-b', 'resume', 'Upload cover letter');
// An instance that slots a light-DOM twin of its own control beside it, so nothing under the
- // host singles the inner one out: it stays retained-but-unlisted and the note keeps having
- // something to count that the listing does not.
+ // host singles the inner one out and only its live handle reaches it.
var anon = document.querySelector('ds-drop.anon');
anon.innerHTML = '<input type="file" id="portfolio" style="position:absolute;width:0;height:0;opacity:0">';
anon.attachShadow({mode: 'open'}).innerHTML = '<slot></slot>' +
@@ -20614,12 +20659,10 @@ async def test_hidden_native_note_counts_only_the_controls_it_actually_listed()
r = await _tool(tools, "observe").handler({})
assert r.status == "ok"
tagged = [ln for ln in r.content.splitlines() if "[hidden-native" in ln and not ln.startswith("note:")]
- assert len(tagged) == 3, r.content
- assert "note: 3 native control(s) hidden behind styled proxies" in r.content, r.content
- # The one that nothing under its host singles out stays unlisted, and is said to be dropped
- # rather than counted as listed: the note claims what it printed, not what it walked.
- assert "reused by another instance of the same component" in r.content
- assert "portfolio" not in r.content, r.content
+ assert len(tagged) == 4, r.content
+ assert "note: 4 native control(s) hidden behind styled proxies" in r.content, r.content
+ assert any("'Upload portfolio'" in ln for ln in tagged), r.content
+ assert "Upload references" not in r.content, r.content
# Two instances of one component, each holding a control under the same id. Shadow encapsulation
@@ -21026,9 +21069,8 @@ async def test_verify_commit_reads_a_shadow_hosted_field() -> None:
async def test_a_shadow_selector_is_never_handed_out_when_it_would_denote_a_sibling() -> None:
# Unique is not enough, it must be THIS element, and that has to hold on the pierced path too: a
# NULL id folds to U+FFFD when escaped, so a selector built from it denotes a sibling carrying
- # the real U+FFFD id. observe declines to name the first control and says why, rather than
- # handing out a selector that resolves to the second -- and the sibling it does name still
- # resolves to itself.
+ # the real U+FFFD id. observe declines to name the first control, rather than handing out a
+ # selector that resolves to the second, and reaches it by its own handle instead.
async with _live_page(
"""<x-host id="h"></x-host><script>
var r = document.getElementById('h').attachShadow({mode: 'open'});
@@ -21045,11 +21087,9 @@ async def test_a_shadow_selector_is_never_handed_out_when_it_would_denote_a_sibl
) as page:
tools = build_browser_tools(_fixed_page_provider(page))
r = await _tool(tools, "observe").handler({})
- assert "Real Control" not in r.content, r.content
- assert "identifier we cannot render safely" in r.content, r.content
- ref = _ref_line(r.content, "Decoy")
- text = await _tool(tools, "get_html").handler({"selector": ref, "format": "text"})
- assert text.status == "ok" and text.content.strip() == "Decoy", text.content
+ for name in ("Real Control", "Decoy"):
+ text = await _tool(tools, "get_html").handler({"selector": _ref_line(r.content, name), "format": "text"})
+ assert text.status == "ok" and text.content.strip() == name, text.content
# The seam between the two shipped halves: a styled listbox proxy AND the hidden native it writes
@@ -21260,30 +21300,44 @@ async def test_the_address_observe_prints_is_byte_identical_to_the_argument_the_
@_skip_no_browser
@pytest.mark.asyncio
-async def test_a_control_replaced_by_the_act_leaves_bookkeeping_an_address_that_re_resolves() -> None:
[email protected]("in_root", [False, True], ids=["named", "handle_only"])
+async def test_a_control_replaced_by_the_act_leaves_bookkeeping_an_address_that_re_resolves(in_root: bool) -> None:
# The submit watch's in-flight probe, the repeat guard's key and the nudge all read the caller's
# args AFTER dispatch, and turns later. The act token is a stamp on ONE node, so a control the
# page replaces as it acts -- a submit button swapped for its "Submitting" version -- carries it
# away; the probe fails open on a selector that resolves to nothing, which is exactly how a
# submission still in flight reads as settled. What those readers get back has to re-resolve.
- async with _live_page(
- """<button id="send" style="width:120px;height:24px">Send</button>
- <script>
- window.hits = [];
- document.getElementById('send').addEventListener('click', () => {
+ swap = """function () {
window.hits.push('send');
- const old = document.getElementById('send');
const fresh = document.createElement('button');
- fresh.id = 'send';
+ fresh.type = 'button';
+ if (this.id) fresh.id = this.id;
fresh.textContent = 'Submitting';
fresh.style.cssText = 'width:120px;height:24px';
- old.parentNode.insertBefore(fresh, old);
- old.remove();
- });
+ this.parentNode.insertBefore(fresh, this);
+ this.remove();
+ }"""
+ page_html = (
+ f"""<x-form id="f"></x-form>
+ <script>
+ window.hits = [];
+ const root = document.getElementById('f').attachShadow({{mode: 'open'}});
+ root.innerHTML = '<div><button type="button" style="width:120px;height:24px">Send</button></div>'
+ + '<div><button type="button" style="width:120px;height:24px">Cancel</button></div>';
+ root.querySelector('button').addEventListener('click', {swap});
</script>"""
- ) as page:
+ if in_root
+ else f"""<button id="send" style="width:120px;height:24px">Send</button>
+ <script>
+ window.hits = [];
+ document.getElementById('send').addEventListener('click', {swap});
+ </script>"""
+ )
+ async with _live_page(page_html) as page:
tools = build_browser_tools(_fixed_page_provider(page))
r = await _tool(tools, "observe").handler({})
+ if in_root:
+ assert r.data["summary"]["listed_by_handle_only"] == 2, r.data["summary"]
args = {"selector": _ref_line(r.content, "'Send'")}
clicked = await _tool(tools, "click").handler(args)
@@ -21461,12 +21515,24 @@ async def test_a_coupled_transposition_is_the_one_form_still_open_and_this_pins_
@_skip_no_browser
@pytest.mark.asyncio
@pytest.mark.parametrize("attack", sorted(_PAIRING_ATTACKS), ids=sorted(_PAIRING_ATTACKS))
-async def test_no_poisoned_dispatch_can_pair_a_digest_line_with_a_decoy_element(attack: str) -> None:
[email protected]("in_root", [False, True], ids=["named", "handle_only"])
+async def test_no_poisoned_dispatch_can_pair_a_digest_line_with_a_decoy_element(attack: str, in_root: bool) -> None:
# The perceive->act identity invariant: whatever the page does to the intrinsics, the element the
# engine acts on is the one the line the model read described. Failing closed is allowed -- acting
# on Beta is not, because that is a wrong-element commit the PAGE chose.
- async with _live_page(
- """<button id="alpha" style="width:90px;height:22px">Alpha</button>
+ page_html = (
+ """<x-pair id="p"></x-pair>
+ <script>
+ window.hits = [];
+ const root = document.getElementById('p').attachShadow({mode: 'open'});
+ root.innerHTML = '<div><button type="button" style="width:90px;height:22px">Alpha</button></div>'
+ + '<div><button type="button" style="width:90px;height:22px">Beta</button></div>';
+ for (const b of root.querySelectorAll('button'))
+ b.addEventListener('click', (e) => window.hits.push(e.currentTarget.textContent.toLowerCase()));
+ const beta = root.querySelectorAll('button')[1];
+ """
+ if in_root
+ else """<button id="alpha" style="width:90px;height:22px">Alpha</button>
<button id="beta" style="width:90px;height:22px">Beta</button>
<script>
window.hits = [];
@@ -21474,12 +21540,12 @@ async def test_no_poisoned_dispatch_can_pair_a_digest_line_with_a_decoy_element(
b.addEventListener('click', (e) => window.hits.push(e.currentTarget.id));
const beta = document.getElementById('beta');
"""
- + _PAIRING_ATTACKS[attack]
- + """
- </script>"""
- ) as page:
+ )
+ async with _live_page(page_html + _PAIRING_ATTACKS[attack] + "\n</script>") as page:
tools = build_browser_tools(_fixed_page_provider(page))
r = await _tool(tools, "observe").handler({})
+ if in_root:
+ assert r.data["summary"]["listed_by_handle_only"] == 2, r.data["summary"]
# Non-vacuous: the attack must not simply hide Alpha, or there would be nothing to mis-address.
alpha_ref = _ref_line(r.content, "'Alpha'")
@@ -21648,7 +21714,7 @@ async def test_a_host_anchored_control_is_driven_rather_than_reported_gone() ->
tools = build_browser_tools(_fixed_page_provider(page))
r = await _tool(tools, "observe").handler({})
listed = [ln for ln in r.content.splitlines() if "[hidden-native" in ln and not ln.startswith("note:")]
- assert len(listed) == 3, r.content
+ assert len(listed) == 4, r.content
# dz-b's own dropzone, distinguished from dz-a's identical-shaped one by its label.
chosen = _ref_line(r.content, "Upload cover letter")
assert any("hidden-native" in ln for ln in listed if chosen in ln), r.content
@@ -21682,15 +21748,14 @@ async def test_a_host_anchored_selector_counts_what_the_host_slots_as_well_as_wh
r = await _tool(tools, "observe").handler({})
# Armed on the DIGEST too, not only on the fixture: the property below is quantified over what
# was actually listed, so an empty or collapsed digest would satisfy it without protecting
- # anything. The light-DOM twin is still named, and the one under the host is refused AND said
- # to be.
- assert re.search(r"\((\d+) interactive elements\)", r.content).group(1) == "1", r.content
- assert "reused by another instance of the same component" in r.content, r.content
- # Whatever selector the internal mint fell back to for the one control it DID list (no longer
- # anything the digest shows the model), it must genuinely denote only that element.
+ # anything. The light-DOM twin is still named, and the one under the host is listed with no
+ # selector at all rather than an ambiguous one.
+ assert re.search(r"\((\d+) interactive elements\)", r.content).group(1) == "2", r.content
+ # Whatever selector the internal mint fell back to for a control it named (no longer anything
+ # the digest shows the model), it must genuinely denote only that element.
selectors = [e["selector"] for e in (await _observe_data(page))["elements"]]
- assert len(selectors) == 1, selectors
- for sel in selectors:
+ assert len(selectors) == 2 and selectors.count("") == 1, selectors
+ for sel in filter(None, selectors):
assert await page.locator(sel).count() == 1, f"{sel} denotes more than one element: {selectors}"