Add new access object callback
[framework/web/webkit-efl.git] / LayoutTests / media / video-controls-captions.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5     <title>Test closed caption button toggling.</title>
6     <script src=media-file.js></script>
7     <script src=media-controls.js></script>
8     <script src=video-test.js></script>
9     <script>
10         var captionsButtonElement;
11         var captionsButtonCoordinates;
12
13         function startTest()
14         {
15             if (!window.eventSender) {
16                 consoleWrite("No eventSender found.");
17                 failTest();
18             }
19
20             try {
21                 captionsButtonElement = mediaControlsElement(internals.shadowRoot(video).firstChild, "-webkit-media-controls-toggle-closed-captions-button");
22                 captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggle-closed-captions-button");
23             } catch (exception) {
24                 consoleWrite("Failed to find a closed captions button or its coordinates: " + exception);
25                 failTest();
26                 return;
27             }
28
29             consoleWrite("");
30             consoleWrite("** Caption button should be visible and enabled because we have a captions track.");
31             testExpected("captionsButtonCoordinates[0]", 0, ">");
32             testExpected("captionsButtonCoordinates[1]", 0, ">");
33             testExpected("captionsButtonElement.disabled", false);
34
35             consoleWrite("");
36             consoleWrite("** The captions track should be listed in textTracks, but not yet loaded. **");
37             testExpected("video.textTracks.length", 1);
38             testExpected("video.textTracks[0].mode", "disabled");
39             checkCaptionsDisplay();
40
41             consoleWrite("");
42             consoleWrite("** Captions track should load and captions should become visible after button is clicked **");
43             clickCCButton();
44         }
45
46         function clickCCButton()
47         {
48             consoleWrite("*** Click the CC button.");
49             eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordinates[1]);
50             eventSender.mouseDown();
51             eventSender.mouseUp();
52         }
53
54         function checkCaptionsDisplay()
55         {
56             // When no tracks are loaded, this should report no text track container,
57             // when tracks are loaded but not visible, should report no cues visible,
58             // when tracks are loaded and visible, should properly check the text.
59             testExpected("textTrackDisplayElement(video, 'display').innerText", "Lorem");
60         }
61
62         function trackLoaded()
63         {
64             checkCaptionsDisplay();
65
66             consoleWrite("");
67             consoleWrite("** Captions should not be visible after button is clicked again **");
68             clickCCButton();
69             checkCaptionsDisplay();
70
71             endTest();
72         }
73
74         function loaded()
75         {
76             findMediaElement();
77             consoleWrite("Set the user language preference so that the track will be chosen when the CC button is clicked.");
78             run("internals.setUserPreferredLanguages(['en'])");
79
80             waitForEvent('canplaythrough', startTest);
81
82             video.src = findMediaFile('video', 'content/counting');
83         }
84     </script>
85 </head>
86 <body onload="loaded()">
87     <p>Tests that the closed captions button, when toggled, updates the text track display area.</p>
88     <video controls >
89         <track src="track/captions-webvtt/captions-fast.vtt" kind="captions" srclang="en" onload="trackLoaded()">
90     </video>
91
92 </body>
93 </html>