| 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 mediaKeySession; | 14 var mediaKeySession; |
| 15 MediaKeys.create('org.w3.clearkey').then(function(mediaKeys) { | 15 navigator.requestMediaKeySystemAccess('org.w3.clearkey').then(fu
nction(access) { |
| 16 return access.createMediaKeys(); |
| 17 }).then(function(mediaKeys) { |
| 16 var initDataType = getInitDataType(); | 18 var initDataType = getInitDataType(); |
| 17 mediaKeySession = mediaKeys.createSession(); | 19 mediaKeySession = mediaKeys.createSession(); |
| 18 return mediaKeySession.generateRequest(initDataType, getInit
Data(initDataType)); | 20 return mediaKeySession.generateRequest(initDataType, getInit
Data(initDataType)); |
| 19 }).then(function() { | 21 }).then(function() { |
| 20 // Wait for the session to be closed. | 22 // Wait for the session to be closed. |
| 21 mediaKeySession.closed.then(function(result) { | 23 mediaKeySession.closed.then(function(result) { |
| 22 assert_equals(result, undefined); | 24 assert_equals(result, undefined); |
| 23 // Now that the session is closed, verify that the | 25 // Now that the session is closed, verify that the |
| 24 // closed attribute immediately returns a fulfilled | 26 // closed attribute immediately returns a fulfilled |
| 25 // promise. | 27 // promise. |
| 26 return mediaKeySession.closed; | 28 return mediaKeySession.closed; |
| 27 }).then(function(result) { | 29 }).then(function(result) { |
| 28 assert_equals(result, undefined); | 30 assert_equals(result, undefined); |
| 29 test.done(); | 31 test.done(); |
| 30 }); | 32 }); |
| 31 | 33 |
| 32 // release() should result in the closed promise being | 34 // release() should result in the closed promise being |
| 33 // fulfilled. | 35 // fulfilled. |
| 34 return mediaKeySession.close(); | 36 return mediaKeySession.close(); |
| 35 }).catch(function(error) { | 37 }).catch(function(error) { |
| 36 forceTestFailureFromPromise(test, error); | 38 forceTestFailureFromPromise(test, error); |
| 37 }); | 39 }); |
| 38 }, 'Test MediaKeySession closed event.'); | 40 }, 'Test MediaKeySession closed event.'); |
| 39 </script> | 41 </script> |
| 40 </body> | 42 </body> |
| 41 </html> | 43 </html> |
| OLD | NEW |