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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return message.substring(0, prefix.length) == prefix; | 179 return message.substring(0, prefix.length) == prefix; |
180 }; | 180 }; |
181 | 181 |
182 Utils.installTitleEventHandler = function(element, event) { | 182 Utils.installTitleEventHandler = function(element, event) { |
183 element.addEventListener(event, function(e) { | 183 element.addEventListener(event, function(e) { |
184 Utils.setResultInTitle(e.type.toUpperCase()); | 184 Utils.setResultInTitle(e.type.toUpperCase()); |
185 }, false); | 185 }, false); |
186 }; | 186 }; |
187 | 187 |
188 Utils.isRenewalMessage = function(message) { | 188 Utils.isRenewalMessage = function(message) { |
189 if (message.messageType != 'license-renewal') | 189 return (message.messageType == 'license-renewal'); |
190 return false; | |
191 | |
192 if (!Utils.hasPrefix(message.message, EME_RENEWAL_MESSAGE_HEADER)) { | |
193 Utils.failTest('license-renewal message doesn\'t contain expected header', | |
194 EME_RENEWAL_MISSING_HEADER); | |
195 } | |
196 return true; | |
197 }; | 190 }; |
198 | 191 |
199 Utils.resetTitleChange = function() { | 192 Utils.resetTitleChange = function() { |
200 this.titleChanged = false; | 193 this.titleChanged = false; |
201 document.title = ''; | 194 document.title = ''; |
202 }; | 195 }; |
203 | 196 |
204 Utils.sendRequest = function( | 197 Utils.sendRequest = function( |
205 requestType, responseType, message, serverURL, onResponseCallbackFn, | 198 requestType, responseType, message, serverURL, onResponseCallbackFn, |
206 forceInvalidResponse) { | 199 forceInvalidResponse) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 var time = Utils.getCurrentTimeString(); | 262 var time = Utils.getCurrentTimeString(); |
270 // Log to document. | 263 // Log to document. |
271 Utils.documentLog(arguments[0], time); | 264 Utils.documentLog(arguments[0], time); |
272 // Log to JS console. | 265 // Log to JS console. |
273 var logString = time + ' - '; | 266 var logString = time + ' - '; |
274 for (var i = 0; i < arguments.length; i++) { | 267 for (var i = 0; i < arguments.length; i++) { |
275 logString += ' ' + arguments[i]; | 268 logString += ' ' + arguments[i]; |
276 } | 269 } |
277 console.log(logString); | 270 console.log(logString); |
278 }; | 271 }; |
OLD | NEW |