Skip to content

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

JavaScript

Consent walls: same-tree text counts, frames, and stubs the hide pass hid

Paul Bakaus3f9a6fce6bce
diff --git a/crates/browser/src/consent.rs b/crates/browser/src/consent.rs
index b0ad5a19f..ded7b7902 100644
--- a/crates/browser/src/consent.rs
+++ b/crates/browser/src/consent.rs
@@ -227,7 +227,9 @@ const SHOWING_JS: &str = r#"const q = s => { try { return Array.from(document.qu
};"#;
/// A probe fragment. Defines `consent` (the names of the managers whose roots
-/// are showing), `consentChars` (the visible text inside those roots) and
+/// are showing), `consentChars` (the visible text inside those roots, shadow
+/// roots included), `consentShadowChars` (the shadow-root part of it),
+/// `consentFrames` (sizable frames inside those roots) and
/// `consentOutside` (visible form controls and sizable media outside them,
/// counted up to 20).
pub fn probe_fragment() -> String {
@@ -255,10 +257,24 @@ pub fn probe_fragment() -> String {
}}
return text;
}};
+ // `consentShadowChars` is the part of that text the page's own
+ // `body.innerText` cannot see, so the probe adds it to the page's count and
+ // the two counts describe the same text. `consentFrames` counts sizable
+ // frames inside the roots: a manager that draws its message in an iframe
+ // (Sourcepoint) holds text no page script can read.
let consentChars = 0;
+ let consentShadowChars = 0;
+ let consentFrames = 0;
for (const el of consentRoots) {{
if (consentRoots.some(o => o !== el && o.contains(el))) continue;
- consentChars += visibleText(el);
+ const all = visibleText(el);
+ consentChars += all;
+ consentShadowChars += Math.max(0, all - (el.innerText || '').replace(/\s+/g, ' ').trim().length);
+ for (const f of el.querySelectorAll('iframe')) {{
+ if (!boxShows(f)) continue;
+ const r = f.getBoundingClientRect();
+ if (r.width * r.height >= {media_px}) consentFrames++;
+ }}
}}
// 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
diff --git a/crates/browser/src/lib.rs b/crates/browser/src/lib.rs
index 043c61cfd..03c1aeca4 100644
--- a/crates/browser/src/lib.rs
+++ b/crates/browser/src/lib.rs
@@ -810,7 +810,15 @@ fn check_validity(
/// 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()?;
+ // The first hide pass's rules are on: a root that was an empty stub then
+ // is hidden by them now, though it holds the wall. The probe reads the
+ // page with them off, in one task, so nothing paints in between.
+ let expr = format!(
+ "(() => {{ const s = document.getElementById({id}); if (s) s.disabled = true; try {{ return {probe}; }} finally {{ if (s) s.disabled = false; }} }})()",
+ id = serde_json::json!(consent::HIDE_STYLE_ID),
+ probe = validity::probe_js(),
+ );
+ let raw = page.evaluate_value(&expr).ok()?;
let probe = PageProbe::from_value(&raw);
if probe.consent.is_empty() {
return None;
diff --git a/crates/browser/src/validity.rs b/crates/browser/src/validity.rs
index 85fa74521..80023651e 100644
--- a/crates/browser/src/validity.rs
+++ b/crates/browser/src/validity.rs
@@ -101,11 +101,12 @@ pub fn probe_js() -> String {
const text = (document.body && document.body.innerText) || '';
return {{
title: String(document.title || ''),
- textChars: text.replace(/\s+/g, ' ').trim().length,
+ textChars: text.replace(/\s+/g, ' ').trim().length + consentShadowChars,
href: String(location.href || ''),
markers: found,
consent,
consentChars,
+ consentFrames,
consentOutside,
}};
}})()"#,
@@ -127,6 +128,9 @@ pub struct PageProbe {
pub consent_chars: u64,
/// Visible form controls and sizable media outside those roots (up to 20).
pub consent_outside: u64,
+ /// Sizable frames inside those roots: a message drawn in an iframe,
+ /// whose text the page cannot read.
+ pub consent_frames: u64,
}
impl PageProbe {
@@ -147,6 +151,7 @@ impl PageProbe {
.unwrap_or_default(),
consent_chars: v.get("consentChars").and_then(Value::as_f64).unwrap_or(0.0).max(0.0) as u64,
consent_outside: v.get("consentOutside").and_then(Value::as_f64).unwrap_or(0.0).max(0.0) as u64,
+ consent_frames: v.get("consentFrames").and_then(Value::as_f64).unwrap_or(0.0).max(0.0) as u64,
}
}
@@ -159,6 +164,7 @@ impl PageProbe {
"consent": self.consent,
"consentChars": self.consent_chars,
"consentOutside": self.consent_outside,
+ "consentFrames": self.consent_frames,
})
}
}
@@ -351,7 +357,7 @@ pub fn classify_with(response: Option<&DocumentResponse>, probe: &PageProbe, con
let outside = probe.text_chars.saturating_sub(probe.consent_chars);
if outside < CONSENT_WALL_OUTSIDE_CHARS
&& probe.consent_outside == 0
- && probe.consent_chars >= CONSENT_WALL_MIN_CHARS
+ && (probe.consent_chars >= CONSENT_WALL_MIN_CHARS || probe.consent_frames > 0)
{
return PageValidity::Blocked {
kind: BlockKind::ConsentWall,
@@ -433,6 +439,20 @@ mod tests {
assert_eq!(classify(Some(&resp(200, &[])), &p), PageValidity::Ok);
}
+ #[test]
+ fn a_manager_drawn_in_a_frame_is_a_wall_over_an_empty_page() {
+ let mut p = probe("Example", 0, &[]);
+ p.consent = vec!["Sourcepoint".into()];
+ p.consent_frames = 1;
+ assert!(matches!(
+ classify(Some(&resp(200, &[])), &p),
+ PageValidity::Blocked { kind: BlockKind::ConsentWall, .. }
+ ));
+ // The same frame over a page with copy of its own is the page.
+ p.text_chars = 400;
+ 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 086a3acec..0681c203f 100644
--- a/crates/browser/tests/consent_hiding.rs
+++ b/crates/browser/tests/consent_hiding.rs
@@ -17,6 +17,8 @@
//! - 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.
+//! - A wall that fills a root already in the page, or is drawn in a frame,
+//! is refused; a short page under a shadow-root banner is scanned.
use std::collections::HashMap;
use std::io::{Read, Write};
@@ -280,3 +282,32 @@ fn a_lock_the_sites_own_modal_holds_stays() {
assert_eq!(consent.hidden, vec!["Cookiebot"]);
assert!(consent.unlocked.is_empty(), "{:?}", consent.unlocked);
}
+
+#[test]
+fn a_wall_that_fills_an_empty_root_after_load_is_refused() {
+ let Some(engine) = engine() else { return };
+ let port = serve();
+ let url = format!("http://127.0.0.1:{port}/late-stub-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 Usercentrics, "), "{}", err.message);
+}
+
+#[test]
+fn a_wall_drawn_in_a_frame_is_refused() {
+ let Some(engine) = engine() else { return };
+ let port = serve();
+ let url = format!("http://127.0.0.1:{port}/frame-wall.html");
+ let err = engine.detect_url(&url, &ScanOptions::default()).expect_err("a framed consent wall must not scan");
+ assert!(err.message.starts_with("the page is a consent wall, not the site (consent manager Sourcepoint, "), "{}", err.message);
+}
+
+#[test]
+fn a_short_page_under_a_shadow_root_banner_is_scanned() {
+ let Some(engine) = engine() else { return };
+ let port = serve();
+ let url = format!("http://127.0.0.1:{port}/shadow-short-page.html");
+ let scan = engine.detect_url_scan(&url, &ScanOptions::default()).expect("a short page is a page");
+ for f in &scan.findings {
+ assert_eq!(f.extras.get("consentHidden"), Some(&serde_json::json!(["Usercentrics"])), "{f:?}");
+ }
+}
diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.md
index f737d7f2b..4acc42213 100644
--- a/docs/CLI-CONTRACT.md
+++ b/docs/CLI-CONTRACT.md
@@ -349,7 +349,7 @@ 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, read from the first element in it with text of its own, so a type logo set in a child `span` counts), the nav bar (`nav`, `header`, `role=navigation|banner`, at least half the viewport wide), neither inside `main` or an `article` (an article's own header, a pagination nav and a row of partner logos are local chrome), 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 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 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 or a frame of 10,000 square pixels or more (a message drawn in an iframe, whose text the page cannot read). Text the manager renders in a shadow root is added to the page's visible-text count too, so the two counts describe the same text. 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, with the earlier hide rules switched off for that read, so a wall that arrives after load, or fills a root that was an empty stub, 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.
diff --git a/tests/fixtures/consent/frame-wall.html b/tests/fixtures/consent/frame-wall.html
new file mode 100644
index 000000000..0a0c56091
--- /dev/null
+++ b/tests/fixtures/consent/frame-wall.html
@@ -0,0 +1,22 @@
+<!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 wall drawn in a frame</title>
+ <style>
+ /* A page that is only a Sourcepoint-shaped message, drawn in an iframe
+ whose text the page cannot read. The frame counts as the manager's
+ content, so the page is refused as a consent wall. Pinned by
+ crates/browser/tests/consent_hiding.rs. */
+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; background: #f3f4f6; }
+ #sp_message_container_1234 { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
+ #sp_message_container_1234 iframe { width: 640px; height: 400px; border: 0; background: #fff; }
+ </style>
+</head>
+<body>
+ <div id="sp_message_container_1234">
+ <iframe title="Privacy message" srcdoc="&lt;p&gt;We and our partners use cookies to personalise content and ads.&lt;/p&gt;&lt;button&gt;Accept&lt;/button&gt;"></iframe>
+ </div>
+</body>
+</html>
diff --git a/tests/fixtures/consent/late-stub-wall.html b/tests/fixtures/consent/late-stub-wall.html
new file mode 100644
index 000000000..b01822abc
--- /dev/null
+++ b/tests/fixtures/consent/late-stub-wall.html
@@ -0,0 +1,30 @@
+<!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 wall that fills an empty root after load</title>
+ <style>
+ /* An empty page with Usercentrics' root already in the DOM, empty, at
+ load: the first hide pass hides it. The dialog renders into its shadow
+ root on the first scroll. The late wall check reads the page with the hide rules
+ off, so the wall is refused. Pinned by
+ crates/browser/tests/consent_hiding.rs. */
+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; min-height: 3000px; background: #f3f4f6; }
+ </style>
+</head>
+<body>
+ <div id="usercentrics-root"></div>
+ <script>
+ window.addEventListener('scroll', () => {
+ const root = document.getElementById('usercentrics-root');
+ if (root.shadowRoot) return;
+ 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>';
+ }, { passive: true });
+ </script>
+</body>
+</html>
diff --git a/tests/fixtures/consent/shadow-short-page.html b/tests/fixtures/consent/shadow-short-page.html
new file mode 100644
index 000000000..83d9d7731
--- /dev/null
+++ b/tests/fixtures/consent/shadow-short-page.html
@@ -0,0 +1,26 @@
+<!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 short page under a shadow-root banner</title>
+ <style>
+ /* A short page with a paragraph of its own under a Usercentrics-shaped
+ banner rendered in a shadow root. The banner's text is counted in the
+ page's total too, so the page's own copy is outside it and the page is
+ scanned, not refused. 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; }
+ </style>
+</head>
+<body>
+ <h1>Opening hours</h1>
+ <p>The studio is open Tuesday to Saturday from ten until six, and by appointment on Mondays.</p>
+ <div id="usercentrics-root"></div>
+ <script>
+ document.getElementById('usercentrics-root').attachShadow({ mode: 'open' }).innerHTML =
+ '<style>.bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 24px; background: #fff; }</style>'
+ + '<div class="bar" role="region" aria-label="Privacy settings">'
+ + '<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></div>';
+ </script>
+</body>
+</html>