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/file_eme_createMediaKeys.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/file_eme_createMediaKeys.html')
-rw-r--r-- | dom/media/test/file_eme_createMediaKeys.html | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/dom/media/test/file_eme_createMediaKeys.html b/dom/media/test/file_eme_createMediaKeys.html new file mode 100644 index 0000000000..3ff782b1bf --- /dev/null +++ b/dom/media/test/file_eme_createMediaKeys.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<html> +<head> +<title>Eme createMediaKeys helper page</title> +<script> +// This script waits for a message then attempts to requestMediaKeySystemAccess +// then createMediaKeys. On success posts 'successCreatingMediaKeys' to the +// source of the message, on failure posts 'failureCreatingMediaKeys' and a +// description of the failure to the source of the message. + +async function createMediaKeys() { + const clearKeyOptions = [ + { + initDataTypes: ["webm"], + videoCapabilities: [{ contentType: 'video/webm; codecs="vp9"' }], + }, + ]; + + let access = await navigator.requestMediaKeySystemAccess( + "org.w3.clearkey", + clearKeyOptions + ); + + return access.createMediaKeys(); +} +function setupMessageListener() { + window.onmessage = async event => { + // We don't bother checking the message data since it should always be + // telling us to create media keys. + try { + let keys = await createMediaKeys(); + if (!keys) { + event.source.postMessage("failureCreatingMediaKeys no keys", "*"); + return; + } + event.source.postMessage("successCreatingMediaKeys", "*"); + } catch (e) { + event.source.postMessage(`failureCreatingMediaKeys ${e}`, "*"); + } + }; +} +window.onload = setupMessageListener; +</script> +</head> +<body> +</body> +</html> |