OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Utils provide logging functions and other JS functions commonly used by the | 5 // Utils provide logging functions and other JS functions commonly used by the |
6 // app and media players. | 6 // app and media players. |
7 var Utils = new function() { | 7 var Utils = new function() { |
8 this.titleChanged = false; | 8 this.titleChanged = false; |
9 }; | 9 }; |
10 | 10 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 function sendRequestAttempt() { | 220 function sendRequestAttempt() { |
221 requestAttemptCount++; | 221 requestAttemptCount++; |
222 if (requestAttemptCount == MAXIMUM_REQUEST_ATTEMPTS) { | 222 if (requestAttemptCount == MAXIMUM_REQUEST_ATTEMPTS) { |
223 Utils.failTest('FAILED: Exceeded maximum license request attempts.'); | 223 Utils.failTest('FAILED: Exceeded maximum license request attempts.'); |
224 return; | 224 return; |
225 } | 225 } |
226 var xmlhttp = new XMLHttpRequest(); | 226 var xmlhttp = new XMLHttpRequest(); |
227 xmlhttp.responseType = responseType; | 227 xmlhttp.responseType = responseType; |
228 xmlhttp.open(requestType, serverURL, true); | 228 xmlhttp.open(requestType, serverURL, true); |
229 | 229 xmlhttp.onerror = function(e) { |
| 230 Utils.timeLog('Request status: ' + this.statusText); |
| 231 Utils.failTest('FAILED: License request XHR failed with network error.'); |
| 232 }; |
230 xmlhttp.onload = function(e) { | 233 xmlhttp.onload = function(e) { |
231 if (this.status == 200) { | 234 if (this.status == 200) { |
232 if (onSuccessCallbackFn) | 235 if (onSuccessCallbackFn) |
233 onSuccessCallbackFn(this.response); | 236 onSuccessCallbackFn(this.response); |
234 } else { | 237 } else { |
235 Utils.timeLog('Bad response status: ' + this.status); | 238 Utils.timeLog('Bad response status: ' + this.status); |
236 Utils.timeLog('Bad response: ' + this.response); | 239 Utils.timeLog('Bad response: ' + this.response); |
237 Utils.timeLog('Retrying request if possible in ' + | 240 Utils.timeLog('Retrying request if possible in ' + |
238 REQUEST_RETRY_DELAY_MS + 'ms'); | 241 REQUEST_RETRY_DELAY_MS + 'ms'); |
239 setTimeout(sendRequestAttempt, REQUEST_RETRY_DELAY_MS); | 242 setTimeout(sendRequestAttempt, REQUEST_RETRY_DELAY_MS); |
(...skipping 27 matching lines...) Expand all Loading... |
267 var time = Utils.getCurrentTimeString(); | 270 var time = Utils.getCurrentTimeString(); |
268 // Log to document. | 271 // Log to document. |
269 Utils.documentLog(arguments[0], time); | 272 Utils.documentLog(arguments[0], time); |
270 // Log to JS console. | 273 // Log to JS console. |
271 var logString = time + ' - '; | 274 var logString = time + ' - '; |
272 for (var i = 0; i < arguments.length; i++) { | 275 for (var i = 0; i < arguments.length; i++) { |
273 logString += ' ' + arguments[i]; | 276 logString += ' ' + arguments[i]; |
274 } | 277 } |
275 console.log(logString); | 278 console.log(logString); |
276 }; | 279 }; |
OLD | NEW |