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">
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
var manager = new MediaTestManager;
|
2009-09-14 19:30:44 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
manager.finished(e.token);
|
2009-09-14 19:30:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function tryClone(event) {
|
2009-10-14 18:28:59 -07:00
|
|
|
var e = event.target;
|
|
|
|
var clone = e.cloneNode(false);
|
2010-08-26 19:11:46 -07:00
|
|
|
clone.token = e.token;
|
|
|
|
|
2009-10-14 18:28:59 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
function initTest(test, token) {
|
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();
|
2010-08-26 19:11:46 -07:00
|
|
|
e.token = token;
|
|
|
|
manager.started(token);
|
2009-09-14 19:30:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
manager.runTests(gCloneTests, initTest);
|
2009-09-14 19:30:44 -07:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|