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>
10 var captionsButtonElement;
11 var captionsButtonCoordinates;
15 if (!window.eventSender) {
16 consoleWrite("No eventSender found.");
21 captionsButtonElement = mediaControlsElement(internals.shadowRoot(video).firstChild, "-webkit-media-controls-toggle-closed-captions-button");
22 captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggle-closed-captions-button");
24 consoleWrite("Failed to find a closed captions button or its coordinates: " + exception);
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);
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();
42 consoleWrite("** Captions track should load and captions should become visible after button is clicked **");
46 function clickCCButton()
48 consoleWrite("*** Click the CC button.");
49 eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordinates[1]);
50 eventSender.mouseDown();
51 eventSender.mouseUp();
54 function checkCaptionsDisplay()
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");
62 function trackLoaded()
64 checkCaptionsDisplay();
67 consoleWrite("** Captions should not be visible after button is clicked again **");
69 checkCaptionsDisplay();
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'])");
80 waitForEvent('canplaythrough', startTest);
82 video.src = findMediaFile('video', 'content/counting');
86 <body onload="loaded()">
87 <p>Tests that the closed captions button, when toggled, updates the text track display area.</p>
89 <track src="track/captions-webvtt/captions-fast.vtt" kind="captions" srclang="en" onload="trackLoaded()">