Bug 1501621 - Enable ESLint for netwerk/dns/ and netwerk/protocol/ (manual changes) r=dragana,Standard8
authorMichael Kohler <me@michaelkohler.info>
Fri, 02 Nov 2018 10:38:14 +0000
changeset 444079 a140c44db41d303d1ac2a8a48ce5f90386f2a041
parent 444078 e9f6807ef4a022bc278fe792a12de698e73f8fc7
child 444080 8cdaa33486f47c268f14568896966416eb25d636
push id34981
push useraciure@mozilla.com
push dateFri, 02 Nov 2018 16:43:47 +0000
treeherdermozilla-central@9f6501baf1d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdragana, Standard8
bugs1501621
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 1501621 - Enable ESLint for netwerk/dns/ and netwerk/protocol/ (manual changes) r=dragana,Standard8 Depends on D10590 Differential Revision: https://phabricator.services.mozilla.com/D10592
.eslintignore
netwerk/dns/mdns/libmdns/MulticastDNSAndroid.jsm
netwerk/dns/mdns/libmdns/fallback/DNSResourceRecord.jsm
netwerk/dns/mdns/libmdns/fallback/MulticastDNS.jsm
netwerk/protocol/ftp/test/frametest/menu.html
netwerk/protocol/http/UserAgentOverrides.jsm
netwerk/protocol/http/UserAgentUpdates.jsm
netwerk/protocol/http/WellKnownOpportunisticUtils.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -22,18 +22,16 @@ gfx/layers/**
 gfx/tests/browser/**
 gfx/tests/chrome/**
 gfx/tests/mochitest/**
 image/**
 layout/**
 memory/replace/dmd/test/**
 modules/**
 netwerk/cookie/test/browser/**
-netwerk/protocol/**
-netwerk/dns/**
 netwerk/test/browser/**
 netwerk/test/httpserver/**
 netwerk/test/mochitests/**
 netwerk/test/unit*/**
 # Bug 1501445.
 netwerk/wifi/tests/wifi_access_point_test.html
 parser/**
 tools/update-packaging/**
--- a/netwerk/dns/mdns/libmdns/MulticastDNSAndroid.jsm
+++ b/netwerk/dns/mdns/libmdns/MulticastDNSAndroid.jsm
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["MulticastDNS"];
 
 ChromeUtils.import("resource://gre/modules/Messaging.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 const DEBUG = false;
 
 var log = function(s) {};
 if (DEBUG) {
   log = ChromeUtils.import("resource://gre/modules/AndroidLog.jsm", {})
           .AndroidLog.d.bind(null, "MulticastDNS");
 }
--- a/netwerk/dns/mdns/libmdns/fallback/DNSResourceRecord.jsm
+++ b/netwerk/dns/mdns/libmdns/fallback/DNSResourceRecord.jsm
@@ -3,26 +3,21 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 /* jshint esnext: true, moz: true */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["DNSResourceRecord"];
 
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/DataReader.jsm");
 ChromeUtils.import("resource://gre/modules/DataWriter.jsm");
 ChromeUtils.import("resource://gre/modules/DNSRecord.jsm");
 ChromeUtils.import("resource://gre/modules/DNSTypes.jsm");
 
-function debug(msg) {
-  Services.console.logStringMessage("MulticastDNS: " + msg);
-}
-
 const DNS_RESOURCE_RECORD_DEFAULT_TTL = 120; // 120 seconds
 
 class DNSResourceRecord extends DNSRecord {
   constructor(properties = {}) {
     super(properties);
 
     this.ttl  = properties.ttl || DNS_RESOURCE_RECORD_DEFAULT_TTL;
     this.data = properties.data || {};
--- a/netwerk/dns/mdns/libmdns/fallback/MulticastDNS.jsm
+++ b/netwerk/dns/mdns/libmdns/fallback/MulticastDNS.jsm
@@ -5,27 +5,24 @@
 /* jshint esnext: true, moz: true */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["MulticastDNS"];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/Timer.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.import("resource://gre/modules/DNSPacket.jsm");
 ChromeUtils.import("resource://gre/modules/DNSRecord.jsm");
 ChromeUtils.import("resource://gre/modules/DNSResourceRecord.jsm");
 ChromeUtils.import("resource://gre/modules/DNSTypes.jsm");
 
 const NS_NETWORK_LINK_TOPIC = "network:link-status-changed";
 
-let observerService     = Cc["@mozilla.org/observer-service;1"]
-                            .getService(Ci.nsIObserverService);
 let networkInfoService  = Cc["@mozilla.org/network-info-service;1"]
                             .createInstance(Ci.nsINetworkInfoService);
 
 const DEBUG = true;
 
 const MDNS_MULTICAST_GROUP = "224.0.0.251";
 const MDNS_PORT            = 5353;
 const DEFAULT_TTL          = 120;
@@ -122,30 +119,30 @@ class MulticastDNS {
 
   _attachNetworkLinkObserver() {
     if (this._networkLinkObserverTimeout) {
       clearTimeout(this._networkLinkObserverTimeout);
     }
 
     if (!this._isNetworkLinkObserverAttached) {
       DEBUG && debug("Attaching observer " + NS_NETWORK_LINK_TOPIC);
-      observerService.addObserver(this._networkLinkObserver, NS_NETWORK_LINK_TOPIC);
+      Services.obs.addObserver(this._networkLinkObserver, NS_NETWORK_LINK_TOPIC);
       this._isNetworkLinkObserverAttached = true;
     }
   }
 
   _detachNetworkLinkObserver() {
     if (this._isNetworkLinkObserverAttached) {
       if (this._networkLinkObserverTimeout) {
         clearTimeout(this._networkLinkObserverTimeout);
       }
 
       this._networkLinkObserverTimeout = setTimeout(() => {
         DEBUG && debug("Detaching observer " + NS_NETWORK_LINK_TOPIC);
-        observerService.removeObserver(this._networkLinkObserver, NS_NETWORK_LINK_TOPIC);
+        Services.obs.removeObserver(this._networkLinkObserver, NS_NETWORK_LINK_TOPIC);
         this._isNetworkLinkObserverAttached = false;
         this._networkLinkObserverTimeout = null;
       }, 5000);
     }
   }
 
   startDiscovery(aServiceType, aListener) {
     DEBUG && debug('startDiscovery("' + aServiceType + '")');
@@ -342,17 +339,17 @@ class MulticastDNS {
     // Cancel any existing broadcasting timer.
     this._cancelBroadcastTimer();
 
     let now = Date.now();
 
     // Go through services and find services to broadcast.
     let bcastServices = [];
     let nextBcastWait = undefined;
-    for (let [serviceKey, publishedService] of this._services) {
+    for (let [, publishedService] of this._services) {
       // if lastAdvertised is undefined, service hasn't finished it's initial
       // two broadcasts.
       if (publishedService.lastAdvertised === undefined) {
         continue;
       }
 
       // Otherwise, check lastAdvertised against now.
       let msSinceAdv = now - publishedService.lastAdvertised;
--- a/netwerk/protocol/ftp/test/frametest/menu.html
+++ b/netwerk/protocol/ftp/test/frametest/menu.html
@@ -1,44 +1,44 @@
 <html>
 
 <script language="javascript">
-
+/* eslint-disable no-unsanitized/method */
 <!--
 
 function add_location(url) {
-	// faster to do this in one assignment, but who really cares.
+    // faster to do this in one assignment, but who really cares.
 
-	var string = '<LI> <a href=\"javascript: ftp_open(\'';
-	string += url;
-	string += '\')\"';
-	string += 'onmouseover=\"window.status=\'ftp://';
-	string += url;
-	string += '\'; return true; \">';
-	string += url;
-	string += "</a>";
-	document.writeln(string);
+    var string = '<LI> <a href=\"javascript: ftp_open(\'';
+    string += url;
+    string += '\')\"';
+    string += 'onmouseover=\"window.status=\'ftp://';
+    string += url;
+    string += '\'; return true; \">';
+    string += url;
+    string += "</a>";
+    document.writeln(string);
 }
 
 function ftp_open(url) {
-	url = "ftp://" + url;
-	parent.ftp_content.location = url;
+    url = "ftp://" + url;
+    parent.ftp_content.location = url;
 }
 
 // I like this format.
 document.writeln("<pre>");
 
 document.writeln("<br><OL><b>Company sites</b>");
     add_location("ftp.mozilla.org");
-	add_location("ftp.sun.com");
-	add_location("ftp.iplanet.com");
-	add_location("ftp.netscape.com");
-	add_location("ftp.apple.com");
-	add_location("ftp.microsoft.com");
-	add_location("ftp.netmanage.com");
+    add_location("ftp.sun.com");
+    add_location("ftp.iplanet.com");
+    add_location("ftp.netscape.com");
+    add_location("ftp.apple.com");
+    add_location("ftp.microsoft.com");
+    add_location("ftp.netmanage.com");
 
 document.writeln("</OL><br><OL><b>Misc sites</b>");
     add_location("cal044202.student.utwente.nl");
     add_location("download.intel.com");
     add_location("fddisunsite.oit.unc.edu");
     add_location("ftp.abas.de");
     add_location("ftp.acm.org");
     add_location("ftp.acomp.hu");
--- a/netwerk/protocol/http/UserAgentOverrides.jsm
+++ b/netwerk/protocol/http/UserAgentOverrides.jsm
@@ -141,17 +141,16 @@ function getUserAgentFromOverride(overri
 
 function buildOverrides() {
   gOverrides.clear();
   gOverrideForHostCache.clear();
 
   if (!Services.prefs.getBoolPref(PREF_OVERRIDES_ENABLED))
     return;
 
-  let builtUAs = new Map;
   let domains = gPrefBranch.getChildList("");
 
   for (let domain of domains) {
     let override = gPrefBranch.getCharPref(domain);
     let userAgent = getUserAgentFromOverride(override);
 
     if (userAgent != DEFAULT_UA) {
       gOverrides.set(domain, userAgent);
--- a/netwerk/protocol/http/UserAgentUpdates.jsm
+++ b/netwerk/protocol/http/UserAgentUpdates.jsm
@@ -23,22 +23,16 @@ ChromeUtils.defineModuleGetter(
 
 
 ChromeUtils.defineModuleGetter(
   this, "UpdateUtils", "resource://gre/modules/UpdateUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(
   this, "gUpdateTimer", "@mozilla.org/updates/timer-manager;1", "nsIUpdateTimerManager");
 
-XPCOMUtils.defineLazyGetter(this, "gApp",
-  function() {
-    return Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo)
-                                            .QueryInterface(Ci.nsIXULRuntime);
-  });
-
 XPCOMUtils.defineLazyGetter(this, "gDecoder",
   function() { return new TextDecoder(); }
 );
 
 XPCOMUtils.defineLazyGetter(this, "gEncoder",
   function() { return new TextEncoder(); }
 );
 
@@ -178,21 +172,21 @@ var UserAgentUpdates = {
     } catch (e) {
       return def;
     }
   },
 
   _getParameters() {
     return {
       "%DATE%": function() { return Date.now().toString(); },
-      "%PRODUCT%": function() { return gApp.name; },
-      "%APP_ID%": function() { return gApp.ID; },
-      "%APP_VERSION%": function() { return gApp.version; },
-      "%BUILD_ID%": function() { return gApp.appBuildID; },
-      "%OS%": function() { return gApp.OS; },
+      "%PRODUCT%": function() { return Services.appinfo.name; },
+      "%APP_ID%": function() { return Services.appinfo.ID; },
+      "%APP_VERSION%": function() { return Services.appinfo.version; },
+      "%BUILD_ID%": function() { return Services.appinfo.appBuildID; },
+      "%OS%": function() { return Services.appinfo.OS; },
       "%CHANNEL%": function() { return UpdateUtils.UpdateChannel; },
       "%DISTRIBUTION%": function() { return this._getPref(PREF_APP_DISTRIBUTION, ""); },
       "%DISTRIBUTION_VERSION%": function() { return this._getPref(PREF_APP_DISTRIBUTION_VERSION, ""); },
     };
   },
 
   _getUpdateURL() {
     let url = this._getPref(PREF_UPDATES_URL, "");
@@ -231,17 +225,17 @@ var UserAgentUpdates = {
       },
       response => { // error
         this._scheduleUpdate(true /* retry */);
       });
   },
 
   _scheduleUpdate(retry) {
     // only schedule updates in the main process
-    if (gApp.processType !== Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
+    if (Services.appinfo.processType !== Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT) {
       return;
     }
     let interval = this._getPref(PREF_UPDATES_INTERVAL, 604800 /* 1 week */);
     if (retry) {
       interval = this._getPref(PREF_UPDATES_RETRY, interval);
     }
     gUpdateTimer.registerTimer(TIMER_ID, this, Math.max(1, interval));
   },
--- a/netwerk/protocol/http/WellKnownOpportunisticUtils.js
+++ b/netwerk/protocol/http/WellKnownOpportunisticUtils.js
@@ -17,25 +17,25 @@ function WellKnownOpportunisticUtils() {
 }
 
 WellKnownOpportunisticUtils.prototype = {
   classID: WELLKNOWNOPPORTUNISTICUTILS_CID,
   contractID: WELLKNOWNOPPORTUNISTICUTILS_CONTRACTID,
   classDescription: "Well-Known Opportunistic Utils",
   QueryInterface: ChromeUtils.generateQI([Ci.nsIWellKnownOpportunisticUtils]),
 
-    verify(aJSON, aOrigin, aAlternatePort) {
-	try {
-	  let obj = JSON.parse(aJSON.toLowerCase());
-	  let ports = obj[aOrigin.toLowerCase()]["tls-ports"];
-	  if (!ports.includes(aAlternatePort)) {
-	    throw "invalid port";
-	  }
-	  this.lifetime = obj[aOrigin.toLowerCase()].lifetime;
-          this.mixed = obj[aOrigin.toLowerCase()]["mixed-scheme"];
-	} catch (e) {
-	  return;
-	}
-      this.valid = true;
-    },
+  verify(aJSON, aOrigin, aAlternatePort) {
+    try {
+      let obj = JSON.parse(aJSON.toLowerCase());
+      let ports = obj[aOrigin.toLowerCase()]["tls-ports"];
+      if (!ports.includes(aAlternatePort)) {
+        throw "invalid port";
+      }
+      this.lifetime = obj[aOrigin.toLowerCase()].lifetime;
+      this.mixed = obj[aOrigin.toLowerCase()]["mixed-scheme"];
+    } catch (e) {
+      return;
+    }
+    this.valid = true;
+  },
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WellKnownOpportunisticUtils]);