diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /dom/media/test/file_playback_and_bfcache.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream/115.8.0esr.tar.xz firefox-esr-upstream/115.8.0esr.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/file_playback_and_bfcache.html')
-rw-r--r-- | dom/media/test/file_playback_and_bfcache.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/dom/media/test/file_playback_and_bfcache.html b/dom/media/test/file_playback_and_bfcache.html new file mode 100644 index 0000000000..4798e1487e --- /dev/null +++ b/dom/media/test/file_playback_and_bfcache.html @@ -0,0 +1,57 @@ +<!DOCTYPE HTML> +<html> +<head> + <script> + function init() { + if (location.search == "") { + let bc1 = new BroadcastChannel("bc1"); + bc1.onmessage = function(e) { + if (e.data == "loadNext") { + location.href = location.href + "?page2"; + } else if (e.data == "forward") { + bc1.close(); + history.forward(); + } + }; + window.onpageshow = function() { + bc1.postMessage("pageshow"); + }; + } else { + document.body.innerHTML = "<video controls src='owl.mp3' autoplay>"; + let bc2 = new BroadcastChannel("bc2"); + bc2.onmessage = function(e) { + if (e.data == "back") { + history.back(); + } else if (e.data == "statistics") { + bc2.postMessage({ currentTime: document.body.firstChild.currentTime, + duration: document.body.firstChild.duration }); + bc2.close(); + window.close(); + } + } + window.onpageshow = function(e) { + bc2.postMessage({ event: "pageshow", persisted: e.persisted}); + if (!e.persisted) { + // The initial statistics is sent once we know the duration and + // have loaded all the data. + let mediaElement = document.body.firstChild; + mediaElement.onpause = function() { + mediaElement.onpause = null; + mediaElement.currentTime = 0; + mediaElement.onplay = function() { + setTimeout(function() { + bc2.postMessage({ currentTime: mediaElement.currentTime, + duration: mediaElement.duration }); + }, 500); + } + mediaElement.play(); + } + } + }; + } + } + </script> +</head> +<body onload="init()"> +</body> +</html> |