| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 var message = String.fromCharCode.apply(null, msg); | 195 var message = String.fromCharCode.apply(null, msg); |
| 196 return message.substring(0, prefix.length) == prefix; | 196 return message.substring(0, prefix.length) == prefix; |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 Utils.installTitleEventHandler = function(element, event) { | 199 Utils.installTitleEventHandler = function(element, event) { |
| 200 element.addEventListener(event, function(e) { | 200 element.addEventListener(event, function(e) { |
| 201 Utils.setResultInTitle(e.type); | 201 Utils.setResultInTitle(e.type); |
| 202 }, false); | 202 }, false); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 Utils.isRenewalMessage = function(message) { |
| 206 if (message.messageType != 'license-renewal') |
| 207 return false; |
| 208 |
| 209 if (!Utils.isHeartBeatMessage(message.message)) { |
| 210 Utils.failTest('license-renewal message doesn\'t contain HEART_BEAT_HEADER', |
| 211 KEY_ERROR); |
| 212 } |
| 213 return true; |
| 214 }; |
| 215 |
| 205 Utils.isHeartBeatMessage = function(msg) { | 216 Utils.isHeartBeatMessage = function(msg) { |
| 206 return Utils.hasPrefix(Utils.convertToUint8Array(msg), HEART_BEAT_HEADER); | 217 return Utils.hasPrefix(Utils.convertToUint8Array(msg), HEART_BEAT_HEADER); |
| 207 }; | 218 }; |
| 208 | 219 |
| 209 Utils.resetTitleChange = function() { | 220 Utils.resetTitleChange = function() { |
| 210 this.titleChanged = false; | 221 this.titleChanged = false; |
| 211 document.title = ''; | 222 document.title = ''; |
| 212 }; | 223 }; |
| 213 | 224 |
| 214 Utils.sendRequest = function(requestType, responseType, message, serverURL, | 225 Utils.sendRequest = function(requestType, responseType, message, serverURL, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 var time = Utils.getCurrentTimeString(); | 286 var time = Utils.getCurrentTimeString(); |
| 276 // Log to document. | 287 // Log to document. |
| 277 Utils.documentLog(arguments[0], time); | 288 Utils.documentLog(arguments[0], time); |
| 278 // Log to JS console. | 289 // Log to JS console. |
| 279 var logString = time + ' - '; | 290 var logString = time + ' - '; |
| 280 for (var i = 0; i < arguments.length; i++) { | 291 for (var i = 0; i < arguments.length; i++) { |
| 281 logString += ' ' + arguments[i]; | 292 logString += ' ' + arguments[i]; |
| 282 } | 293 } |
| 283 console.log(logString); | 294 console.log(logString); |
| 284 }; | 295 }; |
| OLD | NEW |