Bug 475441. Clean up media tests to avoid opening windows or leaving them lying around. r=doublec

--HG--
extra : rebase_source : 86a5dabc1992d0676de30d67db99bec3e1b91b54
This commit is contained in:
Robert O'Callahan 2009-03-30 14:22:02 +13:00
parent 930ba04d88
commit 69e0e0412a
3 changed files with 41 additions and 29 deletions

View File

@ -12,6 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463830
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=463830">Mozilla Bug 463830</a>
<p id="display"></p>
<iframe id="i"></iframe>
<div id="content" style="display: none">
</div>
@ -28,20 +29,23 @@ var gTestNum = 0;
addLoadEvent(runTest);
var title;
var i = document.getElementById("i");
function runTest() {
if (gTestNum == gTests.length) {
SimpleTest.finish();
return;
}
var file = gTests[gTestNum].file;
var title = gTests[gTestNum].title;
var w = window.open(file, "", "width=500,height=300");
w.onload =
function() {
is(w.document.title, title, "Audio doc title incorrect");
w.close();
setTimeout(runTest, 0);
};
if (gTestNum == 0) {
i.addEventListener("load", function() {
is(i.contentDocument.title, title, "Doc title incorrect");
setTimeout(runTest, 0);
}, false);
}
title = gTests[gTestNum].title;
i.src = gTests[gTestNum].file;
gTestNum++;
}

View File

@ -11,10 +11,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
<script>
var gLoadedDataCount = 0;
var gLog = false;
var gTestWindow;
function log(msg) {
//document.getElementById('log').innerHTML += "<p>"+msg+"</p>";
//dump(msg + "\n");
if (gLog) {
document.getElementById('log').innerHTML += "<p>"+msg+"</p>";
dump(msg + "\n");
}
}
function loadeddata() {
@ -24,6 +28,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=479711
function loaded() {
is(gLoadedDataCount, 5, "onload was not delayed until after metadataloaded");
log("doc-loaded gLoadedDataCount = " + gLoadedDataCount);
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
gTestWindow.close();
SimpleTest.finish();
}
@ -51,8 +59,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=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);
}
@ -90,13 +96,11 @@ 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).
var gTestWindow = window.open("", "testWindow", "width=400,height=400");
// 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);
v4.addEventListener('load',
function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
gTestWindow.close();
}, false);
</script>
</pre>

View File

@ -12,6 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463830
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=463830">Mozilla Bug 463830</a>
<p id="display"></p>
<iframe id="i"></iframe>
<div id="content" style="display: none">
</div>
@ -29,20 +30,23 @@ var gTestNum = 0;
addLoadEvent(runTest);
var title;
var i = document.getElementById("i");
function runTest() {
if (gTestNum == gTests.length) {
SimpleTest.finish();
return;
}
var file = gTests[gTestNum].file;
var title = gTests[gTestNum].title;
var w = window.open(file, "", "width=500,height=300");
w.onload =
function() {
is(w.document.title, title, "Video doc title incorrect");
w.close();
setTimeout(runTest, 0);
};
if (gTestNum == 0) {
i.addEventListener("load", function() {
is(i.contentDocument.title, title, "Doc title incorrect");
setTimeout(runTest, 0);
}, false);
}
title = gTests[gTestNum].title;
i.src = gTests[gTestNum].file;
gTestNum++;
}