feat(consent-tester): /scan-matrix echt — Profil je Engine + Per-Engine-Summary (Phase 1.2)
- _scanner_run reicht browser_profile an run_consent_test durch (statt Single-Chromium-Shim) - neue scan_matrix_summary.matrix_scan_dict: ConsentTestResult -> schlanke Matrix-dict-Form (phases fuer _extract_dimensions + kompakter `summary`: cookies_before_consent/after_reject, reject_respected-Heuristik [keine Verstoesse UND kein neuer Tracker], surface, screenshot) - multi_browser_scanner._run_one hebt summary + engine + is_mobile an die Zeile, verwirft die vollen Cookie-Listen (JSONB-Persistenz schlank) - consent_scanner: _ctx_base mit Mobile-Device-Emulation (iPhone-Profil -> echtes Mobile-Viewport/Touch), alle 5 new_context auf **_ctx_base - Tests: test_scan_matrix_summary (6) inkl. _extract_dimensions-Vertrag Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -172,15 +172,28 @@ async def run_consent_test(
|
||||
_launch["executable_path"] = _prof["executable_path"]
|
||||
browser = await p.chromium.launch(**_launch)
|
||||
|
||||
# Gemeinsame Context-Optionen. Bei Mobile-Profilen (Profil nennt ein
|
||||
# Playwright-`device`, z.B. „iPhone 15") echte Mobile-Emulation
|
||||
# (Viewport/UA/Touch) statt Desktop — sonst wäre die Mobile-Matrix-
|
||||
# Zeile nur Desktop-WebKit. Nur bekannte new_context-kwargs kopieren
|
||||
# (NICHT das volle Device-dict spreaden → default_browser_type bricht).
|
||||
_device = p.devices.get(_prof["device"]) if _prof.get("device") else None
|
||||
_ctx_base: dict = {
|
||||
"user_agent": USER_AGENT,
|
||||
"viewport": {"width": 1920, "height": 1080},
|
||||
"locale": "de-DE",
|
||||
"timezone_id": "Europe/Berlin",
|
||||
}
|
||||
if _device:
|
||||
for _k in ("user_agent", "viewport", "device_scale_factor",
|
||||
"is_mobile", "has_touch"):
|
||||
if _k in _device:
|
||||
_ctx_base[_k] = _device[_k]
|
||||
|
||||
try:
|
||||
# ── Phase A: Before consent ──────────────────────────
|
||||
logger.info("Phase A: First visit (no interaction)")
|
||||
ctx_a = await browser.new_context(
|
||||
user_agent=USER_AGENT,
|
||||
viewport={"width": 1920, "height": 1080},
|
||||
locale="de-DE",
|
||||
timezone_id="Europe/Berlin",
|
||||
)
|
||||
ctx_a = await browser.new_context(**_ctx_base)
|
||||
page_a = await ctx_a.new_page()
|
||||
await page_a.add_init_script(_INTERCEPTOR_INIT)
|
||||
if HAS_STEALTH:
|
||||
@@ -271,12 +284,7 @@ async def run_consent_test(
|
||||
|
||||
# ── Phase B: After rejecting ─────────────────────────
|
||||
logger.info("Phase B: Reject consent (%s)", banner.provider)
|
||||
ctx_b = await browser.new_context(
|
||||
user_agent=USER_AGENT,
|
||||
viewport={"width": 1920, "height": 1080},
|
||||
locale="de-DE",
|
||||
timezone_id="Europe/Berlin",
|
||||
)
|
||||
ctx_b = await browser.new_context(**_ctx_base)
|
||||
page_b = await ctx_b.new_page()
|
||||
await page_b.add_init_script(_INTERCEPTOR_INIT)
|
||||
if HAS_STEALTH:
|
||||
@@ -338,12 +346,7 @@ async def run_consent_test(
|
||||
|
||||
# ── Phase C: After accepting ─────────────────────────
|
||||
logger.info("Phase C: Accept consent (%s)", banner.provider)
|
||||
ctx_c = await browser.new_context(
|
||||
user_agent=USER_AGENT,
|
||||
viewport={"width": 1920, "height": 1080},
|
||||
locale="de-DE",
|
||||
timezone_id="Europe/Berlin",
|
||||
)
|
||||
ctx_c = await browser.new_context(**_ctx_base)
|
||||
page_c = await ctx_c.new_page()
|
||||
await page_c.add_init_script(_INTERCEPTOR_INIT)
|
||||
if HAS_STEALTH:
|
||||
@@ -411,12 +414,7 @@ async def run_consent_test(
|
||||
try:
|
||||
from services.category_tester import detect_categories, test_single_category
|
||||
|
||||
ctx_cat = await browser.new_context(
|
||||
user_agent=USER_AGENT,
|
||||
viewport={"width": 1920, "height": 1080},
|
||||
locale="de-DE",
|
||||
timezone_id="Europe/Berlin",
|
||||
)
|
||||
ctx_cat = await browser.new_context(**_ctx_base)
|
||||
page_cat = await ctx_cat.new_page()
|
||||
if HAS_STEALTH:
|
||||
await stealth_async(page_cat)
|
||||
@@ -461,12 +459,7 @@ async def run_consent_test(
|
||||
"skipping remaining %d categories",
|
||||
len(unique_cats) - len(result.category_tests))
|
||||
break
|
||||
cat_ctx = await browser.new_context(
|
||||
user_agent=USER_AGENT,
|
||||
viewport={"width": 1920, "height": 1080},
|
||||
locale="de-DE",
|
||||
timezone_id="Europe/Berlin",
|
||||
)
|
||||
cat_ctx = await browser.new_context(**_ctx_base)
|
||||
try:
|
||||
cat_result = await asyncio.wait_for(
|
||||
test_single_category(cat_ctx, url, cat, banner, wait_ms),
|
||||
|
||||
Reference in New Issue
Block a user