diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/components/resistfingerprinting/test/mochitest/test_bug1382499_touch_api.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/resistfingerprinting/test/mochitest/test_bug1382499_touch_api.html')
-rw-r--r-- | browser/components/resistfingerprinting/test/mochitest/test_bug1382499_touch_api.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/browser/components/resistfingerprinting/test/mochitest/test_bug1382499_touch_api.html b/browser/components/resistfingerprinting/test/mochitest/test_bug1382499_touch_api.html new file mode 100644 index 0000000000..c440d37cf2 --- /dev/null +++ b/browser/components/resistfingerprinting/test/mochitest/test_bug1382499_touch_api.html @@ -0,0 +1,70 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"/> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<script> +/* global SimpleTest SpecialPowers synthesizeTouch */ + +SimpleTest.waitForExplicitFinish(); + +function promiseEvent(target, eventName) { + return new Promise(resolve => { + target.addEventListener(eventName, resolve, {once: true}); + }); +} + +function promiseTouchEvent(target, type, offsetX, offsetY, params) { + let touchEventPromise = promiseEvent(target, type); + params.type = type; + synthesizeTouch(target, offsetX, offsetY, params); + return touchEventPromise; +} + +document.addEventListener("DOMContentLoaded", async () => { + const target0 = document.getElementById("target0"); + const touchParams = {force: 1.0, angle: 1.0, rx: 2, ry: 3}; + await SpecialPowers.pushPrefEnv({set: [["dom.w3c_touch_events.enabled", 1]]}); + + for (let seq of [0, 1, 2, 3]) { + let resist = false; + if (seq == 0) { + resist = true; + await SpecialPowers.pushPrefEnv({set: [["privacy.resistFingerprinting", true]]}); + } else if (seq == 1) { + await SpecialPowers.pushPrefEnv({set: [["privacy.resistFingerprinting", false]]}); + } else if (seq == 2) { + resist = true; + await SpecialPowers.pushPrefEnv({set: [ + ["privacy.fingerprintingProtection", true], + ["privacy.fingerprintingProtection.overrides", "+TouchEvents"] + ]}); + } else { + await SpecialPowers.pushPrefEnv({set: [ + ["privacy.fingerprintingProtection", true], + ["privacy.fingerprintingProtection.overrides", "-TouchEvents"] + ]}); + } + + info("starting test with fingerprinting resistance " + (resist ? "on" : "off") + " sequence number " + seq); + let touchEvent = await promiseTouchEvent(target0, "touchstart", 5, 5, touchParams); + info("touch event received"); + let touch = touchEvent.touches[0]; + + if (resist) { + is(touch.screenX, touch.clientX, "touch.screenX should be the same as touch.clientX"); + is(touch.screenY, touch.clientY, "touch.screenY should be the same as touch.clientY"); + // radiusX/radiusY may differ from the original rx/ry because of AppUnitsPerCSSPixel and AppUnitsPerDevPixel. + // So only check if the values are spoofed. + is(touch.radiusX, 0, "touch.radiusX"); + is(touch.radiusY, 0, "touch.radiusY"); + } + is(touch.force, resist ? 0.0 : touchParams.force, "touch.force"); + is(touch.rotationAngle, resist ? 0 : touchParams.angle, "touch.rotationAngle"); + await SpecialPowers.popPrefEnv(); + } + + SimpleTest.finish(); +}); +</script> +<div id="target0">target 0</div> |