# Privacy mode's fingerprint protection (S024), offline: tests/smoke/pages/fingerprint.html reads every surface
# with privacy mode off and on and saves them as fp-off.json / fp-on.json (shots fp-off.png / fp-on.png).
#   tools/smoke.sh tests/smoke/privacy-mode.txt
# Incognito windows start with it on (privacy.mode off, mode_incognito on): tests/smoke/privacy-incognito.txt.
wait 3
set /vpn/enabled false
set /privacy/mode false
wait 1
open @PAGES@/fingerprint.html
waitfor 30 document.title === "FP done"
save fp-off JSON.stringify(window.fp, null, 1)
shot fp-off
# The engine's own values: Servo's platform and appVersion, the real core count, the real screen.
assert window.fp.platform === "Linux" && window.fp.appVersion === "4.0" && window.fp.webgl.vendor === "Mozilla/Servo" && window.fp.languages.length === 1
assert window.fp.screen !== "0 0 0 0 24 24"
set /privacy/mode true
wait 1
# The real values go to the next load in the URL's hash (Servo doesn't keep window.name).
js location.href = "?on#" + encodeURIComponent(JSON.stringify({ canvas: window.fp.canvas, audio: window.fp.audio }))
wait 1
waitfor 30 document.title === "FP done"
save fp-on JSON.stringify(window.fp, null, 1)
shot fp-on
js window.off = JSON.parse(decodeURIComponent(location.hash.slice(1))); JSON.stringify(window.off)
# Common values, consistent with the Firefox user agent.
assert window.fp.hardwareConcurrency === 8 && window.fp.platform === "Linux x86_64" && window.fp.appVersion === "5.0 (X11)"
assert window.fp.webgl.vendor === "Mozilla" && window.fp.webgl.renderer === "Mozilla" && window.fp.webgl.unmaskedVendor === "Mozilla" && window.fp.webgl.unmaskedRenderer === "Mozilla"
# Desktop Firefox: no touch points, touch events can't be created; the language list as Firefox sends it.
assert window.fp.touchEvents === "function NotSupportedError" && window.fp.maxTouchPoints === 0
assert window.fp.languages.length === 2 && window.fp.languages[0] === window.fp.language && window.fp.language.startsWith(window.fp.languages[1] + "-")
assert ["1366 768", "1536 864", "1920 1080", "2560 1440", "3840 2160"].some(s => window.fp.screen === s + " " + s + " 24 24") && window.fp.availOrigin === "0 0"
# Noise: canvas and audio differ from the real values but stay stable within the page (no "!=" in the canvas read).
assert window.fp.canvas !== window.off.canvas && !window.fp.canvas.includes("!=") && window.fp.audio !== window.off.audio
# Every probed font measures as installed.
assert window.fp.fonts.count === 32
# Replaced functions still look native; frames (markup and script-made) see the same values as the page.
assert window.fp.nativeLooking === true
assert window.fp.frameMismatch.static.length === 0 && window.fp.frameMismatch.scripted.length === 0
# The time zone and language stay real.
assert window.fp.timezone === Intl.DateTimeFormat().resolvedOptions().timeZone && window.fp.language === navigator.language
# Same site, same run: the same canvas value after a reload.
js location.href = "?again#" + window.fp.canvas
wait 1
waitfor 30 document.title === "FP done"
assert window.fp.canvas === location.hash.slice(1)
flyout shield
wait 1
shot shield-on
flyout none
page nacre://settings/privacy_mode
wait 2
shot settings-privacy-mode
status done
quit
