Backed out changeset ddccd40117a0 (bug 1853271) for causing bug 1854769. CLOSED TREE
[gecko.git] / dom / media / test / test_eme_special_key_system.html
blob0addc06ebc17a9b5d7147ce68b98e338f10b0788
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Test Encrypted Media Extensions - Special key system</title>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
7 </head>
8 <body>
9 <pre id="test">
10 <script class="testbody" type="text/javascript">
11 function requestProtectionQueryKeySystemAccess() {
12 const kKeySystemOptions = [
14 initDataTypes: ["cenc"],
15 videoCapabilities: [{ contentType: 'video/mp4; codecs="avc1.4d4015"' }],
18 const kClearKeyWithProtectionQuery =
19 "org.mozilla.clearkey_with_protection_query";
20 return navigator.requestMediaKeySystemAccess(
21 kClearKeyWithProtectionQuery,
22 kKeySystemOptions
25 // Tests that org.mozilla.clearkey_with_protection_query cannot be accessed from JS if not preffed on.
26 add_task(async function protectionQueryKeySystemShouldBeHidden() {
27 try {
28 // Should throw since special key systems are not enabled.
29 await requestProtectionQueryKeySystemAccess();
30 ok(
31 false,
32 "Test should have thrown by default because media.clearkey.test-key-systems.enabled should not be set"
34 } catch (e) {
35 is(e.name, "NotSupportedError", "Should get not supported error");
36 is(
37 e.message,
38 "Key system is unsupported",
39 "Should get message that key system is unsupported"
42 });
44 // Tests that org.mozilla.clearkey_with_protection_query can be accessed from JS if preffed on.
45 add_task(async function protectionQueryKeySystemShouldBeExposed() {
46 await SpecialPowers.pushPrefEnv({
47 set: [["media.clearkey.test-key-systems.enabled", true]],
48 });
49 try {
50 // Should not throw since special key systems are enabled.
51 let access = await requestProtectionQueryKeySystemAccess();
52 ok(
53 access,
54 "Should get access to protection query key system when preffed on"
56 } catch (e) {
57 ok(false, "Test should not have thrown and key system should be available");
59 });
60 </script>
61 </pre>
62 </body>
63 </html>