<commit_before>const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");

let cleanupAry = [];

function restart() {
  Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup)
      .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
}

function main(win) {
  let doc = win.document;
  let restartMI = doc.createElement("menuitem");
  let fileMenu = doc.getElementById("menu_FilePopup");
  let quitMI = doc.getElementById("menu_FileQuitItem");
  restartMI.setAttribute("id", "menu_FileRestartItem");
  restartMI.setAttribute("label", "Restart");
  restartMI.addEventListener("command", restart, true);
  fileMenu.insertBefore(restartMI, quitMI);

  let len = cleanupAry.push(function() fileMenu.removeChild(restartMI));
  win.addEventListener("unload", function() {
    cleanupAry[len - 1] = null;
  }, false);
}
<commit_msg>fixing a minor mem leak when disabling/uninstalling RR there were remaining window unload listeners that are now removed.<commit_after>const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");

let cleanupAry = [];

function restart() {
  Cc['@mozilla.org/toolkit/app-startup;1'].getService(Ci.nsIAppStartup)
      .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
}

function main(win) {
  let doc = win.document;
  let restartMI = doc.createElement("menuitem");
  let fileMenu = doc.getElementById("menu_FilePopup");
  let quitMI = doc.getElementById("menu_FileQuitItem");
  restartMI.setAttribute("id", "menu_FileRestartItem");
  restartMI.setAttribute("label", "Restart");
  restartMI.addEventListener("command", restart, true);
  fileMenu.insertBefore(restartMI, quitMI);

  let idx1 = cleanupAry.push(function() fileMenu.removeChild(restartMI)) - 1;
  let idx2 = cleanupAry.push(function() (
      win.removeEventListener("unload", winUnloader, false))) - 1;
  function winUnloader() {
    cleanupAry[idx1] = null;
    cleanupAry[idx2] = null;
  }
  win.addEventListener("unload", winUnloader, false);
}

{'fraction_non_alphanumeric': 0.1463531669865643, 'fraction_numerical': 0.004318618042226488, 'mean_word_length': 5.556603773584905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6759937', 'n_tokens_mistral': 695, 'n_tokens_neox': 689, 'n_words': 126}