summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_replay_metadata.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/test/test_replay_metadata.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/test/test_replay_metadata.html')
-rw-r--r--dom/media/test/test_replay_metadata.html120
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 000000000..312a38197
--- /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 type="application/javascript" 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, false);
+ n.removeEventListener("ended", playbackEnded, false);
+ n.removeEventListener("playing", playing, false);
+ n.removeEventListener("loadeddata", loadedData, false);
+ n.removeEventListener("seeking", seekStarted, false);
+ n.removeEventListener("seeked", seekEnded, false);
+ 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, false);
+ v.addEventListener("ended", playbackEnded, false);
+ v.addEventListener("playing", playing, false);
+ v.addEventListener("loadeddata", loadedData, false);
+ v.addEventListener("seeking", seekStarted, false);
+ v.addEventListener("seeked", seekEnded, false);
+ document.body.appendChild(v);
+}
+
+manager.runTests(gSmallTests, startTest);
+
+</script>
+</pre>
+</body>
+</html>