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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return elementCoordinates(button); 61 return elementCoordinates(button);
62 } 62 }
63 63
64 function mediaControlsButtonDimensions(element, id) 64 function mediaControlsButtonDimensions(element, id)
65 { 65 {
66 var button = mediaControlsButton(element, id); 66 var button = mediaControlsButton(element, id);
67 var buttonBoundingRect = button.getBoundingClientRect(); 67 var buttonBoundingRect = button.getBoundingClientRect();
68 return new Array(buttonBoundingRect.width, buttonBoundingRect.height); 68 return new Array(buttonBoundingRect.width, buttonBoundingRect.height);
69 } 69 }
70 70
71 function textTrackContainerElement(parentElement) {
72 return mediaControlsElement(internals.shadowRoot(parentElement).firstChild,
73 "-webkit-media-text-track-container");
74 }
75
76 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
77 var containerElement = textTrackContainerElement(parentElement);
78 if (!containerElement)
79 return null;
80
81 var controlID = id;
82 if (controlID != 'cue')
83 controlID = "-webkit-media-text-track-" + id;
84
85 return textTrackCueElement(containerElement, controlID);
86 }
87
88 function textTrackCueElementByIndex(displayElement, cueNumber) {
89 for (i = 0; i < cueNumber; i++)
90 displayElement = displayElement.nextSibling;
91
92 return displayElement;
93 }
94
95 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.
96 return mediaControlsElement(containerElement.firstChild, controlID);
97 }
98
71 function textTrackDisplayElement(parentElement, id, cueNumber) 99 function textTrackDisplayElement(parentElement, id, cueNumber)
72 { 100 {
73 var textTrackContainerID = "-webkit-media-text-track-container"; 101 var containerElement = textTrackContainerElement(parentElement);
74 var containerElement = mediaControlsElement(internals.shadowRoot(parentEleme nt).firstChild, textTrackContainerID);
75 102
76 if (!containerElement) 103 if (!containerElement)
77 throw "Failed to find text track container element"; 104 throw "Failed to find text track container element";
78 105
79 if (!id) 106 if (!id)
80 return containerElement; 107 return containerElement;
81 108
82 if (arguments[1] != 'cue') 109 var controlID = id;
83 var controlID = "-webkit-media-text-track-" + arguments[1]; 110 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
84 else 111 controlID = "-webkit-media-text-track-" + id;
85 var controlID = arguments[1];
86 112
87 var displayElement = mediaControlsElement(containerElement.firstChild, contr olID); 113 var displayElement = textTrackCueElement(containerElement, controlID);
88 if (!displayElement) 114 if (!displayElement)
89 throw "No text track cue with display id '" + controlID + "' is currentl y visible"; 115 throw "No text track cue with display id '" + controlID + "' is currentl y visible";
90 116
91 if (cueNumber) { 117 if (cueNumber) {
92 for (i = 0; i < cueNumber; i++) 118 displayElement = textTrackCueElementByIndex(displayElement, cueNumber);
93 displayElement = displayElement.nextSibling;
94 119
95 if (!displayElement) 120 if (!displayElement)
96 throw "There are not " + cueNumber + " text track cues visible"; 121 throw "There are not " + cueNumber + " text track cues visible";
97 } 122 }
98 123
99 return displayElement; 124 return displayElement;
100 } 125 }
101 126
102 function isClosedCaptionsButtonVisible(currentMediaElement) 127 function isClosedCaptionsButtonVisible(currentMediaElement)
103 { 128 {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 192 }
168 193
169 function selectTextTrack(video, index) 194 function selectTextTrack(video, index)
170 { 195 {
171 clickCCButton(); 196 clickCCButton();
172 var trackListItemElement = textTrackListItemAtIndex(video, index); 197 var trackListItemElement = textTrackListItemAtIndex(video, index);
173 var trackListItemCoordinates = elementCoordinates(trackListItemElement); 198 var trackListItemCoordinates = elementCoordinates(trackListItemElement);
174 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]) ; 199 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]) ;
175 } 200 }
176 201
202 function clickTextTrackAtIndex(video, index)
203 {
204 var captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggl e-closed-captions-button");
205 clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1 ]);
206 var trackListItemElement = textTrackListItemAtIndex(video, index);
207 var trackListItemCoordinates = elementCoordinates(trackListItemElement);
208 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]) ;
209 }
210
177 function turnClosedCaptionsOff(video) 211 function turnClosedCaptionsOff(video)
178 { 212 {
179 selectTextTrack(video, -1); 213 clickTextTrackAtIndex(video, -1);
180 } 214 }
181 215
182 function runAfterHideMediaControlsTimerFired(func, mediaElement) 216 function runAfterHideMediaControlsTimerFired(func, mediaElement)
183 { 217 {
184 if (mediaElement.paused) 218 if (mediaElement.paused)
185 throw "The media element is not playing"; 219 throw "The media element is not playing";
186 220
187 // Compute the time it'll take until the controls will be invisible - 221 // Compute the time it'll take until the controls will be invisible -
188 // assuming playback has been started prior to invoking this 222 // assuming playback has been started prior to invoking this
189 // function. Allow 500ms slack. 223 // function. Allow 500ms slack.
190 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration Ms + 500; 224 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration Ms + 500;
191 225
192 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m ediaElement.currentTime)) 226 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m ediaElement.currentTime))
193 throw "The media will end before the controls have been hidden"; 227 throw "The media will end before the controls have been hidden";
194 228
195 setTimeout(func, hideTimeoutMs); 229 setTimeout(func, hideTimeoutMs);
196 } 230 }
OLDNEW
« 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