Bug 1369309 - Part 2: Add a test case to check whether media statistics has been spoofed correctly when 'privacy.resistFingerprinting' is true. r=jwwang, r=arthuredelstein
authorTim Huang <tihuang@mozilla.com>
Mon, 19 Jun 2017 14:43:27 +0800
changeset 373905 23efa91adf8a33e8e516b15db1a1031d8e997c18
parent 373904 81f871657e18ded2d101f3e36c1bac23ea61ad89
child 373906 9afd71d7438c5b7bbd01a317cf7490529b50fdc5
push id48490
push userryanvm@gmail.com
push dateThu, 10 Aug 2017 20:10:41 +0000
treeherderautoland@45ec9d0af14b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, arthuredelstein
bugs1369309
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1369309 - Part 2: Add a test case to check whether media statistics has been spoofed correctly when 'privacy.resistFingerprinting' is true. r=jwwang, r=arthuredelstein MozReview-Commit-ID: F6jNk58z7bH
dom/media/test/mochitest.ini
dom/media/test/test_video_stats_resistfingerprinting.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -1128,16 +1128,18 @@ skip-if = android_version == '22' # andr
 tags = webvtt
 [test_webvtt_event_same_time.html]
 tags = webvtt
 [test_unseekable.html]
 [test_video_to_canvas.html]
 skip-if = toolkit == 'android' # android(bug 1232305), bugs 1320418,1347953,1347954,1348140,1348386
 [test_video_in_audio_element.html]
 skip-if = toolkit == 'android' # bug 1372457
+[test_video_stats_resistfingerprinting.html]
+tags = resistfingerprinting
 [test_videoDocumentTitle.html]
 skip-if = toolkit == 'android' # android(bug 1232305)
 [test_VideoPlaybackQuality.html]
 skip-if = toolkit == 'android' # android(bug 1232305)
 [test_VideoPlaybackQuality_disabled.html]
 skip-if = android_version == '15' || android_version == '17' # android(bug 1232305)
 [test_volume.html]
 skip-if = toolkit == 'android' # android(bug 1232305)
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_video_stats_resistfingerprinting.html
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Mozilla Bug:
+https://bugzilla.mozilla.org/show_bug.cgi?id=1369309
+Tor Ticket:
+https://trac.torproject.org/projects/tor/ticket/15757
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1369309</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="manifest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=682299">Mozilla Bug 1369309</a>
+<a target="_blank" href="https://trac.torproject.org/projects/tor/ticket/15757">Tor Ticket 15757</a>
+
+<!-- The main testing script -->
+<script class="testbody" type="text/javascript">
+  var manager = new MediaTestManager;
+  // Push the setting of 'privacy.resistFingerprinting' into gTestPrefs, which
+  // will be set during MediaTestManager.runTests().
+  gTestPrefs.push(
+    ["privacy.resistFingerprinting", true]
+  );
+  var testCases = [
+    { name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266 },
+    { name:"seek-short.webm", type:"video/webm", width:320, height:240, duration:0.23 },
+  ];
+
+  function checkStats(v) {
+    is(v.mozParsedFrames, 0,
+        "mozParsedFrames should be 0 if fingerprinting resistance is enabled");
+    is(v.mozDecodedFrames, 0,
+        "mozDecodedFrames should be 0 if fingerprinting resistance is enabled");
+    is(v.mozPresentedFrames, 0,
+        "mozPresentedFrames should be 0 if fingerprinting resistance is enabled");
+    is(v.mozPaintedFrames, 0,
+        "mozPaintedFrames should be 0 if fingerprinting resistance is enabled");
+    is(v.mozFrameDelay, 0.0,
+        "mozFrameDelay should be 0.0 if fingerprinting resistance is enabled");
+    let playbackQuality = v.getVideoPlaybackQuality();
+    is(playbackQuality.creationTime, 0,
+        "VideoPlaybackQuality.creationTime should be 0 if fingerprinting resistance is enabled");
+    is(playbackQuality.totalVideoFrames, 0,
+        "VideoPlaybackQuality.totalVideoFrames should be 0 if fingerprinting resistance is enabled");
+    is(playbackQuality.droppedVideoFrames, 0,
+        "VideoPlaybackQuality.droppedVideoFrames should be 0 if fingerprinting resistance is enabled");
+    is(playbackQuality.corruptedVideoFrames, 0,
+        "VideoPlaybackQuality.corruptedVideoFrames should be 0 if fingerprinting resistance is enabled");
+  }
+
+  function startTest(test, token) {
+    let v = document.createElement("video");
+    v.token = token;
+    v.src = test.name;
+    manager.started(token);
+    once(v, "ended", () => {
+      checkStats(v);
+      removeNodeAndSource(v);
+      manager.finished(v.token);
+    });
+    v.play();
+  }
+
+  manager.runTests(testCases, startTest);
+
+</script>
+</body>
+</html>