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