mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
111 lines
3.6 KiB
HTML
111 lines
3.6 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test playback of media files that should play OK</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>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
//longer timeout for sometimes B2G emulator runs very slowly
|
|
if (SpecialPowers.Services.appinfo.name == "B2G") {
|
|
SimpleTest.requestLongerTimeout(3);
|
|
}
|
|
|
|
var manager = new MediaTestManager;
|
|
|
|
function localCheckMetadata(msg, e, test) {
|
|
if (test.width) {
|
|
is(e.videoWidth, test.width, msg + " video width");
|
|
}
|
|
if (test.height) {
|
|
is(e.videoHeight, test.height, msg + " video height");
|
|
}
|
|
if (test.duration) {
|
|
// see bug 1039901 for skipping mp3 duration test on B2G
|
|
if (SpecialPowers.Services.appinfo.name == "B2G" && /mp3$/.test(test.name)) {
|
|
todo(false, "Fix mp3 duration bug on B2G");
|
|
return;
|
|
}
|
|
ok(Math.abs(e.duration - test.duration) < 0.1,
|
|
msg + " duration (" + e.duration + ") should be around " + test.duration);
|
|
}
|
|
}
|
|
|
|
function startTest(test, token) {
|
|
var v = document.createElement('video');
|
|
v.preload = "metadata";
|
|
v.token = token;
|
|
manager.started(token);
|
|
var checkMetadata = localCheckMetadata;
|
|
|
|
v.src = test.name;
|
|
v.name = test.name;
|
|
var check = function(test, v) { return function() {
|
|
is(test.name, v.name, "Name should match test.name #1");
|
|
checkMetadata(test.name, v, test);
|
|
}}(test, v);
|
|
var noLoad = function(test, v) { return function() {
|
|
ok(false, test.name + " should not fire 'load' event");
|
|
}}(test, v);
|
|
var checkEnded = function(test, v) { return function() {
|
|
if (test.duration) {
|
|
ok(Math.abs(v.currentTime - test.duration) < 0.1,
|
|
test.name + " current time at end: " + v.currentTime + " should be: " + test.duration);
|
|
}
|
|
is(test.name, v.name, "Name should match test.name #2");
|
|
is(v.readyState, v.HAVE_CURRENT_DATA, test.name + " checking readyState");
|
|
ok(v.readyState != v.NETWORK_LOADED, test.name + " shouldn't report NETWORK_LOADED");
|
|
ok(v.ended, test.name + " checking playback has ended");
|
|
if (v.ended && v.seenSuspend && !v.finished) {
|
|
v.finished = true;
|
|
v.removeEventListener("timeupdate", timeUpdate, false);
|
|
removeNodeAndSource(v);
|
|
manager.finished(v.token);
|
|
}
|
|
}}(test, v);
|
|
var checkSuspended = function(test, v) { return function() {
|
|
is(test.name, v.name, "Name should match test.name #3");
|
|
if (v.seenSuspend)
|
|
return;
|
|
|
|
v.seenSuspend = true;
|
|
ok(true, test.name + " got suspend");
|
|
if (v.ended && !v.finished) {
|
|
v.finished = true;
|
|
v.removeEventListener("timeupdate", timeUpdate, false);
|
|
removeNodeAndSource(v);
|
|
manager.finished(v.token);
|
|
}
|
|
}}(test, v);
|
|
v.prevTime = 0;
|
|
var timeUpdate = function(test, v) { return function() {
|
|
is(test.name, v.name, "Name should match test.name #4");
|
|
checkMetadata(test.name, v, test);
|
|
ok(v.prevTime <= v.currentTime,
|
|
test.name + " time should run forwards: p=" +
|
|
v.prevTime + " c=" + v.currentTime);
|
|
v.prevTime = v.currentTime;
|
|
}}(test, v);
|
|
v.addEventListener("load", noLoad, false);
|
|
v.addEventListener("loadedmetadata", check, false);
|
|
v.addEventListener("timeupdate", timeUpdate, false);
|
|
|
|
// We should get "ended" and "suspend" events for every resource
|
|
v.addEventListener("ended", checkEnded, false);
|
|
v.addEventListener("suspend", checkSuspended, false);
|
|
|
|
document.body.appendChild(v);
|
|
v.play();
|
|
}
|
|
|
|
manager.runTests(gPlayTests, startTest);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|