gecko/content/media/test/test_delay_load.html

115 lines
3.1 KiB
HTML
Raw Normal View History

<!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>
var gRegisteredElements = [];
var gLog = false;
var gTestWindow;
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, "Video " + v.id + " is not ready before onload fired");
}
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
gTestWindow.close();
SimpleTest.finish();
}
addLoadEvent(loaded);
SimpleTest.waitForExplicitFinish();
</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>
<video src="320x240.ogv" id="v0"></video>
<div id="log" style="font-size: small;"></div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 479711 **/
register(document.getElementById('v0'));
function createVideo(id) {
var v = document.createElement("video");
v.id = id;
if (gLog) {
var gEventTypes = [ 'loadstart', 'progress', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'play', 'pause', 'loadedmetadata', 'loadeddata', 'waiting', 'playing', 'canplay', 'canplaythrough', 'seeking', 'seeked', 'timeupdate', 'ended', 'ratechange', 'durationchange', 'volumechange' ];
function listener(evt) {
log('event ' + evt.target.id + " " + evt.type);
}
for (var i=0; i<gEventTypes.length; i++) {
var t = gEventTypes[i];
v.addEventListener(t, listener, false);
}
}
2010-03-08 22:14:21 -08:00
v.src = "http://localhost:8888/tests/content/media/test/320x240.ogv";
register(v);
return v;
}
// Load, add, then remove.
var v1 = createVideo("v1");
v1.load();
document.body.appendChild(v1);
v1.parentNode.removeChild(v1);
// Load and add.
var v2 = createVideo("v2");
v2.load();
document.body.appendChild(v2);
// Load outside of doc.
var v3 = createVideo("v3");
v3.load();
// Load and move to another document.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var v4 = createVideo("v4");
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.
gTestWindow = window.open("", "testWindow", "width=400,height=400");
gTestWindow.document.body.appendChild(v4);
</script>
</pre>
</body>
</html>