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

Side by Side Diff: media/test/data/eme_player_js/utils.js

Issue 854633003: Verify heartbeat messages have type 'license-renewal' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove heartbeat Created 5 years, 11 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
OLDNEW
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
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.isHeartBeatMessage = function(msg) { 205 Utils.isRenewalMessage = function(message) {
206 return Utils.hasPrefix(Utils.convertToUint8Array(msg), HEART_BEAT_HEADER); 206 if (message.messageType != 'license-renewal')
207 return false;
208
209 if (!Utils.isRenewalMessagePrefixed(message.message)) {
210 Utils.failTest('license-renewal message doesn\'t contain expected header',
211 KEY_ERROR);
212 }
213 return true;
214 };
215
216 // For the prefixed API renewal messages are determined by looking at the
217 // message and finding a known string.
218 Utils.isRenewalMessagePrefixed = function(msg) {
219 return Utils.hasPrefix(Utils.convertToUint8Array(msg),
220 RENEWAL_MESSAGE_HEADER);
207 }; 221 };
208 222
209 Utils.resetTitleChange = function() { 223 Utils.resetTitleChange = function() {
210 this.titleChanged = false; 224 this.titleChanged = false;
211 document.title = ''; 225 document.title = '';
212 }; 226 };
213 227
214 Utils.sendRequest = function(requestType, responseType, message, serverURL, 228 Utils.sendRequest = function(requestType, responseType, message, serverURL,
215 onSuccessCallbackFn, forceInvalidResponse) { 229 onSuccessCallbackFn, forceInvalidResponse) {
216 var requestAttemptCount = 0; 230 var requestAttemptCount = 0;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 var time = Utils.getCurrentTimeString(); 289 var time = Utils.getCurrentTimeString();
276 // Log to document. 290 // Log to document.
277 Utils.documentLog(arguments[0], time); 291 Utils.documentLog(arguments[0], time);
278 // Log to JS console. 292 // Log to JS console.
279 var logString = time + ' - '; 293 var logString = time + ' - ';
280 for (var i = 0; i < arguments.length; i++) { 294 for (var i = 0; i < arguments.length; i++) {
281 logString += ' ' + arguments[i]; 295 logString += ' ' + arguments[i];
282 } 296 }
283 console.log(logString); 297 console.log(logString);
284 }; 298 };
OLDNEW
« media/test/data/eme_player_js/globals.js ('K') | « media/test/data/eme_player_js/player_utils.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698