Bug 1458375 - Add a new browser-idle-startup-tasks-finished notification. r?felipe
This notification fires when a browser window finishes running its idle tasks. Note
that it might never run if every window goes away before the idle tasks can run.
MozReview-Commit-ID: IEH98S29jhV
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1156,16 +1156,17 @@ if (document.documentElement.getAttribut
let _resolveDelayedStartup;
var delayedStartupPromise = new Promise(resolve => {
_resolveDelayedStartup = resolve;
});
var gBrowserInit = {
delayedStartupFinished: false,
+ idleTasksFinished: false,
_tabToAdopt: undefined,
getTabToAdopt() {
if (this._tabToAdopt !== undefined) {
return this._tabToAdopt;
}
@@ -1772,16 +1773,24 @@ var gBrowserInit = {
try {
DownloadsCommon.initializeAllDataLinks();
ChromeUtils.import("resource:///modules/DownloadsTaskbar.jsm", {})
.DownloadsTaskbar.registerIndicator(window);
} catch (ex) {
Cu.reportError(ex);
}
}, {timeout: 10000});
+
+ // This should always go last, since the idle tasks (except for the ones with
+ // timeouts) should execute in order. Note that this observer notification is
+ // not guaranteed to fire, since the window could close before we get here.
+ scheduleIdleTask(() => {
+ this.idleTasksFinished = true;
+ Services.obs.notifyObservers(window, "browser-idle-startup-tasks-finished");
+ });
},
// Returns the URI(s) to load at startup if it is immediately known, or a
// promise resolving to the URI to load.
get _uriToLoadPromise() {
delete this._uriToLoadPromise;
return this._uriToLoadPromise = function() {
// window.arguments[0]: URI to load (string), or an nsIArray of