blob: 17c03c42cb7ae42397a7ee5df27cf09fa3cda62e [file] [log] [blame]
eric.carlson@apple.comd0f1a742016-01-25 17:55:17 +00001<!DOCTYPE html>
2<html>
3 <head>
4 <script src=media-file.js></script>
5 <script src=video-test.js></script>
6
7 <script>
8 var endedCount = 0;
9 var audio;
10
11 function start()
12 {
13 consoleWrite("");
14 audio = document.querySelector("audio");
15 waitForEvent("ended", ended);
16 waitForEvent("canplaythrough", canplaythrough);
17
18 audio.src = findMediaFile("audio", "content/silence")
19 }
20
21 function canplaythrough()
22 {
23 run("audio.currentTime = 1.0");
24 run("audio.play()");
25 consoleWrite("");
26 }
27
28 function ended()
29 {
30 switch (++endedCount)
31 {
32 case 1:
33 testExpected("audio.ended", true);
34
35 run("audio.currentTime = 0");
36 setTimeout(endTest, 200);
37
38 consoleWrite("");
39 break;
40 default:
41 consoleWrite("");
42 failTest("'ended' event fired again");
43 break;
44 }
45 }
46 </script>
47 </head>
48 <body onload="start()">
49 <audio controls></audio>
50 <p><b>Test 'ended' event by:</b>
51 <ol>
52 <li>Playing to the end.</li>
53 <li>When 'ended' event fires, seek to 0.</li>
54 <li>Verify that 'ended' event is not fired again.</li>
55 </ol>
56 </p>
57 </body>
58</html>