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_request_notifications.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/test_eme_request_notifications.html')
-rw-r--r-- | dom/media/test/test_eme_request_notifications.html | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/dom/media/test/test_eme_request_notifications.html b/dom/media/test/test_eme_request_notifications.html new file mode 100644 index 0000000000..6c44f892a6 --- /dev/null +++ b/dom/media/test/test_eme_request_notifications.html @@ -0,0 +1,82 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test Encrypted Media Extensions</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> + <script type="text/javascript" src="manifest.js"></script> + <script type="text/javascript" src="eme.js"></script> +</head> +<body> +<pre id="test"> +<script class="testbody" type="text/javascript"> +var manager = new MediaTestManager; + +function SetPrefs(prefs) { + return SpecialPowers.pushPrefEnv({"set": prefs}); +} + +function observe() { + return new Promise(function(resolve, reject) { + var observer = function(subject, topic, data) { + SpecialPowers.Services.obs.removeObserver(observer, "mediakeys-request"); + resolve(JSON.parse(data).status); + }; + SpecialPowers.Services.obs.addObserver(observer, "mediakeys-request"); + }); +} + +function Test(test) { + var p = test.prefs ? SetPrefs(test.prefs) : Promise.resolve(); + var name = "'" + test.keySystem + "'"; + + var res = observe().then((status) => { + is(status, test.expectedStatus, name + " expected status"); + }); + + p.then(() => navigator.requestMediaKeySystemAccess(test.keySystem, gCencMediaKeySystemConfig)) + .then((keySystemAccess) => keySystemAccess.createMediaKeys()); + + return res; +} + +var tests = [ + { + keySystem: CLEARKEY_KEYSYSTEM, + expectedStatus: 'cdm-created', + prefs: [["media.eme.enabled", false]] + }, + { + keySystem: "com.widevine.alpha", + expectedStatus: 'api-disabled', + prefs: [["media.eme.enabled", false]] + }, + { + keySystem: "com.widevine.alpha", + expectedStatus: 'cdm-disabled', + prefs: [["media.eme.enabled", true], ["media.gmp-widevinecdm.enabled", false]] + }, + { + keySystem: "com.widevine.alpha", + expectedStatus: 'cdm-not-installed', + prefs: [["media.eme.enabled", true], ["media.gmp-widevinecdm.enabled", true]] + }, + { + keySystem: CLEARKEY_KEYSYSTEM, + expectedStatus: 'cdm-created', + prefs: [["media.eme.enabled", true]] + } +]; + +SimpleTest.waitForExplicitFinish(); +tests + .reduce(function(p, c, i, array) { + return p.then(function() { + return Test(c); + }); + }, Promise.resolve()) + .then(SimpleTest.finish); +</script> +</pre> +</body> +</html> |