Skip to content

Instantly share code, notes, and snippets.

@gijsk
Created May 24, 2019 10:44
Show Gist options
  • Save gijsk/ce9fa9494d7e588a6a5919c2c85a86f4 to your computer and use it in GitHub Desktop.
Save gijsk/ce9fa9494d7e588a6a5919c2c85a86f4 to your computer and use it in GitHub Desktop.
Make quitter wait for idle startup finished
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