X
Tap here to go to the mobile version of the site.

Support Forum

Script does not work in FF 46

Posted

This code works on FF 38 and earlier to for restarting, why not in 46?

    const nsIAppStartup = Components.interfaces.nsIAppStartup;

    // Notify all windows that an application quit has been requested.
    var os = Components.classes["@mozilla.org/observer-service;1"]
        .getService(Components.interfaces.nsIObserverService);
    var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
        .createInstance(Components.interfaces.nsISupportsPRBool);
    os.notifyObservers(cancelQuit, "quit-application-requested", null);

    // Something aborted the quit process. 
    if (cancelQuit.data)
        return;

    // Notify all windows that an application quit has been granted.
    os.notifyObservers(null, "quit-application-granted", null);

    // Enumerate all windows and call shutdown handlers
    var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
        .getService(Components.interfaces.nsIWindowMediator);
    var windows = wm.getEnumerator(null);
    while (windows.hasMoreElements()) {
        var win = windows.getNext();
        if (("tryToClose" in win) && !win.tryToClose())
            return;
    }
    Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup)
        .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
This code works on FF 38 and earlier to for restarting, why not in 46? <pre><nowiki> const nsIAppStartup = Components.interfaces.nsIAppStartup; // Notify all windows that an application quit has been requested. var os = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"] .createInstance(Components.interfaces.nsISupportsPRBool); os.notifyObservers(cancelQuit, "quit-application-requested", null); // Something aborted the quit process. if (cancelQuit.data) return; // Notify all windows that an application quit has been granted. os.notifyObservers(null, "quit-application-granted", null); // Enumerate all windows and call shutdown handlers var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var windows = wm.getEnumerator(null); while (windows.hasMoreElements()) { var win = windows.getNext(); if (("tryToClose" in win) && !win.tryToClose()) return; } Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup) .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);</nowiki></pre>

Modified by cor-el

Additional System Details

Installed Plug-ins

  • Adobe PDF Plug-In For Firefox and Netscape 15.10.20056
  • NPRuntime Script Plug-in Library for Java(TM) Deploy
  • Next Generation Java Plug-in 11.31.2 for Mozilla browsers
  • The plug-in allows you to open and edit files using Microsoft Office applications
  • Office Authorization plug-in for NPAPI browsers
  • Shockwave Flash 21.0 r0

Application

  • User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0

More Information

cor-el
  • Top 10 Contributor
  • Moderator
17536 solutions 158566 answers

Maybe this is caused by the usage of windows as a variable name. You should always be cautious with using such a name as an identifier because it may get a reserved name at some time.

Maybe this is caused by the usage of windows as a variable name. You should always be cautious with using such a name as an identifier because it may get a reserved name at some time.
guigs 1072 solutions 11697 answers

Hi rdwray, Is this for version 46 ESR? If so please also ask this in the mailing list for ESR versions if we cannot figure it out here.

Also scripts are generally a good question to ask about in stackoverflow.com

Hi rdwray, Is this for version 46 ESR? If so please also ask this in the mailing list for ESR versions if we cannot figure it out here. *[https://www.mozilla.org/en-US/firefox/organizations/faq/] Also scripts are generally a good question to ask about in stackoverflow.com