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

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 comments 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..8a4259ca54d6c7145307405044818f41b986bcd0 100644
--- a/third_party/WebKit/LayoutTests/media/media-controls.js
+++ b/third_party/WebKit/LayoutTests/media/media-controls.js
@@ -68,10 +68,37 @@ 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 textTrackCueElementById(parentElement, id) {
foolip 2016/07/05 13:37:00 It looks like you're only using this in one place
Srirama 2016/07/05 18:33:28 Just to return null and check for null instead of
+ var containerElement = textTrackContainerElement(parentElement);
+ if (!containerElement)
+ return null;
+
+ var controlID = id;
+ if (controlID != 'cue')
+ controlID = "-webkit-media-text-track-" + id;
+
+ return textTrackCueElement(containerElement, controlID);
+}
+
+function textTrackCueElementByIndex(displayElement, cueNumber) {
+ for (i = 0; i < cueNumber; i++)
+ displayElement = displayElement.nextSibling;
+
+ return displayElement;
+}
+
+function textTrackCueElement(containerElement, controlID){
foolip 2016/07/05 13:37:00 This helper doesn't seem to do much, going back to
Srirama 2016/07/05 18:33:28 Done.
+ return mediaControlsElement(containerElement.firstChild, controlID);
+}
+
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,18 +106,16 @@ 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')
foolip 2016/07/05 13:37:00 This special casing still seems silly. "cue" is ne
Srirama 2016/07/05 18:33:28 Yes, i have added the required functions for this
+ controlID = "-webkit-media-text-track-" + id;
- var displayElement = mediaControlsElement(containerElement.firstChild, controlID);
+ var displayElement = textTrackCueElement(containerElement, controlID);
if (!displayElement)
throw "No text track cue with display id '" + controlID + "' is currently visible";
if (cueNumber) {
- for (i = 0; i < cueNumber; i++)
- displayElement = displayElement.nextSibling;
+ displayElement = textTrackCueElementByIndex(displayElement, cueNumber);
if (!displayElement)
throw "There are not " + cueNumber + " text track cues visible";
@@ -174,9 +199,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