Bug 1508983 - Enable ESLint for dom/base/test/chrome/ (manual changes) r=Standard8,smaug
authormordax <contact@mordax.io>
Wed, 12 Dec 2018 14:56:54 +0000
changeset 510299 61192787a882e30a7c17c3e5b1a7768ee14597b6
parent 510298 002907f3b577b9ec1f339c85896f1d1d2983ab06
child 510300 dd6e480be25351f9e291575cb1505a297b60f506
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, smaug
bugs1508983
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1508983 - Enable ESLint for dom/base/test/chrome/ (manual changes) r=Standard8,smaug Differential Revision: https://phabricator.services.mozilla.com/D13129
.eslintignore
dom/base/test/chrome/bug418986-1.js
dom/base/test/chrome/cpows_child.js
dom/base/test/chrome/custom_element_ep.js
dom/base/test/chrome/test_bug1339722.html
dom/base/test/chrome/test_bug682305.html
dom/base/test/chrome/test_bug914381.html
--- a/.eslintignore
+++ b/.eslintignore
@@ -164,18 +164,22 @@ devtools/server/tests/unit/sourcemapped.
 
 # devtools specific format test file
 devtools/server/tests/unit/xpcshell_debugging_script.js
 
 # dom/ exclusions
 dom/abort/**
 dom/animation/**
 dom/asmjscache/**
-dom/base/**
 dom/battery/**
+dom/base/*.*
+dom/base/test/*.*
+dom/base/test/unit/test_serializers_entities*.js
+dom/base/test/unit_ipc/**
+dom/base/test/jsmodules/**
 dom/bindings/**
 dom/broadcastchannel/**
 dom/browser-element/**
 dom/cache/test/mochitest/**
 dom/cache/test/xpcshell/**
 dom/canvas/**
 dom/console/**
 dom/crypto/**
--- a/dom/base/test/chrome/bug418986-1.js
+++ b/dom/base/test/chrome/bug418986-1.js
@@ -1,14 +1,14 @@
+/* globals chromeWindow */
 // The main test function.
 var test = function(isContent) {
   SimpleTest.waitForExplicitFinish();
 
-	SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
-																		  true]]});
+  SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal", true]]});
 
   let { ww } = SpecialPowers.Services;
   window.chromeWindow = ww.activeWindow;
 
   // The pairs of values expected to be the same when
   // fingerprinting resistance is enabled.
   let pairs = [
     ["screenX", 0],
@@ -28,16 +28,17 @@ var test = function(isContent) {
     ["screen.orientation.type", "'landscape-primary'"],
     ["screen.orientation.angle", 0],
     ["screen.mozOrientation", "'landscape-primary'"],
     ["devicePixelRatio", 1],
   ];
 
   // checkPair: tests if members of pair [a, b] are equal when evaluated.
   let checkPair = function(a, b) {
+    // eslint-disable-next-line no-eval
     is(eval(a), eval(b), a + " should be equal to " + b);
   };
 
   // Returns generator object that iterates through pref values.
   let prefVals = (function* () { yield false; yield true; })();
 
   // The main test function, runs until all pref values are exhausted.
   let nextTest = function() {
--- a/dom/base/test/chrome/cpows_child.js
+++ b/dom/base/test/chrome/cpows_child.js
@@ -1,11 +1,13 @@
+/* eslint-env mozilla/frame-script */
 dump("loaded child cpow test\n");
 
 Cu.importGlobalProperties(["XMLHttpRequest"]);
+var is_remote;
 
 (function start() {
   [is_remote] = sendRpcMessage("cpows:is_remote");
 
   var tests = [
     parent_test,
     error_reporting_test,
     dom_test,
@@ -170,27 +172,26 @@ function compartment_test(finish) {
     return;
   }
 
   let sb = Cu.Sandbox("http://www.example.com", { wantGlobalProperties: ["XMLHttpRequest"] });
   sb.eval("function getUnprivilegedObject() { var xhr = new XMLHttpRequest(); xhr.expando = 42; return xhr; }");
   function testParentObject(obj) {
     let results = [];
     function is(a, b, msg) { results.push({ result: a === b ? "PASS" : "FAIL", message: msg }); }
-    function ok(x, msg) { results.push({ result: x ? "PASS" : "FAIL", message: msg }); }
-
+    function ok1(x, msg) { results.push({ result: x ? "PASS" : "FAIL", message: msg }); }
     let cpowLocation = Cu.getRealmLocation(obj);
-    ok(/shared JSM global/.test(cpowLocation),
+    ok1(/shared JSM global/.test(cpowLocation),
        "child->parent CPOWs should live in the privileged junk scope: " + cpowLocation);
     is(obj(), 42, "child->parent CPOW is invokable");
     try {
       obj.expando;
-      ok(false, "child->parent CPOW cannot access properties");
+      ok1(false, "child->parent CPOW cannot access properties");
     } catch (e) {
-      ok(true, "child->parent CPOW cannot access properties");
+      ok1(true, "child->parent CPOW cannot access properties");
     }
 
     return results;
   }
   sendRpcMessage("cpows:compartment_test", {}, { getUnprivilegedObject: sb.getUnprivilegedObject,
                                                  testParentObject });
   finish();
 }
@@ -311,17 +312,17 @@ function cancel_test2(finish) {
       ok(req.status == 200, "XHR succeeded");
       fin = true;
     };
 
     req.onload = reqListener;
     req.open("get", "http://example.com", false);
     req.send(null);
 
-    ok(fin == true, "XHR happened");
+    ok(fin === true, "XHR happened");
 
     fin1 = true;
     if (fin1 && fin2) finish();
   }
 
   sendAsyncMessage("cpows:cancel_test2", null, {f});
   addMessageListener("cpows:cancel_test2_done", msg => {
     fin2 = true;
--- a/dom/base/test/chrome/custom_element_ep.js
+++ b/dom/base/test/chrome/custom_element_ep.js
@@ -1,8 +1,9 @@
+/* globals finishTest */
 class XFoo extends HTMLElement {
   constructor() {
     super();
     this.magicNumber = 42;
   }
 
   connectedCallback() {
     finishTest(this.magicNumber === 42);
--- a/dom/base/test/chrome/test_bug1339722.html
+++ b/dom/base/test/chrome/test_bug1339722.html
@@ -18,40 +18,40 @@ https://bugzilla.mozilla.org/show_bug.cg
    * 3. In the event handler, delete the iframe so that the frameloader would be
    *    destoryed in the middle of ReallyStartLoading.
    * 4. Verify that it doesn't crash.
   **/
 
   ChromeUtils.import("resource://gre/modules/Services.jsm");
 
   const TOPIC = "http-on-useragent-request";
+  let win;
   Services.obs.addObserver({
     observe(subject, topic, data) {
       info("Got " + topic);
       Services.obs.removeObserver(this, TOPIC);
 
       // Query window proxy so it triggers DOMWindowCreated.
       let channel = subject.QueryInterface(Ci.nsIHttpChannel);
-      let win = channel.notificationCallbacks.getInterface(Ci.mozIDOMWindowProxy);
+      win = channel.notificationCallbacks.getInterface(Ci.mozIDOMWindowProxy);
     },
   }, TOPIC);
 
   let docShell = SpecialPowers.wrap(window).docShell;
   docShell.chromeEventHandler.addEventListener("DOMWindowCreated", function handler(e) {
-    docShell.chromeEventHandler.removeEventListener("DOMWindowCreated", handler);
     let iframe = document.getElementById("testFrame");
     is(e.target, iframe.contentDocument, "verify event target");
 
     // Remove the iframe to cause frameloader destroy.
     iframe.remove();
     setTimeout($ => {
       ok(!document.getElementById("testFrame"), "verify iframe removed");
       SimpleTest.finish();
     }, 0);
-  });
+  }, {once: true});
 
   SimpleTest.waitForExplicitFinish();
   </script>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1339722">Mozilla Bug 1339722</a>
 <p id="display"></p>
 <div id="content" style="display: none"></div>
--- a/dom/base/test/chrome/test_bug682305.html
+++ b/dom/base/test/chrome/test_bug682305.html
@@ -22,26 +22,25 @@ SimpleTest.waitForExplicitFinish();
 
 /*
  * Register a custom nsIProtocolHandler service
  * in order to be able to implement *and use* an
  * nsIChannel component written in Javascript.
  */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-var ios = Cc["@mozilla.org/network/io-service;1"]
-            .getService(Ci.nsIIOService);
+
 var contentSecManager = Cc["@mozilla.org/contentsecuritymanager;1"]
                           .getService(Ci.nsIContentSecurityManager);
 
 var PROTOCOL_SCHEME = "jsproto";
 
 
 function CustomChannel(uri, loadInfo) {
-	this.URI = this.originalURI = uri;
+  this.URI = this.originalURI = uri;
   this.loadInfo = loadInfo;
 }
 CustomChannel.prototype = {
   URI: null,
   originalURI: null,
   loadInfo: null,
   contentCharset: "utf-8",
   contentLength: 0,
@@ -118,17 +117,17 @@ CustomProtocol.prototype = {
              .createInstance(Ci.nsIURIMutator)
              .setSpec(spec)
              .finalize();
   },
   newChannel2: function newChannel2(URI, loadInfo) {
     return new CustomChannel(URI, loadInfo);
   },
   newChannel: function newChannel(URI) {
-    return newChannel2(URI);
+    return this.newChannel2(URI);
   },
   QueryInterface: ChromeUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIProtocolHandler]),
 };
 
 var gFactory = {
   register() {
     var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
 
--- a/dom/base/test/chrome/test_bug914381.html
+++ b/dom/base/test/chrome/test_bug914381.html
@@ -11,25 +11,25 @@ https://bugzilla.mozilla.org/show_bug.cg
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=914381">Mozilla Bug 914381</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 <script type="application/javascript">
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function createFileWithData(fileData) {
-  var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
-  var testFile = dirSvc.get("ProfD", Ci.nsIFile);
+  var testFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
   testFile.append("testBug914381");
 
   var outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
   outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
-                 0666, 0);
+                 0o666, 0);
   outStream.write(fileData, fileData.length);
   outStream.close();
 
   return testFile;
 }
 
 /** Test for Bug 914381. File's created in JS using an nsIFile should allow mozGetFullPathInternal calls to succeed **/
 var file = createFileWithData("Test bug 914381");