Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/media-controls.js |
| diff --git a/third_party/WebKit/LayoutTests/media/media-controls.js b/third_party/WebKit/LayoutTests/media/media-controls.js |
| index eb96ca8c85a578b982d225581f7f1e0f0d0dc993..3a59c4d651bc72bfbb10b8cf84673c439d483a4d 100644 |
| --- a/third_party/WebKit/LayoutTests/media/media-controls.js |
| +++ b/third_party/WebKit/LayoutTests/media/media-controls.js |
| @@ -47,13 +47,18 @@ function mediaControlsButton(element, id) |
| return button; |
| } |
| +function elementCoordinates(element) |
| +{ |
| + var elementBoundingRect = element.getBoundingClientRect(); |
| + var x = elementBoundingRect.left + elementBoundingRect.width / 2; |
| + var y = elementBoundingRect.top + elementBoundingRect.height / 2; |
| + return new Array(x, y); |
| +} |
| + |
| function mediaControlsButtonCoordinates(element, id) |
| { |
| var button = mediaControlsButton(element, id); |
| - var buttonBoundingRect = button.getBoundingClientRect(); |
| - var x = buttonBoundingRect.left + buttonBoundingRect.width / 2; |
| - var y = buttonBoundingRect.top + buttonBoundingRect.height / 2; |
| - return new Array(x, y); |
| + return elementCoordinates(button); |
| } |
| function mediaControlsButtonDimensions(element, id) |
| @@ -119,14 +124,48 @@ function testClosedCaptionsButtonVisibility(expected) |
| } |
| } |
| -function clickCCButton() |
| +function clickAtCoordinates(x, y) |
| { |
| - consoleWrite("*** Click the CC button."); |
| - eventSender.mouseMoveTo(captionsButtonCoordinates[0], captionsButtonCoordinates[1]); |
| + eventSender.mouseMoveTo(x, y); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| } |
| +function clickCCButton() |
| +{ |
| + consoleWrite("*** Click the CC button."); |
| + clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1]); |
| +} |
| + |
| +function textTrackListItem(video, index) |
|
fs
2016/02/23 13:16:43
...AtIndex? ...WithIndex?
srivats
2016/02/24 05:20:16
Done.
|
| +{ |
| + var textTrackListElementID = "-internal-media-controls-text-track-list"; |
| + var textTrackListElement = mediaControlsElement(internals.shadowRoot(video).firstChild, textTrackListElementID); |
| + if (!textTrackListElement) |
| + throw "Failed to find text track list element"; |
| + |
| + var tracksSectionElement = textTrackListElement.lastChild; |
| + var trackListItems = tracksSectionElement.childNodes; |
| + for (var i = 0; i < trackListItems.length; i++) { |
| + var trackListItem = trackListItems[i]; |
| + if (trackListItem.firstChild.getAttribute("data-track-index") == index) |
| + return trackListItem; |
| + } |
| +} |
| + |
| +function selectTextTrack(video, index) |
| +{ |
| + clickCCButton(); |
| + var trackListItemElement = textTrackListItem(video, index); |
| + var trackListItemCoordinates = elementCoordinates(trackListItemElement); |
| + clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]); |
| +} |
| + |
| +function turnClosedCaptionsOff(video) |
| +{ |
| + selectTextTrack(video, -1); |
| +} |
| + |
| function runAfterHideMediaControlsTimerFired(func, mediaElement) |
| { |
| if (mediaElement.paused) |