diff --git a/.eslintignore b/.eslintignore index 0f7b1b3cd5a7..e76c0f642a3d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -175,9 +175,6 @@ services/fxaccounts/FxAccountsPairingChannel.js # Servo is imported. servo/ -# third party modules -testing/mochitest/tests/Harness_sanity/ - # Test files that we don't want to lint (preprocessed, minified etc) testing/marionette/atom.js testing/mozbase/mozprofile/tests/files/prefs_with_comments.js diff --git a/.eslintrc.js b/.eslintrc.js index 14fff1a902e9..2da3702da6bb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -32,6 +32,7 @@ const mochitestTestPaths = [ "**/test/mochitest/", "**/tests/mochitest/", "testing/mochitest/tests/SimpleTest/", + "testing/mochitest/tests/Harness_sanity/", ]; const chromeTestPaths = [ diff --git a/testing/mochitest/tests/Harness_sanity/SpecialPowersLoadChromeScript.js b/testing/mochitest/tests/Harness_sanity/SpecialPowersLoadChromeScript.js index 731081832980..f370f85cb50c 100644 --- a/testing/mochitest/tests/Harness_sanity/SpecialPowersLoadChromeScript.js +++ b/testing/mochitest/tests/Harness_sanity/SpecialPowersLoadChromeScript.js @@ -1,10 +1,13 @@ +/* eslint-env mozilla/frame-script */ +/* global assert */ + // Just receive 'foo' message and forward it back // as 'bar' message -addMessageListener("foo", function (message) { +addMessageListener("foo", function(message) { sendAsyncMessage("bar", message); }); -addMessageListener("valid-assert", function (message) { +addMessageListener("valid-assert", function(message) { assert.ok(true, "valid assertion"); assert.equal(1, 1, "another valid assertion"); sendAsyncMessage("valid-assert-done"); diff --git a/testing/mochitest/tests/Harness_sanity/importtesting_chromescript.js b/testing/mochitest/tests/Harness_sanity/importtesting_chromescript.js index 162c2c47fa92..77d1c0701dde 100644 --- a/testing/mochitest/tests/Harness_sanity/importtesting_chromescript.js +++ b/testing/mochitest/tests/Harness_sanity/importtesting_chromescript.js @@ -1,3 +1,5 @@ -addMessageListener("ImportTesting:IsModuleLoaded", function (msg) { +/* eslint-env mozilla/frame-script */ + +addMessageListener("ImportTesting:IsModuleLoaded", function(msg) { sendAsyncMessage("ImportTesting:IsModuleLoadedReply", Cu.isModuleLoaded(msg)); }); diff --git a/testing/mochitest/tests/Harness_sanity/specialPowers_framescript.js b/testing/mochitest/tests/Harness_sanity/specialPowers_framescript.js index e572fb6f36d9..314b3cdf1f29 100644 --- a/testing/mochitest/tests/Harness_sanity/specialPowers_framescript.js +++ b/testing/mochitest/tests/Harness_sanity/specialPowers_framescript.js @@ -1,13 +1,15 @@ -const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +/* eslint-env mozilla/frame-script */ + +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); var permChangedObs = { - observe: function(subject, topic, data) { - if (topic == 'perm-changed') { + observe(subject, topic, data) { + if (topic == "perm-changed") { var permission = subject.QueryInterface(Ci.nsIPermission); var msg = { op: data, type: permission.type }; - sendAsyncMessage('perm-changed', msg); + sendAsyncMessage("perm-changed", msg); } - } + }, }; -Services.obs.addObserver(permChangedObs, 'perm-changed'); +Services.obs.addObserver(permChangedObs, "perm-changed"); diff --git a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html index 989db4e5e3a9..2e602b4db0e0 100644 --- a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html +++ b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersExtension.html @@ -54,6 +54,7 @@ async function starttest(){ // Test an invalid pref var retVal = null; + // eslint-disable-next-line mozilla/use-default-preference-values try { retVal = SpecialPowers.getBoolPref('extensions.checkCompat0123456789'); } catch (ex) { @@ -71,7 +72,7 @@ async function starttest(){ SpecialPowers.removeChromeEventListener("TestEvent", testEventListener2, true); dispatchTestEvent(); is(eventCount, 1, "Shouldn't have got an event!"); - + // Test Complex Pref - TODO: Without chrome access, I don't know how you'd actually // set this preference since you have to create an XPCOM object. // Leaving untested for now. @@ -79,7 +80,7 @@ async function starttest(){ // Test a DOMWindowUtils method and property is(SpecialPowers.DOMWindowUtils.getClassName(window), "Proxy"); is(SpecialPowers.DOMWindowUtils.docCharsetIsForced, false); - + // QueryInterface and getPrivilegedProps tests is(SpecialPowers.can_QI(SpecialPowers), false); let doc = SpecialPowers.wrap(document); @@ -91,7 +92,7 @@ async function starttest(){ is(SpecialPowers.getPrivilegedProps(doc, "baseURIObject.fileName"), "test_SpecialPowersExtension.html", "Should have a fileName property now"); - + //try to run garbage collection SpecialPowers.gc(); diff --git a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersLoadChromeScript.html b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersLoadChromeScript.html index 4572b471f6ae..6a84464c899f 100644 --- a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersLoadChromeScript.html +++ b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersLoadChromeScript.html @@ -9,6 +9,9 @@
 
diff --git a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html
index 36c8280b684f..b2ed66601545 100644
--- a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html
+++ b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSandbox.html
@@ -71,15 +71,15 @@ add_task(async function() {
     },
     "SpecialPowers.spawn-subframe": () => {
       return SpecialPowers.spawn(frame, [subframeSrc], async src => {
-        let frame = this.content.document.createElement("iframe");
-        frame.src = src;
-        this.content.document.body.appendChild(frame);
+        let subFrame = this.content.document.createElement("iframe");
+        subFrame.src = src;
+        this.content.document.body.appendChild(subFrame);
 
         await new Promise(resolve => {
-          frame.addEventListener("load", resolve, { once: true });
+          subFrame.addEventListener("load", resolve, { once: true });
         });
 
-        await SpecialPowers.spawn(frame, [], () => {
+        await SpecialPowers.spawn(subFrame, [], () => {
           Assert.equal(1, 2, "Thing");
           Assert.equal(1, 1, "Hmm");
           Assert.ok(true, "Yay.");
diff --git a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html
index b385c01d55b6..851b9195610b 100644
--- a/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html
+++ b/testing/mochitest/tests/Harness_sanity/test_SpecialPowersSpawn.html
@@ -30,6 +30,7 @@
 
     is(result, "Hello there.", "Got correct element text from frame");
 
+    /* eslint-disable no-shadow */
     result = await SpecialPowers.spawn(frame, ["#hello"], selector => {
       return SpecialPowers.spawn(content.parent, [selector], selector => {
         let elem = content.document.querySelector(selector);
@@ -54,7 +55,7 @@
 
     is(result, "Hello there.", "Got correct element text from browsing context");
 
-    let line = 58; // Keep this in sync with the line number where the callback function starts.
+    let line = 59; // Keep this in sync with the line number where the callback function starts.
     let callback = () => {
       let e = new Error("Hello.");
       return { filename: e.fileName, lineNumber: e.lineNumber };
diff --git a/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html b/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html
index a4894798e27b..f2436ab077b5 100644
--- a/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html
+++ b/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html
@@ -50,7 +50,7 @@ function starttest() {
       $("testMouseEvent").addEventListener("click", doCheck, {once: true});
       sendMouseEvent({type:'click'}, "testMouseEvent");
       is(check, true, 'sendMouseEvent should dispatch click event');
-      
+
       check = false;
       $("testKeyEvent").addEventListener("keypress", doCheck, {once: true});
       $("testKeyEvent").focus();
@@ -58,12 +58,12 @@ function starttest() {
       is($("testKeyEvent").value, "x", "sendChar should work");
       is(check, true, "sendChar should dispatch keyPress");
       $("testKeyEvent").value = "";
-    
+
       $("testStrEvent").focus();
       sendString("string");
       is($("testStrEvent").value, "string", "sendString should work");
       $("testStrEvent").value = "";
-    
+
       var keydown = false;
       var keypress = false;
       $("testKeyEvent").focus();
@@ -76,7 +76,7 @@ function starttest() {
       } else {
         ok(keypress, "sendKey should dispatch keyPress even for non-printable key");
       }
-    
+
       /* test synthesizeMouse* */
       //focus trick enables us to run this in iframes
       $("radioTarget1").addEventListener('focus', function (aEvent) {
@@ -97,22 +97,22 @@ function starttest() {
         $("textBoxA").addEventListener("click", function() { check = true; });
         synthesizeMouseAtCenter($("textBoxA"), {});
         is(check, true, 'synthesizeMouse should dispatch mouse event');
-    
+
         check = false;
         synthesizeMouseExpectEvent($("textBoxA"), 1, 1, {}, $("textBoxA"), "click", "synthesizeMouseExpectEvent should fire click event");
         is(check, true, 'synthesizeMouse should dispatch mouse event');
       }, {once: true});
       $("textBoxA").focus();
-    
+
       /**
-       * TODO: testing synthesizeWheel requires a setTimeout 
+       * TODO: testing synthesizeWheel requires a setTimeout
        * since there is delay between the scroll event and a check, so for now just test
        * that we can successfully call it to avoid having setTimeout vary the runtime metric.
        * Testing of this method is currently done here:
        * toolkit/content/tests/chrome/test_mousescroll.xul
        */
       synthesizeWheel($("scrollB"), 5, 5, {'deltaY': 10.0, deltaMode: WheelEvent.DOM_DELTA_LINE});
-    
+
       /* test synthesizeKey* */
       check = false;
       $("testKeyEvent").addEventListener("keypress", doCheck, {once:true});
@@ -150,18 +150,18 @@ function starttest() {
                         { arg: "~", code: "Backquote", keyCode: KeyboardEvent.DOM_VK_BACK_QUOTE },
                         { arg: "<", code: "Comma", keyCode: KeyboardEvent.DOM_VK_COMMA },
                         { arg: ".", code: "Period", keyCode: KeyboardEvent.DOM_VK_PERIOD }]) {
-        let keydown, keyup;
+        let testKeydown, keyup;
         $("testKeyEvent").focus();
-        $("testKeyEvent").addEventListener("keydown", (e) => { keydown = e; }, {once: true});
+        $("testKeyEvent").addEventListener("keydown", (e) => { testKeydown = e; }, {once: true});
         $("testKeyEvent").addEventListener("keyup", (e) => { keyup = e; }, {once: true});
         synthesizeKey(test.arg);
-        is(keydown.code, test.code, `Synthesizing "${test.arg}" should set code value of "keydown" to "${test.code}"`);
-        is(keydown.keyCode, test.keyCode, `Synthesizing "${test.arg}" should set keyCode value of "keydown" to "${test.keyCode}"`);
+        is(testKeydown.code, test.code, `Synthesizing "${test.arg}" should set code value of "keydown" to "${test.code}"`);
+        is(testKeydown.keyCode, test.keyCode, `Synthesizing "${test.arg}" should set keyCode value of "keydown" to "${test.keyCode}"`);
         is(keyup.code, test.code, `Synthesizing "${test.arg}" key should set code value of "keyup" to "${test.code}"`);
         is(keyup.keyCode, test.keyCode, `Synthesizing "${test.arg}" key should set keyCode value of "keyup" to "${test.keyCode}"`);
         $("testKeyEvent").value = "";
       }
-    
+
       /* test synthesizeComposition */
       var description = "";
       var keydownEvent = null;
@@ -272,7 +272,7 @@ function starttest() {
       is(querySelectedText.text, "",
          "query selected text event returns wrong selected text");
       $("textBoxB").value = "";
-    
+
       querySelectedText = synthesizeQuerySelectedText();
       ok(querySelectedText, "query selected text event result is null");
       ok(querySelectedText.succeeded, "query selected text event failed");
diff --git a/testing/mochitest/tests/Harness_sanity/test_sanityException.html b/testing/mochitest/tests/Harness_sanity/test_sanityException.html
index c0e4368f0a5e..463f51d80eb4 100644
--- a/testing/mochitest/tests/Harness_sanity/test_sanityException.html
+++ b/testing/mochitest/tests/Harness_sanity/test_sanityException.html
@@ -9,6 +9,7 @@
 
 
diff --git a/testing/mochitest/tests/Harness_sanity/test_sanityException2.html b/testing/mochitest/tests/Harness_sanity/test_sanityException2.html
index 33249afe520b..1136b7391642 100644
--- a/testing/mochitest/tests/Harness_sanity/test_sanityException2.html
+++ b/testing/mochitest/tests/Harness_sanity/test_sanityException2.html
@@ -11,6 +11,7 @@ SimpleTest.waitForExplicitFinish();
 ok(true, "a call to ok");
 SimpleTest.executeSoon(function() {
   SimpleTest.expectUncaughtException();
+  // eslint-disable-next-line no-throw-literal
   throw "an uncaught exception";
 });
 SimpleTest.executeSoon(function() {
diff --git a/testing/mochitest/tests/Harness_sanity/test_sanitySimpletest.html b/testing/mochitest/tests/Harness_sanity/test_sanitySimpletest.html
index bea579e4c7d0..2b289f1387f5 100644
--- a/testing/mochitest/tests/Harness_sanity/test_sanitySimpletest.html
+++ b/testing/mochitest/tests/Harness_sanity/test_sanitySimpletest.html
@@ -84,6 +84,7 @@ function starttest() {
             //expect and throw exception here. Otherwise, any code that follows the throw call will never be executed
             SimpleTest.expectUncaughtException();
             //make sure we catch this error
+            // eslint-disable-next-line no-throw-literal
             throw "i am an uncaught exception"
           }
         );
diff --git a/testing/mochitest/tests/Harness_sanity/test_sanity_cleanup2.html b/testing/mochitest/tests/Harness_sanity/test_sanity_cleanup2.html
index fe755aedc999..b0b75238198b 100644
--- a/testing/mochitest/tests/Harness_sanity/test_sanity_cleanup2.html
+++ b/testing/mochitest/tests/Harness_sanity/test_sanity_cleanup2.html
@@ -9,7 +9,7 @@