How to restart firefox from code?

658 views Asked by At

How to correctly restart firefox (without any "restore session" things and with the same windows as before) from code?

I know pid of "firefox-bin" in a bash script process and I have my custom plugin loaded into it.

1

There are 1 answers

5
Neil On BEST ANSWER
Services.prefs.setBoolPref("browser.sessionstore.resume_session_once", true);
const nsIAppStartup = Components.interfaces.nsIAppStartup;
Components.classes["@mozilla.org/toolkit/app-startup;1"]
          .getService(nsIAppStartup)
          .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);

Note that this applies to Firefox 4 so the code might be slightly different for earlier versions.