[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser/tor-browser-45.2.0esr-6.5-1] Regression tests for Bug 1517: Reduce precision of time for Javascript.
commit b60b8871fa08feaaca24bcf6dff43df0cd1c5f29
Author: Arthur Edelstein <arthuredelstein@xxxxxxxxx>
Date: Fri May 27 11:31:48 2016 -0700
Regression tests for Bug 1517: Reduce precision of time for Javascript.
---
tbb-tests/audio.ogg | Bin 0 -> 16521 bytes
tbb-tests/mochitest.ini | 3 ++
tbb-tests/noaudio.webm | Bin 0 -> 105755 bytes
tbb-tests/test_tor_bug1517.html | 79 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+)
diff --git a/tbb-tests/audio.ogg b/tbb-tests/audio.ogg
new file mode 100644
index 0000000..d7f6a0c
Binary files /dev/null and b/tbb-tests/audio.ogg differ
diff --git a/tbb-tests/mochitest.ini b/tbb-tests/mochitest.ini
index 2dc049a..3d2e7c9 100644
--- a/tbb-tests/mochitest.ini
+++ b/tbb-tests/mochitest.ini
@@ -1,8 +1,11 @@
[DEFAULT]
support-files =
+ audio.ogg
match.png
mismatch.png
+ noaudio.webm
+[test_tor_bug1517.html]
[test_tor_bug2874.html]
[test_tor_bug2875.html]
[test_tor_bug4755.html]
diff --git a/tbb-tests/noaudio.webm b/tbb-tests/noaudio.webm
new file mode 100644
index 0000000..9207017
Binary files /dev/null and b/tbb-tests/noaudio.webm differ
diff --git a/tbb-tests/test_tor_bug1517.html b/tbb-tests/test_tor_bug1517.html
new file mode 100644
index 0000000..67d6693
--- /dev/null
+++ b/tbb-tests/test_tor_bug1517.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Tor bug
+https://trac.torproject.org/projects/tor/ticket/1517
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Tor Bug 1517</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://trac.torproject.org/projects/tor/ticket/1517">Tor Bug 1517</a>
+
+<!-- Canvas, Video, Audio elements for testing 'currentTime' -->
+<canvas id="test-canvas" width="100" height="100"></canvas>
+<video id="test-video"
+ src="http://example.com/tests/tbb-tests/noaudio.webm"></video>
+<audio id="test-audio"
+ src="http://example.com/tests/tbb-tests/audio.ogg"></audio>
+
+<!-- The main testing script -->
+<script type="application/javascript;version=1.7">
+ SimpleTest.requestFlakyTimeout("testing JS time-based fingerprinting");
+
+ // __later(delay)__.
+ // Return a promise that resolves after the requested delay in ms.
+ let later = function (delay) {
+ return new Promise((resolve, reject) => {
+ window.setTimeout(resolve, delay);
+ });
+ };
+
+ // The main testing task
+ add_task(function* () {
+ // Prepare for test of AudioContext.currentTime
+ let audioContext = new AudioContext();
+ // Prepare for test of CanvasStream.currentTime
+ let canvas = document.getElementById("test-canvas");
+ let context = canvas.getContext('2d');
+ context.fillText("test", 20, 20);
+ let canvasStream = canvas.captureStream(25);
+ // Prepare for test of HTMLVideoElement.currentTime
+ let video = document.getElementById("test-video");
+ video.currentTime = 1.25;
+ // Prepare for test of HTMLAudioElement.currenTime
+ let audio = document.getElementById("test-audio");
+ audio.currentTime = 1.35;
+ // Allow ~150 ms to elapse, so we can get non-zero
+ // time values for all elements.
+ yield later(150);
+ // Known ways to generate time stamps, in milliseconds
+ let timeStampCodes = [
+ 'performance.now()',
+ 'new Date().getTime()',
+ 'new Event("").timeStamp',
+ 'audioContext.currentTime * 1000',
+ 'canvasStream.currentTime * 1000',
+ 'video.currentTime * 1000',
+ 'audio.currentTime * 1000',
+ ];
+ // Loop through each timeStampCode, evaluate it,
+ // and check if it is rounded to the nearest 100 ms.
+ for (let timeStampCode of timeStampCodes) {
+ let timeStamp = eval(timeStampCode);
+ let roundedTimeStamp = 100*Math.round(timeStamp/100);
+ ok(timeStamp === roundedTimeStamp,
+ "'" + timeStampCode +
+ "' should be rounded to nearest 100 ms; saw " +
+ timeStamp);
+ }
+ });
+</script>
+
+
+</body>
+</html>
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits