content/media/test/test_wav_ended2.html

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

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

mercurial