2009-09-14 19:30:44 -07:00
|
|
|
<!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");
|
2009-10-14 18:28:59 -07:00
|
|
|
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);
|
|
|
|
}
|
2009-09-14 19:30:44 -07:00
|
|
|
|
|
|
|
--testsWaiting;
|
|
|
|
if (testsWaiting == 0) {
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function tryClone(event) {
|
2009-10-14 18:28:59 -07:00
|
|
|
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");
|
2009-09-14 19:30:44 -07:00
|
|
|
|
|
|
|
clone.addEventListener("loadeddata", cloneLoaded, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find something we can play
|
2009-10-14 19:59:41 -07:00
|
|
|
for (var i = 0; i < gCloneTests.length; ++i) {
|
|
|
|
var test = gCloneTests[i];
|
2009-10-14 18:28:59 -07:00
|
|
|
var elemType = /^audio/.test(test.type) ? "audio" : "video";
|
2009-09-14 19:30:44 -07:00
|
|
|
var e = document.createElement(elemType);
|
2009-10-14 18:28:59 -07:00
|
|
|
if (e.canPlayType(test.type)) {
|
|
|
|
e.src = test.name;
|
|
|
|
if (test.duration) {
|
|
|
|
e._expectedDuration = test.duration;
|
|
|
|
}
|
2009-09-14 19:30:44 -07:00
|
|
|
e.addEventListener("loadeddata", tryClone, false);
|
|
|
|
e.load();
|
|
|
|
++testsWaiting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (testsWaiting == 0) {
|
|
|
|
todo(false, "Can't play anything");
|
|
|
|
} else {
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|