[Modern Media Controls] Turn media/modern-media-controls/ios-inline-media-controls...
[WebKit-https.git] / LayoutTests / media / media-ended.html
1 <!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 canplaythroughCount = 0;
10             var audio;
11
12             function start()
13             {
14                 audio = document.querySelector("audio");
15                 waitForEvent("ended", ended);
16
17                 audio.src = findMediaFile("audio", "content/silence")
18             }
19
20             function ended()
21             {
22                 switch (++endedCount)
23                 {
24                     case 1:
25                         testExpected("audio.ended", true);
26
27                         // Change src but don't seek so that internal state isn't reset.
28                         audio.src = findMediaFile("audio", "content/silence")
29                         testExpected("audio.ended", false);
30
31                         consoleWrite("");
32                         break;
33                     case 2:
34                         testExpected("audio.ended", true);
35                         endTest();
36                         break;
37                 }
38             }
39         </script>
40     </head>
41     <body onload="start()">
42         <audio controls autoplay></audio>
43         <p><b>Test ended by:</b>
44         <ol>
45             <li>Play to the end.</li>
46             <li>When 'ended' event fires, change the source.</li>
47             <li>Verify that 'ended' event fires again on different source.</li>
48         </ol>
49         </p>
50     </body>
51 </html>