Bug 1508817 - Enable ESLint for docshell (manual changes). r=Standard8,bzbarsky
authorMellina Yonashiro <yonashiro.mellina@gmail.com>
Fri, 22 Mar 2019 07:53:32 +0000
changeset 465756 cb0dd2254bc35f7c7f52ed546f9461a00dc7786c
parent 465755 b338bce4319eb9fc5fcb86ab2c89f1b6992e9050
child 465757 ed20a4120896c4ad0071fd3a4eabc21399ccfe49
push id112523
push usershindli@mozilla.com
push dateSat, 23 Mar 2019 09:54:29 +0000
treeherdermozilla-inbound@59e55930dc0f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, bzbarsky
bugs1508817
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 1508817 - Enable ESLint for docshell (manual changes). r=Standard8,bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D23038
.eslintignore
docshell/test/browser/browser_browsingContext-01.js
docshell/test/browser/browser_bug1328501.js
docshell/test/browser/browser_bug349769.js
docshell/test/browser/browser_bug388121-1.js
docshell/test/browser/browser_bug388121-2.js
docshell/test/browser/browser_loadDisallowInherit.js
docshell/test/browser/browser_timelineMarkers-02.js
docshell/test/browser/browser_timelineMarkers-05.js
docshell/test/browser/browser_timelineMarkers-frame-02.js
docshell/test/browser/browser_timelineMarkers-frame-03.js
docshell/test/browser/browser_timelineMarkers-frame-04.js
docshell/test/browser/browser_timelineMarkers-frame-05.js
docshell/test/browser/file_bug1328501_framescript.js
docshell/test/browser/file_bug422543_script.js
docshell/test/browser/frame-head.js
docshell/test/browser/timelineMarkers-04.html
docshell/test/iframesandbox/file_top_navigation_by_location_exotic.html
docshell/test/iframesandbox/test_child_navigation_by_location.html
docshell/test/iframesandbox/test_other_auxiliary_navigation_by_location.html
docshell/test/iframesandbox/test_our_auxiliary_navigation_by_location.html
docshell/test/iframesandbox/test_parent_navigation_by_location.html
docshell/test/iframesandbox/test_sibling_navigation_by_location.html
docshell/test/iframesandbox/test_top_navigation_by_location.html
docshell/test/iframesandbox/test_top_navigation_by_location_exotic.html
docshell/test/mochitest/file_bug1121701_1.html
docshell/test/mochitest/file_bug1121701_2.html
docshell/test/mochitest/file_bug540462.html
docshell/test/mochitest/file_bug668513.html
docshell/test/mochitest/test_bug1121701.html
docshell/test/mochitest/test_bug1151421.html
docshell/test/mochitest/test_bug1450164.html
docshell/test/mochitest/test_bug385434.html
docshell/test/mochitest/test_bug387979.html
docshell/test/mochitest/test_bug475636.html
docshell/test/mochitest/test_bug529119-1.html
docshell/test/mochitest/test_bug529119-2.html
docshell/test/mochitest/test_bug551225.html
docshell/test/mochitest/test_bug570341.html
docshell/test/mochitest/test_bug580069.html
docshell/test/mochitest/test_bug590573.html
docshell/test/mochitest/test_bug640387_1.html
docshell/test/mochitest/test_bug640387_2.html
docshell/test/mochitest/test_bug660404.html
docshell/test/mochitest/test_bug703855.html
docshell/test/mochitest/test_bug797909.html
docshell/test/mochitest/test_close_onpagehide_by_history_back.html
docshell/test/mochitest/test_triggeringprincipal_location_seturi.html
--- a/.eslintignore
+++ b/.eslintignore
@@ -9,19 +9,16 @@
 **/reftests/**
 
 # Exclude expected objdirs.
 obj*/**
 
 # We ignore all these directories by default, until we get them enabled.
 # If you are enabling a directory, please add directory specific exclusions
 # below.
-docshell/test/browser/**
-docshell/test/iframesandbox/**
-docshell/test/mochitest/**
 extensions/cookie/**
 extensions/spellcheck/**
 extensions/universalchardet/**
 image/**
 layout/**
 netwerk/cookie/test/browser/**
 netwerk/test/browser/**
 netwerk/test/mochitests/**
--- a/docshell/test/browser/browser_browsingContext-01.js
+++ b/docshell/test/browser/browser_browsingContext-01.js
@@ -1,17 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const URL = "about:blank";
 
 async function getBrowsingContextId(browser, id) {
-  return await ContentTask.spawn(
+  return ContentTask.spawn(
     browser,
     id,
     async function(id) {
       let contextId = content.window.docShell.browsingContext.id;
 
       let frames = [content.window];
       while (frames.length) {
         let frame = frames.pop();
@@ -24,17 +24,17 @@ async function getBrowsingContextId(brow
         frames = frames.concat(Array.from(frame.frames));
       }
 
       return contextId;
     });
 }
 
 async function addFrame(browser, id, parentId) {
-  return await ContentTask.spawn(
+  return ContentTask.spawn(
     browser,
     {parentId, id},
     async function({ parentId, id }) {
       let parent = null;
       if (parentId) {
         let frames = [content.window];
         while (frames.length) {
           let frame = frames.pop();
@@ -54,17 +54,17 @@ async function addFrame(browser, id, par
       frame.url = "about:blank";
       parent.appendChild(frame);
 
       return frame.contentWindow.docShell.browsingContext.id;
     });
 }
 
 async function removeFrame(browser, id) {
-  return await ContentTask.spawn(
+  return ContentTask.spawn(
     browser,
     id,
     async function(id) {
       let frames = [content.window];
       while (frames.length) {
         let frame = frames.pop();
         let target = frame.document.getElementById(id);
         if (target) {
--- a/docshell/test/browser/browser_bug1328501.js
+++ b/docshell/test/browser/browser_bug1328501.js
@@ -24,15 +24,16 @@ add_task(async function testMultiFrameRe
     // which will force about:blank content viewers being created.
     browser.messageManager.loadFrameScript(FRAME_SCRIPT_URL, false);
 
     // The frame script also forwards frames-loaded.
     let framesLoaded = BrowserTestUtils.waitForMessage(browser.messageManager, "test:frames-loaded");
 
     browser.goBack();
     await framesLoaded;
+    // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
     await new Promise(r => setTimeout(r, 1000));
     await ContentTask.spawn(browser, FRAME_URL, (FRAME_URL) => {
       is(content.document.querySelector("#testFrame1").contentWindow.location.href, FRAME_URL);
       is(content.document.querySelector("#testFrame2").contentWindow.location.href, FRAME_URL);
     });
   });
 });
--- a/docshell/test/browser/browser_bug349769.js
+++ b/docshell/test/browser/browser_bug349769.js
@@ -1,20 +1,19 @@
 add_task(async function test() {
-  const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
+  const secMan = Services.scriptSecurityManager;
   const uris = [undefined, "about:blank"];
 
   function checkContentProcess(newBrowser, uri) {
     return ContentTask.spawn(newBrowser, uri, async function(uri) {
       var prin = content.document.nodePrincipal;
       Assert.notEqual(prin, null, "Loaded principal must not be null when adding " + uri);
       Assert.notEqual(prin, undefined, "Loaded principal must not be undefined when loading " + uri);
 
-      const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
-                       .getService(Ci.nsIScriptSecurityManager);
+      const secMan = Services.scriptSecurityManager;
       Assert.equal(secMan.isSystemPrincipal(prin), false,
          "Loaded principal must not be system when loading " + uri);
     });
   }
 
   for (var uri of uris) {
     await BrowserTestUtils.withNewTab({ gBrowser }, async function(newBrowser) {
       let loadedPromise = BrowserTestUtils.browserLoaded(newBrowser);
--- a/docshell/test/browser/browser_bug388121-1.js
+++ b/docshell/test/browser/browser_bug388121-1.js
@@ -1,15 +1,14 @@
 add_task(async function test() {
   await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, async function(newBrowser) {
     await ContentTask.spawn(newBrowser, null, async function() {
       var prin = content.document.nodePrincipal;
       Assert.notEqual(prin, null, "Loaded principal must not be null");
       Assert.notEqual(prin, undefined, "Loaded principal must not be undefined");
 
-      const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
-                       .getService(Ci.nsIScriptSecurityManager);
+      const secMan = Services.scriptSecurityManager;
       Assert.equal(secMan.isSystemPrincipal(prin), false,
         "Loaded principal must not be system");
     });
   });
 });
 
--- a/docshell/test/browser/browser_bug388121-2.js
+++ b/docshell/test/browser/browser_bug388121-2.js
@@ -1,21 +1,22 @@
 function test() {
   waitForExplicitFinish();
 
   var w;
-  const secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
+  const secMan = Services.scriptSecurityManager;
   var iteration = 1;
   const uris = ["", "about:blank"];
   var uri;
   var origDoc;
 
   function testLoad() {
     if (w.document == origDoc) {
       // Go back to polling
+      // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
       setTimeout(testLoad, 10);
       return;
     }
     var prin = w.document.nodePrincipal;
     isnot(prin, null, "Loaded principal must not be null when adding " + uri);
     isnot(prin, undefined, "Loaded principal must not be undefined when loading " + uri);
     is(secMan.isSystemPrincipal(prin), false,
        "Loaded principal must not be system when loading " + uri);
@@ -45,14 +46,15 @@ function test() {
       // No actual load here, so just move along.
       w.close();
       ++iteration;
       doTest();
     } else {
       origDoc = w.document;
       // Need to poll, because load listeners on the content window won't
       // survive the load.
+      // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
       setTimeout(testLoad, 10);
     }
   }
 
   doTest();
 }
--- a/docshell/test/browser/browser_loadDisallowInherit.js
+++ b/docshell/test/browser/browser_loadDisallowInherit.js
@@ -26,20 +26,18 @@ function startTest() {
     BrowserTestUtils.browserLoaded(browser, false, url).then(() => {
       func();
     });
     browser.loadURI(url, { flags, triggeringPrincipal });
   }
 
   // Load a normal http URL
   function testURL(url, func) {
-    let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].
-                   getService(Ci.nsIScriptSecurityManager);
-    let ios = Cc["@mozilla.org/network/io-service;1"].
-                getService(Ci.nsIIOService);
+    let secMan = Services.scriptSecurityManager;
+    let ios = Services.io;
     let artificialPrincipal = secMan.createCodebasePrincipal(ios.newURI("http://example.com/"), {});
     loadURL("http://example.com/", 0, artificialPrincipal, function() {
       let pagePrincipal = browser.contentPrincipal;
       ok(pagePrincipal, "got principal for http:// page");
 
       // Now load the URL normally
       loadURL(url, 0, artificialPrincipal, function() {
         ok(browser.contentPrincipal.equals(pagePrincipal), url + " should inherit principal");
--- a/docshell/test/browser/browser_timelineMarkers-02.js
+++ b/docshell/test/browser/browser_timelineMarkers-02.js
@@ -1,15 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-var URL = "<!DOCTYPE html><style>" +
+var TEST_URL = "<!DOCTYPE html><style>" +
           "body {margin:0; padding: 0;} " +
           "div {width:100px;height:100px;background:red;} " +
           ".resize-change-color {width:50px;height:50px;background:blue;} " +
           ".change-color {width:50px;height:50px;background:yellow;} " +
           ".add-class {}" +
           "</style><div></div>";
-URL = "data:text/html;charset=utf8," + encodeURIComponent(URL);
+TEST_URL = "data:text/html;charset=utf8," + encodeURIComponent(TEST_URL);
 
-var test = makeTimelineTest("browser_timelineMarkers-frame-02.js", URL);
+var test = makeTimelineTest("browser_timelineMarkers-frame-02.js", TEST_URL);
--- a/docshell/test/browser/browser_timelineMarkers-05.js
+++ b/docshell/test/browser/browser_timelineMarkers-05.js
@@ -1,15 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-var URL = "<!DOCTYPE html><style>" +
+var TEST_URL = "<!DOCTYPE html><style>" +
           "body {margin:0; padding: 0;} " +
           "div {width:100px;height:100px;background:red;} " +
           ".resize-change-color {width:50px;height:50px;background:blue;} " +
           ".change-color {width:50px;height:50px;background:yellow;} " +
           ".add-class {}" +
           "</style><div></div>";
-URL = "data:text/html;charset=utf8," + encodeURIComponent(URL);
+TEST_URL = "data:text/html;charset=utf8," + encodeURIComponent(TEST_URL);
 
-var test = makeTimelineTest("browser_timelineMarkers-frame-05.js", URL);
+var test = makeTimelineTest("browser_timelineMarkers-frame-05.js", TEST_URL);
--- a/docshell/test/browser/browser_timelineMarkers-frame-02.js
+++ b/docshell/test/browser/browser_timelineMarkers-frame-02.js
@@ -1,11 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+// This file expects frame-head.js to be loaded in the environment.
+/* import-globals-from frame-head.js */
+
 "use strict";
 
 // Test that the docShell profile timeline API returns the right markers when
 // restyles, reflows and paints occur
 
 function rectangleContains(rect, x, y, width, height) {
   return rect.x <= x && rect.y <= y && rect.width >= width &&
     rect.height >= height;
@@ -98,17 +101,17 @@ var TESTS = [{
     is(markers[0].name, "ConsoleTime", "Got first ConsoleTime marker");
     is(markers[0].causeName, "FOO", "Got ConsoleTime FOO detail");
     is(markers[1].name, "ConsoleTime", "Got second ConsoleTime marker");
     is(markers[1].causeName, "BAR", "Got ConsoleTime BAR detail");
   },
 }, {
   desc: "Timestamps created by console.timeStamp()",
   searchFor: "Timestamp",
-  setup(docshell) {
+  setup(docShell) {
     content.console.timeStamp("rock");
     let markers = docShell.popProfileTimelineMarkers();
     is(markers.length, 1, "Got one marker");
     is(markers[0].name, "TimeStamp", "Got Timestamp marker");
     is(markers[0].causeName, "rock", "Got Timestamp label value");
     content.console.timeStamp("paper");
     content.console.timeStamp("scissors");
     content.console.timeStamp();
--- a/docshell/test/browser/browser_timelineMarkers-frame-03.js
+++ b/docshell/test/browser/browser_timelineMarkers-frame-03.js
@@ -1,11 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+// This file expects frame-head.js to be loaded in the environment.
+/* import-globals-from frame-head.js */
+
 "use strict";
 
 // Test that the docShell profile timeline API returns the right
 // markers for DOM events.
 
 var TESTS = [{
   desc: "Event dispatch with single handler",
   searchFor: "DOMEvent",
@@ -70,17 +73,17 @@ var TESTS = [{
     is(markers.length, 1, "Got 1 marker");
   },
 }, {
   desc: "Event dispatch on window",
   searchFor(markers) {
     return markers.filter(m => m.name == "DOMEvent").length >= 2;
   },
   setup(docShell) {
-    let doc = content.window.addEventListener("aardvark", function(e) {
+    content.window.addEventListener("aardvark", function(e) {
       console.log("I like ants!");
     });
 
     content.window.dispatchEvent(new content.Event("aardvark"));
   },
   check(markers) {
     markers = markers.filter(m => m.name == "DOMEvent");
     is(markers.length, 1, "Got 1 marker");
--- a/docshell/test/browser/browser_timelineMarkers-frame-04.js
+++ b/docshell/test/browser/browser_timelineMarkers-frame-04.js
@@ -1,11 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+// This file expects frame-head.js to be loaded in the environment.
+/* import-globals-from frame-head.js */
+
 "use strict";
 
 // Test that the docShell profile timeline API returns the right
 // markers for XMLHttpRequest events.
 
 var TESTS = [{
   desc: "Event dispatch from XMLHttpRequest",
   searchFor(markers) {
--- a/docshell/test/browser/browser_timelineMarkers-frame-05.js
+++ b/docshell/test/browser/browser_timelineMarkers-frame-05.js
@@ -1,11 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+// This file expects frame-head.js to be loaded in the environment.
+/* import-globals-from frame-head.js */
+
 "use strict";
 
 function forceSyncReflow(div) {
   div.setAttribute("class", "resize-change-color");
   // Force a reflow.
   return div.offsetWidth;
 }
 
--- a/docshell/test/browser/file_bug1328501_framescript.js
+++ b/docshell/test/browser/file_bug1328501_framescript.js
@@ -1,21 +1,24 @@
 // Forward iframe loaded event.
+
+/* eslint-env mozilla/frame-script */
+
 addEventListener("frames-loaded",
   e => sendAsyncMessage("test:frames-loaded"), true, true);
 
 let requestObserver = {
   observe(subject, topic, data) {
     if (topic == "http-on-opening-request") {
       // Get DOMWindow on all child docshells to force about:blank
       // content viewers being created.
       getChildDocShells().map(ds => {
-        let window = ds.QueryInterface(Ci.nsIInterfaceRequestor)
-                      .getInterface(Ci.nsILoadContext)
-                      .associatedWindow;
+        ds.QueryInterface(Ci.nsIInterfaceRequestor)
+          .getInterface(Ci.nsILoadContext)
+          .associatedWindow;
       });
     }
   },
   QueryInterface: ChromeUtils.generateQI([
     Ci.nsIObserver,
   ]),
 };
 Services.obs.addObserver(requestObserver, "http-on-opening-request");
--- a/docshell/test/browser/file_bug422543_script.js
+++ b/docshell/test/browser/file_bug422543_script.js
@@ -1,8 +1,10 @@
+/* eslint-env mozilla/frame-script */
+
 function SHistoryListener() {
 }
 
 SHistoryListener.prototype = {
   retval: true,
   last: "initial",
 
   OnHistoryNewEntry(aNewURI) {
--- a/docshell/test/browser/frame-head.js
+++ b/docshell/test/browser/frame-head.js
@@ -1,11 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/* eslint-env mozilla/frame-script */
+
 // Functions that are automatically loaded as frame scripts for
 // timeline tests.
 
 const {setTimeout} = ChromeUtils.import("resource://gre/modules/Timer.jsm");
 
 // Functions that look like mochitest functions but forward to the
 // browser process.
 
--- a/docshell/test/browser/timelineMarkers-04.html
+++ b/docshell/test/browser/timelineMarkers-04.html
@@ -7,45 +7,46 @@
 <body>
 
   <p>Test page</p>
 
   <script>
     function do_xhr() {
       const theURL = "timelineMarkers-04.html";
 
-      xhr = new XMLHttpRequest();
+      var xhr = new XMLHttpRequest();
       xhr.onreadystatechange = function() {
         dump("ReadyState = " + xhr.readyState + "\n");
       };
       xhr.open("get", theURL, true);
       xhr.send();
     }
 
     window.addEventListener("dog", do_xhr, true);
 
     function do_promise() {
       new Promise(function(resolve, reject) {
-	console.time("Bob");
-	window.setTimeout(function() {
+        console.time("Bob");
+        window.setTimeout(function() {
           resolve(23);
-	}, 10);
+        }, 10);
       }).then(function(val) {
         console.timeEnd("Bob");
       });
     }
 
     window.addEventListener("promisetest", do_promise, true);
 
     var globalResolver;
     function do_promise_script() {
       new Promise(function(resolve, reject) {
-	console.time("Bob");
+        console.time("Bob");
         globalResolver = resolve;
-	window.setTimeout("globalResolver(23);", 10);
+        // eslint-disable-next-line no-implied-eval
+        window.setTimeout("globalResolver(23)", 10);
       }).then(function(val) {
         console.timeEnd("Bob");
       });
     }
 
     window.addEventListener("promisescript", do_promise_script, true);
 
   </script>
--- a/docshell/test/iframesandbox/file_top_navigation_by_location_exotic.html
+++ b/docshell/test/iframesandbox/file_top_navigation_by_location_exotic.html
@@ -8,16 +8,17 @@
     opener.postMessage({ name: window.name, blocked: true }, "*");
   }
 
   function onNav() {
     opener.postMessage({ name: window.name, blocked: false }, "*");
   }
 
   function setOwnHref() {
+    // eslint-disable-next-line no-self-assign
     location.href = location.href;
   }
 
   window.onload = onNav;
 </script>
 </head>
 <body>
   <iframe name="if1" sandbox="allow-scripts allow-same-origin"></iframe>
--- a/docshell/test/iframesandbox/test_child_navigation_by_location.html
+++ b/docshell/test/iframesandbox/test_child_navigation_by_location.html
@@ -27,17 +27,17 @@ html5 sandboxed iframe should not be abl
       window.parentIframe.eval(testCase.script);
     } catch (e) {
       ok(testCase.shouldBeBlocked, testCase.desc + " - " + e.message);
       runNextTest();
     }
   }
 
   var testCaseIndex = -1;
-  testCases = [
+  var testCases = [
     {
       desc: "Test 1: cross origin child location.replace should NOT be blocked",
       script: "window['crossOriginChildIframe'].location.replace(\"" + testDataUri + "\")",
       shouldBeBlocked: false,
     },
     {
       desc: "Test 2: cross origin child location.assign should be blocked",
       script: "window['crossOriginChildIframe'].location.assign(\"" + testDataUri + "\")",
--- a/docshell/test/iframesandbox/test_other_auxiliary_navigation_by_location.html
+++ b/docshell/test/iframesandbox/test_other_auxiliary_navigation_by_location.html
@@ -25,17 +25,17 @@ html5 sandboxed iframe should not be abl
       window.testIframe.eval(testCase.script);
     } catch (e) {
       ok(true, testCase.desc + " - " + e.message);
       runNextTest();
     }
   }
 
   var testCaseIndex = -1;
-  testCases = [
+  var testCases = [
     {
       desc: "Test 1: location.replace on auxiliary NOT opened by us should be blocked",
       script: "parent.openedWindow.location.replace('file_other_auxiliary_navigation_by_location.html')",
     },
     {
       desc: "Test 2: location.assign on auxiliary NOT opened by us should be blocked",
       script: "parent.openedWindow.location.assign('file_other_auxiliary_navigation_by_location.html')",
     },
@@ -47,17 +47,17 @@ html5 sandboxed iframe should not be abl
       desc: "Test 4: location.hash on auxiliary NOT opened by us should be blocked",
       script: "parent.openedWindow.location.hash = 'wibble'",
     },
   ];
 
   function runNextTest() {
     ++testCaseIndex;
     if (testCaseIndex == testCases.length) {
-      openedWindow.close();
+      window.openedWindow.close();
       SimpleTest.finish();
       return;
     }
 
     runScriptNavigationTest(testCases[testCaseIndex]);
   }
 
   window.onmessage = runNextTest;
--- a/docshell/test/iframesandbox/test_our_auxiliary_navigation_by_location.html
+++ b/docshell/test/iframesandbox/test_our_auxiliary_navigation_by_location.html
@@ -25,17 +25,17 @@ html5 sandboxed iframe should not be abl
       SpecialPowers.wrap(window.testIframe).eval(testCase.script);
     } catch (e) {
       ok(testCase.shouldBeBlocked, testCase.desc + " - " + SpecialPowers.wrap(e).message);
       runNextTest();
     }
   }
 
   var testCaseIndex = -1;
-  testCases = [
+  var testCases = [
     {
       desc: "Test 1: location.replace on auxiliary opened by us should NOT be blocked",
       script: "openedWindow.location.replace('file_our_auxiliary_navigation_by_location.html')",
       shouldBeBlocked: false,
     },
     {
       desc: "Test 2: location.assign on auxiliary opened by us should be blocked without allow-same-origin",
       script: "openedWindow.location.assign('file_our_auxiliary_navigation_by_location.html')",
--- a/docshell/test/iframesandbox/test_parent_navigation_by_location.html
+++ b/docshell/test/iframesandbox/test_parent_navigation_by_location.html
@@ -25,17 +25,17 @@ html5 sandboxed iframe should not be abl
       window.parentIframe.childIframe.eval(testCase.script);
     } catch (e) {
       ok(true, testCase.desc + " - " + e.message);
       runNextTest();
     }
   }
 
   var testCaseIndex = -1;
-  testCases = [
+  var testCases = [
     {
       desc: "Test 1: parent.location.replace should be blocked even when sandboxed with allow-same-origin allow-top-navigation",
       script: "parent.location.replace('file_parent_navigation_by_location.html')",
     },
     {
       desc: "Test 2: parent.location.assign should be blocked even when sandboxed with allow-same-origin allow-top-navigation",
       script: "parent.location.assign('file_parent_navigation_by_location.html')",
     },
--- a/docshell/test/iframesandbox/test_sibling_navigation_by_location.html
+++ b/docshell/test/iframesandbox/test_sibling_navigation_by_location.html
@@ -27,17 +27,17 @@ html5 sandboxed iframe should not be abl
       window.testIframe.eval(testCase.script);
     } catch (e) {
       ok(true, testCase.desc + " - " + e.message);
       runNextTest();
     }
   }
 
   var testCaseIndex = -1;
-  testCases = [
+  var testCases = [
     {
       desc: "Test 1: sibling location.replace should be blocked even when sandboxed with allow-same-origin allow-top-navigation",
       script: "parent['siblingIframe'].location.replace('file_sibling_navigation_by_location.html')",
     },
     {
       desc: "Test 2: sibling location.assign should be blocked even when sandboxed with allow-same-origin allow-top-navigation",
       script: "parent['siblingIframe'].location.assign('file_sibling_navigation_by_location.html')",
     },
--- a/docshell/test/iframesandbox/test_top_navigation_by_location.html
+++ b/docshell/test/iframesandbox/test_top_navigation_by_location.html
@@ -26,17 +26,17 @@ html5 sandboxed iframe should not be abl
       SpecialPowers.wrap(testWin[testCase.iframeName]).eval(testCase.script);
     } catch (e) {
       ok(testCase.shouldBeBlocked, testCase.desc + " - " + SpecialPowers.wrap(e).message);
       runNextTest();
     }
   }
 
   var testCaseIndex = -1;
-  testCases = [
+  var testCases = [
     {
       desc: "Test 1: top.location.replace should be blocked when sandboxed without allow-top-navigation",
       script: "top.location.replace('file_top_navigation_by_location.html')",
       iframeName: "if1",
       shouldBeBlocked: true,
     },
     {
       desc: "Test 2: top.location.assign should be blocked when sandboxed without allow-top-navigation",
--- a/docshell/test/iframesandbox/test_top_navigation_by_location_exotic.html
+++ b/docshell/test/iframesandbox/test_top_navigation_by_location_exotic.html
@@ -27,17 +27,17 @@ html5 sandboxed iframe should not be abl
       testWin[testCase.iframeName].eval(testCase.script);
     } catch (e) {
       ok(testCase.shouldBeBlocked, testCase.desc + " - " + e.message);
       runNextTest();
     }
   }
 
   var testCaseIndex = -1;
-  testCases = [
+  var testCases = [
     {
       desc: "Test 1: location.replace.call(top.location, ...) should be blocked when sandboxed without allow-top-navigation",
       script: "location.replace.call(top.location, 'file_top_navigation_by_location_exotic.html')",
       iframeName: "if1",
       shouldBeBlocked: true,
     },
     {
       desc: "Test 2: location.replace.bind(top.location, ...) should be blocked when sandboxed without allow-top-navigation",
--- a/docshell/test/mochitest/file_bug1121701_1.html
+++ b/docshell/test/mochitest/file_bug1121701_1.html
@@ -1,1 +1,1 @@
-<script>window.onpageshow = function(e) { opener.child1PageShow(e); } </script>
+<script>window.onpageshow = function(e) { opener.child1PageShow(e); }; </script>
--- a/docshell/test/mochitest/file_bug1121701_2.html
+++ b/docshell/test/mochitest/file_bug1121701_2.html
@@ -1,1 +1,1 @@
-<script>window.onpageshow = function(e) { opener.child2PageShow(e); } </script>
+<script>window.onpageshow = function(e) { opener.child2PageShow(e); }; </script>
--- a/docshell/test/mochitest/file_bug540462.html
+++ b/docshell/test/mochitest/file_bug540462.html
@@ -1,16 +1,25 @@
 <html>
   <head>
     <script>
-    //<!--
+    // <!--
     function test() {
       document.open();
-      document.write("<html><body onload='opener.documentWriteLoad(); rel();'><a href='foo.html'>foo</a><script>function rel() { setTimeout('location.reload()', 0); }</script></body></html>");
+      document.write(
+      `<html>
+        <body onload='opener.documentWriteLoad(); rel();'>
+          <a href='foo.html'>foo</a>
+          <script>
+            function rel() { setTimeout('location.reload()', 0); }
+          <\/script>
+        </body>
+      </html>`
+      );
       document.close();
     }
-    //-->
+    // -->
     </script>
   </head>
   <body onload="setTimeout('test()', 0)">
     Test for bug 540462
   </body>
 </html>
--- a/docshell/test/mochitest/file_bug668513.html
+++ b/docshell/test/mochitest/file_bug668513.html
@@ -19,17 +19,17 @@
     var navigation = win.performance && win.performance.navigation;
     if (navigation === undefined) {
       // avoid script errors
       finish();
       return;
     }
 
     // do this with a timeout to see the visuals of the navigations.
-    setTimeout("nav_frame();", 100);
+    setTimeout(nav_frame, 100);
   }
 
   var step = 1;
   function nav_frame() {
     var navigation_frame = frames[0];
     var navigation = navigation_frame.performance.navigation;
     switch (step) {
       case 1:
@@ -71,17 +71,17 @@
 
         var timing = navigation_frame.performance && navigation_frame.performance.timing;
         if (timing === undefined) {
           // avoid script errors
           finish();
           break;
         }
         ok(timing.navigationStart > 0, "navigationStart should be > 0");
-        sequence = ["navigationStart", "redirectStart", "redirectEnd", "fetchStart"];
+        var sequence = ["navigationStart", "redirectStart", "redirectEnd", "fetchStart"];
         for (var j = 1; j < sequence.length; ++j) {
           var prop = sequence[j];
           var prevProp = sequence[j - 1];
           ok(timing[prevProp] <= timing[prop],
              ["Expected ", prevProp, " to happen before ", prop,
               ", got ", prevProp, " = ", timing[prevProp],
               ", ", prop, " = ", timing[prop]].join(""));
         }
--- a/docshell/test/mochitest/test_bug1121701.html
+++ b/docshell/test/mochitest/test_bug1121701.html
@@ -18,19 +18,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   var page1LoadCount = 0;
   function child1PageShow(e) {
     ++page1LoadCount;
     if (page1LoadCount == 1) {
       SimpleTest.executeSoon(function() {
         is(e.persisted, false, "Initial page load shouldn't be persisted.");
         testWin.document.body.innerHTML = "modified";
-        testWin.onpagehide = function(e) {
+        testWin.onpagehide = function(event) {
           testWin.onpagehide = null;
-          ok(e.persisted, "test page 1 should have been persisted");
+          ok(event.persisted, "test page 1 should have been persisted");
           is(testWin.document.body.innerHTML, "modified");
         };
         testWin.location.href = testUrl2;
       });
     } else if (page1LoadCount == 2) {
       is(e.persisted, true, "Page load from bfcache should be persisted.");
       is(testWin.document.body.innerHTML, "modified");
       testWin.close();
--- a/docshell/test/mochitest/test_bug1151421.html
+++ b/docshell/test/mochitest/test_bug1151421.html
@@ -17,16 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 SimpleTest.waitForExplicitFinish();
 
 function childLoad() {
   // Spin the event loop so we leave the onload handler.
   SimpleTest.executeSoon(childLoad2);
 }
 
 function childLoad2() {
+  let iframe = document.getElementById("iframe");
   let cw = iframe.contentWindow;
   let content = cw.document.getElementById("content");
 
   // Create a function to calculate an invariant.
   let topPlusOffset = function() {
     return Math.round(content.getBoundingClientRect().top + cw.pageYOffset);
   };
 
--- a/docshell/test/mochitest/test_bug1450164.html
+++ b/docshell/test/mochitest/test_bug1450164.html
@@ -8,17 +8,17 @@
     <title>Test for Bug 1450164</title>
     <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     <script type="application/javascript">
 
      /** Test for Bug 1450164 **/
 
      function runTest() {
-       child = window.open("file_bug1450164.html", "", "width=100,height=100");
+       var child = window.open("file_bug1450164.html", "", "width=100,height=100");
        child.onload = function() {
          // After the window loads, close it. If we don't crash in debug, consider that a pass.
          child.close();
        };
      }
 
      SimpleTest.waitForExplicitFinish();
      addLoadEvent(runTest);
--- a/docshell/test/mochitest/test_bug385434.html
+++ b/docshell/test/mochitest/test_bug385434.html
@@ -21,16 +21,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 385434 **/
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 SimpleTest.expectAssertions(0, 1); // bug 1333702
 
 var gNumHashchanges = 0;
 var gCallbackOnIframeLoad = false;
+var gSampleEvent;
 
 function statusMsg(msg) {
   var msgElem = document.createElement("p");
   msgElem.appendChild(document.createTextNode(msg));
 
   document.getElementById("status").appendChild(msgElem);
 }
 
@@ -164,16 +165,17 @@ function* run_test() {
                   "trigger a hashchange.");
 
   /*
    * TEST 2 tests that:
    *     <frameset onhashchange = ... > works,
    *     the event is targeted at the window object
    *     the event's cancelable, bubbles settings are correct
    */
+
   enableIframeLoadCallback();
   frameCw.document.location = "file_bug385434_2.html";
   yield undefined;
 
   frameCw.document.location = "file_bug385434_2.html#foo";
   yield undefined;
 
   eventExpected("frame onhashchange should fire events.");
--- a/docshell/test/mochitest/test_bug387979.html
+++ b/docshell/test/mochitest/test_bug387979.html
@@ -13,36 +13,35 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 387979 **/
 function a(s) {
-	var r;
-	try { r = frames[0].document.body; } catch (e) { r = e; }
-        is(r instanceof frames[0].HTMLBodyElement, true,
-           "Can't get body" + s);
+  var r;
+  try { r = frames[0].document.body; } catch (e) { r = e; }
+  is(r instanceof frames[0].HTMLBodyElement, true, "Can't get body" + s);
 }
 var p = 0;
 function b() {
-	switch (++p) {
-	case 1:
-		frames[0].location = "about:blank";
-		break;
-	case 2:
-		a("before reload");
-		frames[0].location.reload();
-		break;
-	case 3:
-		a("after reload");
-                SimpleTest.finish();
-		break;
-	}
+  switch (++p) {
+    case 1:
+      frames[0].location = "about:blank";
+    break;
+    case 2:
+      a("before reload");
+      frames[0].location.reload();
+    break;
+    case 3:
+      a("after reload");
+      SimpleTest.finish();
+    break;
+  }
 }
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 <p id="display">
   <iframe onload="b()"></iframe>
--- a/docshell/test/mochitest/test_bug475636.html
+++ b/docshell/test/mochitest/test_bug475636.html
@@ -17,17 +17,17 @@ Test that refresh to data: URIs don't in
   
 </div>
 <iframe id=loader></iframe>
 <pre id="test">
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-gen = runTests();
+var gen = runTests();
 
 window.private = 42;
 
 window.addEventListener("message", function(e) {
   gen.next(e.data);
 });
 
 var url = "file_bug475636.sjs?";
--- a/docshell/test/mochitest/test_bug529119-1.html
+++ b/docshell/test/mochitest/test_bug529119-1.html
@@ -12,27 +12,27 @@ SimpleTest.requestFlakyTimeout("untriage
 
 var workingURL = "http://mochi.test:8888/tests/docshell/test/mochitest/bug529119-window.html";
 var faultyURL = "http://some-nonexistent-domain-27489274c892748217cn2384.com/";
 
 var w = null;
 var phase = 0;
 var gotWrongPageOnTryAgainClick = false;
 
-function pollForPage(f, w) {
+function pollForPage(f, win) {
   // Start with polling after a delay, we might mistakenly take the current page
   // as an expected one.
   window.setTimeout(function() {
     var iterationsLeft = 200;
     var int = window.setInterval(function() {
       iterationsLeft--;
 
       var haveErrorPage = false;
       try {
-        var title = w.document.title;
+        win.document.title;
       } catch (ex) {
         haveErrorPage = true;
       }
 
       if (iterationsLeft == 0 || haveErrorPage) {
         window.clearInterval(int);
         f(iterationsLeft > 0);
       }
@@ -45,25 +45,25 @@ function windowLoaded() {
     case 0:
       /* 2. We have succeededfully loaded a page, now go to a faulty URL */
       window.setTimeout(function() {
         w.location.href = faultyURL;
       }, 0);
 
       phase = 1;
 
-      pollForPage(function(succeeded) {
-        ok(succeeded, "Waiting for error page succeeded");
+      pollForPage(function(enterErrorSucceeded) {
+        ok(enterErrorSucceeded, "Waiting for error page succeeded");
 
         /* 3. now, while we are on the error page, try to reload it, actually
            click the "Try Again" button */
         SpecialPowers.wrap(w).location.reload();
 
-        pollForPage(function(succeeded) {
-          ok(succeeded, "Waiting for error page succeeded");
+        pollForPage(function(continueErrorSucceeded) {
+          ok(continueErrorSucceeded, "Waiting for error page succeeded");
 
           /* 4-finish, check we are still on the error page */
           is(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page");
           isnot(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page");
           is(gotWrongPageOnTryAgainClick, false,
             "Must not get www.example.com page on reload of an error page");
           w.close();
           SimpleTest.finish();
--- a/docshell/test/mochitest/test_bug529119-2.html
+++ b/docshell/test/mochitest/test_bug529119-2.html
@@ -12,27 +12,27 @@ SimpleTest.requestFlakyTimeout("untriage
 
 var workingURL = "http://mochi.test:8888/tests/docshell/test/mochitest/bug529119-window.html";
 var faultyURL = "http://some-nonexistent-domain-27489274c892748217cn2384.com/";
 
 var w = null;
 var phase = 0;
 var isWindowLoaded = false;
 
-function pollForPage(expectErrorPage, f, w) {
+function pollForPage(expectErrorPage, f, win) {
   // Start with polling after a delay, we might mistakenly take the current page
   // as an expected one.
   window.setTimeout(function() {
     var iterationsLeft = 200;
     var int = window.setInterval(function() {
       iterationsLeft--;
 
       var haveErrorPage = false;
       try {
-        var title = w.document.title;
+        win.document.title;
       } catch (ex) {
         haveErrorPage = true;
       }
 
       if (iterationsLeft == 0 || expectErrorPage == haveErrorPage) {
         window.clearInterval(int);
         f(iterationsLeft > 0);
       }
@@ -48,29 +48,29 @@ function windowLoaded() {
   isWindowLoaded = true;
 
   /* 2. We have successfully loaded a page, now go to a faulty URL */
   // XXX The test fails when we change the location synchronously
   window.setTimeout(function() {
     w.location.href = faultyURL;
   }, 0);
 
-  pollForPage(true, function(succeeded) {
-    ok(succeeded, "Waiting for error page succeeded");
+  pollForPage(true, function(errorSucceeded) {
+    ok(errorSucceeded, "Waiting for error page succeeded");
     /* 3. now, while we are on the error page, navigate back */
     try {
       // We need the SpecialPowers bit, because this is a cross-origin window
       // and we normally can't touch .history on those.
       SpecialPowers.wrap(w).history.back();
     } catch (ex) {
       ok(false, "w.history.back() threw " + ex);
     }
 
-    pollForPage(false, function(succeeded) {
-      ok(succeeded, "Waiting for original page succeeded");
+    pollForPage(false, function(originalSucceeded) {
+      ok(originalSucceeded, "Waiting for original page succeeded");
       /* 4-finish, check we are back at the original page */
       isnot(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page");
       is(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page");
       w.close();
       SimpleTest.finish();
     }, w);
   }, w);
 }
--- a/docshell/test/mochitest/test_bug551225.html
+++ b/docshell/test/mochitest/test_bug551225.html
@@ -11,17 +11,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=551225">Mozilla Bug 551225</a>
 
 <script type="application/javascript">
 
 /** Test for Bug 551225 **/
 
-obj = {
+var obj = {
   a: new Date("1/1/2000"),
   b: /^foo$/,
   c: "bar",
 };
 
 history.replaceState(obj, "", "");
 is(history.state.a.toString(), new Date("1/1/2000").toString(), "Date object.");
 is(history.state.b.toString(), "/^foo$/", "Regex");
--- a/docshell/test/mochitest/test_bug570341.html
+++ b/docshell/test/mochitest/test_bug570341.html
@@ -12,20 +12,20 @@ https://bugzilla.mozilla.org/show_bug.cg
   var moments = {};
 
   var unload = 0;
   var wasEnabled = true;
 
   function collectMoments() {
     var win = frames[0];
     var timing = (win.performance && win.performance.timing) || {};
-    for (var p in timing) {
+    for (let p in timing) {
       moments[p] = timing[p];
     }
-    for (var p in win) {
+    for (let p in win) {
       if (p.substring(0, 9) == "_testing_") {
         moments[p.substring(9)] = win[p];
       }
     }
     moments.evt_unload = unload;
     return moments;
   }
 
@@ -35,21 +35,21 @@ https://bugzilla.mozilla.org/show_bug.cg
     }
     var sequence = [];
     for (var p in moments) {
       sequence.push(p);
     }
     sequence.sort(function(a, b) {
       return moments[a] - moments[b];
     });
-    table = document.createElement("table");
+    var table = document.createElement("table");
     node.appendChild(table);
-    row = document.createElement("tr");
+    var row = document.createElement("tr");
     table.appendChild(row);
-    cell = document.createElement("td");
+    var cell = document.createElement("td");
     row.appendChild(cell);
     cell.appendChild(document.createTextNode("start"));
     cell = document.createElement("td");
     row.appendChild(cell);
     cell.appendChild(document.createTextNode(start));
     for (var i = 0; i < sequence.length; ++i) {
       var prop = sequence[i];
       row = document.createElement("tr");
--- a/docshell/test/mochitest/test_bug580069.html
+++ b/docshell/test/mochitest/test_bug580069.html
@@ -36,19 +36,19 @@ add_task(async function() {
   });
   info("iframe's location is: " + iframeCw.location + ", method is " + method1 + "\n");
   is(method1, "POST", "Method for first load should be POST.");
 
   // Push a new state, and refresh the page. This refresh shouldn't pop up the
   // "are you sure you want to refresh a page with POST data?" dialog. If it
   // does, this test will hang and fail, and we'll see 'Refreshing iframe...' at
   // the end of the test log.
-  iframeCw.history.replaceState('', '', '?replaced');
+  iframeCw.history.replaceState("", "", "?replaced");
 
-  info('Refreshing iframe...\n');
+  info("Refreshing iframe...\n");
   iframeCw.location.reload();
   let method2 = await new Promise(resolve => {
     window.page2Load = resolve;
   });
 
   info("iframe's location is: " + iframeCw.location + ", method is " + method2 + "\n");
   is(method2, "GET", "Method for second load should be GET.");
   is(iframeCw.location.search, "?replaced", "Wrong search on iframe after refresh.");
--- a/docshell/test/mochitest/test_bug590573.html
+++ b/docshell/test/mochitest/test_bug590573.html
@@ -98,18 +98,16 @@ function dumpSHistory(theWindow) {
   for (let i = 0; i < sh.count; i++) {
     let shentry = sh.legacySHistory.getEntryAtIndex(i);
     dump(" " + i + ": " + shentry.URI.spec + "\n");
     for (let j = 0; j < shentry.childCount; j++) {
       let child = shentry.GetChildAt(j);
       dump("   child " + j + ": " + child.URI.spec + "\n");
     }
   }
-
-  return sh;
 }
 
 var popup = window.open("file_bug590573_1.html");
 
 var gTestContinuation = null;
 var loads = 0;
 function pageLoad() {
   loads++;
--- a/docshell/test/mochitest/test_bug640387_1.html
+++ b/docshell/test/mochitest/test_bug640387_1.html
@@ -68,40 +68,40 @@ function* test() {
   // Spin the event loop so hashchange has a chance to fire, if it's going to.
   SimpleTest.executeSoon(function() { gGen.next(); });
   yield undefined;
 
   popup.close();
   SimpleTest.finish();
 }
 
-gGen = null;
+var gGen = null;
 function childLoad() {
   gGen = test();
   gGen.next();
 }
 
-gHashchangeExpected = true;
+var gHashchangeExpected = true;
 function childHashchange() {
   if (gHashchangeExpected) {
     gGen.next();
   } else {
     ok(false, "Got hashchange when we weren't expecting one.");
   }
 }
 
-gCallbackOnPopstate = false;
+var gCallbackOnPopstate = false;
 function childPopstate() {
   if (gCallbackOnPopstate) {
     gGen.next();
   }
 }
 
 /* We need to run this test in a popup, because navigating an iframe
  * back/forwards tends to cause intermittent orange. */
-popup = window.open("file_bug640387.html");
+var popup = window.open("file_bug640387.html");
 
 /* Control now flows up to childLoad(), called once the popup loads. */
 
 </script>
 
 </body>
 </html>
--- a/docshell/test/mochitest/test_bug640387_2.html
+++ b/docshell/test/mochitest/test_bug640387_2.html
@@ -20,26 +20,26 @@ to
 
   http://example.com/
 
 via a non-history load, we do a true load, rather than a scroll. -->
 
 <script type='application/javascript'>
 SimpleTest.waitForExplicitFinish();
 
-callbackOnLoad = false;
+var callbackOnLoad = false;
 function childLoad() {
   if (callbackOnLoad) {
     callbackOnLoad = false;
     gGen.next();
   }
 }
 
-errorOnHashchange = false;
-callbackOnHashchange = false;
+var errorOnHashchange = false;
+var callbackOnHashchange = false;
 function childHashchange() {
   if (errorOnHashchange) {
     ok(false, "Got unexpected hashchange.");
   }
   if (callbackOnHashchange) {
     callbackOnHashchange = false;
     gGen.next();
   }
@@ -74,16 +74,16 @@ function* run_test() {
   // Spin the event loop to give hashchange a chance to fire, if it's going to.
   SimpleTest.executeSoon(function() { gGen.next(); });
   yield undefined;
 
   SimpleTest.finish();
 }
 
 callbackOnLoad = true;
-gGen = run_test();
+var gGen = run_test();
 
 </script>
 
 <iframe id='iframe' src='file_bug640387.html'></iframe>
 
 </body>
 </html>
--- a/docshell/test/mochitest/test_bug660404.html
+++ b/docshell/test/mochitest/test_bug660404.html
@@ -29,17 +29,18 @@ function continueTest() {
       is(ev.persisted, true, "Should be bfcached when navigating to multipart");
     };
     w.location.href = "file_bug660404";
   });
 }
 
 function finishTest() {
   is(w.document.documentElement.textContent, "opener.finishTest();");
-  is(w.document.documentElement.innerHTML, "<head><script>opener.finishTest();</" + "script></head>");
+  is(w.document.documentElement.innerHTML, "<head><script>opener.finishTest();</" +
+                                           "script></head>");
   w.close();
   SimpleTest.finish();
 }
 
 // Have to open a new window, since there's no bfcache in subframes
 w = window.open("file_bug660404-1.html");
 
 </script>
--- a/docshell/test/mochitest/test_bug703855.html
+++ b/docshell/test/mochitest/test_bug703855.html
@@ -43,29 +43,29 @@ var timingAttributes = [
   "responseStart",
   "unloadEventEnd",
   "unloadEventStart",
 ];
 var originalTiming = {};
 
 function runTest() {
   var timing = $("f").contentWindow.performance.timing;
-  for (i in timingAttributes) {
+  for (let i in timingAttributes) {
     originalTiming[timingAttributes[i]] = timing[timingAttributes[i]];
   }
 
   var doc = $("f").contentDocument;
   doc.open();
   doc.write("<!DOCTYPE html>");
   doc.close();
 
   SimpleTest.executeSoon(function() {
     var newTiming = $("f").contentWindow.performance.timing;
-    for (var i in timingAttributes) {
-      is(timing[timingAttributes[i]], originalTiming[timingAttributes[i]],
+    for (let i in timingAttributes) {
+      is(newTiming[timingAttributes[i]], originalTiming[timingAttributes[i]],
          "document.open should not affect value of " + timingAttributes[i]);
     }
     SimpleTest.finish();
   });
 }
 
 addLoadEvent(function() {
   SimpleTest.executeSoon(runTest);
--- a/docshell/test/mochitest/test_bug797909.html
+++ b/docshell/test/mochitest/test_bug797909.html
@@ -17,45 +17,45 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script type="application/javascript">
   /** Test for Bug 797909 **/
 
   SimpleTest.waitForExplicitFinish();
 
   function runTest() {
-    iframe = document.getElementById("ifr");
+    var iframe = document.getElementById("ifr");
     try {
-      var iframeDoc = iframe.contentWindow.document;
+      iframe.contentWindow.document;
       ok(false, "Should have thrown an exception");
     } catch (ex) {
       ok(true, "Got an exception");
     }
 
     iframe = document.createElement("iframe");
     // set sandbox attribute
     iframe.sandbox = "allow-scripts";
     // and then insert into the doc
     document.body.appendChild(iframe);
 
     try {
-      var iframeDoc = iframe.contentWindow.document;
+      iframe.contentWindow.document;
       ok(false, "Should have thrown an exception");
     } catch (ex) {
       ok(true, "Got an exception");
     }
 
     iframe = document.createElement("iframe");
     // set sandbox attribute
     iframe.sandbox = "allow-same-origin";
     // and then insert into the doc
     document.body.appendChild(iframe);
 
     try {
-      var iframeDoc = iframe.contentWindow.document;
+      iframe.contentWindow.document;
       ok(true, "Shouldn't have thrown an exception");
     } catch (ex) {
       ok(false, "Got an unexpected exception");
     }
 
     SimpleTest.finish();
   }
 
--- a/docshell/test/mochitest/test_close_onpagehide_by_history_back.html
+++ b/docshell/test/mochitest/test_close_onpagehide_by_history_back.html
@@ -5,18 +5,18 @@
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1432396">Mozilla Bug 1432396</a>
 <p id="display"></p>
 <script>
 SimpleTest.waitForExplicitFinish();
 
 const w = window.open("file_close_onpagehide1.html");
 window.addEventListener("message", e => {
   is(e.data, "initial", "The initial page loaded");
-  window.addEventListener("message", e => {
-    is(e.data, "second", "The second page loaded");
+  window.addEventListener("message", evt => {
+    is(evt.data, "second", "The second page loaded");
     w.onpagehide = () => {
       w.close();
       info("try to close the popped up window in onpagehide");
       SimpleTest.finish();
     };
     w.history.back();
   }, { once: true });
   w.location = "file_close_onpagehide2.html";
--- a/docshell/test/mochitest/test_triggeringprincipal_location_seturi.html
+++ b/docshell/test/mochitest/test_triggeringprincipal_location_seturi.html
@@ -13,17 +13,17 @@ SimpleTest.waitForExplicitFinish();
 const SAME_ORIGIN_URI = "http://mochi.test:8888/tests/docshell/test/dummy_page.html";
 const CROSS_ORIGIN_URI = "http://example.com/tests/docshell/test/dummy_page.html";
 const NUMBER_OF_TESTS = 3;
 let testCounter = 0;
 
 function checkFinish() {
   testCounter++;
   if (testCounter < NUMBER_OF_TESTS) {
-  	return;
+    return;
   }
   SimpleTest.finish();
 }
 
 // ---- test 1 ----
 
 let myFrame1 = document.createElement("iframe");
 myFrame1.src = SAME_ORIGIN_URI;