content/media/test/test_bug654550.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=654550
michael@0 5 -->
michael@0 6
michael@0 7 <head>
michael@0 8 <title>Test for Bug 654550</title>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 <script type="text/javascript" src="manifest.js"></script>
michael@0 12 </head>
michael@0 13 <body>
michael@0 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=654550">Mozilla Bug 654550</a>
michael@0 15 <pre id="test">
michael@0 16 <script class="testbody" type="text/javascript">
michael@0 17
michael@0 18 /* Test for Bug 654550 */
michael@0 19
michael@0 20 // Parallel test must be disabled for media.video_stats.enabled is a global setting
michael@0 21 // to prevent the setting from changing unexpectedly in the middle of the test.
michael@0 22 PARALLEL_TESTS = 1;
michael@0 23 SimpleTest.waitForExplicitFinish();
michael@0 24 var manager = new MediaTestManager;
michael@0 25
michael@0 26 function checkStats(v, aShouldBeEnabled) {
michael@0 27 if (aShouldBeEnabled) {
michael@0 28 ok(v.mozParsedFrames != 0,
michael@0 29 "At least one value should be different from 0 if stats are enabled");
michael@0 30 } else {
michael@0 31 ok(!v.mozParsedFrames,
michael@0 32 "mozParsedFrames should be 0 if stats are disabled");
michael@0 33 ok(!v.mozDecodedFrames,
michael@0 34 "mozDecodedFrames should be 0 if stats are disabled");
michael@0 35 ok(!v.mozPresentedFrames,
michael@0 36 "mozPresentedFrames should be 0 if stats are disabled");
michael@0 37 ok(!v.mozPaintedFrames,
michael@0 38 "mozPaintedFrames should be 0 if stats are disabled");
michael@0 39 }
michael@0 40
michael@0 41 }
michael@0 42
michael@0 43 function ontimeupdate_statsEnabled(event) {
michael@0 44 var v = event.target;
michael@0 45 v.removeEventListener('timeupdate', ontimeupdate_statsEnabled, false);
michael@0 46 checkStats(v, true);
michael@0 47 SpecialPowers.popPrefEnv(
michael@0 48 function() {
michael@0 49 v.addEventListener("timeupdate", ontimeupdate_statsDisabled);
michael@0 50 });
michael@0 51 }
michael@0 52
michael@0 53 function ontimeupdate_statsDisabled(event) {
michael@0 54 var v = event.target;
michael@0 55 v.removeEventListener('timeupdate', ontimeupdate_statsDisabled, false);
michael@0 56 checkStats(v, false);
michael@0 57 removeNodeAndSource(v);
michael@0 58 manager.finished(v.token);
michael@0 59 }
michael@0 60
michael@0 61 function startTest(test, token) {
michael@0 62 var v = document.createElement('video');
michael@0 63 v.token = token;
michael@0 64 v.src = test.name;
michael@0 65 // playback may reach the end before pref is changed for the duration is short
michael@0 66 // set 'loop' to true to keep playing so that we won't miss 'timeupdate' events
michael@0 67 v.loop = true;
michael@0 68 manager.started(token);
michael@0 69 SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", true]]},
michael@0 70 function() {
michael@0 71 v.play();
michael@0 72 v.addEventListener("timeupdate", ontimeupdate_statsEnabled);
michael@0 73 });
michael@0 74 }
michael@0 75
michael@0 76 SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", false]]},
michael@0 77 function() {
michael@0 78 manager.runTests(gVideoTests, startTest);
michael@0 79 });
michael@0 80
michael@0 81 </script>
michael@0 82 </pre>
michael@0 83 </body>
michael@0 84 </html>

mercurial