gecko/content/media/test/test_mozLoadFrom.html
Matthew Gregan a63978aea7 Bug 522418 - Missing mozLoadFrom mochitest. r=roc
--HG--
extra : rebase_source : bda7a6e7bf813eb7e1c54a8550f224b27f37f425
2009-10-15 15:59:41 +13:00

74 lines
1.8 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test mozLoadFrom API</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<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">
var testsWaiting = 0;
function cloneLoaded(event) {
ok(true, "Clone loaded OK");
var e = event.target;
if (e._expectedDuration) {
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
"Clone " + e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
}
--testsWaiting;
if (testsWaiting == 0) {
SimpleTest.finish();
}
}
function tryClone(event) {
var e = event.target;
var clone = e.cloneNode(false);
if (e._expectedDuration) {
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
clone._expectedDuration = e._expectedDuration;
}
clone.mozLoadFrom(e);
is(clone.currentSrc, e.currentSrc, "Clone source OK");
clone.addEventListener("loadeddata", cloneLoaded, false);
}
// Find something we can play
for (var i = 0; i < gCloneTests.length; ++i) {
var test = gCloneTests[i];
var elemType = /^audio/.test(test.type) ? "audio" : "video";
var e = document.createElement(elemType);
if (e.canPlayType(test.type)) {
e.src = test.name;
if (test.duration) {
e._expectedDuration = test.duration;
}
e.addEventListener("loadeddata", tryClone, false);
e.load();
++testsWaiting;
}
}
if (testsWaiting == 0) {
todo(false, "Can't play anything");
} else {
SimpleTest.waitForExplicitFinish();
}
</script>
</pre>
</body>
</html>