Skip to content

The design language that makes your AI harness better at design.

JavaScript

A challenge overlay inside a hidden wrapper is not showing

Paul Bakausa944b90ca8e8
diff --git a/crates/browser/src/validity.rs b/crates/browser/src/validity.rs
index c3c101ee4..cc2fc05f3 100644
--- a/crates/browser/src/validity.rs
+++ b/crates/browser/src/validity.rs
@@ -125,6 +125,8 @@ pub fn probe_js() -> String {
for (const el of document.querySelectorAll(selector)) {{
const cs = getComputedStyle(el);
if (cs.display === 'none' || cs.visibility === 'hidden' || parseFloat(cs.opacity) <= 0.02) continue;
+ // An ancestor can hide it too (a wrapper at opacity 0 or display: none).
+ try {{ if (el.checkVisibility && !el.checkVisibility({{ opacityProperty: true, visibilityProperty: true }})) continue; }} catch (e) {{}}
const r = el.getBoundingClientRect();
const w = Math.max(0, Math.min(r.right, vw) - Math.max(r.left, 0));
const h = Math.max(0, Math.min(r.bottom, vh) - Math.max(r.top, 0));
diff --git a/crates/browser/tests/recall_and_gates.rs b/crates/browser/tests/recall_and_gates.rs
index 97bb6a4c1..4b10a971e 100644
--- a/crates/browser/tests/recall_and_gates.rs
+++ b/crates/browser/tests/recall_and_gates.rs
@@ -260,4 +260,6 @@ fn a_press_and_hold_sheet_over_the_page_is_a_challenge() {
assert!(err.message.contains("overlay human-press-and-hold"), "{}", err.message);
let closed = format!("http://127.0.0.1:{port}/validity/press-and-hold-closed.html");
engine.detect_url(&closed, &options).expect("a closed sheet leaves the page");
+ let faded = format!("http://127.0.0.1:{port}/validity/press-and-hold-faded.html");
+ engine.detect_url(&faded, &options).expect("a sheet inside a faded wrapper leaves the page");
}
diff --git a/tests/fixtures/validity/press-and-hold-faded.html b/tests/fixtures/validity/press-and-hold-faded.html
new file mode 100644
index 000000000..988804f42
--- /dev/null
+++ b/tests/fixtures/validity/press-and-hold-faded.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8" />
+ <title>Expect More. Pay Less.</title>
+ <style>
+ body { font-family: system-ui, sans-serif; margin: 0; color: #1a1a1a; background: #fff; }
+ main { width: 960px; margin: 0 auto; padding: 32px 24px; }
+ p { font-size: 16px; line-height: 24px; }
+ /* HUMAN Security (PerimeterX) lays its "Press & hold" check over the
+ rendered page as a fixed iframe, target.com run 28. Here it is
+ held inside a wrapper faded to opacity 0: the sheet is not showing,
+ so the page is the page. */
+ .px-fade { opacity: 0; }
+ #px-captcha-modal { display: block; position: fixed; top: 0; left: 0; width: 100%; height: 100%; border: none; z-index: 2147483647; background-color: white; }
+ </style>
+</head>
+<body>
+ <main>
+ <h1>Wellness event</h1>
+ <p>The retailer's home page renders under the check: deals, categories and a footer.</p>
+ </main>
+ <div class="px-fade"><iframe id="px-captcha-modal" srcdoc="&lt;p&gt;Press &amp;amp; hold to confirm you are a human (and not a bot).&lt;/p&gt;"></iframe></div>
+</body>
+</html>