Bug 1561085 - Enable some ESLint rules for the rest of dom/base/test/**. r=smaug
authorMark Banner <standard8@mozilla.com>
Tue, 25 Jun 2019 07:12:51 +0000
changeset 480005 d3fb71b7f76ee61659bbda935eaa26a2e0ee30e1
parent 480004 2cada2586c93a5f0e5a0869c7943f86ef4bb2c97
child 480006 d97ec86872b313d7c24aaf4b4dddd0d7bb3aaec4
push id113515
push useraciure@mozilla.com
push dateTue, 25 Jun 2019 15:55:32 +0000
treeherdermozilla-inbound@5b1d5d83724a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1561085
milestone69.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 1561085 - Enable some ESLint rules for the rest of dom/base/test/**. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D35711
.eslintignore
dom/base/test/browser_aboutnewtab_process_selection.js
dom/base/test/browser_force_process_selector.js
dom/base/test/browser_inputStream_structuredClone.js
dom/base/test/browser_state_notifications.js
dom/base/test/file_bug416317.xhtml
dom/base/test/file_history_document_open.html
dom/base/test/jsmodules/.eslintrc.js
dom/base/test/referrer_helper.js
dom/base/test/test_NodeIterator_basics_filters.xhtml
dom/base/test/test_bug1037687_subframe.html
dom/base/test/test_bug1091883.html
dom/base/test/test_bug338583.html
dom/base/test/test_bug409380.html
dom/base/test/test_bug431701.html
dom/base/test/test_bug435425.html
dom/base/test/test_bug444546.html
dom/base/test/test_bug482935.html
dom/base/test/test_bug493881.js
dom/base/test/test_bug682463.html
dom/base/test/test_bug704320-1.html
dom/base/test/test_bug704320-2.html
dom/base/test/test_bug782342.html
dom/base/test/test_bug913761.html
dom/base/test/test_bug922681.html
dom/base/test/test_bug976673.html
dom/base/test/test_intersectionobservers.html
dom/base/test/test_messagePort.html
dom/base/test/test_messagemanager_targetchain.html
dom/base/test/test_mutationobservers.html
dom/base/test/test_navigator_language.html
dom/base/test/test_postMessages.html
dom/base/test/test_range_bounds.html
dom/base/test/test_timeout_clamp.html
--- a/.eslintignore
+++ b/.eslintignore
@@ -8,18 +8,16 @@
 **/reftest/**
 **/reftests/**
 
 # Exclude expected objdirs.
 obj*/**
 
 # dom/ exclusions which should be removed (aka ESLint enabled)
 dom/base/*.*
-dom/base/test/*.*
-dom/base/test/jsmodules/**
 dom/media/test/**
 !dom/media/test/marionette/yttest/*.js
 dom/promise/**
 dom/xhr/**
 
 # build/ third-party code
 build/pgo/js-input/**
 
@@ -164,26 +162,33 @@ devtools/server/tests/unit/xpcshell_debu
 dom/canvas/test/webgl-conf/**
 dom/imptests/**
 dom/media/webaudio/test/blink/**
 dom/media/webvtt/**
 dom/svg/test/test_nonAnimStrings.xhtml
 dom/svg/test/test_SVG_namespace_ids.html
 
 # Strange encodings
+dom/base/test/file_bug687859-16.js
 dom/encoding/test/test_utf16_files.html
 dom/encoding/test/file_utf16_be_bom.js
 dom/encoding/test/file_utf16_le_bom.js
 
 # Not parsable
 dom/tests/mochitest/general/test_focusrings.xul
 dom/html/test/test_bug677658.html
 
 # Intentional broken files
 dom/base/test/file_js_cache_syntax_error.js
+dom/base/test/jsmodules/test_syntaxError.html
+dom/base/test/jsmodules/test_syntaxErrorAsync.html
+dom/base/test/jsmodules/module_badSyntax.js
+dom/base/test/jsmodules/test_syntaxErrorInline.html
+dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html
+dom/base/test/test_bug687859.html
 dom/media/tests/mochitest/identity/idp-bad.js
 dom/serviceworkers/test/file_js_cache_syntax_error.js
 dom/serviceworkers/test/parse_error_worker.js
 dom/tests/mochitest/bugs/test_bug531176.html
 dom/webauthn/tests/cbor.js
 dom/workers/test/importScripts_worker_imported3.js
 dom/workers/test/invalid.js
 dom/workers/test/threadErrors_worker1.js
--- a/dom/base/test/browser_aboutnewtab_process_selection.js
+++ b/dom/base/test/browser_aboutnewtab_process_selection.js
@@ -57,20 +57,22 @@ add_task(async function(){
   // Navigate to a content page from the parent side.
   BrowserTestUtils.loadURI(tab2.linkedBrowser, TEST_URL);
   await BrowserTestUtils.browserLoaded(tab2.linkedBrowser, false, TEST_URL);
   is(ppmm.childCount, originalChildCount + 1,
      "Navigating away from the preloaded browser (parent side) should create a new content process.")
 
   // Navigate to a content page from the child side.
   await BrowserTestUtils.switchTab(gBrowser, tab1);
+  /* eslint-disable no-shadow */
   await ContentTask.spawn(tab1.linkedBrowser, null, async function() {
     const TEST_URL = "http://www.example.com/browser/dom/base/test/dummy.html";
     content.location.href = TEST_URL;
   });
+  /* eslint-enable no-shadow */
   await BrowserTestUtils.browserLoaded(tab1.linkedBrowser, false, TEST_URL);
   is(ppmm.childCount, originalChildCount + 2,
      "Navigating away from the preloaded browser (child side) should create a new content process.")
 
   BrowserTestUtils.removeTab(tab1);
   BrowserTestUtils.removeTab(tab2);
 
   // Make sure the preload browser does not keep any of the new processes alive.
@@ -101,9 +103,8 @@ add_task(async function preloaded_state_
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URL);
   let navigatedTabHasState = gBrowser.selectedBrowser.hasAttribute("preloadedState");
   ok(!navigatedTabHasState, "Correctly removed the preloadState attribute when navigating away");
 
   // Remove tabs and preloaded browsers
   BrowserTestUtils.removeTab(gBrowser.selectedTab);
   NewTabPagePreloading.removePreloadedBrowser(window);
 });
-
--- a/dom/base/test/browser_force_process_selector.js
+++ b/dom/base/test/browser_force_process_selector.js
@@ -15,17 +15,17 @@ async function spawnNewAndTest(recur, pi
       if (recur) {
         await spawnNewAndTest(recur - 1, pids);
       } else {
         let observer = () => {
           ok(false, "shouldn't have created a new process");
         };
         Services.obs.addObserver(observer, CONTENT_CREATED);
 
-        await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function(browser) {
+        await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function() {
           // If this new tab caused us to create a new process, the ok(false)
           // should have already happened. Therefore, if we get here, we've
           // passed. Simply remove the observer.
           Services.obs.removeObserver(observer, CONTENT_CREATED);
         });
       }
   });
 }
--- a/dom/base/test/browser_inputStream_structuredClone.js
+++ b/dom/base/test/browser_inputStream_structuredClone.js
@@ -17,28 +17,31 @@ async function runTest(input, url) {
   stream.setData(input, input.length);
 
   let data = {
     inputStream: stream
   };
 
   is(data.inputStream.available(), input.length, "The length of the inputStream matches: " + input.length);
 
+  /* eslint-disable no-shadow */
   let dataBack = await ContentTask.spawn(browser, data, function(data) {
     let dataBack = {
       inputStream: data.inputStream,
       check: true,
     };
 
     if (content.location.href.startsWith('about:')) {
       dataBack.check = data.inputStream instanceof content.Components.interfaces.nsIInputStream;
     }
 
     return dataBack;
   });
+  /* eslint-enable no-shadow */
+
 
   ok(dataBack.check, "The inputStream is a nsIInputStream also on content.");
   ok(data.inputStream instanceof Ci.nsIInputStream, "The original object was an inputStream");
   ok(dataBack.inputStream instanceof Ci.nsIInputStream, "We have an inputStream back from the content.");
 
   BrowserTestUtils.removeTab(tab);
 }
 
--- a/dom/base/test/browser_state_notifications.js
+++ b/dom/base/test/browser_state_notifications.js
@@ -45,25 +45,27 @@ const receive = (topic, p, syncCallback)
           // Some tests need to be executed synchronously when the event is fired.
           if (syncCallback) {
             syncCallback(subject);
           }
           resolve(subject);
         }
       }
     };
+    // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
     const id = setTimeout(timeout, 90000);
     addObserver(observer, topic, false);
     queue.push(topic, resolve);
   });
 };
 receive.queue = [];
 
 const openTab = uri => gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, uri);
 
+// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
 const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
 
 const isData = document => document.URL.startsWith("data:");
 
 const uri1 = "data:text/html;charset=utf-8,<h1>1</h1>";
 // For whatever reason going back on load event doesn't work so timeout it is :(
 const uri2 = "data:text/html;charset=utf-8,<h1>2</h1><script>setTimeout(SpecialPowers.wrap(window).back,100)</script>";
 const uri3 = "data:text/html;charset=utf-8,<h1>3</h1>";
--- a/dom/base/test/file_bug416317.xhtml
+++ b/dom/base/test/file_bug416317.xhtml
@@ -221,39 +221,41 @@
     ::table { background: red; }
     ::select { background: red; }
 
     ..test { background: red; color: yellow; }
     .foo..quux { background: red; color: yellow; }
     .bar. { background: red; color: yellow; }
   </span>
   <script><![CDATA[
+  /* eslint-disable no-shadow */
+
   window.onload = function() {
     doTest();
   }
 
   function doTest(){
     if ( !window.location.hash.includes("target") )
       window.location.hash = "#target";
 
     var root = document.getElementById("root");
     var root2 = document.getElementById("root2");
     var root3 = document.getElementById("root3");
     var results = [];
     var tests = 0, passed = 0;
     var cache = {};
 
     var css = document.getElementById("test").firstChild.nodeValue.split("\n");
-    for ( var i = 0; i < css.length; i++ ) {
+    for ( let i = 0; i < css.length; i++ ) {
       css[i] = css[i].replace(/\/\*.*?\*\//g, "")
         .replace(/^\s*|\s*$/g, "").split(/\s*{/);
     }
 
     var ecss = document.getElementById("error").firstChild.nodeValue.split("\n");
-    for ( var i = 0; i < ecss.length; i++ ) {
+    for ( let i = 0; i < ecss.length; i++ ) {
       ecss[i] = ecss[i].replace(/\/\*.*?\*\//g, "")
         .replace(/^\s*|\s*$/g, "").split(/\s*{/);
     }
 
     var namespaceCheck = {};
 
     var badNamespace = [
       {},
@@ -285,24 +287,24 @@
 
     interfaceCheck(fragment, "Fragment");
     runTest( css, "Fragment", fragment, true );
     check( "Fragment", fragment, true, true );
     runTest( ecss, "SyntaxError: Fragment", fragment, false );
     cacheCheck( "Fragment", fragment );
 
     root.remove( );
-    
+
     interfaceCheck(document, "Document");
     runTest( css, "Document", document, true );
     check( "Document", document, true, false );
     runTest( ecss, "SyntaxError: Document", document, false );
     jqTests("Document", document, "querySelectorAll");
     cacheCheck( "Document", document );
-    
+
     done();
 
     function interfaceCheck(obj, type){
       var q = typeof obj.querySelector === "function";
       assert( q, type + " supports querySelector" );
       var qa = typeof obj.querySelectorAll === "function";
       assert( qa, type + " supports querySelectorAll" );
       return q && qa;
@@ -315,17 +317,17 @@
         var r = document.getElementById("results");
         var li = document.createElement("li");
         var b = document.createElement("b");
         b.appendChild( document.createTextNode( ((passed / tests) * 100).toFixed(1) + "%" ) );
         li.appendChild( b );
         li.appendChild( document.createTextNode( ": " + passed + " passed, " + (tests - passed) + " failed" ) );
         r.appendChild( li );
 
-        for ( var i = 0; i < results.length; i++ ) {
+        for ( let i = 0; i < results.length; i++ ) {
               var li = document.createElement("li");
               var span = document.createElement("span");
               span.style.color = (results[i][0] === "FAIL" ? "red" : "green");
               span.appendChild( document.createTextNode( results[i][0] ) );
               li.appendChild( span );
               li.appendChild( document.createTextNode( " " + results[i][1] ) );
               r.appendChild( li );
         }
@@ -399,24 +401,24 @@
 
       pass = false;
       try {
         if ( root.querySelector )
           root.querySelector();
       } catch(e){ pass = true; }
       assert( pass, type + ".querySelector no value" );
 
-      for ( var i = 0; i < css.length; i++ ) {
+      for ( let i = 0; i < css.length; i++ ) {
         var test = css[i];
         if ( test.length == 2 ) {
           var query = test[0], color = test[1].match(/: ([^\s;]+)/)[1];
-  
+
           try {
             var found = root.querySelectorAll(query);
-  
+
             for ( var f = 0; f < found.length; f++ ) {
               found[f].style.backgroundColor = color;
             }
 
             var pass = color != "red" || found.length === 0;
 
             assert(expect && pass, type + ".querySelectorAll: " + query);
           } catch(e){
@@ -558,42 +560,42 @@
 
             try {
               results = query(q, resolver);
             } catch(e) {
               pass = (e.message === "bad ERROR" ||
                       (e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR));
             }
 
-            assert( pass, type + ": " + name + " Bad Resolver #" + (i+1) + " (" + nq + ")" + 
+            assert( pass, type + ": " + name + " Bad Resolver #" + (i+1) + " (" + nq + ")" +
               (pass ? "" : " Expected: " + extra(ids) + " Received: " + extra(results)) );
           }
         } else {
           var pass = false;
 
           try {
             var results = query(q);
             pass = hasPassed( results, ids );
           } catch(e) {
             pass = e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR;
           }
-  
+
           assert( pass, type + ": " + name + " (" + nq + ")" +
             (pass ? "" : " Expected: " + extra(ids) + " Received: " + extra(results)) );
 
           // For now, don't use checkMatchesSelector when
           // restrict === ":scope" because we have no way to hand the
           // right scope to it yet.
           if (results && restrict !== ":scope")
             checkMatchesSelector( results, q );
         }
 
         function hasPassed(results, ids){
           var pass = (results && results.length == ids.length) || (!results && !ids);
-  
+
           if ( ids && results ) {
             for ( var i = 0; ids && i < ids.length; i++ ) {
               if ( ids[i] !== results[i].getAttribute("id") ) {
                 pass = false;
               }
             }
           } else {
             pass = false;
@@ -604,17 +606,17 @@
 
         function extra(results){
           var extra = " [";
           if ( results ) {
             for ( var i = 0; i < results.length; i++ ) {
               extra += (extra.length > 2 ? "," : "") + "'" + (results[i].id || results[i]) + "'";
             }
           }
-  
+
           extra += "]";
           return extra;
         }
       }
 
       t( "SVG", "*|svg", ["svg1","svg2","svg3"] );
       t( "SVG", "svg|svg", ["svg2","svg3"] );
       t( "SVG", "svg|svg *|circle", ["circle2","circle3"] );
@@ -667,17 +669,17 @@
 
       t( "Element Selector", "p", ["firstp","ap","sndp","en","sap","first"] );
       t( "Element Selector", "body", ["body"], false );
       t( "Element Selector", "html", ["html"], false );
       t( "Parent Element", "div p", ["firstp","ap","sndp","en","sap","first"] );
       var param = query("#object1 param");
       assert( param && param.length == 2, type + ": Object/param as context" );
 
-      var l = query("#length");  
+      var l = query("#length");
       assert( l && l.length, type + ': &lt;input name="length"&gt; cannot be found under IE' );
       var lin = query("#lengthtest input");
       assert( lin && lin.length, type + ': &lt;input name="length"&gt; cannot be found under IE' );
 
       t( "Broken Selector", "[" );
       t( "Broken Selector", "(" );
       t( "Broken Selector", "{" );
       t( "Broken Selector", "<" );
@@ -690,47 +692,47 @@
       t( "ID Selector w/ Element", "ul#first", [] );
       t( "ID selector with existing ID descendant", "#firstp #simon1", ["simon1"] );
       t( "ID selector with nonexistent descendant", "#firstp #foobar", [] );
 
       t( "ID selector using UTF8", "#台北Táiběi", ["台北Táiběi"] );
       t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", ["台北Táiběi","台北"] );
       t( "Descendant ID selector using UTF8", "div #台北", ["台北"] );
       t( "Child ID selector using UTF8", "form > #台北", ["台北"] );
-  
+
       t( "Escaped ID", "#foo\\:bar", ["foo:bar"] );
       t( "Escaped ID", "#test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
       t( "Descendant escaped ID", "div #foo\\:bar", ["foo:bar"] );
       t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
       t( "Child escaped ID", "form > #foo\\:bar", ["foo:bar"] );
       t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
-  
+
       t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] ); // bug #267
       t( "ID Selector, not an ancestor ID", "#form #first", [] );
       t( "ID Selector, not a child ID", "#form > #option1a", [] );
-      
+
       t( "All Children of ID", "#foo > *", ["sndp", "en", "sap"] );
       t( "All Children of ID with no children", "#firstUL > *", [] );
 
       t( "ID selector with nonexistent ancestor", "#asdfasdf #foobar", [] ); // bug #986
 
       //t( "body div#form", [], "ID selector within the context of another element" );
 
       t( "Class Selector", ".blog", ["mark","simon"] );
       t( "Class Selector", ".blog.link", ["simon"] );
       t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
       t( "Parent Class Selector", "p .blog", ["mark","simon"] );
-  
+
       t( "Class selector using UTF8", ".台北Táiběi", ["utf8class1"] );
       t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] );
       t( "Class selector using UTF8", ".台北Táiběi.台北", ["utf8class1"] );
       t( "Class selector using UTF8", ".台北Táiběi, .台北", ["utf8class1","utf8class2"] );
       t( "Descendant class selector using UTF8", "div .台北Táiběi", ["utf8class1"] );
       t( "Child class selector using UTF8", "form > .台北Táiběi", ["utf8class1"] );
-  
+
       t( "Escaped Class", ".foo\\:bar", ["foo:bar"] );
       t( "Escaped Class", ".test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
       t( "Descendant scaped Class", "div .foo\\:bar", ["foo:bar"] );
       t( "Descendant scaped Class", "div .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
       t( "Child escaped Class", "form > .foo\\:bar", ["foo:bar"] );
       t( "Child escaped Class", "form > .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
 
       t( "Comma Support", "a.blog, p", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
@@ -751,23 +753,23 @@
       t( "All Children", "code > *", ["anchor1","anchor2"] );
       t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
       t( "Adjacent", "a + a", ["groups"] );
       t( "Adjacent", "a +a", ["groups"] );
       t( "Adjacent", "a+ a", ["groups"] );
       t( "Adjacent", "a+a", ["groups"] );
       t( "Adjacent", "p + p", ["ap","en","sap"] );
       t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
-      
+
       t( "First Child", "p:first-child", ["firstp","sndp"] );
       t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] );
-      
+
       t( "Last Child", "p:last-child", ["sap"] );
       t( "Last Child", "a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon"] );
-  
+
       t( "Nth-child", "#main form#form > *:nth-child(2)", ["text2"] );
       t( "Nth-child", "#main form#form > :nth-child(2)", ["text2"] );
 
       t( "Nth-child", "#form #select1 option:nth-child(3)", ["option1c"] );
       t( "Nth-child", "#form #select1 option:nth-child(0n+3)", ["option1c"] );
       t( "Nth-child", "#form #select1 option:nth-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] );
       t( "Nth-child", "#form #select1 option:nth-child(1n)", ["option1a", "option1b", "option1c", "option1d"] );
       t( "Nth-child", "#form #select1 option:nth-child(n)", ["option1a", "option1b", "option1c", "option1d"] );
@@ -783,37 +785,37 @@
       t( "Nth-child", "#form #select1 option:nth-child(3n-2)", ["option1a", "option1d"] );
       t( "Nth-child", "#form #select1 option:nth-child(3n-3)", ["option1c"] );
       t( "Nth-child", "#form #select1 option:nth-child(3n+0)", ["option1c"] );
       t( "Nth-child", "#form #select1 option:nth-child(-n+3)", ["option1a", "option1b", "option1c"] );
 
       t( "Attribute Exists", "a[title]", ["google"] );
       t( "Attribute Exists", "*[title]", ["google"] );
       t( "Attribute Exists", "[title]", ["google"] );
-      
+
       t( "Attribute Equals", "a[rel='bookmark']", ["simon1"] );
       t( "Attribute Equals", 'a[rel="bookmark"]', ["simon1"] );
       t( "Attribute Equals", "a[rel=bookmark]", ["simon1"] );
       t( "Multiple Attribute Equals", "#form input[type='hidden'],#form input[type='radio']", ['radio1','radio2','hidden1'] );
       t( "Multiple Attribute Equals", "#form input[type=\"hidden\"],#form input[type='radio']", ['radio1','radio2','hidden1'] );
       t( "Multiple Attribute Equals", "#form input[type=hidden],#form input[type=radio]", ['radio1','radio2','hidden1'] );
-  
+
       t( "Attribute selector using UTF8", "span[lang=中文]", ["台北"] );
-  
+
       t( "Attribute Begins With", "a[href ^= 'http://www']", ["google","yahoo"] );
       t( "Attribute Ends With", "a[href $= 'org/']", ["mark"] );
       t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
-  
+
       // t("Select options via [selected]", "#select1 option[selected]", ["option1a"] );
       t("Select options via [selected]", "#select1 option[selected]", [] );
       t("Select options via [selected]", "#select2 option[selected]", ["option2d"] );
       t("Select options via [selected]", "#select3 option[selected]", ["option3b", "option3c"] );
-  
+
       t( "Grouped Form Elements", "input[name='foo[bar]']", ["hidden2"] );
-  
+
       t( ":not() Existing attribute", "#form select:not([multiple])", ["select1", "select2"]);
       t( ":not() Equals attribute", "#form select:not([name=select1])", ["select2", "select3"]);
       t( ":not() Equals quoted attribute", "#form select:not([name='select1'])", ["select2", "select3"]);
 
       t( "First Child", "p:first-child", ["firstp","sndp"] );
       t( "Last Child", "p:last-child", ["sap"] );
       t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
       t( "Empty", "ul:empty", ["firstUL"] );
@@ -1271,36 +1273,36 @@
     <rect id="rect3" x="1" y="1" width="1198" height="398" fill="none" stroke="blue" stroke-width="2"/>
     <circle id="circle3" cx="600" cy="200" r="100" fill="red" stroke="blue" stroke-width="10"  />
   </svg>
   </div>
 
   <h1 id="header">jQuery Test Suite</h1>
   <h2 id="banner"></h2>
   <h2 id="userAgent"></h2>
-  
+
   <!-- Test HTML -->
   <div id="nothiddendiv" style="height:1px;background:white;">
 
     <div id="nothiddendivchild"></div>
   </div>
   <!-- Test for scoping -->
   <nosuchtag id="outerbogustag">
     <nosuchtag id="innerbogustag"></nosuchtag>
   </nosuchtag>
   <!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
   <iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe>
   <dl id="dl" style="display:none;">
   <div id="main" style="display: none;">
     <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
 
     <p id="ap">
-      Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>, 
-      <a id="groups" href="http://groups.google.com/">Google Groups</a>. 
-      This link has <code><a href="http://smin" id="anchor1">class="blog"</a></code>: 
+      Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
+      <a id="groups" href="http://groups.google.com/">Google Groups</a>.
+      This link has <code><a href="http://smin" id="anchor1">class="blog"</a></code>:
       <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a>
 
     </p>
     <div id="foo">
 
       <p id="sndp">Everything inside the red border is inside a div with <code>id="foo"</code>.</p>
       <p lang="en" id="en">This is a normal link: <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p>
       <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
@@ -1317,24 +1319,24 @@
 
       <input type="radio" name="radio2" id="radio2" checked="checked"/>
 
       <input type="checkbox" name="check" id="check1" checked="checked"/>
       <input type="checkbox" id="check2" value="on"/>
 
       <input type="hidden" name="hidden" id="hidden1"/>
       <input type="text" style="display:none;" name="foo[bar]" id="hidden2"/>
-      
+
       <input type="text" id="name" name="name" value="name" />
-      
+
       <button id="button" name="button">Button</button>
-      
+
       <textarea id="area1" maxlength="30">foobar</textarea>
 
-      
+
       <select name="select1" id="select1">
         <option id="option1a" class="emptyopt" value="">Nothing</option>
         <option id="option1b" value="1">1</option>
         <option id="option1c" value="2">2</option>
         <option id="option1d" value="3">3</option>
       </select>
       <select name="select2" id="select2">
 
@@ -1345,62 +1347,62 @@
       </select>
       <select name="select3" id="select3" multiple="multiple">
         <option id="option3a" class="emptyopt" value="">Nothing</option>
 
         <option id="option3b" selected="selected" value="1">1</option>
         <option id="option3c" selected="selected" value="2">2</option>
         <option id="option3d" value="3">3</option>
       </select>
-      
+
       <object id="object1" codebase="stupid">
         <param name="p1" value="x1" />
         <param name="p2" value="x2" />
 
       </object>
-      
+
       <span id="台北Táiběi"></span>
       <span id="台北" lang="中文"></span>
       <span id="utf8class1" class="台北Táiběi 台北"></span>
       <span id="utf8class2" class="台北"></span>
       <span id="foo:bar" class="foo:bar"></span>
       <span id="test.foo[5]bar" class="test.foo[5]bar"></span>
-      
+
       <foo_bar id="foobar">test element</foo_bar>
 
     </form>
     <b id="floatTest">Float test.</b>
     <iframe id="iframe" name="iframe"></iframe>
     <form id="lengthtest">
       <input type="text" id="length" name="test"/>
       <input type="text" id="idTest" name="id"/>
     </form>
     <table id="table"></table>
 
-    
+
     <div id="fx-queue">
       <div id="fadein" class='chain test'>fadeIn<div>fadeIn</div></div>
       <div id="fadeout" class='chain test out'>fadeOut<div>fadeOut</div></div>
-      
+
       <div id="show" class='chain test'>show<div>show</div></div>
       <div id="hide" class='chain test out'>hide<div>hide</div></div>
 
-      
+
       <div id="togglein" class='chain test'>togglein<div>togglein</div></div>
       <div id="toggleout" class='chain test out'>toggleout<div>toggleout</div></div>
-    
-      
+
+
       <div id="slideup" class='chain test'>slideUp<div>slideUp</div></div>
       <div id="slidedown" class='chain test out'>slideDown<div>slideDown</div></div>
-      
+
       <div id="slidetogglein" class='chain test'>slideToggleIn<div>slideToggleIn</div></div>
 
       <div id="slidetoggleout" class='chain test out'>slideToggleOut<div>slideToggleOut</div></div>
     </div>
-    
+
     <div id="fx-tests"></div>
 
     <form id="testForm" action="#" method="get">
       <textarea name="T3" rows="2" cols="15">?
 Z</textarea>
       <input type="hidden" name="H1" value="x" />
       <input type="hidden" name="H2" />
 
@@ -1457,14 +1459,14 @@ Z</textarea>
       <div id="nonnodes"><span>hi</span> there <!-- mon ami --></div>
 
       <div id="t2037">
         <div><div class="hidden">hidden</div></div>
       </div>
     </div>
   </div>
   </dl>
-  
+
   <ol id="tests"></ol>
 </div>
 <ol id="results"></ol>
 </body>
 </html>
--- a/dom/base/test/file_history_document_open.html
+++ b/dom/base/test/file_history_document_open.html
@@ -1,1 +1,1 @@
-<script>function f() { history.length; } window.onload = function() { var f = window.f; document.open(); document.close(); parent.continueTest(f); }</script>
+<script>function f() { history.length; } window.onload = function() { var func = window.f; document.open(); document.close(); parent.continueTest(func); }</script>
new file mode 100644
--- /dev/null
+++ b/dom/base/test/jsmodules/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+  "parserOptions": {
+    "sourceType": "module",
+  }
+};
--- a/dom/base/test/referrer_helper.js
+++ b/dom/base/test/referrer_helper.js
@@ -1,8 +1,11 @@
+// This helper expects these globals to be defined.
+/* global PARAMS, SJS, testCases */
+
 /*
  * common functionality for iframe, anchor, and area referrer attribute tests
  */
 const GET_RESULT = SJS + 'ACTION=get-test-results';
 const RESET_STATE = SJS + 'ACTION=resetState';
 
 SimpleTest.waitForExplicitFinish();
 var advance = function() { tests.next(); };
@@ -75,31 +78,31 @@ var tests = (function*() {
   var iframe = document.getElementById("testframe");
 
   for (var j = 0; j < testCases.length; j++) {
     if (testCases[j].PREFS) {
       yield SpecialPowers.pushPrefEnv({"set": testCases[j].PREFS}, advance);
     }
 
     var actions = testCases[j].ACTION;
-    var tests = testCases[j].TESTS;
+    var subTests = testCases[j].TESTS;
     for (var k = 0; k < actions.length; k++) {
       var actionString = actions[k];
-      for (var i = 0; i < tests.length; i++) {
+      for (var i = 0; i < subTests.length; i++) {
         yield resetState();
         var searchParams = new URLSearchParams();
         searchParams.append("ACTION", actionString);
-        searchParams.append("NAME", tests[i].NAME);
+        searchParams.append("NAME", subTests[i].NAME);
         for (var l of PARAMS) {
-          if (tests[i][l]) {
-            searchParams.append(l, tests[i][l]);
+          if (subTests[i][l]) {
+            searchParams.append(l, subTests[i][l]);
           }
         }
-        var schemeFrom = tests[i].SCHEME_FROM || "http";
+        var schemeFrom = subTests[i].SCHEME_FROM || "http";
         yield iframe.src = schemeFrom + SJS + searchParams.toString();
-        yield checkIndividualResults(tests[i].DESC, tests[i].RESULT, tests[i].NAME);
+        yield checkIndividualResults(subTests[i].DESC, subTests[i].RESULT, subTests[i].NAME);
       };
     };
   };
 
   // complete.
   SimpleTest.finish();
 })();
--- a/dom/base/test/test_NodeIterator_basics_filters.xhtml
+++ b/dom/base/test/test_NodeIterator_basics_filters.xhtml
@@ -16,17 +16,17 @@
 <!-- comment -->
 <?body processing instruction?>
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript"><![CDATA[
   function compare_arrays(e, f, label) {
     var length = (e.length > f.length) ? e.length : f.length;
     for (var i = 0; i < length; i += 1) {
-      if (e[i] > 0) 
+      if (e[i] > 0)
         is(f[i], e[i], label + " - index " + i + ": ");
       else
         todo_is(f[i], -e[i], label + " - index " + i + ": ");
     }
   }
 
   /** DOM Traversal: NodeIterator: Basics **/
   // NOTE: If you change the document structure, you have to make sure
@@ -105,74 +105,74 @@
 
   // backwards
   found.length = 0;
   while (node = iterator.previousNode())
     found.unshift(node.nodeType);
   compare_arrays(expect_f, found, 'filtered backward');
 
   function checkBadFilter(method, n) {
-    var iterator =
+    var iter =
       document.createNodeIterator(document, NodeFilter.SHOW_ALL,
                                   function() {
                                     if (n < 0)
-                                      iterator.detach();
+                                      iter.detach();
                                     return NodeFilter.FILTER_ACCEPT;
                                   });
     while (--n >= 0)
-      iterator.nextNode();
+      iter.nextNode();
     try {
-      iterator[method]();
+      iter[method]();
       ok(true, "Able to call " + method + " on a NodeIterator after calling no-op detach()");
     } catch (x) { ok(false, x) }
   }
   checkBadFilter("nextNode", 2);
   checkBadFilter("previousNode", 3);
 
   (function() {
     // Implementing the scenario outlined in
     // http://bugzilla.mozilla.org/show_bug.cgi?id=552110#c4
 
-    var iterator = (function(filter) {
+    var iter = (function(filt) {
       var grandparent = document.createElement("div"),
           parent = document.createElement("span");
 
       grandparent.appendChild(parent);
       parent.appendChild(document.createElement("img"));
       parent.appendChild(document.createElement("p"));
 
       return document.createNodeIterator(grandparent,
                                          NodeFilter.SHOW_ALL,
-                                         filter);
-    })(function filter(n) {
+                                         filt);
+    })(function(n) {
       if (n.nodeName != "img")
         return NodeFilter.FILTER_ACCEPT;
 
-      iterator.detach();
+      iter.detach();
 
       n.parentNode.remove();
       // Drop any node references passed into this function.
       for (var i = 0; i < arguments.length; ++i)
         arguments[i] = null;
       ok(!n, "arguments[0] = null should have nulled out n");
 
       // Try to trigger GC.
       var xhr = new XMLHttpRequest();
       xhr.open("GET", location.href, false);
       xhr.send();
 
       return NodeFilter.FILTER_SKIP;
     });
 
-    is(iterator.nextNode().nodeName, "div",
-       "iterator.nextNode() returned the wrong node");
-    is(iterator.nextNode().nodeName, "span",
-       "iterator.nextNode() returned the wrong node");
+    is(iter.nextNode().nodeName, "div",
+       "iter.nextNode() returned the wrong node");
+    is(iter.nextNode().nodeName, "span",
+       "iter.nextNode() returned the wrong node");
     try {
-      var p = iterator.nextNode();
-      ok(false, "iterator.nextNode() should have thrown, but instead it returned <" + p.nodeName + ">");
+      var p = iter.nextNode();
+      ok(false, "iter.nextNode() should have thrown, but instead it returned <" + p.nodeName + ">");
     } catch (x) { ok(true, x) }
   })();
-        
+
 ]]></script>
 </pre>
 </body>
 </html>
--- a/dom/base/test/test_bug1037687_subframe.html
+++ b/dom/base/test/test_bug1037687_subframe.html
@@ -2,17 +2,16 @@
 <html>
 <head>
 <script type="application/javascript">
   var SimpleTest = window.parent.SimpleTest;
   var ok = window.parent.ok;
   var is = window.parent.is;
 
   var host;
-  var sr;
   var embed;
   var object;
   var iframe;
   var resourceLoadCount = 0;
 
   function resourceLoaded(event) {
     ++resourceLoadCount;
     ok(true, event.target + " got " + event.load);
@@ -29,17 +28,17 @@
     var info = document.createElement("div");
     info.textContent = type;
     sr.appendChild(info);
     sr.appendChild(el);
   }
 
   function test() {
     host = document.getElementById("host");
-    sr = host.attachShadow({mode: 'open'});
+    let sr = host.attachShadow({mode: 'open'});
     embed = createResource(sr, "embed");
     object = createResource(sr, "object");
     iframe = createResource(sr, "iframe");
   }
 </script>
 </head>
 <body onload="test()">
 <div id="host"></div>
--- a/dom/base/test/test_bug1091883.html
+++ b/dom/base/test/test_bug1091883.html
@@ -38,27 +38,27 @@ function getFrameOrigin(i) {
 function getSubframeOrigin(i) {
   return origins[((i / numOrigins) | 0) % 3];
 }
 function getTargetOrigin(i) {
   return origins[i % 3];
 }
 
 // Create the frames, and tell them which subframes to load.
-for (var i = 0; i < numTests; i++) {
+for (let i = 0; i < numTests; i++) {
   var frame = document.createElement("iframe");
   frame.src = getFrameOrigin(i) +
               "/tests/dom/base/test/file_bug1091883_frame.html#" +
               getSubframeOrigin(i);
   document.body.appendChild(frame);
 }
 
 // Navigate all subframes to the target.
 window.onload = function() {
-  for (var i = 0; i < numTests; i++) {
+  for (let i = 0; i < numTests; i++) {
     frames[i].frames[0].location = getTargetOrigin(i) +
         "/tests/dom/base/test/file_bug1091883_target.html#" + i;
   }
 };
 
 // Check referrer messages from the target.
 var results = {};
 function makeResultsKey(i) {
--- a/dom/base/test/test_bug338583.html
+++ b/dom/base/test/test_bug338583.html
@@ -53,24 +53,24 @@ https://bugzilla.mozilla.org/show_bug.cg
   function runAllTests() {
     // these tests run asynchronously, and they will take 8000 ms
     var all_tests = [
       doTest1, doTest1_e, doTest1_f, doTest2, doTest3, doTest3_b, doTest3_c, doTest3_d,
       doTest3_e, doTest3_f, doTest3_g, doTest3_h, doTest4, doTest4_b,
       doTest5, doTest5_b, doTest5_c, doTest5_e, doTest6, doTest7
     ];
 
-    for (var test_id=0; test_id < all_tests.length; ++test_id) {
+    for (let test_id=0; test_id < all_tests.length; ++test_id) {
       gTestsHaveFinished[test_id] = false;
       var fn = all_tests[test_id];
       fn(test_id);
     }
 
     setTimeout(function() {
-      for (var test_id=0; test_id < all_tests.length; ++test_id) {
+      for (let test_id=0; test_id < all_tests.length; ++test_id) {
         if (!gTestsHaveFinished[test_id]) {
           ok(false, "Test " + test_id + " took too long");
           setTestHasFinished(test_id);
         }
       }
     }, 60000 * stress_factor); // all tests together are supposed to take less than 1 minute
   }
 
@@ -176,17 +176,17 @@ https://bugzilla.mozilla.org/show_bug.cg
     } catch (e) {
       ok(false, "Test 1.e failed");
     }
     setTestHasFinished(test_id);
   }
 
   function doTest1_f(test_id) {
     var called_on_error = false;
-  
+
     gEventSourceObj1_f = new EventSource("file_bug869432.eventsource");
     gEventSourceObj1_f.onopen = function(e) {
       ok(false, "Test 1.f failed: onopen was called");
     };
     gEventSourceObj1_f.onmessage = function(e) {
       ok(false, "Test 1.f failed: onmessage was called");
     };
     gEventSourceObj1_f.onerror = function(e) {
@@ -424,18 +424,18 @@ https://bugzilla.mozilla.org/show_bug.cg
     }, parseInt(3000*stress_factor));
   }
 
 // in order to test (5)
 //   a) valid access-control xsite request
 //   b) invalid access-control xsite request
 //   c) valid access-control xsite request on a restricted page with credentials
 //   d) valid access-control xsite request on a restricted page without credentials
-//   e) valid access-control xsite request on a restricted page when the parameter withCredentials is a getter 
-//   f) valid access-control xsite request on a restricted page when the parameter withCredentials is missing 
+//   e) valid access-control xsite request on a restricted page when the parameter withCredentials is a getter
+//   f) valid access-control xsite request on a restricted page when the parameter withCredentials is missing
 
   function doTest5(test_id)
   {
     gEventSourceObj5_a = new EventSource("http://example.org/tests/dom/base/test/accesscontrol.resource");
 
     gEventSourceObj5_a.onmessage = fn_onmessage;
     gEventSourceObj5_a.hits = [];
     gEventSourceObj5_a.hits['fn_onmessage'] = 0;
@@ -493,27 +493,27 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   function doTest5_d(test_id)
   {
     var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
     xhr.open("GET", "https://example.com/tests/dom/base/test/file_restrictedEventSource.sjs?test=user2_xhr", true, "user 2", "password 2");
     xhr.send();
     xhr.onloadend = function() {
       ok(xhr.status == 200, "Failed to set credentials in test 5.d");
-  
+
       gEventSourceObj5_d = new EventSource("https://example.com/tests/dom/base/test/file_restrictedEventSource.sjs?test=user2_evtsrc");
       ok(!gEventSourceObj5_d.withCredentials, "Wrong withCredentials in test 5.d");
-  
+
       gEventSourceObj5_d.onmessage = function(e) {
         ok(e.origin == "https://example.com", "Wrong Origin in test 5.d");
         fn_onmessage(e);
       };
       gEventSourceObj5_d.hits = [];
       gEventSourceObj5_d.hits['fn_onmessage'] = 0;
-  
+
       setTimeout(function() {
         ok(gEventSourceObj5_d.hits['fn_onmessage'] == 0, "Test 5.d failed");
         gEventSourceObj5_d.close();
         setTestHasFinished(test_id);
       }, parseInt(3000*stress_factor));
     };
   }
 
@@ -600,20 +600,20 @@ https://bugzilla.mozilla.org/show_bug.cg
   function doTest7(test_id)
   {
     gEventSourceObj7 = new EventSource("delayedServerEvents.sjs");
     gEventSourceObj7.msg_received = [];
     gEventSourceObj7.onmessage = function(e)
     {
       e.target.msg_received.push(e.data);
     }
-    
+
     setTimeout(function() {
       gEventSourceObj7.close();
-      
+
       ok(gEventSourceObj7.msg_received[0] == "" &&
          gEventSourceObj7.msg_received[1] == "delayed1" &&
          gEventSourceObj7.msg_received[2] == "delayed2", "Test 7 failed");
 
       document.getElementById('waitSpan').innerHTML = '';
       setTestHasFinished(test_id);
     }, parseInt(8000*stress_factor));
   }
@@ -658,9 +658,8 @@ https://bugzilla.mozilla.org/show_bug.cg
   SimpleTest.requestFlakyTimeout("untriaged");
   addLoadEvent(doTest);
 
 </script>
 </pre>
   <span id=waitSpan>Wait please...</span>
 </body>
 </html>
-
--- a/dom/base/test/test_bug409380.html
+++ b/dom/base/test/test_bug409380.html
@@ -7,23 +7,24 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 409380</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=409380">Mozilla Bug 409380</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 409380 **/
 
+// eslint-disable-next-line complexity
 function runRangeTest()
 {
   // Bug 336381
   // This is a case which can't be supported (at least not at the moment)
   // because DOM Range requires that when the start boundary point is text node,
   // it must be splitted. But in this case boundary point doesn't have parent,
   // so splitting doesn't work.
   var zz = document.getElementById("connectedDiv").firstChild;
@@ -358,21 +359,20 @@ function runRangeTest()
 
   hadException = false;
   try {
     range2.compareBoundaryPoints(range.END_TO_END, range);
   } catch (ex) {
     hadException = true;
   }
   ok(!hadException, "Shouldn't have got an exception!");
-  
+
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runRangeTest);
 
 </script>
 </pre>
 <div id="connectedDiv">zz</div>
 </body>
 </html>
-
--- a/dom/base/test/test_bug431701.html
+++ b/dom/base/test/test_bug431701.html
@@ -32,17 +32,17 @@ var docSources = [
   "iframe2_bug431701.html",
   "iframe3_bug431701.html",
   "iframe4_bug431701.xml",
   "iframe5_bug431701.xml",
   "iframe6_bug431701.xml",
   "iframe7_bug431701.xml",
 ];
 
-for (var i = 0; i < docSources.length; ++i) {
+for (let i = 0; i < docSources.length; ++i) {
   document.getElementsByTagName("iframe")[i].src = docSources[i];
 }
 
 function frameDoc(id) {
   return function() { return $(id).contentDocument; };
 }
 
 function createDoc() {
@@ -89,32 +89,31 @@ function doTest(idx) {
 addLoadEvent(function() {
    SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], startTest);
 });
 
 function startTest() {
   // sanity check
   isnot("", null, "Shouldn't be equal!");
 
-  for (var i = 0; i < tests.length; ++i) {
+  for (let i = 0; i < tests.length; ++i) {
     doTest(i);
   }
 
   // Now check what xhr does
   var xhr = new XMLHttpRequest();
   xhr.open("POST", document.location.href);
   xhr.send(createDoc());
   is(SpecialPowers.wrap(xhr).channel.QueryInterface(SpecialPowers.Ci.nsIHttpChannel)
                 .getRequestHeader("Content-Type"),
      "application/xml;charset=UTF-8", "Testing correct type on the wire");
   xhr.abort();
-                     
+
   SimpleTest.finish();
 };
 
 
 
 
 </script>
 </pre>
 </body>
 </html>
-
--- a/dom/base/test/test_bug435425.html
+++ b/dom/base/test/test_bug435425.html
@@ -7,24 +7,23 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 435425</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=435425">Mozilla Bug 435425</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 435425 **/
 
-var xhr = null;
 var upload = null;
 var currentEvents = null;
 var expectedResponseText = null;
 var uploadTotal = 0;
 var currentProgress = -1;
 
 function logEvent(evt) {
   var i = 0;
@@ -64,17 +63,17 @@ function logEvent(evt) {
     currentProgress = -1;
   }
 
   ok(i != currentEvents.length, "Extra or wrong event?");
   is(evt.type, currentEvents[i].type, "Wrong event!")
   ok(evt.target instanceof currentEvents[i].target,
      "Wrong event target [" + evt.target + "," + evt.type + "]!");
 
-  // If we handled non-optional event, remove all optional events before the 
+  // If we handled non-optional event, remove all optional events before the
   // handled event and then the non-optional event from the list.
   if (!currentEvents[i].optional) {
     for (;i != -1; --i) {
       currentEvents.shift();
     }
   }
 }
 
@@ -97,17 +96,17 @@ function maybeStop(evt) {
 function openXHR(xhr, method, url, privileged) {
   if (privileged)
     SpecialPowers.wrap(xhr).open(method, url);
   else
     xhr.open(method, url);
 }
 
 function start(obj) {
-  xhr = new XMLHttpRequest();
+  let xhr = new XMLHttpRequest();
   upload = xhr.upload;
   currentEvents = obj.expectedEvents;
   expectedResponseText = obj.withUpload;
   currentProgress = -1;
   xhr.onload =
     function(evt) {
       if (expectedResponseText) {
         is(evt.target.responseText, expectedResponseText, "Wrong responseText");
@@ -203,17 +202,17 @@ for (var midLength = 0; midLength < (0x0
 
 for (var largeLength = 0; largeLength < (0x0000FFFF + 2); ++largeLength) {
   large += "A";
 }
 
 const XHR = XMLHttpRequest;
 const UPLOAD = XMLHttpRequestUpload;
 
-var tests = 
+var tests =
   [
     { method: "GET", withUpload: none, testAbort: false, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
                        {target: XHR, type: "progress", optional: false},
                        {target: XHR, type: "load", optional: false},
                        {target: XHR, type: "loadend", optional: false}]},
     { method: "GET", withUpload: none, testAbort: true, testRedirectError: false, testNetworkError: false,
       expectedEvents: [{target: XHR, type: "loadstart", optional: false},
@@ -424,9 +423,8 @@ function nextTest() {
 ok("upload" in (new XMLHttpRequest()), "XMLHttpRequest.upload isn't supported!");
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 
 </script>
 </pre>
 </body>
 </html>
-
--- a/dom/base/test/test_bug444546.html
+++ b/dom/base/test/test_bug444546.html
@@ -24,17 +24,17 @@ https://bugzilla.mozilla.org/show_bug.cg
        color: white;
      }
    </style>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=444546">Mozilla Bug 444546</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 444546 **/
 
   var xhrCount = 5;
   var xhrs = new Array();
@@ -55,19 +55,19 @@ https://bugzilla.mozilla.org/show_bug.cg
     }
     if (evt.target.max == -1 || evt.target.max < diff) {
       evt.target.max = diff;
     }
 
     evt.target.log.textContent = diff + "ms";
     evt.target.prevTime = time;
     if (evt.lengthComputable) {
-      var loaded = (evt.loaded / evt.total);
-      if (loaded < 1) {
-        evt.target.log.style.width = (loaded * 400) + "px";
+      var fractionLoaded = (evt.loaded / evt.total);
+      if (fractionLoaded < 1) {
+        evt.target.log.style.width = (fractionLoaded * 400) + "px";
       }
     }
   }
 
   function loaded(evt) {
     evt.target.log.style.width = "400px";
     evt.target.log.style.background = "green";
     if ("xhr" in evt.target) {
--- a/dom/base/test/test_bug482935.html
+++ b/dom/base/test/test_bug482935.html
@@ -21,17 +21,17 @@ function clearCache() {
 // Tests that the response is cached if the request is cancelled
 // after it has reached state 4
 function testCancelInPhase4() {
 
   clearCache();
 
   // First request - should be loaded from server
   var xhr = new XMLHttpRequest();
-  xhr.addEventListener("readystatechange", function(e) {
+  xhr.addEventListener("readystatechange", function() {
     if (xhr.readyState < xhr.DONE) return;
     is(xhr.readyState, xhr.DONE, "wrong readyState");
     xhr.abort();
     SimpleTest.executeSoon(function() {
       // This request was cancelled, so the responseText should be empty string
       is(xhr.responseText, "", "Expected empty response to cancelled request");
 
       // Second request - should be found in cache
--- a/dom/base/test/test_bug493881.js
+++ b/dom/base/test/test_bug493881.js
@@ -1,11 +1,11 @@
-/** 
+/**
  * Test for Bug 493881: Changes to legacy HTML color properties before the BODY is loaded
- * should be ignored. Additionally, after BODY loads, setting any of these properties to undefined 
+ * should be ignored. Additionally, after BODY loads, setting any of these properties to undefined
  * should cause them to be returned as the string "undefined".
  */
 
 SimpleTest.waitForExplicitFinish();
 
 var legacyProps = ["fgColor", "bgColor", "linkColor", "vlinkColor", "alinkColor"];
 var testColors = ["blue", "silver", "green", "orange", "red"];
 var rgbTestColors = ["rgb(255, 0, 0)", "rgb(192, 192, 192)", "rgb(0, 128, 0)", "rgb(255, 165, 0)", "rgb(255, 0, 0)"];
@@ -21,52 +21,52 @@ function setAndTestProperty(prop, color)
   is(document[prop], initial, "document[" + prop + "] not ignored before body");
   return initial;
 }
 
 /**
  * Attempt to set legacy color properties before BODY exists, and verify that such
  * attempts are ignored.
  */
-for (var i = 0; i < legacyProps.length; i++) {
+for (let i = 0; i < legacyProps.length; i++) {
   initialValues[i] = setAndTestProperty(legacyProps[i], testColors[i]);
 }
 
 /**
  * After BODY loads, run some more tests.
  */
 addLoadEvent( function() {
   // Verify that the legacy color properties still have their original values.
-  for (var i = 0; i < legacyProps.length; i++) {
+  for (let i = 0; i < legacyProps.length; i++) {
     is(document[legacyProps[i]], initialValues[i], "document[" + legacyProps[i] + "] altered after body load");
   }
-  
+
   // Verify that legacy color properties applied before BODY are really ignored when rendering.
   // Save current computed style colors for later use.
-  for (i = 0; i < idPropList.length; i++) {
+  for (let i = 0; i < idPropList.length; i++) {
     var style = window.getComputedStyle(document.getElementById(idPropList[i].id));
     var color = style.getPropertyValue(idPropList[i].prop);
     idPropList[i].initialComputedColor = color;
     isnot(color, rgbTestColors[i], "element rendered using before-body style");
   }
   // XXX: Can't get links to visually activate via script events, so can't verify
   // that the alinkColor property was not applied.
-  
+
   // Verify that setting legacy color props to undefined after BODY loads will cause them
   // to be read as the string "undefined".
-  for (var i = 0; i < legacyProps.length; i++) {
+  for (let i = 0; i < legacyProps.length; i++) {
     document[legacyProps[i]] = undefined;
-    is(document[legacyProps[i]], "undefined", 
+    is(document[legacyProps[i]], "undefined",
       "Unexpected value of " + legacyProps[i] + " after setting to undefined");
   }
-  
+
   // Verify that setting legacy color props to undefined led to result
   // of parsing undefined as a color.
-  for (i = 0; i < idPropList.length; i++) {
+  for (let i = 0; i < idPropList.length; i++) {
     var style = window.getComputedStyle(document.getElementById(idPropList[i].id));
     var color = style.getPropertyValue(idPropList[i].prop);
-    is(color, "rgb(0, 239, 14)", 
+    is(color, "rgb(0, 239, 14)",
       "element's style should get result of parsing undefined as a color");
   }
 
   // Mark the test as finished.
   setTimeout(SimpleTest.finish, 0);
 });
--- a/dom/base/test/test_bug682463.html
+++ b/dom/base/test/test_bug682463.html
@@ -7,31 +7,31 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 682463</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=682463">Mozilla Bug 682463</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 682463 **/
 
   function text(s) {
     return document.createTextNode(s);
   }
   function div(l,r) {
-    var div = document.createElement("DIV");
-    if (l) div.appendChild(l);
-    if (r) div.appendChild(r);
-    return div;
+    var d = document.createElement("DIV");
+    if (l) d.appendChild(l);
+    if (r) d.appendChild(r);
+    return d;
   }
   function createRange(sn,so,en,eo) {
     var r = document.createRange();
     r.setStart(sn,so);
     r.setEnd(en,eo);
     return r;
   }
   function verifyRange(msg,r,sn,so,en,eo) {
--- a/dom/base/test/test_bug704320-1.html
+++ b/dom/base/test/test_bug704320-1.html
@@ -48,28 +48,28 @@ function checkTestsCompleted() {
   }
 }
 let testsGenerator = {};
 SimpleTest.requestLongerTimeout(4);
 /**
  * This is the main test routine -- serialized by use of a generator.
  * It performs all tests in sequence using four iframes.
  */
-function startTests(testName, testIframeUrls) {
+function startTests(testName, iframeUrls) {
   testsGenerator[testName] = (function*() {
     var testframe = document.getElementById(testName);
     testframe.onload = function() {
       advance(testName);
     }
 
-    // load the test frame from testIframeUrls[url]
+    // load the test frame from iframeUrls[url]
     // it will call back into this function via postMessage when it finishes
     // loading and continue beyond the yield.
-    for(url in testIframeUrls) {
-      yield testframe.src = testIframeUrls[url];
+    for(url in iframeUrls) {
+      yield testframe.src = iframeUrls[url];
       // run test and check result for loaded test URL
       yield checkExpectedGlobalResults(testName);
     }
     checkTestsCompleted();
   })();
 }
 
 for (i = 0; i < testIframeUrls.length; i++) {
--- a/dom/base/test/test_bug704320-2.html
+++ b/dom/base/test/test_bug704320-2.html
@@ -48,28 +48,28 @@ function checkTestsCompleted() {
   }
 }
 let testsGenerator = {};
 SimpleTest.requestLongerTimeout(4);
 /**
  * This is the main test routine -- serialized by use of a generator.
  * It performs all tests in sequence using four iframes.
  */
-function startTests(testName, testIframeUrls) {
+function startTests(testName, iframeUrls) {
   testsGenerator[testName] = (function*() {
     var testframe = document.getElementById(testName);
     testframe.onload = function() {
       advance(testName);
     }
 
-    // load the test frame from testIframeUrls[url]
+    // load the test frame from iframeUrls[url]
     // it will call back into this function via postMessage when it finishes
     // loading and continue beyond the yield.
-    for(url in testIframeUrls) {
-      yield testframe.src = testIframeUrls[url];
+    for(url in iframeUrls) {
+      yield testframe.src = iframeUrls[url];
       // run test and check result for loaded test URL
       yield checkExpectedGlobalResults(testName);
     }
     checkTestsCompleted();
   })();
 }
 
 for (i = 0; i < testIframeUrls.length; i++) {
--- a/dom/base/test/test_bug782342.html
+++ b/dom/base/test/test_bug782342.html
@@ -20,18 +20,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script type="text/javascript">
 SimpleTest.waitForExplicitFinish();
 
 var url = "file_bug782342.txt";
 var xhr = new XMLHttpRequest();
 xhr.open("GET", url, true);
 xhr.responseType = "blob";
 
-function checkHeaders(xhr) {
-  var headers = xhr.getAllResponseHeaders();
+function checkHeaders(xhrInner) {
+  var headers = xhrInner.getAllResponseHeaders();
   dump(headers + "\n");
   var p = headers.split("\n");
 
   var contentType = false;
   var contentLength = false;
 
   for (var i = 0; i < p.length; ++i) {
     var header = p[i].split(':')[0];
@@ -39,19 +39,19 @@ function checkHeaders(xhr) {
       contentType = true;
     else if (header.toLowerCase() == 'content-length')
       contentLength = true;
   }
 
   ok(contentLength == true, "Content-length is part of the headers!");
   ok(contentType == true, "Content-type is part of the headers!");
 
-  var ct = xhr.getResponseHeader('content-type');
+  var ct = xhrInner.getResponseHeader('content-type');
   ok(ct.length > 0, 'Get Response Header - content type: ' + ct);
-  var cl = xhr.getResponseHeader('content-length');
+  var cl = xhrInner.getResponseHeader('content-length');
   ok(cl.length > 0, 'Get Response Header - content length: ' + cl);
 }
 
 xhr.addEventListener("load", function () {
   ok(xhr.status === 200, "Status 200!");
   if (xhr.status === 200) {
     var blob = xhr.response;
     ok(blob, "Blob is: " + blob);
--- a/dom/base/test/test_bug913761.html
+++ b/dom/base/test/test_bug913761.html
@@ -13,17 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=913761">Mozilla Bug 913761</a>
 <script type="application/javascript">
 
   var transportChannel = new MessageChannel();
   transportChannel.port1.onmessage = function (event) {
     ok(true, 'Port Returned.');
     var portToService = event.data.port;
-    portToService.onmessage = function (event) {
+    portToService.onmessage = function () {
       ok(true, "message received");
       SimpleTest.finish();
     };
     portToService.postMessage('READY?');
   }
 
   var serviceChannel = new MessageChannel();
   serviceChannel.port1.onmessage = function (event) {
--- a/dom/base/test/test_bug922681.html
+++ b/dom/base/test/test_bug922681.html
@@ -71,21 +71,21 @@ https://bugzilla.mozilla.org/show_bug.cg
     c = document.createElement("caption");
     testInnerHTML(c, "xyz", "xyz");
     testInnerHTML(c, "\0", "");
     testInnerHTML(c, "<td>", "");
     testInnerHTML(c, "<dd>", "<dd></dd>");
     testInnerHTML(c, "<body>", "");
 
     function testTableBody(tag) {
-        var c = document.createElement(tag);
-        testInnerHTML(c, "abc", "abc");
-        testInnerHTML(c, "<td>", "<tr><td></td></tr>");
-        testInnerHTML(c, "</body>", "");
-        testInnerHTML(c, "<input>", "<input>");
+        var e = document.createElement(tag);
+        testInnerHTML(e, "abc", "abc");
+        testInnerHTML(e, "<td>", "<tr><td></td></tr>");
+        testInnerHTML(e, "</body>", "");
+        testInnerHTML(e, "<input>", "<input>");
     }
     testTableBody("thead");
     testTableBody("tbody");
     testTableBody("tfoot");
 
     c = document.createElement("template");
     testInnerHTML(c, "abc", "abc");
     testInnerHTML(c, "<td>", "<td></td>");
--- a/dom/base/test/test_bug976673.html
+++ b/dom/base/test/test_bug976673.html
@@ -47,33 +47,33 @@ function testSetFocus(aEventType, aCallb
 
     var input = document.getElementById("input");
     input.value = "";
 
     var button = document.getElementById("button");
 
     var movingFocus = false;
     button.addEventListener(aEventType,
-                            function (aEvent) {
+                            function (event) {
                               movingFocus = true;
                               input.focus();
-                              aEvent.preventDefault();
+                              event.preventDefault();
                               button.removeEventListener(aEventType, arguments.callee, true);
                             }, true);
 
     synthesizeMouseAtCenter(button, {});
 
-    window.addEventListener("message", function (aEvent) {
+    window.addEventListener("message", function (event) {
       if (movingFocus) {
-        is(aEvent.data, "input-value: blur",
+        is(event.data, "input-value: blur",
            description + "<input> in the iframe should get blur");
         is(input.value, "focus",
            description + "<input> in the parent should get focus");
       } else {
-        is(aEvent.data, "input-value: focus",
+        is(event.data, "input-value: focus",
            description + "<input> in the iframe should keep having focus");
       }
 
       setTimeout(aCallback, 0);
     }, {once: true});
 
     iframe.contentWindow.postMessage("check", "*");
   }, {once: true});
--- a/dom/base/test/test_intersectionobservers.html
+++ b/dom/base/test/test_intersectionobservers.html
@@ -24,16 +24,17 @@ limitations under the License.
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body onload="onLoad()">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1243846">Mozilla Bug 1243846</a>
 <p id="display"></p>
 <pre id="test">
 <script type="application/javascript">
+  /* eslint "no-shadow": ["error", {"allow": ["done", "next"]}] */
   var tests = [];
   var curDescribeMsg = '';
   var curItMsg = '';
 
   function beforeEach_fn() { };
   function afterEach_fn() { };
 
   function before(fn) {
@@ -144,28 +145,28 @@ limitations under the License.
       }
     } else {
       SimpleTest.finish();
     }
   }
 
   var sinon = {
     spy: function () {
-      var callbacks = [];
+      var cbs = [];
       var fn = function () {
         fn.callCount++;
         fn.lastCall = { args: arguments };
-        if (callbacks.length) {
-          callbacks.shift()();
+        if (cbs.length) {
+          cbs.shift()();
         }
       };
       fn.callCount = 0;
       fn.lastCall = { args: [] };
-      fn.waitForNotification = (fn) => {
-        callbacks.push(fn);
+      fn.waitForNotification = (fn1) => {
+        cbs.push(fn1);
       };
       return fn;
     }
   };
 
   var ASYNC_TIMEOUT = 300;
 
 
@@ -922,34 +923,34 @@ limitations under the License.
             done();
           });
         });
       });
 
     });
 
     describe('observe subframe', function () {
-      
+
       it('should not trigger if target and root are not in the same document',
           function(done) {
 
         var spy = sinon.spy();
         io = new IntersectionObserver(spy, {root: rootEl});
 
         targetEl4.onload = function () {
           targetEl5 = targetEl4.contentDocument.getElementById('target5');
           io.observe(targetEl5);
           callDelayed(function() {
             expect(spy.callCount).to.be(0);
             done();
           });
         }
 
         targetEl4.src = "intersectionobserver_iframe.html";
-      
+
       });
 
       it('boundingClientRect matches target.getBoundingClientRect() for an element inside an iframe',
           function(done) {
 
         io = new IntersectionObserver(function(records) {
           expect(records.length).to.be(1);
           expect(records[0].boundingClientRect.top, targetEl5.getBoundingClientRect().top);
@@ -972,17 +973,17 @@ limitations under the License.
         window.onmessage = function (e) {
           expect(e.data).to.be(true);
           done();
         };
 
         targetEl4.src = "http://example.org/tests/dom/base/test/intersectionobserver_cross_domain_iframe.html";
 
       });
-    
+
     });
 
     describe('takeRecords', function() {
 
       it('supports getting records before the callback is invoked', function(done) {
 
         var lastestRecords = [];
         io = new IntersectionObserver(function(records) {
@@ -997,17 +998,17 @@ limitations under the License.
             return;
           }
           callDelayed(function() {
             expect(lastestRecords.length).to.be(1);
             expect(lastestRecords[0].intersectionRatio).to.be(1);
             done();
           });
         });
-        
+
       });
 
     });
 
     describe('unobserve', function() {
 
       it('removes targets from the internal store', function(done) {
 
--- a/dom/base/test/test_messagePort.html
+++ b/dom/base/test/test_messagePort.html
@@ -16,34 +16,34 @@ https://bugzilla.mozilla.org/show_bug.cg
   function testTransfer() {
     var a = new MessageChannel();
     ok(a, "MessageChannel created");
 
     window.addEventListener('message', receiveMessage);
     function receiveMessage(evt) {
       ok(evt.data.port, "Port has been received!");
 
-      var a = new MessageChannel();
-      ok(a, "MessageChannel created");
+      var a1 = new MessageChannel();
+      ok(a1, "MessageChannel created");
 
       try {
-        evt.data.port.postMessage({port: a.port2});
+        evt.data.port.postMessage({port: a1.port2});
         ok(false, "PostMessage should throw! - no transfered port");
       } catch(e) {
         ok(true, "PostMessage should throw! - no transfered port");
       }
 
       try {
-        evt.data.port.postMessage({port: a.port2}, [a.port2, a.port2]);
+        evt.data.port.postMessage({port: a1.port2}, [a1.port2, a1.port2]);
         ok(false, "PostMessage should throw - no duplicate!");
       } catch(e) {
         ok(true, "PostMessage should throw - no duplicate!");
       }
 
-      evt.data.port.postMessage({port: a.port2}, [a.port2]);
+      evt.data.port.postMessage({port: a1.port2}, [a1.port2]);
     }
 
     a.port1.onmessage = function(evt) {
       ok(evt.data.port, "Port has been received!");
       window.removeEventListener('message', receiveMessage);
       runTest();
     }
 
@@ -69,20 +69,20 @@ https://bugzilla.mozilla.org/show_bug.cg
     ok(a, "MessageChannel created");
 
     window.addEventListener('message', receiveMessage);
     function receiveMessage(evt) {
       ok(evt.data, "Data is 42");
       ok(evt.ports, "Port is received");
       is(evt.ports.length, 1, "Ports.length is 1");
 
-      var a = new MessageChannel();
-      ok(a, "MessageChannel created");
+      var a1 = new MessageChannel();
+      ok(a1, "MessageChannel created");
 
-      evt.ports[0].postMessage(42, [a.port2]);
+      evt.ports[0].postMessage(42, [a1.port2]);
     }
 
     a.port1.onmessage = function(evt) {
       ok(evt.data, "Data is 42");
       ok(evt.ports, "Port is received");
       is(evt.ports.length, 1, "Ports.length is 1");
       window.removeEventListener('message', receiveMessage);
       runTest();
@@ -107,9 +107,8 @@ https://bugzilla.mozilla.org/show_bug.cg
   }
 
   SimpleTest.waitForExplicitFinish();
   runTest();
 
 </script>
 </body>
 </html>
-
--- a/dom/base/test/test_messagemanager_targetchain.html
+++ b/dom/base/test/test_messagemanager_targetchain.html
@@ -70,17 +70,17 @@
           let doc2 = SpecialPowers.wrap(iframe2).contentDocument;
           let iframe3 = doc2.createElement("iframe");
           iframe3.setAttribute("src", contentFrameURL);
 
           iframe3.addEventListener("load", function (e) {
             info("Third iframe loaded");
             let doc3 = SpecialPowers.wrap(iframe3).contentDocument;
             let target = doc3.getElementById("target");
-            target.addEventListener("test-event", function onEvent(e) {
+            target.addEventListener("test-event", function onEvent() {
               is(messageIndex, 2,
                  "target should be the last one to receive the test event");
               messageIndex++;
               SimpleTest.finish();
             });
 
             // Fire test event after load
             SimpleTest.executeSoon(function () {
--- a/dom/base/test/test_mutationobservers.html
+++ b/dom/base/test/test_mutationobservers.html
@@ -4,21 +4,21 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=641821
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 641821</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
-<body onload="runTest()">                                                  
+<body onload="runTest()">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=641821">Mozilla Bug 641821</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-                                
+
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 641821 **/
 
 SimpleTest.requestFlakyTimeout("requestFlakyTimeout is silly. (But make sure marquee has time to initialize itself.)");
 
@@ -48,24 +48,24 @@ function log(str) {
 if (!("ok" in window)) {
   window.ok = function(val, str) {
     log(str + (val ? " PASSED\n" : " FAILED\n"));
   }
 }
 
 if (!("is" in window)) {
   window.is = function(val, refVal, str) {
-    log(str + (val == refVal? " PASSED " : " FAILED ") + 
+    log(str + (val == refVal? " PASSED " : " FAILED ") +
         (val != refVal ? "expected " + refVal + " got " + val + "\n" : "\n"));
   }
 }
 
 if (!("isnot" in window)) {
   window.isnot = function(val, refVal, str) {
-    log(str + (val != refVal? " PASSED " : " FAILED ") + 
+    log(str + (val != refVal? " PASSED " : " FAILED ") +
         (val == refVal ? "Didn't expect " + refVal + "\n" : "\n"));
   }
 }
 
 if (!("SimpleTest" in window)) {
   window.SimpleTest =
   {
     finish: function() {
@@ -362,20 +362,20 @@ function testChildList5() {
 function testNestedMutations() {
   div.textContent = null;
   div.appendChild(document.createTextNode("foo"));
   var m2WasCalled = false;
   m = new M(function(records, observer) {
     is(records[0].type, "characterData", "Should have got characterData");
     observer.disconnect();
     m = null;
-    m3 = new M(function(records, observer) {
+    m3 = new M(function(recordsInner, observerInnder) {
       ok(m2WasCalled, "m2 should have been called before m3!");
-      is(records[0].type, "characterData", "Should have got characterData");
-      observer.disconnect();
+      is(recordsInner[0].type, "characterData", "Should have got characterData");
+      observerInnder.disconnect();
       then(testAdoptNode);
       m3 = null;
     });
     m3.observe(div, { characterData: true, subtree: true});
     div.firstChild.data = "foo";
   });
   m2 = new M(function(records, observer) {
     m2WasCalled = true;
@@ -459,17 +459,17 @@ function testInsertAdjacentHTML() {
       is(records[1].target, d2, "");
       is(records[1].previousSibling, null, "");
       is(records[1].nextSibling, null, "");
       is(records[2].target, d3, "");
       is(records[2].previousSibling, null, "");
       is(records[2].nextSibling, null, "");
       is(records[3].target, doc.body, "");
       is(records[3].previousSibling, d4, "");
-      is(records[3].nextSibling, null, "");      
+      is(records[3].nextSibling, null, "");
       observer.disconnect();
       then(testSyncXHR);
       m = null;
     });
   m.observe(doc, { childList: true, subtree: true });
   d1.insertAdjacentHTML("beforebegin", "<div></div><div></div>");
   d2.insertAdjacentHTML("afterbegin", "<div></div><div></div>");
   d3.insertAdjacentHTML("beforeend", "<div></div><div></div>");
@@ -513,22 +513,22 @@ function testTakeRecords() {
       is(records[0].attributeName, "foo", "");
       is(records[0].attributeNamespace, null, "");
       is(records[0].prevValue, null, "");
       is(records[1].type, "childList", "Should have got childList");
       is(records[1].removedNodes.length, 2, "Should have got removedNodes");
       is(records[1].addedNodes.length, 2, "Should have got addedNodes");
       is(records[2].type, "attributes", "Should have got attributes");
       is(records[2].attributeName, "foo", "");
-      
+
       is(records.length, takenRecords.length, "Should have had similar mutations");
       is(records[0].type, takenRecords[0].type, "Should have had similar mutations");
       is(records[1].type, takenRecords[1].type, "Should have had similar mutations");
       is(records[2].type, takenRecords[2].type, "Should have had similar mutations");
-      
+
       is(records[1].removedNodes.length, takenRecords[1].removedNodes.length, "Should have had similar mutations");
       is(records[1].addedNodes.length, takenRecords[1].addedNodes.length, "Should have had similar mutations");
 
       is(m.takeRecords().length, 0, "Shouldn't have any records");
       observer.disconnect();
       then(testMutationObserverAndEvents);
       m = null;
     });
@@ -565,17 +565,17 @@ function testTakeRecords() {
   var mutationEventCount = 0;
   div.addEventListener("DOMAttrModified", mutationListener);
   div.setAttribute("foo", "bar");
   div.setAttribute("foo", "bar");
   is(mutationEventCount, 1, "Should have got only one mutation event!");
 }
 
 function testExpandos() {
-  var m2 = new M(function(records, observer) {
+  m2 = new M(function(records, observer) {
     is(observer.expandoProperty, true);
     observer.disconnect();
     then(testOutsideShadowDOM);
   });
   m2.expandoProperty = true;
   m2.observe(div, { attributes: true });
   m2 = null;
   if (SpecialPowers) {
@@ -591,17 +591,17 @@ function testExpandos() {
 
 function testOutsideShadowDOM() {
   if (!div.attachShadow) {
     todo(false, "Skipping testOutsideShadowDOM and testInsideShadowDOM " +
          "because attachShadow is not supported");
     then(testMarquee);
     return;
   }
-  var m = new M(function(records, observer) {
+  m = new M(function(records, observer) {
     is(records.length, 1);
     is(records[0].type, "attributes", "Should have got attributes");
     observer.disconnect();
     then(testMarquee);
   });
   m.observe(div, {
       attributes: true,
       childList: true,
@@ -612,17 +612,17 @@ function testOutsideShadowDOM() {
   sr.innerHTML = "<div" + ">text</" + "div>";
   sr.firstChild.setAttribute("foo", "bar");
   sr.firstChild.firstChild.data = "text2";
   sr.firstChild.appendChild(document.createElement("div"));
   div.setAttribute("foo", "bar");
 }
 
 function testMarquee() {
-  var m = new M(function(records, observer) {
+  m = new M(function(records, observer) {
     is(records.length, 1);
     is(records[0].type, "attributes");
     is(records[0].attributeName, "ok");
     is(records[0].oldValue, null);
     observer.disconnect();
     then(testStyleCreate);
   });
   var marquee = document.createElement("marquee");
@@ -719,17 +719,17 @@ function testStyleRemoveProperty2() {
   m.observe(div, { attributes: true });
   is(div.getAttribute("style"), null, "style attribute before unsuccessful removeProperty");
   div.style.removeProperty("color");  // shouldn't generate any mutation records
   div.setAttribute("data-test", "a");
 }
 
 function testAttributeRecordMerging1() {
   ok(true, "testAttributeRecordMerging1");
-  var m = new M(function(records, observer) {
+  m = new M(function(records, observer) {
     is(records.length, 2);
     is(records[0].type, "attributes");
     is(records[0].target, div);
     is(records[0].attributeName, "foo");
     is(records[0].attributeNamespace, null);
     is(records[0].oldValue, null);
 
     is(records[1].type, "attributes");
@@ -752,17 +752,17 @@ function testAttributeRecordMerging1() {
   div.setAttribute("foo", "bar_2");
   div.innerHTML = "<div></div>";
   div.firstChild.setAttribute("foo", "bar_1");
   div.firstChild.setAttribute("foo", "bar_2");
 }
 
 function testAttributeRecordMerging2() {
   ok(true, "testAttributeRecordMerging2");
-  var m = new M(function(records, observer) {
+  m = new M(function(records, observer) {
     is(records.length, 2);
     is(records[0].type, "attributes");
     is(records[0].target, div);
     is(records[0].attributeName, "foo");
     is(records[0].attributeNamespace, null);
     is(records[0].oldValue, "initial");
 
     is(records[1].type, "attributes");
@@ -789,30 +789,30 @@ function testAttributeRecordMerging2() {
   div.setAttribute("foo", "bar_1");
   div.setAttribute("foo", "bar_2");
   div.firstChild.setAttribute("foo", "bar_1");
   div.firstChild.setAttribute("foo", "bar_2");
 }
 
 function testAttributeRecordMerging3() {
   ok(true, "testAttributeRecordMerging3");
-  var m = new M(function(records, observer) {
+  m = new M(function(records, observer) {
     is(records.length, 4);
     is(records[0].type, "attributes");
     is(records[0].target, div);
     is(records[0].attributeName, "foo");
     is(records[0].attributeNamespace, null);
     is(records[0].oldValue, "initial");
 
     is(records[1].type, "attributes");
     is(records[1].target, div.firstChild);
     is(records[1].attributeName, "foo");
     is(records[1].attributeNamespace, null);
     is(records[1].oldValue, "initial");
-    
+
     is(records[2].type, "attributes");
     is(records[2].target, div);
     is(records[2].attributeName, "foo");
     is(records[2].attributeNamespace, null);
     is(records[2].oldValue, "bar_1");
 
     is(records[3].type, "attributes");
     is(records[3].target, div.firstChild);
@@ -840,17 +840,17 @@ function testAttributeRecordMerging3() {
   div.setAttribute("foo", "bar_1");
   div.firstChild.setAttribute("foo", "bar_1");
   div.setAttribute("foo", "bar_2");
   div.firstChild.setAttribute("foo", "bar_2");
 }
 
 function testAttributeRecordMerging4() {
   ok(true, "testAttributeRecordMerging4");
-  var m = new M(function(records, observer) {
+  m = new M(function(records, observer) {
   });
 
   div.setAttribute("foo", "initial");
   div.innerHTML = "<div></div>";
   div.firstChild.setAttribute("foo", "initial");
   m.observe(div, {
       attributes: true,
       subtree: true,
--- a/dom/base/test/test_navigator_language.html
+++ b/dom/base/test/test_navigator_language.html
@@ -114,18 +114,18 @@ https://bugzilla.mozilla.org/show_bug.cg
       actualLanguageChangesFromAVL++;
       checkIfDoneAndProceed();
     }
     window.addEventListener('languagechange', languageChangeAVL);
 
     function* testEvents() {
       for (var i = 0; i < testValues.length; ++i) {
         var data = testValues[i];
-        setTimeout(function(data) {
-          SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', data.accept_languages]]});
+        setTimeout(function(d) {
+          SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', d.accept_languages]]});
         }, 0, data);
         expectedLanguageChanges++;
         yield undefined;
 
         is(actualLanguageChangesFromAVL, expectedLanguageChanges);
         is(actualLanguageChangesFromHandler, expectedLanguageChanges);
 
         is(navigator.language, data.language);
--- a/dom/base/test/test_postMessages.html
+++ b/dom/base/test/test_postMessages.html
@@ -398,37 +398,37 @@ function test_workers() {
 
   var resolve;
 
   var w = new Worker('worker_postMessages.js');
   w.postMessage('workers');
   w.onmessage = function(e) {
     is(e.data, 'ok', "Worker ready!");
 
-    w.onmessage = function(e) {
+    w.onmessage = function(e1) {
       if (!resolve) {
         ok(false, "Unexpected message!");
         return;
       }
 
       let tmp = resolve;
       resolve = null;
-      tmp({ data: e.data, ports: e.ports });
+      tmp({ data: e1.data, ports: e1.ports });
     }
 
     runTests({
       clonableObjectsEveryWhere: true,
       clonableObjectsSameProcess: true,
       transferableObjects: true,
       send: function(what, ports) {
         return new Promise(function(r, rr) {
           resolve = r;
           try {
             w.postMessage(what, ports);
-          } catch(e) {
+          } catch(ex) {
             resolve = null;
             rr();
           }
         });
       },
 
       finished: function() {
         onmessage = null;
@@ -488,25 +488,25 @@ function test_broadcastChannel_inWorkers
   var bc = new BroadcastChannel('postMessagesTest_inWorkers');
   var resolve;
 
   var w = new Worker('worker_postMessages.js');
   w.postMessage('broadcastChannel');
   w.onmessage = function(e) {
     is(e.data, 'ok', "Worker ready!");
 
-    w.onmessage = function(e) {
+    w.onmessage = function(e1) {
       if (!resolve) {
         ok(false, "Unexpected message!");
         return;
       }
 
       let tmp = resolve;
       resolve = null;
-      tmp({ data: e.data, ports: e.ports });
+      tmp({ data: e1.data, ports: e1.ports });
     }
 
     runTests({
       clonableObjectsEveryWhere: true,
       clonableObjectsSameProcess: false,
       transferableObjects: false,
       send: function(what, ports) {
         return new Promise(function(r, rr) {
@@ -576,37 +576,37 @@ function test_messagePort_inWorkers() {
   var mc = new MessageChannel();
   var resolve;
 
   var w = new Worker('worker_postMessages.js');
   w.postMessage('messagePort', [ mc.port2 ]);
   w.onmessage = function(e) {
     is(e.data, 'ok', "Worker ready!");
 
-    w.onmessage = function(e) {
+    w.onmessage = function(e1) {
       if (!resolve) {
         ok(false, "Unexpected message!");
         return;
       }
 
       let tmp = resolve;
       resolve = null;
-      tmp({ data: e.data, ports: e.ports });
+      tmp({ data: e1.data, ports: e1.ports });
     }
 
     runTests({
       clonableObjectsEveryWhere: true,
       clonableObjectsSameProcess: false,
       transferableObjects: true,
       send: function(what, ports) {
         return new Promise(function(r, rr) {
           resolve = r;
           try {
             mc.port1.postMessage(what, ports);
-          } catch(e) {
+          } catch(ex) {
             resolve = null;
             rr();
           }
         });
       },
 
       finished: function() {
         onmessage = null;
--- a/dom/base/test/test_range_bounds.html
+++ b/dom/base/test/test_range_bounds.html
@@ -85,18 +85,18 @@ function runATest(obj) {
       isEmptyRectList(rectlist, testname+": ");
     } else {
       is(rectlist.length, obj.rectList.length,
          annotateName(testname+' should return '+obj.rectList.length+' rects.'));
       if(!obj.rectList.forEach){
         //convert RectList to a real array
         obj.rectList=Array.prototype.slice.call(obj.rectList, 0);
       }
-      obj.rectList.forEach(function(rect,i) {
-        is(_getRect(rectlist[i]),_getRect(rect),
+      obj.rectList.forEach(function(r,i) {
+        is(_getRect(rectlist[i]),_getRect(r),
            annotateName(testname+": item at "+i));
       });
     }
   } finally {
     range.detach();
   }
 }
 /** Test for Bug 396392 **/
--- a/dom/base/test/test_timeout_clamp.html
+++ b/dom/base/test/test_timeout_clamp.html
@@ -15,20 +15,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script>
 SimpleTest.waitForExplicitFinish();
 
 // We need to clear our nesting level periodically.  We do this by firing
 // a postMessage() to get a runnable on the event loop without any setTimeout()
 // nesting.
 function clearNestingLevel() {
   return new Promise(resolve => {
-    window.addEventListener('message', function onMessage() {
-      window.removeEventListener('message', onMessage);
+    window.addEventListener('message', () => {
       resolve();
-    });
+    }, {once: true});
     postMessage('done', '*');
   });
 }
 
 function delayByTimeoutChain(iterations) {
   return new Promise(resolve => {
     let count = 0;
     function tick() {