Backed out 2 changesets (bug 1484640) for ESlint failure at browser.js. CLOSED TREE
authorBrindusan Cristian <cbrindusan@mozilla.com>
Wed, 20 Mar 2019 21:24:22 +0200
changeset 465275 e91f6d3bc047478cdd53a12ea2b5b02b6856d849
parent 465274 446d785e076b7f9ffaa32c0506715083d4752961
child 465276 d64cfe30769af8f543ac5259542baa7d304e082b
push id35735
push usershindli@mozilla.com
push dateThu, 21 Mar 2019 04:34:45 +0000
treeherdermozilla-central@ac0cd1a710f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1484640
milestone68.0a1
backs out54f421232d08b49c1bd3769e680f3c61e163f72e
5914426902ac204d49683d56695d1adf45e2c1cd
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 2 changesets (bug 1484640) for ESlint failure at browser.js. CLOSED TREE Backed out changeset 54f421232d08 (bug 1484640) Backed out changeset 5914426902ac (bug 1484640)
.eslintignore
mobile/android/chrome/content/browser.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -261,16 +261,19 @@ mobile/android/app/geckoview-prefs.js
 
 # Uses `#expand`
 mobile/android/chrome/content/about.js
 
 # Not much JS to lint and non-standard at that
 mobile/android/installer/
 mobile/android/locales/
 
+# Non-standard `(catch ex if ...)`
+mobile/android/chrome/content/browser.js
+
 # Pre-processed/pref files
 modules/libpref/greprefs.js
 modules/libpref/init/all.js
 modules/libpref/test/unit/*data/**
 
 # Only contains non-standard test files.
 python/**
 
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -119,17 +119,17 @@ var lazilyLoadedBrowserScripts = [
   ["MasterPassword", "chrome://browser/content/MasterPassword.js"],
   ["OfflineApps", "chrome://browser/content/OfflineApps.js"],
   ["Linkifier", "chrome://browser/content/Linkify.js"],
   ["CastingApps", "chrome://browser/content/CastingApps.js"],
   ["RemoteDebugger", "chrome://browser/content/RemoteDebugger.js"],
   ["gViewSourceUtils", "chrome://global/content/viewSourceUtils.js"],
 ];
 
-lazilyLoadedBrowserScripts.forEach(function(aScript) {
+lazilyLoadedBrowserScripts.forEach(function (aScript) {
   let [name, script] = aScript;
   XPCOMUtils.defineLazyGetter(window, name, function() {
     let sandbox = {};
     Services.scriptloader.loadSubScript(script, sandbox);
     return sandbox[name];
   });
 });
 
@@ -140,17 +140,17 @@ var lazilyLoadedObserverScripts = [
    "chrome://browser/content/MemoryObserver.js"],
   ["ConsoleAPI", ["console-api-log-event"], "chrome://browser/content/ConsoleAPI.js"],
   ["ExtensionPermissions", ["webextension-permission-prompt",
                             "webextension-update-permissions",
                             "webextension-optional-permission-prompt"],
    "chrome://browser/content/ExtensionPermissions.js"],
 ];
 
-lazilyLoadedObserverScripts.forEach(function(aScript) {
+lazilyLoadedObserverScripts.forEach(function (aScript) {
   let [name, notifications, script] = aScript;
   XPCOMUtils.defineLazyGetter(window, name, function() {
     let sandbox = {};
     Services.scriptloader.loadSubScript(script, sandbox);
     return sandbox[name];
   });
   let observer = (s, t, d) => {
     Services.obs.removeObserver(observer, t);
@@ -282,46 +282,46 @@ XPCOMUtils.defineLazyGetter(this, "Conte
 ChromeUtils.defineModuleGetter(this, "Rect", "resource://gre/modules/Geometry.jsm");
 ChromeUtils.defineModuleGetter(this, "Point", "resource://gre/modules/Geometry.jsm");
 
 function resolveGeckoURI(aURI) {
   if (!aURI)
     throw "Can't resolve an empty uri";
 
   if (aURI.startsWith("chrome://")) {
-    let registry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
+    let registry = Cc['@mozilla.org/chrome/chrome-registry;1'].getService(Ci["nsIChromeRegistry"]);
     return registry.convertChromeURL(Services.io.newURI(aURI)).spec;
   } else if (aURI.startsWith("resource://")) {
     let handler = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
     return handler.resolveURI(Services.io.newURI(aURI));
   }
   return aURI;
 }
 
 /**
  * Cache of commonly used string bundles.
  */
 var Strings = {
-  init: function() {
+  init: function () {
     XPCOMUtils.defineLazyGetter(Strings, "brand", () => Services.strings.createBundle("chrome://branding/locale/brand.properties"));
     XPCOMUtils.defineLazyGetter(Strings, "browser", () => Services.strings.createBundle("chrome://browser/locale/browser.properties"));
     XPCOMUtils.defineLazyGetter(Strings, "reader", () => Services.strings.createBundle("chrome://global/locale/aboutReader.properties"));
   },
 
-  flush: function() {
+  flush: function () {
     Services.strings.flushBundles();
     this.init();
   },
 };
 
 Strings.init();
 
 const kFormHelperModeDisabled = 0;
 const kFormHelperModeEnabled = 1;
-const kFormHelperModeDynamic = 2; // disabled on tablets
+const kFormHelperModeDynamic = 2;   // disabled on tablets
 const kMaxHistoryListSize = 50;
 
 function InitLater(fn, object, name) {
   return DelayedInit.schedule(fn, object, name, 15000 /* 15s max wait */);
 }
 
 var BrowserApp = {
   _tabs: [],
@@ -398,23 +398,23 @@ var BrowserApp = {
     Services.obs.addObserver(this, "android-get-pref");
     Services.obs.addObserver(this, "android-set-pref");
     Services.obs.addObserver(this, "gather-telemetry");
     Services.obs.addObserver(this, "keyword-search");
     Services.obs.addObserver(this, "Vibration:Request");
 
     window.addEventListener("fullscreen", function() {
       WindowEventDispatcher.sendRequest({
-        type: window.fullScreen ? "ToggleChrome:Hide" : "ToggleChrome:Show",
+        type: window.fullScreen ? "ToggleChrome:Hide" : "ToggleChrome:Show"
       });
     });
 
     window.addEventListener("fullscreenchange", (e) => {
       WindowEventDispatcher.sendRequest({
-        type: document.fullscreenElement ? "DOMFullScreen:Start" : "DOMFullScreen:Stop",
+        type: document.fullscreenElement ? "DOMFullScreen:Start" : "DOMFullScreen:Stop"
       });
 
       if (this.fullscreenTransitionTab) {
         // Tab selection has changed during a fullscreen transition, handle it now.
         let tab = this.fullscreenTransitionTab;
         this.fullscreenTransitionTab = null;
         this.selectTab(tab);
       }
@@ -564,22 +564,22 @@ var BrowserApp = {
     }
 
     return this._startupStatus;
   },
 
   /**
    * Pass this a locale string, such as "fr" or "es_ES".
    */
-  setLocale: function(locale) {
+  setLocale: function (locale) {
     console.log("browser.js: requesting locale set: " + locale);
     WindowEventDispatcher.sendRequest({ type: "Locale:Set", locale: locale });
   },
 
-  initContextMenu: function() {
+  initContextMenu: function () {
     // We pass a thunk in place of a raw label string. This allows the
     // context menu to automatically accommodate locale changes without
     // having to be rebuilt.
     let stringGetter = name => () => Strings.browser.GetStringFromName(name);
 
     function videoClassifier(aTarget) {
       if (aTarget.readyState == aTarget.HAVE_NOTHING) {
         // We don't know if the height/width of the video,
@@ -607,45 +607,45 @@ var BrowserApp = {
         let newtabStrings = Strings.browser.GetStringFromName("newtabpopup.opened");
         let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
         let buttonLabel = Strings.browser.GetStringFromName("newtabpopup.switch");
 
         Snackbars.show(label, Snackbars.LENGTH_LONG, {
           action: {
             label: buttonLabel,
             callback: () => { BrowserApp.selectTab(tab); },
-          },
+          }
         });
       });
 
     let showOpenInPrivateTab = true;
     if ("@mozilla.org/parental-controls-service;1" in Cc) {
       let pc = Cc["@mozilla.org/parental-controls-service;1"].createInstance(Ci.nsIParentalControlsService);
       showOpenInPrivateTab = pc.isAllowed(Ci.nsIParentalControlsService.PRIVATE_BROWSING);
     }
 
     if (showOpenInPrivateTab) {
       NativeWindow.contextmenus.add(stringGetter("contextmenu.openInPrivateTab"),
         NativeWindow.contextmenus.linkOpenableContext,
-        function(aTarget) {
+        function (aTarget) {
           UITelemetry.addEvent("action.1", "contextmenu", null, "web_open_new_tab");
           UITelemetry.addEvent("loadurl.1", "contextmenu", null);
 
           let url = NativeWindow.contextmenus._getLinkURL(aTarget);
           ContentAreaUtils.urlSecurityCheck(url, aTarget.ownerDocument.nodePrincipal);
           let tab = BrowserApp.addTab(url, {selected: false, parentId: BrowserApp.selectedTab.id, isPrivate: true});
 
           let newtabStrings = Strings.browser.GetStringFromName("newprivatetabpopup.opened");
           let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
           let buttonLabel = Strings.browser.GetStringFromName("newtabpopup.switch");
           Snackbars.show(label, Snackbars.LENGTH_LONG, {
             action: {
               label: buttonLabel,
               callback: () => { BrowserApp.selectTab(tab); },
-            },
+            }
           });
         });
     }
 
     NativeWindow.contextmenus.add(stringGetter("contextmenu.copyLink"),
       NativeWindow.contextmenus.linkCopyableContext,
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_copy_link");
@@ -686,17 +686,17 @@ var BrowserApp = {
           title: aElement.textContent.trim() || aElement.title.trim(),
           uri,
         };
       },
       icon: "drawable://ic_menu_share",
       callback: function(aTarget) {
         // share.1 telemetry is handled in Java via PromptList
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_share_link");
-      },
+      }
     });
 
     NativeWindow.contextmenus.add({
       label: stringGetter("contextmenu.shareEmailAddress"),
       order: NativeWindow.contextmenus.DEFAULT_HTML5_ORDER - 1,
       selector: NativeWindow.contextmenus._disableRestricted("SHARE", NativeWindow.contextmenus.emailLinkContext),
       showAsActions: function(aElement) {
         let url = NativeWindow.contextmenus._getLinkURL(aElement);
@@ -706,17 +706,17 @@ var BrowserApp = {
           title: title,
           uri: emailAddr,
         };
       },
       icon: "drawable://ic_menu_share",
       callback: function(aTarget) {
         // share.1 telemetry is handled in Java via PromptList
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_share_email");
-      },
+      }
     });
 
     NativeWindow.contextmenus.add({
       label: stringGetter("contextmenu.sharePhoneNumber"),
       order: NativeWindow.contextmenus.DEFAULT_HTML5_ORDER - 1,
       selector: NativeWindow.contextmenus._disableRestricted("SHARE", NativeWindow.contextmenus.phoneNumberLinkContext),
       showAsActions: function(aElement) {
         let url = NativeWindow.contextmenus._getLinkURL(aElement);
@@ -726,55 +726,55 @@ var BrowserApp = {
           title: title,
           uri: phoneNumber,
         };
       },
       icon: "drawable://ic_menu_share",
       callback: function(aTarget) {
         // share.1 telemetry is handled in Java via PromptList
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_share_phone");
-      },
+      }
     });
 
     NativeWindow.contextmenus.add(stringGetter("contextmenu.addToContacts"),
       NativeWindow.contextmenus._disableRestricted("ADD_CONTACT", NativeWindow.contextmenus.emailLinkContext),
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_contact_email");
 
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         WindowEventDispatcher.sendRequest({
           type: "Contact:Add",
-          email: url,
+          email: url
         });
       });
 
     NativeWindow.contextmenus.add(stringGetter("contextmenu.addToContacts"),
       NativeWindow.contextmenus._disableRestricted("ADD_CONTACT", NativeWindow.contextmenus.phoneNumberLinkContext),
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_contact_phone");
 
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         WindowEventDispatcher.sendRequest({
           type: "Contact:Add",
-          phone: url,
+          phone: url
         });
       });
 
     NativeWindow.contextmenus.add(stringGetter("contextmenu.bookmarkLink"),
       NativeWindow.contextmenus._disableRestricted("BOOKMARK", NativeWindow.contextmenus.linkBookmarkableContext),
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_bookmark");
         UITelemetry.addEvent("save.1", "contextmenu", null, "bookmark");
 
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         let title = aTarget.textContent || aTarget.title || url;
         GlobalEventDispatcher.sendRequest({
           type: "Bookmark:Insert",
           url: url,
-          title: title,
+          title: title
         });
       });
 
     NativeWindow.contextmenus.add(stringGetter("contextmenu.playMedia"),
       NativeWindow.contextmenus.mediaContext("media-paused"),
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_play");
         aTarget.play();
@@ -811,17 +811,17 @@ var BrowserApp = {
           uri: url,
           type: videoClassifier(aElement) === "Audio" ? "audio/*" : "video/*",
         };
       },
       icon: "drawable://ic_menu_share",
       callback: function(aTarget) {
         // share.1 telemetry is handled in Java via PromptList
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_share_media");
-      },
+      }
     });
 
     NativeWindow.contextmenus.add(stringGetter("contextmenu.fullScreen"),
       NativeWindow.contextmenus.videoContext("not-fullscreen"),
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_fullscreen");
         aTarget.requestFullscreen();
       });
@@ -874,17 +874,17 @@ var BrowserApp = {
           uri: src,
           type: "image/*",
         };
       },
       icon: "drawable://ic_menu_share",
       menu: true,
       callback: function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_share_image");
-      },
+      }
     });
 
 
     NativeWindow.contextmenus.add(stringGetter("contextmenu.saveImage"),
       NativeWindow.contextmenus.imageSaveableContext,
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_save_image");
         UITelemetry.addEvent("save.1", "contextmenu", null, "image");
@@ -907,17 +907,17 @@ var BrowserApp = {
     NativeWindow.contextmenus.add(stringGetter("contextmenu.setImageAs"),
       NativeWindow.contextmenus._disableRestricted("SET_IMAGE", NativeWindow.contextmenus.imageSaveableContext),
       function(aTarget) {
         UITelemetry.addEvent("action.1", "contextmenu", null, "web_background_image");
 
         let src = aTarget.currentSrc || aTarget.src;
         GlobalEventDispatcher.sendRequest({
           type: "Image:SetAs",
-          url: src,
+          url: src
         });
       });
 
     NativeWindow.contextmenus.add(
       function(aTarget) {
         if (aTarget instanceof HTMLVideoElement) {
           return Strings.browser.GetStringFromName(
             `contextmenu.save${videoClassifier(aTarget)}`
@@ -967,17 +967,17 @@ var BrowserApp = {
             label: Strings.browser.GetStringFromName("imageblocking.showAllImages"),
             callback: () => {
               UITelemetry.addEvent("action.1", "toast", null, "web_show_all_image");
               for (let i = 0; i < blockedImgs.length; ++i) {
                 blockedImgs[i].setAttribute("data-ctv-show", "true");
                 blockedImgs[i].setAttribute("src", blockedImgs[i].getAttribute("data-ctv-src"));
               }
             },
-          },
+          }
         });
     });
   },
 
   onAppUpdated: function() {
     // initialize the form history and passwords databases on upgrades
     GlobalEventDispatcher.dispatch("FormHistory:Init", null);
     GlobalEventDispatcher.dispatch("Passwords:Init", null);
@@ -1117,17 +1117,17 @@ var BrowserApp = {
   get selectedBrowser() {
     if (this._selectedTab)
       return this._selectedTab.browser;
     return null;
   },
 
   getTabForId: function getTabForId(aId) {
     let tabs = this._tabs;
-    for (let i = 0; i < tabs.length; i++) {
+    for (let i=0; i < tabs.length; i++) {
        if (tabs[i].id == aId)
          return tabs[i];
     }
     return null;
   },
 
   getTabForBrowser: function getTabForBrowser(aBrowser) {
     let tabs = this._tabs;
@@ -1193,24 +1193,24 @@ var BrowserApp = {
     try {
       aBrowser.loadURI(aURI, {
         flags,
         referrerURI,
         charset,
         postData,
         triggeringPrincipal,
       });
-    } catch (e) {
+    } catch(e) {
       if (tab) {
         let message = {
           type: "Content:LoadError",
-          tabID: tab.id,
+          tabID: tab.id
         };
         GlobalEventDispatcher.sendRequest(message);
-        dump("Handled load error: " + e);
+        dump("Handled load error: " + e)
       }
     }
   },
 
   addTab: function addTab(aURI, aParams) {
     aParams = aParams || {};
 
     let fullscreenState;
@@ -1251,17 +1251,17 @@ var BrowserApp = {
   closeTab: function closeTab(aTab) {
     if (!aTab) {
       Cu.reportError("Error trying to close tab (tab doesn't exist)");
       return;
     }
 
     let message = {
       type: "Tab:Close",
-      tabID: aTab.id,
+      tabID: aTab.id
     };
     GlobalEventDispatcher.sendRequest(message);
   },
 
   // Calling this will update the state in BrowserApp after a tab has been
   // closed in the Java UI.
   _handleTabClosed: function _handleTabClosed(aTab, aShowUndoSnackbar) {
     if (aTab == this.selectedTab)
@@ -1292,18 +1292,18 @@ var BrowserApp = {
         }
 
         Snackbars.show(message, Snackbars.LENGTH_LONG, {
           action: {
             label: Strings.browser.GetStringFromName("undoCloseToast.action2"),
             callback: function() {
               UITelemetry.addEvent("undo.1", "toast", null, "closetab");
               ss.undoCloseTab(window, closedTabData);
-            },
-          },
+            }
+          }
         });
       }
     }
 
     // Retrieve updated tabIndex again for the removal because the index could
     // be changed if a new tab is added by the event listener.
     tabIndex = this._tabs.indexOf(aTab);
     aTab.destroy();
@@ -1320,17 +1320,17 @@ var BrowserApp = {
     }
 
     let step = (fromPosition < toPosition) ? 1 : -1;
     for (let i = fromPosition; i != toPosition; i += step) {
       this._tabs[i] = this._tabs[i + step];
     }
     this._tabs[toPosition] = movedTab;
 
-    let evt = new UIEvent("TabMove", {"bubbles": true, "cancelable": false, "view": window, "detail": fromPosition});
+    let evt = new UIEvent("TabMove", {"bubbles":true, "cancelable":false, "view":window, "detail":fromPosition});
     this.tabs[toPosition].browser.dispatchEvent(evt);
   },
 
   // Use this method to select a tab from JS. This method sends a message
   // to Java to select the tab in the Java UI (we'll get a Tab:Selected message
   // back from Java when that happens).
   selectTab: function selectTab(aTab) {
     if (!aTab) {
@@ -1348,17 +1348,17 @@ var BrowserApp = {
       // remember the new tab for this.
       this.fullscreenTransitionTab = aTab;
       doc.exitFullscreen();
       return;
     }
 
     let message = {
       type: "Tab:Select",
-      tabID: aTab.id,
+      tabID: aTab.id
     };
     GlobalEventDispatcher.sendRequest(message);
   },
 
   /**
    * Gets an open tab with the given URL.
    *
    * @param  aURL URL to look for
@@ -1372,19 +1372,21 @@ var BrowserApp = {
     aOptions = aOptions || {};
     let uri = Services.io.newURI(aURL);
     for (let i = 0; i < this._tabs.length; ++i) {
       let tab = this._tabs[i];
       if (aOptions.startsWith) {
         if (tab.currentURI.spec.startsWith(uri.spec)) {
           return tab;
         }
-      } else if (tab.currentURI.equals(uri)) {
+      } else {
+        if (tab.currentURI.equals(uri)) {
           return tab;
         }
+      }
     }
     return null;
   },
 
   /**
    * If a tab with the given URL already exists, that tab is selected.
    * Otherwise, a new tab is opened with the given URL.
    *
@@ -1413,17 +1415,17 @@ var BrowserApp = {
    * @param {string} addonId
    */
   openAddonManager: function openAddonManager({addonId}) {
     if (addonId) {
       let emWindow;
 
       function receivePong(subject, topic, data) {
         emWindow = subject;
-      }
+      };
 
       Services.obs.addObserver(receivePong, "EM-pong");
       Services.obs.notifyObservers(null, "EM-ping");
       Services.obs.removeObserver(receivePong, "EM-pong");
 
       if (emWindow) {
         // "about:addons" has been already loaded in a tab.
         emWindow.showAddonDetails(addonId);
@@ -1469,17 +1471,17 @@ var BrowserApp = {
     // `viewSourceInBrowser` will load the source content from the page
     // descriptor for the tab (when possible) or fallback to the network if
     // that fails.  Either way, the view source module will manage the tab's
     // location, so use "about:blank" here to avoid unnecessary redundant
     // requests.
     let tab = this.addTab("about:blank", {
       selected: true,
       parentId: aTab.id,
-      isPrivate: PrivateBrowsingUtils.isBrowserPrivate(aTab.browser),
+      isPrivate: PrivateBrowsingUtils.isBrowserPrivate(aTab.browser)
     });
     args.viewSourceBrowser = tab.browser;
 
     gViewSourceUtils.viewSourceInBrowser(args);
   },
 
   quit: function quit(aClear = { sanitize: {}, dontSaveSession: false }) {
     // Notify all windows that an application quit has been requested.
@@ -1495,17 +1497,17 @@ var BrowserApp = {
 
     // Tell session store to forget about this window
     if (aClear.dontSaveSession) {
       let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
       ss.removeWindow(window);
     }
 
     BrowserApp.sanitize(aClear.sanitize, function() {
-      let appStartup = Services.startup;
+      let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
       appStartup.quit(Ci.nsIAppStartup.eForceQuit);
     }, true);
   },
 
   saveAsPDF: function saveAsPDF(aBrowser) {
     RuntimePermissions.waitForPermissions(RuntimePermissions.WRITE_EXTERNAL_STORAGE).then(function(permissionGranted) {
       if (!permissionGranted) {
         return;
@@ -1551,17 +1553,17 @@ var BrowserApp = {
       return this.PREF_TRACKING_PROTECTION_ENABLED;
     }
     if (Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled")) {
       return this.PREF_TRACKING_PROTECTION_ENABLED_PB;
     }
     return this.PREF_TRACKING_PROTECTION_DISABLED;
   },
 
-  sanitize: function(aItems, callback, aShutdown) {
+  sanitize: function (aItems, callback, aShutdown) {
     let success = true;
     var promises = [];
     let refObj = {};
 
     if (aShutdown && Object.getOwnPropertyNames(aItems).length > 0) {
       let msg = Strings.browser.GetStringFromName("alertShutdownSanitize");
       Snackbars.show(msg, Snackbars.LENGTH_INDEFINITE);
     }
@@ -1597,35 +1599,35 @@ var BrowserApp = {
       }
     }
 
     Promise.all(promises).then(function() {
       TelemetryStopwatch.finish("FX_SANITIZE_TOTAL", refObj);
       GlobalEventDispatcher.sendRequest({
         type: "Sanitize:Finished",
         success: true,
-        shutdown: aShutdown === true,
+        shutdown: aShutdown === true
       });
 
       if (callback) {
         callback();
       }
     }).catch(function(err) {
       TelemetryStopwatch.finish("FX_SANITIZE_TOTAL", refObj);
       GlobalEventDispatcher.sendRequest({
         type: "Sanitize:Finished",
         error: err,
         success: false,
-        shutdown: aShutdown === true,
+        shutdown: aShutdown === true
       });
 
       if (callback) {
         callback();
       }
-    });
+    })
   },
 
   getFocusedInput: function(aBrowser, aOnlyInputElements = false) {
     if (!aBrowser)
       return null;
 
     let doc = aBrowser.contentDocument;
     if (!doc)
@@ -1641,16 +1643,17 @@ var BrowserApp = {
         (focused.mozIsTextField(false) || focused.type === "number")) {
       return focused;
     }
 
     if (aOnlyInputElements)
       return null;
 
     if (focused && (focused instanceof HTMLTextAreaElement || focused.isContentEditable)) {
+
       if (focused instanceof HTMLBodyElement) {
         // we are putting focus into a contentEditable frame. scroll the frame into
         // view instead of the contentEditable document contained within, because that
         // results in a better user experience
         focused = focused.ownerGlobal.frameElement;
       }
       return focused;
     }
@@ -1698,37 +1701,36 @@ var BrowserApp = {
     setTimeout(function(e) {
       aBrowser.contentWindow.removeEventListener("resize", onResize);
       if (!gotResize) {
         onResize();
       }
     }, 500);
   },
 
-  getUALocalePref: function() {
+  getUALocalePref: function () {
     return Services.locale.requestedLocale || undefined;
   },
 
-  getOSLocalePref: function() {
+  getOSLocalePref: function () {
     try {
       return Services.prefs.getCharPref("intl.locale.os");
     } catch (e) {
       return undefined;
     }
   },
 
-  setLocalizedPref: function(pref, value) {
+  setLocalizedPref: function (pref, value) {
     let pls = Cc["@mozilla.org/pref-localizedstring;1"]
                 .createInstance(Ci.nsIPrefLocalizedString);
     pls.data = value;
     Services.prefs.setComplexValue(pref, Ci.nsIPrefLocalizedString, pls);
   },
 
-  // eslint-disable-next-line complexity
-  onEvent: function(event, data, callback) {
+  onEvent: function (event, data, callback) {
     let browser = this.selectedBrowser;
 
     switch (event) {
       case "Browser:LoadManifest": {
         installManifest(browser, data);
         break;
       }
 
@@ -1788,17 +1790,22 @@ var BrowserApp = {
         }
 
         console.log("Gecko display locale: " + this.getUALocalePref());
 
         // Rebuild strings to reflect the new locale.
         Strings.flush();
 
         // Make sure we use the right Accept-Language header.
-        let osLocale = Services.prefs.getCharPref("intl.locale.os");
+        let osLocale;
+        try {
+          // This should never not be set at this point, but better safe than sorry.
+          osLocale = Services.prefs.getCharPref("intl.locale.os");
+        } catch (e) {
+        }
 
         this.computeAcceptLanguages(osLocale, data && data.languageTag);
         break;
       }
 
       case "Passwords:Init": {
         let storage = Cc["@mozilla.org/login-manager/storage/mozStorage;1"].
                       getService(Ci.nsILoginManagerStorage);
@@ -1882,17 +1889,16 @@ var BrowserApp = {
               } else {
                 Services.perms.add(normalizedUrl, "trackingprotection", Services.perms.ALLOW_ACTION);
                 Telemetry.addData("TRACKING_PROTECTION_EVENTS", 1);
               }
             } else {
               // Remove the current host from the 'trackingprotection' consumer
               // of the permission manager. This effectively removes this host
               // from the tracking protection white list (any list actually).
-              // eslint-disable-next-line no-lonely-if
               if (PrivateBrowsingUtils.isBrowserPrivate(browser)) {
                 PrivateBrowsingUtils.removeFromTrackingAllowlist(normalizedUrl);
               } else {
                 Services.perms.remove(normalizedUrl, "trackingprotection");
                 Telemetry.addData("TRACKING_PROTECTION_EVENTS", 2);
               }
             }
           }
@@ -1934,17 +1940,17 @@ var BrowserApp = {
         let params = {
           selected: ("selected" in data) ? data.selected : !delayLoad,
           parentId: ("parentId" in data) ? data.parentId : -1,
           flags: flags,
           tabID: data.tabID,
           isPrivate: (data.isPrivate === true),
           pinned: (data.pinned === true),
           delayLoad: (delayLoad === true),
-          desktopMode: (data.desktopMode === true),
+          desktopMode: (data.desktopMode === true)
         };
 
         params.userRequested = url;
 
         if (data.referrerURI) {
           try {
             params.referrerURI = Services.io.newURI(data.referrerURI);
           } catch (e) {
@@ -2018,17 +2024,17 @@ var BrowserApp = {
         let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(this.selectedTab.browser);
         let query = isPrivate ? "" : aData;
 
         let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
         GlobalEventDispatcher.sendRequest({
           type: "Search:Keyword",
           identifier: engine.identifier,
           name: engine.name,
-          query: query,
+          query: query
         });
         break;
 
       case "android-get-pref": {
         // These pref names are not "real" pref names. They are used in the
         // setting menu, and these are passed when initializing the setting
         // menu. aSubject is a nsIWritableVariant to hold the pref value.
         aSubject.QueryInterface(Ci.nsIWritableVariant);
@@ -2116,36 +2122,37 @@ var BrowserApp = {
       case "Vibration:Request":
         if (aSubject instanceof Navigator) {
           let navigator = aSubject;
           let buttons = [
             {
               label: Strings.browser.GetStringFromName("vibrationRequest.denyButton"),
               callback: function() {
                 navigator.setVibrationPermission(false);
-              },
+              }
             },
             {
               label: Strings.browser.GetStringFromName("vibrationRequest.allowButton"),
               callback: function() {
                 navigator.setVibrationPermission(true);
               },
-              positive: true,
-            },
+              positive: true
+            }
           ];
           let message = Strings.browser.GetStringFromName("vibrationRequest.message");
           let options = {};
           NativeWindow.doorhanger.show(message, "vibration-request", buttons,
               BrowserApp.selectedTab.id, options, "VIBRATION");
         }
         break;
 
       default:
         dump('BrowserApp.observe: unexpected topic "' + aTopic + '"\n');
         break;
+
     }
   },
 
   /**
    * Set intl.accept_languages accordingly.
    *
    * After Bug 881510 this will also accept a real Accept-Language choice as
    * input; all Accept-Language logic lives here.
@@ -2240,17 +2247,17 @@ var BrowserApp = {
     if (action == "BACK" && canGoBack) {
       fromIndex = Math.max(historyIndex - kMaxHistoryListSize, 0);
       toIndex = historyIndex;
       selIndex = historyIndex;
     } else if (action == "FORWARD" && canGoForward) {
       fromIndex = historyIndex;
       toIndex = Math.min(historySize - 1, historyIndex + kMaxHistoryListSize);
       selIndex = historyIndex;
-    } else if (action == "ALL" && (canGoBack || canGoForward)) {
+    } else if (action == "ALL" && (canGoBack || canGoForward)){
       fromIndex = historyIndex - kMaxHistoryListSize / 2;
       toIndex = historyIndex + kMaxHistoryListSize / 2;
       if (fromIndex < 0) {
         toIndex -= fromIndex;
       }
 
       if (toIndex > historySize - 1) {
         fromIndex -= toIndex - (historySize - 1);
@@ -2258,35 +2265,35 @@ var BrowserApp = {
       }
 
       fromIndex = Math.max(fromIndex, 0);
       selIndex = historyIndex;
     } else {
       // return empty list immediately.
       return {
         "historyItems": listitems,
-        "toIndex": toIndex,
+        "toIndex": toIndex
       };
     }
 
     let browser = this.selectedBrowser;
     let hist = browser.sessionHistory.legacySHistory;
     for (let i = toIndex; i >= fromIndex; i--) {
       let entry = hist.getEntryAtIndex(i);
       let item = {
         title: entry.title || entry.URI.displaySpec,
         url: entry.URI.displaySpec,
-        selected: (i == selIndex),
+        selected: (i == selIndex)
       };
       listitems.push(item);
     }
 
     return {
       "historyItems": listitems,
-      "toIndex": toIndex,
+      "toIndex": toIndex
     };
   },
 };
 
 async function notifyManifestStatus(tab) {
   try {
     const manifest = await Manifests.getManifest(tab.browser);
     const evtType = (manifest && manifest.installed) ?
@@ -2307,25 +2314,25 @@ async function installManifest(browser, 
     await manifest.install();
     const icon = await manifest.icon(data.iconSize);
     GlobalEventDispatcher.sendRequest({
       type: "Website:AppInstalled",
       icon,
       name: manifest.name,
       start_url: manifest.start_url,
       manifest_path: manifest.path,
-      manifest_url: manifest.url,
+      manifest_url: manifest.url
     });
   } catch (err) {
     Cu.reportError("Failed to install: " + err.message);
     // If we fail to install via the manifest, we will fall back to a standard bookmark
     GlobalEventDispatcher.sendRequest({
       type: "Website:AppInstallFailed",
       url: data.originalUrl,
-      title: data.originalTitle,
+      title: data.originalTitle
     });
   }
 }
 
 var NativeWindow = {
   init: function() {
     GlobalEventDispatcher.registerListener(this, [
       "Doorhanger:Reply",
@@ -2341,17 +2348,17 @@ var NativeWindow = {
     add: function() {
       let options;
       if (arguments.length == 1) {
         options = arguments[0];
       } else if (arguments.length == 3) {
           Log.w("Browser", "This menu addon API has been deprecated. Instead, use the options object API.");
           options = {
             name: arguments[0],
-            callback: arguments[2],
+            callback: arguments[2]
           };
       } else {
          throw "Incorrect number of parameters";
       }
 
       options.type = "Menu:Add";
       options.uuid = uuidgen.generateUUID().toString();
 
@@ -2366,19 +2373,19 @@ var NativeWindow = {
 
     update: function(aUuid, aOptions) {
       if (!aOptions)
         return;
 
       GlobalEventDispatcher.sendRequest({
         type: "Menu:Update",
         uuid: aUuid,
-        options: aOptions,
+        options: aOptions
       });
-    },
+    }
   },
 
   doorhanger: {
     _callbacks: {},
     _callbacksId: 0,
     _promptId: 0,
 
   /**
@@ -2451,29 +2458,29 @@ var NativeWindow = {
       };
       WindowEventDispatcher.sendRequest(json);
     },
 
     hide: function(aValue, aTabID) {
       WindowEventDispatcher.sendRequest({
         type: "Doorhanger:Remove",
         value: aValue,
-        tabID: aTabID,
+        tabID: aTabID
       });
-    },
-  },
-
-  onEvent: function(event, data, callback) {
+    }
+  },
+
+  onEvent: function (event, data, callback) {
     if (event == "Doorhanger:Reply") {
-      let reply_id = data.callback;
+      let reply_id = data["callback"];
 
       if (this.doorhanger._callbacks[reply_id]) {
         // Pass the value of the optional checkbox to the callback
         if (this.doorhanger._callbacks[reply_id].cb) {
-          let checked = data.checked;
+          let checked = data["checked"];
           this.doorhanger._callbacks[reply_id].cb(checked, data.inputs);
         }
 
         let prompt = this.doorhanger._callbacks[reply_id].prompt;
         for (let id in this.doorhanger._callbacks) {
           if (this.doorhanger._callbacks[id].prompt == prompt) {
             delete this.doorhanger._callbacks[id];
           }
@@ -2497,19 +2504,19 @@ var NativeWindow = {
     },
 
     add: function() {
       let args;
       if (arguments.length == 1) {
         args = arguments[0];
       } else if (arguments.length == 3) {
         args = {
-          label: arguments[0],
+          label : arguments[0],
           selector: arguments[1],
-          callback: arguments[2],
+          callback: arguments[2]
         };
       } else {
         throw "Incorrect number of parameters";
       }
 
       if (!args.label)
         throw "Menu items must have a name";
 
@@ -2525,129 +2532,129 @@ var NativeWindow = {
     // Although we do not use this ourselves anymore, add-ons may still
     // need it as it has been documented, so we shouldn't remove it.
     SelectorContext: function(aSelector) {
       return {
         matches: function(aElt) {
           if (aElt.matches)
             return aElt.matches(aSelector);
           return false;
-        },
+        }
       };
     },
 
     linkOpenableNonPrivateContext: {
       matches: function linkOpenableNonPrivateContextMatches(aElement) {
         let doc = aElement.ownerDocument;
         if (!doc || PrivateBrowsingUtils.isContentWindowPrivate(doc.defaultView)) {
           return false;
         }
 
         return NativeWindow.contextmenus.linkOpenableContext.matches(aElement);
-      },
+      }
     },
 
     linkOpenableContext: {
       matches: function linkOpenableContextMatches(aElement) {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri) {
           let scheme = uri.scheme;
           let dontOpen = /^(javascript|mailto|news|snews|tel)$/;
           return (scheme && !dontOpen.test(scheme));
         }
         return false;
-      },
+      }
     },
 
     linkCopyableContext: {
       matches: function linkCopyableContextMatches(aElement) {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri) {
           let scheme = uri.scheme;
           let dontCopy = /^(mailto|tel)$/;
           return (scheme && !dontCopy.test(scheme));
         }
         return false;
-      },
+      }
     },
 
     linkShareableContext: {
       matches: function linkShareableContextMatches(aElement) {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri) {
           let scheme = uri.scheme;
           let dontShare = /^(about|chrome|file|javascript|mailto|resource|tel)$/;
           return (scheme && !dontShare.test(scheme));
         }
         return false;
-      },
+      }
     },
 
     linkBookmarkableContext: {
       matches: function linkBookmarkableContextMatches(aElement) {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri) {
           let scheme = uri.scheme;
           let dontBookmark = /^(mailto|tel)$/;
           return (scheme && !dontBookmark.test(scheme));
         }
         return false;
-      },
+      }
     },
 
     emailLinkContext: {
       matches: function emailLinkContextMatches(aElement) {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri)
           return uri.schemeIs("mailto");
         return false;
-      },
+      }
     },
 
     phoneNumberLinkContext: {
       matches: function phoneNumberLinkContextMatches(aElement) {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri)
           return uri.schemeIs("tel");
         return false;
-      },
+      }
     },
 
     imageLocationCopyableContext: {
       matches: function imageLinkCopyableContextMatches(aElement) {
         if (ChromeUtils.getClassName(aElement) === "HTMLImageElement") {
           // The image is blocked by Tap-to-load Images
           if (aElement.hasAttribute("data-ctv-src") && !aElement.hasAttribute("data-ctv-show")) {
             return false;
           }
         }
         return (aElement instanceof Ci.nsIImageLoadingContent && aElement.currentURI);
-      },
+      }
     },
 
     imageSaveableContext: {
       matches: function imageSaveableContextMatches(aElement) {
         if (ChromeUtils.getClassName(aElement) === "HTMLImageElement") {
           // The image is blocked by Tap-to-load Images
           if (aElement.hasAttribute("data-ctv-src") && !aElement.hasAttribute("data-ctv-show")) {
             return false;
           }
         }
         if (aElement instanceof Ci.nsIImageLoadingContent && aElement.currentURI) {
           // The image must be loaded to allow saving
           let request = aElement.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
           return (request && (request.imageStatus & request.STATUS_SIZE_AVAILABLE));
         }
         return false;
-      },
+      }
     },
 
     imageShareableContext: {
       matches: aElement => {
-        let imgSrc = "";
+        let imgSrc = '';
         if (ChromeUtils.getClassName(aElement) === "HTMLImageElement") {
           imgSrc = aElement.src;
         } else if (aElement instanceof Ci.nsIImageLoadingContent &&
             aElement.currentURI &&
             aElement.currentURI.spec) {
           imgSrc = aElement.currentURI.spec;
         }
 
@@ -2656,38 +2663,38 @@ var NativeWindow = {
         // (shared by all transactions in progress) - otherwise we crash! (bug 1243305)
         //   https://developer.android.com/reference/android/os/TransactionTooLargeException.html
         //
         // The transaction limit is 1MB and we arbitrarily choose to cap this transaction at 1/4 of that = 250,000 bytes.
         // In Java, a UTF-8 character is 1-4 bytes so, 250,000 bytes / 4 bytes/char = 62,500 char
         let MAX_IMG_SRC_LEN = 62500;
         let isTooLong = imgSrc.length >= MAX_IMG_SRC_LEN;
         return !isTooLong && this.NativeWindow.contextmenus.imageSaveableContext.matches(aElement);
-      },
+      }
     },
 
     mediaSaveableContext: {
       matches: function mediaSaveableContextMatches(aElement) {
         return (aElement instanceof HTMLVideoElement ||
                aElement instanceof HTMLAudioElement);
-      },
+      }
     },
 
     imageBlockingPolicyContext: {
       matches: function imageBlockingPolicyContextMatches(aElement) {
         if (ChromeUtils.getClassName(aElement) === "HTMLImageElement" &&
             aElement.getAttribute("data-ctv-src")) {
           // Only show the menuitem if we are blocking the image
           if (aElement.getAttribute("data-ctv-show") == "true") {
             return false;
           }
           return true;
         }
         return false;
-      },
+      }
     },
 
     mediaContext: function(aMode) {
       return {
         matches: function(aElt) {
           if (ChromeUtils.getClassName(aElt) === "HTMLVideoElement" ||
               ChromeUtils.getClassName(aElt) === "HTMLAudioElement") {
             let hasError = aElt.error != null || aElt.networkState == aElt.NETWORK_NO_SOURCE;
@@ -2705,17 +2712,17 @@ var NativeWindow = {
 
             let muted = aElt.muted;
             if (muted && aMode == "media-muted")
               return true;
             else if (!muted && aMode == "media-unmuted")
               return true;
           }
           return false;
-        },
+        }
       };
     },
 
     videoContext: function(aMode) {
       return {
         matches: function(aElt) {
           if (aElt instanceof HTMLVideoElement) {
             if (!aMode) {
@@ -2725,17 +2732,17 @@ var NativeWindow = {
             if (aMode == "not-fullscreen") {
               return !isFullscreen;
             }
             if (aMode == "fullscreen") {
               return isFullscreen;
             }
           }
           return false;
-        },
+        }
       };
     },
 
     /* Holds a WeakRef to the original target element this context menu was shown for.
      * Most API's will have to walk up the tree from this node to find the correct element
      * to act on
      */
     get _target() {
@@ -2839,26 +2846,26 @@ var NativeWindow = {
      * is an image inside an <a> tag, we may have a "link" context and an "image" one.
      */
     _getContextType: function(element) {
       // For anchor nodes, we try to use the scheme to pick a string
       if (ChromeUtils.getClassName(element) === "HTMLAnchorElement") {
         try {
           let uri = this.makeURI(this._getLinkURL(element));
           return Strings.browser.GetStringFromName("browser.menu.context." + uri.scheme);
-        } catch (ex) {
+        } catch(ex) {
           // Fallback to the default
           return this.defaultContext;
         }
       }
 
       // Otherwise we try the nodeName
       try {
         return Strings.browser.GetStringFromName("browser.menu.context." + element.nodeName.toLowerCase());
-      } catch (ex) { }
+      } catch(ex) { }
 
       return this.nonLinkContext;
     },
 
     // Adds context menu items added through the add-on api
     _getNativeContextMenuItems: function(element, x, y) {
       let res = [];
       for (let itemId of Object.keys(this.items)) {
@@ -2944,17 +2951,17 @@ var NativeWindow = {
         if (originalURL) {
           return originalURL;
         }
         return node.currentURI.displaySpec;
       } else if (ChromeUtils.getClassName(node) === "HTMLVideoElement" ||
                  ChromeUtils.getClassName(node) === "HTMLAudioElement") {
         let srcUrl = node.currentSrc || node.src;
         // If URL prepended with blob or mediasource, we'll remove it.
-        return srcUrl.replace(/^(?:blob|mediasource):/, "");
+        return srcUrl.replace(/^(?:blob|mediasource):/, '');
       }
 
       return "";
     },
 
     // Adds an array of menuitems to the current list of items to show, in the correct context
     _addMenuItems: function(items, context) {
         if (!this.menus[context]) {
@@ -3017,17 +3024,17 @@ var NativeWindow = {
         // walk up the tree and find more items to show
         element = element.parentNode;
       }
     },
 
     // Walks the DOM tree to find a title from a node
     _findTitle: function(node) {
       let title = "";
-      while (node && !title) {
+      while(node && !title) {
         title = this._getTitle(node);
         node = node.parentNode;
       }
       return title;
     },
 
     /* Reformats the list of menus to show into an object that can be sent to Prompt.jsm
      * If there is one menu, will return a flat array of menuitems. If there are multiple
@@ -3069,33 +3076,33 @@ var NativeWindow = {
           return 1;
         }
         return 0;
       });
 
       contexts.forEach(context => {
         itemArray.push({
           label: context,
-          items: this._reformatMenuItems(target, menus[context]),
+          items: this._reformatMenuItems(target, menus[context])
         });
       });
 
       return itemArray;
     },
 
     /* Reformats an array of ContextMenuItems into an array that can be handled by Prompt.jsm. Also reformats items
      * and resolves any parmaeters that aren't known until display time
      * (for instance Helper app menu items adjust their title to reflect what Helper App can be used for this link).
      */
     _reformatMenuItems: function(target, menuitems) {
       let itemArray = [];
 
       for (let i = 0; i < menuitems.length; i++) {
         let t = target;
-        while (t) {
+        while(t) {
           if (menuitems[i].matches(t)) {
             let val = menuitems[i].getValue(t);
 
             // hidden menu items will return null from getValue
             if (val) {
               itemArray.push(val);
               break;
             }
@@ -3112,35 +3119,35 @@ var NativeWindow = {
     _innerShow: function(target, x, y) {
       Haptic.performSimpleAction(Haptic.LongPress);
 
       // spin through the tree looking for a title for this context menu
       let title = this._findTitle(target);
 
       for (let context in this.menus) {
         let menu = this.menus[context];
-        menu.sort((a, b) => {
+        menu.sort((a,b) => {
           if (a.order === b.order) {
             return 0;
           }
           return (a.order > b.order) ? 1 : -1;
         });
       }
 
       let useTabs = Object.keys(this.menus).length > 1;
       let prompt = new Prompt({
         window: target.ownerGlobal,
-        title: useTabs ? undefined : title,
+        title: useTabs ? undefined : title
       });
 
       let items = this._reformatList(target);
       if (useTabs) {
         prompt.addTabs({
           id: "tabs",
-          items: items,
+          items: items
         });
       } else {
         prompt.setSingleChoiceItems(items);
       }
 
       prompt.show(this._promptDone.bind(this, target, x, y, items));
     },
 
@@ -3151,17 +3158,17 @@ var NativeWindow = {
         return;
       }
 
       let selectedItemId;
       if (data.tabs) {
         let menu = items[data.tabs.tab];
         selectedItemId = menu.items[data.tabs.item].id;
       } else {
-        selectedItemId = items[data.list[0]].id;
+        selectedItemId = items[data.list[0]].id
       }
 
       let selectedItem = this._findMenuItem(selectedItemId);
       this.menus = null;
 
       if (!selectedItem || !selectedItem.matches || !selectedItem.callback) {
         return;
       }
@@ -3203,17 +3210,17 @@ var NativeWindow = {
     _disableRestricted: function _disableRestricted(restriction, selector) {
       return {
         matches: function _disableRestrictedMatches(aElement, aX, aY) {
           if (!ParentalControls.isAllowed(ParentalControls[restriction])) {
             return false;
           }
 
           return selector.matches(aElement, aX, aY);
-        },
+        }
       };
     },
 
     _getLinkURL: function ch_getLinkURL(aLink) {
       let href = aLink.href;
       if (href) {
         return this.makeURI(href).displaySpec;
       }
@@ -3238,27 +3245,27 @@ var NativeWindow = {
     _stripScheme: function(aString) {
       let index = aString.indexOf(":");
       return aString.slice(index + 1);
     },
 
     _stripViewSource: function(aString) {
       // If we're in a view source tab, remove the view-source: prefix
       return aString.replace(/^view-source:/, "");
-    },
-  },
+    }
+  }
 };
 
 ChromeUtils.defineModuleGetter(this, "PageActions",
                                "resource://gre/modules/PageActions.jsm");
 
 // These alias to the old, deprecated NativeWindow interfaces
 [
   ["pageactions", "resource://gre/modules/PageActions.jsm", "PageActions"],
-  ["toast", "resource://gre/modules/Snackbars.jsm", "Snackbars"],
+  ["toast", "resource://gre/modules/Snackbars.jsm", "Snackbars"]
 ].forEach(item => {
   let [name, script, exprt] = item;
 
   XPCOMUtils.defineLazyGetter(NativeWindow, name, () => {
     var err = Strings.browser.formatStringFromName("nativeWindow.deprecated", ["NativeWindow." + name, script], 2);
     Cu.reportError(err);
 
     let sandbox = {};
@@ -3279,17 +3286,17 @@ var LightWeightThemeWebInstaller = {
     if (ParentalControls.parentalControlsEnabled &&
         !this._manager.currentTheme &&
         ParentalControls.isAllowed(ParentalControls.DEFAULT_THEME)) {
       // We are using the DEFAULT_THEME restriction to differentiate between restricted profiles & guest mode - Bug 1199596
       this._installParentalControlsTheme();
     }
   },
 
-  handleEvent: function(event) {
+  handleEvent: function (event) {
     switch (event.type) {
       case "InstallBrowserTheme":
       case "PreviewBrowserTheme":
       case "ResetBrowserThemePreview":
         // ignore requests from background tabs
         if (event.target.ownerGlobal.top != content)
           return;
     }
@@ -3306,109 +3313,109 @@ var LightWeightThemeWebInstaller = {
         break;
       case "pagehide":
       case "TabSelect":
         this._resetPreview();
         break;
     }
   },
 
-  get _manager() {
+  get _manager () {
     let temp = {};
     ChromeUtils.import("resource://gre/modules/LightweightThemeManager.jsm", temp);
     delete this._manager;
     return this._manager = temp.LightweightThemeManager;
   },
 
   _installParentalControlsTheme: function() {
     let mgr = this._manager;
     let parentalControlsTheme = {
       "headerURL": "resource://android/assets/parental_controls_theme.png",
       "name": "Parental Controls Theme",
-      "id": "parental-controls-theme@mozilla.org",
+      "id": "parental-controls-theme@mozilla.org"
     };
 
     mgr.addBuiltInTheme(parentalControlsTheme);
     mgr.themeChanged(parentalControlsTheme);
   },
 
-  _installRequest: function(event) {
+  _installRequest: function (event) {
     let node = event.target;
     let data = this._getThemeFromNode(node);
     if (!data)
       return;
 
     if (this._isAllowed(node)) {
       this._install(data);
       return;
     }
 
     let allowButtonText = Strings.browser.GetStringFromName("lwthemeInstallRequest.allowButton");
     let IDNService = Cc["@mozilla.org/network/idn-service;1"].getService(Ci.nsIIDNService);
     let hostname = IDNService.convertToDisplayIDN(node.ownerDocument.location.hostname, {});
     let message = Strings.browser.formatStringFromName("lwthemeInstallRequest.message", [hostname], 1);
     let buttons = [{
       label: allowButtonText,
-      callback: function() {
+      callback: function () {
         LightWeightThemeWebInstaller._install(data);
       },
-      positive: true,
+      positive: true
     }];
 
     NativeWindow.doorhanger.show(message, "Personas", buttons, BrowserApp.selectedTab.id);
   },
 
-  _install: function(newLWTheme) {
+  _install: function (newLWTheme) {
     this._manager.currentTheme = newLWTheme;
   },
 
   _previewWindow: null,
-  _preview: function(event) {
+  _preview: function (event) {
     if (!this._isAllowed(event.target))
       return;
     let data = this._getThemeFromNode(event.target);
     if (!data)
       return;
     this._resetPreview();
 
     this._previewWindow = event.target.ownerGlobal;
     this._previewWindow.addEventListener("pagehide", this, true);
     BrowserApp.deck.addEventListener("TabSelect", this);
     this._manager.previewTheme(data);
   },
 
-  _resetPreview: function(event) {
+  _resetPreview: function (event) {
     if (!this._previewWindow ||
         event && !this._isAllowed(event.target))
       return;
 
     this._previewWindow.removeEventListener("pagehide", this, true);
     this._previewWindow = null;
     BrowserApp.deck.removeEventListener("TabSelect", this);
 
     this._manager.resetPreview();
   },
 
-  _isAllowed: function(node) {
+  _isAllowed: function (node) {
     // Make sure the whitelist has been imported to permissions
     PermissionsUtils.importFromPrefs("xpinstall.", "install");
 
     let pm = Services.perms;
 
     let uri = node.ownerDocument.documentURIObject;
     if (!uri.schemeIs("https")) {
       return false;
     }
 
     return pm.testPermission(uri, "install") == pm.ALLOW_ACTION;
   },
 
-  _getThemeFromNode: function(node) {
+  _getThemeFromNode: function (node) {
     return this._manager.parseTheme(node.getAttribute("data-browsertheme"), node.baseURI);
-  },
+  }
 };
 
 var DesktopUserAgent = {
   DESKTOP_UA: null,
   TCO_DOMAIN: "t.co",
   TCO_REPLACE: / Gecko.*/,
 
   init: function ua_init() {
@@ -3490,17 +3497,16 @@ var DesktopUserAgent = {
 
 
 function nsBrowserAccess() {
 }
 
 nsBrowserAccess.prototype = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsIBrowserDOMWindow]),
 
-  // eslint-disable-next-line complexity
   _getBrowser: function _getBrowser(aURI, aOpener, aWhere, aFlags, aTriggeringPrincipal) {
     let isExternal = !!(aFlags & Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
     if (isExternal && aURI && aURI.schemeIs("chrome"))
       return null;
 
     let loadflags = isExternal ?
                       Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :
                       Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
@@ -3514,17 +3520,17 @@ nsBrowserAccess.prototype = {
 
     Services.io.offline = false;
 
     let referrer;
     if (aOpener) {
       try {
         let location = aOpener.location;
         referrer = Services.io.newURI(location);
-      } catch (e) { }
+      } catch(e) { }
     }
 
     let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
     let pinned = false;
 
     if (aURI && aWhere == Ci.nsIBrowserDOMWindow.OPEN_SWITCHTAB) {
       pinned = true;
       let spec = aURI.displaySpec;
@@ -3694,17 +3700,16 @@ function getBaseDomain(aURI) {
         baseDomain = IDNService.convertACEtoUTF8(baseDomain);
       }
     } catch (e) {}
   }
   return baseDomain;
 }
 
 Tab.prototype = {
-  // eslint-disable-next-line complexity
   create: function(aURL, aParams) {
     if (this.browser)
       return;
 
     aParams = aParams || {};
 
     this.browser = document.createElement("browser");
     this.browser.setAttribute("type", "content");
@@ -3729,17 +3734,17 @@ Tab.prototype = {
 
     let attrs = {};
 
     // Must be called after appendChild so the docShell has been created.
     this.setActive(false);
 
     let isPrivate = ("isPrivate" in aParams) && aParams.isPrivate;
     if (isPrivate) {
-      attrs.privateBrowsingId = 1;
+      attrs['privateBrowsingId'] = 1;
     }
 
     this.browser.docShell.setOriginAttributes(attrs);
 
     // Set the new docShell load flags based on network state.
     if (Tabs.useCache) {
       this.browser.docShell.defaultLoadFlags |= Ci.nsIRequest.LOAD_FROM_CACHE;
     }
@@ -3784,28 +3789,28 @@ Tab.prototype = {
         external: ("external" in aParams) ? aParams.external : false,
         selected: ("selected" in aParams || aParams.cancelEditMode === true)
                   ? aParams.selected !== false || aParams.cancelEditMode === true : true,
         cancelEditMode: aParams.cancelEditMode === true,
         title: truncate(title, MAX_TITLE_LENGTH),
         delayLoad: aParams.delayLoad || false,
         desktopMode: this.desktopMode,
         isPrivate: isPrivate,
-        stub: stub,
+        stub: stub
       };
       GlobalEventDispatcher.sendRequest(message);
     }
     this.browser.contentWindow.windowUtils.setDesktopModeViewport(this.desktopMode);
 
     let flags = Ci.nsIWebProgress.NOTIFY_STATE_ALL |
                 Ci.nsIWebProgress.NOTIFY_LOCATION |
                 Ci.nsIWebProgress.NOTIFY_SECURITY |
                 Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING;
     this.filter = Cc["@mozilla.org/appshell/component/browser-status-filter;1"].createInstance(Ci.nsIWebProgress);
-    this.filter.addProgressListener(this, flags);
+    this.filter.addProgressListener(this, flags)
     this.browser.addProgressListener(this.filter, flags);
     this.browser.sessionHistory.legacySHistory.addSHistoryListener(this);
 
     this.browser.addEventListener("DOMContentLoaded", this, true);
     this.browser.addEventListener("DOMFormHasPassword", this, true);
     this.browser.addEventListener("DOMInputPasswordAdded", this, true);
     this.browser.addEventListener("DOMLinkAdded", this, true);
     this.browser.addEventListener("DOMLinkChanged", this, true);
@@ -3823,17 +3828,17 @@ Tab.prototype = {
     this.browser.addEventListener("focusin", this, true);
     this.browser.addEventListener("focusout", this, true);
     this.browser.addEventListener("TabSelect", this, true);
 
     // Note that the XBL binding is untrusted
     this.browser.addEventListener("VideoBindingAttached", this, true, true);
     this.browser.addEventListener("VideoBindingCast", this, true, true);
 
-    Services.obs.addObserver(this, "audioFocusChanged");
+    Services.obs.addObserver(this, "audioFocusChanged", false);
     Services.obs.addObserver(this, "before-first-paint");
     Services.obs.addObserver(this, "media-playback");
 
     XPCOMUtils.defineLazyGetter(this, "_autoFill", () =>
         new GeckoViewAutoFill(WindowEventDispatcher));
 
     // Always initialise new tabs with basic session store data to avoid
     // problems with functions that always expect it to be present
@@ -3844,17 +3849,17 @@ Tab.prototype = {
         url: uri,
         title: truncate(title, MAX_TITLE_LENGTH),
         triggeringPrincipal_base64,
       }],
       index: 1,
       desktopMode: this.desktopMode,
       isPrivate: isPrivate,
       tabId: this.id,
-      parentId: this.parentId,
+      parentId: this.parentId
     };
 
     let pinned = "pinned" in aParams ? aParams.pinned : false;
     if (pinned && uri) {
       let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
       ss.setTabValue(this, "appOrigin", uri);
     }
 
@@ -3880,43 +3885,43 @@ Tab.prototype = {
       try {
         this.browser.loadURI(aURL, {
           flags,
           referrerURI,
           charset,
           postData,
           triggeringPrincipal: aParams.triggeringPrincipal,
         });
-      } catch (e) {
+      } catch(e) {
         let message = {
           type: "Content:LoadError",
-          tabID: this.id,
+          tabID: this.id
         };
         GlobalEventDispatcher.sendRequest(message);
         dump("Handled load error: " + e);
       }
     }
   },
 
   /**
    * Reloads the tab with the desktop mode setting.
    */
-  reloadWithMode: function(aDesktopMode) {
+  reloadWithMode: function (aDesktopMode) {
     // notify desktopmode for PIDOMWindow
     let win = this.browser.contentWindow;
     let dwi = win.windowUtils;
     dwi.setDesktopModeViewport(aDesktopMode);
 
     // Set desktop mode for tab and send change to Java
     if (this.desktopMode != aDesktopMode) {
       this.desktopMode = aDesktopMode;
       GlobalEventDispatcher.sendRequest({
         type: "DesktopMode:Changed",
         desktopMode: aDesktopMode,
-        tabID: this.id,
+        tabID: this.id
       });
     }
 
     // Only reload the page for http/https schemes
     let currentURI = this.browser.currentURI;
     if (!currentURI.schemeIs("http") && !currentURI.schemeIs("https"))
       return;
 
@@ -4012,17 +4017,17 @@ Tab.prototype = {
    */
   zombify: function zombify() {
     let browser = this.browser;
     let data = browser.__SS_data;
     let extra = browser.__SS_extdata;
 
     // Notify any interested parties (e.g. the session store)
     // that the original tab object is going to be destroyed
-    let evt = new UIEvent("TabPreZombify", {"bubbles": true, "cancelable": false, "view": window});
+    let evt = new UIEvent("TabPreZombify", {"bubbles":true, "cancelable":false, "view":window});
     browser.dispatchEvent(evt);
 
     // We need this data to correctly create the new browser
     // If this browser is already a zombie, fallback to the session data
     let currentURL = browser.__SS_restore ? data.entries[0].url : browser.currentURI.spec;
     let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(browser);
 
     this.destroy();
@@ -4031,17 +4036,17 @@ Tab.prototype = {
     // Reattach session store data and flag this browser so it is restored on select
     browser = this.browser;
     browser.__SS_data = data;
     browser.__SS_extdata = extra;
     browser.__SS_restore = true;
     browser.setAttribute("pending", "true");
 
     // Notify the session store to reattach its listeners to the recreated tab object
-    evt = new UIEvent("TabPostZombify", {"bubbles": true, "cancelable": false, "view": window});
+    evt = new UIEvent("TabPostZombify", {"bubbles":true, "cancelable":false, "view":window});
     browser.dispatchEvent(evt);
   },
 
   /**
    * Restores the tab and reloads its contents if it is unloaded from memory and set for delay
    * loading ("zombified").
    */
   unzombify: function unzombify() {
@@ -4053,23 +4058,23 @@ Tab.prototype = {
   // we can collect data as we find meta tags, and replace low quality metadata with higher quality
   // matches. For instance a msApplicationTile icon is a better tile image than an og:image tag.
   METADATA_GOOD_MATCH: 10,
   METADATA_NORMAL_MATCH: 1,
 
   addMetadata: function(type, value, quality = 1) {
     if (!this.metatags) {
       this.metatags = {
-        url: this.browser.currentURI.specIgnoringRef,
+        url: this.browser.currentURI.specIgnoringRef
       };
     }
 
     if (type == "touchIconList") {
-      if (!this.metatags.touchIconList) {
-        this.metatags.touchIconList = {};
+      if (!this.metatags['touchIconList']) {
+        this.metatags['touchIconList'] = {};
       }
       this.metatags.touchIconList[quality] = value;
     } else if (!this.metatags[type] || this.metatags[type + "_quality"] < quality) {
       this.metatags[type] = value;
       this.metatags[type + "_quality"] = quality;
     }
   },
 
@@ -4108,54 +4113,54 @@ Tab.prototype = {
         });
       }
     }
     return {
       type: "Link:Favicon",
       tabID: this.id,
       href: resolveGeckoURI(eventTarget.href),
       size: maxSize,
-      mime: eventTarget.getAttribute("type") || "",
+      mime: eventTarget.getAttribute("type") || ""
     };
   },
 
   makeFeedMessage: function(eventTarget, targetType) {
     try {
       // urlSecurityCeck will throw if things are not OK
       ContentAreaUtils.urlSecurityCheck(eventTarget.href,
             eventTarget.ownerDocument.nodePrincipal,
             Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
 
       if (!this.browser.feeds)
         this.browser.feeds = [];
 
       this.browser.feeds.push({
         href: eventTarget.href,
         title: eventTarget.title,
-        type: targetType,
+        type: targetType
       });
 
       return {
         type: "Link:Feed",
-        tabID: this.id,
+        tabID: this.id
       };
     } catch (e) {
         return null;
     }
   },
 
   makeManifestMessage: async function(target) {
     try {
         const manifest = await Manifests.getManifest(this.browser, target.href);
         const data = await manifest.prefetch(this.browser);
         var cache = {
           type: "Link:Manifest",
           href: target.href,
           manifest: JSON.stringify(data),
-          tabID: this.id,
+          tabID: this.id
         };
         GlobalEventDispatcher.sendRequest(cache);
       } catch (err) {
         Log.e("Browser", "error when makeManifestMessage:" + err);
       }
   },
 
   sendOpenSearchMessage: async function(eventTarget) {
@@ -4188,75 +4193,77 @@ Tab.prototype = {
       }
 
       // Get favicon.
       let iconURL = eventTarget.ownerDocument.documentURIObject.prePath + "/favicon.ico";
 
       let newEngine = {
         title: eventTarget.title,
         url: eventTarget.href,
-        iconURL: iconURL,
+        iconURL: iconURL
       };
 
       this.browser.engines.push(newEngine);
 
       // Don't send a message to display engines if we've already handled an engine.
       if (this.browser.engines.length > 1)
         return null;
 
       // Broadcast message that this tab contains search engines that should be visible.
       GlobalEventDispatcher.sendRequest({
         type: "Link:OpenSearch",
         tabID: this.id,
-        visible: true,
+        visible: true
       });
     }
   },
 
   get parentId() {
     return this._parentId;
   },
 
   set parentId(aParentId) {
     let newParentId = (typeof aParentId == "number") ? aParentId : -1;
     this._parentId = newParentId;
     GlobalEventDispatcher.sendRequest({
       type: "Tab:SetParentId",
       tabID: this.id,
-      parentID: newParentId,
+      parentID: newParentId
     });
   },
 
   get currentURI() {
     if (!this.browser.__SS_restore) {
       return this.browser.currentURI;
-    }
+    } else {
       // For zombie tabs we need to fall back to the session store data.
       let data = this.browser.__SS_data;
       let url = data.entries[data.index - 1].url;
       return Services.io.newURI(url);
-  },
-
-  // eslint-disable-next-line complexity
+    }
+  },
+
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "DOMContentLoaded": {
         let target = aEvent.originalTarget;
 
         // ignore on frames and other documents
         if (target != this.browser.contentDocument)
           return;
 
         let docURI = target.documentURI;
         let errorType = "";
         if (docURI.startsWith("about:certerror")) {
           errorType = "certerror";
-        } else if (docURI.startsWith("about:blocked")) {
+        }
+        else if (docURI.startsWith("about:blocked")) {
           errorType = "blocked";
-        } else if (docURI.startsWith("about:neterror")) {
+        }
+        else if (docURI.startsWith("about:neterror")) {
           let error = docURI.search(/e\=/);
           let duffUrl = docURI.search(/\&u\=/);
           let errorExtra = decodeURIComponent(docURI.slice(error + 2, duffUrl));
           // Here is a list of errorExtra types (et_*)
           // http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/netError.xhtml#287
           if (errorExtra == "fileAccessDenied") {
             // Check if we already have the permissions, then - if we do not have them, show the prompt and reload the page.
             // If we already have them, it means access to file was denied.
@@ -4314,17 +4321,17 @@ Tab.prototype = {
         let hostname = aEvent.target.baseURIObject.displayPrePath;
         let foundLogins = Services.logins.findLogins({}, hostname, "", "");
         if (foundLogins.length > 0) {
           let displayHost = IdentityHandler.getEffectiveHost();
           let title = { text: displayHost, resource: hostname };
           let selectObj = { title: title, logins: foundLogins };
           GlobalEventDispatcher.sendRequest({
             type: "Doorhanger:Logins",
-            data: selectObj,
+            data: selectObj
           });
         }
 
         this._autoFill.addElement(
             FormLikeFactory.createFromForm(aEvent.composedTarget));
         break;
       }
 
@@ -4364,30 +4371,30 @@ Tab.prototype = {
 
         // Sanitize rel link
         let list = this.sanitizeRelString(target.rel);
         if (list.includes("[icon]")) {
           jsonMessage = this.makeFaviconMessage(target);
         } else if (list.includes("[apple-touch-icon]") ||
             list.includes("[apple-touch-icon-precomposed]")) {
           jsonMessage = this.makeFaviconMessage(target);
-          jsonMessage.type = "Link:Touchicon";
+          jsonMessage['type'] = 'Link:Touchicon';
           this.addMetadata("touchIconList", jsonMessage.href, jsonMessage.size);
         } else if (list.includes("[alternate]") && aEvent.type == "DOMLinkAdded") {
           let type = target.type.toLowerCase().replace(/^\s+|\s*(?:;.*)?$/g, "");
           let isFeed = (type == "application/rss+xml" || type == "application/atom+xml");
 
           if (!isFeed)
             return;
 
           jsonMessage = this.makeFeedMessage(target, type);
         } else if (list.includes("[search]") && aEvent.type == "DOMLinkAdded") {
           this.sendOpenSearchMessage(target);
         } else if (list.includes("[manifest]") &&
-                   aEvent.type == "DOMLinkAdded") {
+                   aEvent.type == "DOMLinkAdded"){
           this.makeManifestMessage(target);
           return;
         }
         if (!jsonMessage)
          return;
 
         GlobalEventDispatcher.sendRequest(jsonMessage);
         break;
@@ -4399,17 +4406,17 @@ Tab.prototype = {
 
         // ignore on frames and other documents
         if (aEvent.originalTarget != this.browser.contentDocument)
           return;
 
         GlobalEventDispatcher.sendRequest({
           type: "Content:DOMTitleChanged",
           tabID: this.id,
-          title: truncate(aEvent.target.title, MAX_TITLE_LENGTH),
+          title: truncate(aEvent.target.title, MAX_TITLE_LENGTH)
         });
         break;
       }
 
       case "TabPreZombify": {
         if (!this.playingAudio) {
           return;
         }
@@ -4428,32 +4435,32 @@ Tab.prototype = {
           return;
         }
 
         this.playingAudio = aEvent.type === "DOMAudioPlaybackStarted";
 
         GlobalEventDispatcher.sendRequest({
           type: "Tab:AudioPlayingChange",
           tabID: this.id,
-          isAudioPlaying: this.playingAudio,
+          isAudioPlaying: this.playingAudio
         });
         return;
       }
 
       case "DOMWindowClose": {
         if (!aEvent.isTrusted)
           return;
 
         // Find the relevant tab, and close it from Java
         if (this.browser.contentWindow == aEvent.target) {
           aEvent.preventDefault();
 
           GlobalEventDispatcher.sendRequest({
             type: "Tab:Close",
-            tabID: this.id,
+            tabID: this.id
           });
         }
         break;
       }
 
       case "DOMWillOpenModalDialog": {
         if (!aEvent.isTrusted)
           return;
@@ -4528,17 +4535,17 @@ Tab.prototype = {
         // The rest of this only handles pageshow for the top-level document.
         if (aEvent.originalTarget.defaultView != this.browser.contentWindow)
           return;
 
         GlobalEventDispatcher.sendRequest({
           type: "Content:PageShow",
           tabID: this.id,
           userRequested: this.userRequested,
-          fromCache: Tabs.useCache,
+          fromCache: Tabs.useCache
         });
 
         if (!aEvent.persisted && Services.prefs.getBoolPref("browser.ui.linkify.phone")) {
           if (!this._linkifier)
             this._linkifier = new Linkifier();
           this._linkifier.linkifyNumbers(this.browser.contentWindow.document);
         }
 
@@ -4605,23 +4612,22 @@ Tab.prototype = {
       let restoring = (aStateFlags & Ci.nsIWebProgressListener.STATE_RESTORING) > 0;
 
       let message = {
         type: "Content:StateChange",
         tabID: this.id,
         uri: truncate(uri, MAX_URI_LENGTH),
         state: aStateFlags,
         restoring: restoring,
-        success: success,
+        success: success
       };
       GlobalEventDispatcher.sendRequest(message);
     }
   },
 
-  // eslint-disable-next-line complexity
   onLocationChange: function(aWebProgress, aRequest, aLocationURI, aFlags) {
     let contentWin = aWebProgress.DOMWindow;
     let webNav = contentWin.docShell.QueryInterface(Ci.nsIWebNavigation);
 
     // Browser webapps may load content inside iframes that can not reach across the app/frame boundary
     // i.e. even though the page is loaded in an iframe window.top != webapp
     // Make cure this window is a top level tab before moving on.
     if (BrowserApp.getBrowserForWindow(contentWin) == null) {
@@ -4760,37 +4766,37 @@ Tab.prototype = {
     this._state = aState;
     this._hostChanged = false;
 
     let identity = IdentityHandler.checkIdentity(aState, this.browser);
 
     let message = {
       type: "Content:SecurityChange",
       tabID: this.id,
-      identity: identity,
+      identity: identity
     };
 
     GlobalEventDispatcher.sendRequest(message);
   },
 
   // Cache last tracking event to limit firings and only propagate changes
   _tracking: null,
 
   onContentBlockingEvent: function(aWebProgress, aRequest, aState) {
     let trackingMode = IdentityHandler.getTrackingMode(aState, this.browser);
     if (this._tracking == trackingMode) {
         return;
-    }
+    } else {
         this._tracking = trackingMode;
-
+    }
 
     let message = {
       type: "Content:ContentBlockingEvent",
       tabID: this.id,
-      tracking: trackingMode,
+      tracking: trackingMode
     };
 
     GlobalEventDispatcher.sendRequest(message);
   },
 
   OnHistoryNewEntry: function(newURI, oldIndex) {
     Services.obs.notifyObservers(this.browser, "Content:HistoryChange");
   },
@@ -4814,18 +4820,18 @@ Tab.prototype = {
 
   UpdateMediaPlaybackRelatedObserver: function(active) {
     // Media control is only used for the tab which has playing media, so we
     // only need to register observer after having the active media. And the
     // "media-playback-resumed" is sent when user resume paused media from
     // page, it notifies us that we should change the icon and content in media
     // control interface.
     if (active) {
-      Services.obs.addObserver(this, "mediaControl");
-      Services.obs.addObserver(this, "media-playback-resumed");
+      Services.obs.addObserver(this, "mediaControl", false);
+      Services.obs.addObserver(this, "media-playback-resumed", false);
     } else {
       Services.obs.removeObserver(this, "mediaControl");
       Services.obs.removeObserver(this, "media-playback-resumed");
     }
   },
 
   ShouldNotifyMediaPlaybackChange: function(activeState) {
     // If the media is active, we would check it's duration, because we don't
@@ -4890,17 +4896,17 @@ Tab.prototype = {
           this.UpdateMediaPlaybackRelatedObserver(isActive);
         } else if (aTopic == "media-playback-resumed") {
           status = "resume";
         }
 
         GlobalEventDispatcher.sendRequest({
           type: "Tab:MediaPlaybackChange",
           tabID: this.id,
-          status: status,
+          status: status
         });
         break;
 
       case "audioFocusChanged":
       case "mediaControl":
         let win = this.browser.contentWindow;
         let utils = win.windowUtils;
         let suspendTypes = Ci.nsISuspendedTypes;
@@ -4938,18 +4944,18 @@ Tab.prototype = {
     return this.browser.contentWindow;
   },
 
   QueryInterface: ChromeUtils.generateQI([
     Ci.nsIWebProgressListener,
     Ci.nsISHistoryListener,
     Ci.nsIObserver,
     Ci.nsISupportsWeakReference,
-    Ci.nsIBrowserTab,
-  ]),
+    Ci.nsIBrowserTab
+  ])
 };
 
 var BrowserEventHandler = {
   init: function init() {
     BrowserApp.deck.addEventListener("touchend", this, true);
 
     BrowserApp.deck.addEventListener("DOMUpdateBlockedPopups", PopupBlockerObserver.onUpdateBlockedPopups);
     BrowserApp.deck.addEventListener("MozMouseHittest", this, true);
@@ -4957,22 +4963,22 @@ var BrowserEventHandler = {
     // ReaderViews support backPress listeners.
     WindowEventDispatcher.registerListener((event, data, callback) => {
       callback.onSuccess(Reader.onBackPress(BrowserApp.selectedTab.id));
     }, "Browser:OnBackPressed");
   },
 
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
-      case "touchend":
+      case 'touchend':
         if (this._inCluster) {
           aEvent.preventDefault();
         }
         break;
-      case "MozMouseHittest":
+      case 'MozMouseHittest':
         this._handleRetargetedTouchStart(aEvent);
         break;
     }
   },
 
   _handleRetargetedTouchStart: function(aEvent) {
     // we should only get this called just after a new touchstart with a single
     // touch point.
@@ -4982,17 +4988,17 @@ var BrowserEventHandler = {
 
     let target = aEvent.composedTarget;
     if (!target) {
       return;
     }
 
     this._inCluster = aEvent.hitCluster;
     if (this._inCluster) {
-      return; // No highlight for a cluster of links
+      return;  // No highlight for a cluster of links
     }
 
     let uri = this._getLinkURI(target);
     if (uri) {
       try {
         Services.io.QueryInterface(Ci.nsISpeculativeConnect).speculativeConnect(uri,
                                                                                 target.ownerDocument.nodePrincipal,
                                                                                 null);
@@ -5018,21 +5024,20 @@ var BrowserEventHandler = {
     this._highlightElement = aElement;
   },
 
   _cancelTapHighlight: function _cancelTapHighlight() {
     if (!this._highlightElement)
       return;
 
     this._highlightElement = null;
-  },
+  }
 };
 
 var ErrorPageEventHandler = {
-  // eslint-disable-next-line complexity
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case "click": {
         // Don't trust synthetic events
         if (!aEvent.isTrusted)
           return;
 
         let target = aEvent.originalTarget;
@@ -5089,17 +5094,17 @@ var ErrorPageEventHandler = {
           } else if (errorDoc.documentURI.includes("e=harmfulBlocked")) {
             sendTelemetry = true;
             bucketName = "WARNING_HARMFUL_PAGE_";
           }
           let nsISecTel = Ci.nsISecurityUITelemetry;
           let isIframe = (errorDoc.defaultView.parent === errorDoc.defaultView);
           bucketName += isIframe ? "TOP_" : "FRAME_";
 
-          let formatter = Services.urlFormatter;
+          let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
 
           if (target == errorDoc.getElementById("getMeOutButton")) {
             if (sendTelemetry) {
               Telemetry.addData(probe, nsISecTel[bucketName + "GET_ME_OUT_OF_HERE"]);
             }
             errorDoc.location = "about:home";
           } else if (target == errorDoc.getElementById("reportButton")) {
             // We log even if malware/phishing info URL couldn't be found:
@@ -5119,34 +5124,34 @@ var ErrorPageEventHandler = {
             }
 
             // Allow users to override and continue through to the site,
             let webNav = BrowserApp.selectedBrowser.docShell.QueryInterface(Ci.nsIWebNavigation);
             let location = BrowserApp.selectedBrowser.contentWindow.location;
             let attrs = {};
             let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(BrowserApp.selectedBrowser);
             if (isPrivate) {
-              attrs.privateBrowsingId = 1;
+              attrs["privateBrowsingId"] = 1;
             }
 
             let loadURIOptions = {
               triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(attrs),
               loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER,
             };
             webNav.loadURI(location, loadURIOptions);
 
             // ....but add a notify bar as a reminder, so that they don't lose
             // track after, e.g., tab switching.
             NativeWindow.doorhanger.show(Strings.browser.GetStringFromName("safeBrowsingDoorhanger"), "safebrowsing-warning", [], BrowserApp.selectedTab.id);
           }
         }
         break;
       }
     }
-  },
+  }
 };
 
 var XPInstallObserver = {
   init: function() {
     Services.obs.addObserver(this, "addon-install-origin-blocked");
     Services.obs.addObserver(this, "addon-install-disabled");
     Services.obs.addObserver(this, "addon-install-blocked");
     Services.obs.addObserver(this, "addon-install-started");
@@ -5178,35 +5183,35 @@ var XPInstallObserver = {
           return;
 
         let enabled = Services.prefs.getBoolPref("xpinstall.enabled", true);
 
         let buttons, message, callback;
         if (!enabled) {
           message = strings.GetStringFromName("xpinstallDisabledMessageLocked");
           buttons = [strings.GetStringFromName("unsignedAddonsDisabled.dismiss")];
-          (data) => {};
+          callback: (data) => {};
         } else {
           message = strings.formatStringFromName("xpinstallDisabledMessage2", [brandShortName, host], 2);
           buttons = [
               strings.GetStringFromName("xpinstallDisabledButton"),
-              strings.GetStringFromName("unsignedAddonsDisabled.dismiss"),
+              strings.GetStringFromName("unsignedAddonsDisabled.dismiss")
           ];
-          (data) => {
+          callback: (data) => {
             if (data.button === 1) {
-              Services.prefs.setBoolPref("xpinstall.enabled", true);
+              Services.prefs.setBoolPref("xpinstall.enabled", true)
             }
           };
         }
 
         new Prompt({
           window: window,
           title: Strings.browser.GetStringFromName("addonError.titleError"),
           message: message,
-          buttons: buttons,
+          buttons: buttons
         }).show(callback);
         break;
       }
       case "addon-install-blocked": {
         if (!tab)
           return;
 
         let message;
@@ -5225,40 +5230,40 @@ var XPInstallObserver = {
           } else {
             // We don't have an addon name, show an alternative message.
             message = strings.formatStringFromName("xpinstallPromptWarningDirect", [brandShortName], 1);
           }
         }
 
         let buttons = [
             strings.GetStringFromName("xpinstallPromptAllowButton"),
-            strings.GetStringFromName("unsignedAddonsDisabled.dismiss"),
+            strings.GetStringFromName("unsignedAddonsDisabled.dismiss")
         ];
         new Prompt({
           window: window,
           title: Strings.browser.GetStringFromName("addonError.titleBlocked"),
           message: message,
-          buttons: buttons,
+          buttons: buttons
         }).show((data) => {
           if (data.button === 0) {
             // Kick off the install
             installInfo.install();
           }
         });
         break;
       }
       case "addon-install-origin-blocked": {
         if (!tab)
           return;
 
         new Prompt({
           window: window,
           title: Strings.browser.GetStringFromName("addonError.titleBlocked"),
           message: strings.formatStringFromName("xpinstallPromptWarningDirect", [brandShortName], 1),
-          buttons: [strings.GetStringFromName("unsignedAddonsDisabled.dismiss")],
+          buttons: [strings.GetStringFromName("unsignedAddonsDisabled.dismiss")]
         }).show((data) => {});
         break;
       }
       case "xpi-signature-changed": {
         if (JSON.parse(aData).disabled.length) {
           this._notifyUnsignedAddonsDisabled();
         }
         break;
@@ -5293,18 +5298,18 @@ var XPInstallObserver = {
 
   _notifyUnsignedAddonsDisabled: function() {
     new Prompt({
       window: window,
       title: Strings.browser.GetStringFromName("unsignedAddonsDisabled.title"),
       message: Strings.browser.GetStringFromName("unsignedAddonsDisabled.message"),
       buttons: [
         Strings.browser.GetStringFromName("unsignedAddonsDisabled.viewAddons"),
-        Strings.browser.GetStringFromName("unsignedAddonsDisabled.dismiss"),
-      ],
+        Strings.browser.GetStringFromName("unsignedAddonsDisabled.dismiss")
+      ]
     }).show((data) => {
       if (data.button === 0) {
         // TODO: Open about:addons to show only unsigned add-ons?
         BrowserApp.selectOrAddTab("about:addons", { parentId: BrowserApp.selectedTab.id });
       }
     });
   },
 
@@ -5318,28 +5323,30 @@ var XPInstallObserver = {
     let needsRestart = false;
     if (aInstall.existingAddon && (aInstall.existingAddon.pendingOperations & AddonManager.PENDING_UPGRADE))
       needsRestart = true;
     else if (aAddon.pendingOperations & AddonManager.PENDING_INSTALL)
       needsRestart = true;
 
     if (needsRestart) {
       this.showRestartPrompt();
-    } else if (!aInstall.existingAddon || !AddonManager.shouldAutoUpdate(aInstall.existingAddon)) {
+    } else {
       // Display completion message for new installs or updates not done Automatically
-      let message = Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart.message");
-      Snackbars.show(message, Snackbars.LENGTH_LONG, {
-        action: {
-          label: Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart.action2"),
-          callback: () => {
-            UITelemetry.addEvent("show.1", "toast", null, "addons");
-            BrowserApp.selectOrAddTab("about:addons", { parentId: BrowserApp.selectedTab.id });
-          },
-        },
-      });
+      if (!aInstall.existingAddon || !AddonManager.shouldAutoUpdate(aInstall.existingAddon)) {
+        let message = Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart.message");
+        Snackbars.show(message, Snackbars.LENGTH_LONG, {
+          action: {
+            label: Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart.action2"),
+            callback: () => {
+              UITelemetry.addEvent("show.1", "toast", null, "addons");
+              BrowserApp.selectOrAddTab("about:addons", { parentId: BrowserApp.selectedTab.id });
+            },
+          }
+        });
+      }
     }
   },
 
   onInstallFailed: function(aInstall) {
     this._showErrorMessage(aInstall);
   },
 
   onDownloadProgress: function(aInstall) {},
@@ -5381,17 +5388,17 @@ var XPInstallObserver = {
     msg = msg.replace("#3", Strings.brand.GetStringFromName("brandShortName"));
     msg = msg.replace("#4", Services.appinfo.version);
 
     if (aInstall.error == AddonManager.ERROR_SIGNEDSTATE_REQUIRED) {
       new Prompt({
         window: window,
         title: Strings.browser.GetStringFromName("addonError.titleBlocked"),
         message: msg,
-        buttons: [Strings.browser.GetStringFromName("addonError.learnMore")],
+        buttons: [Strings.browser.GetStringFromName("addonError.learnMore")]
       }).show((data) => {
         if (data.button === 0) {
           let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "unsigned-addons";
           BrowserApp.addTab(url, { parentId: BrowserApp.selectedTab.id });
         }
       });
     } else {
       Services.prompt.alert(null, Strings.browser.GetStringFromName("addonError.titleError"), msg);
@@ -5402,33 +5409,33 @@ var XPInstallObserver = {
     let buttons = [{
       label: Strings.browser.GetStringFromName("notificationRestart.button"),
       callback: function() {
         // Notify all windows that an application quit has been requested
         let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
         Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
 
         // If nothing aborted, quit the app
-        if (!cancelQuit.data) {
+        if (cancelQuit.data == false) {
           Services.obs.notifyObservers(null, "quit-application-proceeding");
           SharedPreferences.forApp().setBoolPref("browser.sessionstore.resume_session_once", true);
-          let appStartup = Services.startup;
+          let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
           appStartup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
         }
       },
-      positive: true,
+      positive: true
     }];
 
     let message = Strings.browser.GetStringFromName("notificationRestart.normal");
     NativeWindow.doorhanger.show(message, "addon-app-restart", buttons, BrowserApp.selectedTab.id, { persistence: -1 }, "ADDON");
   },
 
   hideRestartPrompt: function() {
     NativeWindow.doorhanger.hide("addon-app-restart", BrowserApp.selectedTab.id);
-  },
+  }
 };
 
 /**
  * Handler for blocked popups, triggered by DOMUpdateBlockedPopups events in browser.js
  */
 var PopupBlockerObserver = {
   onUpdateBlockedPopups: function onUpdateBlockedPopups(aEvent) {
     let browser = BrowserApp.selectedBrowser;
@@ -5456,45 +5463,45 @@ var PopupBlockerObserver = {
                                 .replace("#2", popupCount);
 
         let buttons = [
           {
             label: strings.GetStringFromName("popup.dontShow"),
             callback: function(aChecked) {
               if (aChecked)
                 PopupBlockerObserver.allowPopupsForSite(false);
-            },
+            }
           },
           {
             label: strings.GetStringFromName("popup.show"),
             callback: function(aChecked) {
               // Set permission before opening popup windows
               if (aChecked)
                 PopupBlockerObserver.allowPopupsForSite(true);
 
               PopupBlockerObserver.showPopupsForSite();
             },
-            positive: true,
-          },
+            positive: true
+          }
         ];
 
         let options = { checkbox: Strings.browser.GetStringFromName("popup.dontAskAgain") };
         NativeWindow.doorhanger.show(message, "popup-blocked", buttons, null, options);
       }
       // Record the fact that we've reported this blocked popup, so we don't
       // show it again.
       browser.blockedPopups.reported = true;
     }
   },
 
   allowPopupsForSite: function allowPopupsForSite(aAllow) {
     let currentURI = BrowserApp.selectedBrowser.currentURI;
     Services.perms.add(currentURI, "popup", aAllow
-                       ? Ci.nsIPermissionManager.ALLOW_ACTION
-                       : Ci.nsIPermissionManager.DENY_ACTION);
+                       ?  Ci.nsIPermissionManager.ALLOW_ACTION
+                       :  Ci.nsIPermissionManager.DENY_ACTION);
     dump("Allowing popups for: " + currentURI);
   },
 
   showPopupsForSite: function showPopupsForSite() {
     let uri = BrowserApp.selectedBrowser.currentURI;
     let {blockedPopups} = BrowserApp.selectedBrowser;
     if (blockedPopups) {
       for (let i = 0; i < blockedPopups.length; ++i) {
@@ -5511,17 +5518,17 @@ var PopupBlockerObserver = {
         let popupFeatures = blockedPopups[i].popupWindowFeatures;
         let popupName = blockedPopups[i].popupWindowName;
 
         let parent = BrowserApp.selectedTab;
         let isPrivate = PrivateBrowsingUtils.isBrowserPrivate(parent.browser);
         BrowserApp.addTab(popupURIspec, { parentId: parent.id, isPrivate: isPrivate });
       }
     }
-  },
+  }
 };
 
 
 var IndexedDB = {
   _permissionsPrompt: "indexedDB-permissions-prompt",
   _permissionsResponse: "indexedDB-permissions-response",
 
   init: function IndexedDB_init() {
@@ -5576,35 +5583,35 @@ var IndexedDB = {
 
     let buttons = [
     {
       label: strings.GetStringFromName("offlineApps.dontAllow2"),
       callback: function(aChecked) {
         clearTimeout(timeoutId);
         let action = aChecked ? Ci.nsIPermissionManager.DENY_ACTION : Ci.nsIPermissionManager.UNKNOWN_ACTION;
         observer.observe(null, responseTopic, action);
-      },
+      }
     },
     {
       label: strings.GetStringFromName("offlineApps.allow"),
       callback: function() {
         clearTimeout(timeoutId);
         observer.observe(null, responseTopic, Ci.nsIPermissionManager.ALLOW_ACTION);
       },
-      positive: true,
+      positive: true
     }];
 
     let options = { checkbox: Strings.browser.GetStringFromName("offlineApps.dontAskAgain") };
     NativeWindow.doorhanger.show(message, notificationID, buttons, tab.id, options);
 
     // Set the timeoutId after the popup has been created, and use the long
     // timeout value. If the user doesn't notice the popup after this amount of
     // time then it is most likely not visible and we want to alert the page.
     timeoutId = setTimeout(timeoutNotification, firstTimeoutDuration);
-  },
+  }
 };
 
 var CharacterEncoding = {
   _charsets: [],
 
   init: function init() {
     GlobalEventDispatcher.registerListener(this, [
       "CharEncoding:Get",
@@ -5627,31 +5634,31 @@ var CharacterEncoding = {
   sendState: function sendState() {
     let showCharEncoding = "false";
     try {
       showCharEncoding = Services.prefs.getComplexValue("browser.menu.showCharacterEncoding", Ci.nsIPrefLocalizedString).data;
     } catch (e) { /* Optional */ }
 
     GlobalEventDispatcher.sendRequest({
       type: "CharEncoding:State",
-      visible: showCharEncoding,
+      visible: showCharEncoding
     });
   },
 
   getEncoding: function getEncoding() {
     function infoToCharset(info) {
       return { code: info.value, title: info.label };
     }
 
     if (!this._charsets.length) {
       let data = CharsetMenu.getData();
 
       // In the desktop UI, the pinned charsets are shown above the rest.
       let pinnedCharsets = data.pinnedCharsets.map(infoToCharset);
-      let otherCharsets = data.otherCharsets.map(infoToCharset);
+      let otherCharsets = data.otherCharsets.map(infoToCharset)
 
       this._charsets = pinnedCharsets.concat(otherCharsets);
     }
 
     // Look for the index of the selected charset. Default to -1 if the
     // doc charset isn't found in the list of available charsets.
     let docCharset = BrowserApp.selectedBrowser.contentDocument.characterSet;
     let selected = -1;
@@ -5662,26 +5669,26 @@ var CharacterEncoding = {
         selected = i;
         break;
       }
     }
 
     GlobalEventDispatcher.sendRequest({
       type: "CharEncoding:Data",
       charsets: this._charsets,
-      selected: selected,
+      selected: selected
     });
   },
 
   setEncoding: function setEncoding(aEncoding) {
     let browser = BrowserApp.selectedBrowser;
     browser.docShell.gatherCharsetMenuTelemetry();
     browser.docShell.charset = aEncoding;
     browser.reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
-  },
+  }
 };
 
 var IdentityHandler = {
   // No trusted identity information. No site identity icon is shown.
   IDENTITY_MODE_UNKNOWN: "unknown",
 
   // Domain-Validation SSL CA-signed domain verification (DV).
   IDENTITY_MODE_IDENTIFIED: "identified",
@@ -5713,24 +5720,24 @@ var IdentityHandler = {
   // Blocked active tracking content. Shield icon is shown, with a popup option to load content.
   TRACKING_MODE_CONTENT_BLOCKED: "tracking_content_blocked",
 
   // Loaded active tracking content. Yellow triangle icon is shown.
   TRACKING_MODE_CONTENT_LOADED: "tracking_content_loaded",
 
   // Cache the most recent TransportSecurityInfo and Location seen in
   // getIdentityStrings
-  _lastSecInfo: null,
-  _lastLocation: null,
+  _lastSecInfo : null,
+  _lastLocation : null,
 
   /**
    * Helper to parse out the important parts of _lastSecInfo (of the SSL cert in
    * particular) for use in constructing identity UI strings
   */
-  getIdentityData: function() {
+  getIdentityData : function() {
     let result = {};
     let cert = this._lastSecInfo.serverCert;
 
     // Human readable name of Subject
     result.subjectOrg = cert.organization;
 
     // SubjectName fields, broken up for individual access
     if (cert.subjectName) {
@@ -5859,17 +5866,17 @@ var IdentityHandler = {
     let mixedDisplay = this.getMixedDisplayMode(aState);
     let mixedActive = this.getMixedActiveMode(aState);
     let result = {
       origin: locationObj.origin,
       mode: {
         identity: identityMode,
         mixed_display: mixedDisplay,
         mixed_active: mixedActive,
-      },
+      }
     };
 
     result.host = this.getEffectiveHost();
 
     // Don't show identity data for pages with an unknown identity or if any
     // mixed content is loaded (mixed display content is loaded by default).
     // We also return for CHROMEUI pages since they don't have any certificate
     // information to load either. result.secure specifically refers to connection
@@ -5940,17 +5947,17 @@ var IdentityHandler = {
                          .getService(Ci.nsIIDNService);
     try {
       return this._IDNService.convertToDisplayIDN(this._uri.host, {});
     } catch (e) {
       // If something goes wrong (e.g. hostname is an IP address) just fail back
       // to the full domain.
       return this._lastLocation.hostname;
     }
-  },
+  }
 };
 
 var SearchEngines = {
   _contextMenuId: null,
   PREF_SUGGEST_ENABLED: "browser.search.suggest.enabled",
   PREF_SUGGEST_PROMPTED: "browser.search.suggest.prompted",
 
   // Shared preference key used for search activity default engine.
@@ -5978,22 +5985,22 @@ var SearchEngines = {
 
     // Our Java UI assumes that the default engine is the first item in the array,
     // so we need to make sure that's the case.
     if (engineData[0].name !== Services.search.defaultEngine.name) {
       engineData = engineData.filter(engine => engine.name !== Services.search.defaultEngine.name);
       engineData.unshift(Services.search.defaultEngine);
     }
 
-    let searchEngines = engineData.map(function(engine) {
+    let searchEngines = engineData.map(function (engine) {
       return {
         name: engine.name,
         identifier: engine.identifier,
         iconURI: (engine.iconURI ? engine.iconURI.spec : null),
-        hidden: engine.hidden,
+        hidden: engine.hidden
       };
     });
 
     let suggestTemplate = null;
     let suggestEngine = null;
 
     // Check to see if the default engine supports search suggestions. We only need to check
     // the default engine because we only show suggestions for the default engine in the UI.
@@ -6006,31 +6013,31 @@ var SearchEngines = {
     // By convention, the currently configured default engine is at position zero in searchEngines.
     GlobalEventDispatcher.sendRequest({
       type: "SearchEngines:Data",
       searchEngines: searchEngines,
       suggest: {
         engine: suggestEngine,
         template: suggestTemplate,
         enabled: Services.prefs.getBoolPref(this.PREF_SUGGEST_ENABLED),
-        prompted: Services.prefs.getBoolPref(this.PREF_SUGGEST_PROMPTED),
-      },
+        prompted: Services.prefs.getBoolPref(this.PREF_SUGGEST_PROMPTED)
+      }
     });
 
     // Send a speculative connection to the default engine.
     Services.search.defaultEngine.speculativeConnect({ window: window,
                                                        originAttributes: {} });
   },
 
   // Helper method to extract the engine name from a JSON. Simplifies the observe function.
   _extractEngineFromJSON: function _extractEngineFromJSON(data) {
     return Services.search.getEngineByName(data.engine);
   },
 
-  onEvent: function(event, data, callback) {
+  onEvent: function (event, data, callback) {
     let engine;
     switch (event) {
       case "SearchEngines:Add":
         this.displaySearchEnginesList(data);
         break;
       case "SearchEngines:GetVisible":
         Services.search.init().then(this._handleSearchEnginesGetVisible.bind(this));
         break;
@@ -6084,32 +6091,32 @@ var SearchEngines = {
 
     if (!tab)
       return;
 
     let browser = tab.browser;
     let engines = browser.engines;
 
     let p = new Prompt({
-      window: browser.contentWindow,
+      window: browser.contentWindow
     }).setSingleChoiceItems(engines.map(function(e) {
       return { label: e.title };
     })).show(data => {
       if (data.button == -1)
         return;
 
       this.addOpenSearchEngine(engines[data.button]);
       engines.splice(data.button, 1);
 
       if (engines.length < 1) {
         // Broadcast message that there are no more add-able search engines.
         let newEngineMessage = {
           type: "Link:OpenSearch",
           tabID: tab.id,
-          visible: false,
+          visible: false
         };
 
         GlobalEventDispatcher.sendRequest(newEngineMessage);
       }
     });
   },
 
   addOpenSearchEngine: async function addOpenSearchEngine(engine) {
@@ -6170,17 +6177,17 @@ var SearchEngines = {
           for (let option of formElement.options) {
             if (option.selected) {
               formData.push({ name: escape(formElement.name), value: escape(formElement.value) });
               break;
             }
           }
         }
       }
-    }
+    };
 
     // Return valid, pre-sorted queryParams.
     return formData.filter(a => a.name && a.value).sort((a, b) => {
       // nsISearchService.hasEngineWithURL() ensures sort, but this helps.
       if (a.name > b.name) {
         return 1;
       }
       if (b.name > a.name) {
@@ -6230,33 +6237,33 @@ var SearchEngines = {
     let formData = this._getSortedFormData(aElement);
 
     // prompt user for name of search engine
     let promptTitle = Strings.browser.GetStringFromName("contextmenu.addSearchEngine3");
     let title = { value: (aElement.ownerDocument.title || docURI.displayHost) };
     if (!Services.prompt.prompt(null, promptTitle, null, title, null, {})) {
       if (resultCallback) {
         resultCallback(false);
-      }
+      };
       return;
     }
 
     Services.search.init().then(function addEngine_cb(rv) {
       if (!Components.isSuccessCode(rv)) {
         Cu.reportError("Could not initialize search service, bailing out.");
         if (resultCallback) {
           resultCallback(false);
-        }
+        };
         return;
       }
 
       GlobalEventDispatcher.sendRequestForResult({
-        type: "Favicon:Request",
+        type: 'Favicon:Request',
         url: docURI.spec,
-        skipNetwork: false,
+        skipNetwork: false
       }).then(async data => {
         // if there's already an engine with this name, add a number to
         // make the name unique (e.g., "Google" becomes "Google 2")
         let name = title.value;
         for (let i = 2; Services.search.getEngineByName(name); i++) {
             name = title.value + " " + i;
         }
 
@@ -6264,24 +6271,24 @@ var SearchEngines = {
         Snackbars.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [name], 1), Snackbars.LENGTH_LONG);
 
         let engine = Services.search.getEngineByName(name);
         engine.wrappedJSObject._queryCharset = charset;
         formData.forEach(param => { engine.addParam(param.name, param.value, null); });
 
         if (resultCallback) {
             return resultCallback(true);
-        }
+        };
       }).catch(e => {
         dump("Error while fetching icon for search engine");
 
         resultCallback(false);
       });
     });
-  },
+  }
 };
 
 var ActivityObserver = {
   init: function ao_init() {
     Services.obs.addObserver(this, "application-background");
     Services.obs.addObserver(this, "application-foreground");
   },
 
@@ -6302,17 +6309,17 @@ var ActivityObserver = {
       case "application-foreground" :
         isForeground = true;
         break;
     }
 
     if (tab && tab.getActive() != isForeground) {
       tab.setActive(isForeground);
     }
-  },
+  }
 };
 
 var Telemetry = {
   addData: function addData(aHistogramId, aValue) {
     let histogram = Services.telemetry.getHistogramById(aHistogramId);
     histogram.add(aValue);
   },
 };
@@ -6321,17 +6328,17 @@ var Experiments = {
   // Enable malware download protection (bug 936041)
   MALWARE_DOWNLOAD_PROTECTION: "malware-download-protection",
 
   // Try to load pages from disk cache when network is offline (bug 935190)
   OFFLINE_CACHE: "offline-cache",
 
   init() {
     GlobalEventDispatcher.sendRequestForResult({
-      type: "Experiments:GetActive",
+      type: "Experiments:GetActive"
     }).then(names => {
       for (let name of names) {
         switch (name) {
           case this.MALWARE_DOWNLOAD_PROTECTION: {
             // Apply experiment preferences on the default branch. This allows
             // us to avoid migrating user prefs when experiments are enabled/disabled,
             // and it also allows users to override these prefs in about:config.
             let defaults = Services.prefs.getDefaultBranch(null);
@@ -6349,26 +6356,26 @@ var Experiments = {
       }
     });
   },
 
   setOverride(name, isEnabled) {
     GlobalEventDispatcher.sendRequest({
       type: "Experiments:SetOverride",
       name: name,
-      isEnabled: isEnabled,
+      isEnabled: isEnabled
     });
   },
 
   clearOverride(name) {
     GlobalEventDispatcher.sendRequest({
       type: "Experiments:ClearOverride",
-      name: name,
+      name: name
     });
-  },
+  }
 };
 
 var ExternalApps = {
   _contextMenuId: null,
 
   // extend _getLink to pickup html5 media links.
   _getMediaLink: function(aElement) {
     let uri = NativeWindow.contextmenus._getLink(aElement);
@@ -6407,17 +6414,17 @@ var ExternalApps = {
       }
 
       let uri = ExternalApps._getMediaLink(aElement);
       let apps = [];
       if (uri) {
         apps = HelperApps.getAppsForUri(uri);
       }
       return apps.length > 0;
-    },
+    }
   },
 
   openExternal: function(aElement) {
     if (aElement.pause) {
       aElement.pause();
     }
     let uri = ExternalApps._getMediaLink(aElement);
     HelperApps.launchUri(uri);
@@ -6486,39 +6493,39 @@ var ExternalApps = {
 
         if (apps.length > 1) {
           // Use the HelperApps prompt here to filter out any Http handlers
           HelperApps.prompt(apps, {
             window: window,
             title: Strings.browser.GetStringFromName("openInApp.pageAction"),
             buttons: [
               Strings.browser.GetStringFromName("openInApp.ok"),
-              Strings.browser.GetStringFromName("openInApp.cancel"),
+              Strings.browser.GetStringFromName("openInApp.cancel")
             ],
             // Support double tapping to launch an app
-            doubleTapButton: 0,
+            doubleTapButton: 0
           }, (result) => {
             if (result.button != 0) {
               if (wasPlaying) {
                 mediaElement.play();
               }
 
               return;
             }
             apps[result.icongrid0].launch(this._pageActionUri);
           });
         } else {
           apps[0].launch(this._pageActionUri);
         }
-      },
+      }
     });
   },
 
   clearPageAction: function clearPageAction() {
-    if (!this._pageActionId)
+    if(!this._pageActionId)
       return;
 
     PageActions.remove(this._pageActionId);
     delete this._pageActionId;
   },
 };
 
 var Distribution = {
@@ -6611,32 +6618,32 @@ var Distribution = {
       return;
 
     file.append("preferences.json");
     this.readJSON(file, this.applyPrefs);
   },
 
   applyPrefs: function dc_applyPrefs(aData) {
     // Check for required Global preferences
-    let global = aData.Global;
-    if (!(global && global.id && global.version && global.about)) {
+    let global = aData["Global"];
+    if (!(global && global["id"] && global["version"] && global["about"])) {
       Cu.reportError("Distribution: missing or incomplete Global preferences");
       return;
     }
 
     // Force the distribution preferences on the default branch
     let defaults = Services.prefs.getDefaultBranch(null);
-    defaults.setCharPref("distribution.id", global.id);
-    defaults.setCharPref("distribution.version", global.version);
+    defaults.setCharPref("distribution.id", global["id"]);
+    defaults.setCharPref("distribution.version", global["version"]);
 
     let locale = BrowserApp.getUALocalePref();
     defaults.setStringPref("distribution.about",
-                           global["about." + locale] || global.about);
-
-    let prefs = aData.Preferences;
+                           global["about." + locale] || global["about"]);
+
+    let prefs = aData["Preferences"];
     for (let key in prefs) {
       try {
         let value = prefs[key];
         switch (typeof value) {
           case "boolean":
             defaults.setBoolPref(key, value);
             break;
           case "number":
@@ -6651,17 +6658,17 @@ var Distribution = {
     }
 
     // Apply a lightweight theme if necessary
     if (prefs && prefs["lightweightThemes.selectedThemeID"]) {
       Services.obs.notifyObservers(null, "lightweight-theme-apply");
     }
 
     let localizedString = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(Ci.nsIPrefLocalizedString);
-    let localizeablePrefs = aData.LocalizablePreferences;
+    let localizeablePrefs = aData["LocalizablePreferences"];
     for (let key in localizeablePrefs) {
       try {
         let value = localizeablePrefs[key];
         value = value.replace(/%LOCALE%/g, locale);
         localizedString.data = "data:text/plain," + key + "=" + value;
         defaults.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedString);
       } catch (e) { /* ignore bad prefs and move on */ }
     }
@@ -6952,29 +6959,29 @@ ContextMenuItem.prototype = {
       showAsActions: this.addVal("showAsActions", elt),
       icon: this.addVal("icon", elt),
       isGroup: this.addVal("isGroup", elt, false),
       inGroup: this.addVal("inGroup", elt, false),
       disabled: this.addVal("disabled", elt, false),
       selected: this.addVal("selected", elt, false),
       isParent: this.addVal("isParent", elt, false),
     };
-  },
-};
+  }
+}
 
 function HTMLContextMenuItem(elt, target) {
   ContextMenuItem.call(this, { });
 
   this.menuElementRef = Cu.getWeakReference(elt);
   this.targetElementRef = Cu.getWeakReference(target);
 }
 
 HTMLContextMenuItem.prototype = Object.create(ContextMenuItem.prototype, {
   order: {
-    value: NativeWindow.contextmenus.DEFAULT_HTML5_ORDER,
+    value: NativeWindow.contextmenus.DEFAULT_HTML5_ORDER
   },
 
   matches: {
     value: function(target) {
       let t = this.targetElementRef.get();
       return t === target;
     },
   },
@@ -6998,17 +7005,18 @@ HTMLContextMenuItem.prototype = Object.c
           }
 
           var items = NativeWindow.contextmenus._getHTMLContextMenuItemsForMenu(elt, target);
           // This menu will always only have one context, but we still make sure its the "right" one.
           var context = NativeWindow.contextmenus._getContextType(target);
           if (items.length > 0) {
             NativeWindow.contextmenus._addMenuItems(items, context);
           }
-        } catch (ex) {
+
+        } catch(ex) {
           Cu.reportError(ex);
         }
       } else {
         // otherwise just click the menu item
         elt.click();
       }
     },
   },
@@ -7024,13 +7032,13 @@ HTMLContextMenuItem.prototype = Object.c
         return null;
       }
 
       return {
         id: this.id,
         icon: elt.icon,
         label: elt.label,
         disabled: elt.disabled,
-        menu: elt instanceof HTMLMenuElement,
+        menu: elt instanceof HTMLMenuElement
       };
-    },
+    }
   },
 });