tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

aboutRestartRequired.js (1299B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 var AboutRestartRequired = {
      6  /* Only do autofocus if we're the toplevel frame; otherwise we
      7     don't want to call attention to ourselves!  The key part is
      8     that autofocus happens on insertion into the tree, so we
      9     can remove the button, add @autofocus, and reinsert the
     10     button.
     11  */
     12  addAutofocus() {
     13    if (window.top == window) {
     14      var button = document.getElementById("restart");
     15      var parent = button.parentNode;
     16      button.remove();
     17      button.setAttribute("autofocus", "true");
     18      parent.insertAdjacentElement("afterbegin", button);
     19    }
     20  },
     21  restart() {
     22    Services.startup.quit(
     23      Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit
     24    );
     25  },
     26  init() {
     27    this.addAutofocus();
     28  },
     29 };
     30 
     31 AboutRestartRequired.init();
     32 
     33 let restartButton = document.getElementById("restart");
     34 restartButton.onclick = function () {
     35  AboutRestartRequired.restart();
     36 };
     37 
     38 // Dispatch this event so tests can detect that we finished loading the page.
     39 let event = new CustomEvent("AboutRestartRequiredLoad", { bubbles: true });
     40 document.dispatchEvent(event);