diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/encrypted-media/scripts/setmediakeys-again-after-playback.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/scripts/setmediakeys-again-after-playback.js')
-rw-r--r-- | testing/web-platform/tests/encrypted-media/scripts/setmediakeys-again-after-playback.js | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-again-after-playback.js b/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-again-after-playback.js new file mode 100644 index 000000000..772bfcaa8 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-again-after-playback.js @@ -0,0 +1,79 @@ +function runTest(config, qualifier) { + var testname = testnamePrefix(qualifier, config.keysystem) + + ', setmediakeys again after playback'; + + var configuration = getSimpleConfigurationForContent(config.content); + + if (config.initDataType && config.initData) { + configuration.initDataTypes = [config.initDataType]; + } + + async_test(function(test) { + var _video = config.video, + _access, + _mediaKeys, + _mediaKeySession, + _mediaSource; + + function onFailure(error) { + forceTestFailureFromPromise(test, error); + } + + function onMessage(event) { + config.messagehandler(event.messageType, event.message).then( function(response) { + _mediaKeySession.update(response).catch(onFailure).then(function() { + _video.play(); + }); + }); + } + + function onEncrypted(event) { + waitForEventAndRunStep('message', _mediaKeySession, onMessage, test); + _mediaKeySession.generateRequest( config.initData ? config.initDataType : event.initDataType, + config.initData || event.initData ) + .catch(onFailure); + } + + function playVideo() + { + return new Promise(function(resolve) { + _mediaKeySession = _mediaKeys.createSession('temporary'); + waitForEventAndRunStep('encrypted', _video, onEncrypted, test); + _video.src = URL.createObjectURL(_mediaSource); + resolve('success'); + }); + } + + navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]).then(function(access) { + _access = access; + return _access.createMediaKeys(); + }).then(function(result) { + _mediaKeys = result; + return _video.setMediaKeys(_mediaKeys); + }).then(function() { + return config.servercertificate ? _mediaKeys.setServerCertificate( config.servercertificate ) : true; + }).then(function( success ) { + return testmediasource(config); + }).then(function(source) { + _mediaSource = source; + return playVideo(); + }).then(function(results) { + return _access.createMediaKeys(); + }).then(function(result) { + _mediaKeys = result; + return waitForEvent('playing', _video); + }).then(test.step_func(function(result) { + assert_false(_video.ended); + return _video.setMediaKeys(_mediaKeys); + })).then(function() { + // Able to change MediaKeys while playing. + // This is not required to fail. + _video.src=''; + test.done(); + }, test.step_func(function(error) { + assert_in_array(error.name, ['InvalidStateError','NotSupportedError']); + _video.src=''; + test.done(); + })).catch(onFailure); + }, testname); +}
\ No newline at end of file |