OLD | NEW |
(Empty) | |
| 1 function runTest(config, qualifier) { |
| 2 var testname = testnamePrefix( qualifier, config.keysystem ) |
| 3 + ', setMediaKeys'; |
| 4 |
| 5 var configuration = getSimpleConfigurationForContent( config.content ); |
| 6 |
| 7 if ( config.initDataType && config.initData ) { |
| 8 configuration.initDataTypes = [ config.initDataType ]; |
| 9 } |
| 10 |
| 11 async_test (function (test) { |
| 12 var _video = config.video, |
| 13 _mediaKeys; |
| 14 |
| 15 // Test MediaKeys assignment. |
| 16 assert_equals(_video.mediaKeys, null); |
| 17 assert_equals(typeof _video.setMediaKeys, 'function'); |
| 18 |
| 19 function onFailure(error) { |
| 20 forceTestFailureFromPromise(test, error); |
| 21 } |
| 22 |
| 23 // Try setting mediaKeys to null. |
| 24 _video.setMediaKeys(null).then(function(result) { |
| 25 assert_equals(_video.mediaKeys, null); |
| 26 |
| 27 // setMediaKeys should fail when setting to the wrong type of object
- Date. |
| 28 return _video.setMediaKeys(new Date()); |
| 29 }).then(function (result) { |
| 30 assert_unreached('setMediaKeys should fail when setting to wrong kin
d of object (Date)'); |
| 31 }, function(error) { |
| 32 // The error should be TypeError. |
| 33 assert_equals(error.name, 'TypeError', 'setMediaKeys should return a
TypeError when setting to wrong kind of object (Date)'); |
| 34 return navigator.requestMediaKeySystemAccess(config.keysystem, [conf
iguration]); |
| 35 }).then(function(access) { |
| 36 assert_equals(access.keySystem, config.keysystem) |
| 37 return access.createMediaKeys(); |
| 38 }).then(function(result) { |
| 39 _mediaKeys = result; |
| 40 assert_not_equals(_mediaKeys, null); |
| 41 assert_equals(typeof _mediaKeys.createSession, 'function'); |
| 42 return _video.setMediaKeys(_mediaKeys); |
| 43 }).then(function(result) { |
| 44 assert_not_equals(_video.mediaKeys, null); |
| 45 assert_equals(_video.mediaKeys, _mediaKeys); |
| 46 test.done(); |
| 47 }).catch(onFailure); |
| 48 }, testname); |
| 49 } |
OLD | NEW |