content/media/test/test_streams_element_capture_playback.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 <head>
     4   <title>Test that capturing a stream doesn't stop the underlying element from firing events</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     7   <script type="text/javascript" src="manifest.js"></script>
     8 </head>
     9 <body>
    10 <audio id="a"></audio>
    11 <pre id="test">
    12 <script class="testbody" type="text/javascript">
    13 SimpleTest.waitForExplicitFinish();
    15 var a = document.getElementById('a');
    16 var validTimeUpdate = false;
    18 function startTest() {
    19   a.src = "big.wav";
    20   var context = new AudioContext();
    21   var node = context.createMediaElementSource(a);
    22   node.connect(context.destination);
    23   a.addEventListener("timeupdate", function() {
    24     if (a.currentTime > 0.0 && a.currentTime < 5.0 && !validTimeUpdate) {
    25       validTimeUpdate = true;
    26       ok(true, "Received reasonable currentTime in a timeupdate");
    27       SimpleTest.finish();
    28     }
    29   });
    30   a.addEventListener("ended", function() {
    31     if (!validTimeUpdate) {
    32       ok(false, "Received reasonable currentTime in a timeupdate");
    33       SimpleTest.finish();
    34     }
    35   });
    36   a.play();
    37 }
    39 if (a.canPlayType("audio/wave")) {
    40   startTest();
    41 } else {
    42   todo(false, "No playable audio");
    43 }
    44 </script>
    45 </pre>
    46 </body>
    47 </html>

mercurial