| OLD | NEW |
| 1 var captionsButtonElement; | 1 var captionsButtonElement; |
| 2 var captionsButtonCoordinates; | 2 var captionsButtonCoordinates; |
| 3 | 3 |
| 4 // As specified in mediaControls.css, this is how long it takes to fade out cont
rols | 4 // As specified in mediaControls.css, this is how long it takes to fade out cont
rols |
| 5 const controlsFadeOutDurationMs = 300; | 5 const controlsFadeOutDurationMs = 300; |
| 6 | 6 |
| 7 // The timeout for the hide-after-no-mouse-movement behavior. Defined (and | 7 // The timeout for the hide-after-no-mouse-movement behavior. Defined (and |
| 8 // should mirror) the value 'timeWithoutMouseMovementBeforeHidingMediaControls' | 8 // should mirror) the value 'timeWithoutMouseMovementBeforeHidingMediaControls' |
| 9 // in MediaControls.cpp. | 9 // in MediaControls.cpp. |
| 10 const controlsMouseMovementTimeoutMs = 3000; | 10 const controlsMouseMovementTimeoutMs = 3000; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 function clickAtCoordinates(x, y) | 126 function clickAtCoordinates(x, y) |
| 127 { | 127 { |
| 128 eventSender.mouseMoveTo(x, y); | 128 eventSender.mouseMoveTo(x, y); |
| 129 eventSender.mouseDown(); | 129 eventSender.mouseDown(); |
| 130 eventSender.mouseUp(); | 130 eventSender.mouseUp(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 function textTrackListItemAtIndex(video, index) | 133 function textTrackListItemAtIndex(video, index) |
| 134 { | 134 { |
| 135 var textTrackListElementID = "-internal-media-controls-text-track-list"; | 135 var textTrackListElementID = "-internal-media-controls-text-track-list"; |
| 136 var textTrackListElement = mediaControlsElement(internals.shadowRoot(video).
firstChild, textTrackListElementID); | 136 var textTrackListElement = mediaControlsElement( |
| 137 internals.shadowRoot(video).firstChild, textTrackListElementID); |
| 137 if (!textTrackListElement) | 138 if (!textTrackListElement) |
| 138 throw "Failed to find text track list element"; | 139 throw "Failed to find text track list element"; |
| 139 | 140 |
| 140 var trackListItems = textTrackListElement.childNodes; | 141 var trackListItems = textTrackListElement.childNodes; |
| 141 for (var i = 0; i < trackListItems.length; i++) { | 142 for (var i = 0; i < trackListItems.length; i++) { |
| 142 var trackListItem = trackListItems[i]; | 143 var trackListItem = trackListItems[i]; |
| 143 if (trackListItem.firstChild.getAttribute("data-track-index") == index) | 144 if (trackListItem.firstChild.getAttribute("data-track-index") == index) |
| 144 return trackListItem; | 145 return trackListItem; |
| 145 } | 146 } |
| 146 } | 147 } |
| 147 | 148 |
| 149 function clickCaptionButton(video) |
| 150 { |
| 151 var captionsButtonCoordinates = |
| 152 mediaControlsButtonCoordinates(video, "toggle-closed-captions-button
"); |
| 153 clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1
]); |
| 154 } |
| 155 |
| 148 function clickTextTrackAtIndex(video, index) | 156 function clickTextTrackAtIndex(video, index) |
| 149 { | 157 { |
| 150 var captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggl
e-closed-captions-button"); | 158 clickCaptionButton(video); |
| 151 clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1
]); | |
| 152 var trackListItemElement = textTrackListItemAtIndex(video, index); | 159 var trackListItemElement = textTrackListItemAtIndex(video, index); |
| 153 var trackListItemCoordinates = elementCoordinates(trackListItemElement); | 160 var trackListItemCoordinates = elementCoordinates(trackListItemElement); |
| 154 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1])
; | 161 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1])
; |
| 155 } | 162 } |
| 156 | 163 |
| 157 function turnClosedCaptionsOff(video) | 164 function turnClosedCaptionsOff(video) |
| 158 { | 165 { |
| 159 clickTextTrackAtIndex(video, -1); | 166 clickTextTrackAtIndex(video, -1); |
| 160 } | 167 } |
| 161 | 168 |
| 169 function checkCaptionsVisible(video, captions) |
| 170 { |
| 171 for (var i = 0; i < captions.length; i++) { |
| 172 assert_equals(textTrackCueElementByIndex(video, i).innerText, captions[i])
; |
| 173 } |
| 174 } |
| 175 |
| 176 function checkCaptionsHidden(video) |
| 177 { |
| 178 assert_equals(textTrackDisplayElement(video), null); |
| 179 } |
| 180 |
| 162 function runAfterHideMediaControlsTimerFired(func, mediaElement) | 181 function runAfterHideMediaControlsTimerFired(func, mediaElement) |
| 163 { | 182 { |
| 164 if (mediaElement.paused) | 183 if (mediaElement.paused) |
| 165 throw "The media element is not playing"; | 184 throw "The media element is not playing"; |
| 166 | 185 |
| 167 // Compute the time it'll take until the controls will be invisible - | 186 // Compute the time it'll take until the controls will be invisible - |
| 168 // assuming playback has been started prior to invoking this | 187 // assuming playback has been started prior to invoking this |
| 169 // function. Allow 500ms slack. | 188 // function. Allow 500ms slack. |
| 170 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration
Ms + 500; | 189 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration
Ms + 500; |
| 171 | 190 |
| 172 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m
ediaElement.currentTime)) | 191 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m
ediaElement.currentTime)) |
| 173 throw "The media will end before the controls have been hidden"; | 192 throw "The media will end before the controls have been hidden"; |
| 174 | 193 |
| 175 setTimeout(func, hideTimeoutMs); | 194 setTimeout(func, hideTimeoutMs); |
| 176 } | 195 } |
| 177 | 196 |
| 178 function hasFullscreenButton(element) | 197 function hasFullscreenButton(element) |
| 179 { | 198 { |
| 180 var size = mediaControlsButtonDimensions(element, "fullscreen-button"); | 199 var size = mediaControlsButtonDimensions(element, "fullscreen-button"); |
| 181 return size[0] > 0 && size[1] > 0; | 200 return size[0] > 0 && size[1] > 0; |
| 182 } | 201 } |
| OLD | NEW |