tor-browser

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

browser-development-helpers.js (1603B)


      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 /**
      6 * Extra features for local development. This file isn't loaded in
      7 * non-local builds.
      8 */
      9 
     10 var DevelopmentHelpers = {
     11  init() {
     12    this.quickRestart = this.quickRestart.bind(this);
     13    this.addRestartShortcut();
     14  },
     15 
     16  quickRestart() {
     17    Services.obs.notifyObservers(null, "startupcache-invalidate");
     18    Services.env.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
     19 
     20    Services.startup.quit(
     21      Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart
     22    );
     23  },
     24 
     25  addRestartShortcut() {
     26    let command = document.createXULElement("command");
     27    command.setAttribute("id", "cmd_quickRestart");
     28    command.addEventListener("command", this.quickRestart, true);
     29    document.getElementById("mainCommandSet").prepend(command);
     30 
     31    let key = document.createXULElement("key");
     32    key.setAttribute("id", "key_quickRestart");
     33    key.setAttribute("key", "r");
     34    key.setAttribute("modifiers", "accel,alt");
     35    key.setAttribute("command", "cmd_quickRestart");
     36    document.getElementById("mainKeyset").prepend(key);
     37 
     38    let menuitem = document.createXULElement("menuitem");
     39    menuitem.setAttribute("id", "menu_FileRestartItem");
     40    menuitem.setAttribute("key", "key_quickRestart");
     41    menuitem.setAttribute("label", "Restart (Developer)");
     42    menuitem.addEventListener("command", this.quickRestart, true);
     43    document.getElementById("menu_FilePopup").appendChild(menuitem);
     44  },
     45 };