Bug 1508823 - Enable ESLint for dom/browser-element (manual changes). r=mccr8
authorJagmeet Bhamber <jsbhamber2@myseneca.ca>
Tue, 19 Mar 2019 20:56:24 +0000
changeset 465110 a52b7d427119e56bf69f22ba85e2ea662cf043a9
parent 465109 21cd0b75c1c32c030b1ecef94315df2706013d63
child 465111 69c8acfbec73e624acef2fbe0f106a641db20816
push id35732
push useropoprus@mozilla.com
push dateWed, 20 Mar 2019 10:52:37 +0000
treeherdermozilla-central@708979f9c3f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1508823
milestone68.0a1
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
Bug 1508823 - Enable ESLint for dom/browser-element (manual changes). r=mccr8 Depends on D21215 Differential Revision: https://phabricator.services.mozilla.com/D14130
.eslintignore
dom/browser-element/BrowserElementChild.js
dom/browser-element/BrowserElementChildPreload.js
dom/browser-element/BrowserElementCopyPaste.js
dom/browser-element/BrowserElementParent.jsm
dom/browser-element/BrowserElementPromptService.jsm
dom/browser-element/mochitest/async.js
dom/browser-element/mochitest/browserElement_Alert.js
dom/browser-element/mochitest/browserElement_AlertInFrame.js
dom/browser-element/mochitest/browserElement_Auth.js
dom/browser-element/mochitest/browserElement_BackForward.js
dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js
dom/browser-element/mochitest/browserElement_BrowserWindowResize.js
dom/browser-element/mochitest/browserElement_Close.js
dom/browser-element/mochitest/browserElement_CloseFromOpener.js
dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js
dom/browser-element/mochitest/browserElement_CopyPaste.js
dom/browser-element/mochitest/browserElement_DataURI.js
dom/browser-element/mochitest/browserElement_DataURILoad.js
dom/browser-element/mochitest/browserElement_DocumentFirstPaint.js
dom/browser-element/mochitest/browserElement_ErrorSecurity.js
dom/browser-element/mochitest/browserElement_ExposableURI.js
dom/browser-element/mochitest/browserElement_FirstPaint.js
dom/browser-element/mochitest/browserElement_ForwardName.js
dom/browser-element/mochitest/browserElement_FrameWrongURI.js
dom/browser-element/mochitest/browserElement_Iconchange.js
dom/browser-element/mochitest/browserElement_LoadEvents.js
dom/browser-element/mochitest/browserElement_Metachange.js
dom/browser-element/mochitest/browserElement_OpenNamed.js
dom/browser-element/mochitest/browserElement_OpenTab.js
dom/browser-element/mochitest/browserElement_OpenWindow.js
dom/browser-element/mochitest/browserElement_OpenWindowDifferentOrigin.js
dom/browser-element/mochitest/browserElement_OpenWindowEmpty.js
dom/browser-element/mochitest/browserElement_OpenWindowInFrame.js
dom/browser-element/mochitest/browserElement_OpenWindowRejected.js
dom/browser-element/mochitest/browserElement_OpenWindowRejected2.js
dom/browser-element/mochitest/browserElement_Opensearch.js
dom/browser-element/mochitest/browserElement_PrivateBrowsing.js
dom/browser-element/mochitest/browserElement_PromptCheck.js
dom/browser-element/mochitest/browserElement_PromptConfirm.js
dom/browser-element/mochitest/browserElement_Reload.js
dom/browser-element/mochitest/browserElement_ReloadPostRequest.js
dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js
dom/browser-element/mochitest/browserElement_ScrollEvent.js
dom/browser-element/mochitest/browserElement_SecurityChange.js
dom/browser-element/mochitest/browserElement_SendEvent.js
dom/browser-element/mochitest/browserElement_Stop.js
dom/browser-element/mochitest/browserElement_TargetBlank.js
dom/browser-element/mochitest/browserElement_TargetTop.js
dom/browser-element/mochitest/browserElement_ThemeColor.js
dom/browser-element/mochitest/browserElement_Titlechange.js
dom/browser-element/mochitest/browserElement_TopBarrier.js
dom/browser-element/mochitest/browserElement_Viewmode.js
dom/browser-element/mochitest/browserElement_XFrameOptions.js
dom/browser-element/mochitest/browserElement_XFrameOptionsAllowFrom.js
dom/browser-element/mochitest/browserElement_XFrameOptionsDeny.js
dom/browser-element/mochitest/browserElement_XFrameOptionsSameOrigin.js
dom/browser-element/mochitest/file_browserElement_FrameWrongURI.html
dom/browser-element/mochitest/file_browserElement_LoadEvents.html
dom/browser-element/mochitest/file_browserElement_OpenWindowDifferentOrigin.html
dom/browser-element/mochitest/file_browserElement_TargetTop.html
dom/browser-element/mochitest/file_browserElement_XFrameOptionsAllowFrom.html
dom/browser-element/mochitest/file_empty.html
dom/browser-element/mochitest/file_focus.html
tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -162,17 +162,16 @@ devtools/server/tests/unit/xpcshell_debu
 # dom/ exclusions
 dom/animation/**
 dom/base/*.*
 dom/base/test/*.*
 dom/base/test/unit/test_serializers_entities*.js
 dom/base/test/unit_ipc/**
 dom/base/test/jsmodules/**
 dom/bindings/**
-dom/browser-element/**
 dom/canvas/**
 dom/encoding/**
 dom/events/**
 dom/fetch/**
 dom/file/**
 dom/flex/**
 dom/grid/**
 dom/html/**
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* eslint-env mozilla/frame-script */
+/* global api, CopyPasteAssistent */
+
 "use strict";
 
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function debug(msg) {
   // dump("BrowserElementChild - " + msg + "\n");
 }
 
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
+/* eslint-env mozilla/frame-script */
+
 function debug(msg) {
   // dump("BrowserElementChildPreload - " + msg + "\n");
 }
 
 debug("loaded");
 
 var BrowserElementIsReady;
 
@@ -35,17 +37,17 @@ function sendAsyncMsg(msg, data) {
   data.msg_name = msg;
   sendAsyncMessage("browser-element-api:call", data);
 }
 
 function sendSyncMsg(msg, data) {
   // Ensure that we don't send any messages before BrowserElementChild.js
   // finishes loading.
   if (!BrowserElementIsReady) {
-    return;
+    return undefined;
   }
 
   if (!data) {
     data = { };
   }
 
   data.msg_name = msg;
   return sendSyncMessage("browser-element-api:call", data);
@@ -155,20 +157,18 @@ BrowserElementChild.prototype = {
 
     // Registers a MozAfterPaint handler for the very first paint.
     this._addMozAfterPaintHandler(function() {
       sendAsyncMsg("firstpaint");
     });
 
     addMessageListener("browser-element-api:call", this);
 
-    let els = Cc["@mozilla.org/eventlistenerservice;1"]
-                .getService(Ci.nsIEventListenerService);
     LISTENED_SYSTEM_EVENTS.forEach(event => {
-      els.addSystemEventListener(global, event.type, this, event.useCapture);
+      Services.els.addSystemEventListener(global, event.type, this, event.useCapture);
     });
 
     OBSERVED_EVENTS.forEach((aTopic) => {
       Services.obs.addObserver(this, aTopic);
     });
   },
 
   /**
@@ -187,20 +187,18 @@ BrowserElementChild.prototype = {
             .removeProgressListener(this._progressListener);
 
     LISTENED_EVENTS.forEach(event => {
       removeEventListener(event.type, this, event.useCapture, event.wantsUntrusted);
     });
 
     removeMessageListener("browser-element-api:call", this);
 
-    let els = Cc["@mozilla.org/eventlistenerservice;1"]
-                .getService(Ci.nsIEventListenerService);
     LISTENED_SYSTEM_EVENTS.forEach(event => {
-      els.removeSystemEventListener(global, event.type, this, event.useCapture);
+      Services.els.removeSystemEventListener(global, event.type, this, event.useCapture);
     });
 
     OBSERVED_EVENTS.forEach((aTopic) => {
       Services.obs.removeObserver(this, aTopic);
     });
   },
 
   handleEvent(event) {
@@ -276,16 +274,17 @@ BrowserElementChild.prototype = {
       "owner-visibility-change": this._recvOwnerVisibilityChange,
       "entered-fullscreen": this._recvEnteredFullscreen,
       "exit-fullscreen": this._recvExitFullscreen,
     };
 
     if (message.data.msg_name in mmCalls) {
       return mmCalls[message.data.msg_name].apply(self, arguments);
     }
+    return undefined;
   },
 
   _paintFrozenTimer: null,
   observe(subject, topic, data) {
     // Ignore notifications not about our document.  (Note that |content| /can/
     // be null; see bug 874900.)
 
     if (topic !== "activity-done" &&
@@ -358,33 +357,34 @@ BrowserElementChild.prototype = {
 
     let returnValue = this._waitForResult(win);
 
     if (args.promptType == "prompt" ||
         args.promptType == "confirm" ||
         args.promptType == "custom-prompt") {
       return returnValue;
     }
+    return undefined;
   },
 
   /**
    * Spin in a nested event loop until we receive a unblock-modal-prompt message for
    * this window.
    */
   _waitForResult(win) {
     debug("_waitForResult(" + win + ")");
     let utils = win.windowUtils;
 
     let outerWindowID = utils.outerWindowID;
     let innerWindowID = this._tryGetInnerWindowID(win);
     if (innerWindowID === null) {
       // I have no idea what waiting for a result means when there's no inner
       // window, so let's just bail.
       debug("_waitForResult: No inner window. Bailing.");
-      return;
+      return undefined;
     }
 
     this._windowIDDict[outerWindowID] = Cu.getWeakReference(win);
 
     debug("Entering modal state (outerWindowID=" + outerWindowID + ", " +
                                 "innerWindowID=" + innerWindowID + ")");
 
     utils.enterModalState();
@@ -897,17 +897,17 @@ BrowserElementChild.prototype = {
   },
 
   _buildMenuObj(menu, idPrefix, copyableElements) {
     var menuObj = {type: "menu", customized: false, items: []};
     // Customized context menu
     if (menu) {
       this._maybeCopyAttribute(menu, menuObj, "label");
 
-      for (var i = 0, child; child = menu.children[i++];) {
+      for (var i = 0, child; (child = menu.children[i++]);) {
         if (child.nodeName === "MENU") {
           menuObj.items.push(this._buildMenuObj(child, idPrefix + i + "_", false));
         } else if (child.nodeName === "MENUITEM") {
           var id = this._ctxCounter + "_" + idPrefix + i;
           var menuitem = {id, type: "menuitem"};
           this._maybeCopyAttribute(child, menuitem, "label");
           this._maybeCopyAttribute(child, menuitem, "icon");
           this._ctxHandlers[id] = child;
@@ -1021,26 +1021,26 @@ BrowserElementChild.prototype = {
 
       // Ignore locationchange events which occur before the first loadstart.
       // These are usually about:blank loads we don't care about.
       if (!this._seenLoadStart) {
         return;
       }
 
       // Remove password from uri.
-      location = Cc["@mozilla.org/docshell/urifixup;1"]
-        .getService(Ci.nsIURIFixup).createExposableURI(location);
+      location = Services.uriFixup.createExposableURI(location);
 
       var webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
 
       sendAsyncMsg("locationchange", { url: location.spec,
                                        canGoBack: webNav.canGoBack,
                                        canGoForward: webNav.canGoForward });
     },
 
+    // eslint-disable-next-line complexity
     onStateChange(webProgress, request, stateFlags, status) {
       if (webProgress != docShell) {
         return;
       }
 
       if (stateFlags & Ci.nsIWebProgressListener.STATE_START) {
         this._seenLoadStart = true;
         sendAsyncMsg("loadstart");
--- a/dom/browser-element/BrowserElementCopyPaste.js
+++ b/dom/browser-element/BrowserElementCopyPaste.js
@@ -1,16 +1,24 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- /
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
+/*
+global addMessageListener
+global removeMessageListener
+global docShell
+global content
+global sendAsyncMsg
+*/
+
 function debug(msg) {
   // dump("BrowserElementCopyPaste - " + msg + "\n");
 }
 
 debug("loaded");
 
 var CopyPasteAssistent = {
   COMMAND_MAP: {
@@ -66,17 +74,17 @@ var CopyPasteAssistent = {
 
     return docShell.isCommandEnabled(command);
   },
 
   _caretStateChangedHandler(e) {
     e.stopPropagation();
 
     let boundingClientRect = e.boundingClientRect;
-    let canPaste = this._isCommandEnabled("paste");
+    this._isCommandEnabled("paste");
     let zoomFactor = content.innerWidth == 0 ? 1 : content.screen.width / content.innerWidth;
 
     let detail = {
       rect: {
         width: boundingClientRect ? boundingClientRect.width : 0,
         height: boundingClientRect ? boundingClientRect.height : 0,
         top: boundingClientRect ? boundingClientRect.top : 0,
         bottom: boundingClientRect ? boundingClientRect.bottom : 0,
--- a/dom/browser-element/BrowserElementParent.jsm
+++ b/dom/browser-element/BrowserElementParent.jsm
@@ -11,24 +11,16 @@
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {BrowserElementPromptService} = ChromeUtils.import("resource://gre/modules/BrowserElementPromptService.jsm");
 
 function debug(msg) {
   // dump("BrowserElementParent - " + msg + "\n");
 }
 
-function getIntPref(prefName, def) {
-  try {
-    return Services.prefs.getIntPref(prefName);
-  } catch (err) {
-    return def;
-  }
-}
-
 function handleWindowEvent(e) {
   if (this._browserElementParents) {
     let beps = ChromeUtils.nondeterministicGetWeakMapKeys(this._browserElementParents);
     beps.forEach(bep => bep._handleOwnerEvent(e));
   }
 }
 
 function defineNoReturnMethod(fn) {
@@ -91,21 +83,19 @@ BrowserElementParent.prototype = {
     // it reference a WeakMap whose keys are all the BrowserElementParent objects
     // on the window.  Then when the listener fires, we iterate over the
     // WeakMap's keys (which we can do, because we're chrome) to notify the
     // BrowserElementParents.
     if (!this._window._browserElementParents) {
       this._window._browserElementParents = new WeakMap();
       let handler = handleWindowEvent.bind(this._window);
       let windowEvents = ["visibilitychange", "fullscreenchange"];
-      let els = Cc["@mozilla.org/eventlistenerservice;1"]
-                  .getService(Ci.nsIEventListenerService);
       for (let event of windowEvents) {
-        els.addSystemEventListener(this._window, event, handler,
-                                   /* useCapture = */ true);
+        Services.els.addSystemEventListener(this._window, event, handler,
+                                            /* useCapture = */ true);
       }
     }
 
     this._window._browserElementParents.set(this, null);
 
     // Insert ourself into the prompt service.
     BrowserElementPromptService.mapFrameToBrowserElementParent(this._frameElement, this);
     this._setupMessageListener();
@@ -133,17 +123,17 @@ BrowserElementParent.prototype = {
 
   _setupMessageListener() {
     this._mm = this._frameLoader.messageManager;
     this._mm.addMessageListener("browser-element-api:call", this);
   },
 
   receiveMessage(aMsg) {
     if (!this._isAlive()) {
-      return;
+      return undefined;
     }
 
     // Messages we receive are handed to functions which take a (data) argument,
     // where |data| is the message manager's data object.
     // We use a single message and dispatch to various function based
     // on data.msg_name
     let mmCalls = {
       "hello": this._recvHello,
@@ -179,16 +169,17 @@ BrowserElementParent.prototype = {
       "opentab": this._fireEventFromMsg,
     };
 
     if (aMsg.data.msg_name in mmCalls) {
       return mmCalls[aMsg.data.msg_name].apply(this, arguments);
     } else if (aMsg.data.msg_name in mmSecuritySensitiveCalls) {
       return mmSecuritySensitiveCalls[aMsg.data.msg_name].apply(this, arguments);
     }
+    return undefined;
   },
 
   _removeMessageListener() {
     this._mm.removeMessageListener("browser-element-api:call", this);
   },
 
   /**
    * You shouldn't touch this._frameElement or this._window if _isAlive is
@@ -205,17 +196,16 @@ BrowserElementParent.prototype = {
   },
 
   get _windowUtils() {
     return this._window.windowUtils;
   },
 
   promptAuth(authDetail, callback) {
     let evt;
-    let self = this;
     let callbackCalled = false;
     let cancelCallback = function() {
       if (!callbackCalled) {
         callbackCalled = true;
         callback(false, null, null);
       }
     };
 
--- a/dom/browser-element/BrowserElementPromptService.jsm
+++ b/dom/browser-element/BrowserElementPromptService.jsm
@@ -289,18 +289,16 @@ BrowserElementAuthPrompt.prototype = {
       }
     }
 
     // Didn't find an available prompt, so just return.
     if (!hashKey)
       return;
 
     let prompt = this._asyncPrompts[hashKey];
-    let [hostname, httpRealm] = this._getAuthTarget(prompt.channel,
-                                                    prompt.authInfo);
 
     this._asyncPromptInProgress.set(prompt.browserElementParent, true);
     prompt.inProgress = true;
 
     let self = this;
     let callback = function(ok, username, password) {
       debug("Async auth callback is called, ok = " +
             ok + ", username = " + username);
@@ -565,26 +563,24 @@ var BrowserElementPromptService = {
 
   _init() {
     if (this._initialized) {
       return;
     }
 
     // If the pref is disabled, do nothing except wait for the pref to change.
     if (!this._browserFramesPrefEnabled()) {
-      var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-      prefs.addObserver(BROWSER_FRAMES_ENABLED_PREF, this, /* ownsWeak = */ true);
+      Services.prefs.addObserver(BROWSER_FRAMES_ENABLED_PREF, this, /* ownsWeak = */ true);
       return;
     }
 
     this._initialized = true;
     this._browserElementParentMap = new WeakMap();
 
-    var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
-    os.addObserver(this, "outer-window-destroyed", /* ownsWeak = */ true);
+    Services.obs.addObserver(this, "outer-window-destroyed", /* ownsWeak = */ true);
 
     // Wrap the existing @mozilla.org/prompter;1 implementation.
     var contractID = "@mozilla.org/prompter;1";
     var oldCID = Cm.contractIDToCID(contractID);
     var newCID = BrowserElementPromptFactory.prototype.classID;
     var oldFactory = Cm.getClassObject(Cc[contractID], Ci.nsIFactory);
 
     if (oldCID == newCID) {
@@ -639,22 +635,17 @@ var BrowserElementPromptService = {
 
   _observeOuterWindowDestroyed(outerWindowID) {
     let id = outerWindowID.QueryInterface(Ci.nsISupportsPRUint64).data;
     debug("observeOuterWindowDestroyed " + id);
     delete this._browserElementChildMap[outerWindowID.data];
   },
 
   _browserFramesPrefEnabled() {
-    var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-    try {
-      return prefs.getBoolPref(BROWSER_FRAMES_ENABLED_PREF);
-    } catch (e) {
-      return false;
-    }
+    return Services.prefs.getBoolPref(BROWSER_FRAMES_ENABLED_PREF, false);
   },
 
   observe(subject, topic, data) {
     switch (topic) {
     case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID:
       if (data == BROWSER_FRAMES_ENABLED_PREF) {
         this._init();
       }
--- a/dom/browser-element/mochitest/async.js
+++ b/dom/browser-element/mochitest/async.js
@@ -64,15 +64,15 @@
                 try {
                   step(gen.throw(error));
                 } catch (err) {
                   throw err;
                 }
               }
             ).catch(err => reject(err));
           }
-          step(gen.next(value));
+          return step(gen.next(value));
         }
       });
     };
   }
   exports.async = async;
 }(this || self));
--- a/dom/browser-element/mochitest/browserElement_Alert.js
+++ b/dom/browser-element/mochitest/browserElement_Alert.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that alert works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 var numPendingChildTests = 0;
 var iframe;
 var mm;
 
--- a/dom/browser-element/mochitest/browserElement_AlertInFrame.js
+++ b/dom/browser-element/mochitest/browserElement_AlertInFrame.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that alert works from inside an <iframe> inside an <iframe mozbrowser>.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_Auth.js
+++ b/dom/browser-element/mochitest/browserElement_Auth.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that auth prompt works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 const { NetUtil } = SpecialPowers.Cu.import("resource://gre/modules/NetUtil.jsm");
 
 function testFail(msg) {
   ok(false, JSON.stringify(msg));
@@ -32,19 +34,19 @@ function runTest() {
   }, {once: true});
 }
 
 function testHttpAuthCancel(e) {
   iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testHttpAuthCancel);
   // Will cancel authentication, but prompt should not be shown again. Instead,
   // we will be led to fail message
   iframe.addEventListener("mozbrowserusernameandpasswordrequired", testFail);
-  iframe.addEventListener("mozbrowsertitlechange", function(e) {
+  iframe.addEventListener("mozbrowsertitlechange", function(f) {
     iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFail);
-    is(e.detail, "http auth failed", "expected authentication to fail");
+    is(f.detail, "http auth failed", "expected authentication to fail");
     iframe.addEventListener("mozbrowserusernameandpasswordrequired", testHttpAuth);
     SimpleTest.executeSoon(function() {
       // Use absolute path because we need to specify host.
       iframe.src = "http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs";
     });
   }, {once: true});
 
   is(e.detail.realm, "http_realm", "expected realm matches");
@@ -60,48 +62,48 @@ function testHttpAuthCancel(e) {
 }
 
 function testHttpAuth(e) {
   iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testHttpAuth);
 
   // Will authenticate with correct password, prompt should not be
   // called again.
   iframe.addEventListener("mozbrowserusernameandpasswordrequired", testFail);
-  iframe.addEventListener("mozbrowsertitlechange", function(e) {
+  iframe.addEventListener("mozbrowsertitlechange", function(f) {
     iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFail);
-    is(e.detail, "http auth success", "expect authentication to succeed");
+    is(f.detail, "http auth success", "expect authentication to succeed");
     SimpleTest.executeSoon(testProxyAuth);
   }, {once: true});
 
   is(e.detail.realm, "http_realm", "expected realm matches");
   is(e.detail.host, "http://test", "expected host matches");
   is(e.detail.path,
      "/tests/dom/browser-element/mochitest/file_http_401_response.sjs",
      "expected path matches");
   is(e.detail.isProxy, false, "expected isProxy is false");
   e.preventDefault();
 
   SimpleTest.executeSoon(function() {
     e.detail.authenticate("httpuser", "httppass");
   });
 }
 
-function testProxyAuth(e) {
+function testProxyAuth() {
   // The testingSJS simulates the 407 proxy authentication required response
   // for proxy server, which will trigger the browser element to send prompt
   // event with proxy infomation.
   var testingSJS = "http://test/tests/dom/browser-element/mochitest/file_http_407_response.sjs";
   var mozproxy;
 
   function onUserNameAndPasswordRequired(e) {
     iframe.removeEventListener("mozbrowserusernameandpasswordrequired",
                                onUserNameAndPasswordRequired);
-    iframe.addEventListener("mozbrowsertitlechange", function(e) {
+    iframe.addEventListener("mozbrowsertitlechange", function(event) {
       iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFail);
-      is(e.detail, "http auth success", "expect authentication to succeed");
+      is(event.detail, "http auth success", "expect authentication to succeed");
       SimpleTest.executeSoon(testAuthJarNoInterfere);
     }, {once: true});
 
     is(e.detail.realm, "http_realm", "expected realm matches");
     is(e.detail.host, mozproxy, "expected host matches");
     is(e.detail.path,
        "/tests/dom/browser-element/mochitest/file_http_407_response.sjs",
        "expected path matches");
@@ -144,22 +146,20 @@ function testProxyAuth(e) {
 
   var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"]
             .getService();
 
   pps.asyncResolve(channel, 0, resolveCallback);
 }
 
 function testAuthJarNoInterfere(e) {
-  var authMgr = SpecialPowers.Cc["@mozilla.org/network/http-auth-manager;1"]
+  let authMgr = SpecialPowers.Cc["@mozilla.org/network/http-auth-manager;1"]
     .getService(SpecialPowers.Ci.nsIHttpAuthManager);
-  var secMan = SpecialPowers.Cc["@mozilla.org/scriptsecuritymanager;1"]
-               .getService(SpecialPowers.Ci.nsIScriptSecurityManager);
-  var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
-                  .getService(SpecialPowers.Ci.nsIIOService);
+  let secMan = SpecialPowers.Services.scriptSecurityManager;
+  let ioService = SpecialPowers.Services.io;
   var uri = ioService.newURI("http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs");
 
   // Set a bunch of auth data that should not conflict with the correct auth data already
   // stored in the cache.
   var attrs = {appId: 1};
   var principal = secMan.createCodebasePrincipal(uri, attrs);
   authMgr.setAuthIdentity("http", "test", -1, "basic", "http_realm",
                           "tests/dom/browser-element/mochitest/file_http_401_response.sjs",
@@ -172,72 +172,68 @@ function testAuthJarNoInterfere(e) {
   principal = secMan.createCodebasePrincipal(uri, {});
   authMgr.setAuthIdentity("http", "test", -1, "basic", "http_realm",
                           "tests/dom/browser-element/mochitest/file_http_401_response.sjs",
                           "", "httpuser", "wrongpass", false, principal);
 
   // Will authenticate with correct password, prompt should not be
   // called again.
   iframe.addEventListener("mozbrowserusernameandpasswordrequired", testFail);
-  iframe.addEventListener("mozbrowsertitlechange", function(e) {
+  iframe.addEventListener("mozbrowsertitlechange", function(f) {
     iframe.removeEventListener("mozbrowserusernameandpasswordrequired", testFail);
-    is(e.detail, "http auth success", "expected authentication success");
+    is(f.detail, "http auth success", "expected authentication success");
     SimpleTest.executeSoon(testAuthJarInterfere);
   }, {once: true});
 
   // Once more with feeling. Ensure that our new auth data doesn't interfere with this mozbrowser's
   // auth data.
   iframe.src = "http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs";
 }
 
 function testAuthJarInterfere(e) {
-  var authMgr = SpecialPowers.Cc["@mozilla.org/network/http-auth-manager;1"]
+  let authMgr = SpecialPowers.Cc["@mozilla.org/network/http-auth-manager;1"]
     .getService(SpecialPowers.Ci.nsIHttpAuthManager);
-  var secMan = SpecialPowers.Cc["@mozilla.org/scriptsecuritymanager;1"]
-               .getService(SpecialPowers.Ci.nsIScriptSecurityManager);
-  var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
-                  .getService(SpecialPowers.Ci.nsIIOService);
+  let secMan = SpecialPowers.Services.scriptSecurityManager;
+  let ioService = SpecialPowers.Services.io;
   var uri = ioService.newURI("http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs");
 
   // Set some auth data that should overwrite the successful stored details.
   var principal = secMan.createCodebasePrincipal(uri, {inIsolatedMozBrowser: true});
   authMgr.setAuthIdentity("http", "test", -1, "basic", "http_realm",
                           "tests/dom/browser-element/mochitest/file_http_401_response.sjs",
                           "", "httpuser", "wrongpass", false, principal);
 
   // Will authenticate with correct password, prompt should not be
   // called again.
   var gotusernamepasswordrequired = false;
   function onUserNameAndPasswordRequired() {
       gotusernamepasswordrequired = true;
   }
   iframe.addEventListener("mozbrowserusernameandpasswordrequired",
                           onUserNameAndPasswordRequired);
-  iframe.addEventListener("mozbrowsertitlechange", function(e) {
+  iframe.addEventListener("mozbrowsertitlechange", function(f) {
     iframe.removeEventListener("mozbrowserusernameandpasswordrequired",
                                onUserNameAndPasswordRequired);
     ok(gotusernamepasswordrequired,
        "Should have dispatched mozbrowserusernameandpasswordrequired event");
     testFinish();
   }, {once: true});
 
   // Once more with feeling. Ensure that our new auth data interferes with this mozbrowser's
   // auth data.
   iframe.src = "http://test/tests/dom/browser-element/mochitest/file_http_401_response.sjs";
 }
 
 function testFinish() {
   // Clear login information stored in password manager.
-  var authMgr = SpecialPowers.Cc["@mozilla.org/network/http-auth-manager;1"]
+  let authMgr = SpecialPowers.Cc["@mozilla.org/network/http-auth-manager;1"]
     .getService(SpecialPowers.Ci.nsIHttpAuthManager);
   authMgr.clearAll();
 
-  var pwmgr = SpecialPowers.Cc["@mozilla.org/login-manager;1"]
-    .getService(SpecialPowers.Ci.nsILoginManager);
-  pwmgr.removeAllLogins();
+  SpecialPowers.Services.logins.removeAllLogins();
 
   SimpleTest.finish();
 }
 
 addEventListener("testready", function() {
   // Enable http authentiication.
   SpecialPowers.pushPrefEnv({"set": [["network.auth.non-web-content-triggered-resources-http-auth-allow", true]]}, runTest);
 });
--- a/dom/browser-element/mochitest/browserElement_BackForward.js
+++ b/dom/browser-element/mochitest/browserElement_BackForward.js
@@ -1,15 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 741755 - Test that canGo{Back,Forward} and go{Forward,Back} work with
 // <iframe mozbrowser>.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 
 var iframe;
 function addOneShotIframeEventListener(event, fn) {
   function wrapper(e) {
     iframe.removeEventListener(event, wrapper);
     fn(e);
--- a/dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js
+++ b/dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js
@@ -2,50 +2,52 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 780351 - Test that mozbrowser does /not/ divide the window name namespace.
 // Multiple mozbrowsers inside the same app are like multiple browser tabs;
 // they share a window name namespace.
 
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe1 = document.createElement("iframe");
   iframe1.setAttribute("mozbrowser", "true");
 
   // Two mozbrowser frames with the same code both do the same
   // window.open("foo", "bar") call.  We should only get one
   // mozbrowseropenwindow event.
 
   iframe1.addEventListener("mozbrowseropenwindow", function(e) {
     ok(true, "Got first mozbrowseropenwindow event.");
     document.body.appendChild(e.detail.frameElement);
 
-    e.detail.frameElement.addEventListener("mozbrowserlocationchange", function(e) {
-      if (e.detail.url == "http://example.com/#2") {
+    e.detail.frameElement.addEventListener("mozbrowserlocationchange", function(f) {
+      if (f.detail.url == "http://example.com/#2") {
         ok(true, "Got locationchange to http://example.com/#2");
         SimpleTest.finish();
       } else {
-        ok(true, "Got locationchange to " + e.detail.url);
+        ok(true, "Got locationchange to " + f.detail.url);
       }
     });
 
     SimpleTest.executeSoon(function() {
       var iframe2 = document.createElement("iframe");
       // Make sure that iframe1 and iframe2 are in the same TabGroup by linking
       // them through opener. Right now this API requires chrome privileges, as
       // it is on MozFrameLoaderOwner.
       SpecialPowers.wrap(iframe2).presetOpenerWindow(iframe1.contentWindow);
       iframe2.setAttribute("mozbrowser", "true");
 
-      iframe2.addEventListener("mozbrowseropenwindow", function(e) {
+      iframe2.addEventListener("mozbrowseropenwindow", function(f) {
         ok(false, "Got second mozbrowseropenwindow event.");
       });
 
       document.body.appendChild(iframe2);
       iframe2.src = "file_browserElement_BrowserWindowNamespace.html#2";
     });
   });
 
--- a/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js
+++ b/dom/browser-element/mochitest/browserElement_BrowserWindowResize.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 891763 - Test the mozbrowserresize event
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var srcResizeTo = "data:text/html,       \
     <script type='application/javascript'> \
--- a/dom/browser-element/mochitest/browserElement_Close.js
+++ b/dom/browser-element/mochitest/browserElement_Close.js
@@ -1,25 +1,27 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that window.close() works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
   document.body.appendChild(iframe);
 
   iframe.addEventListener("mozbrowserclose", function(e) {
     ok(true, "got mozbrowserclose event.");
     SimpleTest.finish();
   });
 
-  iframe.src = "data:text/html,<html><body><script>window.close()</scr" + "ipt></body></html>";
+  iframe.src = "data:text/html,<html><body><script>window.close()</script></body></html>";
 }
 
 addEventListener("testready", runTest);
--- a/dom/browser-element/mochitest/browserElement_CloseFromOpener.js
+++ b/dom/browser-element/mochitest/browserElement_CloseFromOpener.js
@@ -1,27 +1,29 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 764718 - Test that window.close() works from the opener window.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
   iframe.addEventListener("mozbrowseropenwindow", function(e) {
     ok(true, "got openwindow event.");
     document.body.appendChild(e.detail.frameElement);
 
-    e.detail.frameElement.addEventListener("mozbrowserclose", function(e) {
+    e.detail.frameElement.addEventListener("mozbrowserclose", function(f) {
       ok(true, "got mozbrowserclose event.");
       SimpleTest.finish();
     });
   });
 
 
   document.body.appendChild(iframe);
 
--- a/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
+++ b/dom/browser-element/mochitest/browserElement_ContextmenuEvents.js
@@ -1,10 +1,13 @@
 "use strict";
 
+/* global browserElementTestHelpers */
+/* eslint-env mozilla/frame-script */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.setClipboardPlainTextOnlyPref(false);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 var audioUrl = "http://mochi.test:8888/tests/dom/browser-element/mochitest/audio.ogg";
 var videoUrl = "http://mochi.test:8888/tests/dom/browser-element/mochitest/short-video.ogv";
--- a/dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js
+++ b/dom/browser-element/mochitest/browserElement_CookiesNotThirdParty.js
@@ -1,15 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 806127 - Test that cookies set by <iframe mozbrowser> are not considered
 // third-party.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   const innerPage = "http://example.com/tests/dom/browser-element/mochitest/file_browserElement_CookiesNotThirdParty.html";
 
   var iframe = document.createElement("iframe");
--- a/dom/browser-element/mochitest/browserElement_CopyPaste.js
+++ b/dom/browser-element/mochitest/browserElement_CopyPaste.js
@@ -1,21 +1,22 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that "cut, copy, paste, selectall" and caretstatechanged event works from inside an <iframe mozbrowser>.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.setupAccessibleCaretPref();
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
-const { Services } = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm");
 
 var gTextarea = null;
 var mm;
 var iframeOuter;
 var iframeInner;
 var state = 0;
 var stateMeaning;
 var defaultData;
@@ -67,19 +68,19 @@ function runTest() {
     if (createEmbededFrame) {
       var contentWin = SpecialPowers.wrap(iframeOuter)
                              .frameLoader.docShell.contentViewer.DOMDocument.defaultView;
       var contentDoc = contentWin.document;
       iframeInner = contentDoc.createElement("iframe");
       iframeInner.setAttribute("mozbrowser", true);
       iframeInner.setAttribute("remote", "false");
       contentDoc.body.appendChild(iframeInner);
-      iframeInner.addEventListener("mozbrowserloadend", function(e) {
+      iframeInner.addEventListener("mozbrowserloadend", function(f) {
         mm = SpecialPowers.getBrowserFrameMessageManager(iframeInner);
-        dispatchTest(e);
+        dispatchTest(f);
       }, {once: true});
     } else {
       iframeInner = iframeOuter;
       mm = SpecialPowers.getBrowserFrameMessageManager(iframeInner);
       dispatchTest(e);
     }
   }, {once: true});
 }
@@ -91,19 +92,19 @@ function doCommand(cmd) {
     "paste": "cmd_paste",
     "selectall": "cmd_selectAll",
   };
   var script = 'data:,docShell.doCommand("' + COMMAND_MAP[cmd] + '");';
   mm.loadFrameScript(script, false);
 }
 
 function dispatchTest(e) {
-  iframeInner.addEventListener("mozbrowserloadend", function(e) {
+  iframeInner.addEventListener("mozbrowserloadend", function(f) {
     iframeInner.focus();
-    SimpleTest.executeSoon(function() { testSelectAll(e); });
+    SimpleTest.executeSoon(function() { testSelectAll(f); });
   }, {once: true});
 
   switch (state) {
     case 0: // test for textarea
       defaultData = "Test for selection change event";
       pasteData = "from parent ";
       iframeInner.src = "data:text/html,<html><body>" +
                    "<textarea id='text'>" + defaultData + "</textarea>" +
@@ -175,31 +176,30 @@ function dispatchTest(e) {
         state = 0;
         runTest();
       }
       break;
   }
 }
 
 function isChildProcess() {
-  return SpecialPowers.Cc["@mozilla.org/xre/app-info;1"]
-                         .getService(SpecialPowers.Ci.nsIXULRuntime)
-                         .processType != SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
+  return SpecialPowers.Services.appinfo
+                      .processType != SpecialPowers.Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 }
 
 function testSelectAll(e) {
   // Skip mozbrowser test if we're at child process.
   if (!isChildProcess()) {
     let eventName = "mozbrowsercaretstatechanged";
-    iframeOuter.addEventListener(eventName, function(e) {
+    iframeOuter.addEventListener(eventName, function(f) {
       ok(true, "got mozbrowsercaretstatechanged event." + stateMeaning);
-      ok(e.detail, "event.detail is not null." + stateMeaning);
-      ok(e.detail.width != 0, "event.detail.width is not zero" + stateMeaning);
-      ok(e.detail.height != 0, "event.detail.height is not zero" + stateMeaning);
-      SimpleTest.executeSoon(function() { testCopy1(e); });
+      ok(f.detail, "event.detail is not null." + stateMeaning);
+      ok(f.detail.width != 0, "event.detail.width is not zero" + stateMeaning);
+      ok(f.detail.height != 0, "event.detail.height is not zero" + stateMeaning);
+      SimpleTest.executeSoon(function() { testCopy1(f); });
     }, {capture: true, once: true});
   }
 
   mm.addMessageListener("content-focus", function messageforfocus(msg) {
     mm.removeMessageListener("content-focus", messageforfocus);
     // test selectall command, after calling this the caretstatechanged event should be fired.
     doCommand("selectall");
     if (isChildProcess()) {
@@ -331,9 +331,8 @@ var context = { url: SpecialPowers.wrap(
                   appId: principal.appId,
                   inIsolatedMozBrowser: true }};
 
 addEventListener("testready", function() {
   SpecialPowers.pushPermissions([
     {type: "browser", allow: 1, context},
   ], runTest);
 });
-
--- a/dom/browser-element/mochitest/browserElement_DataURI.js
+++ b/dom/browser-element/mochitest/browserElement_DataURI.js
@@ -1,14 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that data: URIs work with mozbrowserlocationchange events.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe1 = document.createElement("iframe");
   iframe1.setAttribute("mozbrowser", "true");
--- a/dom/browser-element/mochitest/browserElement_DataURILoad.js
+++ b/dom/browser-element/mochitest/browserElement_DataURILoad.js
@@ -1,12 +1,15 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("testing mozbrowser data: navigation is blocked");
 
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 // make sure top level data: URI navigations are blocked.
 const PREF = "security.data_uri.block_toplevel_data_uri_navigations";
--- a/dom/browser-element/mochitest/browserElement_DocumentFirstPaint.js
+++ b/dom/browser-element/mochitest/browserElement_DocumentFirstPaint.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 829486 - Add mozdocumentbrowserfirstpaint event.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 
 var iframe;
 
 function runTestQueue(queue) {
   if (queue.length == 0) {
     SimpleTest.finish();
--- a/dom/browser-element/mochitest/browserElement_ErrorSecurity.js
+++ b/dom/browser-element/mochitest/browserElement_ErrorSecurity.js
@@ -1,15 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 764718 - Test that mozbrowsererror works for a security error.
 
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 var iframe = null;
 function runTest() {
   iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
--- a/dom/browser-element/mochitest/browserElement_ExposableURI.js
+++ b/dom/browser-element/mochitest/browserElement_ExposableURI.js
@@ -1,15 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 795317: Test that the browser element sanitizes its URIs by removing the
 // "unexposable" parts before sending them in the locationchange event.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 var iframe;
 
 function testPassword() {
   function locationchange(e) {
--- a/dom/browser-element/mochitest/browserElement_FirstPaint.js
+++ b/dom/browser-element/mochitest/browserElement_FirstPaint.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 787378 - Add mozbrowserfirstpaint event.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_ForwardName.js
+++ b/dom/browser-element/mochitest/browserElement_ForwardName.js
@@ -1,16 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 781320 - Test that the name in <iframe mozbrowser name="foo"> is
 // forwarded down to remote mozbrowsers.
 
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
   iframe.setAttribute("name", "foo");
--- a/dom/browser-element/mochitest/browserElement_FrameWrongURI.js
+++ b/dom/browser-element/mochitest/browserElement_FrameWrongURI.js
@@ -1,14 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 804446 - Test that window.open(javascript:..) works with <iframe mozbrowser>.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframeJS = document.createElement("iframe");
   iframeJS.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_Iconchange.js
+++ b/dom/browser-element/mochitest/browserElement_Iconchange.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the onmozbrowsericonchange event works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function createHtml(link) {
   return "data:text/html,<html><head>" + link + "<body></body></html>";
 }
--- a/dom/browser-element/mochitest/browserElement_LoadEvents.js
+++ b/dom/browser-element/mochitest/browserElement_LoadEvents.js
@@ -1,15 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that an iframe with the |mozbrowser| attribute emits mozbrowserloadX
 // events when this page is in the whitelist.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   // Load emptypage1 into the iframe, wait for that to finish loading, then
   // call runTest2.
   //
--- a/dom/browser-element/mochitest/browserElement_Metachange.js
+++ b/dom/browser-element/mochitest/browserElement_Metachange.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the onmozbrowsermetachange event works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function createHtml(meta) {
   return 'data:text/html,<html xmlns:xml="http://www.w3.org/XML/1998/namespace"><head>' + meta + "<body></body></html>";
 }
--- a/dom/browser-element/mochitest/browserElement_OpenNamed.js
+++ b/dom/browser-element/mochitest/browserElement_OpenNamed.js
@@ -1,15 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 742944 - In <iframe mozbrowser>, test that if we call window.open twice
 // with the same name, we get only one mozbrowseropenwindow event.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 var iframe;
 var popupFrame;
 function runTest() {
   iframe = document.createElement("iframe");
@@ -18,19 +21,19 @@ function runTest() {
   var gotPopup = false;
   iframe.addEventListener("mozbrowseropenwindow", function(e) {
     is(gotPopup, false, "Should get just one popup.");
     gotPopup = true;
     popupFrame = e.detail.frameElement;
     is(popupFrame.getAttribute("name"), "OpenNamed");
 
     // Called when file_browserElement_OpenNamed2.html loads into popupFrame.
-    popupFrame.addEventListener("mozbrowsershowmodalprompt", function(e) {
+    popupFrame.addEventListener("mozbrowsershowmodalprompt", function(f) {
       ok(gotPopup, "Got openwindow event before showmodalprompt event.");
-      is(e.detail.message, "success: loaded");
+      is(f.detail.message, "success: loaded");
       SimpleTest.executeSoon(test2);
     }, {once: true});
 
     document.body.appendChild(popupFrame);
   });
 
   // OpenNamed.html will call
   //
--- a/dom/browser-element/mochitest/browserElement_OpenTab.js
+++ b/dom/browser-element/mochitest/browserElement_OpenTab.js
@@ -1,14 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 1144015 - test middle/ctrl/cmd-click on a link.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   let iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
   document.body.appendChild(iframe);
--- a/dom/browser-element/mochitest/browserElement_OpenWindow.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindow.js
@@ -1,14 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 742944 - Test that window.open works with <iframe mozbrowser>.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_OpenWindowDifferentOrigin.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowDifferentOrigin.js
@@ -1,31 +1,34 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 769182 - window.open to a different origin should load the page.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
   iframe.addEventListener("mozbrowseropenwindow", function(e) {
     ok(true, "Got first window.open call");
 
-    e.detail.frameElement.addEventListener("mozbrowseropenwindow", function(e) {
+    e.detail.frameElement.addEventListener("mozbrowseropenwindow", function(f) {
       ok(true, "Got second window.open call");
-      document.body.appendChild(e.detail.frameElement);
+      document.body.appendChild(f.detail.frameElement);
     });
 
-    e.detail.frameElement.addEventListener("mozbrowsershowmodalprompt", function(e) {
+    e.detail.frameElement.addEventListener("mozbrowsershowmodalprompt", function(f) {
       ok(true, "Got alert from second window.");
       SimpleTest.finish();
     });
 
     document.body.appendChild(e.detail.frameElement);
   });
 
   // DifferentOrigin.html?1 calls
--- a/dom/browser-element/mochitest/browserElement_OpenWindowEmpty.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowEmpty.js
@@ -1,15 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 1216937 - Test that window.open with null/empty URL should use
 // about:blank as default
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_OpenWindowInFrame.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowInFrame.js
@@ -5,16 +5,19 @@
 //
 // This is basically the same as browserElement_OpenWindow, except that instead
 // of loading file_browserElement_Open1.html directly inside the <iframe
 // mozbrowser>, we load file_browserElement_OpenWindowInFrame.html into the
 // mozbrowser.  OpenWindowInFrame loads file_browserElement_Open1.html inside
 // an iframe.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_OpenWindowRejected.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowRejected.js
@@ -1,15 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 742944 - Do window.open from inside <iframe mozbrowser>.  But then
 // reject the call.  This shouldn't cause problems (crashes, leaks).
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_OpenWindowRejected2.js
+++ b/dom/browser-element/mochitest/browserElement_OpenWindowRejected2.js
@@ -4,16 +4,19 @@
 // Bug 742944 - Do window.open from inside <iframe mozbrowser>.  But then
 // reject the call.  This shouldn't cause problems (crashes, leaks).
 //
 // This is the same as OpenWindowRejected, except we "reject" the popup by not
 // adding the iframe element to our DOM, instead of by not calling
 // preventDefault() on the event.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_Opensearch.js
+++ b/dom/browser-element/mochitest/browserElement_Opensearch.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the onmozbrowseropensearch event works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function createHtml(link) {
   return "data:text/html,<html><head>" + link + "<body></body></html>";
 }
--- a/dom/browser-element/mochitest/browserElement_PrivateBrowsing.js
+++ b/dom/browser-element/mochitest/browserElement_PrivateBrowsing.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the mozprivatebrowsing attribute works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function createFrame(aIsPrivate) {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
   if (aIsPrivate) {
--- a/dom/browser-element/mochitest/browserElement_PromptCheck.js
+++ b/dom/browser-element/mochitest/browserElement_PromptCheck.js
@@ -5,16 +5,18 @@
 // alerts), promptCheck, and confirmCheck work.  We do this by spamming
 // alerts/prompts/confirms from inside an <iframe mozbrowser>.
 //
 // At the moment, we treat alertCheck/promptCheck/confirmCheck just like a
 // normal alert.  But it's different to nsIPrompt!
 
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
@@ -32,26 +34,28 @@ function runTest() {
     }
 
     numPrompts++;
     if (numPrompts == 30) {
       SimpleTest.finish();
     }
   });
 
+  /* eslint-disable no-useless-concat */
   iframe.src =
     'data:text/html,<html><body><script>\
       addEventListener("load", function() { \
        setTimeout(function() { \
         var i = 0; \
         for (; i < 10; i++) { alert(i); } \
         for (; i < 20; i++) { confirm(i); } \
         for (; i < 30; i++) { prompt(i); } \
        }); \
      }); \
      </scr' + "ipt></body></html>";
+   /* eslint-enable no-useless-concat */
 }
 
 // The test harness sets dom.successive_dialog_time_limit to 0 for some bizarre
 // reason.  That's not normal usage, and it keeps us from testing alertCheck!
 addEventListener("testready", function() {
   SpecialPowers.pushPrefEnv({"set": [["dom.successive_dialog_time_limit", 10]]}, runTest);
 });
--- a/dom/browser-element/mochitest/browserElement_PromptConfirm.js
+++ b/dom/browser-element/mochitest/browserElement_PromptConfirm.js
@@ -3,16 +3,18 @@
 
 // Test that prompt and confirm work.  In particular, we're concerned that we
 // get correct return values out of them.
 //
 // We use alert() to communicate the return values of prompt/confirm back to
 // ourselves.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
@@ -63,24 +65,26 @@ function runTest() {
          "expected rv for msg " + curPrompt.msg);
 
       if (prompts.length == 0) {
         SimpleTest.finish();
       }
     }
   });
 
+  /* eslint-disable no-useless-concat */
   iframe.src =
     'data:text/html,<html><body><script>\
       function sendVal(val) { \
         alert("RESULT:" + val); \
       } \
       sendVal(alert("1")); \
       sendVal(confirm("2")); \
       sendVal(confirm("3")); \
       sendVal(confirm("4")); \
       sendVal(prompt("5", "initial")); \
       sendVal(prompt("6", "initial")); \
       sendVal(prompt("7", "initial")); \
     </scr' + "ipt></body></html>";
+  /* eslint-enable no-useless-concat */
 }
 
 addEventListener("testready", runTest);
--- a/dom/browser-element/mochitest/browserElement_Reload.js
+++ b/dom/browser-element/mochitest/browserElement_Reload.js
@@ -1,14 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 741717 - Test the reload ability of <iframe mozbrowser>.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+/* eslint-env mozilla/frame-script */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 var iframeScript = function() {
   sendAsyncMessage("test:innerHTML", {
     data: XPCNativeWrapper.unwrap(content).document.body.innerHTML,
   });
--- a/dom/browser-element/mochitest/browserElement_ReloadPostRequest.js
+++ b/dom/browser-element/mochitest/browserElement_ReloadPostRequest.js
@@ -1,31 +1,32 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 793644, fire an event when attempting to reloads browser element after
 // POST respest.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 browserElementTestHelpers.setEnabledPref(true);
 
 var iframe;
 var gotConfirmRepost = false;
 var doRepost = true;
 var timer;
 var isPostRequestSubmitted;
 
 function getExpectedStrings() {
   let result = {};
-  let bundleService = SpecialPowers.Cc["@mozilla.org/intl/stringbundle;1"].
-    getService(SpecialPowers.Ci.nsIStringBundleService);
-  let appBundle = bundleService.createBundle("chrome://global/locale/appstrings.properties");
-  let brandBundle = bundleService.createBundle("chrome://branding/locale/brand.properties");
+  let appBundle = Services.strings.createBundle("chrome://global/locale/appstrings.properties");
+  let brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
   try {
     let brandName = brandBundle.GetStringFromName("brandShortName");
     result.message = appBundle.formatStringFromName("confirmRepostPrompt",
                                                     [brandName], 1);
   } catch (e) {
     // for the case that we don't have brandShortName
     result.message = appBundle.GetStringFromName("confirmRepostPrompt");
   }
--- a/dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js
+++ b/dom/browser-element/mochitest/browserElement_RemoveBrowserElement.js
@@ -1,16 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 787517: Remove iframe in the handler of showmodalprompt. This shouldn't
 // cause an exception to be thrown.
 
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
--- a/dom/browser-element/mochitest/browserElement_ScrollEvent.js
+++ b/dom/browser-element/mochitest/browserElement_ScrollEvent.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that scroll event bubbles up.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
--- a/dom/browser-element/mochitest/browserElement_SecurityChange.js
+++ b/dom/browser-element/mochitest/browserElement_SecurityChange.js
@@ -1,15 +1,18 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 763694 - Test that <iframe mozbrowser> delivers proper
 // mozbrowsersecuritychange events.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
@@ -50,9 +53,8 @@ function runTest() {
 }
 
 addEventListener("testready", function() {
   SpecialPowers.pushPrefEnv({"set": [
     ["browser.safebrowsing.phishing.enabled", false],
     ["browser.safebrowsing.malware.enabled", false],
   ]}, runTest);
 });
-
--- a/dom/browser-element/mochitest/browserElement_SendEvent.js
+++ b/dom/browser-element/mochitest/browserElement_SendEvent.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that sendMouseEvent dispatch events.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
   document.body.appendChild(iframe);
   var x = 10;
--- a/dom/browser-element/mochitest/browserElement_Stop.js
+++ b/dom/browser-element/mochitest/browserElement_Stop.js
@@ -4,16 +4,19 @@
 // Bug 709759 - Test the stop ability of <iframe mozbrowser>.
 
 // The img that is loaded will never be returned and will block
 // the page from loading, the timeout ensures that the page is
 // actually blocked from loading, once stop is called the
 // image load will be cancaelled and mozbrowserloadend should be called.
 
 "use strict";
+
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 browserElementTestHelpers.setEnabledPref(true);
 
 var iframe;
 var stopped = false;
 var imgSrc = "http://test/tests/dom/browser-element/mochitest/file_bug709759.sjs";
 
--- a/dom/browser-element/mochitest/browserElement_TargetBlank.js
+++ b/dom/browser-element/mochitest/browserElement_TargetBlank.js
@@ -1,15 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 764718 - Test that clicking a link with _target=blank works.
 
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_TargetTop.js
+++ b/dom/browser-element/mochitest/browserElement_TargetTop.js
@@ -1,15 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 771273 - Check that window.open(url, '_top') works properly with <iframe
 // mozbrowser>.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_ThemeColor.js
+++ b/dom/browser-element/mochitest/browserElement_ThemeColor.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the onmozbrowsermetachange event for theme-color works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   function loadFrameScript(script) {
     SpecialPowers.getBrowserFrameMessageManager(iframe1)
                  .loadFrameScript("data:," + script,
@@ -77,9 +79,8 @@ function runTest() {
         ok(false, "Too many metachange events.");
         break;
       }
     }
   }
 }
 
 window.addEventListener("testready", runTest);
-
--- a/dom/browser-element/mochitest/browserElement_Titlechange.js
+++ b/dom/browser-element/mochitest/browserElement_Titlechange.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the onmozbrowsertitlechange event works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 function runTest() {
   var iframe1 = document.createElement("iframe");
   iframe1.setAttribute("mozbrowser", "true");
--- a/dom/browser-element/mochitest/browserElement_TopBarrier.js
+++ b/dom/browser-element/mochitest/browserElement_TopBarrier.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that an <iframe mozbrowser> is a window.{top,parent,frameElement} barrier.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.allowTopLevelDataURINavigation();
 
 var iframe;
 function runTest() {
   iframe = document.createElement("iframe");
--- a/dom/browser-element/mochitest/browserElement_Viewmode.js
+++ b/dom/browser-element/mochitest/browserElement_Viewmode.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that the onmozbrowsermetachange event for viewmode works.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   function loadFrameScript(script) {
     SpecialPowers.getBrowserFrameMessageManager(iframe1)
                  .loadFrameScript("data:," + script,
@@ -63,9 +65,8 @@ function runTest() {
         ok(false, "Too many metachange events.");
         break;
       }
     }
   }
 }
 
 window.addEventListener("testready", runTest);
-
--- a/dom/browser-element/mochitest/browserElement_XFrameOptions.js
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptions.js
@@ -1,15 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 770239 - Test that we can load pages with X-Frame-Options: Deny inside
 // <iframe mozbrowser>.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/browserElement_XFrameOptionsAllowFrom.js
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptionsAllowFrom.js
@@ -1,14 +1,16 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 690168 - Support Allow-From notation for X-Frame-Options header.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 var initialScreenshotArrayBuffer = null;
 
 function arrayBuffersEqual(a, b) {
   var x = new Int8Array(a);
@@ -22,18 +24,16 @@ function arrayBuffersEqual(a, b) {
       return false;
     }
   }
 
   return true;
 }
 
 function runTest() {
-  var count = 0;
-
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
   iframe.height = "1000px";
 
   var step1, stepfinish;
   // The innermost page we load will fire an alert when it successfully loads.
   iframe.addEventListener("mozbrowsershowmodalprompt", function(e) {
     switch (e.detail.message) {
--- a/dom/browser-element/mochitest/browserElement_XFrameOptionsDeny.js
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptionsDeny.js
@@ -1,15 +1,17 @@
 /* Any copyright is dedicated to the public domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 770239 - Test that X-Frame-Options will correctly block a page inside a
 // subframe of <iframe mozbrowser>.
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 var initialScreenshotArrayBuffer;
 
 function arrayBuffersEqual(a, b) {
   var x = new Int8Array(a);
--- a/dom/browser-element/mochitest/browserElement_XFrameOptionsSameOrigin.js
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptionsSameOrigin.js
@@ -2,16 +2,18 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Bug 770239 - Load an X-Frame-Options: SAMEORIGIN page inside an <iframe>
 // inside <iframe mozbrowser>.  The two iframes will have the same origin, but
 // this page will be of a different origin.  The load should succeed.
 
 "use strict";
 
+/* global browserElementTestHelpers */
+
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 
 function runTest() {
   var iframe = document.createElement("iframe");
   iframe.setAttribute("mozbrowser", "true");
 
--- a/dom/browser-element/mochitest/file_browserElement_FrameWrongURI.html
+++ b/dom/browser-element/mochitest/file_browserElement_FrameWrongURI.html
@@ -1,5 +1,6 @@
 <script>
   function testSucceeded() { alert("success"); }
+  // eslint-disable-next-line no-useless-concat
   function callback() { return "<script>opener.testSucceeded()</" + "script>"; }
   var w = window.open("javascript:opener.callback();");
 </script>
--- a/dom/browser-element/mochitest/file_browserElement_LoadEvents.html
+++ b/dom/browser-element/mochitest/file_browserElement_LoadEvents.html
@@ -2,13 +2,14 @@
 <body style="background-color:green;">
 
 <!-- Tests rely on the fact that there's an element in here called 'url' and
      that there's visible text on the page. -->
 
 Aloha!  My URL is <span id='url'></span>.
 
 <script>
+// eslint-disable-next-line no-unsanitized/property
 document.getElementById("url").innerHTML = window.location;
 </script>
 
 </body>
 </html>
--- a/dom/browser-element/mochitest/file_browserElement_OpenWindowDifferentOrigin.html
+++ b/dom/browser-element/mochitest/file_browserElement_OpenWindowDifferentOrigin.html
@@ -5,13 +5,14 @@
 
 <script>
 if (location.search == "?1") {
   open("http://example.com/tests/dom/browser-element/mochitest/file_browserElement_OpenWindowDifferentOrigin.html?2");
 } else if (location.search == "?2") {
   alert("finish");
 }
 
+// eslint-disable-next-line no-unsanitized/property
 document.getElementById("name").innerHTML = location.search;
 </script>
 
 </body>
 </html>
--- a/dom/browser-element/mochitest/file_browserElement_TargetTop.html
+++ b/dom/browser-element/mochitest/file_browserElement_TargetTop.html
@@ -1,12 +1,13 @@
 <html>
 <body>
 <div id='url'></div>
 
 <script>
 if (location.search == "") {
   window.open("file_browserElement_TargetTop.html?2", "_top");
 }
+// eslint-disable-next-line no-unsanitized/property
 document.getElementById("url").innerHTML = document.location.href;
 </script>
 </body>
 </html>
--- a/dom/browser-element/mochitest/file_browserElement_XFrameOptionsAllowFrom.html
+++ b/dom/browser-element/mochitest/file_browserElement_XFrameOptionsAllowFrom.html
@@ -18,19 +18,17 @@ var iframe1 = document.createElement("if
 iframe1.height = "300px";
 var iframe2 = document.createElement("iframe");
 iframe2.height = "300px";
 document.body.appendChild(iframe1);
 
 iframe1.addEventListener("load", function() {
   // This causes our embedder to take a screenshot (and blocks until the
   // screenshot is completed).
-  var iframe2Loaded = false;
   iframe2.addEventListener("load", function() {
-    iframe2Loaded = true;
     alert("finish");
   }, {once: true});
 
   document.body.appendChild(iframe2);
   iframe2.src = frame_src;
 }, {once: true});
 
 
--- a/dom/browser-element/mochitest/file_empty.html
+++ b/dom/browser-element/mochitest/file_empty.html
@@ -2,13 +2,14 @@
 <body>
 
 <!-- Tests rely on the fact that there's an element in here called 'url' and
      that there's visible text on the page. -->
 
 Aloha!  My URL is <span id='url'></span>.
 
 <script>
+// eslint-disable-next-line no-unsanitized/property
 document.getElementById("url").innerHTML = window.location;
 </script>
 
 </body>
 </html>
--- a/dom/browser-element/mochitest/file_focus.html
+++ b/dom/browser-element/mochitest/file_focus.html
@@ -1,24 +1,24 @@
 <html>
 <body>
 
 Aloha!  My URL is <span id='url'></span>.
 <script>
+// eslint-disable-next-line no-unsanitized/property
 document.getElementById("url").innerHTML = window.location;
 </script>
 
 <script>
   // The input element is getting synthesized key events and will prevent
   // default on the first ESC keydown event.
 
   var alreadyBlocked = false;
 
   addEventListener("keydown", function(e) {
-    if (e.keyCode == KeyboardEvent.DOM_VK_ESCAPE &&
-        alreadyBlocked == false) {
+    if (e.keyCode == KeyboardEvent.DOM_VK_ESCAPE && !alreadyBlocked) {
       alreadyBlocked = true;
       e.preventDefault();
     }
   });
 </script>
 </body>
 </html>
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js
@@ -5,16 +5,17 @@ module.exports = {
   "env": {
     "browser": true,
   },
 
   // All globals made available in the test environment.
   "globals": {
     // SpecialPowers is injected into the window object via SimpleTest.js
     "SpecialPowers": false,
+    "XPCNativeWrapper": false,
   },
 
   "overrides": [{
     "env": {
       // Ideally we wouldn't be using the simpletest env here, but our uses of
       // js files mean we pick up everything from the global scope, which could
       // be any one of a number of html files. So we just allow the basics...
       "mozilla/simpletest": true,