summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_unseekable.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/test_unseekable.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/test_unseekable.html')
-rw-r--r--dom/media/test/test_unseekable.html101
1 files changed, 101 insertions, 0 deletions
diff --git a/dom/media/test/test_unseekable.html b/dom/media/test/test_unseekable.html
new file mode 100644
index 0000000000..52c7eccc50
--- /dev/null
+++ b/dom/media/test/test_unseekable.html
@@ -0,0 +1,101 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Media test: unseekable</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>
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/*
+
+Test that unseekable media can't be seeked. We load a media that shouldn't
+be seekable, and play through once. While playing through we repeatedly try
+to seek and check that nothing happens when we do. We also verify that the
+seekable ranges are empty.
+
+*/
+
+var manager = new MediaTestManager;
+
+var onseeking = function(event) {
+ var v = event.target;
+ v.actuallySeeked = true;
+};
+
+var onseeked = function(event) {
+ var v = event.target;
+ v.actuallySeeked = true;
+};
+
+var ontimeupdate = function(event) {
+ var v = event.target;
+
+ // Check that when we seek nothing happens.
+ var t = v.currentTime;
+ v.currentTime = v.currentTime /= 2;
+ ok(Math.abs(t - v.currentTime) < 0.01, "Current time shouldn't change when seeking in unseekable media: " + v.name);
+
+ // Check that the seekable ranges are empty.
+ is(v.seekable.length, 0, "Should have no seekable ranges in unseekable media: " + v.name);
+};
+
+var onended = function(event) {
+ var v = event.target;
+
+ // Remove the event listeners so that they can't run if there are any pending
+ // events.
+ v.removeEventListener("seeking", onseeking);
+ v.removeEventListener("seeked", onseeked);
+ v.removeEventListener("timeupdate", ontimeupdate);
+ v.removeEventListener("ended", onended);
+
+ v.src = "";
+ if (v.parentNode) {
+ v.remove();
+ }
+
+ // Verify that none of the seeks we did in timeupdate actually seeked.
+ ok(!v.actuallySeeked, "Should not be able to seek in unseekable media: " + v.name);
+
+ manager.finished(v.token);
+}
+
+function startTest(test, token) {
+ var v = document.createElement('video');
+ manager.started(token);
+ v.name = test.name;
+ v.src = test.name;
+ v.token = token;
+ v.autoplay = "true";
+
+ v.actuallySeeked = false;
+
+ v.addEventListener("seeking", onseeking);
+ v.addEventListener("seeked", onseeked);
+ v.addEventListener("timeupdate", ontimeupdate);
+ v.addEventListener("ended", onended);
+
+ document.body.appendChild(v);
+}
+
+function canPlay(candidates) {
+ var v = document.createElement("video");
+ var resources = candidates.filter(function(x){return v.canPlayType(x.type);});
+ return (resources.length);
+}
+
+if (canPlay(gUnseekableTests)) {
+ manager.runTests(gUnseekableTests, startTest);
+} else {
+ todo(false, "No files of supported format to test");
+}
+
+
+</script>
+</pre>
+</body>
+</html>