OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test Clear Key handling of non-ASCII responses for update().</tit
le> | 4 <title>Test Clear Key handling of non-ASCII responses for update().</tit
le> |
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 processMessage(event) | 21 function processMessage(event) |
21 { | 22 { |
22 // |jwkSet| includes some non-ASCII characters. | 23 // |jwkSet| includes some non-ASCII characters. |
23 var jwkSet = '{"keys":[{' | 24 var jwkSet = '{"keys":[{' |
24 + '"kty":"oct\uDC00\uD800",' | 25 + '"kty":"oct\uDC00\uD800",' |
25 + '"k":"MDEyMzQ1Njc4OTAxMjM0NQ",' | 26 + '"k":"MDEyMzQ1Njc4OTAxMjM0NQ",' |
26 + '"kid":"MDEyMzQ1Njc4OTAxMjM0NQ"' | 27 + '"kid":"MDEyMzQ1Njc4OTAxMjM0NQ"' |
27 + '\xff\xfe}]'; | 28 + '\xff\xfe}]'; |
28 mediaKeySession.update(stringToUint8Array(jwkSet)).then(func
tion() { | 29 mediaKeySession.update(stringToUint8Array(jwkSet)).then(func
tion() { |
29 forceTestFailureFromPromise(test, 'Error: update() succe
eded'); | 30 forceTestFailureFromPromise(test, 'Error: update() succe
eded'); |
30 }, function(error) { | 31 }, function(error) { |
31 assert_equals(error.name, 'InvalidAccessError'); | 32 assert_equals(error.name, 'InvalidAccessError'); |
32 test.done(); | 33 test.done(); |
33 }); | 34 }); |
34 } | 35 } |
35 | 36 |
36 getSupportedInitDataType().then(function(type) { | 37 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp
leConfiguration()).then(function(access) { |
37 initDataType = type; | 38 initDataType = access.getConfiguration().initDataTypes[0]; |
38 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); | 39 initData = getInitData(initDataType); |
39 }).then(function(access) { | |
40 return access.createMediaKeys(); | 40 return access.createMediaKeys(); |
41 }).then(function(mediaKeys) { | 41 }).then(function(mediaKeys) { |
42 mediaKeySession = mediaKeys.createSession(); | 42 mediaKeySession = mediaKeys.createSession(); |
43 waitForEventAndRunStep('message', mediaKeySession, processMe
ssage, test); | 43 waitForEventAndRunStep('message', mediaKeySession, processMe
ssage, test); |
44 return mediaKeySession.generateRequest(initDataType, getInit
Data(initDataType)); | 44 return mediaKeySession.generateRequest(initDataType, initDat
a); |
45 }); | 45 }); |
46 }, 'Clear Key update() with non-ASCII response.'); | 46 }, 'Clear Key update() with non-ASCII response.'); |
47 </script> | 47 </script> |
48 </body> | 48 </body> |
49 </html> | 49 </html> |
OLD | NEW |