The design language that makes your AI harness better at design.
JavaScript
Consent: roots outside body, closed late banners, inline-hidden reports
Paul Bakaus5fa75ca5701f
diff --git a/crates/browser/src/consent.rs b/crates/browser/src/consent.rsindex e16028309..56459aab5 100644--- a/crates/browser/src/consent.rs+++ b/crates/browser/src/consent.rs@@ -233,7 +233,8 @@ 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, shadow-/// roots included), `consentShadowChars` (the shadow-root part of it),+/// roots included), `consentShadowChars` (the part of it `body.innerText`+/// does not see: shadow-root text, and a root outside `<body>`),/// `consentFrames` (sizable frames inside those roots) and/// `consentOutside` (visible form controls and sizable media outside them,/// counted up to 20).@@ -274,7 +275,10 @@ pub fn probe_fragment() -> String {if (consentRoots.some(o => o !== el && o.contains(el))) continue;const all = visibleText(el);consentChars += all;- consentShadowChars += Math.max(0, all - (el.innerText || '').replace(/\s+/g, ' ').trim().length);+ // A root outside <body> (appended to <html>) is not in body.innerText+ // at all; one inside it is, all but its shadow-root text.+ const inBody = !!document.body && document.body.contains(el);+ consentShadowChars += inBody ? Math.max(0, all - (el.innerText || '').replace(/\s+/g, ' ').trim().length) : all;for (const f of el.querySelectorAll('iframe')) {{if (!boxShows(f)) continue;const r = f.getBoundingClientRect();@@ -339,6 +343,14 @@ pub fn hide_js() -> String {// injected after the first pass) is still reported. Nothing paints between// disabling and re-enabling it: this runs in one task.if (style) style.disabled = true;+ // So are the inline hides an earlier pass stamped, while they are still+ // its own (a manager that has since set its own display keeps it).+ const lifted = q('[' + INLINE_MARK + ']').filter(el => el.style.getPropertyValue('display') === 'none' && el.style.getPropertyPriority('display') === 'important');+ for (const el of lifted) {{+ let prev = ['', ''];+ try {{ prev = JSON.parse(el.getAttribute(INLINE_MARK)); }} catch (e) {{}}+ if (prev[0]) el.style.setProperty('display', prev[0], prev[1]); else el.style.removeProperty('display');+ }}const showingBackdrop = [];for (const {{ m, sels }} of present) {{const on = sels.filter(s => q(s).some(showing));@@ -354,6 +366,7 @@ pub fn hide_js() -> String {(document.head || document.documentElement).appendChild(style);}}style.disabled = false;+ for (const el of lifted) el.style.setProperty('display', 'none', 'important');const rules = [];for (const {{ sels }} of present) for (const s of sels) rules.push(s + ' {{ display: none !important; }}');const text = rules.join('\n');diff --git a/crates/browser/src/lib.rs b/crates/browser/src/lib.rsindex d3b9d9581..58c94aa59 100644--- a/crates/browser/src/lib.rs+++ b/crates/browser/src/lib.rs@@ -814,9 +814,11 @@ fn late_consent_wall(page: &mut Page<'_>) -> Option<(PageProbe, PageValidity)> {// 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.// The same goes for the inline hides that pass stamped on a manager- // whose own inline `!important` outranked the rules.+ // whose own inline `!important` outranked the rules, while they are still+ // its own: a manager that has since set its own display (closing its+ // dialog) keeps what it set.let expr = format!(- "(() => {{ const s = document.getElementById({id}); const marked = Array.from(document.querySelectorAll('[' + {mark} + ']')); const put = marked.map(el => {{ let prev = ['', '']; try {{ prev = JSON.parse(el.getAttribute({mark})); }} catch (e) {{}} if (prev[0]) el.style.setProperty('display', prev[0], prev[1]); else el.style.removeProperty('display'); return el; }}); if (s) s.disabled = true; try {{ return {probe}; }} finally {{ if (s) s.disabled = false; for (const el of put) el.style.setProperty('display', 'none', 'important'); }} }})()",+ "(() => {{ const s = document.getElementById({id}); const marked = Array.from(document.querySelectorAll('[' + {mark} + ']')).filter(el => el.style.getPropertyValue('display') === 'none' && el.style.getPropertyPriority('display') === 'important'); const put = marked.map(el => {{ let prev = ['', '']; try {{ prev = JSON.parse(el.getAttribute({mark})); }} catch (e) {{}} if (prev[0]) el.style.setProperty('display', prev[0], prev[1]); else el.style.removeProperty('display'); return el; }}); if (s) s.disabled = true; try {{ return {probe}; }} finally {{ if (s) s.disabled = false; for (const el of put) el.style.setProperty('display', 'none', 'important'); }} }})()",id = serde_json::json!(consent::HIDE_STYLE_ID),mark = serde_json::json!(consent::INLINE_HIDE_MARK),probe = validity::probe_js(),diff --git a/crates/browser/src/validity.rs b/crates/browser/src/validity.rsindex 0de622c5c..ab4af8a1d 100644--- a/crates/browser/src/validity.rs+++ b/crates/browser/src/validity.rs@@ -129,8 +129,9 @@ pub struct PageProbe {pub consent_chars: u64,/// Visible form controls and sizable media outside those roots (up to 20).pub consent_outside: u64,- /// The part of `consent_chars` in shadow roots, which `text_chars` (the- /// page's `innerText`) does not see.+ /// The part of `consent_chars` that `text_chars` (the page's+ /// `body.innerText`) does not see: shadow-root text, and a root outside+ /// `<body>`.pub consent_shadow_chars: u64,/// Sizable frames inside those roots: a message drawn in an iframe,/// whose text the page cannot read.diff --git a/crates/browser/tests/consent_hiding.rs b/crates/browser/tests/consent_hiding.rsindex d3f13f906..1e1c67c4c 100644--- a/crates/browser/tests/consent_hiding.rs+++ b/crates/browser/tests/consent_hiding.rs@@ -18,7 +18,9 @@//! 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.+//! is refused; a short page under a shadow-root banner, or one appended+//! outside <body>, is scanned, as is a page whose late banner closed+//! itself; a late banner on a root the first pass hid inline is reported.use std::collections::HashMap;use std::io::{Read, Write};@@ -320,3 +322,32 @@ fn a_short_page_under_a_shadow_root_banner_is_scanned() {assert_eq!(f.extras.get("consentHidden"), Some(&serde_json::json!(["Usercentrics"])), "{f:?}");}}++#[test]+fn a_short_page_under_a_banner_outside_body_is_scanned() {+ let Some(engine) = engine() else { return };+ let port = serve();+ let url = format!("http://127.0.0.1:{port}/html-root-banner.html");+ engine.detect_url_scan(&url, &ScanOptions::default()).expect("a short page is a page");+}++#[test]+fn a_late_banner_that_closed_itself_is_not_a_wall() {+ let Some(engine) = engine() else { return };+ let port = serve();+ let url = format!("http://127.0.0.1:{port}/late-closed-banner.html");+ engine.detect_url_scan(&url, &ScanOptions::default()).expect("a closed banner leaves the page");+}++#[test]+fn a_late_banner_on_a_root_hidden_inline_is_reported() {+ let Some(engine) = engine() else { return };+ let port = serve();+ let url = format!("http://127.0.0.1:{port}/late-inline-banner.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();+ assert_eq!(evidence.consent.as_ref().expect("consent report").hidden, vec!["Usercentrics"]);+}diff --git a/docs/CLI-CONTRACT.md b/docs/CLI-CONTRACT.mdindex 2a001d05c..c70f31f36 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 or a frame of 10,000 square pixels or more (a message drawn in an iframe, whose text the page cannot read). For this test, text the manager renders in a shadow root is added to the page's visible-text count too (`consentShadowChars`), so the two counts describe the same text; the challenge checks keep the page's own count. 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 and its inline hides lifted 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 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). For this test, text of the manager's that `body.innerText` does not see (rendered in a shadow root, or in a root appended outside `<body>`) is added to the page's visible-text count too (`consentShadowChars`), so the two counts describe the same text; the challenge checks keep the page's own count. 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 and its inline hides lifted for that read (an inline hide the manager has since replaced with its own display stays as the manager set it), 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/html-root-banner.html b/tests/fixtures/consent/html-root-banner.htmlnew file mode 100644index 000000000..5cec280e9--- /dev/null+++ b/tests/fixtures/consent/html-root-banner.html@@ -0,0 +1,27 @@+<!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 banner appended to the html element</title>+ <style>+ /* A short page with copy of its own under a OneTrust-shaped banner the+ manager appended to <html>, outside <body>. The banner's text is not+ in body.innerText, so it is not subtracted from the page's own: 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; }+ #onetrust-consent-sdk { position: fixed; left: 0; right: 0; bottom: 0; padding: 24px; background: #fff; }+ </style>+</head>+<body>+ <h1>Opening hours</h1>+ <p>The studio is open Tuesday to Saturday from ten until six.</p>+ <script>+ const sdk = document.createElement('div');+ sdk.id = 'onetrust-consent-sdk';+ sdk.innerHTML = '<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 and to measure its performance.</p>';+ document.documentElement.appendChild(sdk);+ </script>+</body>+</html>diff --git a/tests/fixtures/consent/late-closed-banner.html b/tests/fixtures/consent/late-closed-banner.htmlnew file mode 100644index 000000000..db4fe0f5c--- /dev/null+++ b/tests/fixtures/consent/late-closed-banner.html@@ -0,0 +1,33 @@+<!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 late banner that closes itself</title>+ <style>+ /* An empty tall page with Usercentrics' root in the DOM at load, its own+ inline display: block !important outranking the hide rule, so the first+ pass hides it inline. On the first scroll the dialog renders; further+ down the manager closes it by setting its own display: none. The late+ wall check leaves that closed root closed, and the page is scanned.+ 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" style="display: block !important"></div>+ <script>+ const root = document.getElementById('usercentrics-root');+ window.addEventListener('scroll', () => {+ if (!root.shadowRoot) {+ 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></div>';+ } else if (window.scrollY > 600) {+ root.style.setProperty('display', 'none');+ }+ }, { passive: true });+ </script>+</body>+</html>diff --git a/tests/fixtures/consent/late-inline-banner.html b/tests/fixtures/consent/late-inline-banner.htmlnew file mode 100644index 000000000..4a1038787--- /dev/null+++ b/tests/fixtures/consent/late-inline-banner.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 late banner on a root hidden inline</title>+ <style>+ /* A page with copy of its own and Usercentrics' root in the DOM at load,+ its own inline display: block !important outranking the hide rule, so+ the first pass hides it inline. The banner renders on the first scroll;+ the hide pass after the sweep still names it. Pinned by+ crates/browser/tests/consent_hiding.rs. */+ body { font: 16px/1.5 system-ui, sans-serif; margin: 0; padding: 40px; min-height: 3000px; 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" style="display: block !important"></div>+ <script>+ window.addEventListener('scroll', () => {+ const root = document.getElementById('usercentrics-root');+ if (root.shadowRoot) return;+ 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 and to measure how it is used.</p></div>';+ }, { passive: true });+ </script>+</body>+</html>