diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/test/test_eme_special_key_system.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/test_eme_special_key_system.html')
-rw-r--r-- | dom/media/test/test_eme_special_key_system.html | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/dom/media/test/test_eme_special_key_system.html b/dom/media/test/test_eme_special_key_system.html new file mode 100644 index 0000000000..0addc06ebc --- /dev/null +++ b/dom/media/test/test_eme_special_key_system.html @@ -0,0 +1,63 @@ +<!DOCTYPE html> +<html> +<head> + <title>Test Encrypted Media Extensions - Special key system</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> +function requestProtectionQueryKeySystemAccess() { + const kKeySystemOptions = [ + { + initDataTypes: ["cenc"], + videoCapabilities: [{ contentType: 'video/mp4; codecs="avc1.4d4015"' }], + }, + ]; + const kClearKeyWithProtectionQuery = + "org.mozilla.clearkey_with_protection_query"; + return navigator.requestMediaKeySystemAccess( + kClearKeyWithProtectionQuery, + kKeySystemOptions + ); +} +// Tests that org.mozilla.clearkey_with_protection_query cannot be accessed from JS if not preffed on. +add_task(async function protectionQueryKeySystemShouldBeHidden() { + try { + // Should throw since special key systems are not enabled. + await requestProtectionQueryKeySystemAccess(); + ok( + false, + "Test should have thrown by default because media.clearkey.test-key-systems.enabled should not be set" + ); + } catch (e) { + is(e.name, "NotSupportedError", "Should get not supported error"); + is( + e.message, + "Key system is unsupported", + "Should get message that key system is unsupported" + ); + } +}); + +// Tests that org.mozilla.clearkey_with_protection_query can be accessed from JS if preffed on. +add_task(async function protectionQueryKeySystemShouldBeExposed() { + await SpecialPowers.pushPrefEnv({ + set: [["media.clearkey.test-key-systems.enabled", true]], + }); + try { + // Should not throw since special key systems are enabled. + let access = await requestProtectionQueryKeySystemAccess(); + ok( + access, + "Should get access to protection query key system when preffed on" + ); + } catch (e) { + ok(false, "Test should not have thrown and key system should be available"); + } +}); +</script> +</pre> +</body> +</html> |