video-controls-captions-trackmenu-localized.html 2.65 KB
Newer Older
dino@apple.com's avatar
dino@apple.com committed
1
2
3
4
5
6
7
8
9
10
<!DOCTYPE html>
<html>
    <head>
        <title>Testing that the track menu gets localized strings</title>
        <script src="media-controls.js"></script>
        <script src="media-file.js"></script>
        <script src="video-test.js"></script>
        <script src="trackmenu-test.js"></script>
        <script>

11
        var trackListSection;
dino@apple.com's avatar
dino@apple.com committed
12
13
14
15
16
17
18
19
20
21
22
        var item;

        if (window.testRunner)
            testRunner.dumpAsText();

        function testMenuHeaders()
        {
            var trackListElement = getTrackListElement();
            if (!trackListElement)
                return;

23
24
25
            trackListSection = trackListElement.querySelector("h3");
            if (!trackListSection) {
                failTest("There should be a single section element in track list menu");
dino@apple.com's avatar
dino@apple.com committed
26
27
28
                return;
            }

29
            consoleWrite("Heading should be labelled 'Subtitles'");
30
            testExpected("trackListSection.textContent", "Subtitles");
dino@apple.com's avatar
dino@apple.com committed
31
32
33
34
35
36
37
38

            var captionsEntries = trackListElement.querySelectorAll("li");
            if (!captionsEntries || captionsEntries.length <= 0) {
                failTest("Not enough items in captions menu");
                return;
            }

            item = captionsEntries[0];
39
            consoleWrite("<br>First item in captions menu should be labelled 'Off'");
dino@apple.com's avatar
dino@apple.com committed
40
            testExpected("item.textContent", "Off");
41

dino@apple.com's avatar
dino@apple.com committed
42
            item = captionsEntries[1];
43
44
45
46
            consoleWrite("<br>Second item in captions menu should be labelled 'English CC'");
            testExpected("item.textContent", "English CC");

            item = captionsEntries[2];
47
48
            consoleWrite("<br>Third item in captions menu should be labelled 'Laugh Track (English-United States)'");
            testExpected("item.textContent", "Laugh Track (English-United States)");
49
50

            item = captionsEntries[3];
51
52
            consoleWrite("<br>Fourth item in captions menu should be labelled 'Unknown SDH'");
            testExpected("item.textContent", "Unknown SDH");
53

dino@apple.com's avatar
dino@apple.com committed
54
55
56
57
58
59
            endTest();
        }

        function start()
        {
            findMediaElement();
60
            video.src = 'content/counting-captioned.mov';
dino@apple.com's avatar
dino@apple.com committed
61
62
63
64
65
66
67
68
69
            waitForEvent('canplaythrough', function () { startTrackMenuTest(testMenuHeaders); });
        }
        </script>
    </head>

    <body onload="start()">
        <p>Test that captions and subtitles menu items are localized.</p>
        <video width="500" height="300" controls>
            <track kind="captions" src="track/captions-webvtt/captions-fast.vtt">
70
            <track kind="subtitles" src="track/captions-webvtt/captions-fast.vtt" label="Laugh Track" srclang="en-US">
dino@apple.com's avatar
dino@apple.com committed
71
72
73
74
        </video>
    </body>
</html>