Bug 1515877 - Turn on ESLint in mailnews/news; r=aceman
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 24 Dec 2018 23:52:29 +1300
changeset 33202 9bbe95da846a
parent 33201 2c3b0e1ad6a2
child 33203 4dac195e120e
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1515877
Bug 1515877 - Turn on ESLint in mailnews/news; r=aceman
.eslintignore
mailnews/news/content/downloadheaders.js
mailnews/news/src/nsNewsAutoCompleteSearch.js
mailnews/news/test/unit/.eslintrc.js
mailnews/news/test/unit/head_server_setup.js
mailnews/news/test/unit/test_biff.js
mailnews/news/test/unit/test_bug37465.js
mailnews/news/test/unit/test_bug403242.js
mailnews/news/test/unit/test_bug540288.js
mailnews/news/test/unit/test_bug695309.js
mailnews/news/test/unit/test_filter.js
mailnews/news/test/unit/test_getNewsMessage.js
mailnews/news/test/unit/test_internalUris.js
mailnews/news/test/unit/test_newsAutocomplete.js
mailnews/news/test/unit/test_nntpContentLength.js
mailnews/news/test/unit/test_nntpGroupPassword.js
mailnews/news/test/unit/test_nntpPassword.js
mailnews/news/test/unit/test_nntpPassword2.js
mailnews/news/test/unit/test_nntpPassword3.js
mailnews/news/test/unit/test_nntpPasswordFailure.js
mailnews/news/test/unit/test_nntpPost.js
mailnews/news/test/unit/test_nntpProtocols.js
mailnews/news/test/unit/test_nntpProxy.js
mailnews/news/test/unit/test_nntpUrl.js
mailnews/news/test/unit/test_server.js
mailnews/news/test/unit/test_uriParser.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -35,17 +35,16 @@ mailnews/compose/*
 mailnews/db/*
 mailnews/imap/*
 mailnews/import/*
 mailnews/intl/*
 mailnews/jsaccount/*
 mailnews/local/*
 mailnews/mapi/*
 mailnews/mime/*
-mailnews/news/*
 mailnews/test/*
 
 # mailnews/extensions exclusions
 mailnews/extensions/*
 !mailnews/extensions/newsblog
 
 # mail exclusions
 mail/app/profile/all-thunderbird.js
--- a/mailnews/news/content/downloadheaders.js
+++ b/mailnews/news/content/downloadheaders.js
@@ -6,18 +6,17 @@
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var markreadElement = null;
 var numberElement = null;
 
 var nntpServer = null;
 var args = null;
 
-function OnLoad()
-{
+function OnLoad() {
   let newsBundle = document.getElementById("bundle_news");
 
   if ("arguments" in window && window.arguments[0]) {
     args = window.arguments[0]
                  .QueryInterface(Ci.nsINewsDownloadDialogArgs);
     /* by default, act like the user hit cancel */
     args.hitOK = false;
     /* by default, act like the user did not select download all */
@@ -26,17 +25,17 @@ function OnLoad()
 
     nntpServer = MailServices.accounts.getIncomingServer(args.serverKey)
                .QueryInterface(Ci.nsINntpIncomingServer);
 
     document.title = newsBundle.getString("downloadHeadersTitlePrefix");
 
     let infotext = newsBundle.getFormattedString("downloadHeadersInfoText",
                                                  [args.articleCount]);
-    setText('info', infotext);
+    setText("info", infotext);
     let okButtonText = newsBundle.getString("okButtonText");
     let okbutton = document.documentElement.getButton("accept");
     okbutton.setAttribute("label", okButtonText);
     okbutton.focus();
     setText("newsgroupLabel", args.groupName);
   }
 
   numberElement = document.getElementById("number");
--- a/mailnews/news/src/nsNewsAutoCompleteSearch.js
+++ b/mailnews/news/src/nsNewsAutoCompleteSearch.js
@@ -25,47 +25,47 @@ nsNewsAutoCompleteResult.prototype = {
   searchResult: kACR.RESULT_NOMATCH,
   defaultIndex: -1,
   errorDescription: null,
 
   get matchCount() {
     return this._searchResults.length;
   },
 
-  getValueAt: function getValueAt(aIndex) {
+  getValueAt(aIndex) {
     return this._searchResults[aIndex].value;
   },
 
-  getLabelAt: function getLabelAt(aIndex) {
+  getLabelAt(aIndex) {
     return this._searchResults[aIndex].value;
   },
 
-  getCommentAt: function getCommentAt(aIndex) {
+  getCommentAt(aIndex) {
     return this._searchResults[aIndex].comment;
   },
 
-  getStyleAt: function getStyleAt(aIndex) {
+  getStyleAt(aIndex) {
     return "subscribed-news";
   },
 
-  getImageAt: function getImageAt(aIndex) {
+  getImageAt(aIndex) {
     return "";
   },
 
-  getFinalCompleteValueAt: function(aIndex) {
+  getFinalCompleteValueAt(aIndex) {
     return this.getValueAt(aIndex);
   },
 
-  removeValueAt: function removeValueAt(aRowIndex, aRemoveFromDB) {
+  removeValueAt(aRowIndex, aRemoveFromDB) {
   },
 
   // nsISupports
 
-  QueryInterface: ChromeUtils.generateQI([kACR])
-}
+  QueryInterface: ChromeUtils.generateQI([kACR]),
+};
 
 function nsNewsAutoCompleteSearch() {}
 
 nsNewsAutoCompleteSearch.prototype = {
   // For component registration
   classDescription: "Newsgroup Autocomplete",
   classID: Components.ID("e9bb3330-ac7e-11de-8a39-0800200c9a66"),
 
@@ -73,28 +73,26 @@ nsNewsAutoCompleteSearch.prototype = {
   cachedServer: null,
 
   /**
    * Find the newsgroup server associated with the given accountKey.
    *
    * @param accountKey  The key of the account.
    * @return            The incoming news server (or null if one does not exist).
    */
-  _findServer: function _findServer(accountKey) {
+  _findServer(accountKey) {
     let account = MailServices.accounts.getAccount(accountKey);
 
-    if (account.incomingServer.type == 'nntp')
+    if (account.incomingServer.type == "nntp")
       return account.incomingServer;
-    else
-      return null;
+    return null;
   },
 
   // nsIAutoCompleteSearch
-  startSearch: function startSearch(aSearchString, aSearchParam,
-                                    aPreviousResult, aListener) {
+  startSearch(aSearchString, aSearchParam, aPreviousResult, aListener) {
     let params = aSearchParam ? JSON.parse(aSearchParam) : {};
     let result = new nsNewsAutoCompleteResult(aSearchString);
     if (!("type" in params) || !("accountKey" in params) ||
         !kSupportedTypes.has(params.type)) {
       result.searchResult = kACR.RESULT_IGNORED;
       aListener.onSearchResult(this, result);
       return;
     }
@@ -106,32 +104,32 @@ nsNewsAutoCompleteSearch.prototype = {
 
     if (this.cachedServer) {
       let groups = this.cachedServer.rootFolder.subFolders;
       while (groups.hasMoreElements()) {
         let curr = groups.getNext().QueryInterface(Ci.nsIMsgFolder);
         if (curr.prettyName.includes(aSearchString)) {
           result._searchResults.push({
             value: curr.prettyName,
-            comment: this.cachedServer.prettyName
+            comment: this.cachedServer.prettyName,
           });
         }
       }
     }
 
     if (result.matchCount) {
       result.searchResult = kACR.RESULT_SUCCESS;
       // If the user does not select anything, use the first entry:
       result.defaultIndex = 0;
     }
     aListener.onSearchResult(this, result);
   },
 
-  stopSearch: function stopSearch() {
+  stopSearch() {
   },
 
   // nsISupports
 
-  QueryInterface: ChromeUtils.generateQI([Ci.nsIAutoCompleteSearch])
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIAutoCompleteSearch]),
 };
 
 // Module
 var NSGetFactory = XPCOMUtils.generateNSGetFactory([nsNewsAutoCompleteSearch]);
new file mode 100644
--- /dev/null
+++ b/mailnews/news/test/unit/.eslintrc.js
@@ -0,0 +1,14 @@
+"use strict";
+
+module.exports = {
+  "extends": "plugin:mozilla/xpcshell-test",
+
+  "rules": {
+    "func-names": "off",
+    "mozilla/import-headjs-globals": "error",
+    "no-unused-vars": ["error", {
+      "args": "none",
+      "vars": "all",
+    }],
+  },
+};
--- a/mailnews/news/test/unit/head_server_setup.js
+++ b/mailnews/news/test/unit/head_server_setup.js
@@ -1,67 +1,78 @@
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
-var CC = Components.Constructor;
+var test = null;
 
 // WebApps.jsm called by ProxyAutoConfig (PAC) requires a valid nsIXULAppInfo.
 ChromeUtils.import("resource://testing-common/AppInfo.jsm");
 updateAppInfo();
 
 // Ensure the profile directory is set up
 do_get_profile();
 
 var gDEPTH = "../../../../";
 
 // Import the servers
-ChromeUtils.import("resource://testing-common/mailnews/maild.js");
-ChromeUtils.import("resource://testing-common/mailnews/nntpd.js");
+var {
+  fsDebugAll,
+  gThreadManager,
+  nsMailServer,
+} = ChromeUtils.import("resource://testing-common/mailnews/maild.js", null);
+var {
+  newsArticle,
+  NNTP_Giganews_handler,
+  NNTP_RFC2980_handler,
+  NNTP_RFC4643_extension,
+  NNTP_RFC977_handler,
+  nntpDaemon,
+} = ChromeUtils.import("resource://testing-common/mailnews/nntpd.js", null);
 
 var kSimpleNewsArticle =
-  "From: John Doe <john.doe@example.com>\n"+
-  "Date: Sat, 24 Mar 1990 10:59:24 -0500\n"+
-  "Newsgroups: test.subscribe.simple\n"+
-  "Subject: H2G2 -- What does it mean?\n"+
-  "Message-ID: <TSS1@nntp.invalid>\n"+
-  "\n"+
+  "From: John Doe <john.doe@example.com>\n" +
+  "Date: Sat, 24 Mar 1990 10:59:24 -0500\n" +
+  "Newsgroups: test.subscribe.simple\n" +
+  "Subject: H2G2 -- What does it mean?\n" +
+  "Message-ID: <TSS1@nntp.invalid>\n" +
+  "\n" +
   "What does the acronym H2G2 stand for? I've seen it before...\n";
 
 // The groups to set up on the fake server.
 // It is an array of tuples, where the first element is the group name and the
 // second element is whether or not we should subscribe to it.
 var groups = [
   ["misc.test", false],
   ["test.empty", false],
   ["test.subscribe.empty", true],
   ["test.subscribe.simple", true],
-  ["test.filter", true]
+  ["test.filter", true],
 ];
 // Sets up the NNTP daemon object for use in fake server
 function setupNNTPDaemon() {
   var daemon = new nntpDaemon();
 
-  groups.forEach(function (element) {
+  groups.forEach(function(element) {
     daemon.addGroup(element[0]);
   });
 
   var auto_add = do_get_file("postings/auto-add/");
   var files = [];
   var enumerator = auto_add.directoryEntries;
   while (enumerator.hasMoreElements())
     files.push(enumerator.getNext().QueryInterface(Ci.nsIFile));
 
-  files.sort(function (a, b) {
+  files.sort(function(a, b) {
     if (a.leafName == b.leafName) return 0;
     return a.leafName < b.leafName ? -1 : 1;
   });
 
-  files.forEach(function (file) {
+  files.forEach(function(file) {
       var fstream = Cc["@mozilla.org/network/file-input-stream;1"]
                       .createInstance(Ci.nsIFileInputStream);
       var sstream = Cc["@mozilla.org/scriptableinputstream;1"]
                       .createInstance(Ci.nsIScriptableInputStream);
       fstream.init(file, -1, 0, 0);
       sstream.init(fstream);
 
       var post = "";
@@ -88,34 +99,34 @@ function makeServer(handler, daemon) {
 }
 
 // Enable strict threading
 Services.prefs.setBoolPref("mail.strict_threading", true);
 
 
 // Make sure we don't try to use a protected port. I like adding 1024 to the
 // default port when doing so...
-var NNTP_PORT = 1024+119;
+var NNTP_PORT = 1024 + 119;
 
 var _server = null;
 var _account = null;
 
 function subscribeServer(incomingServer) {
   // Subscribe to newsgroups
   incomingServer.QueryInterface(Ci.nsINntpIncomingServer);
-  groups.forEach(function (element) {
+  groups.forEach(function(element) {
       if (element[1])
         incomingServer.subscribeToNewsgroup(element[0]);
     });
   // Only allow one connection
   incomingServer.maximumConnectionsNumber = 1;
 }
 
 // Sets up the client-side portion of fakeserver
-function setupLocalServer(port, host="localhost") {
+function setupLocalServer(port, host = "localhost") {
   if (_server != null)
     return _server;
   let serverAndAccount =
     localAccountUtils.create_incoming_server_and_account("nntp", port, null,
       null, host);
   let server = serverAndAccount.server;
   subscribeServer(server);
 
@@ -136,27 +147,27 @@ function setupProtocolTest(port, newsUrl
     url = URLCreator.newURI(newsUrl);
   }
 
   var newsServer = incomingServer;
   if (!newsServer)
     newsServer = setupLocalServer(port);
 
   var listener = {
-    onStartRequest : function () {},
-    onStopRequest : function ()  {
+    onStartRequest() {},
+    onStopRequest() {
       if (!this.called) {
         this.called = true;
         newsServer.closeCachedConnections();
         this.called = false;
       }
     },
-    onDataAvailable : function () {},
+    onDataAvailable() {},
     QueryInterface: ChromeUtils.generateQI(["nsIStreamListener"]),
-  }
+  };
   listener.called = false;
   newsServer.loadNewsUrl(url, null, listener);
 }
 
 function create_post(baseURL, file) {
   var url = URLCreator.newURI(baseURL);
   url.QueryInterface(Ci.nsINntpUrl);
 
@@ -181,17 +192,17 @@ function resetFolder(folder) {
   dump("resetting folder\n");
   folder.msgDatabase = null;
 }
 
 function do_check_transaction(real, expected) {
   // real.them may have an extra QUIT on the end, where the stream is only
   // closed after we have a chance to process it and not them. We therefore
   // excise this from the list
-  if (real.them[real.them.length-1] == "QUIT")
+  if (real.them[real.them.length - 1] == "QUIT")
     real.them.pop();
 
   Assert.equal(real.them.join(","), expected.join(","));
   dump("Passed test " + test + "\n");
 }
 
 function make_article(file) {
   var fstream = Cc["@mozilla.org/network/file-input-stream;1"]
@@ -214,34 +225,34 @@ function make_article(file) {
 var articleTextListener = {
   data: "",
   finished: false,
 
   QueryInterface:
     ChromeUtils.generateQI([Ci.nsIStreamListener, Ci.nsIRequestObserver]),
 
   // nsIRequestObserver
-  onStartRequest: function(aRequest, aContext) {
+  onStartRequest(aRequest, aContext) {
   },
-  onStopRequest: function(aRequest, aContext, aStatusCode) {
+  onStopRequest(aRequest, aContext, aStatusCode) {
     Assert.equal(aStatusCode, 0);
 
     // Reduce any \r\n to just \n so we can do a good comparison on any
     // platform.
     this.data = this.data.replace(/\r\n/g, "\n");
     this.finished = true;
   },
 
   // nsIStreamListener
-  onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
+  onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount) {
     let scriptStream = Cc["@mozilla.org/scriptableinputstream;1"]
                          .createInstance(Ci.nsIScriptableInputStream);
 
     scriptStream.init(aInputStream);
 
     this.data += scriptStream.read(aCount);
-  }
+  },
 };
 
 registerCleanupFunction(function() {
   load("../../../resources/mailShutdown.js");
 });
 
--- a/mailnews/news/test/unit/test_biff.js
+++ b/mailnews/news/test/unit/test_biff.js
@@ -1,11 +1,12 @@
 // This tests that we can execute biff properly, specifically that filters are
 // run during biff, producing correct counts.
 
+/* import-globals-from ../../../test/resources/filterTestUtils.js */
 load("../../../resources/filterTestUtils.js");
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 function run_test() {
   // Set up the server and add in filters
   let daemon = setupNNTPDaemon();
   let server = makeServer(NNTP_RFC2980_handler, daemon);
@@ -25,20 +26,22 @@ function run_test() {
   filters.loggingEnabled = true;
   createFilter(filters, "subject", "Odd", "read");
   localserver.setFilterList(filters);
 
   // This is a bit hackish, but we don't have any really functional callbacks
   // for biff. Instead, we use the notifier to look for all 7 messages to be
   // added and take that as our sign that the download is finished.
   let expectCount = 7, seen = 0;
-  let listener = { msgAdded: function() {
-    if (++seen == expectCount)
-      localserver.closeCachedConnections();
-    }};
+  let listener = {
+    msgAdded() {
+      if (++seen == expectCount)
+        localserver.closeCachedConnections();
+    },
+  };
   MailServices.mfn.addListener(listener, Ci.nsIMsgFolderNotificationService.msgAdded);
   localserver.performBiff(null);
   server.performTest();
   MailServices.mfn.removeListener(listener);
 
   // We marked, via our filters, one of the messages read. So if we do not
   // have 1 read message, either we're not running the filters on biff, or the
   // filters aren't working. This is disambiguated by the test_filter.js test.
--- a/mailnews/news/test/unit/test_bug37465.js
+++ b/mailnews/news/test/unit/test_bug37465.js
@@ -1,12 +1,11 @@
 // Bug 37465 -- assertions with no accounts
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function run_test() {
   var daemon = setupNNTPDaemon();
   var server = makeServer(NNTP_RFC2980_handler, daemon);
   server.start();
 
   // Correct URI?
   let uri = Services.io.newURI("news://localhost:" + server.port +
--- a/mailnews/news/test/unit/test_bug403242.js
+++ b/mailnews/news/test/unit/test_bug403242.js
@@ -1,31 +1,30 @@
 // Bug 403242 stems from invalid message ids
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
 var daemon, localserver, server;
 
 function run_test() {
   daemon = setupNNTPDaemon();
   daemon.addGroup("test1");
   daemon.addArticle(make_article(do_get_file("postings/bug403242.eml")));
   server = makeServer(NNTP_RFC2980_handler, daemon);
   server.start();
   localserver = setupLocalServer(server.port);
   localserver.subscribeToNewsgroup("test1");
 
   let folder = localserver.rootFolder.getChildNamed("test1");
   folder.getNewMessages(null, {
-    OnStopRunningUrl: function () { localserver.closeCachedConnections(); }});
+    OnStopRunningUrl() { localserver.closeCachedConnections(); },
+  });
   server.performTest();
 
   // Fetch the message
   let uri = folder.generateMessageURI(1);
-  var msgService = Cc['@mozilla.org/messenger/messageservice;1?type=news']
+  var msgService = Cc["@mozilla.org/messenger/messageservice;1?type=news"]
                      .getService(Ci.nsIMsgMessageService);
 
   // Does the URL lie to us?
   let outObj = { value: null };
   msgService.GetUrlForUri(uri, outObj, null);
   let neckoUrl = outObj.value.QueryInterface(Ci.nsINntpUrl);
   Assert.equal(neckoUrl.newsAction, Ci.nsINntpUrl.ActionFetchArticle);
 
--- a/mailnews/news/test/unit/test_bug540288.js
+++ b/mailnews/news/test/unit/test_bug540288.js
@@ -1,51 +1,48 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* Tests that an empty cache entry doesn't return an empty message for news. */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
 // The basic daemon to use for testing nntpd.js implementations
 var daemon = setupNNTPDaemon();
 
 var server;
 var localserver;
 
-var streamListener =
-{
+var streamListener = {
   _data: "",
 
   QueryInterface:
     ChromeUtils.generateQI([Ci.nsIStreamListener, Ci.nsIRequestObserver]),
 
   // nsIRequestObserver
-  onStartRequest: function(aRequest, aContext) {
+  onStartRequest(aRequest, aContext) {
   },
-  onStopRequest: function(aRequest, aContext, aStatusCode) {
+  onStopRequest(aRequest, aContext, aStatusCode) {
     Assert.equal(aStatusCode, 0);
 
     // Reduce any \r\n to just \n so we can do a good comparison on any
     // platform.
     var reduced = this._data.replace(/\r\n/g, "\n");
     Assert.equal(reduced, kSimpleNewsArticle);
 
     // We must finish closing connections and tidying up after a timeout
     // so that the thread has time to unwrap itself.
     do_timeout(0, doTestFinished);
   },
 
   // nsIStreamListener
-  onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
+  onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount) {
     let scriptStream = Cc["@mozilla.org/scriptableinputstream;1"]
                          .createInstance(Ci.nsIScriptableInputStream);
 
     scriptStream.init(aInputStream);
 
     this._data += scriptStream.read(aCount);
-  }
+  },
 };
 
 function doTestFinished() {
     localserver.closeCachedConnections();
 
     server.stop();
 
     var thread = gThreadManager.currentThread;
@@ -62,26 +59,27 @@ function run_test() {
   localserver = setupLocalServer(server.port);
   var uri = Services.io.newURI("news://localhost:" + server.port + "/TSS1%40nntp.test");
 
   try {
     // Add an empty message to the cache
     MailServices.nntp
                 .cacheStorage
                 .asyncOpenURI(uri, "", Ci.nsICacheStorage.OPEN_NORMALLY, {
-      onCacheEntryAvailable: function(cacheEntry, isNew, appCache, status) {
+      onCacheEntryAvailable(cacheEntry, isNew, appCache, status) {
         Assert.equal(status, Cr.NS_OK);
 
         cacheEntry.markValid();
 
         // Get the folder and new mail
         var folder = localserver.rootFolder.getChildNamed("test.subscribe.simple");
         folder.clearFlag(Ci.nsMsgFolderFlags.Offline);
         folder.getNewMessages(null, {
-          OnStopRunningUrl: function () { localserver.closeCachedConnections(); }});
+          OnStopRunningUrl() { localserver.closeCachedConnections(); },
+        });
         server.performTest();
 
         Assert.equal(folder.getTotalMessages(false), 1);
         Assert.ok(folder.hasNewMessages);
 
         server.resetTest();
 
         var message = folder.firstNewMessage;
@@ -89,18 +87,18 @@ function run_test() {
         var messageUri = folder.getUriForMsg(message);
 
         MailServices.nntp
                     .QueryInterface(Ci.nsIMsgMessageService)
                     .DisplayMessage(messageUri, streamListener, null, null, null, {});
 
         // Get the server to run
         server.performTest();
-      }
+      },
     });
 
     do_test_pending();
 
   } catch (e) {
     server.stop();
     do_throw(e);
   }
-};
+}
--- a/mailnews/news/test/unit/test_bug695309.js
+++ b/mailnews/news/test/unit/test_bug695309.js
@@ -10,31 +10,32 @@
 //    response.
 // 6. This causes, in particular, GROUP to read the logon string as the response
 //    (where sprintf clears everything to 0), and AUTHINFO to think credentials
 //    are wrong. The bug's description is then caused by the next read seeing
 //    a large number of (not really) new messages.
 // For the purposes of this test, we read enough to see if the group command is
 // being misread or not, as it is complicated enough.
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/alertTestUtils.js");
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var daemon, localserver, server;
-var killConnection = false;
 var highWater = 0;
 
 var tests = [
   test_newMsgs,
   trigger_bug,
-  cleanUp
+  cleanUp,
 ];
 
 function* test_newMsgs() {
   // Start by initializing the folder, and mark some messages as read.
   let folder = localserver.rootFolder.getChildNamed("test.filter");
   Assert.equal(folder.getTotalMessages(false), 0);
   folder.getNewMessages(null, asyncUrlListener);
   // Do another folder to use up both connections
@@ -60,26 +61,26 @@ function* trigger_bug() {
   // load of the folder in question. This second load should, if the bug is
   // present, be overwritten with one from the load queue that causes the
   // confusion. It then loads it again, and should (before the patch that fixes
   // this) read the 200 logon instead of the 211 group.
   let folder = localserver.rootFolder.getChildNamed("test.filter");
   localserver.performExpand(null);
   // We also need a callback to know that folders have been loaded.
   let folderListener = {
-    OnItemEvent: function (item, event) {
+    OnItemEvent(item, event) {
       dump(event + " triggered for " + item.prettyName + "!\n\n\n");
       if (event == "FolderLoaded" &&
           item.prettyName == "test.subscribe.simple") {
         folder.getNewMessages(null, asyncUrlListener);
       } else if (event == "FolderLoaded" && item == folder) {
         async_driver();
       }
     },
-    QueryInterface: ChromeUtils.generateQI([Ci.nsIFolderListener])
+    QueryInterface: ChromeUtils.generateQI([Ci.nsIFolderListener]),
   };
   MailServices.mailSession.AddFolderListener(folderListener, Ci.nsIFolderListener.event);
   // Again, two things will need to be listened for
   yield false;
   yield false;
   Assert.equal(folder.msgDatabase.dBFolderInfo.highWater, highWater);
   yield true;
 }
--- a/mailnews/news/test/unit/test_filter.js
+++ b/mailnews/news/test/unit/test_filter.js
@@ -1,9 +1,8 @@
-////////////////////////////////////////////////////////////////////////////////
 // Tests for the filtering code of NNTP. The same tests are run for each of the
 // different NNTP setups, to test code in a variety of cases.
 //
 // Different suites:
 // * Perfect 3977 compliance (not tested)
 // * Perfect 2980 compliance (XOVER and XHDR work)
 // * Giganews compliance (XHDR doesn't work for practical purposes)
 // * Only 977 compliance (no XOVER support)
@@ -11,111 +10,111 @@
 // * Test that the following headers trigger:
 //   - Subject
 //   - From
 //   - Date
 //   - Size
 //   - Message-ID (header retrievable by XOVER)
 //   - User-Agent (header not retrievable by XHDR)
 // * Test all actions
-////////////////////////////////////////////////////////////////////////////////
 
+/* import-globals-from ../../../test/resources/filterTestUtils.js */
 load("../../../resources/filterTestUtils.js");
 
 // These are the expected results for testing filter triggers
 var attribResults = {
-  "1@regular.invalid" : ["isRead", false],
-  "2@regular.invalid" : ["isRead", true],
-  "3@regular.invalid" : ["isRead", true],
-  "4@regular.invalid" : ["isRead", true],
-  "5@regular.invalid" : ["isRead", true],
-  "6.odd@regular.invalid" : ["isRead", true],
-  "7@regular.invalid" : ["isRead", true],
-  "8.unread@regular.invalid" : ["isRead", true]
+  "1@regular.invalid": ["isRead", false],
+  "2@regular.invalid": ["isRead", true],
+  "3@regular.invalid": ["isRead", true],
+  "4@regular.invalid": ["isRead", true],
+  "5@regular.invalid": ["isRead", true],
+  "6.odd@regular.invalid": ["isRead", true],
+  "7@regular.invalid": ["isRead", true],
+  "8.unread@regular.invalid": ["isRead", true],
 };
 function testAttrib(handler, daemon, localserver) {
   var server = makeServer(handler, daemon);
   server.setDebugLevel(fsDebugAll);
   server.start();
   localserver.port = server.port;
 
   // Get the folder and force filters to run
   var folder = localserver.rootFolder.getChildNamed("test.filter");
   folder.getNewMessages(null, {
-    OnStopRunningUrl: function () { localserver.closeCachedConnections() }});
+    OnStopRunningUrl() { localserver.closeCachedConnections(); },
+  });
   server.performTest();
 
   var headerEnum = folder.messages;
   var headers = [];
   while (headerEnum.hasMoreElements())
     headers.push(headerEnum.getNext().QueryInterface(Ci.nsIMsgDBHdr));
 
-  try
-  {
+  try {
     Assert.equal(headers.length, 8);
     for (var header of headers) {
       var id = header.messageId;
-      dump("Testing message "+id+"\n");
+      dump("Testing message " + id + "\n");
       Assert.equal(header[attribResults[id][0]], attribResults[id][1]);
     }
   } catch (e) {
     print(server.playTransaction().them);
     throw e;
   } finally {
     server.stop();
   }
 
   resetFolder(folder);
 }
 
 // These are the results for testing actual actions
 var actionResults = {
-  "1@regular.invalid" : ["priority", 6],
+  "1@regular.invalid": ["priority", 6],
   // "2@regular.invalid" should not be in database
-  "3@regular.invalid" : function (header, folder) {
+  "3@regular.invalid": function(header, folder) {
     var flags = folder.msgDatabase.GetThreadContainingMsgHdr(header).flags;
     var ignored = Ci.nsMsgMessageFlags.Ignored;
     // This is checking the thread's kill flag
     return (flags & ignored) == ignored;
   },
-  "4@regular.invalid" : function (header, folder) {
+  "4@regular.invalid": function(header, folder) {
     var flags = folder.msgDatabase.GetThreadContainingMsgHdr(header).flags;
     var watched = Ci.nsMsgMessageFlags.Watched;
     // This is checking the thread's watch flag
     return (flags & watched) == watched;
   },
-  "5@regular.invalid" : ["isFlagged", true],
-  "6.odd@regular.invalid" : ["isRead", false],
-  "7@regular.invalid" : function (header, folder) {
+  "5@regular.invalid": ["isFlagged", true],
+  "6.odd@regular.invalid": ["isRead", false],
+  "7@regular.invalid": function(header, folder) {
     return header.getStringProperty("keywords") == "tag";
   },
-  "8.unread@regular.invalid" : ["isRead", false]
+  "8.unread@regular.invalid": ["isRead", false],
 };
 function testAction(handler, daemon, localserver) {
   var server = makeServer(handler, daemon);
   server.start();
   localserver.port = server.port;
 
   // Get the folder and force filters to run
   var folder = localserver.rootFolder.getChildNamed("test.filter");
   folder.getNewMessages(null, {
-    OnStopRunningUrl: function () { localserver.closeCachedConnections() }});
+    OnStopRunningUrl() { localserver.closeCachedConnections(); },
+  });
   server.performTest();
 
   var headerEnum = folder.messages;
   var headers = [];
   while (headerEnum.hasMoreElements())
     headers.push(headerEnum.getNext().QueryInterface(Ci.nsIMsgDBHdr));
 
-  try
-  {
+  try {
     Assert.equal(headers.length, 7);
     for (var header of headers) {
       var id = header.messageId;
-      dump("Testing message "+id+"\n");
+      dump("Testing message " + id + "\n");
       if (actionResults[id] instanceof Array)
         Assert.equal(header[actionResults[id][0]], actionResults[id][1]);
       else
         Assert.ok(actionResults[id](header, folder));
     }
   } catch (e) {
     print(server.playTransaction().them);
     throw e;
@@ -133,45 +132,45 @@ function run_test() {
   // Set up the server and add in filters
   var daemon = setupNNTPDaemon();
   var localserver = setupLocalServer(NNTP_PORT);
   var serverFilters = localserver.getFilterList(null);
 
   createFilter(serverFilters, "subject", "Odd", "read");
   createFilter(serverFilters, "from", "Odd Person", "read");
   // A PRTime is the time in μs, but a JS date is time in ms.
-  createFilter(serverFilters, "date", new Date(2000, 0, 1)*1000, "read");
+  createFilter(serverFilters, "date", new Date(2000, 0, 1) * 1000, "read");
   createFilter(serverFilters, "size", 2, "read");
   createFilter(serverFilters, "message-id", "odd", "read");
   createFilter(serverFilters, "user-agent", "Odd/1.0", "read");
   createFilter(serverFilters, "message-id", "8.unread", "read");
   localserver.setFilterList(serverFilters);
 
-  handlers.forEach( function (handler) {
+  handlers.forEach(function(handler) {
     testAttrib(handler, daemon, localserver);
   });
 
   // Now we test folder-filters... and actions
   // Clear out the server filters
   while (serverFilters.filterCount > 0)
     serverFilters.removeFilterAt(0);
   localserver.setFilterList(serverFilters);
 
   var folder = localserver.rootFolder.getChildNamed("test.filter");
   var folderFilters = folder.getFilterList(null);
   createFilter(folderFilters, "subject", "First", "priority");
   createFilter(folderFilters, "subject", "Odd", "delete");
   createFilter(folderFilters, "from", "Odd Person", "kill");
-  createFilter(folderFilters, "date", new Date(2000, 0, 1)*1000, "watch");
+  createFilter(folderFilters, "date", new Date(2000, 0, 1) * 1000, "watch");
   createFilter(folderFilters, "size", 2, "flag");
   createFilter(folderFilters, "message-id", "odd", "stop");
   // This shouldn't be hit, because of the previous filter
   createFilter(folderFilters, "message-id", "6.odd", "read");
   createFilter(folderFilters, "user-agent", "Odd/1.0", "tag");
   createFilter(folderFilters, "message-id", "8.unread", "read");
   createFilter(folderFilters, "message-id", "8.unread", "unread");
   folderFilters.loggingEnabled = true;
   folder.setFilterList(folderFilters);
 
-  handlers.forEach( function (handler) {
+  handlers.forEach(function(handler) {
     testAction(handler, daemon, localserver);
   });
 }
--- a/mailnews/news/test/unit/test_getNewsMessage.js
+++ b/mailnews/news/test/unit/test_getNewsMessage.js
@@ -2,56 +2,54 @@
 /*
  * Tests:
  * - getNewMessages for a newsgroup folder (single message).
  * - DisplayMessage for a newsgroup message
  *   - Downloading a single message and checking content in stream is correct.
  */
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 // The basic daemon to use for testing nntpd.js implementations
 var daemon = setupNNTPDaemon();
 
 var server;
 var localserver;
 
-var streamListener =
-{
+var streamListener = {
   _data: "",
 
   QueryInterface:
     ChromeUtils.generateQI([Ci.nsIStreamListener, Ci.nsIRequestObserver]),
 
   // nsIRequestObserver
-  onStartRequest: function(aRequest, aContext) {
+  onStartRequest(aRequest, aContext) {
   },
-  onStopRequest: function(aRequest, aContext, aStatusCode) {
+  onStopRequest(aRequest, aContext, aStatusCode) {
     Assert.equal(aStatusCode, 0);
 
     // Reduce any \r\n to just \n so we can do a good comparison on any
     // platform.
     var reduced = this._data.replace(/\r\n/g, "\n");
     Assert.equal(reduced, kSimpleNewsArticle);
 
     // We must finish closing connections and tidying up after a timeout
     // so that the thread has time to unwrap itself.
     do_timeout(0, doTestFinished);
   },
 
   // nsIStreamListener
-  onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
+  onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount) {
     let scriptStream = Cc["@mozilla.org/scriptableinputstream;1"]
                          .createInstance(Ci.nsIScriptableInputStream);
 
     scriptStream.init(aInputStream);
 
     this._data += scriptStream.read(aCount);
-  }
+  },
 };
 
 function doTestFinished() {
     localserver.closeCachedConnections();
 
     server.stop();
 
     var thread = gThreadManager.currentThread;
@@ -66,17 +64,18 @@ function run_test() {
   server.start();
   localserver = setupLocalServer(server.port);
 
   try {
     // Get the folder and new mail
     var folder = localserver.rootFolder.getChildNamed("test.subscribe.simple");
     folder.clearFlag(Ci.nsMsgFolderFlags.Offline);
     folder.getNewMessages(null, {
-      OnStopRunningUrl: function () { localserver.closeCachedConnections(); }});
+      OnStopRunningUrl() { localserver.closeCachedConnections(); },
+    });
     server.performTest();
 
     Assert.equal(folder.getTotalMessages(false), 1);
     Assert.ok(folder.hasNewMessages);
 
     server.resetTest();
 
     var message = folder.firstNewMessage;
@@ -87,9 +86,9 @@ function run_test() {
 
     do_test_pending();
 
     nntpService.DisplayMessage(messageUri, streamListener, null, null, null, {});
   } catch (e) {
     server.stop();
     do_throw(e);
   }
-};
+}
--- a/mailnews/news/test/unit/test_internalUris.js
+++ b/mailnews/news/test/unit/test_internalUris.js
@@ -1,85 +1,88 @@
 /* Tests internal URIs generated by various methods in the code base.
  * If you manually generate a news URI somewhere, please add it to this test.
  */
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/alertTestUtils.js");
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var dummyMsgWindow = {
   get statusFeedback() {
     return {
-      startMeteors: function () {},
-      stopMeteors: function () {
+      startMeteors() {},
+      stopMeteors() {
         async_driver();
       },
-      showProgress: function () {}
+      showProgress() {},
     };
   },
   get promptDialog() {
     return alertUtilsPrompts;
   },
   QueryInterface: ChromeUtils.generateQI([Ci.nsIMsgWindow,
-                                          Ci.nsISupportsWeakReference])
+                                          Ci.nsISupportsWeakReference]),
 };
 var daemon, localserver, server;
 
 var tests = [
   test_newMsgs,
   test_cancel,
   test_fetchMessage,
   test_search,
   test_grouplist,
   test_postMessage,
   test_escapedName,
-  cleanUp
+  cleanUp,
 ];
 
 var kCancelArticle =
-  "From: fake@acme.invalid\n"+
-  "Newsgroups: test.filter\n"+
-  "Subject: cancel <4@regular.invalid>\n"+
-  "References: <4@regular.invalid>\n"+
-  "Control: cancel <4@regular.invalid>\n"+
-  "MIME-Version: 1.0\n"+
-  "Content-Type: text/plain\n"+
-  "\n"+
+  "From: fake@acme.invalid\n" +
+  "Newsgroups: test.filter\n" +
+  "Subject: cancel <4@regular.invalid>\n" +
+  "References: <4@regular.invalid>\n" +
+  "Control: cancel <4@regular.invalid>\n" +
+  "MIME-Version: 1.0\n" +
+  "Content-Type: text/plain\n" +
+  "\n" +
   "This message was cancelled from within ";
 
 function* test_newMsgs() {
   // This tests nsMsgNewsFolder::GetNewsMessages via getNewMessages
   let folder = localserver.rootFolder.getChildNamed("test.filter");
   Assert.equal(folder.getTotalMessages(false), 0);
   folder.getNewMessages(null, asyncUrlListener);
   yield false;
   Assert.equal(folder.getTotalMessages(false), 8);
   yield true;
 }
 
+/* exported alert, confirmEx */
 // Prompts for cancel
 function alert(title, text) {}
-function confirmEx(title, text, flags) {  return 0; }
+function confirmEx(title, text, flags) { return 0; }
 
 function* test_cancel() {
   // This tests nsMsgNewsFolder::CancelMessage
   let folder = localserver.rootFolder.getChildNamed("test.filter");
   let db = folder.msgDatabase;
   let hdr = db.GetMsgHdrForKey(4);
 
   let folderListener = {
-    OnItemEvent: function(aEventFolder, aEvent) {
+    OnItemEvent(aEventFolder, aEvent) {
       if (aEvent == "DeleteOrMoveMsgCompleted") {
         MailServices.mailSession.RemoveFolderListener(this);
       }
-    }
+    },
   };
   MailServices.mailSession.AddFolderListener(folderListener, Ci.nsIFolderListener.event);
   folder.QueryInterface(Ci.nsIMsgNewsFolder)
         .cancelMessage(hdr, dummyMsgWindow);
   yield false;
 
   Assert.equal(folder.getTotalMessages(false), 7);
 
@@ -90,24 +93,23 @@ function* test_cancel() {
   Assert.ok(article.fullText.startsWith(kCancelArticle));
   yield true;
 }
 
 function* test_fetchMessage() {
   // Tests nsNntpService::CreateMessageIDURL via FetchMessage
   var statuscode = -1;
   let streamlistener = {
-    onDataAvailable: function() {},
-    onStartRequest: function() {
-    },
-    onStopRequest: function (aRequest, aContext, aStatus) {
+    onDataAvailable() {},
+    onStartRequest() {},
+    onStopRequest(aRequest, aContext, aStatus) {
       statuscode = aStatus;
     },
     QueryInterface: ChromeUtils.generateQI([Ci.nsIStreamListener,
-                                            Ci.nsIRequestObserver])
+                                            Ci.nsIRequestObserver]),
   };
   let folder = localserver.rootFolder.getChildNamed("test.filter");
   MailServices.nntp.fetchMessage(folder, 2, null, streamlistener, asyncUrlListener);
   yield false;
   Assert.equal(statuscode, Cr.NS_OK);
   yield true;
 }
 
@@ -116,45 +118,45 @@ function* test_search() {
   let folder = localserver.rootFolder.getChildNamed("test.filter");
   var searchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                         .createInstance(Ci.nsIMsgSearchSession);
   searchSession.addScopeTerm(Ci.nsMsgSearchScope.news, folder);
 
   let searchTerm = searchSession.createTerm();
   searchTerm.attrib = Ci.nsMsgSearchAttrib.Subject;
   let value = searchTerm.value;
-  value.str = 'First';
+  value.str = "First";
   searchTerm.value = value;
   searchTerm.op = Ci.nsMsgSearchOp.Contains;
   searchTerm.booleanAnd = false;
   searchSession.appendTerm(searchTerm);
 
   let hitCount;
   let searchListener = {
-    onSearchHit: function (dbHdr, folder) { hitCount++; },
-    onSearchDone: function (status) {
+    onSearchHit() { hitCount++; },
+    onSearchDone() {
       searchSession.unregisterListener(this);
       async_driver();
     },
-    onNewSearch: function() { hitCount = 0; }
+    onNewSearch() { hitCount = 0; },
   };
   searchSession.registerListener(searchListener);
 
   searchSession.search(null);
   yield false;
 
   Assert.equal(hitCount, 1);
   yield true;
 }
 
 function* test_grouplist() {
   // This tests nsNntpService::GetListOfGroupsOnServer
   let subserver = localserver.QueryInterface(Ci.nsISubscribableServer);
   let subscribeListener = {
-    OnDonePopulating: function () { async_driver(); }
+    OnDonePopulating() { async_driver(); },
   };
   subserver.subscribeListener = subscribeListener;
 
   function enumGroups(rootUri) {
     let hierarchy = subserver.getChildURIs(rootUri);
     let groups = [];
     for (let name of hierarchy) {
       if (subserver.isSubscribable(name))
@@ -188,23 +190,23 @@ function* test_postMessage() {
   MailServices.nntp.postMessage(do_get_file("postings/post2.eml"), "misc.test",
     localserver.key, asyncUrlListener, null);
   yield false;
   Assert.equal(daemon.getGroup("misc.test").keys.length, 1);
   yield true;
 }
 
 // Not tested because it requires UI, and this is insufficient, I think.
-function test_forwardInline() {
-  // This tests mime_parse_stream_complete via forwarding inline
-  let folder = localserver.rootFolder.getChildNamed("test.filter");
-  let hdr = folder.msgDatabase.GetMsgHdrForKey(1);
-  MailServices.compose.forwardMessage("a@b.invalid", hdr, null,
-    localserver, Ci.nsIMsgComposeService.kForwardInline);
-}
+// function test_forwardInline() {
+//   // This tests mime_parse_stream_complete via forwarding inline
+//   let folder = localserver.rootFolder.getChildNamed("test.filter");
+//   let hdr = folder.msgDatabase.GetMsgHdrForKey(1);
+//   MailServices.compose.forwardMessage("a@b.invalid", hdr, null,
+//     localserver, Ci.nsIMsgComposeService.kForwardInline);
+// }
 
 function* test_escapedName() {
   // This does a few tests to make sure our internal URIs work for newsgroups
   // with names that need escaping
   let evilName = "test.malformed&name";
   daemon.addGroup(evilName);
   daemon.addArticle(make_article(do_get_file("postings/bug670935.eml")));
   localserver.subscribeToNewsgroup(evilName);
@@ -213,24 +215,23 @@ function* test_escapedName() {
   let folder = localserver.rootFolder.getChildNamed(evilName);
   folder.getNewMessages(null, asyncUrlListener);
   yield false;
 
   // If we get here, we didn't crash--newsgroups unescape properly.
   // Load a message, to test news-message: URI unescaping
   var statuscode = -1;
   let streamlistener = {
-    onDataAvailable: function() {},
-    onStartRequest: function() {
-    },
-    onStopRequest: function (aRequest, aContext, aStatus) {
+    onDataAvailable() {},
+    onStartRequest() {},
+    onStopRequest(aRequest, aContext, aStatus) {
       statuscode = aStatus;
     },
     QueryInterface: ChromeUtils.generateQI([Ci.nsIStreamListener,
-                                            Ci.nsIRequestObserver])
+                                            Ci.nsIRequestObserver]),
   };
   MailServices.nntp.fetchMessage(folder, 1, null, streamlistener, asyncUrlListener);
   yield false;
   Assert.equal(statuscode, Cr.NS_OK);
   yield true;
 }
 
 function run_test() {
--- a/mailnews/news/test/unit/test_newsAutocomplete.js
+++ b/mailnews/news/test/unit/test_newsAutocomplete.js
@@ -3,35 +3,30 @@
  *
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/
  *
  * ***** END LICENSE BLOCK ***** */
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-// The basic daemon to use for testing nntpd.js implementations
-var gDaemon = setupNNTPDaemon();
-
-var ACR = Ci.nsIAutoCompleteResult;
-
 function acObserver() {}
 
 acObserver.prototype = {
   _search: null,
   _result: null,
 
-  onSearchResult: function (aSearch, aResult) {
+  onSearchResult(aSearch, aResult) {
     this._search = aSearch;
     this._result = aResult;
-  }
+  },
 };
 
 function run_test() {
-  let localserver = setupLocalServer(119);
+  setupLocalServer(119);
 
   // create identity
   let identity = MailServices.accounts.createIdentity();
   _account.addIdentity(identity);
 
   let acs = Cc["@mozilla.org/autocomplete/search;1?name=news"]
     .getService(Ci.nsIAutoCompleteSearch);
   let obs;
@@ -97,9 +92,9 @@ function run_test() {
 
   obs = new acObserver();
   acs.startSearch("empty", paramsF, null, obs);
   Assert.equal(obs._result.matchCount, 1);
 
   let thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
-};
+}
--- a/mailnews/news/test/unit/test_nntpContentLength.js
+++ b/mailnews/news/test/unit/test_nntpContentLength.js
@@ -22,17 +22,18 @@ function run_test() {
   server.start();
   localserver = setupLocalServer(server.port);
 
   try {
     // Get the folder and new mail
     let folder = localserver.rootFolder.getChildNamed("test.subscribe.simple");
     folder.clearFlag(Ci.nsMsgFolderFlags.Offline);
     folder.getNewMessages(null, {
-      OnStopRunningUrl: function () { localserver.closeCachedConnections(); }});
+      OnStopRunningUrl() { localserver.closeCachedConnections(); },
+    });
     server.performTest();
 
     Assert.equal(folder.getTotalMessages(false), 1);
     Assert.ok(folder.hasNewMessages);
 
     server.resetTest();
 
     // Get the message URI
@@ -54,23 +55,22 @@ function run_test() {
                                                  null,
                                                  Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                                                  Ci.nsIContentPolicy.TYPE_OTHER);
     Assert.equal(channel.contentLength, kSimpleNewsArticle.length);
 
     // Now try an attachment. &part=1.2
     // XXX the message doesn't really have an attachment
     let attachmentURL = Services.io.newURI(neckoURL.value.spec + "&part=1.2");
-    let attachmentChannel = Services.io.newChannelFromURI2(attachmentURL,
-                                                           null,
-                                                           Services.scriptSecurityManager.getSystemPrincipal(),
-                                                           null,
-                                                           Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                                                           Ci.nsIContentPolicy.TYPE_OTHER);
+    Services.io.newChannelFromURI2(attachmentURL,
+                                   null,
+                                   Services.scriptSecurityManager.getSystemPrincipal(),
+                                   null,
+                                   Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+                                   Ci.nsIContentPolicy.TYPE_OTHER);
     // Currently attachments have their content length set to the length of the
     // entire message
     Assert.equal(channel.contentLength, kSimpleNewsArticle.length);
-  }
-  catch (e) {
+  } catch (e) {
     server.stop();
     do_throw(e);
   }
-};
+}
--- a/mailnews/news/test/unit/test_nntpGroupPassword.js
+++ b/mailnews/news/test/unit/test_nntpGroupPassword.js
@@ -1,25 +1,22 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Authentication tests for NNTP (based on RFC4643).
  */
 
 // The basic daemon to use for testing nntpd.js implementations
 var daemon = setupNNTPDaemon();
 
-// Define these up here for checking with the transaction
-var test = null;
-
-add_task(async function () {
+add_task(async function() {
   await Services.logins.initializationPromise;
 
   daemon.groupCredentials = {
     "test.subscribe.empty": ["group1", "pass1"],
-    "test.filter": ["group2", "pass2"]
+    "test.filter": ["group2", "pass2"],
   };
 
   var server = makeServer(NNTP_RFC4643_extension, daemon);
   server.start();
   var localserver = setupLocalServer(server.port);
   localserver.singleSignon = false;
 
   // Add passwords to the manager
@@ -34,47 +31,43 @@ add_task(async function () {
   loginInfo2.init(serverURI + "test.filter", null,
     serverURI + "test.filter", "group2", "pass2", "", "");
   Services.logins.addLogin(loginInfo2);
   try {
     var prefix = "news://localhost:" + server.port + "/";
     var transaction;
 
     test = "per-group password part 1";
-    setupProtocolTest(server.port, prefix+"test.subscribe.empty", localserver);
+    setupProtocolTest(server.port, prefix + "test.subscribe.empty", localserver);
     server.performTest();
     transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER",
                                        "GROUP test.subscribe.empty",
                                        "AUTHINFO user group1",
                                        "AUTHINFO pass pass1",
                                        "GROUP test.subscribe.empty"]);
 
     test = "per-group password part 2";
     server.resetTest();
-    setupProtocolTest(server.port, prefix+"test.filter", localserver);
+    setupProtocolTest(server.port, prefix + "test.filter", localserver);
     server.performTest();
     transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER", "GROUP test.filter",
                                        "AUTHINFO user group2",
                                        "AUTHINFO pass pass2",
                                        "GROUP test.filter",
                                        "XOVER 1-8"]);
 
   } catch (e) {
-    dump("NNTP Protocol test "+test+" failed for type RFC 977:\n");
+    dump("NNTP Protocol test " + test + " failed for type RFC 977:\n");
     try {
       var trans = server.playTransaction();
-     if (trans)
-        dump("Commands called: "+uneval(trans)+"\n");
+      if (trans)
+        dump("Commands called: " + uneval(trans) + "\n");
     } catch (exp) {}
     do_throw(e);
   }
   server.stop();
 
   var thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/news/test/unit/test_nntpPassword.js
+++ b/mailnews/news/test/unit/test_nntpPassword.js
@@ -1,55 +1,49 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Authentication tests for NNTP (based on RFC4643).
  *
  * Note: Logins for newsgroup servers for 1.8 were stored with either the
  * default port or the SSL default port. Nothing else!
  */
 
+/* import-globals-from ../../../test/resources/passwordStorage.js */
 load("../../../resources/passwordStorage.js");
 
 // The basic daemon to use for testing nntpd.js implementations
 var daemon = setupNNTPDaemon();
 
-// Define these up here for checking with the transaction
-var test = null;
-
-add_task(async function () {
+add_task(async function() {
   // Prepare files for passwords (generated by a script in bug 1018624).
   await setupForPassword("signons-mailnews1.8.json");
 
   var server = makeServer(NNTP_RFC4643_extension, daemon);
   server.start();
 
   try {
     var prefix = "news://localhost:" + server.port + "/";
     var transaction;
 
     // Test - group subscribe listing
     test = "news:*";
-    setupProtocolTest(server.port, prefix+"*");
+    setupProtocolTest(server.port, prefix + "*");
     server.performTest();
     transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER", "LIST",
                                        "AUTHINFO user testnews",
                                        "AUTHINFO pass newstest", "LIST"]);
 
   } catch (e) {
-    dump("NNTP Protocol test "+test+" failed for type RFC 977:\n");
+    dump("NNTP Protocol test " + test + " failed for type RFC 977:\n");
     try {
       var trans = server.playTransaction();
-     if (trans)
-        dump("Commands called: "+trans.them+"\n");
+      if (trans)
+        dump("Commands called: " + trans.them + "\n");
     } catch (exp) {}
     do_throw(e);
   }
   server.stop();
 
   var thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/news/test/unit/test_nntpPassword2.js
+++ b/mailnews/news/test/unit/test_nntpPassword2.js
@@ -4,25 +4,23 @@
  * details have changed (e.g. realhostname is different from hostname).
  *
  * Note: Logins for newsgroup servers for 1.8 were stored with either the
  * default port or the SSL default port. Nothing else!
  */
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
+/* import-globals-from ../../../test/resources/passwordStorage.js */
 load("../../../resources/passwordStorage.js");
 
 // The basic daemon to use for testing nntpd.js implementations
 var daemon = setupNNTPDaemon();
 
-// Define these up here for checking with the transaction
-var test = null;
-
-add_task(async function () {
+add_task(async function() {
   let server = makeServer(NNTP_RFC4643_extension, daemon);
   server.start();
 
   // These preferences set up a local news server that has had its hostname
   // and username changed from the original settings. We can't do this by
   // function calls for this test as they would cause the password to be
   // forgotten when changing the hostname/username and this breaks the test.
   Services.prefs.setCharPref("mail.account.account1.server", "server1");
@@ -66,36 +64,32 @@ add_task(async function () {
     MailServices.accounts.LoadAccounts();
 
     // Create the incoming server with "original" details.
     var incomingServer = MailServices.accounts.getIncomingServer("server2");
 
     subscribeServer(incomingServer);
 
     // Now set up and run the tests
-    setupProtocolTest(server.port, prefix+"*", incomingServer);
+    setupProtocolTest(server.port, prefix + "*", incomingServer);
     server.performTest();
     var transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER", "LIST",
                                        "AUTHINFO user testnews",
                                        "AUTHINFO pass newstest", "LIST"]);
     incomingServer.QueryInterface(Ci.nsISubscribableServer)
                   .subscribeCleanup();
 
   } catch (e) {
-    dump("NNTP Protocol test "+test+" failed for type RFC 977:\n");
+    dump("NNTP Protocol test " + test + " failed for type RFC 977:\n");
     try {
       var trans = server.playTransaction();
-     if (trans)
-        dump("Commands called: "+trans.them+"\n");
+      if (trans)
+        dump("Commands called: " + trans.them + "\n");
     } catch (exp) {}
     do_throw(e);
   }
   server.stop();
 
   var thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/news/test/unit/test_nntpPassword3.js
+++ b/mailnews/news/test/unit/test_nntpPassword3.js
@@ -1,35 +1,35 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Extra tests for forgetting newsgroup usernames and passwords.
  */
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
+/* import-globals-from ../../../test/resources/passwordStorage.js */
 load("../../../resources/passwordStorage.js");
 
 var kUsername = "testnews";
 var kPassword = "newstest";
 var kProtocol = "nntp";
 var kHostname = "localhost";
 var kServerUrl = "news://" + kHostname;
 
-add_task(async function () {
+add_task(async function() {
   // Prepare files for passwords (generated by a script in bug 1018624).
-  await setupForPassword("signons-mailnews1.8.json")
+  await setupForPassword("signons-mailnews1.8.json");
 
   // Set up the basic accounts and folders.
   localAccountUtils.loadLocalMailAccount();
 
   var incomingServer = MailServices.accounts.createIncomingServer(null, kHostname,
                                                                   kProtocol);
 
-  var i;
   var count = {};
 
   // Test - Check there is a password to begin with...
   var logins = Services.logins.findLogins(count, kServerUrl, null, kServerUrl);
 
   Assert.equal(count.value, 1);
   Assert.equal(logins[0].username, kUsername);
   Assert.equal(logins[0].password, kPassword);
@@ -37,12 +37,8 @@ add_task(async function () {
   // Test - Remove the news password login via the incoming server
   incomingServer.forgetPassword();
 
   logins = Services.logins.findLogins(count, kServerUrl, null, kServerUrl);
 
   // should be no passwords left...
   Assert.equal(count.value, 0);
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/news/test/unit/test_nntpPasswordFailure.js
+++ b/mailnews/news/test/unit/test_nntpPasswordFailure.js
@@ -4,40 +4,42 @@
  *   - Have an invalid password in the password database.
  *   - Check we get a prompt asking what to do.
  *   - Check retry does what it should do.
  *   - Check cancel does what it should do.
  *   - Re-initiate connection, this time select enter new password, check that
  *     we get a new password prompt and can enter the password.
  */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
+/* import-globals-from ../../../test/resources/passwordStorage.js */
+/* import-globals-from ../../../test/resources/mailTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/alertTestUtils.js");
 load("../../../resources/passwordStorage.js");
 load("../../../resources/mailTestUtils.js");
 
-var test = null;
 var server;
 var daemon;
 var incomingServer;
 var folder;
 var attempt = 0;
 var count = {};
 var logins;
 
 var kUserName = "testnews";
 var kInvalidPassword = "newstest";
 var kValidPassword = "notallama";
 
-function alert(aDialogText, aText)
-{
+/* exported alert, confirmEx, promptUsernameAndPasswordPS */
+function alert(aDialogText, aText) {
   // The first few attempts may prompt about the password problem, the last
   // attempt shouldn't.
   Assert.ok(attempt < 4);
 
   // Log the fact we've got an alert, but we don't need to test anything here.
   dump("Alert Title: " + aDialogText + "\nAlert Text: " + aText + "\n");
 }
 
@@ -76,51 +78,49 @@ function promptUsernameAndPasswordPS(aPa
   }
   return false;
 }
 
 function getMail() {
   folder.getNewMessages(gDummyMsgWindow, urlListener);
 }
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       // On the last attempt, we should have successfully got one mail.
       Assert.equal(folder.getTotalMessages(false),
                    attempt == 4 ? 1 : 0);
 
       // If we've just cancelled, expect failure rather than success
       // because the server dropped the connection.
       dump("in onStopRunning, result = " + result + "\n");
-      //do_check_eq(result, attempt == 2 ? Cr.NS_ERROR_FAILURE : 0);
+      // do_check_eq(result, attempt == 2 ? Cr.NS_ERROR_FAILURE : 0);
       async_driver();
-    }
-    catch (e) {
+    } catch (e) {
       // If we have an error, clean up nicely before we throw it.
       server.stop();
 
       var thread = gThreadManager.currentThread;
       while (thread.hasPendingEvents())
         thread.processNextEvent(true);
 
       do_throw(e);
     }
-  }
+  },
 };
 
 // Definition of tests
 var tests = [
   getMail1,
   getMail2,
-  endTest
-]
+  endTest,
+];
 
 function* getMail1() {
   dump("\nGet Mail 1\n");
 
   // Now get mail
   getMail();
   yield false;
   dump("\nGot Mail 1\n");
@@ -155,18 +155,17 @@ function* endTest() {
                                       "news://localhost");
 
   Assert.equal(count.value, 1);
   Assert.equal(logins[0].username, kUserName);
   Assert.equal(logins[0].password, kValidPassword);
   yield true;
 }
 
-function run_test()
-{
+function run_test() {
   // Disable new mail notifications
   Services.prefs.setBoolPref("mail.biff.play_sound", false);
   Services.prefs.setBoolPref("mail.biff.show_alert", false);
   Services.prefs.setBoolPref("mail.biff.show_tray_icon", false);
   Services.prefs.setBoolPref("mail.biff.animate_dock_icon", false);
   Services.prefs.setBoolPref("signon.debug", true);
 
   // Prepare files for passwords (generated by a script in bug 1018624).
--- a/mailnews/news/test/unit/test_nntpPost.js
+++ b/mailnews/news/test/unit/test_nntpPost.js
@@ -3,19 +3,19 @@
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 function run_test() {
   var daemon = setupNNTPDaemon();
   var server = makeServer(NNTP_RFC977_handler, daemon);
   server.start();
   var localserver = setupLocalServer(server.port);
-  var listener = { OnStopRunningUrl: function () {
-    localserver.closeCachedConnections();
-  }};
+  var listener = {
+    OnStopRunningUrl() { localserver.closeCachedConnections(); },
+  };
 
   // Tests bug 484656.
   localserver.realHostName = localserver.hostName;
   localserver.hostName = "news.example.com";
 
   try {
     MailServices.nntp.postMessage(do_get_file("postings/post1.eml"), "test.empty",
       localserver.key, listener, null);
--- a/mailnews/news/test/unit/test_nntpProtocols.js
+++ b/mailnews/news/test/unit/test_nntpProtocols.js
@@ -6,27 +6,27 @@
 var defaultProtocolFlags =
   Ci.nsIProtocolHandler.URI_NORELATIVE |
   Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE |
   Ci.nsIProtocolHandler.ALLOWS_PROXY |
   Ci.nsIProtocolHandler.URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT |
   Ci.nsIProtocolHandler.URI_FORBIDS_COOKIE_ACCESS |
   Ci.nsIProtocolHandler.ORIGIN_IS_FULL_SPEC;
 
-var protocols =
-  [ { protocol: "news",
-      urlSpec: "news://user@localhost/",
-      defaultPort: Ci.nsINntpUrl.DEFAULT_NNTP_PORT
-    },
-    // XXX News secure protocol not working yet.
-    /*
-    { protocol: "snews",
-      urlSpec: "snews://user@localhost/",
-      defaultPort: Ci.nsINntpUrl.DEFAULT_NNTPS_PORT
-      } */];
+var protocols = [{
+  protocol: "news",
+  urlSpec: "news://user@localhost/",
+  defaultPort: Ci.nsINntpUrl.DEFAULT_NNTP_PORT,
+},
+// XXX News secure protocol not working yet.
+/* { protocol: "snews",
+  urlSpec: "snews://user@localhost/",
+  defaultPort: Ci.nsINntpUrl.DEFAULT_NNTPS_PORT
+} */
+];
 
 function run_test() {
   for (var part = 0; part < protocols.length; ++part) {
     print("protocol: " + protocols[part].protocol);
 
     var pH = Cc["@mozilla.org/network/protocol;1?name=" +
                 protocols[part].protocol]
                .createInstance(Ci.nsIProtocolHandler);
--- a/mailnews/news/test/unit/test_nntpProxy.js
+++ b/mailnews/news/test/unit/test_nntpProxy.js
@@ -27,13 +27,8 @@ add_task(async function findMessages() {
   await asyncUrlListener.promise;
   equal(folder.getTotalMessages(false), 8);
 });
 
 add_task(async function cleanUp() {
   NetworkTestUtils.shutdownServers();
   localserver.closeCachedConnections();
 });
-
-function run_test() {
-  run_next_test();
-}
-
--- a/mailnews/news/test/unit/test_nntpUrl.js
+++ b/mailnews/news/test/unit/test_nntpUrl.js
@@ -16,15 +16,15 @@ function getMessageHeaderFromUrl(aUrl) {
   return msgUrl.messageHeader;
 }
 
 function run_test() {
 
   // This is crash test for Bug 392729
   try {
     // msgkey is invalid for news:// protocol
-    let hdr = getMessageHeaderFromUrl("news://localhost:119" +
-                                      "/123@example.invalid?group=test.subscribe.simple&key=abcdefghijk");
+    getMessageHeaderFromUrl("news://localhost:119" +
+                            "/123@example.invalid?group=test.subscribe.simple&key=abcdefghijk");
     Assert.ok(false);
   } catch (e) {
     Assert.equal(e.result, Cr.NS_ERROR_MALFORMED_URI);
   }
 }
--- a/mailnews/news/test/unit/test_server.js
+++ b/mailnews/news/test/unit/test_server.js
@@ -1,183 +1,175 @@
-////////////////////////////////////////////////////////////////////////////////
 // Protocol tests for NNTP. These actually aren't too important, but their main
 // purpose is to make sure that maild is working properly and to provide
 // examples for how using maild. They also help make sure that I coded nntpd.js
 // right, both logically and for RFC compliance.
 // TODO:
 // * We need to hook up mochitest,
 // * TLS negotiation.
-////////////////////////////////////////////////////////////////////////////////
 
 // The basic daemon to use for testing nntpd.js implementations
 var daemon = setupNNTPDaemon();
 
-// Define these up here for checking with the transaction
-var test = null;
-
-////////////////////////////////////////////////////////////////////////////////
-//                             NNTP SERVER TESTS                              //
-////////////////////////////////////////////////////////////////////////////////
-// Functions in order as defined in nntpd.js. Each function tests the URLs    //
-// that are located over the implementation of nsNNTPProtocol::LoadURL and    //
-// added in bug 400331. Furthermore, they are tested in rough order as they   //
-// would be expected to be used in a session. If more URL types are modified, //
-// please add a corresponding type to the following tests.                    //
-// When adding new servers, only test the commands that become different for  //
-// each specified server, to keep down redudant tests.                        //
-////////////////////////////////////////////////////////////////////////////////
+// NNTP SERVER TESTS
+// -----------------
+// Functions in order as defined in nntpd.js. Each function tests the URLs
+// that are located over the implementation of nsNNTPProtocol::LoadURL and
+// added in bug 400331. Furthermore, they are tested in rough order as they
+// would be expected to be used in a session. If more URL types are modified,
+// please add a corresponding type to the following tests.
+// When adding new servers, only test the commands that become different for
+// each specified server, to keep down redudant tests.
 
 function testRFC977() {
   var server = makeServer(NNTP_RFC977_handler, daemon);
   server.start(NNTP_PORT);
 
   try {
-    var prefix = "news://localhost:"+NNTP_PORT+"/";
+    var prefix = "news://localhost:" + NNTP_PORT + "/";
     var transaction;
 
     // Test - group subscribe listing
     test = "news:*";
-    setupProtocolTest(NNTP_PORT, prefix+"*");
+    setupProtocolTest(NNTP_PORT, prefix + "*");
     server.performTest();
     transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER", "LIST"]);
 
     // Test - getting group headers
     test = "news:test.subscribe.empty";
     server.resetTest();
-    setupProtocolTest(NNTP_PORT, prefix+"test.subscribe.empty");
+    setupProtocolTest(NNTP_PORT, prefix + "test.subscribe.empty");
     server.performTest();
     transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER",
       "GROUP test.subscribe.empty"]);
 
     // Test - getting an article
     test = "news:MESSAGE_ID";
     server.resetTest();
-    setupProtocolTest(NNTP_PORT, prefix+"TSS1@nntp.invalid");
+    setupProtocolTest(NNTP_PORT, prefix + "TSS1@nntp.invalid");
     server.performTest();
     transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER",
         "ARTICLE <TSS1@nntp.invalid>"]);
 
     // Test - news expiration
     test = "news:GROUP?list-ids";
     server.resetTest();
-    setupProtocolTest(NNTP_PORT, prefix+"test.filter?list-ids");
+    setupProtocolTest(NNTP_PORT, prefix + "test.filter?list-ids");
     server.performTest();
     transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER",
         "listgroup test.filter"]);
 
     // Test - posting
     test = "news with post";
     server.resetTest();
     var url = create_post(prefix, "postings/post1.eml");
     setupProtocolTest(NNTP_PORT, url);
     server.performTest();
     transaction = server.playTransaction();
     do_check_transaction(transaction, ["MODE READER", "POST"]);
   } catch (e) {
-    dump("NNTP Protocol test "+test+" failed for type RFC 977:\n");
+    dump("NNTP Protocol test " + test + " failed for type RFC 977:\n");
     try {
       var trans = server.playTransaction();
      if (trans)
-        dump("Commands called: "+trans.them+"\n");
+        dump("Commands called: " + trans.them + "\n");
     } catch (exp) {}
     do_throw(e);
   }
   server.stop();
 
   var thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
 }
 
 function testConnectionLimit() {
   var server = makeServer(NNTP_RFC977_handler, daemon);
   server.start(NNTP_PORT);
 
-  var prefix = "news://localhost:"+NNTP_PORT+"/";
-  var transaction;
+  var prefix = "news://localhost:" + NNTP_PORT + "/";
 
   // To test make connections limit, we run two URIs simultaneously.
-  var url = URLCreator.newURI(prefix+"*");
+  var url = URLCreator.newURI(prefix + "*");
   _server.loadNewsUrl(url, null, null);
-  setupProtocolTest(NNTP_PORT, prefix+"TSS1@nntp.invalid");
+  setupProtocolTest(NNTP_PORT, prefix + "TSS1@nntp.invalid");
   server.performTest();
   // We should have length one... which means this must be a transaction object,
   // containing only us and them
-  Assert.ok('us' in server.playTransaction());
+  Assert.ok("us" in server.playTransaction());
   server.stop();
 
   var thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
 }
 
 function testReentrantClose() {
   // What we are testing is that a CloseConnection that spins the event loop
   // does not cause a crash.
   var server = makeServer(NNTP_RFC977_handler, daemon);
   server.start(NNTP_PORT);
 
   var listener = {
-    OnStartRunningUrl: function (url) {},
-    OnStopRunningUrl: function (url, rv) {
+    OnStartRunningUrl(url) {},
+    OnStopRunningUrl(url, rv) {
       // Spin the event loop (entering nsNNTPProtocol::ProcessProtocolState)
       let thread = gThreadManager.currentThread;
       while (thread.hasPendingEvents())
         thread.processNextEvent(true);
-    }
+    },
   };
   // Nice multi-step command--we can close while executing this URL if we are
   // careful.
   var url = URLCreator.newURI("news://localhost:" + NNTP_PORT +
     "/test.filter");
   url.QueryInterface(Ci.nsIMsgMailNewsUrl);
   url.RegisterListener(listener);
 
   _server.loadNewsUrl(url, null, null);
   server.performTest("GROUP");
   dump("Stopping server\n");
-  gThreadManager.currentThread.dispatch(
-    { run: function() { _server.closeCachedConnections(); } },
-    Ci.nsIEventTarget.DISPATCH_NORMAL);
+  gThreadManager.currentThread.dispatch({
+    run() { _server.closeCachedConnections(); },
+  }, Ci.nsIEventTarget.DISPATCH_NORMAL);
   server.performTest();
   server.stop();
 
   // Break refcnt loops
   listener = url = null;
 }
 
 function testManyConnections() {
   // Start up 2 connections at once and make sure that they don't conflict
   var server = makeServer(NNTP_RFC2980_handler, daemon);
   setupLocalServer(NNTP_PORT);
   server.start(NNTP_PORT);
   _server.maximumConnectionsNumber = 3;
   var listener = {
     ran: 0,
-    OnStartRunningUrl: function (url) {},
-    OnStopRunningUrl: function (url, rv) {
+    OnStartRunningUrl(url) {},
+    OnStopRunningUrl(url, rv) {
       if (--(this.ran) == 0)
         _server.closeCachedConnections();
-    }
+    },
   };
   let groups = _server.rootFolder.subFolders;
   while (groups.hasMoreElements()) {
     groups.getNext().QueryInterface(Ci.nsIMsgFolder).getNewMessages(null,
       listener);
     listener.ran++;
   }
   server.performTest();
   // The last one that is processed is test.filter, so make sure that
   // test.subscribed.simple is not retrieving the data meant for test.filter
-  let folder = _server.rootFolder.getChildNamed("test.subscribe.simple")
+  let folder = _server.rootFolder.getChildNamed("test.subscribe.simple");
   Assert.equal(folder.getTotalMessages(false), 1);
 }
 
 function run_test() {
   testRFC977();
   testConnectionLimit();
   testReentrantClose();
   testManyConnections();
--- a/mailnews/news/test/unit/test_uriParser.js
+++ b/mailnews/news/test/unit/test_uriParser.js
@@ -4,144 +4,144 @@ ChromeUtils.import("resource://gre/modul
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var localserver;
 var tests = [
   // news://host/-based URIs
   { uri: "news://localhost/?newgroups",
     get server() { return localserver; },
     folder: null,
-    newsAction: Ci.nsINntpUrl.ActionListNewGroups
+    newsAction: Ci.nsINntpUrl.ActionListNewGroups,
   },
   // news://host/group-based
   { uri: "news://news.server.example/example.group.this",
     server: null,
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionGetNewNews,
-    group: "example.group.this"
+    group: "example.group.this",
   },
   { uri: "news://news.server.example/*",
     server: null,
     folder: null,
-    newsAction: Ci.nsINntpUrl.ActionListGroups
+    newsAction: Ci.nsINntpUrl.ActionListGroups,
   },
   { uri: "news://news.server.example/news.*",
     server: null,
     folder: null,
-    newsAction: Ci.nsINntpUrl.ActionListGroups
+    newsAction: Ci.nsINntpUrl.ActionListGroups,
   },
   { uri: "news://localhost/test.filter?list-ids",
     get server() { return localserver; },
     get folder() { return localserver.rootFolder.getChildNamed("test.filter"); },
     newsAction: Ci.nsINntpUrl.ActionListIds,
-    group: "test.filter"
+    group: "test.filter",
   },
   { uri: "news://localhost/some.group?search/XPAT From 1-5 [Ww][Hh][Oo]",
     get server() { return localserver; },
     newsAction: Ci.nsINntpUrl.ActionSearch,
-    group: "some.group"
+    group: "some.group",
   },
 
   // news://host/message-based URIs
   { uri: "news://localhost/message-id@some-host.invalid",
     get server() { return localserver; },
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionFetchArticle,
     messageID: "message-id@some-host.invalid",
     group: "",
-    key: 0xffffffff
+    key: 0xffffffff,
   },
   { uri: "news://localhost/message-id@some-host.invalid?part=1.4",
     get server() { return localserver; },
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionFetchPart,
-    messageID: "message-id@some-host.invalid"
+    messageID: "message-id@some-host.invalid",
   },
   { uri: "news://localhost/message-id@some-host.invalid?cancel",
     get server() { return localserver; },
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionCancelArticle,
-    messageID: "message-id@some-host.invalid"
+    messageID: "message-id@some-host.invalid",
   },
   { uri: "news://localhost/message-id@some-host.invalid?group=foo&key=123",
     get server() { return localserver; },
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionFetchArticle,
     messageID: "message-id@some-host.invalid",
     group: "foo",
-    key: 123
+    key: 123,
   },
 
   // No-authority uris
   { uri: "news:rec.games.pinball",
     server: null,
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionGetNewNews,
     group: "rec.games.pinball",
-    host: ""
+    host: "",
   },
   { uri: "news:message-id@some-host.invalid",
     server: null,
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionFetchArticle,
     messageID: "message-id@some-host.invalid",
     group: "",
-    key: 0xffffffff
+    key: 0xffffffff,
   },
 
   // news-message://host/group#key
   { uri: "news-message://localhost/test.simple.subscribe#1",
     newsAction: Ci.nsINntpUrl.ActionFetchArticle,
     group: "test.simple.subscribe",
-    key: 1
+    key: 1,
   },
 
   // nntp://host/group
   { uri: "nntp://localhost/test.filter",
     get server() { return localserver; },
     get folder() { return localserver.rootFolder.getChildNamed("test.filter"); },
     newsAction: Ci.nsINntpUrl.ActionGetNewNews,
-    group: "test.filter"
+    group: "test.filter",
   },
   { uri: "nntp://localhost/i.dont.exist",
     get server() { return localserver; },
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionGetNewNews,
-    group: "i.dont.exist"
+    group: "i.dont.exist",
   },
   { uri: "nntp://news.example.invalid/i.dont.exist",
     server: null,
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionGetNewNews,
-    group: "i.dont.exist"
+    group: "i.dont.exist",
   },
 
   // nntp://host/group/key
   { uri: "nntp://localhost/test.filter/123",
     get server() { return localserver; },
     get folder() { return localserver.rootFolder.getChildNamed("test.filter"); },
     newsAction: Ci.nsINntpUrl.ActionFetchArticle,
     group: "test.filter",
-    key: 123
+    key: 123,
   },
   { uri: "nntp://localhost/i.dont.exist/123",
     get server() { return localserver; },
     folder: null,
     newsAction: Ci.nsINntpUrl.ActionFetchArticle,
     group: "i.dont.exist",
-    key: 123
+    key: 123,
   },
 ];
 
 var invalid_uris = [
   "news-message://localhost/test.simple.subscribe#hello",
   "nntp://localhost/",
   "nntp://localhost/a.group/hello",
   "nntp://localhost/a.group/0",
-  "nntp:a.group"
+  "nntp:a.group",
 ];
 
 function run_test() {
   // We're not running the server, just setting it up
   localserver = setupLocalServer(119);
   let nntpService = MailServices.nntp.QueryInterface(Ci.nsIProtocolHandler);
   for (let test of tests) {
     dump("Checking URL " + test.uri + "\n");