Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: third_party/WebKit/LayoutTests/media/media-controls.js

Issue 2121613002: Convert video-controls-[captions, overlay, track]* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nit Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/video-controls-captions.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b923623ff72fe17809c197bc339bbf72e5c5e7a2..c88eb7544a9971dcbbd4412ad123079d937adca1 100644
--- a/third_party/WebKit/LayoutTests/media/media-controls.js
+++ b/third_party/WebKit/LayoutTests/media/media-controls.js
@@ -68,10 +68,33 @@ function mediaControlsButtonDimensions(element, id)
return new Array(buttonBoundingRect.width, buttonBoundingRect.height);
}
+function textTrackContainerElement(parentElement) {
+ return mediaControlsElement(internals.shadowRoot(parentElement).firstChild,
+ "-webkit-media-text-track-container");
+}
+
+function textTrackCueDisplayElement(parentElement) {
+ var containerElement = textTrackContainerElement(parentElement);
+ return mediaControlsElement(containerElement.firstChild, "-webkit-media-text-track-display");
+}
+
+function textTrackCueElementByIndex(parentElement, cueIndex) {
+ var displayElement = textTrackCueDisplayElement(parentElement);
+ if (displayElement) {
+ for (i = 0; i < cueIndex; i++)
+ displayElement = displayElement.nextSibling;
+ }
+
+ return displayElement;
+}
+
+// TODO(srirama.m): Phase out the uses of this function and
+// replace with more specific functions at each call site.
+// For ex: textTrackDisplayElement(video, 'region') => textTrackRegionElement(video) and
+// textTrackDisplayElement(video, 'region-container') => textTrackRegionContainerElement(video).
function textTrackDisplayElement(parentElement, id, cueNumber)
{
- var textTrackContainerID = "-webkit-media-text-track-container";
- var containerElement = mediaControlsElement(internals.shadowRoot(parentElement).firstChild, textTrackContainerID);
+ var containerElement = textTrackContainerElement(parentElement);
if (!containerElement)
throw "Failed to find text track container element";
@@ -79,10 +102,9 @@ function textTrackDisplayElement(parentElement, id, cueNumber)
if (!id)
return containerElement;
- if (arguments[1] != 'cue')
- var controlID = "-webkit-media-text-track-" + arguments[1];
- else
- var controlID = arguments[1];
+ var controlID = id;
+ if (controlID != 'cue')
+ controlID = "-webkit-media-text-track-" + id;
var displayElement = mediaControlsElement(containerElement.firstChild, controlID);
if (!displayElement)
@@ -174,9 +196,18 @@ function selectTextTrack(video, index)
clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]);
}
+function clickTextTrackAtIndex(video, index)
+{
+ var captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggle-closed-captions-button");
+ clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1]);
+ var trackListItemElement = textTrackListItemAtIndex(video, index);
+ var trackListItemCoordinates = elementCoordinates(trackListItemElement);
+ clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]);
+}
+
function turnClosedCaptionsOff(video)
{
- selectTextTrack(video, -1);
+ clickTextTrackAtIndex(video, -1);
}
function runAfterHideMediaControlsTimerFired(func, mediaElement)
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/video-controls-captions.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698