Skip to content

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

JavaScript

Consent walls: refuse late, shadow-root and long ones; keep a site modal's lock

Paul Bakausb3298d1709d6
diff --git a/crates/browser/src/consent.rs b/crates/browser/src/consent.rs
index bc572d0dc..b0ad5a19f 100644
--- a/crates/browser/src/consent.rs
+++ b/crates/browser/src/consent.rs
@@ -241,10 +241,24 @@ pub fn probe_fragment() -> String {
for (const s of m.roots) for (const el of q(s)) if (showing(el)) {{ on = true; consentRoots.push(el); }}
if (on) consent.push(m.name);
}}
+ // A manager that renders into a shadow root (Usercentrics) keeps its text
+ // out of the host's innerText, so each open shadow root under a root adds
+ // its own.
+ const visibleText = el => {{
+ let text = (el.innerText || '').replace(/\s+/g, ' ').trim().length;
+ const hosts = [el].concat(Array.from(el.querySelectorAll('*')).slice(0, 2000));
+ for (const host of hosts) {{
+ const root = host.shadowRoot;
+ if (!root) continue;
+ // innerText of an unrendered child (a <style>) is its source text.
+ for (const child of root.children) if (boxShows(child)) text += visibleText(child);
+ }}
+ return text;
+ }};
let consentChars = 0;
for (const el of consentRoots) {{
if (consentRoots.some(o => o !== el && o.contains(el))) continue;
- consentChars += (el.innerText || '').replace(/\s+/g, ' ').trim().length;
+ consentChars += visibleText(el);
}}
// Content outside the managers that is not text: a form control of any
// size, or an image, video, canvas, SVG or frame of at least
@@ -330,9 +344,9 @@ pub fn hide_js() -> String {
}}
// Undo the scroll lock the manager applied, and only that: its own classes
// on <html> and <body>, and an inline overflow: hidden on either while its
- // backdrop was up (a modal consent layer locks the page that way) and the
- // page is not an app shell that scrolls inside itself. A site's own
- // overflow is left alone.
+ // backdrop was up (a modal consent layer locks the page that way), the
+ // page is not an app shell that scrolls inside itself, and no modal of the
+ // site's own is open. A site's own overflow is left alone.
const html = document.documentElement;
const body = document.body;
for (const {{ m }} of present) {{
@@ -355,7 +369,12 @@ pub fn hide_js() -> String {
}}
return false;
}};
- if (showingBackdrop.length && !appShell()) {{
+ // The site's own modal, open beside the consent layer, may hold the lock
+ // itself: an inline overflow: hidden is then left alone.
+ const siteModal = () => q('dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]').some(el =>
+ !present.some(({{ sels }}) => sels.some(s => {{ try {{ return !!el.closest(s); }} catch (e) {{ return false; }} }}))
+ && showing(el));
+ if (showingBackdrop.length && !appShell() && !siteModal()) {{
for (const [el, tag] of [[html, 'html'], [body, 'body']]) {{
if (!el) continue;
for (const p of ['overflow', 'overflow-y']) {{
diff --git a/crates/browser/src/lib.rs b/crates/browser/src/lib.rs
index a53a7ea1d..c135f8dc1 100644
--- a/crates/browser/src/lib.rs
+++ b/crates/browser/src/lib.rs
@@ -805,6 +805,21 @@ fn check_validity(
Ok((response, probe, verdict))
}
+/// The consent-wall verdict for a page whose consent manager arrived after
+/// the load-time validity check, with the probe it was read from. `None`
+/// when the page is not a consent wall now, or the probe failed (the hide
+/// pass then runs as before).
+fn late_consent_wall(page: &mut Page<'_>) -> Option<(PageProbe, PageValidity)> {
+ let raw = page.evaluate_value(&validity::probe_js()).ok()?;
+ let probe = PageProbe::from_value(&raw);
+ if probe.consent.is_empty() {
+ return None;
+ }
+ let verdict = validity::classify_with(None, &probe, true);
+ matches!(verdict, PageValidity::Blocked { kind: validity::BlockKind::ConsentWall, .. })
+ .then_some((probe, verdict))
+}
+
#[allow(clippy::too_many_arguments)]
fn scan_page_inner(
page: &mut Page<'_>,
@@ -890,8 +905,22 @@ fn scan_page_inner(
step(profile, "scan", "reveal-sweep", url, || reveal_sweep(page)).map_err(cdp_err)?;
// A manager that injects its banner late (after load, or on the first
- // scroll) is hidden here, before the capture every pass reads.
+ // scroll) is hidden here, before the capture every pass reads. A late
+ // banner can be the whole page, so the consent-wall gate runs again
+ // first: hiding a wall would leave nothing to read and report it clean.
if hide_consent {
+ if let Some((probe, verdict)) = late_consent_wall(page) {
+ let message = verdict.error_message().unwrap_or_default();
+ return match evidence {
+ None => Err(EngineError::new(message)),
+ Some((ev, request)) => {
+ ev.probe = Some(probe);
+ ev.validity = Some(verdict);
+ capture_post_scan(page, ev, request, &[], &Map::new());
+ Ok(Vec::new())
+ }
+ };
+ }
step(profile, "scan", "hide-consent", url, || hide_consent_banners(page, consent));
}
diff --git a/crates/browser/src/validity.rs b/crates/browser/src/validity.rs
index 7912c55ca..60e82a11b 100644
--- a/crates/browser/src/validity.rs
+++ b/crates/browser/src/validity.rs
@@ -30,8 +30,10 @@ use serde_json::{json, Value};
/// treated as content even when its title or a marker looks like a challenge.
pub const SMALL_PAGE_CHARS: u64 = 3000;
-/// A small page with a known consent manager showing is a consent wall when
-/// fewer than this many visible characters lie outside the manager's roots,
+/// A page with a known consent manager showing is a consent wall when fewer
+/// than this many visible characters lie outside the manager's roots (a
+/// preference center alone can run past [`SMALL_PAGE_CHARS`], so the page's
+/// total is not the test),
/// nothing else shows outside them (no form control and no image, video or
/// frame of 10,000 square pixels or more, see [`crate::consent`]), and the
/// manager holds at least [`CONSENT_WALL_MIN_CHARS`] characters itself.
@@ -329,7 +331,7 @@ pub fn classify_with(response: Option<&DocumentResponse>, probe: &PageProbe, con
evidence: vec![format!("HTTP {status}")],
};
}
- if consent_wall && small && !probe.consent.is_empty() {
+ if consent_wall && !probe.consent.is_empty() {
let outside = probe.text_chars.saturating_sub(probe.consent_chars);
if outside < CONSENT_WALL_OUTSIDE_CHARS
&& probe.consent_outside == 0
@@ -397,6 +399,24 @@ mod tests {
assert_eq!(classify_with(Some(&resp(200, &[])), &p, false), PageValidity::Ok);
}
+ #[test]
+ fn a_preference_center_longer_than_a_small_page_is_still_a_wall() {
+ // A OneTrust preference center lists every purpose and vendor: more
+ // text than a challenge page holds, and still nothing but the dialog.
+ let mut p = probe("Example", 5400, &[]);
+ p.consent = vec!["OneTrust".into()];
+ p.consent_chars = 5392;
+ assert!(matches!(
+ classify(Some(&resp(200, &[])), &p),
+ PageValidity::Blocked { kind: BlockKind::ConsentWall, .. }
+ ));
+ // The same dialog over a long page is the page.
+ let mut p = probe("Example", 9400, &[]);
+ p.consent = vec!["OneTrust".into()];
+ p.consent_chars = 5392;
+ assert_eq!(classify(Some(&resp(200, &[])), &p), PageValidity::Ok);
+ }
+
#[test]
fn a_short_page_under_a_banner_is_the_page() {
// The review's sign-in page: an h1, two fields, a hint and a button
diff --git a/crates/browser/tests/consent_hiding.rs b/crates/browser/tests/consent_hiding.rs
index 510366bae..086a3acec 100644
--- a/crates/browser/tests/consent_hiding.rs
+++ b/crates/browser/tests/consent_hiding.rs
@@ -14,6 +14,9 @@
//! kept it is scanned, since the banner is what that scan asked for.
//! - A short page under an ordinary banner (a sign-in form) is not a wall.
//! - An app shell's own body lock stays when a manager's backdrop shows.
+//! - A wall that arrives after the load-time check, or renders its text in a
+//! shadow root, is still refused as one.
+//! - A lock the site's own open modal holds stays.
use std::collections::HashMap;
use std::io::{Read, Write};
@@ -49,7 +52,13 @@ fn handle(mut stream: TcpStream) {
.and_then(|l| l.split_whitespace().nth(1))
.unwrap_or("/")
.to_string();
- let body = std::fs::read(fixtures_dir().join(path.trim_start_matches('/'))).unwrap_or_default();
+ // Only files in the fixture directory: no `..` segment, no absolute path.
+ let rel = path.trim_start_matches('/');
+ let body = if rel.split('/').any(|seg| seg == ".." || seg.contains('\\')) {
+ Vec::new()
+ } else {
+ std::fs::read(fixtures_dir().join(rel)).unwrap_or_default()
+ };
let head = format!(
"HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
body.len()
@@ -231,3 +240,43 @@ fn an_app_shells_own_body_lock_stays() {
let snapshot = evidence.scan_snapshot.as_deref().unwrap();
assert!(snapshot.contains("overflow: hidden"), "the body keeps its own lock");
}
+
+#[test]
+fn a_wall_that_arrives_after_load_is_refused() {
+ let Some(engine) = engine() else { return };
+ let port = serve();
+ let url = format!("http://127.0.0.1:{port}/late-wall.html");
+ let err = engine.detect_url(&url, &ScanOptions::default()).expect_err("a late consent wall must not scan");
+ assert!(err.message.starts_with("the page is a consent wall, not the site (consent manager OneTrust, "), "{}", err.message);
+ let mut browser = engine.launch().expect("launch");
+ let (findings, evidence) =
+ detect_url_evidence(&mut browser, &url, &ScanOptions::default(), "load", 100, &EvidenceRequest::default())
+ .expect("evidence scan of a consent wall is Ok");
+ browser.close();
+ assert!(findings.is_empty());
+ assert_eq!(evidence.validity.as_ref().unwrap().to_value()["status"], "consent-wall");
+}
+
+#[test]
+fn a_wall_rendered_in_a_shadow_root_is_refused() {
+ let Some(engine) = engine() else { return };
+ let port = serve();
+ let url = format!("http://127.0.0.1:{port}/shadow-wall.html");
+ let err = engine.detect_url(&url, &ScanOptions::default()).expect_err("a shadow-root consent wall must not scan");
+ assert!(err.message.starts_with("the page is a consent wall, not the site (consent manager Usercentrics, "), "{}", err.message);
+}
+
+#[test]
+fn a_lock_the_sites_own_modal_holds_stays() {
+ let Some(engine) = engine() else { return };
+ let port = serve();
+ let url = format!("http://127.0.0.1:{port}/site-modal.html");
+ let mut browser = engine.launch().expect("launch");
+ let (_, evidence) =
+ detect_url_evidence(&mut browser, &url, &ScanOptions::default(), "load", 100, &EvidenceRequest::default())
+ .expect("scan");
+ browser.close();
+ let consent = evidence.consent.as_ref().expect("consent report");
+ assert_eq!(consent.hidden, vec!["Cookiebot"]);
+ assert!(consent.unlocked.is_empty(), "{:?}", consent.unlocked);
+}
diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.md
index 077d9b2af..14d12fee5 100644
--- a/docs/CLI-CONTRACT.md
+++ b/docs/CLI-CONTRACT.md
@@ -349,8 +349,8 @@ Optional keys added later by engines (appended after the above): `ignoreValue` (
- **Purple headings in the brand hue** (corpus decision r3-23-ai-color-palette-brand-hue). The heading forms of `ai-color-palette` (a snippet ending ` on heading`) do not report when the heading's computed `color` is within 12 degrees of hue of a brand surface on the same page: the solid `background-color` (alpha at least 0.9, chroma at least 50, no gradient painted over it) of the logo (an element whose `id`, `class`, `alt` or `aria-label` contains `logo`; its text colour too when it has text of its own), the nav bar (`nav`, `header`, `role=navigation|banner`, at least half the viewport wide), or a band across the page (at least 90% of the viewport's width) covering a fifth of the viewport's area or more. Headings are never brand surfaces, and the gradient and neon forms keep reporting: purple that shows up only in headings and gradients is the tell. URL engine only (the static engine has no rendered page to read surfaces from).
- **Contrast ratios in snippets.** Every `low-contrast` producer (the element text path shared by both engines, which covers links, spans and placeholders, the static engine's `:hover state`, and the URL engine's `browser contrast` sampling and `pixel contrast` passes, verdict and median) prints a ratio against its threshold: one decimal; two when one decimal would round a failing ratio up to the threshold; and those two cut, not rounded, when rounding them would reach it too. A ratio under the bar never prints as the bar: `4.49:1 (need 4.5:1)`, never `4.5:1` or `4.50:1`. A ratio at or above the threshold, such as a median over it, prints one decimal.
- **Page validity gate.** After `goto` (and settle), before injecting anything, the engine classifies the page (`crates/browser/src/validity.rs`) from the main document's final CDP response and an in-page probe (title, visible text length, final URL, challenge-widget markers). Challenge: an `x-amzn-waf-action` header, `cf-mitigated: challenge`, a final URL on a challenge-only host (`perfdrive.com`, `captcha-delivery.com`), or, on a page with at most 3000 characters of visible text, a challenge title prefix ("Just a moment", "Attention Required! | Cloudflare", "Human Verification", "Access Denied", "Radware Bot Manager", "Captcha", ...) or a full-page widget marker (Cloudflare challenge form, PerimeterX, DataDome, Imperva, Akamai, AWS WAF, slider captchas). HTTP error: a final status >= 400 with no challenge signal. A blocked page throws `the page is a bot challenge, not the site (<signals>). Findings would describe the challenge page, so none are reported.` or `the page returned an error (HTTP <status>). Findings would describe the error page, so none are reported.`, which the CLI prints as `Error: ...` and counts as an operational failure (exit 1). A `file://` load has no response, so only the probe signals apply.
- Consent wall: a page with at most 3000 characters of visible text where a known consent manager (next item) is showing, hiding it would leave next to nothing (fewer than 20 visible characters outside its roots, and no visible form control (`input` other than hidden, `select`, `textarea`, `button`) and no `img`, `svg`, `video`, `canvas`, `iframe`, `object` or `embed` of 10,000 square pixels or more outside them), and the manager holds at least 100 characters. It throws `the page is a consent wall, not the site (consent manager <names>, <n> of <total> visible characters outside it, no control or image outside it). Findings would describe the consent dialog, so none are reported.` A short page under an ordinary banner (a sign-in form, a splash page with a button, an image-first page) is scanned. The probe runs before any banner is hidden. With `--no-consent-hiding` the gate is off and the page is scanned with its banner, which is what that flag asks for. The probe object (evidence) carries `consent` (the names of the managers showing), `consentChars` (visible characters inside them) and `consentOutside` (visible controls and sizable media outside them, counted up to 20).
- - **Consent banners** (Rust engine). A consent banner covers copy a visitor reads once they dismiss it: text under it was skipped as covered or scored against the banner, and the banner's own text was scored as the site's. After the validity gate, again after the reveal sweep (so a banner injected after load or on the first scroll is caught before the capture), and once more right after the capture (when that pass changes the page, the page is captured again, so the capture, the live hit tests and the pixel reads agree), the engine hides the roots and backdrops of the consent managers in `crates/browser/src/consent.rs`: OneTrust, Cookiebot, Usercentrics, TrustArc, Didomi, Quantcast Choice, Sourcepoint, Osano, the open-source Cookie Consent library, CookieYes, Complianz, iubenda, Termly, Axeptio, Borlabs Cookie, Klaro, Cookie Notice, Shopify's privacy banner, and Google Funding Choices. Selectors are the vendor's own ids and classes, never a generic word, so a notice a site wrote for itself stays on the page and is scanned. Hiding is one injected `<style id="impeccable-consent-hide">` of `display: none !important` rules (plus an inline `display: none !important` on a matched element whose own inline style outranks the rule); nothing is clicked and no cookie or consent state is set. The scroll lock is undone only where the manager applied it: its own lock classes on `<html>` / `<body>` (Didomi `didomi-popup-open`, Sourcepoint `sp-message-open`) are removed, and an inline `overflow` / `overflow-y: hidden` on `<html>` or `<body>` is removed only while that manager's backdrop was showing and the page is not an app shell (an element outside the managers at least half the viewport tall that scrolls itself with `overflow-y: auto` / `scroll`, whose body lock is the site's own). Every hide pass is best-effort: one that fails hides nothing and does not fail the scan. Every pass, the hit tests, and the evidence screenshot see the page without the banner (a last hide runs before the screenshot). Findings from a scan that hid a showing banner carry `consentHidden: ["<name>", ...]` (after `thirdParty`), and text mode prints the note above. `--no-consent-hiding` turns all of it off. The evidence API (`detect_url_evidence`) leaves the findings untagged, so they replay equal, and records `Evidence.consent`: `{ hidden, matched: { <name>: [selectors] }, unlocked }`. The static (file) engine is unaffected.
+ Consent wall: a page where a known consent manager (next item) is showing (its text counted with the text of open shadow roots under its roots, where Usercentrics renders), hiding it would leave next to nothing (fewer than 20 visible characters outside its roots, and no visible form control (`input` other than hidden, `select`, `textarea`, `button`) and no `img`, `svg`, `video`, `canvas`, `iframe`, `object` or `embed` of 10,000 square pixels or more outside them), and the manager holds at least 100 characters. It throws `the page is a consent wall, not the site (consent manager <names>, <n> of <total> visible characters outside it, no control or image outside it). Findings would describe the consent dialog, so none are reported.` A short page under an ordinary banner (a sign-in form, a splash page with a button, an image-first page) is scanned. The probe runs before any banner is hidden, and again before the hide pass after the reveal sweep, so a wall that arrives after load is refused too (the evidence then carries that later probe). With `--no-consent-hiding` the gate is off and the page is scanned with its banner, which is what that flag asks for. The probe object (evidence) carries `consent` (the names of the managers showing), `consentChars` (visible characters inside them) and `consentOutside` (visible controls and sizable media outside them, counted up to 20).
+ - **Consent banners** (Rust engine). A consent banner covers copy a visitor reads once they dismiss it: text under it was skipped as covered or scored against the banner, and the banner's own text was scored as the site's. After the validity gate, again after the reveal sweep (so a banner injected after load or on the first scroll is caught before the capture), and once more right after the capture (when that pass changes the page, the page is captured again, so the capture, the live hit tests and the pixel reads agree), the engine hides the roots and backdrops of the consent managers in `crates/browser/src/consent.rs`: OneTrust, Cookiebot, Usercentrics, TrustArc, Didomi, Quantcast Choice, Sourcepoint, Osano, the open-source Cookie Consent library, CookieYes, Complianz, iubenda, Termly, Axeptio, Borlabs Cookie, Klaro, Cookie Notice, Shopify's privacy banner, and Google Funding Choices. Selectors are the vendor's own ids and classes, never a generic word, so a notice a site wrote for itself stays on the page and is scanned. Hiding is one injected `<style id="impeccable-consent-hide">` of `display: none !important` rules (plus an inline `display: none !important` on a matched element whose own inline style outranks the rule); nothing is clicked and no cookie or consent state is set. The scroll lock is undone only where the manager applied it: its own lock classes on `<html>` / `<body>` (Didomi `didomi-popup-open`, Sourcepoint `sp-message-open`) are removed, and an inline `overflow` / `overflow-y: hidden` on `<html>` or `<body>` is removed only while that manager's backdrop was showing the page is not an app shell (an element outside the managers at least half the viewport tall that scrolls itself with `overflow-y: auto` / `scroll`, whose body lock is the site's own), and no modal of the site's own (`dialog[open]`, `[aria-modal="true"]`, `[role="dialog"]`, `[role="alertdialog"]` outside the managers) is showing, since that modal may hold the lock. Every hide pass is best-effort: one that fails hides nothing and does not fail the scan. Every pass, the hit tests, and the evidence screenshot see the page without the banner (a last hide runs before the screenshot). Findings from a scan that hid a showing banner carry `consentHidden: ["<name>", ...]` (after `thirdParty`), and text mode prints the note above. `--no-consent-hiding` turns all of it off. The evidence API (`detect_url_evidence`) leaves the findings untagged, so they replay equal, and records `Evidence.consent`: `{ hidden, matched: { <name>: [selectors] }, unlocked }`. The static (file) engine is unaffected.
- **What the visual pass refuses to read.** The JS reported whatever its sampling produced; the engine says nothing where the reading is not the text's own background. The candidate collector applies the element pass's text gates before a candidate takes one of the `maxCandidates` slots, is sampled, or is scrolled into view: text with no letter and no digit (`◯`, `{ }`, `/`) as well as emoji-only text; a disabled control (`[disabled]`, `[aria-disabled="true"]`); a computed font size under 1px; a `color` at alpha 0.02 or less, or a transparent `-webkit-text-fill-color`, unless the element clips its own background to its text; and an element the painted-at-capture predicate (`crates/core/src/browser/painted.rs`, text gate) says is not painted, such as a tab-strip cell past its clipping edge or a carousel slide parked beside the page. A background image read as a surface has to be under the text: an image drawn `no-repeat` (from the computed `background` shorthand's first layer) whose painted rect, at a `background-size` the capture can place (pixels, percentages, `cover`, or any size once the image's intrinsic size is loaded), covers neither the candidate's text box nor its own box (`body` and `html` are asked only about the text) ends the walk `background image does not cover the text` (`stop`), whether or not the pass could load the file. An icon sprite framing a count and a mark beside a button label are refused this way; a repeating tile and a placement the capture cannot state are read as before. In the stack walk (`impeccable_core::browser::visual`): a translucent surface no longer restarts the walk at its own parent (which re-entered the stack above the node it came from and composited that surface over itself until its alpha read as opaque, and which skipped siblings painted between the surface and that parent) — the walk keeps descending the one `elementsFromPoint` stack, collecting translucent surfaces until an opaque one grounds them, then composites them back in order (topmost surface still names the method, `...+alpha`); a walk that reaches the end of the stack with nothing opaque is unresolved rather than reporting the last translucent color as a surface. A gradient answers analytically only when its stops agree: any stop below 0.95 alpha (a scrim, a glow, a `from-x/10` wash composites differently at every point of the box) or two opaque stops more than 2× apart in contrast make it `gradient stops disagree`, and an `svg` in the stack makes it `<tag> paint`; both end the walk (`stop`) rather than letting the nodes under them answer for the text, so the candidate falls to the screenshot pass. In the screenshot flow: a candidate whose reasons include `background-clip text`, `filter`, or `backdrop filter` is refused before the two screenshots are taken; the verdict is the median over the *glyph cores* (channel delta ≥ 90% of the strongest delta in the box, ≥ 8 of them; when fewer than 8 pixels reach 90%, as on small or thin text, the pixels from 75% up) rather than the tenth percentile over every changed pixel, which antialiased edges drive to 1:1; and the pass reports nothing when the diff is not a glyph over its background — more than 55% of the clip changed (the page repainted), more than a quarter of the changed pixels moved the opposite way from the rest (text mid-animation leaves its old position and its new one in the same diff), most fully painted pixels are not the color the text declares (`preferRenderedForeground` aside, where the painted value *is* the claim), the surface under the glyphs stands 2:1 or further from the surface beside them in the same box (the page paints its own text twice, so hiding one copy leaves the other where the glyphs were), or the median of every measured pixel is more than 3× the verdict (the sample is two populations, not one surface). The snippet shape is unchanged. `median` in it is the median over the same glyph cores the verdict reads, so it prints the verdict's number and never reads below it (it used to be the median over every changed pixel, edges included, which printed verdicts above their own median such as `pixel contrast 3.5:1 median 1.7:1`). The median over every changed pixel still decides the bimodal refusal above, but it is not printed.
- **Viewport edges and overflow.** `body-text-viewport-edge` reports a gutter under 16px, or under 12px when `innerWidth` is 480px or less. A paragraph whose measured text runs past a side of the viewport (the distance rounds below 0) reports no gutter on that side; it still reports a gutter from 0px to the floor on the other side (`(left 8px)`). Those paragraphs, through the same gates plus the Text paint gate and inline ignores, report once per page instead: one `body-text-viewport-edge` finding attributed to the page (`selector` `body`, in `pageLevel`) on the side the furthest text reaches. The message follows what the page does. It reads `text runs past the <side> edge of the <vw>px viewport and is cut off: <name> reaches <d>px past it, with text in <n> block(s)` when the text is cut off: the viewport clips x overflow (the root's `overflow-x`, or body's when the root's is `visible`, at `hidden` or `clip`), the side is not the one the page scrolls to (right, or left under `direction: rtl`), the root's recorded `scrollWidth` does not exceed its `clientWidth` by more than 1px, or for every paragraph on that side a box at `overflow-x: hidden` or `clip` (the paragraph or an ancestor below the body, with its own edge on that side inside the viewport) is passed by the text. `<name>` is then the box reaching furthest among the paragraphs and their ancestors. Otherwise it reads `page scrolls sideways at <vw>px: <name> reaches <d>px past the <side> edge, and text in <n> block(s) runs past it`, where `<name>` is the box reaching furthest past that side among those no ancestor below the root clips or scrolls on x and not `position: fixed`, and no further than the page scrolls (ties go to the outer box). When the engine cannot tell (nothing it can see clips the text and the root recorded no `scrollWidth`) the sideways wording stands and `<name>` is the box reaching furthest among the paragraphs and their ancestors. In both wordings the paragraph itself is named when its text reaches further than any such box. `<name>` is the element's `class_selector`, except that a `div` with no class is named `div#<id>`, else `div in <tag>#<id>` or `div in <tag>.<class>` (at most three classes) after its nearest ancestor below the body with an id or a class, else `div ("<text>")` with up to 40 characters of its text, cut at a word and ended with `…` when cut, double quotes in the text written as `'`. `text-overflow` reports a spill only when it does harm: a box at `overflow-x: hidden` or `clip` (the element itself or an ancestor below the body, with area) is passed by the spill's reach, the spill reaches within a quarter em of the viewport's side or past it, or the spilled part comes within a quarter em of another element's text or painted box on the element's lines (not an ancestor or descendant, not a box that holds the element's whole box, and not a decoration layer: an absolutely or fixed positioned box with no text, other than a replaced element or an `svg`, that is 2px thick or less or paints only a plain fill, with no background image or border, at alpha times opacity under 0.25). The reach is the painted extent, or the scroll extent where that is taken as read; text that runs past its box into free space reports nothing.
- `createBrowserDetector(options)`: shared browser, defaults `waitUntil:'load'`, `settleMs:100`, `viewport 1280x800`; `close()` closes only an owned browser.
diff --git a/tests/fixtures/consent/late-wall.html b/tests/fixtures/consent/late-wall.html
new file mode 100644
index 000000000..92a02a6bc
--- /dev/null
+++ b/tests/fixtures/consent/late-wall.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Consent hiding: a consent wall that arrives after load</title>
+ <style>
+ /* An empty page whose OneTrust-shaped dialog arrives after the load-time
+ validity check. Hiding it would leave nothing to read, so the late
+ hide pass checks for a wall again and the page is refused. Pinned by
+ crates/browser/tests/consent_hiding.rs. */
+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; background: #f3f4f6; }
+ #onetrust-pc-sdk { position: fixed; top: 80px; left: 50%; width: 640px; margin-left: -320px; padding: 32px; background: #fff; }
+ </style>
+</head>
+<body>
+ <script>
+ setTimeout(() => {
+ const sdk = document.createElement('div');
+ sdk.id = 'onetrust-consent-sdk';
+ sdk.innerHTML = '<div id="onetrust-pc-sdk" role="dialog" aria-label="Privacy preferences"><h2>Your privacy choices</h2>'
+ + '<p>We and our partners store and access information on your device, such as cookies, and process personal data such as unique identifiers and browsing data, to personalise content and advertising, to measure the performance of content and advertising, and to develop and improve our products.</p>'
+ + '<button type="button">Accept all</button> <button type="button">Reject all</button></div>';
+ document.body.appendChild(sdk);
+ }, 300);
+ </script>
+</body>
+</html>
diff --git a/tests/fixtures/consent/shadow-wall.html b/tests/fixtures/consent/shadow-wall.html
new file mode 100644
index 000000000..9fff6c159
--- /dev/null
+++ b/tests/fixtures/consent/shadow-wall.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Consent hiding: a consent wall rendered in a shadow root</title>
+ <style>
+ /* A page that is only a Usercentrics-shaped dialog, rendered into the
+ open shadow root of #usercentrics-root the way Usercentrics does. Its
+ text is not in the host's innerText, and still counts toward the wall.
+ Pinned by crates/browser/tests/consent_hiding.rs. */
+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; background: #f3f4f6; }
+ </style>
+</head>
+<body>
+ <div id="usercentrics-root"></div>
+ <script>
+ document.getElementById('usercentrics-root').attachShadow({ mode: 'open' }).innerHTML =
+ '<style>.box { position: fixed; top: 80px; left: 50%; width: 640px; margin-left: -320px; padding: 32px; background: #fff; }</style>'
+ + '<div class="box" role="dialog" aria-label="Privacy settings"><h2>Privacy settings</h2>'
+ + '<p>We use cookies and similar technologies to provide this website, to measure how it is used and to show you personalised content and advertising. You can accept all of these purposes, reject them, or choose which ones you allow in the settings.</p>'
+ + '<button type="button">Accept all</button> <button type="button">Deny</button></div>';
+ </script>
+</body>
+</html>
diff --git a/tests/fixtures/consent/site-modal.html b/tests/fixtures/consent/site-modal.html
new file mode 100644
index 000000000..a5be2f069
--- /dev/null
+++ b/tests/fixtures/consent/site-modal.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Consent hiding: the site's own modal beside a consent layer</title>
+ <style>
+ /* A page with its own newsletter modal open, which locks <body> with an
+ inline overflow: hidden, under a Cookiebot-shaped dialog and underlay.
+ Hiding the consent layer leaves the site's lock alone. Pinned by
+ crates/browser/tests/consent_hiding.rs. */
+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; padding: 40px; color: #111; background: #fff; }
+ .section { height: 900px; }
+ #CybotCookiebotDialogBodyUnderlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 2147483630; }
+ #CybotCookiebotDialog { position: fixed; top: 200px; left: 50%; width: 640px; margin-left: -320px; height: 200px;
+ padding: 28px; background: #ffffff; z-index: 2147483631; }
+ .newsletter { position: fixed; bottom: 40px; right: 40px; width: 320px; padding: 24px; background: #fff; border: 1px solid #ddd; z-index: 10; }
+ </style>
+</head>
+<body style="overflow: hidden">
+ <h1>A page with its own modal open</h1>
+ <div class="section"><p>The first section of a page with plenty of its own copy, so it is a page and not a wall.</p></div>
+ <div class="section"><p>The second section.</p></div>
+ <div class="newsletter" role="dialog" aria-modal="true" aria-label="Newsletter"><p>Get the weekly letter.</p><button type="button">Subscribe</button></div>
+ <div id="CybotCookiebotDialogBodyUnderlay"></div>
+ <div id="CybotCookiebotDialog" role="dialog"><p>This website uses cookies to personalise content and to analyse our traffic.</p><button type="button">Allow all</button></div>
+</body>
+</html>