diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/media/test/test_replay_metadata.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/test_replay_metadata.html')
-rw-r--r-- | dom/media/test/test_replay_metadata.html | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/dom/media/test/test_replay_metadata.html b/dom/media/test/test_replay_metadata.html new file mode 100644 index 0000000000..dab022885f --- /dev/null +++ b/dom/media/test/test_replay_metadata.html @@ -0,0 +1,120 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=467972 +--> +<head> + <title>Test for Bug 467972</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=467972">Mozilla Bug 467972</a> + +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script type="application/javascript"> + +// Test for Bug 467972. Tests that when we play to end, seek to 0, and play again, that we don't +// send/receive multiple loadeddata and loadedmetadata events. + +var manager = new MediaTestManager; + +function seekStarted(evt) { + var v = evt.target; + v._gotSeekStarted = true; +} + +function seekEnded(evt) { + var v = evt.target; + v._gotSeekEnded = true; + v.play(); +} + +function loadedData(evt) { + var v = evt.target; + v._loadedDataCount++; + ok(v._loadedDataCount <= 1, "No more than 1 onloadeddata event for " + v._name); +} + +function loadedMetaData(evt) { + var v = evt.target; + v._loadedMetaDataCount++; + ok(v._loadedMetaDataCount <= 1, "No more than 1 onloadedmetadata event for " + v._name); + checkMetadata(v._name, v, v._test); + v.play(); +} + +function playing(evt) { + evt.target._playingCount++; +} + +function removeNodeAndListener(n) { + n.removeEventListener("loadedmetadata", loadedMetaData); + n.removeEventListener("ended", playbackEnded); + n.removeEventListener("playing", playing); + n.removeEventListener("loadeddata", loadedData); + n.removeEventListener("seeking", seekStarted); + n.removeEventListener("seeked", seekEnded); + removeNodeAndSource(n); +} + +function playbackEnded(evt) { + var v = evt.target; + v._endCount++; + ok(v.currentTime >= v.duration-0.1 && v.currentTime <= v.duration + 0.1, + "CurrentTime (" + v.currentTime + ") should be around " + v.duration + + " for " + v._name); + if (!v._playedOnce) { + v.currentTime = 0; + ok(v.seeking, "seeking should be true for " + v._name); + ok(!v.ended, "ended shouldn't be true once seeking has begun for " + v._name); + v._playedOnce = true; + } else { + ok(v._gotSeekEnded, "Should have received seekended for " + v._name); + ok(v._gotSeekStarted, "Should have received seekstarted for " + v._name); + is(v._loadedDataCount, 1, "Should have 1 onloadeddata event for " + v._name); + is(v._loadedMetaDataCount, 1, "Should have 1 onloadedmetadata event for " + v._name); + is(v._endCount, 2, "Should have received two ended events for " + v._name); + ok(v._playingCount > 0, "Should have at least one playing event for " + v._name); + v._finished = true; + removeNodeAndListener(v); + manager.finished(v.token); + } +} + +function startTest(test, token) { + var v = document.createElement('video'); + v.preload = "auto"; + v.token = token; + manager.started(token); + v.src = test.name; + v._name = test.name; + v._playedOnce = false; + v._gotSeekEnded = false; + v._gotSeekStarted = false; + v._loadedDataCount = 0; + v._loadedMetaDataCount = 0; + v._playingCount = 0; + v._endCount = 0; + v._test = test; + v._finished = false; + v.addEventListener("loadedmetadata", loadedMetaData); + v.addEventListener("ended", playbackEnded); + v.addEventListener("playing", playing); + v.addEventListener("loadeddata", loadedData); + v.addEventListener("seeking", seekStarted); + v.addEventListener("seeked", seekEnded); + document.body.appendChild(v); +} + +manager.runTests(gSmallTests, startTest); + +</script> +</pre> +</body> +</html> |