Bug 942229 - Intermittent browser_cmd_screenshot.js, r=jwalker

--HG--
extra : rebase_source : f44fec6e46526a1381ac956bc362f82e11c1123c
This commit is contained in:
Olli Pettay 2013-12-11 22:36:24 +02:00
parent bb8f3692fd
commit ce023acc30
2 changed files with 11 additions and 6 deletions

View File

@ -170,9 +170,7 @@ function addWindow(windowOptions, callback) {
let win = OpenBrowserWindow(windowOptions);
let onLoad = function() {
win.removeEventListener("load", onLoad, false);
whenDelayedStartupFinished(win, function() {
// Would like to get rid of this executeSoon, but without it the url
// (TEST_URI) provided in addTabWithToolbarRunTests hasn't loaded
executeSoon(function() {
@ -187,9 +185,7 @@ function addWindow(windowOptions, callback) {
deferred.reject(ex);
}
});
};
win.addEventListener("load", onLoad, false);
});
return deferred.promise;
}

View File

@ -10,6 +10,15 @@ let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "/helpers.js", this);
Services.scriptloader.loadSubScript(testDir + "/mockCommands.js", this);
function whenDelayedStartupFinished(aWindow, aCallback) {
Services.obs.addObserver(function observer(aSubject, aTopic) {
if (aWindow == aSubject) {
Services.obs.removeObserver(observer, aTopic);
executeSoon(aCallback);
}
}, "browser-delayed-startup-finished", false);
}
/**
* Force GC on shutdown, because it seems that GCLI can outrun the garbage
* collector in some situations, which causes test failures in later tests