OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Invalid Clear Key License.</title> | 4 <title>Invalid Clear Key License.</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 async_test(function(test) | 12 async_test(function(test) |
13 { | 13 { |
14 var initDataType; | 14 var initDataType; |
15 var initData; | 15 var initData; |
16 var invalidLicense = new Uint8Array( | 16 var invalidLicense = new Uint8Array( |
17 [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77]); | 17 [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77]); |
18 | 18 |
19 function handleMessage(event) { | 19 function handleMessage(event) { |
20 event.target.update(invalidLicense).then(function(event) { | 20 event.target.update(invalidLicense).then(function(event) { |
21 assert_unreached('Error: update() succeeded unexpectedly
.'); | 21 assert_unreached('Error: update() succeeded unexpectedly
.'); |
22 test.done(); | 22 test.done(); |
23 }).catch(function(error) { | 23 }).catch(function(error) { |
24 assert_equals(error.name, 'InvalidAccessError'); | 24 assert_equals(error.name, 'InvalidAccessError'); |
25 test.done(); | 25 test.done(); |
26 }); | 26 }); |
27 } | 27 } |
28 | 28 |
29 getSupportedInitDataType().then(function(type) { | 29 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp
leConfiguration()).then(function(access) { |
30 initDataType = type; | 30 initDataType = access.getConfiguration().initDataTypes[0]; |
31 initData = getInitData(initDataType); | 31 initData = getInitData(initDataType); |
32 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); | |
33 }).then(function(access) { | |
34 return access.createMediaKeys(); | 32 return access.createMediaKeys(); |
35 }).then(function(mediaKeys) { | 33 }).then(function(mediaKeys) { |
36 var keySession = mediaKeys.createSession(); | 34 var keySession = mediaKeys.createSession(); |
37 keySession.addEventListener('message', handleMessage, false)
; | 35 keySession.addEventListener('message', handleMessage, false)
; |
38 keySession.generateRequest(initDataType, initData); | 36 keySession.generateRequest(initDataType, initData); |
39 }).catch(function(error) { | 37 }).catch(function(error) { |
40 forceTestFailureFromPromise(test, error); | 38 forceTestFailureFromPromise(test, error); |
41 }); | 39 }); |
42 }, 'Invalid Clear Key License.'); | 40 }, 'Invalid Clear Key License.'); |
43 </script> | 41 </script> |
44 </body> | 42 </body> |
45 </html> | 43 </html> |
OLD | NEW |