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" />
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,
25 // Tests that org.mozilla.clearkey_with_protection_query cannot be accessed from JS if not preffed on.
26 add_task(async function protectionQueryKeySystemShouldBeHidden() {
28 // Should throw since special key systems are not enabled.
29 await requestProtectionQueryKeySystemAccess();
32 "Test should have thrown by default because media.clearkey.test-key-systems.enabled should not be set"
35 is(e.name,
"NotSupportedError",
"Should get not supported error");
38 "Key system is unsupported",
39 "Should get message that key system is unsupported"
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]],
50 // Should not throw since special key systems are enabled.
51 let access = await requestProtectionQueryKeySystemAccess();
54 "Should get access to protection query key system when preffed on"
57 ok(false,
"Test should not have thrown and key system should be available");