Bug 1532941 - Enable ESLint for uriloader (manual changes). r=Standard8,qdot
☠☠ backed out by 14c61ee043c8 ☠ ☠
authorSyeda Asra Arshia Qadri <asra.qadri@gmail.com>
Wed, 13 Mar 2019 20:50:11 +0000
changeset 521853 bf03fb29b472
parent 521852 c5190e74039c
child 521854 8014816b11ed
push id10870
push usernbeleuzu@mozilla.com
push dateFri, 15 Mar 2019 20:00:07 +0000
treeherdermozilla-beta@c594aee5b7a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, qdot
bugs1532941
milestone67.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 1532941 - Enable ESLint for uriloader (manual changes). r=Standard8,qdot Differential Revision: https://phabricator.services.mozilla.com/D22478
.eslintignore
uriloader/exthandler/tests/mochitest/.eslintrc.js
uriloader/exthandler/tests/mochitest/browser_auto_close_window.js
uriloader/exthandler/tests/mochitest/handlerApps.js
uriloader/exthandler/tests/mochitest/unsafeBidi_chromeScript.js
uriloader/exthandler/tests/unit/test_badMIMEType.js
uriloader/exthandler/tests/unit/test_getTypeFromExtension_ext_to_type_mapping.js
uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
uriloader/exthandler/tests/unit/test_handlerService.js
uriloader/exthandler/tests/unit/test_punycodeURIs.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -22,18 +22,16 @@ extensions/spellcheck/**
 extensions/universalchardet/**
 image/**
 layout/**
 netwerk/cookie/test/browser/**
 netwerk/test/browser/**
 netwerk/test/mochitests/**
 netwerk/test/unit*/**
 tools/update-packaging/**
-uriloader/exthandler/**
-uriloader/exthandler/tests/mochitest/**
 xpfe/**
 
 # We currently have no js files in these directories, so we ignore them by
 # default to aid ESLint's performance.
 build/**
 config/**
 db/**
 embedding/**
new file mode 100644
--- /dev/null
+++ b/uriloader/exthandler/tests/mochitest/.eslintrc.js
@@ -0,0 +1,8 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "plugin:mozilla/browser-test",
+    "plugin:mozilla/mochitest-test",
+  ]
+};
--- a/uriloader/exthandler/tests/mochitest/browser_auto_close_window.js
+++ b/uriloader/exthandler/tests/mochitest/browser_auto_close_window.js
@@ -55,17 +55,16 @@ add_task(async function simple_navigatio
     is(windowContext, browser.ownerGlobal, "got the right windowContext");
   });
 });
 
 // Given a browser pointing to download_page.html, clicks on the link that
 // opens with target="_blank" (i.e. a new tab) and ensures that we
 // automatically open and close that tab.
 async function testNewTab(browser) {
-  let targetURL = browser.currentURI.spec;
   let dialogAppeared = promiseHelperAppDialog();
   let tabOpened = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen").then((event) => {
     return [ event.target, BrowserTestUtils.waitForTabClosing(event.target) ];
   });
 
   await BrowserTestUtils.synthesizeMouseAtCenter("#target_blank", {}, browser);
 
   let windowContext = await dialogAppeared;
--- a/uriloader/exthandler/tests/mochitest/handlerApps.js
+++ b/uriloader/exthandler/tests/mochitest/handlerApps.js
@@ -12,18 +12,17 @@ function test() {
   var webHandler = Cc["@mozilla.org/uriloader/web-handler-app;1"].
     createInstance(SpecialPowers.Ci.nsIWebHandlerApp);
   webHandler.name = "Test Web Handler App";
   webHandler.uriTemplate =
       "https://example.com/tests/uriloader/exthandler/tests/mochitest/" +
       "handlerApp.xhtml?uri=%s";
 
   // set up the uri to test with
-  var ioService = Cc["@mozilla.org/network/io-service;1"].
-    getService(SpecialPowers.Ci.nsIIOService);
+  var ioService = Services.io;
   var uri = ioService.newURI(testURI);
 
   // create a window, and launch the handler in it
   var newWindow = window.open("", "handlerWindow", "height=300,width=300");
   var windowContext = SpecialPowers.wrap(newWindow).docShell;
 
   webHandler.launchWithURI(uri, windowContext);
 
@@ -38,18 +37,17 @@ function test() {
   ok(true, "webHandler launchWithURI (new window/tab) test started");
 
   // set up the local handler object
   var localHandler = Cc["@mozilla.org/uriloader/local-handler-app;1"].
     createInstance(SpecialPowers.Ci.nsILocalHandlerApp);
   localHandler.name = "Test Local Handler App";
 
   // get a local app that we know will be there and do something sane
-  var osString = Cc["@mozilla.org/xre/app-info;1"].
-                 getService(SpecialPowers.Ci.nsIXULRuntime).OS;
+  var osString = Services.appinfo.OS;
 
   var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
                getService(SpecialPowers.Ci.nsIDirectoryServiceProvider);
   if (osString == "WINNT") {
     var windowsDir = dirSvc.getFile("WinD", {});
     var exe = windowsDir.clone().QueryInterface(SpecialPowers.Ci.nsIFile);
     exe.appendRelativePath("SYSTEM32\\HOSTNAME.EXE");
   } else if (osString == "Darwin") {
--- a/uriloader/exthandler/tests/mochitest/unsafeBidi_chromeScript.js
+++ b/uriloader/exthandler/tests/mochitest/unsafeBidi_chromeScript.js
@@ -1,17 +1,17 @@
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const HELPERAPP_DIALOG_CONTRACT = "@mozilla.org/helperapplauncherdialog;1";
 const HELPERAPP_DIALOG_CID =
   Components.ID(Cc[HELPERAPP_DIALOG_CONTRACT].number);
 
 const FAKE_CID = Cc["@mozilla.org/uuid-generator;1"].
                    getService(Ci.nsIUUIDGenerator).generateUUID();
-
+/* eslint-env mozilla/frame-script */
 function HelperAppLauncherDialog() {}
 HelperAppLauncherDialog.prototype = {
   show(aLauncher, aWindowContext, aReason) {
     sendAsyncMessage("suggestedFileName", aLauncher.suggestedFileName);
   },
   QueryInterface: ChromeUtils.generateQI([Ci.nsIHelperAppLauncherDialog]),
 };
 
--- a/uriloader/exthandler/tests/unit/test_badMIMEType.js
+++ b/uriloader/exthandler/tests/unit/test_badMIMEType.js
@@ -6,24 +6,22 @@
 function run_test() {
   // "text/plain" has an 0xFF character appended to it.  This means it's an
   // invalid string, which is tricky to enter using a text editor (I used
   // emacs' hexl-mode).  It also means an ordinary text editor might drop it
   // or convert it to something that *is* valid (in UTF8).  So we measure
   // its length to make sure this hasn't happened.
   var badMimeType = "text/plainÿ";
   Assert.equal(badMimeType.length, 11);
-
   try {
-    var type = Cc["@mozilla.org/mime;1"].
-               getService(Ci.nsIMIMEService).
-               getFromTypeAndExtension(badMimeType, "txt");
+    Cc["@mozilla.org/mime;1"].
+      getService(Ci.nsIMIMEService).
+      getFromTypeAndExtension(badMimeType, "txt");
   } catch (e) {
     if (!(e instanceof Ci.nsIException) ||
         e.result != Cr.NS_ERROR_NOT_AVAILABLE) {
       throw e;
     }
     // This is an expected exception, thrown if the type can't be determined
-  } finally {
   }
   // Not crashing is good enough
   Assert.equal(true, true);
 }
--- a/uriloader/exthandler/tests/unit/test_getTypeFromExtension_ext_to_type_mapping.js
+++ b/uriloader/exthandler/tests/unit/test_getTypeFromExtension_ext_to_type_mapping.js
@@ -9,18 +9,17 @@
  * "ext-to-type-mapping" category if the provided extension is not lowercase.
  */
 function run_test() {
   // --- Common services ---
 
   const mimeService = Cc["@mozilla.org/mime;1"].
                       getService(Ci.nsIMIMEService);
 
-  const categoryManager = Cc["@mozilla.org/categorymanager;1"].
-                          getService(Ci.nsICategoryManager);
+  const categoryManager = Services.catMan;
 
   // --- Test procedure ---
 
   const kTestExtension          = "testextension";
   const kTestExtensionMixedCase = "testExtensIon";
   const kTestMimeType           = "application/x-testextension";
 
   // Ensure that the test extension is not initially recognized by the operating
--- a/uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
+++ b/uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
@@ -116,24 +116,24 @@ function run_test() {
   var componentRegistrar = Components.manager.
                            QueryInterface(Ci.nsIComponentRegistrar);
 
   var originalWindowsRegKeyCID;
   var mockWindowsRegKeyFactory;
 
   const kMockCID = Components.ID("{9b23dfe9-296b-4740-ba1c-d39c9a16e55e}");
   const kWindowsRegKeyContractID = "@mozilla.org/windows-registry-key;1";
-  const kWindowsRegKeyClassName = "nsWindowsRegKey";
 
   function registerMockWindowsRegKeyFactory() {
     mockWindowsRegKeyFactory = {
       createInstance(aOuter, aIid) {
         if (aOuter != null)
           throw Cr.NS_ERROR_NO_AGGREGATION;
-
+        // XXX Bug 1533719 - originalWindowsRegKeyFactory is undefined.
+        // eslint-disable-next-line no-undef
         var innerKey = originalWindowsRegKeyFactory.createInstance(null, aIid);
         var key = new MockWindowsRegKey(innerKey);
 
         return key.QueryInterface(aIid);
       },
     };
 
     // Preserve the original factory
@@ -166,19 +166,19 @@ function run_test() {
 
   // --- Test procedure ---
 
   // Activate the override of the ".txt" file association data in the registry
   registerMockWindowsRegKeyFactory();
   try {
     // Try and get the MIME type associated with the extension. If this
     // operation does not throw an unexpected exception, the test succeeds.
-    var type = Cc["@mozilla.org/mime;1"].
-               getService(Ci.nsIMIMEService).
-               getTypeFromExtension(".txt");
+    Cc["@mozilla.org/mime;1"].
+      getService(Ci.nsIMIMEService).
+      getTypeFromExtension(".txt");
   } catch (e) {
     if (!(e instanceof Ci.nsIException) ||
         e.result != Cr.NS_ERROR_NOT_AVAILABLE) {
       throw e;
     }
     // This is an expected exception, thrown if the type can't be determined
   } finally {
     // Ensure we restore the original factory when the test is finished
--- a/uriloader/exthandler/tests/unit/test_handlerService.js
+++ b/uriloader/exthandler/tests/unit/test_handlerService.js
@@ -10,21 +10,17 @@ function run_test() {
                      getService(Ci.nsIHandlerService);
 
   const mimeSvc = Cc["@mozilla.org/mime;1"].
                   getService(Ci.nsIMIMEService);
 
   const protoSvc = Cc["@mozilla.org/uriloader/external-protocol-service;1"].
                    getService(Ci.nsIExternalProtocolService);
 
-  const prefSvc = Cc["@mozilla.org/preferences-service;1"].
-                  getService(Ci.nsIPrefService);
-
-  const ioService = Cc["@mozilla.org/network/io-service;1"].
-                    getService(Ci.nsIIOService);
+  const prefSvc = Services.prefs;
 
   const env = Cc["@mozilla.org/process/environment;1"].
               getService(Ci.nsIEnvironment);
 
   const rootPrefBranch = prefSvc.getBranch("");
 
   let noMailto = false;
   if (mozinfo.os == "win") {
@@ -238,20 +234,19 @@ function run_test() {
     handlerTypes.push("irc");
     handlerTypes.push("ircs");
   }
   for (let handler of handlerSvc.enumerate()) {
     Assert.notEqual(handlerTypes.indexOf(handler.type), -1);
     handlerTypes.splice(handlerTypes.indexOf(handler.type), 1);
   }
   Assert.equal(handlerTypes.length, 0);
-
   // Make sure the handler service's remove method removes a handler record.
   handlerSvc.remove(handlerInfo2);
-  handlers = handlerSvc.enumerate();
+  let handlers = handlerSvc.enumerate();
   while (handlers.hasMoreElements())
     Assert.notEqual(handlers.getNext().QueryInterface(Ci.nsIHandlerInfo).type,
                     handlerInfo2.type);
 
   // Make sure we can store and retrieve a handler info object with no preferred
   // handler.
   var noPreferredHandlerInfo =
     mimeSvc.getFromTypeAndExtension("nonexistent/no-preferred-handler", null);
--- a/uriloader/exthandler/tests/unit/test_punycodeURIs.js
+++ b/uriloader/exthandler/tests/unit/test_punycodeURIs.js
@@ -63,19 +63,17 @@ function checkFile() {
 
 function run_test() {
   if (mozinfo.os == "mac") {
     dump("INFO | test_punycodeURIs.js | Skipping test on mac, bug 599475");
     return;
   }
 
   // set up the uri to test with
-  var ioService =
-    Cc["@mozilla.org/network/io-service;1"]
-      .getService(Ci.nsIIOService);
+  var ioService = Services.io;
 
   // set up the local handler object
   var localHandler =
     Cc["@mozilla.org/uriloader/local-handler-app;1"]
       .createInstance(Ci.nsILocalHandlerApp);
   localHandler.name = "Test Local Handler App";
 
   // WriteArgument will just dump its arguments to a file for us.