OLD | NEW |
(Empty) | |
| 1 function runTest(config, qualifier) |
| 2 { |
| 3 var testname = testnamePrefix(qualifier, config.keysystem) + ' test MediaKey
Session closed event.'; |
| 4 |
| 5 var configuration = { |
| 6 initDataTypes: [config.initDataType], |
| 7 audioCapabilities: [{ |
| 8 contentType: config.audioType |
| 9 }], |
| 10 videoCapabilities: [{ |
| 11 contentType: config.videoType |
| 12 }], |
| 13 sessionTypes: ['temporary'] |
| 14 }; |
| 15 |
| 16 promise_test(function (test) { |
| 17 var initDataType; |
| 18 var initData; |
| 19 var mediaKeySession; |
| 20 |
| 21 return navigator.requestMediaKeySystemAccess(config.keysystem, [configur
ation]).then(function (access) { |
| 22 initDataType = access.getConfiguration().initDataTypes[0]; |
| 23 return access.createMediaKeys(); |
| 24 }).then(function (mediaKeys) { |
| 25 mediaKeySession = mediaKeys.createSession(); |
| 26 if(config.initData) { |
| 27 initData = config.initData; |
| 28 } else { |
| 29 initData = stringToUint8Array(atob(config.content.keys[0].initDa
ta)); |
| 30 } |
| 31 return mediaKeySession.generateRequest(initDataType, initData); |
| 32 }).then(function() { |
| 33 // close() should result in the closed promise being |
| 34 // fulfilled. |
| 35 return mediaKeySession.close(); |
| 36 }).then(function (result) { |
| 37 assert_equals(result, undefined); |
| 38 // Wait for the session to be closed. |
| 39 return mediaKeySession.closed; |
| 40 }).then(function (result) { |
| 41 assert_equals(result, undefined); |
| 42 // Now that the session is closed, verify that the |
| 43 // closed attribute immediately returns a fulfilled |
| 44 // promise. |
| 45 return mediaKeySession.closed; |
| 46 }).then(function (result) { |
| 47 assert_equals(result, undefined); |
| 48 }).catch(function(error) { |
| 49 assert_unreached('Error: ' + error.name); |
| 50 }); |
| 51 }, testname); |
| 52 } |
OLD | NEW |