64c27e585756d6ca684506daef7f35f1c2ffcb91
[WebKit-https.git] / LayoutTests / media / track / track-in-band-style.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         <script src=../media-controls.js></script>
9
10         <script>
11
12                 function testCues()
13                 {
14                     cueDisplayElement = null;
15                     cueNode = null;
16                     try {
17                         cueDisplayElement = textTrackDisplayElement(video, 'display', 0);
18                         cueNode = textTrackDisplayElement(video, 'cue');
19                     } catch (ex) {
20                         consoleWrite('<br>Text track cue at time 0.3s not visible. Track cues are:');
21                         for (var i = 0; i < inbandTrack1.cues.length; i++)
22                             consoleWrite(" cue " + i + ": start time = " + inbandTrack1.cues[i].startTime.toFixed(2) + ", text = " + inbandTrack1.cues[i].text);
23                         failTest("<br>");
24                         return;
25                     }
26     
27                     consoleWrite("<br><i>** Test current cue colors<" + "/i>");
28                     testExpected("getComputedStyle(cueDisplayElement).color", "rgb(255, 255, 255)");
29                     testExpected("getComputedStyle(cueNode).backgroundColor", "rgb(0, 0, 0)");
30     
31                     endTest();
32                 }
33                 
34                 function tracksChanged()
35                 {
36                     run("video.play()");
37                     setTimeout(function() {
38                         video.pause();
39                         video.currentTime = 0.3;
40                         waitForEventOn(inbandTrack1, 'cuechange', testCues);
41                     }, 1000);
42                 }
43     
44                 function canplaythrough()
45                 {
46                     consoleWrite("<br><i>** Check initial in-band track states<" + "/i>");
47                     waitForEventOn(video.textTracks, 'change', tracksChanged);
48                     run("inbandTrack1 = video.textTracks[0]");
49                     testExpected("video.textTracks.length", 1);
50                     testExpected("inbandTrack1.language", "en");
51                     testExpected("inbandTrack1.kind", "captions");
52                     run("inbandTrack1.mode = 'showing'");
53                 }
54
55             function loaded()
56             {
57                 consoleWrite("Test that style to all cues is applied correctly.");
58                 findMediaElement();
59                 video.src = '../content/counting-captioned.mov';
60                 waitForEvent('canplaythrough', canplaythrough);
61             }
62
63         </script>
64     </head>
65     <body onload="loaded()">
66         <video controls >
67         </video>
68     </body>
69 </html>