OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test MediaKeySession not callable immediately after CreateSession
().</title> | 4 <title>Test MediaKeySession not callable immediately after CreateSession
().</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 // After creation, the MediaKeySession object is not | 12 // After creation, the MediaKeySession object is not |
13 // callable, and we should get a InvalidStateError. | 13 // callable, and we should get a InvalidStateError. |
14 | 14 |
15 promise_test(function() | 15 promise_test(function() |
16 { | 16 { |
17 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
[{}]).then(function(access) { | 17 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
getSimpleConfiguration()).then(function(access) { |
18 return access.createMediaKeys(); | 18 return access.createMediaKeys(); |
19 }).then(function(mediaKeys) { | 19 }).then(function(mediaKeys) { |
20 var mediaKeySession = mediaKeys.createSession(); | 20 var mediaKeySession = mediaKeys.createSession(); |
21 | 21 |
22 var arbitraryResponse = new Uint8Array([0x00, 0x11]); | 22 var arbitraryResponse = new Uint8Array([0x00, 0x11]); |
23 return mediaKeySession.update(arbitraryResponse).then(functi
on(result) { | 23 return mediaKeySession.update(arbitraryResponse).then(functi
on(result) { |
24 assert_unreached('update() succeeded unexpectedly.'); | 24 assert_unreached('update() succeeded unexpectedly.'); |
25 }).catch(function(error) { | 25 }).catch(function(error) { |
26 assert_equals(error.name, 'InvalidStateError'); | 26 assert_equals(error.name, 'InvalidStateError'); |
27 }); | 27 }); |
28 }); | 28 }); |
29 }, 'Update() immediately after CreateSession().'); | 29 }, 'Update() immediately after CreateSession().'); |
30 | 30 |
31 promise_test(function() | 31 promise_test(function() |
32 { | 32 { |
33 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
[{}]).then(function(access) { | 33 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
getSimpleConfiguration()).then(function(access) { |
34 return access.createMediaKeys(); | 34 return access.createMediaKeys(); |
35 }).then(function(mediaKeys) { | 35 }).then(function(mediaKeys) { |
36 var mediaKeySession = mediaKeys.createSession(); | 36 var mediaKeySession = mediaKeys.createSession(); |
37 | 37 |
38 return mediaKeySession.close().then(function(result) { | 38 return mediaKeySession.close().then(function(result) { |
39 assert_unreached('close() succeeded unexpectedly.'); | 39 assert_unreached('close() succeeded unexpectedly.'); |
40 }).catch(function(error) { | 40 }).catch(function(error) { |
41 assert_equals(error.name, 'InvalidStateError'); | 41 assert_equals(error.name, 'InvalidStateError'); |
42 }); | 42 }); |
43 }); | 43 }); |
44 }, 'Close() immediately after CreateSession().'); | 44 }, 'Close() immediately after CreateSession().'); |
45 | 45 |
46 promise_test(function() | 46 promise_test(function() |
47 { | 47 { |
48 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
[{}]).then(function(access) { | 48 return navigator.requestMediaKeySystemAccess('org.w3.clearkey',
getSimpleConfiguration()).then(function(access) { |
49 return access.createMediaKeys(); | 49 return access.createMediaKeys(); |
50 }).then(function(mediaKeys) { | 50 }).then(function(mediaKeys) { |
51 var mediaKeySession = mediaKeys.createSession(); | 51 var mediaKeySession = mediaKeys.createSession(); |
52 | 52 |
53 return mediaKeySession.remove().then(function(result) { | 53 return mediaKeySession.remove().then(function(result) { |
54 assert_unreached('remove() succeeded unexpectedly.'); | 54 assert_unreached('remove() succeeded unexpectedly.'); |
55 }).catch(function(error) { | 55 }).catch(function(error) { |
56 assert_equals(error.name, 'InvalidStateError'); | 56 assert_equals(error.name, 'InvalidStateError'); |
57 }); | 57 }); |
58 }); | 58 }); |
59 }, 'Remove() immediately after CreateSession().'); | 59 }, 'Remove() immediately after CreateSession().'); |
60 </script> | 60 </script> |
61 </body> | 61 </body> |
62 </html> | 62 </html> |
63 | 63 |
OLD | NEW |