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

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

Issue 405733003: Update browser tests to support upcoming EME parameter type changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 12 matching lines...) Expand all
23 } 23 }
24 }; 24 };
25 25
26 Utils.convertToArray = function(input) { 26 Utils.convertToArray = function(input) {
27 if (Array.isArray(input)) 27 if (Array.isArray(input))
28 return input; 28 return input;
29 return [input]; 29 return [input];
30 }; 30 };
31 31
32 Utils.convertToUint8Array = function(msg) { 32 Utils.convertToUint8Array = function(msg) {
33 var ans = new Uint8Array(msg.length); 33 if (typeof msg == 'string') {
34 for (var i = 0; i < msg.length; i++) { 34 var ans = new Uint8Array(msg.length);
35 ans[i] = msg.charCodeAt(i); 35 for (var i = 0; i < msg.length; i++) {
36 ans[i] = msg.charCodeAt(i);
37 }
38 return ans;
36 } 39 }
37 return ans; 40 // Assume it is ArrayBuffer or ArrayBufferView. If it already a Uint8Array,
41 // this will just make a copy.
ddorwin 2014/07/20 22:35:05 ... of the view. right? Change the last sentence
jrummell 2014/07/23 22:30:05 Done.
42 return new Uint8Array(msg);
38 }; 43 };
39 44
40 Utils.createJWKData = function(keyId, key) { 45 Utils.createJWKData = function(keyId, key) {
41 // JWK routines copied from third_party/WebKit/LayoutTests/media/ 46 // JWK routines copied from third_party/WebKit/LayoutTests/media/
42 // encrypted-media/encrypted-media-utils.js 47 // encrypted-media/encrypted-media-utils.js
43 // 48 //
44 // Encodes data (Uint8Array) into base64 string without trailing '='. 49 // Encodes data (Uint8Array) into base64 string without trailing '='.
45 // TODO(jrummell): Update once the EME spec is updated to say base64url 50 // TODO(jrummell): Update once the EME spec is updated to say base64url
46 // encoding. 51 // encoding.
47 function base64Encode(data) { 52 function base64Encode(data) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 for (var i = 0; i < uintArray.length; i++) { 148 for (var i = 0; i < uintArray.length; i++) {
144 var hex = uintArray[i].toString(16); 149 var hex = uintArray[i].toString(16);
145 if (hex.length == 1) 150 if (hex.length == 1)
146 hex = '0' + hex; 151 hex = '0' + hex;
147 hex_str += hex; 152 hex_str += hex;
148 } 153 }
149 return hex_str; 154 return hex_str;
150 }; 155 };
151 156
152 Utils.getInitDataFromMessage = function(message, mediaType) { 157 Utils.getInitDataFromMessage = function(message, mediaType) {
153 var initData = message.message; 158 var initData = Utils.convertToUint8Array(message.message);
ddorwin 2014/07/20 22:35:05 This will probably need to change when we update C
jrummell 2014/07/23 22:30:06 Acknowledged.
154 if (mediaType.indexOf('mp4') != -1) { 159 if (mediaType.indexOf('mp4') != -1) {
155 // Temporary hack for Clear Key in v0.1. 160 // Temporary hack for Clear Key in v0.1.
156 // If content uses mp4, then message.message is PSSH data. Instead of 161 // If content uses mp4, then message.message is PSSH data. Instead of
157 // parsing that data we hard code the initData. 162 // parsing that data we hard code the initData.
158 initData = Utils.convertToUint8Array(KEY_ID); 163 initData = Utils.convertToUint8Array(KEY_ID);
159 } 164 }
160 return initData; 165 return initData;
161 }; 166 };
162 167
163 Utils.hasPrefix = function(msg, prefix) { 168 Utils.hasPrefix = function(msg, prefix) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 var time = Utils.getCurrentTimeString(); 241 var time = Utils.getCurrentTimeString();
237 // Log to document. 242 // Log to document.
238 Utils.documentLog(arguments[0], time); 243 Utils.documentLog(arguments[0], time);
239 // Log to JS console. 244 // Log to JS console.
240 var logString = time + ' - '; 245 var logString = time + ' - ';
241 for (var i = 0; i < arguments.length; i++) { 246 for (var i = 0; i < arguments.length; i++) {
242 logString += ' ' + arguments[i]; 247 logString += ' ' + arguments[i];
243 } 248 }
244 console.log(logString); 249 console.log(logString);
245 }; 250 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698