| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test handling of invalid responses for update().</title> | 4 <title>Test handling of invalid responses for update().</title> |
| 5 <script src="encrypted-media-utils.js"></script> | 5 <script src="encrypted-media-utils.js"></script> |
| 6 <script src="../../resources/testharness.js"></script> | 6 <script src="../../resources/testharness.js"></script> |
| 7 <script src="../../resources/testharnessreport.js"></script> | 7 <script src="../../resources/testharnessreport.js"></script> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <div id="log"></div> | 10 <div id="log"></div> |
| 11 <script> | 11 <script> |
| 12 // This test passes |response| to update() as a JSON Web Key Set. | 12 // This test passes |response| to update() as a JSON Web Key Set. |
| 13 // CDMs other than Clear Key won't expect |response| in this format. | 13 // CDMs other than Clear Key won't expect |response| in this format. |
| 14 | 14 |
| 15 async_test(function(test) | 15 async_test(function(test) |
| 16 { | 16 { |
| 17 var initDataType; | 17 var initDataType; |
| 18 var initData; |
| 18 var mediaKeySession; | 19 var mediaKeySession; |
| 19 | 20 |
| 20 function repeat(pattern, count) { | 21 function repeat(pattern, count) { |
| 21 var result = ''; | 22 var result = ''; |
| 22 while (count > 1) { | 23 while (count > 1) { |
| 23 if (count & 1) result += pattern; | 24 if (count & 1) result += pattern; |
| 24 count >>= 1; | 25 count >>= 1; |
| 25 pattern += pattern; | 26 pattern += pattern; |
| 26 } | 27 } |
| 27 return result + pattern; | 28 return result + pattern; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 46 assert_greater_than(jwkSet.length, 65536); | 47 assert_greater_than(jwkSet.length, 65536); |
| 47 var jwkSetArray = stringToUint8Array(jwkSet); | 48 var jwkSetArray = stringToUint8Array(jwkSet); |
| 48 mediaKeySession.update(jwkSetArray).then(function() { | 49 mediaKeySession.update(jwkSetArray).then(function() { |
| 49 forceTestFailureFromPromise(test, 'Error: update() succe
eded'); | 50 forceTestFailureFromPromise(test, 'Error: update() succe
eded'); |
| 50 }, function(error) { | 51 }, function(error) { |
| 51 assert_equals(error.name, 'InvalidAccessError'); | 52 assert_equals(error.name, 'InvalidAccessError'); |
| 52 test.done(); | 53 test.done(); |
| 53 }); | 54 }); |
| 54 } | 55 } |
| 55 | 56 |
| 56 getSupportedInitDataType().then(function(type) { | 57 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp
leConfiguration()).then(function(access) { |
| 57 initDataType = type; | 58 initDataType = access.getConfiguration().initDataTypes[0]; |
| 58 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); | 59 initData = getInitData(initDataType); |
| 59 }).then(function(access) { | |
| 60 return access.createMediaKeys(); | 60 return access.createMediaKeys(); |
| 61 }).then(function(mediaKeys) { | 61 }).then(function(mediaKeys) { |
| 62 mediaKeySession = mediaKeys.createSession(); | 62 mediaKeySession = mediaKeys.createSession(); |
| 63 waitForEventAndRunStep('message', mediaKeySession, processMe
ssage, test); | 63 waitForEventAndRunStep('message', mediaKeySession, processMe
ssage, test); |
| 64 return mediaKeySession.generateRequest(initDataType, getInit
Data(initDataType)); | 64 return mediaKeySession.generateRequest(initDataType, initDat
a); |
| 65 }); | 65 }); |
| 66 }, 'update() with response longer than 64Kb characters.'); | 66 }, 'update() with response longer than 64Kb characters.'); |
| 67 </script> | 67 </script> |
| 68 </body> | 68 </body> |
| 69 </html> | 69 </html> |
| OLD | NEW |