content/media/test/test_wav_ended2.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 <head>
michael@0 4 <title>Wave Media test: ended and replaying</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 7 </head>
michael@0 8 <body>
michael@0 9 <!-- try with autoplay and no v.play in starttest, also with both -->
michael@0 10 <pre id="test">
michael@0 11 <script class="testbody" type="text/javascript">
michael@0 12 // Test if audio can be replayed after ended.
michael@0 13 var completed = false;
michael@0 14 var playingCount = 0;
michael@0 15 var endCount = 0;
michael@0 16
michael@0 17 function startTest() {
michael@0 18 if (completed)
michael@0 19 return;
michael@0 20
michael@0 21 var v = document.getElementById('v');
michael@0 22 v.play();
michael@0 23 }
michael@0 24
michael@0 25 function playbackStarted() {
michael@0 26 if (completed)
michael@0 27 return;
michael@0 28
michael@0 29 playingCount++;
michael@0 30 }
michael@0 31
michael@0 32 function playbackEnded() {
michael@0 33 if (completed)
michael@0 34 return;
michael@0 35
michael@0 36 endCount++;
michael@0 37 var v = document.getElementById('v');
michael@0 38 ok(v.currentTime >= 0.9 && v.currentTime <= 1.1,
michael@0 39 "Checking currentTime at end: " + v.currentTime);
michael@0 40 ok(v.ended, "Checking playback has ended");
michael@0 41 ok(playingCount > 0, "Expect at least one playing event");
michael@0 42 playingCount = 0;
michael@0 43 if (endCount < 2) {
michael@0 44 v.play();
michael@0 45 } else {
michael@0 46 ok(endCount == 2, "Check playback after ended event");
michael@0 47 completed = true;
michael@0 48 SimpleTest.finish();
michael@0 49 }
michael@0 50 }
michael@0 51
michael@0 52 SimpleTest.waitForExplicitFinish();
michael@0 53 </script>
michael@0 54 </pre>
michael@0 55 <audio id='v'
michael@0 56 onloadedmetadata='return startTest();'
michael@0 57 onplaying='return playbackStarted();'
michael@0 58 onended='return playbackEnded();'>
michael@0 59 <source type='audio/x-wav' src='r11025_s16_c1.wav'>
michael@0 60 </audio>
michael@0 61 </body>
michael@0 62 </html>

mercurial