mirror of
https://github.com/feder-cr/invisible_playwright.git
synced 2026-06-19 09:08:06 +02:00
- BINARY_VERSION -> firefox-12 (self-calibrating font widths, per-family canvas distinctness, render-noise that preserves solid reference renders). - font_pool: the standard Windows fonts (Calibri, Franklin Gothic, Gadugi, Javanese Text, Myanmar Text) move from the per-profile optional set to core, so they are always present and the detected font set matches a real Windows install on every host. Defensive dedup in derive_font_prefs. - GPU persona applied on every platform (Linux/macOS present a coherent Windows GPU + WebGL params); pool re-rooted on a real-device GPU mix; render seeds recalibrated. - prefs: emit absolute per-family font widths that the binary self-calibrates. - geoip: always pull the latest mmdb via the releases/latest permalink, checked each launch, offline-safe (no pinned tag that can 404). - tests: per-font canvas distinctness, solid-readback purity under render-noise, always-present standard-font invariant, no duplicate families.
63 lines
2.5 KiB
Python
63 lines
2.5 KiB
Python
"""Regression guard: render-noise stays ACTIVE on high-entropy WebGL readbacks.
|
|
|
|
The near-uniform skip added 2026-06-18 (so fixed-hash reference checks on a solid
|
|
WebGL readback pass) must NOT disable noise on real fingerprint renders. A
|
|
high-entropy WebGL readback (>16 distinct colours) must still differ between two
|
|
seeds — i.e. the per-seed gamma noise is applied. Pairs with
|
|
test_canvas_render_stealth.py (solid readback stays pure).
|
|
|
|
Kept in its own file: it launches its own short-lived browsers, so it must not run
|
|
alongside another module's shared browser (the Playwright sync API cannot nest).
|
|
|
|
Run: pytest tests/test_webgl_noise_active.py -m e2e -v
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
|
|
import pytest
|
|
|
|
from invisible_playwright import InvisiblePlaywright
|
|
|
|
# A high-entropy render: 64 columns, each a distinct colour (>16 distinct → the
|
|
# near-uniform skip does NOT apply → noise must run).
|
|
_HIGH_ENTROPY_JS = """() => {
|
|
const c = document.createElement('canvas'); c.width = 64; c.height = 64;
|
|
const gl = c.getContext('webgl', {preserveDrawingBuffer: true});
|
|
if (!gl) return null;
|
|
gl.enable(gl.SCISSOR_TEST);
|
|
for (let k = 0; k < 64; k++) {
|
|
gl.scissor(k, 0, 1, 64);
|
|
gl.clearColor(k / 64, (63 - k) / 64, (k * 7 % 64) / 64, 1);
|
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
}
|
|
const buf = new Uint8Array(64 * 64 * 4);
|
|
gl.finish(); gl.readPixels(0, 0, 64, 64, gl.RGBA, gl.UNSIGNED_BYTE, buf);
|
|
return Array.from(buf);
|
|
}"""
|
|
|
|
|
|
def _render_hash(firefox_binary, seed: int):
|
|
with InvisiblePlaywright(
|
|
seed=seed, binary_path=firefox_binary, headless=True,
|
|
extra_prefs={"zoom.stealth.fpp.hw_seed": 1000 + seed},
|
|
) as b:
|
|
p = b.new_context().new_page()
|
|
p.goto("about:blank", timeout=30_000)
|
|
arr = p.evaluate(_HIGH_ENTROPY_JS)
|
|
if arr is None:
|
|
return None
|
|
return hashlib.sha256(bytes(arr)).hexdigest()
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_high_entropy_webgl_still_noised_per_seed(firefox_binary):
|
|
"""Two different seeds → two different per-seed gamma curves → the high-entropy
|
|
readback hashes must differ. Identical hashes would mean the noise was skipped
|
|
on a real (non-uniform) render — a regression of the uniform-skip scope."""
|
|
h1 = _render_hash(firefox_binary, 1)
|
|
h2 = _render_hash(firefox_binary, 2)
|
|
if h1 is None or h2 is None:
|
|
pytest.skip("webgl unavailable")
|
|
assert h1 != h2, \
|
|
"high-entropy WebGL readback identical across seeds → render-noise not applied"
|