[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser/tor-browser-52.1.0esr-7.0-2] Bug 10286: Regression tests for Touch API fingerprinting resistance
commit 00d2bfb5067659c352690c06cb85a8b76bc7addb
Author: Arthur Edelstein <arthuredelstein@xxxxxxxxx>
Date: Wed Apr 26 08:57:21 2017 -0700
Bug 10286: Regression tests for Touch API fingerprinting resistance
Also, fix typo in EventUtils.js
---
dom/events/test/mochitest.ini | 1 +
.../test_touchevent_resist_fingerprinting.html | 68 ++++++++++++++++++++++
testing/mochitest/tests/SimpleTest/EventUtils.js | 2 +-
3 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/dom/events/test/mochitest.ini b/dom/events/test/mochitest.ini
index 4322a7b..92e68f3 100644
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -185,3 +185,4 @@ skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
[test_wheel_default_action.html]
[test_bug687787.html]
[test_bug1298970.html]
+[test_touchevent_resist_fingerprinting.html]
diff --git a/dom/events/test/test_touchevent_resist_fingerprinting.html b/dom/events/test/test_touchevent_resist_fingerprinting.html
new file mode 100644
index 0000000..8ba7925
--- /dev/null
+++ b/dom/events/test/test_touchevent_resist_fingerprinting.html
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://trac.torproject.org/10286
+-->
+ <head>
+ <meta charset="utf-8">
+ <title>Test for Tor Bug 10286</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ </head>
+ <body>
+ <div id="target0">target0</div>
+ <script type="application/javascript">
+ SimpleTest.waitForExplicitFinish();
+
+ let promiseEvent = (target, eventName) => {
+ return new Promise(resolve => {
+ target.addEventListener(eventName, function eventOccurred(event) {
+ target.removeEventListener(eventName, eventOccurred, false);
+ resolve(event);
+ }, false);
+ });
+ }
+
+ let promiseTouchEvent = (target, type, offsetX, offsetY, params) => {
+ let touchEventPromise = promiseEvent(target, type);
+ params.type = type;
+ synthesizeTouch(target, offsetX, offsetY, params);
+ return touchEventPromise;
+ };
+
+ let target0 = document.getElementById("target0");
+ let touchParams = { force: 1.0, angle: 1.0, rx: 2, ry: 3 };
+
+ let runTest = async () => {
+ await SpecialPowers.pushPrefEnv(
+ { set: [["dom.w3c_touch_events.enabled", 1]] });
+ for (let resist of [false, true]) {
+ await SpecialPowers.pushPrefEnv(
+ { set: [["privacy.resistFingerprinting", resist]] });
+ info("starting test with fingerprinting resistance " +
+ (resist ? "on" : "off"));
+ 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");
+ }
+ is(touch.force, resist ? 0.0 : touchParams.force, "touch.force");
+ is(touch.radiusX, resist ? 1 : touchParams.rx, "touch.radiusX");
+ is(touch.radiusY, resist ? 1 : touchParams.ry, "touch.radiusY");
+ is(touch.rotationAngle, resist ? 0 : touchParams.angle,
+ "touch.rotationAngle");
+ }
+ }
+
+ window.onload = () => {
+ runTest().then(() => SimpleTest.finish());
+ };
+ </script>
+ </body>
+</html>
diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js
index a0df2d5..c36a480 100644
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -395,7 +395,7 @@ function synthesizeTouchAtPoint(left, top, aEvent, aWindow = window)
if (utils) {
var id = aEvent.id || 0;
var rx = aEvent.rx || 1;
- var ry = aEvent.rx || 1;
+ var ry = aEvent.ry || 1;
var angle = aEvent.angle || 0;
var force = aEvent.force || 1;
var modifiers = _parseModifiers(aEvent, aWindow);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits