<commit_before>/* globals UITour */
/** The main module is loaded on startup

This also contains the UI that is directly in the browser,
specifically the button and control over the panel.  `lib/errors.js`
controls some error-specific UI
*/

"use strict";
// cfx set this to true, and causes a ton of messages
require("sdk/preferences/service").set("javascript.options.strict", false);

const self = require("sdk/self");
const tabs = require("sdk/tabs");
const shooter = require("./shooter");
const { prefs } = require("sdk/simple-prefs");
const helperworker = require("./helperworker");
const { ActionButton } = require("sdk/ui/button/action");
const { watchFunction } = require("./errors");
const { Cu, Cc, Ci } = require("chrome");
const winutil = require("sdk/window/utils");
const req = require("./req");
const { setTimeout } = require("sdk/timers");
var { Hotkey } = require("sdk/hotkeys");

let Services;

// Give the server a chance to start if the pref is set
require("./headless").init();

Cu.import("resource:///modules/UITour.jsm");

let loadReason = null; // eslint-disable-line no-unused-vars
let initialized = false;
let tabsBeingShot = {};

// FIXME turn off the tour for now until it gets some love.
const ENABLE_FTU = false;

function getNotificationBox(browser) {
  let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
  let win = wm.getMostRecentWindow("navigator:browser");
  let gBrowser = win.gBrowser;

  browser = browser || gBrowser.selectedBrowser;
  return gBrowser.getNotificationBox(browser);
}

function showNotificationBar(shotcontext) {
  var nb = require("./notificationbox");
  if (nb.notificationbox().getNotificationWithValue("pageshot-notification-bar") !== null) {
    return;
  }
  let thebox = nb.notificationbox();
  let fragment = thebox.ownerDocument.createDocumentFragment();
  let myShots = thebox.ownerDocument.createElement("button");
  myShots.className = "myshots";
  myShots.setAttribute("label", "myshots");<commit_msg>Fixes #1351 Track the back button using the pageshow event (ready only fires for pages not in the cache) and clean up tabsBeingShot<commit_after>/* globals UITour */
/** The main module is loaded on startup

This also contains the UI that is directly in the browser,
specifically the button and control over the panel.  `lib/errors.js`
controls some error-specific UI
*/

"use strict";
// cfx set this to true, and causes a ton of messages
require("sdk/preferences/service").set("javascript.options.strict", false);

const self = require("sdk/self");
const tabs = require("sdk/tabs");
const shooter = require("./shooter");
const { prefs } = require("sdk/simple-prefs");
const helperworker = require("./helperworker");
const { ActionButton } = require("sdk/ui/button/action");
const { watchFunction } = require("./errors");
const { Cu, Cc, Ci } = require("chrome");
const winutil = require("sdk/window/utils");
const req = require("./req");
const { setTimeout } = require("sdk/timers");
var { Hotkey } = require("sdk/hotkeys");

let Services;

// Give the server a chance to start if the pref is set
require("./headless").init();

Cu.import("resource:///modules/UITour.jsm");

let loadReason = null; // eslint-disable-line no-unused-vars
let initialized = false;
let tabsBeingShot = {};

function cleanUpTabsBeingShot(tab) {
  delete tabsBeingShot[tab.id];
}

for (let tab of tabs) {
  tab.on("pageshow", cleanUpTabsBeingShot);
}

tabs.on("open", function(tab) {
  tab.on("pageshow", cleanUpTabsBeingShot);
});

// FIXME turn off the tour for now until it gets some love.
const ENABLE_FTU = false;

function getNotificationBox(browser) {
  let wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
  let win = wm.getMostRecentWindow("navigator:browser");
  let gBrowser = win.gBrowser;

  browser = browser || gBrowser.selectedBrowser;
  return gBrowser.getNotificationBox(browser);
}

function showNotificationBar(shotcontext) {
  var nb = require("./notificationbox");
  if (nb.notificationbox().getNotificationWithValue("pageshot-notification-bar") !== null) {
    return;
  }
  let thebox = nb.notificationbox();
  let fragment = thebox.ownerDocument.createDocumentFragment();
  let myShots = thebox.ownerDocument.createElement("button");
  myShots.className = "myshots";
  myShots.setAttribute("label", "myshots");
{'fraction_non_alphanumeric': 0.14279155188246098, 'fraction_numerical': 0.0013774104683195593, 'mean_word_length': 4.976680384087792, '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': '6464584', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1306, 'n_words': 368}