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_cueless_webm_seek-2.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_cueless_webm_seek-2.html')
-rw-r--r-- | dom/media/test/test_cueless_webm_seek-2.html | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/dom/media/test/test_cueless_webm_seek-2.html b/dom/media/test/test_cueless_webm_seek-2.html new file mode 100644 index 0000000000..720cc18399 --- /dev/null +++ b/dom/media/test/test_cueless_webm_seek-2.html @@ -0,0 +1,126 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=657791 +--> +<head> + <title>Test for Bug 657791</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> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=657791">Mozilla Bug 657791</a> + +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script type="application/javascript"> + +// Subset of seek tests for cueless WebMs. When random seeking (rather than just +// in buffered ranges) is implemented for WebM, these tests can be removed and +// the cueless WebM(s) references can be moved to the general test_seek test +// array. +// Test array is defined in manifest.js + +var manager = new MediaTestManager; + +// Exercise functionality as in test_seek-2 +function testWebM2(e) { + var v = e.target; + v.removeEventListener('loadeddata', testWebM2); + + var startPassed = false; + var endPassed = false; + var completed = false; + + ok(v.buffered.length >= 1, "Should have a buffered range"); + var halfBuffered = v.buffered.end(0) / 2; + + function start() { + if (completed) + return; + + is(v.seekable.start(0), v.buffered.start(0), "Seekable start should be buffered start"); + is(v.seekable.end(0), v.buffered.end(0), "Seekable end should be buffered end"); + v.currentTime=halfBuffered; + v.play(); + } + + function seekStarted() { + if (completed) + return; + + startPassed = true; + } + + function seekEnded() { + if (completed) + return; + + endPassed = true; + } + + function playbackEnded() { + if (completed) + return; + + completed = true; + ok(startPassed, "send seeking event"); + ok(endPassed, "send seeked event"); + ok(v.ended, "Checking playback has ended"); + ok(Math.abs(v.currentTime - v.duration) <= 0.1, "Checking currentTime at end: " + v.currentTime); + removeNodeAndSource(v); + manager.finished(v._token); + } + + v.addEventListener("ended", playbackEnded); + v.addEventListener("seeking", seekStarted); + v.addEventListener("seeked", seekEnded); + + start(); +} + +// Fetch the media resource using XHR so we can be sure the entire +// resource is loaded before we test buffered ranges. This ensures +// we have deterministic behaviour. +function fetch(url, fetched_callback) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", url, true); + xhr.responseType = "blob"; + + var loaded = function (event) { + if (xhr.status == 200 || xhr.status == 206) { + // Request fulfilled. Note sometimes we get 206... Presumably because either + // httpd.js or Necko cached the result. + fetched_callback(window.URL.createObjectURL(xhr.response)); + } else { + ok(false, "Fetch failed headers=" + xhr.getAllResponseHeaders()); + } + }; + + xhr.addEventListener("load", loaded); + xhr.send(); +} + +function startTest(test, token) { + var onfetched = function(uri) { + var v = document.createElement('video'); + v._token = token; + v.src = uri; + v.addEventListener("loadeddata", testWebM2); + document.body.appendChild(v); + } + manager.started(token); + fetch(test.name, onfetched); +} + +SimpleTest.waitForExplicitFinish(); +manager.runTests(gCuelessWebMTests, startTest); + +</script> +</pre> +</body> +</html> |