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

Side by Side Diff: third_party/WebKit/LayoutTests/media/media-controls.js

Issue 2265463002: Remove unused functions from media-controls.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | no next file » | 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 if (!captionsButtonElement.disabled 129 if (!captionsButtonElement.disabled
130 && captionsButtonCoordinates[0] > 0 130 && captionsButtonCoordinates[0] > 0
131 && captionsButtonCoordinates[1] > 0) { 131 && captionsButtonCoordinates[1] > 0) {
132 return true; 132 return true;
133 } 133 }
134 134
135 return false; 135 return false;
136 } 136 }
137 137
138 function testClosedCaptionsButtonVisibility(expected)
139 {
140 try {
141 captionsButtonElement = mediaControlsButton(mediaElement, "toggle-closed -captions-button");
142 captionsButtonCoordinates = mediaControlsButtonCoordinates(mediaElement, "toggle-closed-captions-button");
143 } catch (exception) {
144 consoleWrite("Failed to find a closed captions button or its coordinates : " + exception);
145 if (expected)
146 failTest();
147 return;
148 }
149
150 consoleWrite("");
151 if (expected == true) {
152 consoleWrite("** Caption button should be visible and enabled.");
153 testExpected("captionsButtonCoordinates[0]", 0, ">");
154 testExpected("captionsButtonCoordinates[1]", 0, ">");
155 testExpected("captionsButtonElement.disabled", false);
156 } else {
157 consoleWrite("** Caption button should not be visible.");
158 testExpected("captionsButtonCoordinates[0]", 0, "<=");
159 testExpected("captionsButtonCoordinates[1]", 0, "<=");
160 }
161 }
162
163 function clickAtCoordinates(x, y) 138 function clickAtCoordinates(x, y)
164 { 139 {
165 eventSender.mouseMoveTo(x, y); 140 eventSender.mouseMoveTo(x, y);
166 eventSender.mouseDown(); 141 eventSender.mouseDown();
167 eventSender.mouseUp(); 142 eventSender.mouseUp();
168 } 143 }
169 144
170 function clickCCButton()
171 {
172 consoleWrite("*** Click the CC button.");
173 clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1 ]);
174 }
175
176 function textTrackListItemAtIndex(video, index) 145 function textTrackListItemAtIndex(video, index)
177 { 146 {
178 var textTrackListElementID = "-internal-media-controls-text-track-list"; 147 var textTrackListElementID = "-internal-media-controls-text-track-list";
179 var textTrackListElement = mediaControlsElement(internals.shadowRoot(video). firstChild, textTrackListElementID); 148 var textTrackListElement = mediaControlsElement(internals.shadowRoot(video). firstChild, textTrackListElementID);
180 if (!textTrackListElement) 149 if (!textTrackListElement)
181 throw "Failed to find text track list element"; 150 throw "Failed to find text track list element";
182 151
183 var trackListItems = textTrackListElement.childNodes; 152 var trackListItems = textTrackListElement.childNodes;
184 for (var i = 0; i < trackListItems.length; i++) { 153 for (var i = 0; i < trackListItems.length; i++) {
185 var trackListItem = trackListItems[i]; 154 var trackListItem = trackListItems[i];
186 if (trackListItem.firstChild.getAttribute("data-track-index") == index) 155 if (trackListItem.firstChild.getAttribute("data-track-index") == index)
187 return trackListItem; 156 return trackListItem;
188 } 157 }
189 } 158 }
190 159
191 function selectTextTrack(video, index)
192 {
193 clickCCButton();
194 var trackListItemElement = textTrackListItemAtIndex(video, index);
195 var trackListItemCoordinates = elementCoordinates(trackListItemElement);
196 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]) ;
197 }
198
199 function clickTextTrackAtIndex(video, index) 160 function clickTextTrackAtIndex(video, index)
200 { 161 {
201 var captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggl e-closed-captions-button"); 162 var captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggl e-closed-captions-button");
202 clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1 ]); 163 clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1 ]);
203 var trackListItemElement = textTrackListItemAtIndex(video, index); 164 var trackListItemElement = textTrackListItemAtIndex(video, index);
204 var trackListItemCoordinates = elementCoordinates(trackListItemElement); 165 var trackListItemCoordinates = elementCoordinates(trackListItemElement);
205 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]) ; 166 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1]) ;
206 } 167 }
207 168
208 function turnClosedCaptionsOff(video) 169 function turnClosedCaptionsOff(video)
209 { 170 {
210 clickTextTrackAtIndex(video, -1); 171 clickTextTrackAtIndex(video, -1);
211 } 172 }
212 173
213 function runAfterHideMediaControlsTimerFired(func, mediaElement) 174 function runAfterHideMediaControlsTimerFired(func, mediaElement)
214 { 175 {
215 if (mediaElement.paused) 176 if (mediaElement.paused)
216 throw "The media element is not playing"; 177 throw "The media element is not playing";
217 178
218 // Compute the time it'll take until the controls will be invisible - 179 // Compute the time it'll take until the controls will be invisible -
219 // assuming playback has been started prior to invoking this 180 // assuming playback has been started prior to invoking this
220 // function. Allow 500ms slack. 181 // function. Allow 500ms slack.
221 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration Ms + 500; 182 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration Ms + 500;
222 183
223 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m ediaElement.currentTime)) 184 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m ediaElement.currentTime))
224 throw "The media will end before the controls have been hidden"; 185 throw "The media will end before the controls have been hidden";
225 186
226 setTimeout(func, hideTimeoutMs); 187 setTimeout(func, hideTimeoutMs);
227 } 188 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698