feat(consent-tester): browser_profile-Param — echte Engine-Wahl im Scan (Phase 1.1)

run_consent_test nimmt jetzt browser_profile (browser_profiles.py): Firefox/Gecko,
WebKit/Safari oder Blink (Chromium-Default / Chrome-/Edge-Channel / Brave via
executable_path). Rückwärtskompatibel: None → Chromium wie bisher. Fundament für
die echte /scan-matrix (Stage-1.b-Shim), die als nächstes Profile durchreicht.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-12 22:21:20 +02:00
parent 11740bd2f9
commit c816827720
+23 -6
View File
@@ -117,6 +117,7 @@ def _apply_edge_case_findings(result, url: str = "") -> None:
async def run_consent_test( async def run_consent_test(
url: str, wait_secs: int = 10, categories: list[str] | None = None, url: str, wait_secs: int = 10, categories: list[str] | None = None,
browser_profile: dict | None = None,
) -> ConsentTestResult: ) -> ConsentTestResult:
"""Run 3-phase consent test on a URL. """Run 3-phase consent test on a URL.
@@ -124,6 +125,9 @@ async def run_consent_test(
url: Website URL to test. url: Website URL to test.
wait_secs: Seconds to wait per phase. wait_secs: Seconds to wait per phase.
categories: Optional list of category names to test (empty = test all). categories: Optional list of category names to test (empty = test all).
browser_profile: Optional profile dict from browser_profiles.py — waehlt
die Engine (blink/gecko/webkit) + channel (chrome/msedge) bzw.
executable_path (Brave). None = Chromium-Default (wie bisher).
""" """
result = ConsentTestResult() result = ConsentTestResult()
wait_ms = wait_secs * 1000 wait_ms = wait_secs * 1000
@@ -136,10 +140,9 @@ async def run_consent_test(
from services.cmp_extractor import CMPCapture from services.cmp_extractor import CMPCapture
cmp_capture = CMPCapture() cmp_capture = CMPCapture()
async with async_playwright() as p: _prof = browser_profile or {}
browser = await p.chromium.launch( _engine = _prof.get("engine", "blink")
headless=True, _chromium_args = [
args=[
"--no-sandbox", "--no-sandbox",
"--disable-dev-shm-usage", "--disable-dev-shm-usage",
"--disable-blink-features=AutomationControlled", "--disable-blink-features=AutomationControlled",
@@ -152,8 +155,22 @@ async def run_consent_test(
"--disable-renderer-backgrounding", "--disable-renderer-backgrounding",
"--disable-backgrounding-occluded-windows", "--disable-backgrounding-occluded-windows",
"--js-flags=--max-old-space-size=2048", "--js-flags=--max-old-space-size=2048",
], ]
)
async with async_playwright() as p:
# Engine-Wahl je Profil: Firefox/Gecko, WebKit/Safari oder Blink
# (Chromium-Default / Chrome-/Edge-Channel / Brave via executable_path).
if _engine == "gecko":
browser = await p.firefox.launch(headless=True)
elif _engine == "webkit":
browser = await p.webkit.launch(headless=True)
else:
_launch: dict = {"headless": True, "args": _chromium_args}
if _prof.get("channel"):
_launch["channel"] = _prof["channel"]
if _prof.get("executable_path"):
_launch["executable_path"] = _prof["executable_path"]
browser = await p.chromium.launch(**_launch)
try: try:
# ── Phase A: Before consent ────────────────────────── # ── Phase A: Before consent ──────────────────────────