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

Side by Side Diff: LayoutTests/media/encrypted-media/encrypted-media-utils.js

Issue 397463005: Change EME WebIDL to use ArrayBuffer/ArrayBufferView. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 4 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 var console = null; 1 var console = null;
2 2
3 function consoleWrite(text) 3 function consoleWrite(text)
4 { 4 {
5 if (!console && document.body) { 5 if (!console && document.body) {
6 console = document.createElement('div'); 6 console = document.createElement('div');
7 document.body.appendChild(console); 7 document.body.appendChild(console);
8 } 8 }
9 var span = document.createElement('span'); 9 var span = document.createElement('span');
10 span.appendChild(document.createTextNode(text)); 10 span.appendChild(document.createTextNode(text));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // http://tools.ietf.org/html/draft-ietf-jose-json-web-key 78 // http://tools.ietf.org/html/draft-ietf-jose-json-web-key
79 79
80 // Encodes data into base64 string without trailing '='. 80 // Encodes data into base64 string without trailing '='.
81 function base64Encode(data) 81 function base64Encode(data)
82 { 82 {
83 var result = btoa(String.fromCharCode.apply(null, data)); 83 var result = btoa(String.fromCharCode.apply(null, data));
84 return result.replace(/=+$/g, ''); 84 return result.replace(/=+$/g, '');
85 } 85 }
86 86
87 // Creates a JWK from raw key ID and key. 87 // Creates a JWK from raw key ID and key.
88 // |keyId| and |key| are expected to be ArrayBufferViews, not base64-encoded.
88 function createJWK(keyId, key) 89 function createJWK(keyId, key)
89 { 90 {
90 var jwk = '{"kty":"oct","kid":"'; 91 var jwk = '{"kty":"oct","kid":"';
92 // FIXME: Should use base64URLEncoding.
91 jwk += base64Encode(keyId); 93 jwk += base64Encode(keyId);
92 jwk += '","k":"'; 94 jwk += '","k":"';
93 jwk += base64Encode(key); 95 jwk += base64Encode(key);
94 jwk += '"}'; 96 jwk += '"}';
95 return jwk; 97 return jwk;
96 } 98 }
97 99
98 // Creates a JWK Set from multiple JWKs. 100 // Creates a JWK Set from multiple JWKs.
99 function createJWKSet() 101 function createJWKSet()
100 { 102 {
(...skipping 13 matching lines...) Expand all
114 // currently no way to report a failed test in the test harness, errors 116 // currently no way to report a failed test in the test harness, errors
115 // are reported using force_timeout(). 117 // are reported using force_timeout().
116 if (message) 118 if (message)
117 consoleWrite(message + ': ' + error.message); 119 consoleWrite(message + ': ' + error.message);
118 else if (error) 120 else if (error)
119 consoleWrite(error.message); 121 consoleWrite(error.message);
120 122
121 test.force_timeout(); 123 test.force_timeout();
122 test.done(); 124 test.done();
123 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698