How to restart Mozila Firefox browser from firefox extension

I am creating a firefox extension. I have to restart firefox after certain condition from extension's js file. So how can I restart firefox browser by extension javascript ? Thanks in advance.


Use this code:

function restart() {
  let canceled = Cc[";1"]

  Services.obs.notifyObservers(canceled, "quit-application-requested", "restart");

  if ( return false; // somebody canceled our quit request

  // disable fastload cache?
  if (getPref("disable_fastload")) Services.appinfo.invalidateCachesOnRestart();

  // restart
      .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);

  return true;

The following will invoke the already existing Mozilla restart command (which makes sure that all the appropriate cleanup is done).

This will work from a context where you have access to the browser window element (i.e. from a dialog window which you have opened (e.g. options dialog)):


Need Your Help

How to properly use the dispose method on a class

c# windowsformshost

I'm working on a database and I need to write the database to file when the database class is destroyed along with every else when the form is closed

Conditional Coloring of Datatable in PF or var vs binding tags in a datatable

java datatable primefaces

I have a datatable and a collector. Each row in the datatable has a button and this button adds the corresponding row to the collector. I want to add conditional coloring to this datatable. Conditi...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.