Skip to content

Automate browser based workflows with AI

Name the challenge frame inside a covering layer instead of telling the agent to dismiss it (SKY-16365) (#8603)

Andrew Neilsonce62b6313379
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.py
index 6d402422d..9f3caf936 100644
--- a/skyvern/forge/agent.py
+++ b/skyvern/forge/agent.py
@@ -498,7 +498,7 @@ _PAGE_FINGERPRINT_PROBE_JS = (
# page change and resets the stall counter -- on a frozen page the model works through
# mark after mark, which is precisely the run the stall detector exists to catch.
# OTP bookkeeping attributes must also be ignored after masking so stamps do not count as page progress.
- ' const scrub = (s) => s.replace(/ data-(?:tv3-act|skyvern-otp-[^\\s=]+)="[^"]*"/gi, \'\');'
+ ' const scrub = (s) => s.replace(/ data-(?:tv3-act|tv3-cover|skyvern-otp-[^\\s=]+)="[^"]*"/gi, \'\');'
" const walk = (root) => { h = mix(scrub(otpSafeHtml(root, true)), h);"
" const all = root.querySelectorAll('*'); elems += all.length;"
" for (const el of root.querySelectorAll('input, textarea, select'))"
diff --git a/skyvern/forge/taskv3/loop.py b/skyvern/forge/taskv3/loop.py
index 10b3db1a3..cbffe40c4 100644
--- a/skyvern/forge/taskv3/loop.py
+++ b/skyvern/forge/taskv3/loop.py
@@ -108,11 +108,13 @@ ToolOkClass = Literal[
"attached_no_activity",
]
-# Which of the three `covered` messages the model actually got. All three are one `tool_error_class`,
-# so without this the split is only recoverable by pulling step archives and classifying the prose.
+# Which `covered` message the model actually got. They are one `tool_error_class`, so without this
+# the split is only recoverable by pulling step archives and classifying the prose.
CoveredBranch = Literal[
# The layer was named and its controls enumerated into the message.
"named",
+ # The layer holds a challenge frame, so the message names it and omits the dismissal sentence.
+ "challenge",
# No layer to name: the message says only that something is on top of the field.
"unnamed",
# The layer intercepts the pointer but paints nothing, so it is absent from the screenshot.
diff --git a/skyvern/forge/taskv3/tools.py b/skyvern/forge/taskv3/tools.py
index f82d6914e..527e5f0e0 100644
--- a/skyvern/forge/taskv3/tools.py
+++ b/skyvern/forge/taskv3/tools.py
@@ -13,6 +13,7 @@ alongside `make_finish_tool()`.
from __future__ import annotations
import asyncio
+import contextlib
import dataclasses
import io
import json
@@ -195,6 +196,22 @@ _MARKER_ATTR_OPEN = 'data-tv3="'
# is what separates ours from theirs.
_MINTED_MARKER_VALUE_RE = re.compile(r"\At\d+(?:-\d+)?\Z")
+_CHALLENGE_VENDOR_FRAME_URL = re.compile(CHALLENGE_VENDOR_SIGNATURE, re.IGNORECASE)
+
+# Containment is walked from the frame's host upward because the probe runs in an isolated world and
+# its shadow walk pierces only OPEN roots -- neither sees a widget iframe mounted inside a closed one.
+_COVER_ANCESTOR_WALK_LIMIT = 40
+_HOST_INSIDE_COVER_JS = r"""(host, limit) => {
+ let n = host;
+ for (let depth = 0; n && depth < limit; depth++) {
+ try {
+ if (n.nodeType === 1 && n.hasAttribute('data-tv3-cover')) return true;
+ n = n.parentElement || (n.getRootNode() || {}).host || null;
+ } catch (e) { return false; }
+ }
+ return false;
+}"""
+
def _marker_head_fragment_len(content: str, offset: int) -> int:
"""How many characters at `offset` are the tail of a marker attribute the cut opened, or 0.
@@ -3372,6 +3389,8 @@ _TYPE_TARGET_PROBE_JS = (
"""
+ _NATIVE_LABEL_JS
+ r"""
+ try { _q.all('[data-tv3-cover]').forEach((n) => n.removeAttribute('data-tv3-cover')); } catch (e) { /* best-effort */ }
+
// A host-anchored selector's two halves straddle a shadow boundary, so no single root can match it
// and a per-root lookup finds nothing -- which would read as "no field here" and skip the check on
// exactly the controls that addressing made reachable. The executor resolves it; take its element.
@@ -4093,6 +4112,7 @@ _TYPE_TARGET_PROBE_JS = (
// because that is where a footer actually lives.
const truncated = allControls.length > 8;
const controls = truncated ? allControls.slice(0, 5).concat(allControls.slice(-3)) : allControls;
+ try { layer.setAttribute('data-tv3-cover', '1'); } catch (e) { /* best-effort */ }
out.occluder = { selector: layerSelector, name: layerName, controls, truncated };
out.occluder.layerKind = layerKind;
// Whether a PERSON would see this layer at all. A leftover consent backdrop still intercepts the
@@ -8732,9 +8752,9 @@ def build_browser_tools(
html = ""
else:
html = mask_otp_values_in_html(await page.content())
- # The click/type reaction gate stamps data-tv3-pre on every visible element; internal bookkeeping
- # that, left in place, costs a third of the truncation budget below in noise.
- html = html.replace(' data-tv3-pre="1"', "")
+ # The click/type reaction gate stamps data-tv3-pre on every visible element and the reach probe
+ # marks the layer it names; bookkeeping that, left in place, costs truncation budget in noise.
+ html = html.replace(' data-tv3-pre="1"', "").replace(' data-tv3-cover="1"', "")
# The act-by-mark tag outlives its call, so unlike the other data-tv3-* bookkeeping it is
# still on the page when this runs. It is a stable handle rather than a dangerous one -- the
# token belongs to the element, not the number -- but it is ours, not the page's, and it
@@ -8796,11 +8816,15 @@ def build_browser_tools(
return parts
def _covered_branch(occluder: dict[str, Any] | None) -> CoveredBranch:
- """Which of the three messages will render. The dispatch below branches on THIS, so the
+ """Which message will render. The dispatch below branches on THIS, so the
recorded branch and the sentence the model got cannot disagree -- including after a new
branch is added, which only has to be expressed here once."""
if not occluder:
return "unnamed"
+ # Ahead of `invisible`: a transparent wall holding a live challenge frame is not a leftover
+ # backdrop, and telling the model to press Escape on it abandons the verification.
+ if str(occluder.get("challengeFrame") or "").strip():
+ return "challenge"
if occluder.get("invisible"):
return "invisible"
return "named"
@@ -8821,8 +8845,9 @@ def build_browser_tools(
also = "" if verb == "clicked" else " — a person could not click it either"
name = str((occluder or {}).get("name") or "").strip()
layer_selector = (occluder or {}).get("selector")
- # Recorded from here, above every return, because this helper is the single place all three
- # messages are built: one call covers click, both typing paths and the two re-raises, and a
+ challenge_frame = str((occluder or {}).get("challengeFrame") or "").strip()
+ # Recorded from here, above every return, because this helper is the single place every
+ # message is built: one call covers click, both typing paths and the two re-raises, and a
# branch added below cannot slip out un-recorded. The layer's NAME is deliberately not
# recorded -- it is page text, and these names carry personal data.
parts = _named_controls(occluder)
@@ -8864,6 +8889,12 @@ def build_browser_tools(
controls_desc = "re-observe — no controls were found on it"
if (occluder or {}).get("truncated"):
controls_desc += "; more controls exist (re-observe to see the rest)"
+ if branch == "challenge":
+ return ToolResult.error(
+ f"{selector} is covered by {layer_desc}, which contains a challenge frame "
+ f"({challenge_frame}), so it cannot be {verb}{also}. Its controls: {controls_desc}.",
+ error_class="covered",
+ )
return ToolResult.error(
f"{selector} is covered by {layer_desc}, so it cannot be {verb}{also}. "
# The layer may be a general modal, not just a consent wall -- these are every control
@@ -9556,7 +9587,9 @@ def build_browser_tools(
# `ownLabel` (the field's own skin-sized label) is the one occluded case that is not a
# block; it falls through to the force-retry below.
if reach_probe and reach_probe.get("occluded") and not reach_probe.get("ownLabel"):
- return _covered_error(selector, reach_probe.get("occluder"), verb="clicked")
+ occluder = reach_probe.get("occluder")
+ await _annotate_challenge_frame(page, _current_page(), occluder)
+ return _covered_error(selector, occluder, verb="clicked")
# A URL is the wrong question (pushState moves it without leaving the page); the token
# planted before the click answers "is this still the same document" exactly.
try:
@@ -9737,6 +9770,44 @@ def build_browser_tools(
await page.hover(selector, timeout=15000)
return ToolResult.ok(f"hovered {selector}")
+ async def _annotate_challenge_frame(realm: Any, top_page: Any, occluder: dict[str, Any] | None) -> None:
+ if not occluder:
+ return
+ try:
+ root = realm.main_frame if realm is top_page else realm
+ for frame in top_page.frames:
+ parsed = urlparse(frame.url or "")
+ if parsed.scheme not in ("http", "https") or not parsed.hostname:
+ continue
+ if not _CHALLENGE_VENDOR_FRAME_URL.search(f"{parsed.scheme}://{parsed.hostname}{parsed.path}"):
+ continue
+ chain = [frame]
+ while chain[-1].parent_frame is not None and chain[-1].parent_frame is not root:
+ chain.append(chain[-1].parent_frame)
+ if chain[-1].parent_frame is not root:
+ continue
+ handles: list[Any] = []
+ try:
+ # is_visible() judges an element only within its own document, so every iframe on the way
+ # from the match up to the acting realm has to render for the challenge to be on screen.
+ rendered = True
+ for link in chain:
+ handles.append(await link.frame_element())
+ if not await handles[-1].is_visible():
+ rendered = False
+ break
+ if rendered and await handles[-1].evaluate(_HOST_INSIDE_COVER_JS, _COVER_ANCESTOR_WALK_LIMIT):
+ occluder["challengeFrame"] = parsed.hostname
+ return
+ except Exception:
+ LOG.debug("taskv3 could not place a challenge frame against the covering layer", exc_info=True)
+ finally:
+ for handle in handles:
+ with contextlib.suppress(Exception):
+ await handle.dispose()
+ except Exception:
+ LOG.debug("taskv3 could not enumerate frames under the covering layer", exc_info=True)
+
async def _reachable_for_typing(page: Any, selector: str) -> tuple[bool, bool, dict[str, Any] | None]:
"""(reachable, occluded, occluder). Raises when the field cannot accept typed text at all. Shared
by both typing paths: fill() does no hit-testing, so without this a covered password or email
@@ -9753,6 +9824,7 @@ def build_browser_tools(
occluded = bool(isinstance(probe, dict) and probe.get("occluded"))
occluder = probe.get("occluder") if isinstance(probe, dict) else None
if occluded and not probe.get("skinned"):
+ await _annotate_challenge_frame(page, _current_page(), occluder)
return False, occluded, occluder
# Reachable: a skinned own-popup is force-typed past, so there is no blocking occluder to
# report. The probe still names it (the click path, which reads the probe directly, needs the
diff --git a/tests/unit/test_taskv3_tools.py b/tests/unit/test_taskv3_tools.py
index 52ecd1b9a..6b3f056d2 100644
--- a/tests/unit/test_taskv3_tools.py
+++ b/tests/unit/test_taskv3_tools.py
@@ -27,6 +27,7 @@ import pytest
# Captured at import (before the _fast_upload_settle autouse fixture rebinds the module attr) so the
# delay-specific test can exercise the real function while other upload tests skip the sleep.
from playwright.async_api import Error as _PlaywrightError
+from playwright.async_api import Frame, Page, Route
from structlog.testing import capture_logs
import skyvern.forge.taskv3.loop as taskv3_loop
@@ -1756,11 +1757,13 @@ _STATUS_PAGE_HTML = """
@contextlib.asynccontextmanager
-async def _content_page(html: str) -> AsyncIterator[Any]:
+async def _content_page(html: str, extra_args: list[str] | None = None) -> AsyncIterator[Any]:
from playwright.async_api import async_playwright # noqa: PLC0415
async with async_playwright() as pw:
- browser = await pw.chromium.launch(headless=True, args=["--use-mock-keychain", "--password-store=basic"])
+ browser = await pw.chromium.launch(
+ headless=True, args=["--use-mock-keychain", "--password-store=basic", *(extra_args or [])]
+ )
try:
context = await browser.new_context(viewport={"width": 1024, "height": 900})
page = await context.new_page()
@@ -12763,6 +12766,27 @@ async def test_type_into_an_open_combobox_is_not_blocked_by_its_own_listbox() ->
assert await page.eval_on_selector("#src", "el => el.value") == "Applicant Referral"
+_SKINNED_COMBOBOX_BESIDE_A_FREE_FIELD_HTML = (
+ _OPEN_COMBOBOX_OWN_LISTBOX_HTML
+ + '<input id="free" type="text" style="position:absolute;left:400px;top:0;width:200px;height:30px">'
+)
+
+
+@_skip_no_browser
+async def test_a_skinned_type_leaves_no_cover_mark_for_the_next_probe_to_trust() -> None:
+ async with _content_page(_SKINNED_COMBOBOX_BESIDE_A_FREE_FIELD_HTML) as page:
+ tools = build_browser_tools(_fixed_page_provider(page))
+ forced = await _tool(tools, "type").handler({"selector": "#src", "text": "Applicant Referral"})
+ assert forced.status == "ok", forced.content
+ assert await page.eval_on_selector("#src-lb", "el => el.hasAttribute('data-tv3-cover')") is True
+ html = await _tool(tools, "get_html").handler({})
+ assert "data-tv3-cover" not in html.content, html.content
+ free = await _tool(tools, "type").handler({"selector": "#free", "text": "hello"})
+ assert free.status == "ok", free.content
+ assert await page.query_selector("[data-tv3-cover]") is None
+
+
# A native, full-sized, opacity:1 radio with a same-size SIBLING <label for=id> drawn on top of it —
# not the zero-sized hidden-native shape the skinned-checkbox proxy path already covers.
_RADIO_UNDER_SIBLING_LABEL_HTML = """
@@ -13123,6 +13147,221 @@ async def test_click_through_a_wall_nested_inside_the_own_label_is_still_covered
assert await page.eval_on_selector("#agree", "el => el.checked") is False
+# The widget's iframe sits in a CLOSED shadow root: the shape an in-page src scan would miss, which
+# is why containment is decided from the frame host upward rather than by scanning the layer.
+_CHALLENGE_FRAME_URL = "https://challenges.cloudflare.com/turnstile/v0/api.html"
+_CHALLENGE_FRAME_HOST = "challenges.cloudflare.com"
+
+_MOUNT_CLOSED_SHADOW_FRAMES_JS = """(host, arg) => {
+ const root = host.attachShadow({ mode: 'closed' });
+ for (const src of arg.srcs) {
+ const frame = document.createElement('iframe');
+ frame.src = src;
+ frame.style.cssText = arg.style;
+ root.appendChild(frame);
+ }
+}"""
+
+_CHALLENGE_WALL_HTML = """
+<!doctype html><html><body style="margin:0">
+<button id="go" style="position:absolute;left:40px;top:300px;width:120px;height:40px">Go</button>
+<input id="email" type="email" style="position:absolute;left:200px;top:300px;width:200px;height:40px">
+<div id="wall" role="dialog" aria-label="Please check the box below to continue."
+ style="position:fixed;left:0;top:0;width:100%;height:100%;background:#fff;z-index:9">
+ <div id="widget" style="position:absolute;left:40px;top:120px;width:300px;height:65px"></div>
+ <button id="close" style="position:absolute;left:40px;top:220px">Close</button>
+</div>
+</body></html>
+"""
+
+# The same wall, but the widget is a SIBLING of it rather than part of it: a page-embedded challenge
+# that a full-viewport consent backdrop happens to paint over is not what the backdrop contains.
+_CHALLENGE_BESIDE_WALL_HTML = """
+<!doctype html><html><body style="margin:0">
+<button id="go" style="position:absolute;left:40px;top:300px;width:120px;height:40px">Go</button>
+<input id="email" type="email" style="position:absolute;left:200px;top:300px;width:200px;height:40px">
+<div id="widget" style="position:absolute;left:500px;top:120px;width:300px;height:65px;z-index:__Z__"></div>
+<div id="wall" role="dialog" aria-label="Please check the box below to continue."
+ style="position:fixed;left:0;top:0;width:100%;height:100%;background:#fff;z-index:9">
+ <button id="close" style="position:absolute;left:40px;top:220px">Close</button>
+</div>
+</body></html>
+"""
+
+_CHALLENGE_WALL_IN_CHILD_FRAME_HTML = (
+ '<!doctype html><html><body style="margin:0"><iframe id="shell" srcdoc=\''
+ + _CHALLENGE_WALL_HTML.replace("'", "&apos;").replace("\n", "")
+ + '\' style="position:absolute;left:0;top:0;width:1000px;height:880px;border:0"></iframe></body></html>'
+)
+
+
+async def _mount_challenge_frame(
+ realm: Page | Frame,
+ page: Page,
+ host_selector: str,
+ *,
+ style: str = "width:300px;height:65px;border:0",
+ ahead_of_it: str | None = None,
+) -> None:
+ async def _fulfill(route: Route) -> None:
+ await route.fulfill(content_type="text/html", body="<p>Verify you are human</p>")
+
+ srcs = ([ahead_of_it] if ahead_of_it else []) + [_CHALLENGE_FRAME_URL]
+ await page.route(f"{_CHALLENGE_FRAME_URL}*", _fulfill)
+ async with page.expect_event("framenavigated", lambda f: _CHALLENGE_FRAME_URL in (f.url or "")):
+ await realm.eval_on_selector(host_selector, _MOUNT_CLOSED_SHADOW_FRAMES_JS, {"srcs": srcs, "style": style})
+
+
+@_skip_no_browser
+async def test_click_covered_by_a_layer_holding_a_challenge_frame_names_it_and_drops_the_dismissal() -> None:
+ async with _content_page(_CHALLENGE_WALL_HTML, extra_args=["--site-per-process"]) as page:
+ await _mount_challenge_frame(page, page, "#widget")
+ tools = build_browser_tools(_fixed_page_provider(page))
+ r = await _tool(tools, "click").handler({"selector": "#go"})
+ assert r.status == "error", r.content
+ assert r.error_class == "covered", r.error_class
+ assert '"Please check the box below to continue." (#wall)' in r.content, r.content
+ assert f"contains a challenge frame ({_CHALLENGE_FRAME_HOST})" in r.content, r.content
+ assert '#close "Close"' in r.content, r.content
+ assert "closes or dismisses" not in r.content, r.content
+ assert "solve_captcha" not in r.content, r.content
+
+
+@_skip_no_browser
+async def test_type_into_a_field_covered_by_a_challenge_layer_names_the_frame() -> None:
+ async with _content_page(_CHALLENGE_WALL_HTML) as page:
+ await _mount_challenge_frame(page, page, "#widget")
+ tools = build_browser_tools(_fixed_page_provider(page))
+ r = await _tool(tools, "type").handler({"selector": "#email", "text": "[email protected]"})
+ assert r.status == "error", r.content
+ assert r.error_class == "covered", r.error_class
+ assert f"contains a challenge frame ({_CHALLENGE_FRAME_HOST})" in r.content, r.content
+ assert "closes or dismisses" not in r.content, r.content
+ assert await page.eval_on_selector("#email", "el => el.value") == ""
+
+
+@_skip_no_browser
+ ("z_index", "tool_name", "args"),
+ [("99", "click", {"selector": "#go"}), ("1", "type", {"selector": "#email", "text": "[email protected]"})],
+)
+async def test_a_challenge_frame_beside_the_covering_layer_is_not_reported_as_inside_it(
+ z_index: str, tool_name: str, args: dict[str, str]
+) -> None:
+ async with _content_page(_CHALLENGE_BESIDE_WALL_HTML.replace("__Z__", z_index)) as page:
+ await _mount_challenge_frame(page, page, "#widget")
+ tools = build_browser_tools(_fixed_page_provider(page))
+ r = await _tool(tools, tool_name).handler(args)
+ assert r.status == "error", r.content
+ assert "challenge frame" not in r.content, r.content
+ assert "Pick whichever one actually closes or dismisses the layer" in r.content, r.content
+
+
+# A wall that paints nothing and carries no control reads as a leftover backdrop -- except when it
+# holds the challenge, where "press Escape" would abandon the verification the page is waiting on.
+_TRANSPARENT_CHALLENGE_WALL_HTML = """
+<!doctype html><html><body style="margin:0">
+<button id="go" style="position:absolute;left:40px;top:300px;width:120px;height:40px">Go</button>
+<div id="wall" role="dialog" aria-label="Please check the box below to continue."
+ style="position:fixed;left:0;top:0;width:100%;height:100%;background:transparent;z-index:9">
+ <div id="widget" style="position:absolute;left:40px;top:120px;width:300px;height:65px"></div>
+</div>
+</body></html>
+"""
+
+
+@_skip_no_browser
+async def test_an_invisible_wall_holding_a_challenge_frame_is_never_called_a_leftover_backdrop() -> None:
+ async with _content_page(_TRANSPARENT_CHALLENGE_WALL_HTML) as page:
+ await _mount_challenge_frame(page, page, "#widget")
+ tools = build_browser_tools(_fixed_page_provider(page))
+ r = await _tool(tools, "click").handler({"selector": "#go"})
+ assert r.status == "error", r.content
+ assert r.error_class == "covered", r.error_class
+ assert f"contains a challenge frame ({_CHALLENGE_FRAME_HOST})" in r.content, r.content
+ assert "INVISIBLE" not in r.content, r.content
+ assert "leftover backdrop" not in r.content, r.content
+ assert "press Escape" not in r.content, r.content
+ assert "closes or dismisses" not in r.content, r.content
+
+
+@_skip_no_browser
+async def test_a_page_authored_data_frame_does_not_stand_in_for_the_real_challenge_host() -> None:
+ payload = "turnstile " + "x" * 2000
+ async with _content_page(_CHALLENGE_WALL_HTML) as page:
+ await _mount_challenge_frame(page, page, "#widget", ahead_of_it=f"data:text/html,{payload}")
+ tools = build_browser_tools(_fixed_page_provider(page))
+ r = await _tool(tools, "click").handler({"selector": "#go"})
+ assert r.status == "error", r.content
+ assert f"contains a challenge frame ({_CHALLENGE_FRAME_HOST})" in r.content, r.content
+ assert "xxxx" not in r.content, r.content
+
+
+@_skip_no_browser
+async def test_a_challenge_frame_the_layer_does_not_render_is_not_reported_as_present() -> None:
+ async with _content_page(_CHALLENGE_WALL_HTML) as page:
+ await _mount_challenge_frame(page, page, "#widget", style="display:none")
+ tools = build_browser_tools(_fixed_page_provider(page))
+ r = await _tool(tools, "click").handler({"selector": "#go"})
+ assert r.status == "error", r.content
+ assert "challenge frame" not in r.content, r.content
+ assert "Pick whichever one actually closes or dismisses the layer" in r.content, r.content
+
+
+@_skip_no_browser
[email protected](("hidden", "reported"), [(None, True), ("middle", False), ("vendor", False)])
+async def test_a_nested_challenge_frame_is_reported_only_when_every_embedding_frame_renders(
+ hidden: str | None, reported: bool
+) -> None:
+ shown = "width:300px;height:65px;border:0"
+
+ def add_frame_js(frame_id: str, style: str) -> str:
+ return (
+ f"el => {{ const f = document.createElement('iframe'); f.id = '{frame_id}';"
+ " f.srcdoc = '<div id=\\\"inner\\\"></div>';"
+ f" f.style.cssText = '{style}'; el.appendChild(f); }}"
+ )
+
+ async with _content_page(_CHALLENGE_WALL_HTML) as page:
+ await page.eval_on_selector("#widget", add_frame_js("outer", shown))
+ await page.frame_locator("#outer").locator("#inner").wait_for(state="attached")
+ outer = next(f for f in page.frames if f.parent_frame is page.main_frame)
+ await outer.eval_on_selector(
+ "#inner", add_frame_js("middle", shown + ";visibility:hidden" if hidden == "middle" else shown)
+ )
+ await page.frame_locator("#outer").frame_locator("#middle").locator("#inner").wait_for(state="attached")
+ middle = next(f for f in page.frames if f.parent_frame is outer)
+ await _mount_challenge_frame(middle, page, "#inner", style="display:none" if hidden == "vendor" else shown)
+ tools = build_browser_tools(_fixed_page_provider(page))
+ r = await _tool(tools, "click").handler({"selector": "#go"})
+ assert r.status == "error", r.content
+ assert (f"contains a challenge frame ({_CHALLENGE_FRAME_HOST})" in r.content) is reported, r.content
+ assert ("closes or dismisses" in r.content) is not reported, r.content
+
+
+@_skip_no_browser
+async def test_a_challenge_layer_inside_a_child_frame_realm_is_still_named(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(settings, "TASK_V3_FRAME_PERCEPTION", True)
+ async with _content_page(_CHALLENGE_WALL_IN_CHILD_FRAME_HTML) as page:
+ shell = page.frame_locator("#shell")
+ await shell.locator("#widget").wait_for(state="attached")
+ child = next(f for f in page.frames if f.parent_frame is page.main_frame)
+ await _mount_challenge_frame(child, page, "#widget")
+ tools = build_browser_tools(_fixed_page_provider(page))
+ r = await _tool(tools, "type").handler({"selector": "#email", "text": "[email protected]"})
+ assert r.status == "error", r.content
+ assert f"contains a challenge frame ({_CHALLENGE_FRAME_HOST})" in r.content, r.content
+ assert "closes or dismisses" not in r.content, r.content
+
+
# The sibling-label radio shape, but the label itself carries a widget role -- the boundary node must
# be excluded from its own interactive-descendant test, or it reads as intercepting itself.
_RADIO_UNDER_WIDGET_ROLE_LABEL_HTML = """
@@ -16511,6 +16750,8 @@ async def test_acting_on_a_new_mark_does_not_read_as_a_page_change() -> None:
assert len(await page.query_selector_all("[data-tv3-act]")) == 2 # both really are tagged
assert before == after
+ await page.eval_on_selector("#a", "el => el.setAttribute('data-tv3-cover', '1')")
+ assert await page.evaluate(_PAGE_FINGERPRINT_PROBE_JS) == after
# A payload URL long enough to hit observe's per-field display caps (label 140, value 100,
@@ -24122,8 +24363,6 @@ def test_no_page_only_playwright_api_is_called_on_a_realm_variable() -> None:
import re
from pathlib import Path
- from playwright.async_api import Frame, Page
-
page_only = {name for name in dir(Page) if not name.startswith("_") and not hasattr(Frame, name)}
# Page inherits these from its event emitter; Frame has no event surface at all.
page_only |= {"on", "once", "remove_listener"}