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.

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

mercurial