Bug 486556. Don't rely on loadeddata firing before the document load event, per spec it might not. r=doublec

--HG--
extra : rebase_source : 66db9e1f5e94d17f028855e62ebe1aee2ee5acc4
This commit is contained in:
Robert O'Callahan 2009-04-10 13:12:19 +12:00
parent 92ae784765
commit 95cf32025a

View File

@ -10,7 +10,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script>
var gLoadedDataCount = 0;
var gRegisteredElements = [];
var gLog = false;
var gTestWindow;
@ -21,13 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
}
}
function loadeddata() {
gLoadedDataCount++;
function register(v) {
gRegisteredElements.push(v);
}
function loaded() {
is(gLoadedDataCount, 5, "onload was not delayed until after metadataloaded");
log("doc-loaded gLoadedDataCount = " + gLoadedDataCount);
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();
@ -48,7 +52,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
</div>
<video src="320x240.ogv" onloadeddata="loadeddata();"></video>
<video src="320x240.ogv" id="v0"></video>
<div id="log" style="font-size: small;"></div>
@ -57,25 +61,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
/** Test for Bug 479711 **/
var gEventTypes = [ 'loadstart', 'progress', 'suspend', 'load', '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);
}
register(document.getElementById('v0'));
function createVideo(id) {
var v = document.createElement("video");
v.id = id;
for (var i=0; i<gEventTypes.length; i++) {
var t = gEventTypes[i];
v.addEventListener(t, listener, false);
if (gLog) {
var gEventTypes = [ 'loadstart', 'progress', 'suspend', 'load', '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);
}
}
v.addEventListener('loadeddata', loadeddata, false);
v.src = "http://localhost:8888/tests/content/media/video/test/320x240.ogv";
register(v);
return v;
}
// Load, add, then remove.
var v1 = createVideo("v1");
v1.load();
@ -101,7 +107,7 @@ v4.load(); // load started while in this document, this doc's load will block un
// 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>