2010-05-30 15:02:06 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=495319
|
|
|
|
-->
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>Bug 495319 - playing back small audio files should fire timeupdate</title>
|
|
|
|
<script type="text/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=495319">Mozilla Bug 495319</a>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
var manager = new MediaTestManager;
|
2010-05-30 15:02:06 -07:00
|
|
|
|
|
|
|
function timeupdate(e) {
|
2010-11-24 10:34:57 -08:00
|
|
|
var v = e.target;
|
|
|
|
v._timeupdateCount++;
|
2012-06-01 11:52:37 -07:00
|
|
|
ok(v.gotEnded == 0, v._name + " - shouldn't get timeupdate after ended");
|
2010-05-30 15:02:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function ended(e) {
|
|
|
|
var v = e.target;
|
2012-06-01 11:52:37 -07:00
|
|
|
++v.gotEnded;
|
2010-05-30 15:02:06 -07:00
|
|
|
ok(v._timeupdateCount > 0, v._name + " - should see at least one timeupdate: " + v.currentTime);
|
2010-08-26 19:11:46 -07:00
|
|
|
v._finished = true;
|
2010-11-24 10:34:57 -08:00
|
|
|
// Finish the test after 500ms. We shouldn't receive any timeupdate events
|
|
|
|
// after the ended event, so this gives time for any pending timeupdate events
|
|
|
|
// to fire so we can ensure we don't regress behaviour.
|
|
|
|
setTimeout(
|
|
|
|
function() {
|
|
|
|
// Remove the event listeners before removing the video from the document.
|
|
|
|
// We should receive a timeupdate and pause event when we remove the element
|
|
|
|
// from the document (as the element is specified to behave as if pause() was
|
|
|
|
// invoked when it's removed from a document), and we don't want those
|
|
|
|
// confusing the test results.
|
|
|
|
v.removeEventListener("ended", ended, false);
|
|
|
|
v.removeEventListener("timeupdate", timeupdate, false);
|
2012-06-01 11:52:37 -07:00
|
|
|
v.removeEventListener("timeupdate", logEvent, false);
|
|
|
|
v.removeEventListener("pause", logEvent, false);
|
|
|
|
v.removeEventListener("stalled", logEvent, false);
|
2010-11-24 10:34:57 -08:00
|
|
|
v.parentNode.removeChild(v);
|
|
|
|
manager.finished(v.token);
|
|
|
|
},
|
|
|
|
500);
|
2010-05-30 15:02:06 -07:00
|
|
|
}
|
|
|
|
|
2011-11-30 19:59:00 -08:00
|
|
|
var eventsToLog = ["play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
|
|
|
|
"loadeddata", "playing", "progress", "timeupdate", "ended", "suspend", "error", "stalled", "emptied", "abort",
|
|
|
|
"waiting", "pause"];
|
|
|
|
function logEvent(event) {
|
2012-06-01 11:52:37 -07:00
|
|
|
if (event.target.gotEnded > (event.type == "ended" ? 1 : 0)) {
|
2012-08-03 03:28:12 -07:00
|
|
|
if (event.target.currentSrc.slice(-9) == "seek.webm" && event.type == "stalled") {
|
|
|
|
todo(false, event.target.currentSrc + " got unexpected stalled after ended (bug 760770)");
|
|
|
|
} else {
|
|
|
|
ok(false, event.target.currentSrc + " got unexpected " + event.type + " after ended");
|
|
|
|
}
|
2012-06-01 11:52:37 -07:00
|
|
|
} else {
|
|
|
|
info(event.target.currentSrc + " got " + event.type);
|
|
|
|
}
|
2011-11-30 19:59:00 -08:00
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
function startTest(test, token) {
|
2010-05-30 15:02:06 -07:00
|
|
|
var type = /^video/.test(test.type) ? "video" : "audio";
|
|
|
|
var v = document.createElement(type);
|
2010-08-26 19:11:46 -07:00
|
|
|
v.token = token;
|
|
|
|
manager.started(token);
|
2010-05-30 15:02:06 -07:00
|
|
|
v.src = test.name;
|
|
|
|
v._name = test.name;
|
|
|
|
v._timeupdateCount = 0;
|
|
|
|
v._finished = false;
|
2012-06-01 11:52:37 -07:00
|
|
|
v.gotEnded = 0;
|
2010-05-30 15:02:06 -07:00
|
|
|
v.autoplay = true;
|
|
|
|
v.addEventListener("ended", ended, false);
|
|
|
|
v.addEventListener("timeupdate", timeupdate, false);
|
2011-11-30 19:59:00 -08:00
|
|
|
for (var i = 0; i < eventsToLog.length; ++i) {
|
|
|
|
v.addEventListener(eventsToLog[i], logEvent, false);
|
|
|
|
}
|
2010-05-30 15:02:06 -07:00
|
|
|
document.body.appendChild(v);
|
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
manager.runTests(gSmallTests, startTest);
|
2010-05-30 15:02:06 -07:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|