| Index: LayoutTests/media/media-controls.js
|
| diff --git a/LayoutTests/media/media-controls.js b/LayoutTests/media/media-controls.js
|
| index eb96ca8c85a578b982d225581f7f1e0f0d0dc993..89e1674878fdf1290f0b8937b14a8c7698bca74b 100644
|
| --- a/LayoutTests/media/media-controls.js
|
| +++ b/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)
|
| +{
|
| + var textTrackListElementID = "-webkit-media-controls-closed-captions-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("x-webkit-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)
|
|
|