OLD | NEW |
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // 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 |
117 // are reported using force_timeout(). | 117 // are reported using force_timeout(). |
118 if (message) | 118 if (message) |
119 consoleWrite(message + ': ' + error.message); | 119 consoleWrite(message + ': ' + error.message); |
120 else if (error) | 120 else if (error) |
121 consoleWrite(error.message); | 121 consoleWrite(error.message); |
122 | 122 |
123 test.force_timeout(); | 123 test.force_timeout(); |
124 test.done(); | 124 test.done(); |
125 } | 125 } |
| 126 |
| 127 function extractSingleKeyIdFromMessage(message) |
| 128 { |
| 129 try { |
| 130 var json = JSON.parse(String.fromCharCode.apply(null, new Uint8Array(mes
sage))); |
| 131 // Decode the first element of 'kids'. |
| 132 // FIXME: Switch to base64url. See |
| 133 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/en
crypted-media.html#using-base64url |
| 134 assert_equals(1, json.kids.length); |
| 135 var decoded_key = atob(json.kids[0]); |
| 136 // Convert to an Uint8Array and return it. |
| 137 return stringToUint8Array(decoded_key); |
| 138 } |
| 139 catch (o) { |
| 140 // Not valid JSON, so return message untouched as Uint8Array. |
| 141 // This is for backwards compatibility. |
| 142 // FIXME: Remove this once the code is switched to return JSON all |
| 143 // the time. |
| 144 return new Uint8Array(message); |
| 145 } |
| 146 } |
OLD | NEW |