Track menu needs localization
[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                 // Track list should have two <ul> elements.
19                 var trackListSections = trackListElement.querySelectorAll("ul");
20                 if (!trackListSections || trackListSections.length != 2) {
21                     failTest("There should be two ul elements in track list menu");
22                     return;
23                 }
24                 for (var i = 0; i < trackListSections.length; i++) {
25                     consoleWrite("<br>*** Test menu section " + i + ".");
26                     var lastTrackLabel = null;
27                     var trackListItems = trackListSections[i].querySelectorAll("li");
28                     if (!trackListItems || trackListItems.length != 5) {
29                         failTest("There should be five li elements in this section");
30                         return;
31                     }
32                     for (var j = 0; j < trackListItems.length; j++) {
33                         var item = trackListItems[j];
34                         if (j == 0)
35                             logResult(item.textContent == "Off", "First item should be labelled off");
36                         else {
37                             if (lastTrackLabel)
38                                 logResult(item.textContent > lastTrackLabel, lastTrackLabel + " comes before " + item.textContent);
39                             else
40                                 logResult(true, item.textContent + " is the first real item in the list");
41                             lastTrackLabel = item.textContent;
42                         }
43                     }
44                     consoleWrite("Menu section " + i + " was ok.<br>");
45                 }
46                 endTest();
47             }
48
49             function start()
50             {
51                 findMediaElement();
52                 waitForEvent('canplaythrough', function () { startTrackMenuTest(testSortedMenu); });
53             }
54         </script>
55     </head>
56
57     <body onload="start()">
58         <p>Test that captions and subtitles are sorted in the menu.</p>
59         <video width="500" height="300" controls>
60             <source src="content/test.mp4" type="video/mp4">
61             <source src="content/test.ogv" type="video/ogg">
62             <track label="c" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">
63             <track label="b" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">
64             <track label="a" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="en">
65             <track label="d" kind="captions" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">
66             <track label="b" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">
67             <track label="a" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en-au">
68             <track label="c" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="en">
69             <track label="d" kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" srclang="ja">
70         </video>
71     </body>
72 </html>
73