OLD | NEW |
| 1 var captionsButtonElement; |
| 2 var captionsButtonCoordinates; |
1 | 3 |
2 function mediaControlsElement(first, id) | 4 function mediaControlsElement(first, id) |
3 { | 5 { |
4 for (var element = first; element; element = element.nextSibling) { | 6 for (var element = first; element; element = element.nextSibling) { |
5 // Not every element in the media controls has a shadow pseudo ID, eg. t
he | 7 // Not every element in the media controls has a shadow pseudo ID, eg. t
he |
6 // text nodes for the time values, so guard against exceptions. | 8 // text nodes for the time values, so guard against exceptions. |
7 try { | 9 try { |
8 if (internals.shadowPseudoId(element) == id) | 10 if (internals.shadowPseudoId(element) == id) |
9 return element; | 11 return element; |
10 } catch (exception) { } | 12 } catch (exception) { } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if (cueNumber) { | 68 if (cueNumber) { |
67 for (i = 0; i < cueNumber; i++) | 69 for (i = 0; i < cueNumber; i++) |
68 displayElement = displayElement.nextSibling; | 70 displayElement = displayElement.nextSibling; |
69 | 71 |
70 if (!displayElement) | 72 if (!displayElement) |
71 throw "There are not " + cueNumber + " text track cues visible"; | 73 throw "There are not " + cueNumber + " text track cues visible"; |
72 } | 74 } |
73 | 75 |
74 return displayElement; | 76 return displayElement; |
75 } | 77 } |
| 78 |
| 79 function testClosedCaptionsButtonVisibility(expected) |
| 80 { |
| 81 try { |
| 82 captionsButtonElement = mediaControlsElement(internals.shadowRoot(video)
.firstChild, "-webkit-media-controls-toggle-closed-captions-button"); |
| 83 captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggl
e-closed-captions-button"); |
| 84 } catch (exception) { |
| 85 consoleWrite("Failed to find a closed captions button or its coordinates
: " + exception); |
| 86 if (expected) |
| 87 failTest(); |
| 88 return; |
| 89 } |
| 90 |
| 91 consoleWrite(""); |
| 92 if (expected == true) { |
| 93 consoleWrite("** Caption button should be visible and enabled because we
have a captions track."); |
| 94 testExpected("captionsButtonCoordinates[0]", 0, ">"); |
| 95 testExpected("captionsButtonCoordinates[1]", 0, ">"); |
| 96 testExpected("captionsButtonElement.disabled", false); |
| 97 } else { |
| 98 consoleWrite("** Caption button should not be visible as there are no ca
ption tracks."); |
| 99 testExpected("captionsButtonCoordinates[0]", 0, "<="); |
| 100 testExpected("captionsButtonCoordinates[1]", 0, "<="); |
| 101 } |
| 102 } |
| 103 |
| 104 function clickCCButton() |
| 105 { |
| 106 consoleWrite("*** Click the CC button."); |
| 107 eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordina
tes[1]); |
| 108 eventSender.mouseDown(); |
| 109 eventSender.mouseUp(); |
| 110 } |
OLD | NEW |