Bug 1288606 - Fix intermittent orange by making sure a weakly held nsISHistoryListener doesn't get GC'd before the browser_bug670318.js completes. r?Gijs
MozReview-Commit-ID: AWvpK6OpmmI
--- a/docshell/test/browser/browser_bug670318.js
+++ b/docshell/test/browser/browser_bug670318.js
@@ -26,16 +26,17 @@ add_task(function* test() {
addEventListener("load", function onLoad() {
removeEventListener("load", onLoad, true);
Assert.ok(history.index < history.count, "history.index is valid");
testDone.resolve();
}, true);
history.removeSHistoryListener(listener);
+ delete content._testListener;
content.setTimeout(() => { content.location.reload(); }, 0);
}
return true;
},
OnHistoryReload: () => true,
OnHistoryGoBack: () => true,
@@ -50,13 +51,20 @@ add_task(function* test() {
return true;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference])
};
history.addSHistoryListener(listener);
+ // Since listener implements nsISupportsWeakReference, we are
+ // responsible for keeping it alive so that the GC doesn't clear
+ // it before the test completes. We do this by anchoring the listener
+ // to the content global window, and clearing it just before the test
+ // completes.
+ content._testListener = listener;
content.location = URL;
+
yield testDone.promise;
});
});
});