[Mac] Captions menu should indicate language and type of track
[WebKit-https.git] / LayoutTests / media / video-controls-captions-trackmenu-sorted.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <title>Testing that the list of tracks is sorted</title>
5         <script src="media-controls.js"></script>
6         <script src="media-file.js"></script>
7         <script src="video-test.js"></script>
8         <script src="trackmenu-test.js"></script>
9         <script>
10             if (window.testRunner)
11                 testRunner.dumpAsText();
12
13             function testSortedMenu()
14             {
15                 var trackListElement = getTrackListElement();
16                 if (!trackListElement)
17                     return;
18                 var trackListSection = trackListElement.querySelector("ul");
19                 if (!trackListSection) {
20                     failTest("There should be a ul element in track list menu");
21                     return;
22                 }
23                 var lastTrackLabel = null;
24                 var trackListItems = trackListSection.querySelectorAll("li");
25                 if (!trackListItems || trackListItems.length != 7) {
26                     failTest("There should be seven li elements in the menu");
27                     return;
28                 }
29                 for (var j = 0; j < trackListItems.length; j++) {
30                     var item = trackListItems[j];
31                     if (j == 0)
32                         logResult(item.textContent == "Off", "First item should be labelled off");
33                     else {
34                         if (lastTrackLabel)
35                             logResult(item.textContent > lastTrackLabel, lastTrackLabel + " comes before " + item.textContent);
36                         else
37                             logResult(true, item.textContent + " is the first real item in the list");
38                         lastTrackLabel = item.textContent;
39                     }
40                 }
41                 endTest();
42             }
43
44             function start()
45             {
46                 findMediaElement();
47                 video.src = findMediaFile('video', 'content/test');
48                 waitForEvent('canplaythrough', function () { startTrackMenuTest(testSortedMenu); });
49             }
50         </script>
51     </head>
52
53     <body onload="start()">
54         <p>Test that captions and subtitles are sorted in the menu.</p>
55         <video width="500" height="300" controls>
56             <track label="c" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">
57             <track label="b" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">
58             <track label="a" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en">
59             <track label="b" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">
60             <track label="a" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">
61             <track label="c" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en">
62         </video>
63     </body>
64 </html>
65