Created
May 24, 2019 10:44
-
-
Save gijsk/ce9fa9494d7e588a6a5919c2c85a86f4 to your computer and use it in GitHub Desktop.
Make quitter wait for idle startup finished
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tools/quitter/parent.js b/tools/quitter/parent.js | |
--- a/tools/quitter/parent.js | |
+++ b/tools/quitter/parent.js | |
@@ -4,14 +4,24 @@ | |
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); | |
this.quitter = class extends ExtensionAPI { | |
getAPI(context) { | |
return { | |
quitter: { | |
quit() { | |
+ let browserWindow = Services.wm.getMostRecentWindow("navigator:browser"); | |
+ if (browserWindow && browserWindow.gBrowserInit && | |
+ !browserWindow.gBrowserInit.idleTasksFinished) { | |
+ let obs = () => { | |
+ Services.obs.removeObserver(obs, "browser-idle-startup-tasks-finished"); | |
+ this.quit(); | |
+ }; | |
+ Services.obs.addObserver(obs, "browser-idle-startup-tasks-finished"); | |
+ return; | |
+ } | |
Services.startup.quit(Ci.nsIAppStartup.eForceQuit); | |
}, | |
}, | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment