Bug 1397365: Part 3 - Fine-tune mochitest headers to wait for browser to be loaded. r?mconley
Several header functions were not completely waiting for the new window
to be initialized. The behavior was race-y and the switch of the initialBrowser
to nodefaultsrc made it more pronounced.
MozReview-Commit-ID: AjCWXozBcfi
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -208,19 +208,17 @@ function setAndUpdateBlocklist(aURL, aCa
}
function resetBlocklist() {
Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL);
}
function whenNewWindowLoaded(aOptions, aCallback) {
let win = OpenBrowserWindow(aOptions);
- win.addEventListener("load", function() {
- aCallback(win);
- }, {once: true});
+ whenDelayedStartupFinished(win, () => aCallback(win));
}
function promiseWindowWillBeClosed(win) {
return new Promise((resolve, reject) => {
Services.obs.addObserver(function observe(subject, topic) {
if (subject == win) {
Services.obs.removeObserver(observe, topic);
resolve();
--- a/browser/base/content/test/referrer/head.js
+++ b/browser/base/content/test/referrer/head.js
@@ -249,13 +249,15 @@ function startReferrerTest(aStartTestCas
// Open the window where we'll load the source URLs.
gTestWindow = openDialog(location, "", "chrome,all,dialog=no", "about:blank");
registerCleanupFunction(function() {
gTestWindow && gTestWindow.close();
});
// Load and start the first test.
delayedStartupFinished(gTestWindow).then(function() {
- referrerTestCaseLoaded(0, params).then(function() {
- aStartTestCase(0);
+ BrowserTestUtils.browserLoaded(gTestWindow.gBrowser.selectedBrowser).then(() => {
+ referrerTestCaseLoaded(0, params).then(function() {
+ aStartTestCase(0);
+ });
});
});
}