Bug 508472, wait for load and paint events before starting test, r=dolske

This commit is contained in:
Neil Deakin 2009-08-12 10:04:51 -04:00
parent 5c4ab1a382
commit 223d38e76c

View File

@ -367,8 +367,24 @@ function startTest() {
// The frame causes an extra menu item, and prevents running the test
// standalone (ie, clicking the test name in the Mochitest window) to see
// success/failure messages.
var painted = false, loaded = false;
function waitForEvents(event)
{
if (event.type == "MozAfterPaint")
painted = true;
else if (event.type == "load")
loaded = true;
if (painted && loaded) {
subwindow.removeEventListener("MozAfterPaint", waitForEvents, false);
subwindow.onload = null;
startTest();
}
}
var subwindow = window.open("./subtst_contextmenu.html", "contextmenu-subtext", "width=600,height=700");
subwindow.onload = startTest;
subwindow.addEventListener("MozAfterPaint", waitForEvents, false);
subwindow.onload = waitForEvents;
SimpleTest.waitForExplicitFinish();
</script>