summaryrefslogtreecommitdiffstats
path: root/dom/media/test/file_playback_and_bfcache.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/media/test/file_playback_and_bfcache.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
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.html57
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>