Bug 1423839 Enable ESLint for NetUtil.jsm and netwerk/cookie/test/unit/ r?standard8 draft
authorNicola Webb <nicolaptv@gmail.com>
Fri, 22 Dec 2017 17:33:26 +0000
changeset 714390 008fd795c1c9f60c563d467c8cf2e539e0daa083
parent 714389 91dccd03475c39bd3bd2e46ccfaf3489e8f673d9
child 744576 2beb5095e265c52c08b486cf140802395d9a11ed
push id93908
push userbmo:nicolaptv@gmail.com
push dateFri, 22 Dec 2017 17:34:17 +0000
reviewersstandard8
bugs1423839
milestone59.0a1
Bug 1423839 Enable ESLint for NetUtil.jsm and netwerk/cookie/test/unit/ r?standard8 MozReview-Commit-ID: EphT7ZFiay5
.eslintignore
netwerk/base/NetUtil.jsm
netwerk/cookie/test/unit/test_bug1155169.js
netwerk/cookie/test/unit/test_bug1321912.js
netwerk/cookie/test/unit/test_eviction.js
netwerk/cookie/test/unit/test_parser_0001.js
netwerk/cookie/test/unit/test_parser_0019.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -23,19 +23,17 @@ gfx/tests/browser/**
 gfx/tests/chrome/**
 gfx/tests/mochitest/**
 gfx/tests/unit/**
 image/**
 intl/**
 layout/**
 memory/replace/dmd/test/**
 modules/**
-netwerk/base/NetUtil.jsm
 netwerk/cookie/test/browser/**
-netwerk/cookie/test/unit/**
 netwerk/protocol/**
 netwerk/dns/**
 netwerk/test/browser/**
 netwerk/test/httpserver/**
 netwerk/test/mochitests/**
 netwerk/test/unit*/**
 netwerk/wifi/**
 parser/**
--- a/netwerk/base/NetUtil.jsm
+++ b/netwerk/base/NetUtil.jsm
@@ -7,34 +7,34 @@
 this.EXPORTED_SYMBOLS = [
   "NetUtil",
 ];
 
 /**
  * Necko utilities
  */
 
-////////////////////////////////////////////////////////////////////////////////
-//// Constants
+// //////////////////////////////////////////////////////////////////////////////
+// // Constants
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cr = Components.results;
 const Cu = Components.utils;
 
 const PR_UINT32_MAX = 0xffffffff;
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 const BinaryInputStream = Components.Constructor("@mozilla.org/binaryinputstream;1",
                                                  "nsIBinaryInputStream", "setInputStream");
 
-////////////////////////////////////////////////////////////////////////////////
-//// NetUtil Object
+// //////////////////////////////////////////////////////////////////////////////
+// // NetUtil Object
 
 this.NetUtil = {
     /**
      * Function to perform simple async copying from aSource (an input stream)
      * to aSink (an output stream).  The copy will happen on some background
      * thread.  Both streams will be closed when the copy completes.
      *
      * @param aSource
@@ -45,18 +45,17 @@ this.NetUtil = {
      *        A function that will be called at copy completion with a single
      *        argument: the nsresult status code for the copy operation.
      *
      * @return An nsIRequest representing the copy operation (for example, this
      *         can be used to cancel the copying).  The consumer can ignore the
      *         return value if desired.
      */
     asyncCopy: function NetUtil_asyncCopy(aSource, aSink,
-                                          aCallback = null)
-    {
+                                          aCallback = null) {
         if (!aSource || !aSink) {
             let exception = new Components.Exception(
                 "Must have a source and a sink",
                 Cr.NS_ERROR_INVALID_ARG,
                 Components.stack.caller
             );
             throw exception;
         }
@@ -67,21 +66,21 @@ this.NetUtil = {
         copier.init(aSource, aSink,
                     null /* Default event target */,
                     0 /* Default length */,
                     true, true /* Auto-close */);
 
         var observer;
         if (aCallback) {
             observer = {
-                onStartRequest: function(aRequest, aContext) {},
-                onStopRequest: function(aRequest, aContext, aStatusCode) {
+                onStartRequest(aRequest, aContext) {},
+                onStopRequest(aRequest, aContext, aStatusCode) {
                     aCallback(aStatusCode);
                 }
-            }
+            };
         } else {
             observer = null;
         }
 
         // start the copying
         copier.QueryInterface(Ci.nsIAsyncStreamCopier).asyncCopy(observer, null);
         return copier;
     },
@@ -99,18 +98,17 @@ this.NetUtil = {
      *        Using an nsIURI, nsIFile, or string spec directly is deprecated.
      * @param aCallback
      *        The callback function that will be notified upon completion.  It
      *        will get these arguments:
      *        1) An nsIInputStream containing the data from aSource, if any.
      *        2) The status code from opening the source.
      *        3) Reference to the nsIRequest.
      */
-    asyncFetch: function NetUtil_asyncFetch(aSource, aCallback)
-    {
+    asyncFetch: function NetUtil_asyncFetch(aSource, aCallback) {
         if (!aSource || !aCallback) {
             let exception = new Components.Exception(
                 "Must have a source and a callback",
                 Cr.NS_ERROR_INVALID_ARG,
                 Components.stack.caller
             );
             throw exception;
         }
@@ -120,18 +118,18 @@ this.NetUtil = {
         let pipe = Cc["@mozilla.org/pipe;1"].
                    createInstance(Ci.nsIPipe);
         pipe.init(true, true, 0, PR_UINT32_MAX, null);
 
         // Create a listener that will give data to the pipe's output stream.
         let listener = Cc["@mozilla.org/network/simple-stream-listener;1"].
                        createInstance(Ci.nsISimpleStreamListener);
         listener.init(pipe.outputStream, {
-            onStartRequest: function(aRequest, aContext) {},
-            onStopRequest: function(aRequest, aContext, aStatusCode) {
+            onStartRequest(aRequest, aContext) {},
+            onStopRequest(aRequest, aContext, aStatusCode) {
                 pipe.outputStream.close();
                 aCallback(pipe.inputStream, aStatusCode, aRequest);
             }
         });
 
         // Input streams are handled slightly differently from everything else.
         if (aSource instanceof Ci.nsIInputStream) {
             let pump = Cc["@mozilla.org/network/input-stream-pump;1"].
@@ -147,29 +145,27 @@ this.NetUtil = {
         }
 
         try {
             // Open the channel using asyncOpen2() if the loadinfo contains one
             // of the security mode flags, otherwise fall back to use asyncOpen().
             if (channel.loadInfo &&
                 channel.loadInfo.securityMode != 0) {
                 channel.asyncOpen2(listener);
-            }
-            else {
+            } else {
                 // Log deprecation warning to console to make sure all channels
                 // are created providing the correct security flags in the loadinfo.
                 // See nsILoadInfo for all available security flags and also the API
                 // of NetUtil.newChannel() for details above.
                 Cu.reportError("NetUtil.jsm: asyncFetch() requires the channel to have " +
                     "one of the security flags set in the loadinfo (see nsILoadInfo). " +
                     "Please create channel using NetUtil.newChannel()");
                 channel.asyncOpen(listener, null);
             }
-        }
-        catch (e) {
+        } catch (e) {
             let exception = new Components.Exception(
                 "Failed to open input source '" + channel.originalURI.spec + "'",
                 e.result,
                 Components.stack.caller,
                 aSource,
                 e
             );
             throw exception;
@@ -186,18 +182,17 @@ this.NetUtil = {
      *        The character set for the URI.  Only used if aTarget is not an
      *        nsIFile.
      * @param aBaseURI [optional]
      *        The base URI for the spec.  Only used if aTarget is not an
      *        nsIFile.
      *
      * @return an nsIURI object.
      */
-    newURI: function NetUtil_newURI(aTarget, aOriginCharset, aBaseURI)
-    {
+    newURI: function NetUtil_newURI(aTarget, aOriginCharset, aBaseURI) {
         if (!aTarget) {
             let exception = new Components.Exception(
                 "Must have a non-null string spec or nsIFile object",
                 Cr.NS_ERROR_INVALID_ARG,
                 Components.stack.caller
             );
             throw exception;
         }
@@ -244,18 +239,17 @@ this.NetUtil = {
      *        string, which is a deprecated API.  Must be undefined otherwise.
      *        Use NetUtil.newURI if you need to use this option.
      * @param aBaseURI [deprecated]
      *        The base URI for the spec.  Only used if aWhatToLoad is a string,
      *        which is a deprecated API.  Must be undefined otherwise.  Use
      *        NetUtil.newURI if you need to use this option.
      * @return an nsIChannel object.
      */
-    newChannel: function NetUtil_newChannel(aWhatToLoad, aOriginCharset, aBaseURI)
-    {
+    newChannel: function NetUtil_newChannel(aWhatToLoad, aOriginCharset, aBaseURI) {
         // Check for the deprecated API first.
         if (typeof aWhatToLoad == "string" ||
             (aWhatToLoad instanceof Ci.nsIFile) ||
             (aWhatToLoad instanceof Ci.nsIURI)) {
 
             let uri = (aWhatToLoad instanceof Ci.nsIURI)
                       ? aWhatToLoad
                       : this.newURI(aWhatToLoad, aOriginCharset, aBaseURI);
@@ -385,18 +379,17 @@ this.NetUtil = {
      * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from aInputStream would
      *         block the calling thread (non-blocking mode only).
      * @throws NS_ERROR_FAILURE if there are not enough bytes available to read
      *         aCount amount of data.
      * @throws NS_ERROR_ILLEGAL_INPUT if aInputStream has invalid sequences
      */
     readInputStreamToString: function NetUtil_readInputStreamToString(aInputStream,
                                                                       aCount,
-                                                                      aOptions)
-    {
+                                                                      aOptions) {
         if (!(aInputStream instanceof Ci.nsIInputStream)) {
             let exception = new Components.Exception(
                 "First argument should be an nsIInputStream",
                 Cr.NS_ERROR_INVALID_ARG,
                 Components.stack.caller
             );
             throw exception;
         }
@@ -424,31 +417,29 @@ this.NetUtil = {
             }
 
             cis.init(aInputStream, aOptions.charset, aCount,
                      aOptions.replacement);
             let str = {};
             cis.readString(-1, str);
             cis.close();
             return str.value;
-          }
-          catch (e) {
+          } catch (e) {
             // Adjust the stack so it throws at the caller's location.
             throw new Components.Exception(e.message, e.result,
                                            Components.stack.caller, e.data);
           }
         }
 
         let sis = Cc["@mozilla.org/scriptableinputstream;1"].
                   createInstance(Ci.nsIScriptableInputStream);
         sis.init(aInputStream);
         try {
             return sis.readBytes(aCount);
-        }
-        catch (e) {
+        } catch (e) {
             // Adjust the stack so it throws at the caller's location.
             throw new Components.Exception(e.message, e.result,
                                            Components.stack.caller, e.data);
         }
     },
 
     /**
      * Reads aCount bytes from aInputStream into a string.
@@ -461,18 +452,17 @@ this.NetUtil = {
      * @return the bytes from the input stream in string form.
      *
      * @throws NS_ERROR_INVALID_ARG if aInputStream is not an nsIInputStream.
      * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from aInputStream would
      *         block the calling thread (non-blocking mode only).
      * @throws NS_ERROR_FAILURE if there are not enough bytes available to read
      *         aCount amount of data.
      */
-    readInputStream(aInputStream, aCount)
-    {
+    readInputStream(aInputStream, aCount) {
         if (!(aInputStream instanceof Ci.nsIInputStream)) {
             let exception = new Components.Exception(
                 "First argument should be an nsIInputStream",
                 Cr.NS_ERROR_INVALID_ARG,
                 Components.stack.caller
             );
             throw exception;
         }
@@ -487,15 +477,14 @@ this.NetUtil = {
         return result;
     },
 
     /**
      * Returns a reference to nsIIOService.
      *
      * @return a reference to nsIIOService.
      */
-    get ioService()
-    {
+    get ioService() {
         delete this.ioService;
-        return this.ioService = Cc["@mozilla.org/network/io-service;1"].
-                                getService(Ci.nsIIOService);
+
+        return this.ioService = Services.io;
     },
 };
--- a/netwerk/cookie/test/unit/test_bug1155169.js
+++ b/netwerk/cookie/test/unit/test_bug1155169.js
@@ -37,18 +37,18 @@ function run_test() {
   });
 
   // Reset cookie.
   setCookie("foo=bar", {
     type: "changed", isSession: true, isSecure: false, isHttpOnly: false
   });
 }
 
-function setCookie(value, expected) {
-  function setCookieInternal(value, expected = null) {
+function setCookie(value, expected = null) {
+  function setCookieInternal() {
     function observer(subject, topic, data) {
       if (!expected) {
         do_throw("no notification expected");
         return;
       }
 
       // Check we saw the right notification.
       Assert.equal(data, expected.type);
--- a/netwerk/cookie/test/unit/test_bug1321912.js
+++ b/netwerk/cookie/test/unit/test_bug1321912.js
@@ -1,21 +1,19 @@
 const {utils: Cu, interfaces: Ci, classes: Cc} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 
 do_get_profile();
-const dirSvc = Cc["@mozilla.org/file/directory_service;1"].
-               getService(Ci.nsIProperties);
+const dirSvc = Services.dirsvc;
 
 let dbFile = dirSvc.get("ProfD", Ci.nsIFile);
 dbFile.append("cookies.sqlite");
 
-let storage = Cc["@mozilla.org/storage/service;1"].
-              getService(Ci.mozIStorageService);
+let storage = Services.storage;
 let properties = Cc["@mozilla.org/hash-property-bag;1"].
                  createInstance(Ci.nsIWritablePropertyBag);
 properties.setProperty("shared", true);
 let conn = storage.openDatabase(dbFile);
 
 // Write the schema v7 to the database.
 conn.schemaVersion = 7;
 conn.executeSimpleSQL("CREATE TABLE moz_cookies (" +
@@ -46,18 +44,17 @@ let now = Date.now();
 conn.executeSimpleSQL("INSERT INTO moz_cookies(" +
   "baseDomain, host, name, value, path, expiry, " +
   "lastAccessed, creationTime, isSecure, isHttpOnly) VALUES (" +
   "'foo.com', '.foo.com', 'foo', 'bar=baz', '/', " +
   now + ", " + now + ", " + now + ", 1, 1)");
 
 // Now start the cookie service, and then check the fields in the table.
 // Get sessionEnumerator to wait for the initialization in cookie thread
-const enumerator = Cc["@mozilla.org/cookieService;1"].
-                   getService(Ci.nsICookieManager).sessionEnumerator;
+const enumerator = Services.cookies.sessionEnumerator;
 
 Assert.ok(conn.schemaVersion, 8);
 let stmt = conn.createStatement("SELECT sql FROM sqlite_master " +
                                   "WHERE type = 'table' AND " +
                                   "      name = 'moz_cookies'");
 try {
   Assert.ok(stmt.executeStep());
   let sql = stmt.getString(0);
--- a/netwerk/cookie/test/unit/test_eviction.js
+++ b/netwerk/cookie/test/unit/test_eviction.js
@@ -14,24 +14,24 @@ function run_test() {
     for (var host of BASE_HOSTNAMES) {
         var base = SUBDOMAINS[0] + host;
         var sub = SUBDOMAINS[1] + host;
         var other = SUBDOMAINS[2] + host;
         var another = SUBDOMAINS[3] + host;
         tests.push([host, test_basic_eviction.bind(this, base, sub, other, another)]);
         add_task(async function a() {
             var t = tests.splice(0, 1)[0];
-            info('testing with host ' + t[0]);
+            info("testing with host " + t[0]);
             await t[1]();
             cm.removeAll();
         });
         tests.push([host, test_domain_or_path_matches_not_both.bind(this, base, sub, other, another)]);
         add_task(async function() {
             var t = tests.splice(0, 1)[0];
-            info('testing with host ' + t[0]);
+            info("testing with host " + t[0]);
             await t[1]();
             cm.removeAll();
         });
     }
     add_task(async function() {
         await test_localdomain();
         cm.removeAll();
     });
@@ -49,177 +49,177 @@ async function test_path_prefix() {
     Services.prefs.setIntPref("network.cookie.maxPerHost", 2);
 
     const BASE_URI = Services.io.newURI("http://example.org/");
     const BASE_BAR = Services.io.newURI("http://example.org/bar/");
     const BASE_BARBAR = Services.io.newURI("http://example.org/barbar/");
 
     await setCookie("session_first", null, null, null, BASE_URI);
     await setCookie("session_second", null, "/bar", null, BASE_BAR);
-    verifyCookies(['session_first', 'session_second'], BASE_URI);
+    verifyCookies(["session_first", "session_second"], BASE_URI);
 
     await setCookie("session_third", null, "/barbar", null, BASE_BARBAR);
-    verifyCookies(['session_first', 'session_third'], BASE_URI);
+    verifyCookies(["session_first", "session_third"], BASE_URI);
 }
 
 // Verify that subdomains of localhost are treated as separate hosts and aren't considered
 // candidates for eviction.
 async function test_localdomain() {
     Services.prefs.setIntPref("network.cookie.maxPerHost", 2);
 
     const BASE_URI = Services.io.newURI("http://localhost");
     const BASE_BAR = Services.io.newURI("http://localhost/bar");
     const OTHER_URI = Services.io.newURI("http://other.localhost");
     const OTHER_BAR = Services.io.newURI("http://other.localhost/bar");
-    
+
     await setCookie("session_no_path", null, null, null, BASE_URI);
     await setCookie("session_bar_path", null, "/bar", null, BASE_BAR);
 
     await setCookie("session_no_path", null, null, null, OTHER_URI);
     await setCookie("session_bar_path", null, "/bar", null, OTHER_BAR);
 
-    verifyCookies(['session_no_path',
-                   'session_bar_path'], BASE_URI);
-    verifyCookies(['session_no_path',
-                   'session_bar_path'], OTHER_URI);
+    verifyCookies(["session_no_path",
+                   "session_bar_path"], BASE_URI);
+    verifyCookies(["session_no_path",
+                   "session_bar_path"], OTHER_URI);
 
     await setCookie("session_another_no_path", null, null, null, BASE_URI);
-    verifyCookies(['session_no_path',
-                   'session_another_no_path'], BASE_URI);
+    verifyCookies(["session_no_path",
+                   "session_another_no_path"], BASE_URI);
 
     await setCookie("session_another_no_path", null, null, null, OTHER_URI);
-    verifyCookies(['session_no_path',
-                   'session_another_no_path'], OTHER_URI);
+    verifyCookies(["session_no_path",
+                   "session_another_no_path"], OTHER_URI);
 }
 
 // Ensure that cookies are still considered candidates for eviction if either the domain
 // or path matches, but not both.
 async function test_domain_or_path_matches_not_both(base_host,
                                                subdomain_host,
                                                other_subdomain_host,
                                                another_subdomain_host) {
     Services.prefs.setIntPref("network.cookie.maxPerHost", 2);
 
     const BASE_URI = Services.io.newURI("http://" + base_host);
     const PUB_FOO_PATH = Services.io.newURI("http://" + subdomain_host + "/foo/");
     const WWW_BAR_PATH = Services.io.newURI("http://" + other_subdomain_host + "/bar/");
     const OTHER_BAR_PATH = Services.io.newURI("http://" + another_subdomain_host + "/bar/");
     const PUB_BAR_PATH = Services.io.newURI("http://" + subdomain_host + "/bar/");
-    const WWW_FOO_PATH = Services.io.newURI("http://" + other_subdomain_host + "/foo/");
+    // const WWW_FOO_PATH = Services.io.newURI("http://" + other_subdomain_host + "/foo/");
 
     await setCookie("session_pub_with_foo_path", subdomain_host, "/foo", null, PUB_FOO_PATH);
     await setCookie("session_www_with_bar_path", other_subdomain_host, "/bar", null, WWW_BAR_PATH);
-    verifyCookies(['session_pub_with_foo_path',
-                   'session_www_with_bar_path'], BASE_URI);
+    verifyCookies(["session_pub_with_foo_path",
+                   "session_www_with_bar_path"], BASE_URI);
 
     await setCookie("session_pub_with_bar_path", subdomain_host, "/bar", null, PUB_BAR_PATH);
-    verifyCookies(['session_www_with_bar_path',
-                   'session_pub_with_bar_path'], BASE_URI);
+    verifyCookies(["session_www_with_bar_path",
+                   "session_pub_with_bar_path"], BASE_URI);
 
     await setCookie("session_other_with_bar_path", another_subdomain_host, "/bar", null, OTHER_BAR_PATH);
-    verifyCookies(['session_pub_with_bar_path',
-                   'session_other_with_bar_path'], BASE_URI);
+    verifyCookies(["session_pub_with_bar_path",
+                   "session_other_with_bar_path"], BASE_URI);
 }
 
 async function test_basic_eviction(base_host, subdomain_host, other_subdomain_host) {
     Services.prefs.setIntPref("network.cookie.maxPerHost", 5);
 
     const BASE_URI = Services.io.newURI("http://" + base_host);
     const SUBDOMAIN_URI = Services.io.newURI("http://" + subdomain_host);
     const OTHER_SUBDOMAIN_URI = Services.io.newURI("http://" + other_subdomain_host);
     const FOO_PATH = Services.io.newURI("http://" + base_host + "/foo/");
     const BAR_PATH = Services.io.newURI("http://" + base_host + "/bar/");
-    const ALL_SUBDOMAINS = '.' + base_host;
+    const ALL_SUBDOMAINS = "." + base_host;
     const OTHER_SUBDOMAIN = other_subdomain_host;
 
     // Initialize the set of cookies with a mix of non-session cookies with no path,
     // and session cookies with explicit paths. Any subsequent cookies added will cause
     // existing cookies to be evicted.
     await setCookie("non_session_non_path_non_domain", null, null, 100000, BASE_URI);
     await setCookie("non_session_non_path_subdomain", ALL_SUBDOMAINS, null, 100000, SUBDOMAIN_URI);
     await setCookie("session_non_path_pub_domain", OTHER_SUBDOMAIN, null, null, OTHER_SUBDOMAIN_URI);
     await setCookie("session_foo_path", null, "/foo", null, FOO_PATH);
     await setCookie("session_bar_path", null, "/bar", null, BAR_PATH);
-    verifyCookies(['non_session_non_path_non_domain',
-                   'non_session_non_path_subdomain',
-                   'session_non_path_pub_domain',
-                   'session_foo_path',
-                   'session_bar_path'], BASE_URI);
+    verifyCookies(["non_session_non_path_non_domain",
+                   "non_session_non_path_subdomain",
+                   "session_non_path_pub_domain",
+                   "session_foo_path",
+                   "session_bar_path"], BASE_URI);
 
     // Ensure that cookies set for the / path appear more recent.
-    cs.getCookieString(OTHER_SUBDOMAIN_URI, null)
-    verifyCookies(['non_session_non_path_non_domain',
-                   'session_foo_path',
-                   'session_bar_path',
-                   'non_session_non_path_subdomain',
-                   'session_non_path_pub_domain'], BASE_URI);
+    cs.getCookieString(OTHER_SUBDOMAIN_URI, null);
+    verifyCookies(["non_session_non_path_non_domain",
+                   "session_foo_path",
+                   "session_bar_path",
+                   "non_session_non_path_subdomain",
+                   "session_non_path_pub_domain"], BASE_URI);
 
     // Evict oldest cookie that does not match example.org/foo (session_bar_path)
     await setCookie("session_foo_path_2", null, "/foo", null, FOO_PATH);
-    verifyCookies(['non_session_non_path_non_domain',
-                   'session_foo_path',
-                   'non_session_non_path_subdomain',
-                   'session_non_path_pub_domain',
-                   'session_foo_path_2'], BASE_URI);
+    verifyCookies(["non_session_non_path_non_domain",
+                   "session_foo_path",
+                   "non_session_non_path_subdomain",
+                   "session_non_path_pub_domain",
+                   "session_foo_path_2"], BASE_URI);
 
     // Evict oldest cookie that does not match example.org/bar (session_foo_path)
     await setCookie("session_bar_path_2", null, "/bar", null, BAR_PATH);
-    verifyCookies(['non_session_non_path_non_domain',
-                   'non_session_non_path_subdomain',
-                   'session_non_path_pub_domain',
-                   'session_foo_path_2',
-                   'session_bar_path_2'], BASE_URI);
+    verifyCookies(["non_session_non_path_non_domain",
+                   "non_session_non_path_subdomain",
+                   "session_non_path_pub_domain",
+                   "session_foo_path_2",
+                   "session_bar_path_2"], BASE_URI);
 
     // Evict oldest cookie that does not match example.org/ (session_non_path_pub_domain)
     await setCookie("non_session_non_path_non_domain_2", null, null, 100000, BASE_URI);
-    verifyCookies(['non_session_non_path_non_domain',
-                   'non_session_non_path_subdomain',
-                   'session_foo_path_2',
-                   'session_bar_path_2',
-                   'non_session_non_path_non_domain_2'], BASE_URI);
+    verifyCookies(["non_session_non_path_non_domain",
+                   "non_session_non_path_subdomain",
+                   "session_foo_path_2",
+                   "session_bar_path_2",
+                   "non_session_non_path_non_domain_2"], BASE_URI);
 
     // Evict oldest cookie that does not match example.org/ (session_foo_path_2)
     await setCookie("session_non_path_non_domain_3", null, null, null, BASE_URI);
-    verifyCookies(['non_session_non_path_non_domain',
-                   'non_session_non_path_subdomain',
-                   'session_bar_path_2',
-                   'non_session_non_path_non_domain_2',
-                   'session_non_path_non_domain_3'], BASE_URI);
+    verifyCookies(["non_session_non_path_non_domain",
+                   "non_session_non_path_subdomain",
+                   "session_bar_path_2",
+                   "non_session_non_path_non_domain_2",
+                   "session_non_path_non_domain_3"], BASE_URI);
 
     // Evict oldest cookie; all such cookies match example.org/bar (non_session_non_path_non_domain)
     await setCookie("non_session_bar_path_non_domain", null, null, 100000, BAR_PATH);
-    verifyCookies(['non_session_non_path_subdomain',
-                   'session_bar_path_2',
-                   'non_session_non_path_non_domain_2',
-                   'session_non_path_non_domain_3',
-                   'non_session_bar_path_non_domain'], BASE_URI);
+    verifyCookies(["non_session_non_path_subdomain",
+                   "session_bar_path_2",
+                   "non_session_non_path_non_domain_2",
+                   "session_non_path_non_domain_3",
+                   "non_session_bar_path_non_domain"], BASE_URI);
 
     // Evict oldest cookie that deose not match example.org/ (session_bar_path_2)
     await setCookie("non_session_non_path_pub_domain", null, null, 100000, OTHER_SUBDOMAIN_URI);
-    verifyCookies(['non_session_non_path_subdomain',
-                   'non_session_non_path_non_domain_2',
-                   'session_non_path_non_domain_3',
-                   'non_session_bar_path_non_domain',
-                   'non_session_non_path_pub_domain'], BASE_URI);
+    verifyCookies(["non_session_non_path_subdomain",
+                   "non_session_non_path_non_domain_2",
+                   "session_non_path_non_domain_3",
+                   "non_session_bar_path_non_domain",
+                   "non_session_non_path_pub_domain"], BASE_URI);
 
     // Evict oldest cookie that does not match example.org/bar (non_session_non_path_pub_domain)
-    await setCookie("non_session_bar_path_non_domain_2", null, '/bar', 100000, BAR_PATH);
-    verifyCookies(['non_session_non_path_subdomain',
-                   'non_session_non_path_non_domain_2',
-                   'session_non_path_non_domain_3',
-                   'non_session_bar_path_non_domain',
-                   'non_session_bar_path_non_domain_2'], BASE_URI);
+    await setCookie("non_session_bar_path_non_domain_2", null, "/bar", 100000, BAR_PATH);
+    verifyCookies(["non_session_non_path_subdomain",
+                   "non_session_non_path_non_domain_2",
+                   "session_non_path_non_domain_3",
+                   "non_session_bar_path_non_domain",
+                   "non_session_bar_path_non_domain_2"], BASE_URI);
 
     // Evict oldest cookie that does not match example.org/ (non_session_bar_path_non_domain)
     await setCookie("non_session_non_path_non_domain_4", null, null, 100000, BASE_URI);
-    verifyCookies(['non_session_non_path_subdomain',
-                   'non_session_non_path_non_domain_2',
-                   'session_non_path_non_domain_3',
-                   'non_session_bar_path_non_domain_2',
-                   'non_session_non_path_non_domain_4'], BASE_URI);
+    verifyCookies(["non_session_non_path_subdomain",
+                   "non_session_non_path_non_domain_2",
+                   "session_non_path_non_domain_3",
+                   "non_session_bar_path_non_domain_2",
+                   "non_session_non_path_non_domain_4"], BASE_URI);
 
     // At this point all remaining cookies have a path of / and either don't have a domain
     // or have one that matches subdomains.
     // They will therefore be evicted from oldest to newest if all new cookies added share
     // similar characteristics.
 }
 
 // Verify that the given cookie names exist, and are ordered from least to most recently accessed
@@ -236,17 +236,17 @@ function verifyCookies(names, uri) {
             return actual_cookies.findIndex(function(c) {
                 return c.name == n;
             }) == -1;
         });
         let right = actual_cookies.filter(function(c) {
             return names.findIndex(function(n) {
                 return c.name == n;
             }) == -1;
-        }).map(function(c) { return c.name });
+        }).map(function(c) { return c.name; });
         if (left.length) {
             info("unexpected cookies: " + left);
         }
         if (right.length) {
             info("expected cookies: " + right);
         }
     }
     Assert.equal(names.length, actual_cookies.length);
@@ -254,40 +254,40 @@ function verifyCookies(names, uri) {
         if (a.lastAccessed < b.lastAccessed)
             return -1;
         if (a.lastAccessed > b.lastAccessed)
             return 1;
         return 0;
     });
     for (var i = 0; i < names.length; i++) {
         Assert.equal(names[i], actual_cookies[i].name);
-        Assert.equal(names[i].startsWith('session'), actual_cookies[i].isSession);
+        Assert.equal(names[i].startsWith("session"), actual_cookies[i].isSession);
     }
 }
 
-var lastValue = 0
+var lastValue = 0;
 function setCookie(name, domain, path, maxAge, url) {
     let value = name + "=" + ++lastValue;
-    var s = 'setting cookie ' + value;
+    var s = "setting cookie " + value;
     if (domain) {
         value += "; Domain=" + domain;
-        s += ' (d=' + domain + ')';
+        s += " (d=" + domain + ")";
     }
     if (path) {
         value += "; Path=" + path;
-        s += ' (p=' + path + ')';
+        s += " (p=" + path + ")";
     }
     if (maxAge) {
         value += "; Max-Age=" + maxAge;
-        s += ' (non-session)';
+        s += " (non-session)";
     } else {
-        s += ' (session)';
+        s += " (session)";
     }
-    s += ' for ' + url.spec;
+    s += " for " + url.spec;
     info(s);
     cs.setCookieStringFromHttp(url, null, null, value, null, null);
     return new Promise(function(resolve) {
         // Windows XP has low precision timestamps that cause our cookie eviction
         // algorithm to produce different results from other platforms. We work around
         // this by ensuring that there's a clear gap between each cookie update.
         do_timeout(10, resolve);
-    })
+    });
 }
--- a/netwerk/cookie/test/unit/test_parser_0001.js
+++ b/netwerk/cookie/test/unit/test_parser_0001.js
@@ -1,18 +1,16 @@
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 function inChildProcess() {
-  return Cc["@mozilla.org/xre/app-info;1"]
-           .getService(Ci.nsIXULRuntime)
-           .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
+  return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 }
 
 function run_test() {
   // Allow all cookies if the pref service is available in this process.
   if (!inChildProcess())
     Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
 
   let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);
--- a/netwerk/cookie/test/unit/test_parser_0019.js
+++ b/netwerk/cookie/test/unit/test_parser_0019.js
@@ -1,18 +1,16 @@
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 
 Components.utils.import("resource://gre/modules/NetUtil.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 function inChildProcess() {
-  return Cc["@mozilla.org/xre/app-info;1"]
-           .getService(Ci.nsIXULRuntime)
-           .processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
+  return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
 }
 
 function run_test() {
   // Allow all cookies if the pref service is available in this process.
   if (!inChildProcess())
     Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
 
   let cs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsICookieService);