tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / media / track / track-cues-enter-exit.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
6         <script src=../media-file.js></script>
7         <script src=../video-test.js></script>
8     </head>
9     <body>
10         <p>Tests that TextTrack's cues are indexed and updated in order during video playback. Test uses the enter and exits events on TextTrackCue.</p>
11         <video controls>
12             <track id="testTrack" src="captions-webvtt/cues-chrono-order.vtt" kind="captions" onload="loaded()">
13         </video>
14         <script>            
15
16         var cueCount = 0;
17         var currentCue;
18         var testTrack;
19
20         var trackLoaded = false;
21         var videoCanPlayThrough = false;
22
23         function attemptTests()
24         {
25             if (!trackLoaded || !videoCanPlayThrough)
26                 return;
27
28             testTrack = document.getElementById("testTrack");
29             testExpected("testTrack.track.cues.length", 3);
30             for (var i = 0; i < testTrack.track.cues.length; i++) {
31                 testTrack.track.cues[i].addEventListener('enter', cueEntered);
32                 testTrack.track.cues[i].addEventListener('exit', cueExited);
33             }
34             run("video.play()");
35             consoleWrite("");
36         }
37
38         function cueEntered()
39         {
40             consoleWrite("EVENT(enter)");
41
42             currentCue = event.target;
43
44             consoleWrite("This cue is the currently active cue:");
45             testExpected(currentCue, testTrack.track.activeCues[0]);
46             testExpected("currentCue.id", cueCount + 1);
47             consoleWrite("");
48         }
49
50         function cueExited()
51         {
52             consoleWrite("EVENT(exit)");
53             consoleWrite("");
54
55             ++cueCount;
56             if (cueCount == testTrack.track.cues.length)
57                 endTest();
58         }
59
60         waitForEvent('canplaythrough',
61             function () 
62             {
63                 videoCanPlayThrough = true;
64                 attemptTests();
65             }
66         );
67         
68         function loaded()
69         {
70             trackLoaded = true;
71             attemptTests();
72         }
73
74         findMediaElement();
75         video.src = findMediaFile("video", "../content/test");
76         
77         </script>
78     </body>
79 </html>