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/reset-src-after-setmediakeys.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/reset-src-after-setmediakeys.js')
-rw-r--r-- | testing/web-platform/tests/encrypted-media/scripts/reset-src-after-setmediakeys.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/reset-src-after-setmediakeys.js b/testing/web-platform/tests/encrypted-media/scripts/reset-src-after-setmediakeys.js new file mode 100644 index 000000000..acddd8dd5 --- /dev/null +++ b/testing/web-platform/tests/encrypted-media/scripts/reset-src-after-setmediakeys.js @@ -0,0 +1,61 @@ +function runTest(config) +{ + async_test(function(test) { + var mediaKeys; + var mediaSource; + var encryptedEventIndex = 0; + var video = config.video; + var keysystem = config.keysystem; + var configuration = { + initDataTypes: [config.initDataType], + audioCapabilities: [{ + contentType: config.audioType + }], + videoCapabilities: [{ + contentType: config.videoType + }], + sessionTypes: ['temporary'] + }; + + assert_not_equals(video, null); + + var onEncrypted = function(event) { + ++encryptedEventIndex; + assert_equals(video.mediaKeys, mediaKeys); + + // This event is fired once for the audio stream and once + // for the video stream each time .src is set. + if (encryptedEventIndex === 2) { + // Finished first video; Create new media source and wait for two more encrypted events + return testmediasource(config).then(function (source) { + video.src = URL.createObjectURL(source); + }).catch(function (error) { + forceTestFailureFromPromise(test, error) + }); + } else if (encryptedEventIndex === 4) { + // Finished second video. + test.done(); + } + }; + + // Create a MediaKeys object and assign it to video. + return navigator.requestMediaKeySystemAccess(keysystem, [configuration]).then(test.step_func(function (access) { + assert_equals(access.keySystem, keysystem); + return access.createMediaKeys(); + })).then(test.step_func(function (result) { + mediaKeys = result; + assert_not_equals(mediaKeys, null); + return video.setMediaKeys(mediaKeys); + })).then(test.step_func(function () { + assert_equals(video.mediaKeys, mediaKeys); + return testmediasource(config); + })).then(function (source) { + waitForEventAndRunStep('encrypted', video, onEncrypted, test); + mediaSource = source; + video.src = URL.createObjectURL(mediaSource); + }).catch(function (error) { + forceTestFailureFromPromise(test, error); + }); + + }, 'Reset src after setMediaKeys().'); +} |