Bug 1489980 - Enable ESLint for editor/ - Manual fixes. r=masayuki
authorMark Banner <standard8@mozilla.com>
Thu, 13 Sep 2018 07:59:47 +0000
changeset 484524 0d8eb8a0c2b4ad081ffad8ecf172b82d16c38d01
parent 484523 de36f39840c64a50ccc45f8c0593d8dcd651dfc2
child 484525 da39be9798ad66987d684506b69a249f1257d55e
push id241
push userfmarier@mozilla.com
push dateMon, 24 Sep 2018 21:48:02 +0000
reviewersmasayuki
bugs1489980
milestone64.0a1
Bug 1489980 - Enable ESLint for editor/ - Manual fixes. r=masayuki This enables the editor directory to be linted, and fixes the remaining issues raised by ESLint. Various rules were fixed here including, no-shadow, no-undef, no-unused-vars and others. I've generally gone conservative, disabling rules where it doesn't make sense to fix them (e.g. sometimes suggests use-services for tests, but it is only used once, or within a Chrome script). Depends on D5585 Differential Revision: https://phabricator.services.mozilla.com/D5587
.eslintignore
editor/AsyncSpellCheckTestHelper.jsm
editor/composer/test/test_bug519928.html
editor/libeditor/tests/.eslintrc.js
editor/libeditor/tests/browser_bug629172.js
editor/libeditor/tests/file_select_all_without_body.html
editor/libeditor/tests/test_CF_HTML_clipboard.html
editor/libeditor/tests/test_backspace_vs.html
editor/libeditor/tests/test_bug1053048.html
editor/libeditor/tests/test_bug1100966.html
editor/libeditor/tests/test_bug1102906.html
editor/libeditor/tests/test_bug1154791.html
editor/libeditor/tests/test_bug1230473.html
editor/libeditor/tests/test_bug1257363.html
editor/libeditor/tests/test_bug1258085.html
editor/libeditor/tests/test_bug1270235.html
editor/libeditor/tests/test_bug1306532.html
editor/libeditor/tests/test_bug1315065.html
editor/libeditor/tests/test_bug1318312.html
editor/libeditor/tests/test_bug1330796.html
editor/libeditor/tests/test_bug1425997.html
editor/libeditor/tests/test_bug366682.html
editor/libeditor/tests/test_bug372345.html
editor/libeditor/tests/test_bug404320.html
editor/libeditor/tests/test_bug408231.html
editor/libeditor/tests/test_bug410986.html
editor/libeditor/tests/test_bug414526.html
editor/libeditor/tests/test_bug432225.html
editor/libeditor/tests/test_bug471319.html
editor/libeditor/tests/test_bug478725.html
editor/libeditor/tests/test_bug480972.html
editor/libeditor/tests/test_bug484181.html
editor/libeditor/tests/test_bug502673.html
editor/libeditor/tests/test_bug520189.html
editor/libeditor/tests/test_bug525389.html
editor/libeditor/tests/test_bug537046.html
editor/libeditor/tests/test_bug551704.html
editor/libeditor/tests/test_bug569988.html
editor/libeditor/tests/test_bug596333.html
editor/libeditor/tests/test_bug612128.html
editor/libeditor/tests/test_bug636465.html
editor/libeditor/tests/test_bug645914.html
editor/libeditor/tests/test_bug674770-2.html
editor/libeditor/tests/test_bug772796.html
editor/libeditor/tests/test_bug790475.html
editor/libeditor/tests/test_bug795418-2.html
editor/libeditor/tests/test_bug795418-3.html
editor/libeditor/tests/test_bug795785.html
editor/libeditor/tests/test_bug830600.html
editor/libeditor/tests/test_bug850043.html
editor/libeditor/tests/test_bug966155.html
editor/libeditor/tests/test_bug966552.html
editor/libeditor/tests/test_contenteditable_focus.html
editor/libeditor/tests/test_contenteditable_text_input_handling.html
editor/libeditor/tests/test_documentCharacterSet.html
editor/libeditor/tests/test_dom_input_event_on_htmleditor.html
editor/libeditor/tests/test_dom_input_event_on_texteditor.html
editor/libeditor/tests/test_dragdrop.html
editor/libeditor/tests/test_execCommandPaste_noTarget.html
editor/libeditor/tests/test_htmleditor_keyevent_handling.html
editor/libeditor/tests/test_inlineTableEditing.html
editor/libeditor/tests/test_nsITableEditor_getCellAt.html
editor/libeditor/tests/test_nsITableEditor_getCellIndexes.html
editor/libeditor/tests/test_nsITableEditor_getFirstRow.html
editor/libeditor/tests/test_nsITableEditor_getNextSelectedCell.html
editor/libeditor/tests/test_nsITableEditor_getTableSize.html
editor/libeditor/tests/test_selection_move_commands.html
editor/libeditor/tests/test_texteditor_keyevent_handling.html
editor/spellchecker/tests/test_bug1200533.html
editor/spellchecker/tests/test_bug1204147.html
editor/spellchecker/tests/test_bug1205983.html
editor/spellchecker/tests/test_bug1209414.html
editor/spellchecker/tests/test_bug1219928.html
editor/spellchecker/tests/test_bug678842.html
editor/spellchecker/tests/test_bug697981.html
editor/spellchecker/tests/test_bug717433.html
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,25 +1,25 @@
 # Always ignore node_modules.
 **/node_modules/**/*.*
 
 # Always ignore crashtests - specially crafted files that originally caused a
 # crash.
 **/crashtests/**
 # Also ignore reftest - specially crafted to produce expected output.
 **/reftest/**
+**/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/**
-editor/**
 extensions/cookie/**
 extensions/spellcheck/**
 extensions/universalchardet/**
 gfx/layers/**
 gfx/tests/browser/**
 gfx/tests/chrome/**
 gfx/tests/mochitest/**
 image/**
@@ -254,16 +254,19 @@ dom/xhr/**
 dom/xml/**
 dom/xslt/**
 dom/xul/**
 
 # Third-party
 dom/media/webvtt/**
 
 # Third-party
+editor/libeditor/tests/browserscope/**
+
+# Third-party
 gfx/ots/**
 gfx/skia/**
 
 # intl/ exclusions
 intl/icu/**
 intl/locale/**
 intl/strres/**
 intl/uconv/**
--- a/editor/AsyncSpellCheckTestHelper.jsm
+++ b/editor/AsyncSpellCheckTestHelper.jsm
@@ -55,16 +55,17 @@ function onSpellCheck(editableElement, c
     count = 0;
     let expectedTopic = waitingForEnded ? SPELL_CHECK_ENDED_TOPIC :
                         SPELL_CHECK_STARTED_TOPIC;
     if (topic != expectedTopic)
       Cu.reportError("Expected " + expectedTopic + " but got " + topic + "!");
     waitingForEnded = !waitingForEnded;
   }
 
+  // eslint-disable-next-line mozilla/use-services
   let os = Cc["@mozilla.org/observer-service;1"].
            getService(Ci.nsIObserverService);
   os.addObserver(observe, SPELL_CHECK_STARTED_TOPIC);
   os.addObserver(observe, SPELL_CHECK_ENDED_TOPIC);
 
   let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
   timer.init(function tick() {
     // Wait an arbitrarily large number -- 50 -- turns of the event loop before
--- a/editor/composer/test/test_bug519928.html
+++ b/editor/composer/test/test_bug519928.html
@@ -1,23 +1,23 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=519928
 -->
 <head>
   <title>Test for Bug 519928</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
+  <script type="text/javascript" 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=519928">Mozilla Bug 519928</a>
 <p id="display"></p>
 <div id="content">
-<iframe id="load-frame"></iframe>  
+<iframe id="load-frame"></iframe>
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var iframe = document.getElementById("load-frame");
 
 function enableJS() { allowJS(true, iframe); }
 function disableJS() { allowJS(false, iframe); }
@@ -33,21 +33,23 @@ function expectJSAllowed(allowed, testCo
   var doc = iframe.contentDocument;
   doc.body.innerHTML = "<iframe></iframe>";
   var innerFrame = doc.querySelector("iframe");
   innerFrame.addEventListener("load", function() {
     var msg = "The inner iframe should" + (allowed ? "" : " not") + " be able to run Javascript";
     is(self_.ICanRunMyJS, allowed, msg);
     callback();
   }, {once: true});
+  // eslint-disable-next-line no-useless-concat
   var iframeSrc = "<script>parent.parent.ICanRunMyJS = true;</scr" + "ipt>";
   innerFrame.srcdoc = iframeSrc;
 }
 
 SimpleTest.waitForExplicitFinish();
+/* eslint-disable max-nested-callbacks */
 addLoadEvent(function() {
   var enterDesignMode = function() { document.designMode = "on"; };
   var leaveDesignMode = function() { document.designMode = "off"; };
   expectJSAllowed(false, disableJS, function() {
     expectJSAllowed(true, enableJS, function() {
       expectJSAllowed(true, enterDesignMode, function() {
         expectJSAllowed(true, leaveDesignMode, function() {
           expectJSAllowed(false, disableJS, function() {
@@ -77,16 +79,17 @@ addLoadEvent(function() {
               });
             });
           });
         });
       });
     });
   });
 });
+/* eslint-enable max-nested-callbacks */
 
 function testDocumentDisabledJS() {
   window.ICanRunMyJS = false;
   var self_ = window;
   // Ensure design modes are disabled
   document.designMode = "off";
   iframe.contentDocument.designMode = "off";
 
@@ -100,16 +103,17 @@ function testDocumentDisabledJS() {
   // Javascript disabled on the innerFrame.
   allowJS(false, innerFrame);
 
   innerFrame.addEventListener("load", function() {
     var msg = "The inner iframe should not be able to run Javascript";
     is(self_.ICanRunMyJS, false, msg);
     SimpleTest.finish();
   }, {once: true});
+  // eslint-disable-next-line no-useless-concat
   var iframeSrc = "<script>parent.parent.ICanRunMyJS = true;</scr" + "ipt>";
   innerFrame.srcdoc = iframeSrc;
 }
 
 </script>
 </pre>
 </body>
 </html>
--- a/editor/libeditor/tests/.eslintrc.js
+++ b/editor/libeditor/tests/.eslintrc.js
@@ -1,8 +1,16 @@
 "use strict";
 
 module.exports = {
   "extends": [
     "plugin:mozilla/browser-test",
     "plugin:mozilla/mochitest-test",
-  ]
+  ],
+
+  "plugins": [
+    "no-unsanitized",
+  ],
+
+  "rules": {
+    "no-unsanitized/property": "off",
+  },
 };
--- a/editor/libeditor/tests/browser_bug629172.js
+++ b/editor/libeditor/tests/browser_bug629172.js
@@ -1,17 +1,17 @@
 add_task(async function() {
   await new Promise(resolve => waitForFocus(resolve, window));
 
   const kPageURL = "http://example.org/browser/editor/libeditor/tests/bug629172.html";
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: kPageURL,
-  }, async function(aBrowser) {
-    await ContentTask.spawn(aBrowser, {}, async function() {
+  }, async function(browser) {
+    await ContentTask.spawn(browser, {}, async function() {
       var window = content.window.wrappedJSObject;
       var document = window.document;
 
       // Note: Using the with keyword, we would have been able to write this as:
       //
       // with (window) {
       //   Screenshots = {};
       //   // so on
@@ -45,18 +45,18 @@ add_task(async function() {
       // the content process only in e10s mode.
       if (gMultiProcessBrowser) {
         return EventUtils.synthesizeAndWaitKey("x", {accelKey: true, shiftKey: true});
       }
       EventUtils.synthesizeKey("x", {accelKey: true, shiftKey: true});
       return Promise.resolve();
     }
 
-    async function testDirection(initialDir, aBrowser) {
-      await ContentTask.spawn(aBrowser, {initialDir}, function({initialDir}) {
+    async function testDirection(initDir, aBrowser) {
+      await ContentTask.spawn(aBrowser, {initialDir: initDir}, function({initialDir}) {
         var window = content.window.wrappedJSObject;
         var document = window.document;
 
         var t = window.t = document.createElement("textarea");
         t.setAttribute("dir", initialDir);
         t.value = "test.";
         window.inputEventCount = 0;
         t.oninput = function() { window.inputEventCount++; };
@@ -69,17 +69,17 @@ add_task(async function() {
                           /* fuzz = */ null,
                           "Textarea before switching the direction from " +
                             initialDir,
                           "Reference " + initialDir + " textarea");
         t.focus();
         is(window.inputEventCount, 0, "input event count must be 0 before");
       });
       await simulateCtrlShiftX(aBrowser);
-      await ContentTask.spawn(aBrowser, {initialDir}, function({initialDir}) {
+      await ContentTask.spawn(aBrowser, {initialDir: initDir}, function({initialDir}) {
         var window = content.window.wrappedJSObject;
         var expectedDir = initialDir == "ltr" ? "rtl" : "ltr";
         is(window.t.getAttribute("dir"), expectedDir,
            "The dir attribute must be correctly updated");
         is(window.inputEventCount, 1, "input event count must be 1 after");
         window.t.blur();
         var s2 = window.snapshotWindow(window);
         window.ok = ok; // for assertSnapshots
@@ -88,17 +88,17 @@ add_task(async function() {
                         /* fuzz = */ null,
                           "Textarea after switching the direction from " +
                             initialDir,
                           "Reference " + expectedDir + " textarea");
         window.t.focus();
         is(window.inputEventCount, 1, "input event count must be 1 before");
       });
       await simulateCtrlShiftX(aBrowser);
-      await ContentTask.spawn(aBrowser, {initialDir}, function({initialDir}) {
+      await ContentTask.spawn(aBrowser, {initialDir: initDir}, function({initialDir}) {
         var window = content.window.wrappedJSObject;
 
         is(window.inputEventCount, 2, "input event count must be 2 after");
         is(window.t.getAttribute("dir"), initialDir == "ltr" ? "ltr" : "rtl", "The dir attribute must be correctly updated");
         window.t.blur();
         var s3 = window.snapshotWindow(window);
         window.ok = ok; // for assertSnapshots
         window.
@@ -106,12 +106,12 @@ add_task(async function() {
                           /* fuzz = */ null,
                           "Textarea after switching back the direction to " +
                             initialDir,
                           "Reference " + initialDir + " textarea");
         window.t.remove();
       });
     }
 
-    await testDirection("ltr", aBrowser);
-    await testDirection("rtl", aBrowser);
+    await testDirection("ltr", browser);
+    await testDirection("rtl", browser);
   });
 });
--- a/editor/libeditor/tests/file_select_all_without_body.html
+++ b/editor/libeditor/tests/file_select_all_without_body.html
@@ -12,17 +12,17 @@ function unload() {
 
 function boom() {
   var root = document.documentElement;
   while (root.firstChild) {
     root.firstChild.remove();
   }
   root.appendChild(document.createTextNode("Mozilla"));
   root.focus();
-  cespan = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
+  let cespan = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
   cespan.setAttributeNS(null, "contenteditable", "true");
   root.appendChild(cespan);
   try {
     document.execCommand("selectAll", false, null);
   } catch (e) { }
 
   is(window.getSelection().toString(), "Mozilla",
      "The nodes are not selected");
--- a/editor/libeditor/tests/test_CF_HTML_clipboard.html
+++ b/editor/libeditor/tests/test_CF_HTML_clipboard.html
@@ -27,44 +27,43 @@ function copyCF_HTML(cfhtml, success, fa
   const CF_HTML = "application/x-moz-nativehtml";
 
   function getLoadContext() {
     return SpecialPowers.wrap(window)
                  .docShell
                  .QueryInterface(Ci.nsILoadContext);
   }
 
-  var cb = Cc["@mozilla.org/widget/clipboard;1"].
-           getService(Ci.nsIClipboard);
+  var cb = SpecialPowers.Services.clipboard;
 
   var counter = 0;
-  function copyCF_HTML_worker(success, failure) {
+  function copyCF_HTML_worker(successFn, failureFn) {
     if (++counter > 50) {
       ok(false, "Timed out while polling clipboard for pasted data");
       failure();
       return;
     }
 
     var flavors = [CF_HTML];
     if (!cb.hasDataMatchingFlavors(flavors, flavors.length, cb.kGlobalClipboard)) {
-      setTimeout(function() { copyCF_HTML_worker(success, failure); }, 100);
+      setTimeout(function() { copyCF_HTML_worker(successFn, failureFn); }, 100);
       return;
     }
 
     var trans = Cc["@mozilla.org/widget/transferable;1"].
                 createInstance(Ci.nsITransferable);
     trans.init(getLoadContext());
     trans.addDataFlavor(CF_HTML);
     cb.getData(trans, cb.kGlobalClipboard);
     var data = SpecialPowers.createBlankObject();
     try {
       trans.getTransferData(CF_HTML, data, {});
       data = SpecialPowers.wrap(data).value.QueryInterface(Ci.nsISupportsCString).data;
     } catch (e) {
-      setTimeout(function() { copyCF_HTML_worker(success, failure); }, 100);
+      setTimeout(function() { copyCF_HTML_worker(successFn, failureFn); }, 100);
       return;
     }
     success();
   }
 
   var trans = Cc["@mozilla.org/widget/transferable;1"].
               createInstance(Ci.nsITransferable);
   trans.init(getLoadContext());
--- a/editor/libeditor/tests/test_backspace_vs.html
+++ b/editor/libeditor/tests/test_backspace_vs.html
@@ -46,17 +46,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 
 function test(edit, bsCount) {
   edit.focus();
   var sel = window.getSelection();
   sel.collapse(edit.childNodes[0], edit.textContent.length - 1);
-  for (i = 0; i < bsCount; ++i) {
+  for (let i = 0; i < bsCount; ++i) {
     synthesizeKey("KEY_Backspace");
   }
   is(edit.textContent, "ab", "The backspace key should delete the characters correctly");
 }
 
 function testWithMove(edit, offset, bsCount) {
   edit.focus();
   var sel = window.getSelection();
@@ -87,17 +87,17 @@ function runTest() {
    *
    * For now, only rely on such an emoji font on OS X 10.7+. (Note that the
    * Segoe UI Emoji font on Win8.1 and Win10 does not implement Regional
    * Indicator flags.)
    *
    * Once the Firefox Emoji font is ready, we can load that via @font-face
    * and expect these tests to work across all platforms.
    */
-  hasEmojiFont =
+  let hasEmojiFont =
     (navigator.platform.indexOf("Mac") == 0 &&
      /10\.([7-9]|[1-9][0-9])/.test(navigator.oscpu));
 
   if (hasEmojiFont) {
     test(document.getElementById("edit7"), 1);
     test(document.getElementById("edit8"), 2);
     test(document.getElementById("edit9"), 3);
     test(document.getElementById("edit10"), 4);
--- a/editor/libeditor/tests/test_bug1053048.html
+++ b/editor/libeditor/tests/test_bug1053048.html
@@ -22,20 +22,20 @@ https://bugzilla.mozilla.org/show_bug.cg
     textarea.focus();
 
     var editor = textarea.editor;
     var selectionPrivate = editor.selection;
 
     var selectionListener = {
       count: 0,
       notifySelectionChanged(aDocument, aSelection, aReason) {
-      ok(true, "selectionStart: " + textarea.selectionStart);
-      ok(true, "selectionEnd: " + textarea.selectionEnd);
-      this.count++;
-    },
+        ok(true, "selectionStart: " + textarea.selectionStart);
+        ok(true, "selectionEnd: " + textarea.selectionEnd);
+        this.count++;
+      },
     };
 
     // Move caret to the end of the textarea
     synthesizeMouse(textarea, 290, 10, {});
     is(textarea.selectionStart, 3, "selectionStart should be 3 (after \"foo\")");
     is(textarea.selectionEnd, 3, "selectionEnd should be 3 (after \"foo\")");
 
     selectionPrivate.addSelectionListener(selectionListener);
--- a/editor/libeditor/tests/test_bug1100966.html
+++ b/editor/libeditor/tests/test_bug1100966.html
@@ -29,36 +29,35 @@ let {onSpellCheck} = SpecialPowers.Cu.im
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   var div = document.getElementById("content");
   div.focus();
   synthesizeMouseAtCenter(div, {});
 
   getSpellChecker().UpdateCurrentDictionary(() => {
     sendString(" ");
-    setTimeout(function() {
+    SimpleTest.executeSoon(function() {
       sendString("a");
-      setTimeout(function() {
+      SimpleTest.executeSoon(function() {
         synthesizeKey("KEY_Backspace");
 
         onSpellCheck(div, function() {
           var sel = getSpellCheckSelection();
           is(sel.rangeCount, 2, "We should have two misspelled words");
           is(String(sel.getRangeAt(0)), "fivee", "Correct misspelled word");
           is(String(sel.getRangeAt(1)), "sixx", "Correct misspelled word");
 
           SimpleTest.finish();
         });
-      }, 0);
-    }, 0);
+      });
+    });
   });
 });
 
 function getEditor() {
-  var Ci = SpecialPowers.Ci;
   var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window);
 }
 
 function getSpellChecker() {
   return getEditor().getInlineSpellChecker(false).spellChecker;
 }
 
--- a/editor/libeditor/tests/test_bug1102906.html
+++ b/editor/libeditor/tests/test_bug1102906.html
@@ -17,17 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   /* Test for Bug 1102906 */
   /* The caret should be movable by using keyboard after drag-and-drop. */
 
   SimpleTest.waitForExplicitFinish();
   SimpleTest.waitForFocus( () => {
     let content = document.getElementById("content");
     let drag = document.getElementById("drag");
-      let selection = window.getSelection();
+    let selection = window.getSelection();
 
     /* Perform drag-and-drop for an arbitrary content. The caret should be at
        the end of the contenteditable. */
     selection.selectAllChildren(drag);
     synthesizeDrop(drag, content, {}, "copy");
 
     let textContentAfterDrop = content.textContent;
 
--- a/editor/libeditor/tests/test_bug1154791.html
+++ b/editor/libeditor/tests/test_bug1154791.html
@@ -29,36 +29,35 @@ SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   var div = document.getElementById("content");
   div.focus();
   getSpellChecker().UpdateCurrentDictionary(() => {
     synthesizeMouseAtCenter(div, {});
     synthesizeKey("KEY_ArrowLeft");
     synthesizeKey("KEY_ArrowLeft");
 
-    setTimeout(function() {
+    SimpleTest.executeSoon(function() {
       synthesizeKey("KEY_Backspace");
-      setTimeout(function() {
+      SimpleTest.executeSoon(function() {
         sendString(" ");
 
         onSpellCheck(div, function() {
           var sel = getSpellCheckSelection();
           is(sel.rangeCount, 2, "We should have two misspelled words");
           is(String(sel.getRangeAt(0)), "thiss", "Correct misspelled word");
           is(String(sel.getRangeAt(1)), "onee", "Correct misspelled word");
 
           SimpleTest.finish();
         });
-      }, 0);
-    }, 0);
+      });
+    });
   });
 });
 
 function getEditor() {
-  var Ci = SpecialPowers.Ci;
   var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window);
 }
 
 function getSpellChecker() {
   return getEditor().getInlineSpellChecker(false).spellChecker;
 }
 
--- a/editor/libeditor/tests/test_bug1230473.html
+++ b/editor/libeditor/tests/test_bug1230473.html
@@ -27,22 +27,22 @@ SimpleTest.waitForFocus(() => {
     function isNSEditableElement() {
       return aEditor.tagName.toLowerCase() == "input" || aEditor.tagName.toLowerCase() == "textarea";
     }
     function value() {
       return isNSEditableElement() ? aEditor.value : aEditor.textContent;
     }
     function isComposing() {
       return isNSEditableElement() ? SpecialPowers.wrap(aEditor)
-                                                   .editor
-                                                   .composing :
-                                      SpecialPowers.wrap(window)
-                                                   .docShell
-                                                   .editor
-                                                   .composing;
+                                                  .editor
+                                                  .composing :
+                                     SpecialPowers.wrap(window)
+                                                  .docShell
+                                                  .editor
+                                                  .composing;
     }
     function clear() {
       if (isNSEditableElement()) {
         aEditor.value = "";
       } else {
         aEditor.textContent = "";
       }
     }
--- a/editor/libeditor/tests/test_bug1257363.html
+++ b/editor/libeditor/tests/test_bug1257363.html
@@ -91,18 +91,18 @@ SimpleTest.waitForFocus(function() {
   is(div.innerHTML, "<p><font color=\"red\">12345a</font></p><font color=\"red\">b</font>67",
                     "unexpected HTML");
 
   // ***** Delete test *****
   div = document.getElementById("deleteCSS");
   div.focus();
   synthesizeMouse(div, 100, 2, {}); /* click behind and down */
 
-  var sel = window.getSelection();
-  var selRange = sel.getRangeAt(0);
+  sel = window.getSelection();
+  selRange = sel.getRangeAt(0);
   is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
   is(selRange.endOffset, 1, "offset should be 1");
 
   // left, enter should create a new empty paragraph before
   // but leave the selection at the start of the existing paragraph.
   synthesizeKey("KEY_ArrowLeft");
   synthesizeKey("KEY_Enter");
 
@@ -131,18 +131,18 @@ SimpleTest.waitForFocus(function() {
   is(div.innerHTML, "<p style=\"color:red;\">ax</p>",
                     "unexpected HTML");
 
   // Let's repeat the whole thing, but a font tag instead of CSS.
   div = document.getElementById("delete");
   div.focus();
   synthesizeMouse(div, 100, 2, {}); /* click behind and down */
 
-  var sel = window.getSelection();
-  var selRange = sel.getRangeAt(0);
+  sel = window.getSelection();
+  selRange = sel.getRangeAt(0);
   is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node");
   is(selRange.endOffset, 1, "offset should be 1");
 
   // left, enter should create a new empty paragraph before
   // but leave the selection at the start of the existing paragraph.
   synthesizeKey("KEY_ArrowLeft");
   synthesizeKey("KEY_Enter");
 
--- a/editor/libeditor/tests/test_bug1258085.html
+++ b/editor/libeditor/tests/test_bug1258085.html
@@ -50,17 +50,17 @@ SimpleTest.waitForFocus(function() {
   checks("Backward-selected backspace");
 
   // Make sure we're not deleting if the whitespace isn't actually collapsed
   div.style.whiteSpace = "pre-wrap";
   reset();
   synthesizeKey("KEY_ArrowRight");
   synthesizeKey("KEY_ArrowRight");
   synthesizeKey("KEY_Backspace");
-  if (div.innerHTML, "x<br> ", "pre-wrap: Don't delete uncollapsed space");
+  is(div.innerHTML, "x<br> ", "pre-wrap: Don't delete uncollapsed space");
   ok(getSelection().isCollapsed, "pre-wrap: Selection must be collapsed");
   is(getSelection().focusNode, div.lastChild,
      "pre-wrap: Focus must be in final text node");
   is(getSelection().focusOffset, 1, "pre-wrap: Focus must be at end of node");
 
   SimpleTest.finish();
 });
 </script>
--- a/editor/libeditor/tests/test_bug1270235.html
+++ b/editor/libeditor/tests/test_bug1270235.html
@@ -18,17 +18,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="edit1" contenteditable="true"><p>AB</p></div>
 <script type="application/javascript">
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(() => {
   let element = document.getElementById("edit1");
   element.focus();
   let textNode = element.firstChild.firstChild;
   let node = textNode.splitText(0);
-  node.parentNode.removeChild(node);
+  node.remove();
 
   ok(!node.parentNode, "parent must be null");
 
   let newRange = document.createRange();
   newRange.setStart(node, 0);
   newRange.setEnd(node, 0);
   let selection = document.getSelection();
   selection.removeAllRanges();
--- a/editor/libeditor/tests/test_bug1306532.html
+++ b/editor/libeditor/tests/test_bug1306532.html
@@ -3,16 +3,20 @@
 <title>Test for bug 1306532</title>
 <style src="/tests/SimpleTest/test.css" type="text/css"></style>
 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
 
 <script class="testbody" type="application/javascript">
 
 function runTest() {
+  const headingone = document.getElementById("headingone");
+  const celltwo = document.getElementById("celltwo");
+  const pasteframe = document.getElementById("pasteframe");
+
   // Copy content from table.
   var selection = getSelection();
   var startRange = document.createRange();
   startRange.setStart(headingone, 0);
   startRange.setEnd(celltwo, 0);
   selection.removeAllRanges();
   selection.addRange(startRange);
   SpecialPowers.wrap(document).execCommand("copy", false, null);
--- a/editor/libeditor/tests/test_bug1315065.html
+++ b/editor/libeditor/tests/test_bug1315065.html
@@ -50,23 +50,23 @@ SimpleTest.waitForFocus(() => {
       case 3:
         selection.collapse(emptyTextNode3, 0);
         break;
       default:
         ok(false, "aSelectionCollapsedTo is illegal value");
     }
   }
 
-  for (var i = 0; i < 4; i++) {
+  for (let i = 0; i < 4; i++) {
     const kDescription = i == 0 ? "Backspace from immediately after the last character" :
                                   "Backspace from " + i + "th empty text node";
     editor.focus();
     initForBackspace(i);
     synthesizeKey("KEY_Backspace");
-    var p = document.getElementById("p");
+    let p = document.getElementById("p");
     ok(p, kDescription + ": <p> element shouldn't be removed by Backspace key press");
     is(p.tagName.toLowerCase(), "p", kDescription + ": <p> element shouldn't be removed by Backspace key press");
     // When Backspace key is pressed even in empty text nodes, Gecko should not remove empty text nodes for now
     // because we should keep our traditional behavior (same as Edge) for backward compatibility as far as possible.
     // In this case, Chromium removes all empty text nodes, but Edge doesn't remove any empty text nodes.
     is(p.childNodes.length, 5, kDescription + ": <p> should have 5 children after pressing Backspace key");
     is(p.childNodes.item(0).textContent, "ab", kDescription + ": 'c' should be removed by pressing Backspace key");
     is(p.childNodes.item(1).textContent, "", kDescription + ": 1st empty text node should not be removed by pressing Backspace key");
@@ -107,17 +107,17 @@ SimpleTest.waitForFocus(() => {
       case 3:
         selection.collapse(emptyTextNode3, 0);
         break;
       default:
         ok(false, "aSelectionCollapsedTo is illegal value");
     }
   }
 
-  for (var i = 0; i < 4; i++) {
+  for (let i = 0; i < 4; i++) {
     const kDescription = i == 0 ? "Delete from immediately before the first character" :
                                   "Delete from " + i + "th empty text node";
     editor.focus();
     initForDelete(i);
     synthesizeKey("KEY_Delete");
     var p = document.getElementById("p");
     ok(p, kDescription + ": <p> element shouldn't be removed by Delete key press");
     is(p.tagName.toLowerCase(), "p", kDescription + ": <p> element shouldn't be removed by Delete key press");
--- a/editor/libeditor/tests/test_bug1318312.html
+++ b/editor/libeditor/tests/test_bug1318312.html
@@ -11,16 +11,17 @@
 <body>
 <div id="outerEditor" contenteditable><p>content of outer editor</p>
 <div id="staticInEditor" contenteditable="false"><p>static content of outer editor</p>
 <div id="innerEditor" contenteditable><p>content of inner editor</p></div></div></div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var outerEditor = document.getElementById("outerEditor");
+var innerEditor = document.getElementById("innerEditor");
 
 function runTests() {
   outerEditor.focus();
   is(document.activeElement, outerEditor,
      "outerEditor should have focus");
 
   // Move cursor into the innerEditor with ArrowDown key.  Then, focus shouldn't
   // be moved to innerEditor from outerEditor.
--- a/editor/libeditor/tests/test_bug1330796.html
+++ b/editor/libeditor/tests/test_bug1330796.html
@@ -63,17 +63,17 @@ var tests = [
 SimpleTest.waitForExplicitFinish();
 
 SimpleTest.waitForFocus(function() {
 
   var sel = window.getSelection();
   var theEdit = document.getElementById("editable");
   makeMailEditor();
 
-  for (i = 0; i < tests.length; i++) {
+  for (let i = 0; i < tests.length; i++) {
     theEdit.innerHTML = tests[i][0];
     theEdit.focus();
     var theText = theEdit.firstChild.firstChild;
     // Position set at the beginning , middle and end of the text.
     sel.collapse(theText, tests[i][1]);
 
     synthesizeKey("KEY_Enter");
     sendString("x");
--- a/editor/libeditor/tests/test_bug1425997.html
+++ b/editor/libeditor/tests/test_bug1425997.html
@@ -25,17 +25,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script class="testbody" type="application/javascript">
 SimpleTest.waitForExplicitFinish();
 // 3 assertions are recorded due to nested execCommand() but not a problem.
 // They are necessary to detect invalid method call without mutation event listers.
 SimpleTest.expectAssertions(3, 3);
 SimpleTest.waitForFocus(function() {
   let selection = window.getSelection();
   let editor = document.getElementById("editor");
-  let originalContent = editor.innerHTML;
   function onCharacterDataModified() {
     // Until removing all NBSPs which were inserted by the editor,
     // emulates Backspace key with "delete" command.
     // When this test is created, the behavior is:
     //   after 1st delete: "\n<!-- -->&nbsp;&nbsp;\n"
     //   after 2nd delete: "\n<!-- -->&nbsp;\n"
     //   after 3rd delete: "\n<!-- -->\n"
     while (editor.innerHTML.includes("&nbsp;")) {
--- a/editor/libeditor/tests/test_bug366682.html
+++ b/editor/libeditor/tests/test_bug366682.html
@@ -29,17 +29,16 @@ function getEdit() {
   return document.getElementById("edit");
 }
 
 function editDoc() {
   return getEdit().contentDocument;
 }
 
 function getEditor() {
-  var Ci = SpecialPowers.Ci;
   var win = editDoc().defaultView;
   var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
   return editingSession.getEditorForWindow(win);
 }
 
 function runTest() {
   editDoc().body.innerHTML = "<div>errror and an other errror</div>";
   gMisspeltWords = ["errror", "errror"];
--- a/editor/libeditor/tests/test_bug372345.html
+++ b/editor/libeditor/tests/test_bug372345.html
@@ -19,17 +19,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script type="application/javascript">
 
 /** Test for Bug 372345 **/
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() {
   var iframe = document.querySelector("iframe");
   var doc = iframe.contentDocument;
   var content = doc.body;
-  var link = content.querySelector("a");
   function testCursor(post) {
     setTimeout(function() {
       var link = document.createElement("a");
       link.href = "http://mozilla.org/";
       link.textContent = "link";
       link.style.cursor = "pointer";
       content.appendChild(link);
       is(iframe.contentWindow.getComputedStyle(link).cursor, "pointer", "Make sure that the cursor is set to pointer");
--- a/editor/libeditor/tests/test_bug404320.html
+++ b/editor/libeditor/tests/test_bug404320.html
@@ -39,17 +39,16 @@ function runTests() {
 
     is(resultNode.tagName, shouldSucceed ? tag.toUpperCase() : "P", "tag was changed");
   }
 
   function formatBlockTests(tags, shouldSucceed) {
     var html = "<p>Content</p>";
     for (var i = 0; i < tags.length; ++i) {
       var tag = tags[i];
-      var resultTag = tag.toUpperCase();
 
       doc.body.innerHTML = html;
       testFormatBlock(tag, false, shouldSucceed);
 
       doc.body.innerHTML = html;
       testFormatBlock(tag, true, shouldSucceed);
     }
   }
--- a/editor/libeditor/tests/test_bug408231.html
+++ b/editor/libeditor/tests/test_bug408231.html
@@ -7,17 +7,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 408231</title>
   <script type="text/javascript" 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=408231">Mozilla Bug 408231</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 408231 **/
 
     var commandEnabledResults = [
       ["contentReadOnly", "true"],
@@ -178,55 +178,55 @@ https://bugzilla.mozilla.org/show_bug.cg
       ["unlink", ""],
       ["not-a-command", ""],
     ];
 
 
     function callQueryCommandEnabled(cmdName) {
       var result;
       try {
-        result = "" + document.queryCommandEnabled( cmdName );
-      } catch ( error ) {
+        result = "" + document.queryCommandEnabled(cmdName);
+      } catch (error) {
         result = "name" in error ? error.name : "exception";
       }
       return result;
     }
 
     function callQueryCommandIndeterm(cmdName) {
       var result;
       try {
-        result = "" + document.queryCommandIndeterm( cmdName );
-      } catch ( error ) {
+        result = "" + document.queryCommandIndeterm(cmdName);
+      } catch (error) {
         result = "name" in error ? error.name : "exception";
       }
       return result;
     }
 
     function callQueryCommandState(cmdName) {
       var result;
       try {
-        result = "" + document.queryCommandState( cmdName );
-      } catch ( error ) {
+        result = "" + document.queryCommandState(cmdName);
+      } catch (error) {
         result = "name" in error ? error.name : "exception";
       }
       return result;
     }
 
     function callQueryCommandValue(cmdName) {
       var result;
       try {
-        result = "" + document.queryCommandValue( cmdName );
-      } catch ( error ) {
+        result = "" + document.queryCommandValue(cmdName);
+      } catch (error) {
         result = "name" in error ? error.name : "exception";
       }
       return result;
     }
 
     function testQueryCommand(expectedResults, fun, funName) {
-      for (i = 0; i < expectedResults.length; i++) {
+      for (let i = 0; i < expectedResults.length; i++) {
         var commandName = expectedResults[i][0];
         var expectedResult = expectedResults[i][1];
         var result = fun(commandName);
         ok(result == expectedResult, funName + "(" + commandName + ") result=" + result + " expected=" + expectedResult);
       }
     }
 
     function runTests() {
@@ -242,9 +242,8 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     window.onload = runTests;
     SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
-
--- a/editor/libeditor/tests/test_bug410986.html
+++ b/editor/libeditor/tests/test_bug410986.html
@@ -47,20 +47,20 @@ SimpleTest.waitForFocus(function() {
       ed.innerHTML = "";
       ed.blur();
       getSelection().selectAllChildren(document.getElementById("contents"));
       SimpleTest.waitForClipboard("green text",
         function() {
           synthesizeKey("C", {accelKey: true});
         },
         function() {
-          var ed = document.getElementById("editor");
-          ed.focus();
+          var ed1 = document.getElementById("editor");
+          ed1.focus();
           synthesizeKey("V", {accelKey: true});
-          isnot(ed.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1,
+          isnot(ed1.innerHTML.indexOf("<span style=\"color: green;\">green text</span>"), -1,
                 "Content should be pasted in HTML format");
           is(gPasteEvents, 2, "Two paste events must be fired");
 
           SimpleTest.finish();
         },
         function() {
           ok(false, "Failed to copy the second item to the clipboard");
           SimpleTest.finish();
--- a/editor/libeditor/tests/test_bug414526.html
+++ b/editor/libeditor/tests/test_bug414526.html
@@ -3,17 +3,17 @@
   <title>Test for backspace key and delete key shouldn't remove another editing host's text</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <div id="display"></div>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(runTests);
--- a/editor/libeditor/tests/test_bug432225.html
+++ b/editor/libeditor/tests/test_bug432225.html
@@ -2,24 +2,24 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=432225
 -->
 <head>
   <title>Test for Bug 432225</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <script src="spellcheck.js"></script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=432225">Mozilla Bug 432225</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 432225 **/
 
 let {onSpellCheck} = SpecialPowers.Cu.import("resource://testing-common/AsyncSpellCheckTestHelper.jsm", {});
 
@@ -32,17 +32,16 @@ function getEdit() {
   return document.getElementById("edit");
 }
 
 function editDoc() {
   return getEdit().contentDocument;
 }
 
 function getEditor() {
-  var Ci = SpecialPowers.Ci;
   var win = editDoc().defaultView;
   var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
   return editingSession.getEditorForWindow(win);
 }
 
 function runTest() {
   editDoc().designMode = "on";
   setTimeout(function() { addWords(100); }, 0);
--- a/editor/libeditor/tests/test_bug471319.html
+++ b/editor/libeditor/tests/test_bug471319.html
@@ -23,31 +23,30 @@ https://bugzilla.mozilla.org/show_bug.cg
     <script type="application/javascript">
 
       /** Test for Bug 471319 **/
 
       SimpleTest.waitForExplicitFinish();
 
       function doTest() {
         let t1 = SpecialPowers.wrap($("t1"));
-        let editor = null;
 
         // Test 1: Undo on an empty editor - the editor should not forget about
         // the bogus node
-        t1Editor = t1.editor;
+        let t1Editor = t1.editor;
 
         // Did the editor recognize the new bogus node?
         t1Editor.undo(1);
         ok(!t1.value, "<br> still recognized as bogus node on undo");
 
 
         // Test 2: Redo on an empty editor - the editor should not forget about
         // the bogus node
         let t2 = SpecialPowers.wrap($("t2"));
-        t2Editor = t2.editor;
+        let t2Editor = t2.editor;
 
         // Did the editor recognize the new bogus node?
         t2Editor.redo(1);
         ok(!t2.value, "<br> still recognized as bogus node on redo");
 
 
         // Test 3: Undoing a batched transaction where both end points of the
         // transaction are the bogus node - the bogus node should still be
--- a/editor/libeditor/tests/test_bug478725.html
+++ b/editor/libeditor/tests/test_bug478725.html
@@ -123,9 +123,8 @@ addLoadEvent(runTest);
 </pre>
 
 
 <iframe id="i1" width="200" height="100" src="about:blank"></iframe><br>
 <iframe id="i2" width="200" height="100" src="about:blank"></iframe><br>
 
 </body>
 </html>
- 
--- a/editor/libeditor/tests/test_bug480972.html
+++ b/editor/libeditor/tests/test_bug480972.html
@@ -90,9 +90,8 @@ addLoadEvent(runTest);
 </pre>
 
 
 <iframe id="i1" width="200" height="100" src="about:blank"></iframe><br>
 <iframe id="i2" width="200" height="100" src="about:blank"></iframe><br>
 
 </body>
 </html>
- 
--- a/editor/libeditor/tests/test_bug484181.html
+++ b/editor/libeditor/tests/test_bug484181.html
@@ -22,17 +22,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 /** Test for Bug 484181 **/
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 
 var gMisspeltWords;
 
 function getEditor() {
-  var Ci = SpecialPowers.Ci;
   var win = window;
   var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
   return editingSession.getEditorForWindow(win);
 }
 
 function append(str) {
   var edit = document.getElementById("edit");
   var editor = getEditor();
@@ -42,18 +41,18 @@ function append(str) {
   sendString(str);
 }
 
 function runTest() {
   gMisspeltWords = ["haz", "cheezburger"];
   var edit = document.getElementById("edit");
   edit.focus();
 
-  SpecialPowers.Cu.import(
-    "resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
+  const {onSpellCheck} = SpecialPowers.Cu.import(
+    "resource://testing-common/AsyncSpellCheckTestHelper.jsm", null);
   onSpellCheck(edit, function() {
     ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
        "All misspellings before editing are accounted for.");
 
     append(" becaz I'm a lulcat!");
     onSpellCheck(edit, function() {
       gMisspeltWords.push("becaz");
       gMisspeltWords.push("lulcat");
--- a/editor/libeditor/tests/test_bug502673.html
+++ b/editor/libeditor/tests/test_bug502673.html
@@ -6,17 +6,17 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=502673
 -->
 
 <head>
   <title>Test for Bug 502673</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
 </head>
 
 <body onload="doTest();">
   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=502673">Mozilla Bug 502673</a>
   <p id="display"></p>
   <div id="content" style="display: none">
   </div>
 
@@ -28,27 +28,27 @@ https://bugzilla.mozilla.org/show_bug.cg
       SimpleTest.waitForExplicitFinish();
 
       function listener() {
       }
 
       listener.prototype =
       {
         NotifyDocumentWillBeDestroyed() {
-    var editor = SpecialPowers.wrap(this.input).editor;
-    editor.removeDocumentStateListener(this);
-  },
+          var editor = SpecialPowers.wrap(this.input).editor;
+          editor.removeDocumentStateListener(this);
+        },
 
         NotifyDocumentCreated() {
-  },
+        },
 
         NotifyDocumentStateChanged(aNowDirty) {
-    var editor = SpecialPowers.wrap(this.input).editor;
-    editor.removeDocumentStateListener(this);
-  },
+          var editor = SpecialPowers.wrap(this.input).editor;
+          editor.removeDocumentStateListener(this);
+        },
 
         QueryInterface: SpecialPowers.wrapCallback(function(iid) {
           if (iid.equals(SpecialPowers.Ci.nsIDocumentStateListener) ||
               iid.equals(SpecialPowers.Ci.nsISupports))
             return this;
           throw SpecialPowers.Cr.NS_ERROR_NO_INTERFACE;
         }),
       };
@@ -76,17 +76,17 @@ https://bugzilla.mozilla.org/show_bug.cg
         // Report success if we get here - clearly we didn't crash
         ok(true, "Multiple listeners removed themselves after " +
                  "NotifyDocumentStateChanged notifications - didn't crash");
 
         // Add the listeners again for the next test
         editor.addDocumentStateListener(listener1);
         editor.addDocumentStateListener(listener2);
         editor.addDocumentStateListener(listener3);
-      
+
         // Test 2. Fire NotifyDocumentWillBeDestroyed notifications where the
         // listeners remove themselves (though in the real world, listeners
         // shouldn't do this as nsEditor::PreDestroy removes them as
         // listeners anyway)
         document.body.removeChild(input);
         ok(true, "Multiple listeners removed themselves after " +
                  "NotifyDocumentWillBeDestroyed notifications - didn't crash");
 
--- a/editor/libeditor/tests/test_bug520189.html
+++ b/editor/libeditor/tests/test_bug520189.html
@@ -2,17 +2,17 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=520182
 -->
 <head>
   <title>Test for Bug 520182</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=520182">Mozilla Bug 520182</a>
 <p id="display"></p>
 <div id="content">
   <iframe id="a" src="about:blank"></iframe>
   <iframe id="b" src="about:blank"></iframe>
   <iframe id="c" src="about:blank"></iframe>
@@ -74,16 +74,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   <div id="xxx" contenteditable="true"></div>
   <iframe id="xxxx" src="about:blank"></iframe>
   <div id="yyy" contenteditable="true"></div>
   <iframe id="yyyy" src="about:blank"></iframe>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
+/* eslint-disable no-useless-concat */
+
 /** Test for Bug 520182 **/
 
 const dataPayload = "foo<iframe src=\"data:text/html,bar\"></iframe>baz";
 const jsPayload = "foo<iframe src=\"javascript:void('bar');\"></iframe>baz";
 const httpPayload = "foo<iframe src=\"http://mochi.test:8888/\"></iframe>baz";
 const scriptPayload = "foo<script>document.write(\"<iframe></iframe>\");</sc" + "ript>baz";
 const scriptExternalPayload = "foo<script src=\"data:text/javascript,document.write('<iframe></iframe>');\"></sc" + "ript>baz";
 const validStyle1Payload = "foo<style>#bar{color:red;}</style>baz";
@@ -531,16 +533,17 @@ var tests = [
     isIFrame: true,
     payload: microdataPayload,
     rootElement() { return document.getElementById("yyyy").contentDocument.documentElement; },
     checkResult(html) { is(html.indexOf("name"), -1, "Should have dropped name."); is(html.indexOf("rel"), -1, "Should have dropped rel."); isnot(html.indexOf("itemprop"), -1, "Should not have dropped itemprop."); },
   },
 ];
 
 function doNextTest() {
+  /* global testCounter:true */
   if (typeof testCounter == "undefined")
     testCounter = 0;
   else if (++testCounter == tests.length) {
     SimpleTest.finish();
     return;
   }
 
   runTest(tests[testCounter]);
@@ -576,18 +579,17 @@ function runTest(test) {
       win = elem.contentDocument.defaultView;
     } else {
       getSelection().collapse(elem, 0);
       win = window;
     }
     editor = SpecialPowers.wrap(win).docShell.editor;
     editor.pasteTransferable(trans);
   } else {
-    var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"]
-                                 .getService(SpecialPowers.Ci.nsIClipboard);
+    var clipboard = SpecialPowers.Services.clipboard;
 
     clipboard.setData(trans, null, SpecialPowers.Ci.nsIClipboard.kGlobalClipboard);
 
     synthesizeKey("V", {accelKey: true});
   }
 
   if ("checkResult" in test) {
     if ("isIFrame" in test) {
--- a/editor/libeditor/tests/test_bug525389.html
+++ b/editor/libeditor/tests/test_bug525389.html
@@ -58,63 +58,64 @@ async function runTest() {
   function getTransferableFromClipboard(asHTML) {
     var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
     trans.init(getLoadContext());
     if (asHTML) {
       trans.addDataFlavor("text/html");
     } else {
       trans.addDataFlavor("text/unicode");
     }
-    var clip = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
+    var clip = SpecialPowers.Services.clipboard;
     clip.getData(trans, Ci.nsIClipboard.kGlobalClipboard);
     return trans;
   }
 
-  function makeTransferable(s, asHTML, target_id) {
-    var e = document.getElementById("i2");
-    var doc = e.contentDocument;
-    if (asHTML) {
-      doc.body.innerHTML = s;
-    } else {
-      var text = doc.createTextNode(s);
-      doc.body.appendChild(text);
-    }
-    doc.designMode = "on";
-    doc.defaultView.focus();
-    var selection = doc.defaultView.getSelection();
-    selection.removeAllRanges();
-    if (!target_id) {
-      selection.selectAllChildren(doc.body);
-    } else {
-      var range = document.createRange();
-      range.selectNode(doc.getElementById(target_id));
-      selection.addRange(range);
-    }
-
-    // We cannot use plain strings, we have to use nsSupportsString.
-    var supportsStringClass = SpecialPowers.Components.classes["@mozilla.org/supports-string;1"];
-    var ssData = supportsStringClass.createInstance(Ci.nsISupportsString);
-
-    // Create the transferable.
-    var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
-    trans.init(getLoadContext());
-
-    // Add the data to the transferable.
-    if (asHTML) {
-      trans.addDataFlavor("text/html");
-      ssData.data = doc.body.innerHTML;
-      trans.setTransferData("text/html", ssData, ssData.length * 2);
-    } else {
-      trans.addDataFlavor("text/unicode");
-      ssData.data = doc.body.innerHTML;
-      trans.setTransferData("text/unicode", ssData, ssData.length * 2);
-    }
-
-    return trans;
-  }
+  // Commented out as the test for it below is also commented out.
+  // function makeTransferable(s, asHTML, target_id) {
+  //   var e = document.getElementById("i2");
+  //   var doc = e.contentDocument;
+  //   if (asHTML) {
+  //     doc.body.innerHTML = s;
+  //   } else {
+  //     var text = doc.createTextNode(s);
+  //     doc.body.appendChild(text);
+  //   }
+  //   doc.designMode = "on";
+  //   doc.defaultView.focus();
+  //   var selection = doc.defaultView.getSelection();
+  //   selection.removeAllRanges();
+  //   if (!target_id) {
+  //     selection.selectAllChildren(doc.body);
+  //   } else {
+  //     var range = document.createRange();
+  //     range.selectNode(doc.getElementById(target_id));
+  //     selection.addRange(range);
+  //   }
+  //
+  //   // We cannot use plain strings, we have to use nsSupportsString.
+  //   var supportsStringClass = SpecialPowers.Components.classes["@mozilla.org/supports-string;1"];
+  //   var ssData = supportsStringClass.createInstance(Ci.nsISupportsString);
+  //
+  //   // Create the transferable.
+  //   var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
+  //   trans.init(getLoadContext());
+  //
+  //   // Add the data to the transferable.
+  //   if (asHTML) {
+  //     trans.addDataFlavor("text/html");
+  //     ssData.data = doc.body.innerHTML;
+  //     trans.setTransferData("text/html", ssData, ssData.length * 2);
+  //   } else {
+  //     trans.addDataFlavor("text/unicode");
+  //     ssData.data = doc.body.innerHTML;
+  //     trans.setTransferData("text/unicode", ssData, ssData.length * 2);
+  //   }
+  //
+  //   return trans;
+  // }
 
   async function copyToClipBoard(s, asHTML, target_id) {
     var e = document.getElementById("i2");
     var doc = e.contentDocument;
     if (asHTML) {
       doc.body.innerHTML = s;
     } else {
       var text = doc.createTextNode(s);
--- a/editor/libeditor/tests/test_bug537046.html
+++ b/editor/libeditor/tests/test_bug537046.html
@@ -2,17 +2,17 @@
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=537046
 -->
 <head>
   <title>Test for Bug 537046</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>  
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=537046">Mozilla Bug 537046</a>
 <p id="display"></p>
 <div id="content">
   <div id="editor" contenteditable="true">
     Some editable content
   </div>
--- a/editor/libeditor/tests/test_bug551704.html
+++ b/editor/libeditor/tests/test_bug551704.html
@@ -101,20 +101,21 @@ function continueTest() {
   }
   var current = 0;
   function doNextTest() {
     if (current == divs.length) {
       SimpleTest.finish();
       return;
     }
     var div = divs[current++];
+    let type;
     if (div.textContent == "a") {
-      var type = typeBCDEF;
+      type = typeBCDEF;
     } else {
-      var type = typeABCDEF;
+      type = typeABCDEF;
     }
     var expectedHTML = "<div>abc</div><div>def<br></div>";
     var expectedText = "abc\ndef";
     testLineBreak(div, type, expectedText, expectedHTML, doNextTest);
   }
 
   doNextTest();
 }
--- a/editor/libeditor/tests/test_bug569988.html
+++ b/editor/libeditor/tests/test_bug569988.html
@@ -8,32 +8,33 @@ https://bugzilla.mozilla.org/show_bug.cg
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <script src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" href="/tests/SimpleTest/test.css">
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=569988">Mozilla Bug 569988</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 569988 **/
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(runTest);
 
 
 function runTest() {
+  /* eslint-env mozilla/frame-script */
   var script = SpecialPowers.loadChromeScript(function() {
+    const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm", null);
     var gPromptInput = null;
-    var os = Cc["@mozilla.org/observer-service;1"]
-               .getService(Ci.nsIObserverService);
+    var os = Services.obs;
 
     os.addObserver(onPromptLoad, "common-dialog-loaded");
     os.addObserver(onPromptLoad, "tabmodal-dialog-loaded");
 
     function onPromptLoad(subject, topic, data) {
       sendAsyncMessage("ok", [true, "onPromptLoad is called"]);
       gPromptInput = subject.Dialog.ui.loginTextbox;
       gPromptInput.addEventListener("focus", onPromptFocus);
@@ -41,19 +42,17 @@ function runTest() {
       subject.Dialog.ui.button0.focus();
       gPromptInput.focus();
     }
 
     function onPromptFocus() {
       sendAsyncMessage("ok", [true, "onPromptFocus is called"]);
       gPromptInput.removeEventListener("focus", onPromptFocus);
 
-      var listenerService =
-        Cc["@mozilla.org/eventlistenerservice;1"]
-          .getService(Ci.nsIEventListenerService);
+      var listenerService = Services.els;
 
       var listener = {
         handleEvent: function _hv(aEvent) {
           var isPrevented = aEvent.defaultPrevented;
           sendAsyncMessage("ok", [!isPrevented,
                            "ESC key event is prevented by editor"]);
           listenerService.removeSystemEventListener(gPromptInput, "keypress",
                                                     listener, false);
@@ -62,22 +61,21 @@ function runTest() {
       listenerService.addSystemEventListener(gPromptInput, "keypress",
                                              listener, false);
 
       sendAsyncMessage("info", "sending key");
       var EventUtils = {};
       EventUtils.window = {};
       EventUtils._EU_Ci = Ci;
       EventUtils._EU_Cc = Cc;
-      Cc["@mozilla.org/moz/jssubscript-loader;1"]
-        .getService(Ci.mozIJSSubScriptLoader)
+      Services.scriptloader
         .loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
                        EventUtils);
       EventUtils.synthesizeKey("VK_ESCAPE", {},
-                               gPromptInput.ownerDocument.defaultView);
+                               gPromptInput.ownerGlobal);
     }
 
     addMessageListener("destroy", function() {
       os.removeObserver(onPromptLoad, "tabmodal-dialog-loaded");
       os.removeObserver(onPromptLoad, "common-dialog-loaded");
     });
   });
   script.addMessageListener("ok", ([val, msg]) => ok(val, msg));
--- a/editor/libeditor/tests/test_bug596333.html
+++ b/editor/libeditor/tests/test_bug596333.html
@@ -21,36 +21,35 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 596333 **/
 const Ci = SpecialPowers.Ci;
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 
 var gMisspeltWords;
+var onSpellCheck;
 
 function getEditor() {
   return SpecialPowers.wrap(document.getElementById("edit")).editor;
 }
 
 function append(str) {
   var edit = document.getElementById("edit");
   edit.focus();
   edit.selectionStart = edit.selectionEnd = edit.value.length;
-  var editor = getEditor();
   sendString(str);
 }
 
 function getLoadContext() {
   return SpecialPowers.wrap(window).docShell.QueryInterface(Ci.nsILoadContext);
 }
 
 function paste(str) {
-  var edit = document.getElementById("edit");
-  var Cc = SpecialPowers.Cc, Ci = SpecialPowers.Ci;
+  var Cc = SpecialPowers.Cc;
   var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
   trans.init(getLoadContext());
   var s = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
   s.data = str;
   trans.setTransferData("text/unicode", s, str.length * 2);
 
   getEditor().pasteTransferable(trans);
 }
@@ -100,18 +99,18 @@ function runOnFocus() {
     });
   });
 }
 
 function runTest() {
   var edit = document.getElementById("edit");
   edit.focus();
 
-  SpecialPowers.Cu.import(
-    "resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
+  onSpellCheck = SpecialPowers.Cu.import(
+    "resource://testing-common/AsyncSpellCheckTestHelper.jsm", null).onSpellCheck;
   onSpellCheck(edit, runOnFocus);
 }
 </script>
 </pre>
 
 <textarea id="edit">I can haz cheezburger</textarea>
 
 </body>
--- a/editor/libeditor/tests/test_bug612128.html
+++ b/editor/libeditor/tests/test_bug612128.html
@@ -14,21 +14,22 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content">
 <input>
 <div contenteditable></div>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
+/* eslint-disable no-useless-concat */
+
 /** Test for Bug 612128 **/
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() {
   document.querySelector("input").focus();
-  var threw = false;
   try {
     is(document.execCommand("inserthtml", null, "<span>f" + "oo</span>"),
        false, "The insertHTML command should return false");
   } catch (e) {
     ok(false, "insertHTML should not throw here");
   }
   is(document.querySelectorAll("span").length, 0, "No span element should be injected inside the page");
   is(document.body.innerHTML.indexOf("f" + "oo"), -1, "No text should be injected inside the page");
--- a/editor/libeditor/tests/test_bug636465.html
+++ b/editor/libeditor/tests/test_bug636465.html
@@ -6,33 +6,32 @@
 <script src="/tests/SimpleTest/WindowSnapshot.js"></script>
 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=636465"
    target="_blank">Mozilla Bug 636465</a>
 <input id="x" value="foobarbaz" spellcheck="true" style="background-color: transparent; border: transparent;">
 <script>
 SimpleTest.waitForExplicitFinish();
 
 function runTest() {
-  SpecialPowers.Cu.import(
-    "resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
+  const {onSpellCheck} = SpecialPowers.Cu.import(
+    "resource://testing-common/AsyncSpellCheckTestHelper.jsm", {});
   var x = document.getElementById("x");
   x.focus();
   onSpellCheck(x, function() {
     x.blur();
     var spellCheckTrue = snapshotWindow(window);
     x.setAttribute("spellcheck", "false");
     var spellCheckFalse = snapshotWindow(window);
     x.setAttribute("spellcheck", "true");
     x.focus();
     onSpellCheck(x, function() {
       x.blur();
       var spellCheckTrueAgain = snapshotWindow(window);
       x.removeAttribute("spellcheck");
       var spellCheckNone = snapshotWindow(window);
-      var after = snapshotWindow(window);
       var ret = compareSnapshots(spellCheckTrue, spellCheckFalse, false)[0];
       ok(ret,
          "Setting the spellcheck attribute to false should work");
       if (!ret) {
         ok(false, "\nspellCheckTrue: " + spellCheckTrue.toDataURL() + "\nspellCheckFalse: " + spellCheckFalse.toDataURL());
       }
       ret = compareSnapshots(spellCheckTrue, spellCheckTrueAgain, true)[0];
       ok(ret,
--- a/editor/libeditor/tests/test_bug645914.html
+++ b/editor/libeditor/tests/test_bug645914.html
@@ -18,17 +18,17 @@ bar</textarea>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 645914 **/
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   SpecialPowers.pushPrefEnv({"set": [["layout.word_select.eat_space_to_next_word", true],
-                                    ["browser.triple_click_selects_paragraph", false]]}, startTest);
+                                     ["browser.triple_click_selects_paragraph", false]]}, startTest);
 });
 function startTest() {
   var textarea = document.querySelector("textarea");
   textarea.selectionStart = textarea.selectionEnd = 0;
 
   // Simulate a double click on foo
   synthesizeMouse(textarea, 5, 5, {clickCount: 2});
 
--- a/editor/libeditor/tests/test_bug674770-2.html
+++ b/editor/libeditor/tests/test_bug674770-2.html
@@ -42,17 +42,17 @@ function clickEventHandler(aEvent) {
   }
 }
 
 // NOTE: tests need to check the result *after* the content is actually
 //       modified.  Sometimes, the modification is delayed. Therefore, there
 //       are a lot of functions and SimpleTest.executeSoon()s.
 SimpleTest.waitForFocus(function() {
   SpecialPowers.pushPrefEnv({"set": [["middlemouse.contentLoadURL", false],
-                                    ["middlemouse.paste", true]]}, startTest);
+                                     ["middlemouse.paste", true]]}, startTest);
 });
 function startTest() {
   frameWindow = iframe.contentWindow;
   frameDocument = iframe.contentDocument;
 
   frameDocument.getElementById("input").addEventListener("click", clickEventHandler);
   frameDocument.getElementById("editor1").addEventListener("click", clickEventHandler);
   frameDocument.getElementById("editor2").addEventListener("click", clickEventHandler);
@@ -155,17 +155,16 @@ function runInputTests3() {
 
       SimpleTest.executeSoon(runInputTests4);
     });
   });
 }
 
 function runInputTests4() {
   var input = frameDocument.getElementById("input");
-  var editor1 = frameDocument.getElementById("editor1");
 
   // preventDefault() of input element's click event handler should prevent
   // middle click pasting in it.
   input.value = "";
   input.focus();
 
   SimpleTest.executeSoon(function() {
     gClicked = false;
--- a/editor/libeditor/tests/test_bug772796.html
+++ b/editor/libeditor/tests/test_bug772796.html
@@ -147,17 +147,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     SimpleTest.waitForFocus(function() {
 
       var sel = window.getSelection();
       var theEdit = document.getElementById("editable");
       var testName;
       var theDiv;
 
-      for (i = 0; i < tests.length; i++) {
+      for (let i = 0; i < tests.length; i++) {
         testName = "test" + i.toString();
 
         /* Set up the selection. */
         theEdit.innerHTML = "<div id=\"" + testName + "\">" + tests[i][0] + "</div>";
         theDiv = document.getElementById(testName);
         theDiv.focus();
         sel.collapse(theDiv, 0);
         synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */
--- a/editor/libeditor/tests/test_bug790475.html
+++ b/editor/libeditor/tests/test_bug790475.html
@@ -23,17 +23,16 @@ https://bugzilla.mozilla.org/show_bug.cg
  */
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(runTest);
 
 var gMisspeltWords;
 
 function getEditor() {
-  const Ci = SpecialPowers.Ci;
   var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
   return editingSession.getEditorForWindow(window);
 }
 
 function getSpellCheckSelection() {
   var editor = getEditor();
   var selcon = editor.selectionController;
   return selcon.getSelection(selcon.SELECTION_SPELLCHECK);
--- a/editor/libeditor/tests/test_bug795418-2.html
+++ b/editor/libeditor/tests/test_bug795418-2.html
@@ -34,17 +34,16 @@ SimpleTest.waitForFocus(function() {
   // Select the text from the text node in div.
   var r = document.createRange();
   r.setStart(div.firstChild, 0);
   r.setEnd(div.firstChild, 9);
   sel.addRange(r);
 
   function checkResult() {
     var iframe = document.querySelector("iframe");
-    var iframeWindow = iframe.contentWindow;
     var theEdit = iframe.contentDocument.firstChild;
     theEdit.offsetHeight;
     is(theEdit.innerHTML,
        "<blockquote xmlns=\"http://www.w3.org/1999/xhtml\" type=\"cite\">Copy this</blockquote><span xmlns=\"http://www.w3.org/1999/xhtml\">AB</span>",
        "unexpected HTML for test");
     SimpleTest.finish();
   }
 
--- a/editor/libeditor/tests/test_bug795418-3.html
+++ b/editor/libeditor/tests/test_bug795418-3.html
@@ -33,17 +33,16 @@ SimpleTest.waitForFocus(function() {
   // Select the text from the text node in div.
   var r = document.createRange();
   r.setStart(div.firstChild, 0);
   r.setEnd(div.firstChild, 9);
   sel.addRange(r);
 
   function checkResult() {
     var iframe = document.querySelector("iframe");
-    var iframeWindow = iframe.contentWindow;
     var theEdit = iframe.contentDocument.body;
     theEdit.offsetHeight;
     is(theEdit.innerHTML,
        "<span>AB<blockquote type=\"cite\">Copy this</blockquote></span>",
        "unexpected HTML for test");
     SimpleTest.finish();
   }
 
--- a/editor/libeditor/tests/test_bug795785.html
+++ b/editor/libeditor/tests/test_bug795785.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=795785">Mozilla Bug 795785</a>
 <div id="display">
   <textarea id="textarea" style="overflow: hidden; height: 3em; width: 5em; word-wrap: normal;"></textarea>
   <div id="div" contenteditable style="overflow: hidden; height: 3em; width: 5em;"></div>
 </div>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
 
 SimpleTest.waitForExplicitFinish();
@@ -63,17 +63,16 @@ function doKeyEventTest(aElement, aEleme
           is(aElement.scrollTop, scrollTop,
              aElementDescription + " was not scrolled by down key events");
           var longWord = "aaaaaaaaaaaaaaaaaaaa";
           sendString(longWord);
           hitEventLoop(function() {
             isnot(aElement.scrollLeft, 0,
                   aElementDescription + " was not scrolled by typing long word");
             var scrollLeft = aElement.scrollLeft;
-            var i;
             synthesizeKey("KEY_ArrowLeft", {repeat: longWord.length});
             hitEventLoop(function() {
               isnot(aElement.scrollLeft, scrollLeft,
                     aElementDescription + " was not scrolled by left key events");
               synthesizeKey("KEY_ArrowRight", {repeat: longWord.length});
               hitEventLoop(function() {
                 is(aElement.scrollLeft, scrollLeft,
                    aElementDescription + " was not scrolled by right key events");
--- a/editor/libeditor/tests/test_bug830600.html
+++ b/editor/libeditor/tests/test_bug830600.html
@@ -27,17 +27,16 @@ https://bugzilla.mozilla.org/show_bug.cg
       SimpleTest.waitForFocus(function() {
         const Ci = SpecialPowers.Ci;
         function test(str, expected, callback) {
           var t = document.getElementById("t1");
           t.focus();
           t.value = "";
           var editor = SpecialPowers.wrap(t).editor;
           editor.QueryInterface(Ci.nsIPlaintextEditor);
-          var origNewlineHandling = editor.newlineHandling;
           editor.newlineHandling = Ci.nsIPlaintextEditor.eNewlinesStripSurroundingWhitespace;
           SimpleTest.waitForClipboard(str,
             function() {
               SpecialPowers.Cc["@mozilla.org/widget/clipboardhelper;1"]
                         .getService(Ci.nsIClipboardHelper)
                         .copyString(str);
             },
             function() {
--- a/editor/libeditor/tests/test_bug850043.html
+++ b/editor/libeditor/tests/test_bug850043.html
@@ -20,18 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="content" style="display: none">
 </div>
 
 <pre id="test">
 </pre>
 <script>
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(() => {
-  let fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
-    getService(SpecialPowers.Ci.nsIFocusManager);
+  let fm = SpecialPowers.Services.focus;
 
   let element = document.getElementById("textarea");
   element.setSelectionRange(element.value.length, element.value.length);
   element.focus();
   is(SpecialPowers.unwrap(fm.focusedElement), element, "failed to move focus");
 
   synthesizeKey("KEY_End");
   sendString("a");
--- a/editor/libeditor/tests/test_bug966155.html
+++ b/editor/libeditor/tests/test_bug966155.html
@@ -13,19 +13,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=966155">Mozilla Bug 966155</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 SimpleTest.waitForExplicitFinish();
 
-var win = window.open("file_bug966155.html", "", "test-966155");
-win.addEventListener("load", function() {
-  runTest(win);
+var testWindow = window.open("file_bug966155.html", "", "test-966155");
+testWindow.addEventListener("load", function() {
+  runTest(testWindow);
 }, {once: true});
 
 function runTest(win) {
   SimpleTest.waitForFocus(function() {
     var doc = win.document;
     var iframe = doc.querySelector("iframe");
     var iframeDoc = iframe.contentDocument;
     var input = doc.querySelector("input");
--- a/editor/libeditor/tests/test_bug966552.html
+++ b/editor/libeditor/tests/test_bug966552.html
@@ -13,19 +13,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=966552">Mozilla Bug 966552</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 SimpleTest.waitForExplicitFinish();
 
-var win = window.open("file_bug966552.html", "", "test-966552");
-win.addEventListener("load", function() {
-  runTest(win);
+var testWindow = window.open("file_bug966552.html", "", "test-966552");
+testWindow.addEventListener("load", function() {
+  runTest(testWindow);
 }, {once: true});
 
 function runTest(win) {
   SimpleTest.waitForFocus(function() {
     var doc = win.document;
     var sel = win.getSelection();
     doc.body.focus();
     sel.collapse(doc.body.firstChild, 2);
--- a/editor/libeditor/tests/test_contenteditable_focus.html
+++ b/editor/libeditor/tests/test_contenteditable_focus.html
@@ -28,57 +28,44 @@
     </div>
     <span id="spanInEditor">span element in editor</span><br>
   </div>
   <div id="otherEditor" contenteditable="true">
     other editor.
   </div>
 </div>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(runTests, window);
 
 function runTests() {
   runTestsInternal();
   SimpleTest.finish();
 }
 
 function runTestsInternal() {
-  var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
-             getService(SpecialPowers.Ci.nsIFocusManager);
+  var fm = SpecialPowers.Services.focus;
   // XXX using selCon for checking the visibility of the caret, however,
   // selCon is shared in document, cannot get the element of owner of the
   // caret from javascript?
   var selCon = SpecialPowers.wrap(window).docShell.
         QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor).
         getInterface(SpecialPowers.Ci.nsISelectionDisplay).
         QueryInterface(SpecialPowers.Ci.nsISelectionController);
   var selection = window.getSelection();
 
-  var inputText = document.getElementById("inputText");
-  var inputTextReadonly = document.getElementById("inputTextReadonly");
-  var inputButton = document.getElementById("inputButton");
-  var button = document.getElementById("button");
   var editor = document.getElementById("editor");
   var inputTextInEditor = document.getElementById("inputTextInEditor");
-  var inputTextReadonlyInEditor = document.getElementById("inputTextReadonlyInEditor");
-  var inputButtonInEditor = document.getElementById("inputButtonInEditor");
-  var noeditableInEditor = document.getElementById("noeditableInEditor");
-  var spanInNoneditableInEditor = document.getElementById("spanInNoneditableInEditor");
-  var inputTextInNoneditableInEditor = document.getElementById("inputTextInNoneditableInEditor");
-  var inputTextReadonlyInNoneditableInEditor = document.getElementById("inputTextReadonlyInNoneditableInEditor");
-  var inputButtonInNoneditableInEditor = document.getElementById("inputButtonInNoneditableInEditor");
-  var buttonInNoneditableInEditor = document.getElementById("buttonInNoneditableInEditor");
   var spanInEditor = document.getElementById("spanInEditor");
   var otherEditor = document.getElementById("otherEditor");
 
   // XXX if there is a contenteditable element, HTML editor sets dom selection
   // to first editable node, but this makes inconsistency with normal document
   // behavior.
   todo_is(selection.rangeCount, 0, "unexpected selection range is there");
   ok(!selCon.caretVisible, "caret is visible in the document");
@@ -103,28 +90,28 @@ function runTestsInternal() {
   // Move focus to other editor
   otherEditor.focus();
   is(SpecialPowers.unwrap(fm.focusedElement), otherEditor,
      "the other editor didn't get focus");
   is(selection.rangeCount, 1,
      "there is no selection range when the other editor has focus");
   range = selection.getRangeAt(0);
   ok(range.collapsed, "the selection range isn't collapsed");
-  var startNode = range.startContainer;
+  startNode = range.startContainer;
   is(startNode.nodeType, Node.TEXT_NODE, "the caret isn't set to the text node");
   is(startNode, otherEditor.firstChild, "the caret isn't set to the other editor");
   ok(selCon.caretVisible, "caret isn't visible in the other editor");
   // Move focus to inputTextInEditor
   inputTextInEditor.focus();
   is(SpecialPowers.unwrap(fm.focusedElement), inputTextInEditor,
      "inputTextInEditor didn't get focus #2");
   is(selection.rangeCount, 1, "selection range is lost from the document");
   range = selection.getRangeAt(0);
   ok(range.collapsed, "the selection range isn't collapsed");
-  var startNode = range.startContainer;
+  startNode = range.startContainer;
   is(startNode.nodeType, Node.TEXT_NODE, "the caret isn't set to the first text node");
   // XXX maybe, the caret can stay on the other editor if it's better.
   is(startNode, editor.firstChild,
      "the caret should stay on the other editor");
   ok(selCon.caretVisible,
      "caret isn't visible in the inputTextInEditor");
   // Move focus to the other editor again
   otherEditor.focus();
@@ -143,17 +130,17 @@ function runTestsInternal() {
   editor.focus();
   is(SpecialPowers.unwrap(fm.focusedElement), editor,
      "the editor didn't get focus #2");
   is(selection.rangeCount, 1, "selection range is lost from the document");
   range = selection.getRangeAt(0);
   ok(range.collapsed, "the selection range isn't collapsed");
   is(range.startOffset, 5,
      "the caret is moved when the editor was focused (offset)");
-  var startNode = range.startContainer;
+  startNode = range.startContainer;
   is(startNode.nodeType, 3, "the caret isn't in text node");
   is(startNode.parentNode, spanInEditor,
      "the caret is moved when the editor was focused (node)");
   ok(selCon.caretVisible, "caret isn't visible in the editor (spanInEditor)");
 
   // Move focus to each focusable element in the editor.
   function testFocusMove(aSetFocusElementID, aFocusable, aCaretVisible) {
     editor.focus();
--- a/editor/libeditor/tests/test_contenteditable_text_input_handling.html
+++ b/editor/libeditor/tests/test_contenteditable_text_input_handling.html
@@ -9,39 +9,38 @@
           href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 </head>
 <body>
 <div id="display">
   <p id="static">static content<input id="inputInStatic"><textarea id="textareaInStatic"></textarea></p>
   <p id="editor"contenteditable="true">content editable<input id="inputInEditor"><textarea id="textareaInEditor"></textarea></p>
 </div>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(runTests);
 
 const kLF = !navigator.platform.indexOf("Win") ? "\r\n" : "\n";
 
 function runTests() {
-  var fm = Cc["@mozilla.org/focus-manager;1"].
-             getService(Ci.nsIFocusManager);
+  const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm", null);
+  var fm = Services.focus;
 
   var listener = {
     handleEvent: function _hv(aEvent) {
       aEvent.preventDefault(); // prevent the browser default behavior
     },
   };
-  var els = Cc["@mozilla.org/eventlistenerservice;1"].
-    getService(Ci.nsIEventListenerService);
+  var els = Services.els;
   els.addSystemEventListener(window, "keypress", listener, false);
 
   var staticContent = document.getElementById("static");
   staticContent._defaultValue = getTextValue(staticContent);
   staticContent._isFocusable = false;
   staticContent._isEditable = false;
   staticContent._isContentEditable = false;
   staticContent._description = "non-editable p element";
@@ -148,22 +147,22 @@ function runTests() {
         checkValue(inputInEditor, "");
         checkValue(textareaInEditor, "");
       }
     }
 
     // When key events are fired on unfocused editor.
     function testDispatchedKeyEvent(aTarget) {
       var targetDescription = " (dispatched to " + aTarget._description + ")";
-      function dispatchKeyEvent(aKeyCode, aChar, aTarget) {
+      function dispatchKeyEvent(aKeyCode, aChar, aDispatchTarget) {
         var keyEvent = document.createEvent("KeyboardEvent");
         keyEvent.initKeyEvent("keypress", true, true, null, false, false,
                                false, false, aKeyCode,
                                aChar ? aChar.charCodeAt(0) : 0);
-        aTarget.dispatchEvent(keyEvent);
+        aDispatchTarget.dispatchEvent(keyEvent);
       }
 
       function checkValueForDispatchedKeyEvent(aElement, aInsertedText) {
         if (aElement == aTarget && aElement._isEditable &&
             (!aElement._isContentEditable || aElement == aFocus)) {
           is(getTextValue(aElement), aInsertedText + aElement._defaultValue,
              aElement._description +
                " wasn't edited by dispatched key events" +
--- a/editor/libeditor/tests/test_documentCharacterSet.html
+++ b/editor/libeditor/tests/test_documentCharacterSet.html
@@ -11,17 +11,16 @@
 </div>
 
 <iframe></iframe>
 
 <pre id="test">
 
 <script class="testbody" type="application/javascript">
 function getEditor() {
-  const Ci = SpecialPowers.Ci;
   let editframe = window.frames[0];
   return SpecialPowers.wrap(editframe).docShell.editingSession
                       .getEditorForWindow(editframe);
 }
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   let editdoc = window.frames[0].document;
--- a/editor/libeditor/tests/test_dom_input_event_on_htmleditor.html
+++ b/editor/libeditor/tests/test_dom_input_event_on_htmleditor.html
@@ -12,17 +12,17 @@
 <div id="display">
   <iframe id="editor1" srcdoc="<html><body contenteditable id='eventTarget'></body></html>"></iframe>
   <iframe id="editor2" srcdoc="<html contenteditable id='eventTarget'><body></body></html>"></iframe>
   <iframe id="editor3" srcdoc="<html><body><div contenteditable id='eventTarget'></div></body></html>"></iframe>
   <iframe id="editor4" srcdoc="<html contenteditable id='eventTarget'><body><div contenteditable id='editTarget'></div></body></html>"></iframe>
   <iframe id="editor5" srcdoc="<html><body id='eventTarget'></body><script>document.designMode='on';</script></html>"></iframe>
 </div>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(runTests, window);
@@ -61,24 +61,24 @@ function runTests() {
     var inputEvent = null;
 
     var handler = function(aEvent) {
       is(aEvent.target, eventTarget,
          "input event is fired on unexpected element: " + aEvent.target.tagName);
       ok(!aEvent.cancelable, "input event must not be cancelable");
       ok(aEvent.bubbles, "input event must be bubbles");
       if (SpecialPowers.getBoolPref("dom.event.highrestimestamp.enabled")) {
-        var duration = Math.abs(window.performance.now() - aEvent.timeStamp);
+        let duration = Math.abs(window.performance.now() - aEvent.timeStamp);
         ok(duration < 30 * 1000,
            "perhaps, timestamp wasn't set correctly :" + aEvent.timeStamp +
            " (expected it to be within 30s of the current time but it " +
            "differed by " + duration + "ms)");
       } else {
         var eventTime = new Date(aEvent.timeStamp);
-        var duration = Math.abs(Date.now() - aEvent.timeStamp);
+        let duration = Math.abs(Date.now() - aEvent.timeStamp);
         ok(duration < 30 * 1000,
            "perhaps, timestamp wasn't set correctly :" +
            eventTime.toLocaleString() +
            " (expected it to be within 30s of the current time but it " +
            "differed by " + duration + "ms)");
       }
       inputEvent = aEvent;
     };
--- a/editor/libeditor/tests/test_dom_input_event_on_texteditor.html
+++ b/editor/libeditor/tests/test_dom_input_event_on_texteditor.html
@@ -9,17 +9,17 @@
           href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <div id="display">
   <input type="text" id="input">
   <textarea id="textarea"></textarea>
 </div>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(runTests, window);
@@ -35,24 +35,24 @@ function runTests() {
     var inputEvent = null;
 
     var handler = function(aEvent) {
       is(aEvent.target, aElement,
          "input event is fired on unexpected element: " + aEvent.target.tagName);
       ok(!aEvent.cancelable, "input event must not be cancelable");
       ok(aEvent.bubbles, "input event must be bubbles");
       if (SpecialPowers.getBoolPref("dom.event.highrestimestamp.enabled")) {
-        var duration = Math.abs(window.performance.now() - aEvent.timeStamp);
+        let duration = Math.abs(window.performance.now() - aEvent.timeStamp);
         ok(duration < 30 * 1000,
            "perhaps, timestamp wasn't set correctly :" + aEvent.timeStamp +
            " (expected it to be within 30s of the current time but it " +
            "differed by " + duration + "ms)");
       } else {
         var eventTime = new Date(aEvent.timeStamp);
-        var duration = Math.abs(Date.now() - aEvent.timeStamp);
+        let duration = Math.abs(Date.now() - aEvent.timeStamp);
         ok(duration < 30 * 1000,
            "perhaps, timestamp wasn't set correctly :" +
            eventTime.toLocaleString() +
            " (expected it to be within 30s of the current time but it " +
            "differed by " + duration + "ms)");
       }
       inputEvent = aEvent;
     };
--- a/editor/libeditor/tests/test_dragdrop.html
+++ b/editor/libeditor/tests/test_dragdrop.html
@@ -29,16 +29,18 @@ function doTest() {
                             data: "<html><body></body></html>" };
   const htmlInfoData = { type: "text/_moz_htmlinfo", data: "0,0" };
   const htmlData = { type: "text/html", data: '<span id="text" style="font-size: 40px;">Some Text</span>' };
 
   const htmlContextDataEditable = { type: "text/_moz_htmlcontext",
                                     data: '<html><body><p id="contenteditable" contenteditable="true"></p></body></html>' };
 
   var text = document.getElementById("text");
+  var textarea = document.getElementById("textarea");
+  var bold = document.getElementById("bold");
   var input = document.getElementById("input");
   var contenteditable = document.getElementById("contenteditable");
 
   var selection = window.getSelection();
 
   // -------- Test dragging regular text
   selection.selectAllChildren(text);
   var result = synthesizeDragStart(text, [[htmlContextData, htmlInfoData, htmlData,
--- a/editor/libeditor/tests/test_execCommandPaste_noTarget.html
+++ b/editor/libeditor/tests/test_execCommandPaste_noTarget.html
@@ -8,28 +8,26 @@
 </head>
 <body>
 <script>
 
   add_task(async function() {
     let seenPaste = false;
     let seenCopy = false;
     document.addEventListener("copy", function oncpy(e) {
-      document.removeEventListener("copy", oncpy);
       e.clipboardData.setData("text/plain", "my text");
       e.preventDefault();
       seenCopy = true;
-    });
+    }, {once: true});
     document.addEventListener("paste", function onpst(e) {
-      document.removeEventListener("paste", onpst);
       is(e.clipboardData.getData("text/plain"), "my text",
          "The correct text was read from the clipboard");
       e.preventDefault();
       seenPaste = true;
-    });
+    }, {once: true});
 
     ok(SpecialPowers.wrap(document).execCommand("copy"),
        "Call should succeed");
     ok(seenCopy, "Successfully copied the text to the clipboard");
     ok(SpecialPowers.wrap(document).execCommand("paste"),
        "Call should succeed");
     ok(seenPaste, "Successfully read text from the clipboard");
 
--- a/editor/libeditor/tests/test_htmleditor_keyevent_handling.html
+++ b/editor/libeditor/tests/test_htmleditor_keyevent_handling.html
@@ -8,38 +8,39 @@
   <link rel="stylesheet" type="text/css"
           href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 </head>
 <body>
 <div id="display">
   <div id="htmlEditor" contenteditable="true"><br></div>
 </div>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
+/* eslint-disable no-nested-ternary */
+
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(runTests, window);
 
 var htmlEditor = document.getElementById("htmlEditor");
 
 const kIsMac = navigator.platform.indexOf("Mac") == 0;
 const kIsWin = navigator.platform.indexOf("Win") == 0;
 const kIsLinux = navigator.platform.indexOf("Linux") == 0 || navigator.platform.indexOf("SunOS") == 0 ;
 
 function runTests() {
   document.execCommand("stylewithcss", false, "true");
   document.execCommand("defaultParagraphSeparator", false, "div");
 
-  var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
-    getService(SpecialPowers.Ci.nsIFocusManager);
+  var fm = SpecialPowers.Services.focus;
 
   var capturingPhase = { fired: false, prevented: false };
   var bubblingPhase = { fired: false, prevented: false };
 
   var listener = {
     handleEvent: function _hv(aEvent) {
       is(aEvent.type, "keypress", "unexpected event is handled");
       switch (aEvent.eventPhase) {
@@ -78,16 +79,17 @@ function runTests() {
 
     is(bubblingPhase.prevented, aPreventedOnBubbling,
        getDesciption(aPreventedOnBubbling) + "prevented on bubbling phase");
   }
 
   SpecialPowers.addSystemEventListener(window, "keypress", listener, true);
   SpecialPowers.addSystemEventListener(window, "keypress", listener, false);
 
+  // eslint-disable-next-line complexity
   function doTest(aElement, aDescription,
                   aIsReadonly, aIsTabbable, aIsPlaintext) {
     function reset(aText) {
       capturingPhase.fired = false;
       capturingPhase.prevented = false;
       bubblingPhase.fired = false;
       bubblingPhase.prevented = false;
       aElement.innerHTML = aText;
--- a/editor/libeditor/tests/test_inlineTableEditing.html
+++ b/editor/libeditor/tests/test_inlineTableEditing.html
@@ -26,17 +26,18 @@ SimpleTest.waitForFocus(function() {
   document.execCommand("enableObjectResizing", false, "false");
   document.execCommand("enableInlineTableEditing", false, "true");
 
   let tableNode = document.getElementById("table1");
   synthesizeMouseAtCenter(tableNode, {});
   isnot(tableNode.getAttribute("_moz_resizing"), "true",
          "_moz_resizing attribute shouldn't be true without object resizing");
 
-  ok(document.getElementById("tr2"), "id=tr2 should exist");
+  let tr2 = document.getElementById("tr2");
+  ok(tr2, "id=tr2 should exist");
   synthesizeMouse(tr2, 0, tr2.clientHeight / 2, {});
   ok(!document.getElementById("tr2"),
      "id=tr2 should be removed by a click in the row");
 
   SimpleTest.finish();
 });
 </script>
 </pre>
--- a/editor/libeditor/tests/test_nsITableEditor_getCellAt.html
+++ b/editor/libeditor/tests/test_nsITableEditor_getCellAt.html
@@ -15,24 +15,24 @@
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   let editor = document.getElementById("content");
   let selection = document.getSelection();
 
   try {
-    let cell = SpecialPowers.unwrap(getTableEditor().getCellAt(undefined, 0, 0));
+    SpecialPowers.unwrap(getTableEditor().getCellAt(undefined, 0, 0));
     ok(false, "nsITableEditor.getCellAt(undefined) should cause throwing an exception when editor does not have Selection");
   } catch (e) {
     ok(true, "nsITableEditor.getCellAt(undefined) should cause throwing an exception when editor does not have Selection");
   }
 
   try {
-    let cell = SpecialPowers.unwrap(getTableEditor().getTableSize(null, 0, 0));
+    SpecialPowers.unwrap(getTableEditor().getTableSize(null, 0, 0));
     ok(false, "nsITableEditor.getCellAt(null) should cause throwing an exception when editor does not have Selection");
   } catch (e) {
     ok(true, "nsITableEditor.getCellAt(null) should cause throwing an exception when editor does not have Selection");
   }
 
   // XXX This is inconsistent behavior with other APIs.
   try {
     let cell = SpecialPowers.unwrap(getTableEditor().getCellAt(editor, 0, 0));
--- a/editor/libeditor/tests/test_nsITableEditor_getCellIndexes.html
+++ b/editor/libeditor/tests/test_nsITableEditor_getCellIndexes.html
@@ -38,17 +38,17 @@ SimpleTest.waitForFocus(function() {
     getTableEditor().getCellIndexes(editor, rowIndex, columnIndex);
     ok(false, "nsITableEditor.getCellIndexes() should cause throwing an exception if given node is not a <td> nor a <th>");
   } catch (e) {
     ok(true, "nsITableEditor.getCellIndexes() should cause throwing an exception if given node is not a <td> nor a <th>");
   }
 
   // Set id to "test" for the argument for getCellIndexes().
   // Set data-row and data-col to expected indexes.
-  kTests = [
+  const kTests = [
     '<table><tr><td id="test" data-row="0" data-col="0">cell1-1</td><td>cell1-2</td><td>cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
     '<table><tr><td>cell1-1</td><td id="test" data-row="0" data-col="1">cell1-2</td><td>cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
     '<table><tr><td>cell1-1</td><td>cell1-2</td><td id="test" data-row="0" data-col="2">cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
     '<table><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</tr><tr><td id="test" data-row="1" data-col="0">cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
     '<table><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</tr><tr><td>cell2-1</td><td id="test" data-row="1" data-col="1">cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
     '<table><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td id="test" data-row="1" data-col="2">cell2-3</td></tr><tr><td>cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
     '<table><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td id="test" data-row="2" data-col="0">cell3-1</td><td>cell3-2</td><td>cell3-3</td></tr></table>',
     '<table><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr><tr><td>cell3-1</td><td id="test" data-row="2" data-col="1">cell3-2</td><td>cell3-3</td></tr></table>',
--- a/editor/libeditor/tests/test_nsITableEditor_getFirstRow.html
+++ b/editor/libeditor/tests/test_nsITableEditor_getFirstRow.html
@@ -14,40 +14,40 @@
 
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
   let editor = document.getElementById("content");
 
   try {
-    let ret = SpecialPowers.unwrap(getTableEditor().getFirstRow(undefined));
+    SpecialPowers.unwrap(getTableEditor().getFirstRow(undefined));
     ok(false, "nsITableEditor.getFirstRow(undefined) should cause throwing an exception");
   } catch (e) {
     ok(true, "nsITableEditor.getFirstRow(undefined) should cause throwing an exception");
   }
 
   try {
-    let ret = SpecialPowers.unwrap(getTableEditor().getFirstRow(null));
+    SpecialPowers.unwrap(getTableEditor().getFirstRow(null));
     ok(false, "nsITableEditor.getFirstRow(null) should cause throwing an exception");
   } catch (e) {
     ok(true, "nsITableEditor.getFirstRow(null) should cause throwing an exception");
   }
 
   try {
-    let ret = SpecialPowers.unwrap(getTableEditor().getFirstRow(editor));
+    SpecialPowers.unwrap(getTableEditor().getFirstRow(editor));
     ok(false, "nsITableEditor.getFirstRow() should cause throwing an exception if given node is not in <table>");
   } catch (e) {
     ok(true, "nsITableEditor.getFirstRow() should cause throwing an exception if given node is not in <table>");
   }
 
   // Set id to "test" for the argument for getFirstRow().
   // Set id to "expected" for the expected <tr> element result (if there is).
   // Set class of <table> to "hasAnonymousRow" if it does not has <tr> but will be anonymous <tr> element is created.
-  kTests = [
+  const kTests = [
     '<table id="test"><tr id="expected"><td>cell1-1</td><td>cell1-2</td></tr><tr><td>cell2-1</td><td>cell2-2</td></tr></table>',
     '<table><tr id="expected"><td id="test">cell1-1</td><td>cell1-2</td></tr><tr><td>cell2-1</td><td>cell2-2</td></tr></table>',
     '<table><tr id="expected"><td id="test">cell1-1</td><td>cell1-2</td></tr><tr><td>cell2-1</td><td>cell2-2</td></tr></table>',
     '<table><tr id="expected"><td>cell1-1</td><td id="test">cell1-2</td></tr><tr><td>cell2-1</td><td>cell2-2</td></tr></table>',
     '<table><tr id="expected"><td>cell1-1</td><td>cell1-2</td></tr><tr id="test"><td>cell2-1</td><td>cell2-2</td></tr></table>',
     '<table><tr id="expected"><td>cell1-1</td><td>cell1-2</td></tr><tr><td id="test">cell2-1</td><td>cell2-2</td></tr></table>',
     '<table><tr id="expected"><td>cell1-1</td><td>cell1-2</td></tr><tr><td>cell2-1</td><td id="test">cell2-2</td></tr></table>',
     '<table><tbody id="test"><tr id="expected"><td>cell1-1</td><td>cell1-2</td></tr><tr><td>cell2-1</td><td>cell2-2</td></tr></tbody></table>',
--- a/editor/libeditor/tests/test_nsITableEditor_getNextSelectedCell.html
+++ b/editor/libeditor/tests/test_nsITableEditor_getNextSelectedCell.html
@@ -30,17 +30,17 @@ SimpleTest.waitForFocus(function() {
         '<table><tr id="r2-1"><td id="c2-1-1">cell2-1-1</td></tr></table>' +
         '</th><td id="c5-5">cell5-5</td></tr>' +
       '<tr id="r6"><td id="c6-2">cell6-2</td><td id="c6-3">cell6-3</td><td id="c6-4"><p>cell6-4</p></td><td id="c6-5">cell6-5</td></tr>' +
       '<tr id="r7"><td id="c7-2" colspan="4">cell7-2</td></tr>' +
     "</table>";
 
   let tr = document.getElementById("r1");
   selection.setBaseAndExtent(tr, 0, tr, 1);
-  cell = SpecialPowers.unwrap(getTableEditor().getFirstSelectedCell(rangeWrapper));
+  let cell = SpecialPowers.unwrap(getTableEditor().getFirstSelectedCell(rangeWrapper));
   is(cell.getAttribute("id"), "c1-1",
      "#1-1 nsITableEditor.getFirstSelectedCell() should return the first cell element in the first row");
 
   cell = SpecialPowers.unwrap(getTableEditor().getNextSelectedCell(rangeWrapper));
   is(cell, null,
      "Next of #1-1 nsITableEditor.getNextSelectedCell() should return null if there is only one selected range");
 
   selection.removeAllRanges();
--- a/editor/libeditor/tests/test_nsITableEditor_getTableSize.html
+++ b/editor/libeditor/tests/test_nsITableEditor_getTableSize.html
@@ -38,17 +38,17 @@ SimpleTest.waitForFocus(function() {
     getTableEditor().getTableSize(editor, rowCount, columnCount);
     ok(false, "nsITableEditor.getTableSize() should cause throwing an exception if given node is not in a <table>");
   } catch (e) {
     ok(true, "nsITableEditor.getTableSize() should cause throwing an exception if given node is not in a <table>");
   }
 
   // Set id to "test" for the argument for getTableSize().
   // Set data-rows and data-cols to expected count of them.
-  kTests = [
+  const kTests = [
     '<table><tr><td id="test" data-rows="2" data-cols="3">cell1-1</td><td>cell1-2</td><td>cell1-3</td></tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr></table>',
     '<table><tr id="test" data-rows="2" data-cols="3"><td>cell1-1</td><td>cell1-2</td><td>cell1-3</td></tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr></table>',
     '<table id="test" data-rows="2" data-cols="3"><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</td></tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr></table>',
     '<table><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</td></tr><tr><td>cell2-1</td><td>cell2-2</td><td><p id="test" data-rows="2" data-cols="3">cell2-3</p></td></tr></table>',
     '<table><caption id="test" data-rows="2" data-cols="3">caption</caption><tr><td>cell1-1</td><td>cell1-2</td><td>cell1-3</td></tr><tr><td>cell2-1</td><td>cell2-2</td><td>cell2-3</td></tr></table>',
     '<table id="test" data-rows="0" data-cols="0"></table>',
     '<table id="test" data-rows="0" data-cols="0"><caption>caption</caption></table>',
     '<table id="test" data-rows="1" data-cols="1"><td>cell1-1</td></table>',
--- a/editor/libeditor/tests/test_selection_move_commands.html
+++ b/editor/libeditor/tests/test_selection_move_commands.html
@@ -51,19 +51,19 @@ function* runTests() {
 
   function testMoveCommand(cmd, expectNode, expectOffset) {
     SpecialPowers.doCommand(window, cmd);
     is(sel.isCollapsed, true, "collapsed after " + cmd);
     is(sel.anchorNode, expectNode, "node after " + cmd);
     is(sel.anchorOffset, expectOffset, "offset after " + cmd);
   }
 
-  function findChildNum(e, child) {
+  function findChildNum(element, child) {
     var i = 0;
-    var n = e.firstChild;
+    var n = element.firstChild;
     while (n && n != child) {
       n = n.nextSibling;
       ++i;
     }
     if (!n)
       return -1;
     return i;
   }
--- a/editor/libeditor/tests/test_texteditor_keyevent_handling.html
+++ b/editor/libeditor/tests/test_texteditor_keyevent_handling.html
@@ -10,17 +10,17 @@
 </head>
 <body>
 <div id="display">
   <input type="text" id="inputField">
   <input type="password" id="passwordField">
   <textarea id="textarea"></textarea>
 </div>
 <div id="content" style="display: none">
-  
+
 </div>
 <pre id="test">
 </pre>
 
 <script class="testbody" type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(runTests, window);
@@ -29,18 +29,17 @@ var inputField = document.getElementById
 var passwordField = document.getElementById("passwordField");
 var textarea = document.getElementById("textarea");
 
 const kIsMac = navigator.platform.indexOf("Mac") == 0;
 const kIsWin = navigator.platform.indexOf("Win") == 0;
 const kIsLinux = navigator.platform.indexOf("Linux") == 0;
 
 function runTests() {
-  var fm = SpecialPowers.Cc["@mozilla.org/focus-manager;1"].
-    getService(SpecialPowers.Ci.nsIFocusManager);
+  var fm = SpecialPowers.Services.focus;
 
   var capturingPhase = { fired: false, prevented: false };
   var bubblingPhase = { fired: false, prevented: false };
 
   var listener = {
     handleEvent: function _hv(aEvent) {
       is(aEvent.type, "keypress", "unexpected event is handled");
       switch (aEvent.eventPhase) {
--- a/editor/spellchecker/tests/test_bug1200533.html
+++ b/editor/spellchecker/tests/test_bug1200533.html
@@ -47,17 +47,19 @@ var tests = [
     [ "ko-not-avail",    "de-DE", "de-DE" ],
   ];
 
 var loadCount = 0;
 var script;
 
 var loadListener = function(evt) {
   if (loadCount == 0) {
+    /* eslint-env mozilla/frame-script */
     script = SpecialPowers.loadChromeScript(function() {
+      // eslint-disable-next-line mozilla/use-services
       var dir = Cc["@mozilla.org/file/directory_service;1"]
                   .getService(Ci.nsIProperties)
                   .get("CurWorkD", Ci.nsIFile);
       dir.append("tests");
       dir.append("editor");
       dir.append("spellchecker");
       dir.append("tests");
 
--- a/editor/spellchecker/tests/test_bug1204147.html
+++ b/editor/spellchecker/tests/test_bug1204147.html
@@ -26,30 +26,32 @@ var content = document.getElementById("c
 // one that should use "en-US". With the bug corrected, we get "en-US", before
 // we got "en-GB" from the content preference.
 
 var firstLoad = true;
 var script;
 
 var loadListener = function(evt) {
   if (firstLoad) {
+    /* eslint-env mozilla/frame-script */
     script = SpecialPowers.loadChromeScript(function() {
+      // eslint-disable-next-line mozilla/use-services
       var dir = Cc["@mozilla.org/file/directory_service;1"]
                   .getService(Ci.nsIProperties)
                   .get("CurWorkD", Ci.nsIFile);
       dir.append("tests");
       dir.append("editor");
       dir.append("spellchecker");
       dir.append("tests");
 
       var hunspell = Cc["@mozilla.org/spellchecker/engine;1"]
                        .getService(Ci.mozISpellCheckingEngine);
 
       // Install en-GB dictionary.
-      en_GB = dir.clone();
+      let en_GB = dir.clone();
       en_GB.append("en-GB");
       hunspell.addDirectory(en_GB);
 
       addMessageListener("en_GB-exists", () => en_GB.exists());
       addMessageListener("destroy", () => hunspell.removeDirectory(en_GB));
     });
     is(script.sendSyncMessage("en_GB-exists")[0][0], true,
        "true expected (en-GB directory should exist)");
--- a/editor/spellchecker/tests/test_bug1205983.html
+++ b/editor/spellchecker/tests/test_bug1205983.html
@@ -30,17 +30,19 @@ var script;
 
 var onSpellCheck =
   SpecialPowers.Cu.import(
     "resource://testing-common/AsyncSpellCheckTestHelper.jsm").onSpellCheck;
 
 /** Test for Bug 1205983 **/
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
+  /* eslint-env mozilla/frame-script */
   script = SpecialPowers.loadChromeScript(function() {
+    // eslint-disable-next-line mozilla/use-services
     var dir = Cc["@mozilla.org/file/directory_service;1"]
                 .getService(Ci.nsIProperties)
                 .get("CurWorkD", Ci.nsIFile);
     dir.append("tests");
     dir.append("editor");
     dir.append("spellchecker");
     dir.append("tests");
 
@@ -60,17 +62,16 @@ SimpleTest.waitForFocus(function() {
 
   document.getElementById("de-DE").focus();
 });
 
 function deFocus() {
   elem_de = document.getElementById("de-DE");
 
   onSpellCheck(elem_de, function() {
-    var Ci = SpecialPowers.Ci;
     var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
     editor_de = editingSession.getEditorForWindow(window);
     selcon_de = editor_de.selectionController;
     var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
 
     // Check that we spelled in German, so there is only one misspelled word.
     is(sel.toString(), "German", "one misspelled word expected: German");
 
@@ -84,16 +85,17 @@ function enFocus() {
   var editor_en =
     SpecialPowers.wrap(elem_en)
                  .editor;
   editor_en.setSpellcheckUserOverride(true);
   var inlineSpellChecker = editor_en.getInlineSpellChecker(true);
 
   onSpellCheck(elem_en, function() {
     var spellchecker = inlineSpellChecker.spellChecker;
+    let currentDictonary;
     try {
       currentDictonary = spellchecker.GetCurrentDictionary();
     } catch (e) {}
 
     // Check that the English dictionary is loaded and that the spell check has worked.
     is(currentDictonary, "en-US", "expected en-US");
     is(getMisspelledWords(editor_en), "Nogoodword", "one misspelled word expected: Nogoodword");
 
@@ -108,18 +110,19 @@ function enFocus() {
 
     // Focus again, so the spelling gets updated, but before we need to kill the focus handler.
     elem_de.onfocus = null;
     elem_de.blur();
     elem_de.focus();
 
     // After removal, the de_DE editor should refresh the spelling with en-US.
     onSpellCheck(elem_de, function() {
-      var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
-      is(sel.toString(), "heute" + "ist" + "ein" + "guter",
+      var endSel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
+      // eslint-disable-next-line no-useless-concat
+      is(endSel.toString(), "heute" + "ist" + "ein" + "guter",
          "some misspelled words expected: heute ist ein guter");
 
       // If we don't reset this, we cause massive leaks.
       selcon_de = null;
       editor_de = null;
 
       SimpleTest.finish();
     });
--- a/editor/spellchecker/tests/test_bug1209414.html
+++ b/editor/spellchecker/tests/test_bug1209414.html
@@ -37,37 +37,40 @@ var script;
  */
 
 var onSpellCheck =
   SpecialPowers.Cu.import(
     "resource://testing-common/AsyncSpellCheckTestHelper.jsm").onSpellCheck;
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
+  /* global browserElement */
+  /* eslint-env mozilla/frame-script */
   script = SpecialPowers.loadChromeScript(function() {
     var chromeWin = browserElement.ownerGlobal.docShell
                     .rootTreeItem.domWindow
                     .QueryInterface(Ci.nsIDOMChromeWindow);
     var contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
     contextMenu.addEventListener("popupshown",
                                  () => sendAsyncMessage("popupshown"));
 
+    // eslint-disable-next-line mozilla/use-services
     var dir = Cc["@mozilla.org/file/directory_service;1"]
                 .getService(Ci.nsIProperties)
                 .get("CurWorkD", Ci.nsIFile);
     dir.append("tests");
     dir.append("editor");
     dir.append("spellchecker");
     dir.append("tests");
 
     var hunspell = Cc["@mozilla.org/spellchecker/engine;1"]
                      .getService(Ci.mozISpellCheckingEngine);
 
     // Install de-DE dictionary.
-    de_DE = dir.clone();
+    let de_DE = dir.clone();
     de_DE.append("de-DE");
     hunspell.addDirectory(de_DE);
 
     addMessageListener("hidepopup", function() {
       var state = contextMenu.state;
 
       // Select Language from the menu.  Take a look at
       // toolkit/modules/InlineSpellChecker.jsm to see how the menu works.
@@ -96,16 +99,17 @@ SimpleTest.waitForFocus(function() {
     var inlineSpellChecker = editor_de.getInlineSpellChecker(true);
     var spellchecker = inlineSpellChecker.spellChecker;
     try {
       var currentDictonary = spellchecker.GetCurrentDictionary();
     } catch (e) {}
 
     // Check that the German dictionary is loaded and that the spell check has worked.
     is(currentDictonary, "de-DE", "expected de-DE");
+    // eslint-disable-next-line no-useless-concat
     is(getMisspelledWords(editor_de), "today" + "is" + "a" + "good" + "day", "some misspelled words expected: today is a good day");
 
     // Focus again, just to be sure that the context-click won't trigger another spell check.
     elem_de.focus();
 
     // Make sure all spell checking action is done before right-click to select the en-US dictionary.
     onSpellCheck(elem_de, function() {
       synthesizeMouse(elem_de, 2, 2, { type: "contextmenu", button: 2 }, window);
@@ -115,22 +119,24 @@ SimpleTest.waitForFocus(function() {
 
 function handlePopup() {
   var state = script.sendSyncMessage("hidepopup")[0][0];
   is(state, "open", "checking if popup is open");
 
   onSpellCheck(elem_de, function() {
     var inlineSpellChecker = editor_de.getInlineSpellChecker(true);
     var spellchecker = inlineSpellChecker.spellChecker;
+    let currentDictonary;
     try {
       currentDictonary = spellchecker.GetCurrentDictionary();
     } catch (e) {}
 
     // Check that the English dictionary is loaded and that the spell check has worked.
     is(currentDictonary, "en-US", "expected en-US");
+    // eslint-disable-next-line no-useless-concat
     is(getMisspelledWords(editor_de), "heute" + "ist" + "ein" + "guter", "some misspelled words expected: heute ist ein guter");
 
     // Remove the fake de_DE dictionary again.
     script.sendSyncMessage("destroy");
 
     // This will clear the content preferences and reset "spellchecker.dictionary".
     spellchecker.SetCurrentDictionary("");
     SimpleTest.finish();
--- a/editor/spellchecker/tests/test_bug1219928.html
+++ b/editor/spellchecker/tests/test_bug1219928.html
@@ -24,18 +24,19 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 /** Test for Bug 1219928 **/
 /* Very simple test to check that <style> blocks are skipped in the spell check */
 
 var spellchecker;
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
-  SpecialPowers.Cu.import(
-    "resource://testing-common/AsyncSpellCheckTestHelper.jsm", window);
+  var onSpellCheck =
+    SpecialPowers.Cu.import(
+      "resource://testing-common/AsyncSpellCheckTestHelper.jsm", null).onSpellCheck;
 
   var elem = document.getElementById("en-US");
   elem.focus();
 
   onSpellCheck(elem, function() {
     var Ci = SpecialPowers.Ci;
     var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
     var editor = editingSession.getEditorForWindow(window);
--- a/editor/spellchecker/tests/test_bug678842.html
+++ b/editor/spellchecker/tests/test_bug678842.html
@@ -7,17 +7,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 678842</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" href="/tests/SimpleTest/test.css">
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=678842">Mozilla Bug 678842</a>
 <p id="display"></p>
 <iframe id="content"></iframe>
-  
+
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 678842 **/
 SimpleTest.waitForExplicitFinish();
 var content = document.getElementById("content");
 // load a subframe containing an editor with a defined unknown lang. At first
@@ -25,30 +25,32 @@ var content = document.getElementById("c
 // dictionary. So, we can check, dictionary is correctly remembered between
 // loads.
 
 var firstLoad = true;
 var script;
 
 var loadListener = function(evt) {
   if (firstLoad) {
+    /* eslint-env mozilla/frame-script */
     script = SpecialPowers.loadChromeScript(function() {
+      // eslint-disable-next-line mozilla/use-services
       var dir = Cc["@mozilla.org/file/directory_service;1"]
                   .getService(Ci.nsIProperties)
                   .get("CurWorkD", Ci.nsIFile);
       dir.append("tests");
       dir.append("editor");
       dir.append("spellchecker");
       dir.append("tests");
 
       var hunspell = Cc["@mozilla.org/spellchecker/engine;1"]
                        .getService(Ci.mozISpellCheckingEngine);
 
       // Install en-GB dictionary.
-      en_GB = dir.clone();
+      let en_GB = dir.clone();
       en_GB.append("en-GB");
       hunspell.addDirectory(en_GB);
 
       addMessageListener("en_GB-exists", () => en_GB.exists());
       addMessageListener("destroy", () => hunspell.removeDirectory(en_GB));
     });
     is(script.sendSyncMessage("en_GB-exists")[0][0], true,
        "true expected (en-GB directory should exist)");
--- a/editor/spellchecker/tests/test_bug697981.html
+++ b/editor/spellchecker/tests/test_bug697981.html
@@ -30,17 +30,19 @@ var script;
 var onSpellCheck =
   SpecialPowers.Cu.import(
     "resource://testing-common/AsyncSpellCheckTestHelper.jsm")
                .onSpellCheck;
 
 /** Test for Bug 697981 **/
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
+  /* eslint-env mozilla/frame-script */
   script = SpecialPowers.loadChromeScript(function() {
+    // eslint-disable-next-line mozilla/use-services
     var dir = Cc["@mozilla.org/file/directory_service;1"]
                 .getService(Ci.nsIProperties)
                 .get("CurWorkD", Ci.nsIFile);
     dir.append("tests");
     dir.append("editor");
     dir.append("spellchecker");
     dir.append("tests");
 
@@ -85,16 +87,17 @@ function deFocus() {
 function enFocus() {
   var elem_en = document.getElementById("en-US");
   var editor_en = SpecialPowers.wrap(elem_en).editor;
   editor_en.setSpellcheckUserOverride(true);
   var inlineSpellChecker = editor_en.getInlineSpellChecker(true);
 
   onSpellCheck(elem_en, function() {
     var spellchecker = inlineSpellChecker.spellChecker;
+    let currentDictonary;
     try {
       currentDictonary = spellchecker.GetCurrentDictionary();
     } catch (e) {}
 
     // Check that the English dictionary is loaded and that the spell check has worked.
     is(currentDictonary, "en-US", "expected en-US");
     is(getMisspelledWords(editor_en), "Nogoodword", "one misspelled word expected: Nogoodword");
 
@@ -115,16 +118,17 @@ function enFocus() {
     onSpellCheck(elem_de, function() {
       spellchecker = inlineSpellChecker.spellChecker;
       try {
         currentDictonary = spellchecker.GetCurrentDictionary();
       } catch (e) {}
 
       // Check that the default English dictionary is loaded and that the spell check has worked.
       is(currentDictonary, "en-US", "expected en-US");
+      // eslint-disable-next-line no-useless-concat
       is(getMisspelledWords(editor_de), "heute" + "ist" + "ein" + "guter",
          "some misspelled words expected: heute ist ein guter");
 
       SimpleTest.finish();
     });
   });
 }
 
--- a/editor/spellchecker/tests/test_bug717433.html
+++ b/editor/spellchecker/tests/test_bug717433.html
@@ -27,17 +27,19 @@ var content = document.getElementById("c
 
 var firstLoad = true;
 var expected = "";
 var script;
 
 var loadListener = function(evt) {
 
   if (firstLoad) {
+    /* eslint-env mozilla/frame-script */
     script = SpecialPowers.loadChromeScript(function() {
+      // eslint-disable-next-line mozilla/use-services
       var dir = Cc["@mozilla.org/file/directory_service;1"]
                   .getService(Ci.nsIProperties)
                   .get("CurWorkD", Ci.nsIFile);
       dir.append("tests");
       dir.append("editor");
       dir.append("spellchecker");
       dir.append("tests");