Bug 1506042 - Enable ESLint for docshell/resources and docshell/test/chrome (manual fixes). r=smaug
authorMark Banner <standard8@mozilla.com>
Fri, 09 Nov 2018 10:51:37 +0000
changeset 445403 ea9a6719f0c7244a7d63316b1d0cb7dc41f9a0c3
parent 445402 8f6702639abc0d48d610facf3002a2a2dc1114f9
child 445404 130c60233efa84ffb5f6814ea709d9913ee6fbcc
push id35015
push userdluca@mozilla.com
push dateFri, 09 Nov 2018 17:45:20 +0000
treeherdermozilla-central@2f1158e5e0ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1506042
milestone65.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 1506042 - Enable ESLint for docshell/resources and docshell/test/chrome (manual fixes). r=smaug Depends on D11441 Differential Revision: https://phabricator.services.mozilla.com/D11442
.eslintignore
docshell/test/chrome/bug303267.html
docshell/test/chrome/docshell_helpers.js
docshell/test/chrome/test_bug909218.html
--- a/.eslintignore
+++ b/.eslintignore
@@ -9,19 +9,17 @@
 **/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/resources/**
 docshell/test/browser/**
-docshell/test/chrome/**
 docshell/test/iframesandbox/**
 docshell/test/mochitest/**
 extensions/cookie/**
 extensions/spellcheck/**
 extensions/universalchardet/**
 gfx/layers/**
 gfx/tests/browser/**
 gfx/tests/chrome/**
--- a/docshell/test/chrome/bug303267.html
+++ b/docshell/test/chrome/bug303267.html
@@ -3,21 +3,21 @@
   <title>
     bug303267.html
     </title>
   </head>
 <body onpageshow="showpageshowcount()">
 <script>
 var pageshowcount = 0;
 function showpageshowcount() {
-	pageshowcount++;
-	var div1 = document.getElementById("div1");
-	while (div1.firstChild) {
-		div1.firstChild.remove();
-	}
-	div1.appendChild(document.createTextNode(
-	  "pageshowcount: " + pageshowcount));
+  pageshowcount++;
+  var div1 = document.getElementById("div1");
+  while (div1.firstChild) {
+    div1.firstChild.remove();
+  }
+  div1.appendChild(document.createTextNode(
+    "pageshowcount: " + pageshowcount));
 }
 </script>
 <div id="div1">
 	</div>
 </body>
 </html>
--- a/docshell/test/chrome/docshell_helpers.js
+++ b/docshell/test/chrome/docshell_helpers.js
@@ -2,16 +2,20 @@
  * Import common SimpleTest methods so that they're usable in this window.
  */
 var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror", "todo",
   "todo_is", "todo_isnot" ];
 for (var name of imports) {
   window[name] = window.opener.wrappedJSObject[name];
 }
 ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
+ChromeUtils.import("resource://gre/modules/Services.jsm");
+
+// Some functions assume chrome-harness.js has been loaded.
+/* import-globals-from ../../../testing/mochitest/chrome-harness.js */
 
 /**
  * Define global constants and variables.
  */
 const NAV_NONE = 0;
 const NAV_BACK = 1;
 const NAV_FORWARD = 2;
 const NAV_URI = 3;
@@ -83,16 +87,17 @@ var gExtractedPath = null; // used to ca
  *                     callback is not notified if eventsToListenFor is [].
  *
  * There must be an expectedEvent object for each event of the types in
  * eventsToListenFor which is triggered by this navigation.  For example, if
  * eventsToListenFor = [ "pagehide", "pageshow" ], then expectedEvents
  * must contain an object for each pagehide and pageshow event which occurs as
  * a result of this navigation.
  */
+// eslint-disable-next-line complexity
 function doPageNavigation(params) {
   // Parse the parameters.
   let back = params.back ? params.back : false;
   let forward = params.forward ? params.forward : false;
   let reload = params.reload ? params.reload : false;
   let uri = params.uri ? params.uri : false;
   let eventsToListenFor = typeof(params.eventsToListenFor) != "undefined" ?
     params.eventsToListenFor : ["pageshow"];
@@ -335,32 +340,28 @@ function pageEventListener(event) {
 function finish() {
   // Work around bug 467960.
   var history = TestWindow.getBrowser().webNavigation.sessionHistory;
   history.legacySHistory.PurgeHistory(history.count);
 
   // If the test changed the value of max_total_viewers via a call to
   // enableBFCache(), then restore it now.
   if (typeof(gOrigMaxTotalViewers) != "undefined") {
-    var prefs = Cc["@mozilla.org/preferences-service;1"]
-                .getService(Ci.nsIPrefBranch);
-    prefs.setIntPref("browser.sessionhistory.max_total_viewers",
+    Services.prefs.setIntPref("browser.sessionhistory.max_total_viewers",
       gOrigMaxTotalViewers);
   }
 
   // Close the test window and signal the framework that the test is done.
   let opener = window.opener;
   let SimpleTest = opener.wrappedJSObject.SimpleTest;
 
   // Wait for the window to be closed before finishing the test
-  let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]
-	             .getService(Ci.nsIWindowWatcher);
-  ww.registerNotification(function(subject, topic, data) {
+  Services.ww.registerNotification(function observer(subject, topic, data) {
     if (topic == "domwindowclosed") {
-      ww.unregisterNotification(arguments.callee);
+      Services.ww.unregisterNotification(observer);
       SimpleTest.waitForFocus(SimpleTest.finish, opener);
     }
   });
 
   window.close();
 }
 
 /**
@@ -419,34 +420,31 @@ function waitForNextPaint(cb) {
  * Enable or disable the bfcache.
  *
  * Parameters:
  *
  *   enable: if true, set max_total_viewers to -1 (the default); if false, set
  *           to 0 (disabled), if a number, set it to that specific number
  */
 function enableBFCache(enable) {
-  var prefs = Cc["@mozilla.org/preferences-service;1"]
-              .getService(Ci.nsIPrefBranch);
-
   // If this is the first time the test called enableBFCache(),
   // store the original value of max_total_viewers, so it can
   // be restored at the end of the test.
   if (typeof(gOrigMaxTotalViewers) == "undefined") {
     gOrigMaxTotalViewers =
-      prefs.getIntPref("browser.sessionhistory.max_total_viewers");
+      Services.prefs.getIntPref("browser.sessionhistory.max_total_viewers");
   }
 
   if (typeof(enable) == "boolean") {
     if (enable)
-      prefs.setIntPref("browser.sessionhistory.max_total_viewers", -1);
+      Services.prefs.setIntPref("browser.sessionhistory.max_total_viewers", -1);
     else
-      prefs.setIntPref("browser.sessionhistory.max_total_viewers", 0);
+      Services.prefs.setIntPref("browser.sessionhistory.max_total_viewers", 0);
   } else if (typeof(enable) == "number") {
-    prefs.setIntPref("browser.sessionhistory.max_total_viewers", enable);
+    Services.prefs.setIntPref("browser.sessionhistory.max_total_viewers", enable);
   }
 }
 
 /*
  * get http root for local tests.  Use a single extractJarToTmp instead of
  * extracting for each test.
  * Returns a file://path if we have a .jar file
  */
--- a/docshell/test/chrome/test_bug909218.html
+++ b/docshell/test/chrome/test_bug909218.html
@@ -36,17 +36,17 @@ function test() {
   RequestWatcher.init(docShell, SimpleTest.finish);
   // Set the flags we care about, then load our test URL.
   docShell.defaultLoadFlags = TEST_FLAGS;
   iframe.setAttribute("src", TEST_URL);
 }
 
 // an nsIWebProgressListener that checks all requests made by the docShell
 // have the flags we expect.
-RequestWatcher = {
+var RequestWatcher = {
   init(docShell, callback) {
     this.callback = callback;
     this.docShell = docShell;
     docShell.
           QueryInterface(Ci.nsIInterfaceRequestor).
           getInterface(Ci.nsIWebProgress).
           addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST |
                                     Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);