Remove common consent overlays

This commit is contained in:
2026-05-16 22:32:30 -07:00
parent 62cd3e9509
commit 73b5313a0c
2 changed files with 125 additions and 3 deletions

View File

@@ -78,6 +78,28 @@ test("applies cosmetic filters with domain exceptions and skips unsupported proc
assert.match(getCosmeticCssForHostname(rules, "foo.com").join("\n"), /\.adguard/);
});
test("renderPage removes common cookie consent overlays before snapshot", async () => {
const html = `<!doctype html>
<html class="js sp-message-open" style="overflow: hidden;">
<body class="didomi-popup-open" style="overflow: hidden;">
<main>Article text</main>
<div id="sp_message_container_123" role="dialog" aria-modal="true">
<iframe id="sp_message_iframe_123" title="SP Consent Message" srcdoc="<p>Cookies on FT Sites</p>"></iframe>
</div>
</body>
</html>`;
const rendered = await renderPage(`data:text/html,${encodeURIComponent(html)}`, {
userscriptDelay: 0
});
assert.match(rendered, /Article text/);
assert.doesNotMatch(rendered, /sp_message_container_123/);
assert.doesNotMatch(rendered, /sp_message_iframe_123/);
assert.doesNotMatch(rendered, /<html[^>]*class="[^"]*sp-message-open/i);
assert.doesNotMatch(rendered, /<body[^>]*class="[^"]*didomi-popup-open/i);
});
test("renderPage serializes CSSOM-inserted style rules", async () => {
const html = `<!doctype html>
<html>