summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-multiple-times-with-the-same-mediakeys.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/encrypted-media/scripts/setmediakeys-multiple-times-with-the-same-mediakeys.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/scripts/setmediakeys-multiple-times-with-the-same-mediakeys.js')
-rw-r--r--testing/web-platform/tests/encrypted-media/scripts/setmediakeys-multiple-times-with-the-same-mediakeys.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-multiple-times-with-the-same-mediakeys.js b/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-multiple-times-with-the-same-mediakeys.js
new file mode 100644
index 0000000000..f6af8267f2
--- /dev/null
+++ b/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-multiple-times-with-the-same-mediakeys.js
@@ -0,0 +1,46 @@
+function runTest(config, qualifier) {
+ var testname = testnamePrefix( qualifier, config.keysystem )
+ + ', setmediakeys multiple times with the same mediakeys';
+
+ var configuration = getSimpleConfigurationForContent( config.content );
+
+ if ( config.initDataType && config.initData ) {
+ configuration.initDataTypes = [ config.initDataType ];
+ }
+
+ async_test (function (test) {
+ var _video = config.video,
+ _mediaKeys;
+
+ // Test MediaKeys assignment.
+ assert_equals(_video.mediaKeys, null);
+ assert_equals(typeof _video.setMediaKeys, 'function');
+
+ function onFailure(error) {
+ forceTestFailureFromPromise(test, error);
+ }
+
+ navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]).then(function(access) {
+ return access.createMediaKeys();
+ }).then(function(result) {
+ _mediaKeys = result;
+ // Set mediaKeys for first time on video should work.
+ return _video.setMediaKeys(_mediaKeys);
+ }).then(function(result) {
+ assert_equals(_video.mediaKeys, _mediaKeys);
+ // Set mediaKeys on video again should return a resolved promise.
+ return _video.setMediaKeys(_mediaKeys);
+ }).then(function (result) {
+ assert_equals(_video.mediaKeys, _mediaKeys);
+ return testmediasource(config);
+ }).then(function(source) {
+ // Set src attribute on Video Element
+ _video.src = URL.createObjectURL(source);
+ // Set mediaKeys again on video should still return a resolved promise.
+ return _video.setMediaKeys(_mediaKeys);
+ }).then(function() {
+ assert_equals(_video.mediaKeys, _mediaKeys);
+ test.done();
+ }).catch(onFailure);
+ }, testname);
+} \ No newline at end of file