gecko/content/media/test/test_delay_load.html
Chris Pearce c7317b404d Bug 564720 - Refactor media tests to be backend independent were possible. r=roc
--HG--
rename : content/media/test/test_play.html => content/media/test/test_play_events.html
rename : content/media/test/test_progress2.html => content/media/test/test_progress.html
rename : content/media/test/test_onloadedmetadata.html => content/media/test/test_replay_metadata.html
rename : content/media/test/test_wav_trunc_seek.html => content/media/test/test_seek_out_of_range.html
rename : content/media/test/test_bug495319.html => content/media/test/test_timeupdate_small_files.html
rename : content/media/test/test_bug486646.html => content/media/test/test_video_to_canvas.html
2010-05-31 10:02:06 +12:00

129 lines
3.2 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=479711
-->
<head>
<title>Test for Bug 479711</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/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>
<script>
var gRegisteredElements = [];
var gLog = false;
var testWindows = [];
function log(msg) {
if (gLog) {
document.getElementById('log').innerHTML += "<p>"+msg+"</p>";
dump(msg + "\n");
}
}
function register(v) {
gRegisteredElements.push(v);
}
function loaded() {
log("onload fired!");
for (var i = 0; i < gRegisteredElements.length; ++i) {
var v = gRegisteredElements[i];
ok(v.readyState >= v.HAVE_CURRENT_DATA,
v._name + ":" + v.id + " is not ready before onload fired (" + v.readyState + ")");
}
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
for (i=0; i<testWindows.length; ++i) {
testWindows[i].close();
}
SimpleTest.finish();
}
addLoadEvent(loaded);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=479711">Mozilla Bug 479711</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<div id="log" style="font-size: small;"></div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 479711 **/
function createVideo(name, type, id) {
var v = document.createElement("video");
if (!v.canPlayType(type)) {
return null;
}
v.src = name;
v._name = name;
v.id = id;
register(v);
return v;
}
for (var i=0; i<gSmallTests.length; ++i) {
var test = gSmallTests[i];
// Straightforward add, causing a load.
var v1 = createVideo(test.name, test.type, "1");
if (v1 == null) {
continue;
}
document.body.appendChild(v1);
// Load, add, then remove.
var v1 = createVideo(test.name, test.type, "1");
if (!v1) {
continue;
}
v1.load();
document.body.appendChild(v1);
v1.parentNode.removeChild(v1);
// Load and add.
var v2 = createVideo(test.name, test.type, "2");
v2.load();
document.body.appendChild(v2);
// Load outside of doc.
var v3 = createVideo(test.name, test.type, "3");
v3.load();
// Load and move to another document.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var v4 = createVideo(test.name, test.type, "4");
v4.load(); // load started while in this document, this doc's load will block until
// the video's finished loading (in the other document).
// Opening a new window to do this is a bit annoying, but if we use an iframe here,
// delaying of the iframe's load event might interfere with the firing of our load event
// in some confusing way. So it's simpler just to open another window.
var w = window.open("", "testWindow"+i, "width=400,height=400");
w.document.body.appendChild(v4);
testWindows.push(w);
}
if (gRegisteredElements.length > 0) {
SimpleTest.waitForExplicitFinish();
} else {
todo(false, "No types supported");
}
</script>
</pre>
</body>
</html>