summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-to-multiple-video-elements.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/encrypted-media/scripts/setmediakeys-to-multiple-video-elements.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/encrypted-media/scripts/setmediakeys-to-multiple-video-elements.js')
-rw-r--r--testing/web-platform/tests/encrypted-media/scripts/setmediakeys-to-multiple-video-elements.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-to-multiple-video-elements.js b/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-to-multiple-video-elements.js
new file mode 100644
index 0000000000..4c7faef69d
--- /dev/null
+++ b/testing/web-platform/tests/encrypted-media/scripts/setmediakeys-to-multiple-video-elements.js
@@ -0,0 +1,54 @@
+function runTest(config, qualifier) {
+ var testname = testnamePrefix(qualifier, config.keysystem)
+ + ', setMediaKeys to multiple video elements';
+
+ var configuration = getSimpleConfigurationForContent(config.content);
+
+ if ( config.initDataType && config.initData ) {
+ configuration.initDataTypes = [ config.initDataType ];
+ }
+
+ async_test (function (test) {
+ var _video1 = config.video1,
+ _video2 = config.video2,
+ _mediaKeys;
+
+ function onFailure(error) {
+ forceTestFailureFromPromise(test, error);
+ }
+
+ navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]).then(function(access) {
+ assert_equals(access.keySystem, config.keysystem)
+ return access.createMediaKeys();
+ }).then(function(result) {
+ _mediaKeys = result;
+ assert_not_equals(_mediaKeys, null);
+ assert_equals(typeof _mediaKeys.createSession, 'function');
+ return _video1.setMediaKeys(_mediaKeys);
+ }).then(function(result) {
+ assert_not_equals(_video1.mediaKeys, null);
+ assert_equals(_video1.mediaKeys, _mediaKeys);
+ // The specification allows this to fail, but it is not required to fail.
+ return _video2.setMediaKeys(_mediaKeys);
+ }).then(function(result) {
+ // Second setMediaKeys is not required to fail.
+ assert_equals(_video2.mediaKeys, _mediaKeys);
+ return Promise.resolve();
+ }, function(error) {
+ assert_equals(error.name, 'QuotaExceededError');
+ assert_not_equals(error.message, '');
+ // Return something so the promise resolves properly.
+ return Promise.resolve();
+ }).then(function() {
+ // Now clear it from video1.
+ return _video1.setMediaKeys(null);
+ }).then(function() {
+ // Should be assignable to video2.
+ return _video2.setMediaKeys(_mediaKeys);
+ }).then(function(result) {
+ assert_not_equals(_video2.mediaKeys, null);
+ assert_equals(_video2.mediaKeys, _mediaKeys);
+ test.done();
+ }).catch(onFailure);
+ }, testname);
+} \ No newline at end of file