OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Test MediaKeySession closed event</title> | 4 <title>Test MediaKeySession closed event</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 mediaKeySession; | 16 var mediaKeySession; |
17 getSupportedInitDataType().then(function(type) { | 17 |
18 initDataType = type; | 18 navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimp
leConfiguration()).then(function(access) { |
| 19 initDataType = access.getConfiguration().initDataTypes[0]; |
19 initData = getInitData(initDataType); | 20 initData = getInitData(initDataType); |
20 return navigator.requestMediaKeySystemAccess('org.w3.clearke
y', [{}]); | |
21 }).then(function(access) { | |
22 return access.createMediaKeys(); | 21 return access.createMediaKeys(); |
23 }).then(function(mediaKeys) { | 22 }).then(function(mediaKeys) { |
24 mediaKeySession = mediaKeys.createSession(); | 23 mediaKeySession = mediaKeys.createSession(); |
25 return mediaKeySession.generateRequest(initDataType, initDat
a); | 24 return mediaKeySession.generateRequest(initDataType, initDat
a); |
26 }).then(function() { | 25 }).then(function() { |
27 // Wait for the session to be closed. | 26 // Wait for the session to be closed. |
28 mediaKeySession.closed.then(function(result) { | 27 mediaKeySession.closed.then(function(result) { |
29 assert_equals(result, undefined); | 28 assert_equals(result, undefined); |
30 // Now that the session is closed, verify that the | 29 // Now that the session is closed, verify that the |
31 // closed attribute immediately returns a fulfilled | 30 // closed attribute immediately returns a fulfilled |
32 // promise. | 31 // promise. |
33 return mediaKeySession.closed; | 32 return mediaKeySession.closed; |
34 }).then(function(result) { | 33 }).then(function(result) { |
35 assert_equals(result, undefined); | 34 assert_equals(result, undefined); |
36 test.done(); | 35 test.done(); |
37 }); | 36 }); |
38 | 37 |
39 // release() should result in the closed promise being | 38 // release() should result in the closed promise being |
40 // fulfilled. | 39 // fulfilled. |
41 return mediaKeySession.close(); | 40 return mediaKeySession.close(); |
42 }).catch(function(error) { | 41 }).catch(function(error) { |
43 forceTestFailureFromPromise(test, error); | 42 forceTestFailureFromPromise(test, error); |
44 }); | 43 }); |
45 }, 'Test MediaKeySession closed event.'); | 44 }, 'Test MediaKeySession closed event.'); |
46 </script> | 45 </script> |
47 </body> | 46 </body> |
48 </html> | 47 </html> |
OLD | NEW |