Index: LayoutTests/media/media-controls.js |
diff --git a/LayoutTests/media/media-controls.js b/LayoutTests/media/media-controls.js |
index e0630476439bc8a4c84ac9bb472f0833f4e212ef..67f9fac06c827f3c50eed5c1dc6d20d7e03bd697 100644 |
--- a/LayoutTests/media/media-controls.js |
+++ b/LayoutTests/media/media-controls.js |
@@ -1,3 +1,5 @@ |
+var captionsButtonElement; |
+var captionsButtonCoordinates; |
function mediaControlsElement(first, id) |
{ |
@@ -73,3 +75,36 @@ function textTrackDisplayElement(parentElement, id, cueNumber) |
return displayElement; |
} |
+ |
+function testClosedCaptionsButtonVisibility(expected) |
+{ |
+ try { |
+ captionsButtonElement = mediaControlsElement(internals.shadowRoot(video).firstChild, "-webkit-media-controls-toggle-closed-captions-button"); |
+ captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggle-closed-captions-button"); |
+ } catch (exception) { |
+ consoleWrite("Failed to find a closed captions button or its coordinates: " + exception); |
+ if (expected) |
+ failTest(); |
+ return; |
+ } |
+ |
+ consoleWrite(""); |
+ if (expected == true) { |
+ consoleWrite("** Caption button should be visible and enabled because we have a captions track."); |
+ testExpected("captionsButtonCoordinates[0]", 0, ">"); |
+ testExpected("captionsButtonCoordinates[1]", 0, ">"); |
+ testExpected("captionsButtonElement.disabled", false); |
+ } else { |
+ consoleWrite("** Caption button should not be visible as there are no caption tracks."); |
+ testExpected("captionsButtonCoordinates[0]", 0, "<="); |
+ testExpected("captionsButtonCoordinates[1]", 0, "<="); |
+ } |
+} |
+ |
+function clickCCButton() |
+{ |
+ consoleWrite("*** Click the CC button."); |
+ eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordinates[1]); |
+ eventSender.mouseDown(); |
+ eventSender.mouseUp(); |
+} |