Bug 1515877 - Turn on ESLint in mailnews/local; r=aceman
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 01 Jan 2019 11:21:26 +1300
changeset 34090 5753ad5a95c90434a62b55f3a12a3a2612e0d364
parent 34089 71d23319ac8228b0e4b35ad66f13a9221f8947c6
child 34091 40bfc93a1dcc6baec73082c6c39999b787023efb
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersaceman
bugs1515877
Bug 1515877 - Turn on ESLint in mailnews/local; r=aceman
.eslintignore
mailnews/local/test/unit/.eslintrc.js
mailnews/local/test/unit/head_maillocal.js
mailnews/local/test/unit/test_bug457168.js
mailnews/local/test/unit/test_duplicateKey.js
mailnews/local/test/unit/test_fileName.js
mailnews/local/test/unit/test_folderLoaded.js
mailnews/local/test/unit/test_localFolder.js
mailnews/local/test/unit/test_mailboxContentLength.js
mailnews/local/test/unit/test_mailboxProtocol.js
mailnews/local/test/unit/test_movemailDownload.js
mailnews/local/test/unit/test_msgCopy.js
mailnews/local/test/unit/test_msgIDParsing.js
mailnews/local/test/unit/test_nsIMsgLocalMailFolder.js
mailnews/local/test/unit/test_nsIMsgPluggableStore.js
mailnews/local/test/unit/test_over2GBMailboxes.js
mailnews/local/test/unit/test_over4GBMailboxes.js
mailnews/local/test/unit/test_pop3AuthMethods.js
mailnews/local/test/unit/test_pop3Download.js
mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js
mailnews/local/test/unit/test_pop3Duplicates.js
mailnews/local/test/unit/test_pop3FilterActions.js
mailnews/local/test/unit/test_pop3GSSAPIFail.js
mailnews/local/test/unit/test_pop3GetNewMail.js
mailnews/local/test/unit/test_pop3MoveFilter.js
mailnews/local/test/unit/test_pop3MoveFilter2.js
mailnews/local/test/unit/test_pop3MultiCopy.js
mailnews/local/test/unit/test_pop3MultiCopy2.js
mailnews/local/test/unit/test_pop3Password.js
mailnews/local/test/unit/test_pop3Password2.js
mailnews/local/test/unit/test_pop3Password3.js
mailnews/local/test/unit/test_pop3PasswordFailure.js
mailnews/local/test/unit/test_pop3PasswordFailure2.js
mailnews/local/test/unit/test_pop3PasswordFailure3.js
mailnews/local/test/unit/test_pop3Proxy.js
mailnews/local/test/unit/test_pop3Pump.js
mailnews/local/test/unit/test_pop3ServerBrokenCRAMDisconnect.js
mailnews/local/test/unit/test_pop3ServerBrokenCRAMFail.js
mailnews/local/test/unit/test_preview.js
mailnews/local/test/unit/test_saveMessage.js
mailnews/local/test/unit/test_streamHeaders.js
mailnews/local/test/unit/test_undoDelete.js
mailnews/local/test/unit/test_verifyLogon.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -32,18 +32,16 @@ mailnews/addrbook/*
 mailnews/base/*
 mailnews/build/*
 mailnews/compose/*
 mailnews/db/*
 mailnews/imap/*
 mailnews/import/*
 mailnews/intl/*
 mailnews/jsaccount/*
-mailnews/local/*
-mailnews/mapi/*
 mailnews/mime/*
 mailnews/test/*
 
 # mailnews/extensions exclusions
 mailnews/extensions/*
 !mailnews/extensions/newsblog
 
 # mail exclusions
new file mode 100644
--- /dev/null
+++ b/mailnews/local/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/local/test/unit/head_maillocal.js
+++ b/mailnews/local/test/unit/head_maillocal.js
@@ -1,32 +1,33 @@
 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/mailTestUtils.js");
 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 pop3 server scripts
+/* import-globals-from ../../../test/fakeserver/maild.js */
+/* import-globals-from ../../../test/fakeserver/auth.js */
+/* import-globals-from ../../../test/fakeserver/pop3d.js */
 ChromeUtils.import("resource://testing-common/mailnews/maild.js");
 ChromeUtils.import("resource://testing-common/mailnews/auth.js");
 ChromeUtils.import("resource://testing-common/mailnews/pop3d.js");
 
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-
 // Setup the daemon and server
 // If the debugOption is set, then it will be applied to the server.
 function setupServerDaemon(debugOption) {
   var daemon = new pop3Daemon();
   var extraProps = {};
   function createHandler(d) {
     var handler = new POP3_RFC5034_handler(d);
     for (var prop in extraProps) {
@@ -35,44 +36,43 @@ function setupServerDaemon(debugOption) 
     return handler;
   }
   var server = new nsMailServer(createHandler, daemon);
   if (debugOption)
     server.setDebugLevel(debugOption);
   return [daemon, server, extraProps];
 }
 
-function createPop3ServerAndLocalFolders(port, hostname="localhost") {
+function createPop3ServerAndLocalFolders(port, hostname = "localhost") {
   localAccountUtils.loadLocalMailAccount();
   let server = localAccountUtils.create_incoming_server("pop3", port,
     "fred", "wilma", hostname);
   return server;
 }
 
-var gCopyListener =
-{
+var gCopyListener = {
   callbackFunction: null,
   copiedMessageHeaderKeys: [],
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey) {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {
     try {
       this.copiedMessageHeaderKeys.push(aKey);
     } catch (ex) {
       dump(ex);
     }
   },
-  GetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus) {
+  GetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) {
     if (this.callbackFunction) {
       mailTestUtils.do_timeout_function(0, this.callbackFunction,
                                         null,
-                                        [ this.copiedMessageHeaderKeys, aStatus ]);
+                                        [this.copiedMessageHeaderKeys, aStatus]);
     }
-  }
+  },
 };
 
 /**
  * copyFileMessageInLocalFolder
  * A utility wrapper of nsIMsgCopyService.CopyFileMessage to copy a message
  * into local inbox folder.
  *
  * @param aMessageFile     An instance of nsIFile to copy.
@@ -107,17 +107,17 @@ function do_check_transaction(real, expe
   // If we don't spin the event loop before starting the next test, the readers
   // aren't expired. In this case, the "real" real transaction is the last one.
   if (real instanceof Array)
     real = real[real.length - 1];
 
   // 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 create_temporary_directory() {
   let directory = Services.dirsvc.get("TmpD", Ci.nsIFile);
--- a/mailnews/local/test/unit/test_bug457168.js
+++ b/mailnews/local/test/unit/test_bug457168.js
@@ -1,57 +1,54 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Protocol tests for POP3.
  */
-ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var type = null;
-var test = null;
 var server;
 var daemon;
 var incomingServer;
 var thisTest;
 
-var tests = [
-  { title: "Get New Mail, One Message",
-    messages: [ "message2.eml", "message2.eml", "message3.eml" ],
-    transaction: [ "AUTH", "CAPA", "AUTH PLAIN", "STAT", "LIST", "UIDL",
-                   "RETR 1", "DELE 1", "RETR 2", "DELE 2", "RETR 3", "DELE 3" ] }
-];
+var tests = [{
+  title: "Get New Mail, One Message",
+  messages: ["message2.eml", "message2.eml", "message3.eml"],
+  transaction: [
+    "AUTH", "CAPA", "AUTH PLAIN", "STAT", "LIST", "UIDL",
+    "RETR 1", "DELE 1", "RETR 2", "DELE 2", "RETR 3", "DELE 3",
+  ],
+}];
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       var transaction = server.playTransaction();
 
       do_check_transaction(transaction, thisTest.transaction);
 
       Assert.equal(localAccountUtils.inboxFolder.getTotalMessages(false), 2);
       Assert.equal(localAccountUtils.inboxFolder.getNumUnread(false), 1);
 
       Assert.equal(result, 0);
-    }
-    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);
     }
 
     // Let OnStopRunningUrl return cleanly before doing anything else.
     do_timeout(0, checkBusy);
-  }
+  },
 };
 
 function checkBusy() {
   if (tests.length == 0) {
     incomingServer.closeCachedConnections();
 
     // No more tests, let everything finish
     server.stop();
@@ -112,18 +109,16 @@ function run_test() {
   Services.prefs.setBoolPref("mail.biff.animate_dock_icon", false);
   Services.prefs.setIntPref("mail.server.default.dup_action", 2);
 
   server = setupServerDaemon();
   daemon = server[0];
   server = server[1];
   server.start();
 
-  type = "RFC 1939";
-
   // Set up the basic accounts and folders
   incomingServer = createPop3ServerAndLocalFolders(server.port);
 
   // Create a cc filter
   var filters = incomingServer.getFilterList(null);
 
   var filter = filters.createFilter("cc dup test");
   filter.filterType = Ci.nsMsgFilterType.Incoming;
--- a/mailnews/local/test/unit/test_duplicateKey.js
+++ b/mailnews/local/test/unit/test_duplicateKey.js
@@ -1,16 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * This test deletes intermediate messages, then compacts, then adds more
  * messages, testing for duplicated keys in bug 1202105.
  */
 
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
 ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
 add_task(async function runPump() {
 
   gPOP3Pump.files = ["../../../data/bugmail1",
                      "../../../data/bugmail1",
                      "../../../data/bugmail1",
@@ -26,21 +27,21 @@ add_task(async function runPump() {
   let deletes = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
   deletes.appendElement(hdrs[1]);
   deletes.appendElement(hdrs[2]);
 
   // Note the listener won't work because this is a sync delete,
   // but it should!
   localAccountUtils.inboxFolder
                    .deleteMessages(deletes, // in nsIArray messages,
-                                   null, //in nsIMsgWindow msgWindow,
+                                   null, // in nsIMsgWindow msgWindow,
                                    true, // in boolean deleteStorage,
                                    true, // in boolean isMove,
                                    null, // in nsIMsgCopyServiceListener,
-                                   false); //in boolean allowUndo
+                                   false); // in boolean allowUndo
 
   dump("Messages after delete\n");
   hdrs = showMessages(localAccountUtils.inboxFolder);
   Assert.equal(hdrs.length, 3, "Check db length after deleting two messages");
 
   // compact
   var listener = new PromiseTestUtils.PromiseUrlListener();
   localAccountUtils.inboxFolder.compact(listener, null);
@@ -57,20 +58,16 @@ add_task(async function runPump() {
 
   dump("Messages after new message\n");
   hdrs = showMessages(localAccountUtils.inboxFolder);
   Assert.equal(hdrs.length, 4, "Check db length after adding one message");
 
   gPOP3Pump = null;
 });
 
-function run_test() {
-  run_next_test();
-}
-
 function showMessages(folder) {
   let enumerator = folder.msgDatabase.EnumerateMessages();
   var hdrs = [];
   while (enumerator.hasMoreElements()) {
     hdrs.push(enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr));
     dump("key " + (hdrs.length - 1) + " is " + hdrs[hdrs.length - 1].messageKey + "\n");
   }
   return hdrs;
--- a/mailnews/local/test/unit/test_fileName.js
+++ b/mailnews/local/test/unit/test_fileName.js
@@ -1,16 +1,13 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Test handling of special chars in folder names
  */
 
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-
 function run_test() {
   let testFolderName = "";
   let OSname = Services.sysinfo.getProperty("name");
   if (OSname == "Windows_NT") {
     // On Windows test file with ' ' in the name.
     testFolderName = "bugmail 1";
   } else if (OSname == "Linux") {
     // On Linux test file with '`' in the name.
@@ -62,17 +59,17 @@ function run_test() {
   Services.prefs.setCharPref("mail.server.server2.name", "poptest");
   Services.prefs.setCharPref("mail.server.server2.type", "pop3");
   Services.prefs.setCharPref("mail.server.server2.userName", "user");
   // This basically says to ignore the time stamp in the .msf file
   Services.prefs.setIntPref("mail.db_timestamp_leeway", 0x7FFFFFFF);
 
   localAccountUtils.incomingServer = MailServices.accounts.localFoldersServer;
   // force load of accounts.
-  let defaultAccount = MailServices.accounts.defaultAccount;
+  MailServices.accounts.defaultAccount;
 
   let pop3Server = MailServices.accounts.FindServer("user", "poptest", "pop3");
   let rootFolder = localAccountUtils.incomingServer.rootMsgFolder
                                     .QueryInterface(Ci.nsIMsgLocalMailFolder);
   let pop3Root = pop3Server.rootMsgFolder;
 
   // Note: Inbox is not created automatically when there is no deferred server,
   // so we need to create it.
--- a/mailnews/local/test/unit/test_folderLoaded.js
+++ b/mailnews/local/test/unit/test_folderLoaded.js
@@ -6,79 +6,77 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
  /**
  * The intent of this file is to show a folder loaded event after a load
  * with a null database.
  *
  */
+
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 
 var testSubjects = ["[Bug 397009] A filter will let me tag, but not untag",
                     "Hello, did you receive my bugmail?"];
 var gMsgFile1 = do_get_file("../../../data/bugmail1");
 var gMsgFile2 = do_get_file("../../../data/draft1");
 
 var gTargetFolder = null;
 
 var tests = [
-  function* setup()
-  {
+  function* setup() {
     do_timeout(5000, function() {
       // should be done by now
       Assert.ok(false);
     });
 
-    if (typeof localAccountUtils.inboxFolder == 'undefined')
+    if (typeof localAccountUtils.inboxFolder == "undefined")
       localAccountUtils.loadLocalMailAccount();
     localAccountUtils.rootFolder.createSubfolder("target", null);
     gTargetFolder = localAccountUtils.rootFolder.getChildNamed("target");
 
     MailServices.copy.CopyFileMessage(gMsgFile1, gTargetFolder, null, false, 0,
                                       "", asyncCopyListener, null);
     yield false;
 
     MailServices.copy.CopyFileMessage(gMsgFile2, gTargetFolder, null, false, 0,
                                       "", asyncCopyListener, null);
     yield false;
 
   },
 
-  function* firstUpdate()
-  {
+  function* firstUpdate() {
     // get message headers for the target folder
     let enumerator = gTargetFolder.msgDatabase.EnumerateMessages();
     var msgCount = 0;
-    while(enumerator.hasMoreElements())
-    {
+    while (enumerator.hasMoreElements()) {
       msgCount++;
       let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
       Assert.equal(hdr.subject, testSubjects[msgCount - 1]);
     }
     Assert.equal(msgCount, 2);
 
     // try an update
-    mailTestUtils.updateFolderAndNotify(gTargetFolder, function () {
+    mailTestUtils.updateFolderAndNotify(gTargetFolder, function() {
       dump("after FolderLoaded1\n");
       async_driver();
     });
     yield false;
   },
 
-  function* secondUpdate()
-  {
+  function* secondUpdate() {
     // If the following executes, the test hangs in bug 787557.
     gTargetFolder.msgDatabase = null;
     // try an update
-    mailTestUtils.updateFolderAndNotify(gTargetFolder, function () {
+    mailTestUtils.updateFolderAndNotify(gTargetFolder, function() {
       dump("after FolderLoaded2\n");
       async_driver();
     });
     yield false;
   },
-
 ];
 
 function run_test() {
   async_run_tests(tests);
 }
--- a/mailnews/local/test/unit/test_localFolder.js
+++ b/mailnews/local/test/unit/test_localFolder.js
@@ -6,17 +6,17 @@
  * nsIMsgFolder.subFolders tests
  * These tests intend to test pluggableStore.discoverSubFolders
  * and nsIMsgFolder.hasSubFolders.
  */
 
 // Currently we have two mailbox storage formats.
 var gPluggableStores = [
   "@mozilla.org/msgstore/berkeleystore;1",
-  "@mozilla.org/msgstore/maildirstore;1"
+  "@mozilla.org/msgstore/maildirstore;1",
 ];
 
 /**
  * Check whether the expected folder structure
  * exists in the root folder "mailFolder".
  *
  * @param expected  array of folders and subfolders
  *                  we expect
@@ -42,39 +42,37 @@ function check_sub_folders(expected, act
       check_sub_folders(expected[index].subFolders, actualFolder.subFolders);
     }
   }
 }
 
 /**
  * Test default mailbox without creating any subfolders.
  */
-function test_default_mailbox(expected, type)
-{
+function test_default_mailbox(expected, type) {
   let mailbox = setup_mailbox(type, create_temporary_directory());
 
   check_sub_folders(expected, mailbox.subFolders);
 }
 
 /**
  * A helper method to add the folders in aFolderArray
  * to the aParentFolder as subfolders.
  *
  * @param aFolderArray   array of folders and subfolders
  *                       (js objects).
  * @param aParentFolder  folder (nsIMsgFolder) to which
  *                       the folders and subfolders from
  *                       aFolderArray are to be added.
  */
-function add_sub_folders(aFolderArray, aParentFolder)
-{
+function add_sub_folders(aFolderArray, aParentFolder) {
   for (let msgFolder of aFolderArray) {
     if (!aParentFolder.containsChildNamed(msgFolder.name))
       aParentFolder.createSubfolder(msgFolder.name, null);
-    if (!!msgFolder.subFolders) {
+    if (msgFolder.subFolders) {
       add_sub_folders(msgFolder.subFolders,
                       aParentFolder.getChildNamed(msgFolder.name));
     }
   }
 }
 
 
 /**
@@ -92,48 +90,45 @@ function test_mailbox(expected, type) {
 }
 
 function run_all_tests() {
   test_default_mailbox([{ name: "Trash" }, { name: "Outbox" }], "none");
   test_default_mailbox([{ name: "Inbox" }, { name: "Trash" }], "pop3");
 
   // Assuming that the order of the folders returned from the actual folder
   // discovery is independent and un-important for this test.
-  test_mailbox([
-    {
-      name: "Inbox",
-      subFolders: [ { name: "sub4" } ]
-    },
-    {
-      name: "Trash"
-    }
-  ], "pop3");
+  test_mailbox([{
+    name: "Inbox",
+    subFolders: [{
+      name: "sub4",
+    }],
+  }, {
+    name: "Trash",
+  }], "pop3");
 
-  test_mailbox([
-    {
-      name: "Inbox",
-      subFolders: [
-        { name: "inbox-sub1",
-          subFolders: [ { name: "inbox-sub-sub1" },
-                        { name: "inbox-sub-sub2" }
-                      ]
-        },
-        { name: "inbox-sub2" }
-      ]
-    },
-    {
-      name: "Trash"
-    },
-    {
-      name: "Outbox",
-      subFolders: [
-        { name: "outbox-sub1" }
-      ]
-    }
-  ], "pop3");
+  test_mailbox([{
+    name: "Inbox",
+    subFolders: [{
+      name: "inbox-sub1",
+      subFolders: [{
+        name: "inbox-sub-sub1",
+      }, {
+        name: "inbox-sub-sub2",
+      }],
+    }, {
+      name: "inbox-sub2",
+    }],
+  }, {
+    name: "Trash",
+  }, {
+    name: "Outbox",
+    subFolders: [{
+      name: "outbox-sub1",
+    }],
+  }], "pop3");
 }
 
 function run_test() {
   for (let store in gPluggableStores) {
     Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                                gPluggableStores[store]);
     run_all_tests();
   }
--- a/mailnews/local/test/unit/test_mailboxContentLength.js
+++ b/mailnews/local/test/unit/test_mailboxContentLength.js
@@ -9,24 +9,22 @@
 /*
  * Test content length for the mailbox protocol. This focuses on necko URLs
  * that are run externally.
  */
 
 // Take a multipart message as we're testing attachment URLs as well
 var gFile = do_get_file("../../../data/multipart-complex2");
 
-function run_test()
-{
+function run_test() {
   do_test_pending();
   copyFileMessageInLocalFolder(gFile, 0, "", null, verifyContentLength);
 }
 
-function verifyContentLength(aMessageHeaderKeys, aStatus)
-{
+function verifyContentLength(aMessageHeaderKeys, aStatus) {
   Assert.notEqual(aMessageHeaderKeys, null);
   // First get the message URI
   let msgHdr = localAccountUtils.inboxFolder.GetMessageHeader(aMessageHeaderKeys[0]);
   let messageUri = localAccountUtils.inboxFolder.getUriForMsg(msgHdr);
   // Convert this to a URI that necko can run
   let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
   let neckoURL = {};
   let messageService = messenger.messageServiceFromURI(messageUri);
@@ -41,20 +39,20 @@ function verifyContentLength(aMessageHea
                                                Services.scriptSecurityManager.getSystemPrincipal(),
                                                null,
                                                Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                                                Ci.nsIContentPolicy.TYPE_OTHER);
   Assert.equal(channel.contentLength, gFile.fileSize);
 
   // Now try an attachment. &part=1.2
   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, gFile.fileSize);
 
   do_test_finished();
 }
--- a/mailnews/local/test/unit/test_mailboxProtocol.js
+++ b/mailnews/local/test/unit/test_mailboxProtocol.js
@@ -5,26 +5,24 @@
 
 var defaultProtocolFlags =
   Ci.nsIProtocolHandler.URI_NORELATIVE |
   Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
   Ci.nsIProtocolHandler.URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT |
   Ci.nsIProtocolHandler.URI_FORBIDS_COOKIE_ACCESS |
   Ci.nsIProtocolHandler.ORIGIN_IS_FULL_SPEC;
 
-var protocols =
-  [ { protocol: "mailbox",
-      urlSpec: "mailbox://user@localhost/",
-      // mailbox protocol doesn't use a port
-      defaultPort: -1
-    },
-  ];
+var protocols = [{
+  protocol: "mailbox",
+  urlSpec: "mailbox://user@localhost/",
+  // mailbox protocol doesn't use a port
+  defaultPort: -1,
+}];
 
-function run_test()
-{
+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);
 
     Assert.equal(pH.scheme, protocols[part].protocol);
--- a/mailnews/local/test/unit/test_movemailDownload.js
+++ b/mailnews/local/test/unit/test_movemailDownload.js
@@ -1,35 +1,20 @@
 /**
  * The intent of this file is to test that movemail download code
  * works correctly.
  */
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
+
 ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
-var gPluggableStores = [
-  "@mozilla.org/msgstore/berkeleystore;1",
-  "@mozilla.org/msgstore/maildirstore;1"
-];
-
 var testSubjects = ["[Bug 397009] A filter will let me tag, but not untag",
                     "Hello, did you receive my bugmail?",
                     "[Bug 655578] list-id filter broken"];
 
 var gMsgHdrs = [];
-var gHdrIndex = 0;
-
-// the movemail spool dir file is these three files
-// concatenated together.
-
-var gFiles = ["../../../data/bugmail1",
-              "../../../data/draft1",
-              "../../../data/bugmail19"];
-
 var gMoveMailInbox;
 
 function setup(storeID, aHostName) {
   return function _setup() {
     localAccountUtils.loadLocalMailAccount(storeID);
     let movemailServer =
       MailServices.accounts.createIncomingServer("", aHostName, "movemail");
     let workingDir = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
@@ -39,53 +24,51 @@ function setup(storeID, aHostName) {
     // movemail truncates spool file, so make a copy, and use that
     workingDirFile.copyTo(null, "movemailspool-copy");
     fullPath += "-copy";
     dump("full path = " + fullPath + "\n");
     movemailServer.setCharValue("spoolDir", fullPath);
     movemailServer.QueryInterface(Ci.nsILocalMailIncomingServer);
     movemailServer.getNewMail(null, null, null);
     gMoveMailInbox = movemailServer.rootFolder.getChildNamed("INBOX");
-  }
+  };
 }
 
 var gTestArray = [
   function continueTest() {
     // Clear the gMsgHdrs array.
     gMsgHdrs = [];
     // get message headers for the inbox folder
     let enumerator = gMoveMailInbox.msgDatabase.EnumerateMessages();
     var msgCount = 0;
-    let hdr;
     while (enumerator.hasMoreElements()) {
       let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
       gMsgHdrs.push(hdr);
       Assert.equal(hdr.subject, testSubjects[msgCount++]);
     }
     Assert.equal(msgCount, 3);
   },
   async function streamMessages() {
     for (let msgHdr of gMsgHdrs)
       await streamNextMessage(msgHdr);
-  }
+  },
 ];
 
-function run_test()
-{
+function run_test() {
   let hostName = "movemail";
   for (let index = 0; index < localAccountUtils.pluggableStores.length; index++) {
     add_task(setup(localAccountUtils.pluggableStores[index],
                    hostName + "-" + index));
     gTestArray.forEach(x => add_task(x));
   }
 
   run_next_test();
 }
 
-var streamNextMessage = async function (aMsgHdr) {
+var streamNextMessage = async function(aMsgHdr) {
   let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
   let msgURI = aMsgHdr.folder.getUriForMsg(aMsgHdr);
   dump("streaming msg " + msgURI + " store token = " +
        aMsgHdr.getStringProperty("storeToken"));
   let msgServ = messenger.messageServiceFromURI(msgURI);
   let streamListener = new PromiseTestUtils.PromiseStreamListener();
   msgServ.streamMessage(msgURI, streamListener, null, null, false, "", true);
   let data = await streamListener.promise;
--- a/mailnews/local/test/unit/test_msgCopy.js
+++ b/mailnews/local/test/unit/test_msgCopy.js
@@ -6,18 +6,17 @@
 
 var bugmail11 = do_get_file("../../../data/bugmail11");
 
 // main test
 
 // tag used with test messages
 var tag1 = "istag";
 
-function run_test()
-{
+function run_test() {
   do_test_pending();
   copyFileMessageInLocalFolder(bugmail11, 0, tag1, null, test_keywords);
 }
 
 function test_keywords(aMessageHeaderKeys, aStatus) {
   let headerKeys = aMessageHeaderKeys;
   Assert.notEqual(headerKeys, null);
   let copiedMessage = localAccountUtils.inboxFolder.GetMessageHeader(headerKeys[0]);
--- a/mailnews/local/test/unit/test_msgIDParsing.js
+++ b/mailnews/local/test/unit/test_msgIDParsing.js
@@ -1,31 +1,22 @@
 /*
  * Test bug 676916 - nsParseMailbox parses multi-line message-id header incorrectly
  */
 
-
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://testing-common/mailnews/localAccountUtils.js");
-
-var gMessenger = Cc["@mozilla.org/messenger;1"].
-                   createInstance(Ci.nsIMessenger);
-
 var headers =
   "from: alice@t1.example.com\r\n" +
   "to: bob@t2.example.net\r\n" +
   "message-id:   \r\n   <abcmessageid>\r\n";
 
-function testMsgID()
-{
-  let localFolder = localAccountUtils.inboxFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
-  localAccountUtils.inboxFolder.addMessage("From \r\n"+ headers + "\r\nhello\r\n");
+function testMsgID() {
+  localAccountUtils.inboxFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
+  localAccountUtils.inboxFolder.addMessage("From \r\n" + headers + "\r\nhello\r\n");
   let msgHdr = localAccountUtils.inboxFolder.firstNewMessage;
   Assert.equal(msgHdr.messageId, "abcmessageid");
 }
 
-function run_test()
-{
+function run_test() {
   for (let storeID of localAccountUtils.pluggableStores) {
     localAccountUtils.loadLocalMailAccount(storeID);
     testMsgID();
   }
 }
--- a/mailnews/local/test/unit/test_nsIMsgLocalMailFolder.js
+++ b/mailnews/local/test/unit/test_nsIMsgLocalMailFolder.js
@@ -1,17 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /*
  * Test suite for local folder functions.
  */
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
 load("../../../resources/messageGenerator.js");
 
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+var { toXPCOMArray } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
+
 /**
  * Bug 66763
  * Test deletion of a folder with a name already existing in Trash.
  */
 function subtest_folder_deletion(root) {
   // Now we only have <root> and some default subfolders, like Trash.
   let trash = root.getChildNamed("Trash");
   Assert.ok(!trash.hasSubFolders);
@@ -21,33 +22,32 @@ function subtest_folder_deletion(root) {
   let path = folder.filePath;
   Assert.ok(path.exists());
 
   // Delete "folder" into Trash.
   let folderArray = toXPCOMArray([folder], Ci.nsIMutableArray);
   root.deleteSubFolders(folderArray, null);
   Assert.ok(!path.exists());
   Assert.equal(trash.numSubFolders, 1);
-  let folderDeleted = trash.getChildNamed("folder");
+  trash.getChildNamed("folder");
 
   // Create another "folder" in root.
   folder = root.createLocalSubfolder("folder");
   // Delete "folder" into Trash again.
   folderArray = toXPCOMArray([folder], Ci.nsIMutableArray);
   root.deleteSubFolders(folderArray, null);
   Assert.equal(trash.numSubFolders, 2);
   // The folder should be automatically renamed as the same name already is in Trash.
-  let folderDeleted2 = trash.getChildNamed("folder(2)");
+  trash.getChildNamed("folder(2)");
 
   // Create yet another "folder" in root.
   folder = root.createLocalSubfolder("folder");
 
   // But now with another subfolder
-  let subfolder = folder.QueryInterface(Ci.nsIMsgLocalMailFolder)
-                        .createLocalSubfolder("subfolder");
+  folder.QueryInterface(Ci.nsIMsgLocalMailFolder).createLocalSubfolder("subfolder");
 
   // Delete folder into Trash again
   folderArray = toXPCOMArray([folder], Ci.nsIMutableArray);
   root.deleteSubFolders(folderArray, null);
   Assert.equal(trash.numSubFolders, 3);
   // The folder should be automatically renamed as the same name already is in Trash
   // but the subfolder should be untouched.
   let folderDeleted3 = trash.getChildNamed("folder(3)");
@@ -108,25 +108,24 @@ function subtest_folder_operations(root)
   // Test - getChildNamed
 
   Assert.equal(root.getChildNamed("folder1"), folder);
 
   // Check for non match, this should throw
   var thrown = false;
   try {
     root.getChildNamed("folder2");
-  }
-  catch (e) {
+  } catch (e) {
     thrown = true;
   }
 
   Assert.ok(thrown);
 
   // folder2 is a child of folder however.
-  var folder2 = folder.getChildNamed("folder2");
+  folder2 = folder.getChildNamed("folder2");
 
   // Test - isAncestorOf
 
   Assert.ok(folder.isAncestorOf(folder2));
   Assert.ok(root.isAncestorOf(folder2));
   Assert.ok(!folder.isAncestorOf(root));
 
   // Test - FoldersWithFlag
@@ -167,23 +166,22 @@ function subtest_folder_operations(root)
   let hdr = folder1Local.addMessage(message.toMboxString());
   Assert.equal(message.messageId, hdr.messageId);
 
   folder3Local.copyFolderLocal(folder, true, null, null);
 
   // Test - Get the new folders, make sure the old ones don't exist
 
   var folder1Moved = folder3.getChildNamed("folder1");
-  var folder2Moved = folder1Moved.getChildNamed("folder2");
+  folder1Moved.getChildNamed("folder2");
 
   thrown = false;
   try {
     root.getChildNamed("folder1");
-  }
-  catch (e) {
+  } catch (e) {
     thrown = true;
   }
 
   Assert.ok(thrown);
 
   if (folder.filePath.exists())
     dump("shouldn't exist - folder file path " + folder.URI + "\n");
   Assert.ok(!folder.filePath.exists());
@@ -238,17 +236,17 @@ function subtest_folder_operations(root)
 function test_store_rename(root) {
   let folder1 = root.createLocalSubfolder("newfolder1")
                     .QueryInterface(Ci.nsIMsgLocalMailFolder);
   Assert.ok(root.hasSubFolders);
   Assert.ok(!folder1.hasSubFolders);
   let folder2 = folder1.createLocalSubfolder("newfolder1-sub");
   let folder3 = root.createLocalSubfolder("newfolder3")
                     .QueryInterface(Ci.nsIMsgLocalMailFolder);
-  let folder3Subfolder = folder3.createLocalSubfolder("newfolder3-sub");
+  folder3.createLocalSubfolder("newfolder3-sub");
 
   Assert.ok(folder1.hasSubFolders);
   Assert.ok(!folder2.hasSubFolders);
   Assert.ok(folder3.hasSubFolders);
 
   folder1.rename("folder1", null);
   Assert.ok(root.containsChildNamed("folder1"));
   folder1 = root.getChildNamed("folder1");
@@ -261,26 +259,26 @@ function test_store_rename(root) {
   Assert.ok(folder1.containsChildNamed(folder2.name));
   Assert.ok(folder2.filePath.exists());
 
   folder3 = root.getChildNamed("newfolder3");
   root.propagateDelete(folder3, true, null);
   Assert.ok(!root.containsChildNamed("newfolder3"));
   folder3 = root.createLocalSubfolder("newfolder3")
                 .QueryInterface(Ci.nsIMsgLocalMailFolder);
-  folder3Subfolder = folder3.createLocalSubfolder("newfolder3-sub");
+  folder3.createLocalSubfolder("newfolder3-sub");
   folder3.rename("folder3", null);
 
   Assert.ok(root.containsChildNamed("folder3"));
   Assert.ok(!root.containsChildNamed("newfolder3"));
 }
 
 var gPluggableStores = [
   "@mozilla.org/msgstore/berkeleystore;1",
-  "@mozilla.org/msgstore/maildirstore;1"
+  "@mozilla.org/msgstore/maildirstore;1",
 ];
 
 function run_all_tests(aHostName) {
   let server = MailServices.accounts.createIncomingServer("nobody", aHostName,
                                                           "none");
   let account = MailServices.accounts.createAccount();
   account.incomingServer = server;
 
--- a/mailnews/local/test/unit/test_nsIMsgPluggableStore.js
+++ b/mailnews/local/test/unit/test_nsIMsgPluggableStore.js
@@ -3,17 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * nsIMsgPluggableStore interface tests
  */
 
 var gPluggableStores = [
   "@mozilla.org/msgstore/berkeleystore;1",
-  "@mozilla.org/msgstore/maildirstore;1"
+  "@mozilla.org/msgstore/maildirstore;1",
 ];
 
 function test_discoverSubFolders() {
   let mailbox = setup_mailbox("none", create_temporary_directory());
 
   mailbox.msgStore.discoverSubFolders(mailbox, true);
 
 }
--- a/mailnews/local/test/unit/test_over2GBMailboxes.js
+++ b/mailnews/local/test/unit/test_over2GBMailboxes.js
@@ -1,23 +1,23 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
 /* Test of accessing over 2 GiB local folder. */
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
 load("../../../resources/messageGenerator.js");
 var bugmail10 = do_get_file("../../../data/bugmail10");
 
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/berkeleystore;1");
 
 var gLocalInboxSize;
 var gLocalTrashFolder;
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
   do_test_pending();
 
   let inboxFile = localAccountUtils.inboxFolder.filePath;
 
@@ -54,87 +54,85 @@ function run_test()
   info("Local inbox size (before copyFileMessageInLocalFolder()) = " +
        gLocalInboxSize);
 
   // Append mail data to over 2 GiB position for over 2 GiB msgkey.
   copyFileMessageInLocalFolder(bugmail10, 0, "", null, copyMessages);
 }
 
 // Get message whose offset is over 2 GiB.
-function getMessageHdr()
-{
+function getMessageHdr() {
   let msgEnum = localAccountUtils.inboxFolder.msgDatabase.EnumerateMessages();
   while (msgEnum.hasMoreElements()) {
     let header = msgEnum.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     if (header.messageOffset >= 0x80000000) {
       return header;
     }
   }
 
   do_throw("Over 2 GiB msgkey was not found!");
+  return null; // This won't ever happen, but we're keeping the linter happy.
 }
 
-function copyMessages()
-{
+function copyMessages() {
   // Make sure inbox file grew (i.e., we were not writing over data).
   let localInboxSize = localAccountUtils.inboxFolder.filePath.fileSize;
   info("Local inbox size (after copyFileMessageInLocalFolder()) = " +
        localInboxSize);
   Assert.ok(localInboxSize > gLocalInboxSize);
 
   // Copy the message into the subfolder.
   let messages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
   messages.appendElement(getMessageHdr());
   MailServices.copy.CopyMessages(localAccountUtils.inboxFolder, messages,
                                  gLocalTrashFolder,
                                  false, copyListener2, null, false);
 }
 
 var copyListener2 = {
-  OnStartCopy : function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey : function(aKey) {},
-  OnStopCopy : function(aStatus) {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {},
+  OnStopCopy(aStatus) {
     Assert.equal(aStatus, 0);
 
     do_timeout(0, accessOver2GBMsg);
-  }
+  },
 };
 
 // streamMessage() test by over 2 GiB mail offset.
-function accessOver2GBMsg()
-{
+function accessOver2GBMsg() {
   let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
   let msghdr = getMessageHdr();
   let msgURI = msghdr.folder.getUriForMsg(msghdr);
   let msgServ = messenger.messageServiceFromURI(msgURI);
   msgServ.streamMessage(msgURI, gStreamListener, null, null, false, "", true);
 }
 
 var gStreamListener = {
-  QueryInterface : ChromeUtils.generateQI([Ci.nsIStreamListener]),
-  _stream : null,
-  _data : null,
-  onStartRequest : function (aRequest, aContext) {
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIStreamListener]),
+  _stream: null,
+  _data: null,
+  onStartRequest(aRequest, aContext) {
     this._data = "";
   },
-  onStopRequest : function (aRequest, aContext, aStatusCode) {
+  onStopRequest(aRequest, aContext, aStatusCode) {
     let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
                     .createInstance(Ci.nsIFileInputStream);
     let stream = Cc["@mozilla.org/scriptableinputstream;1"]
                    .createInstance(Ci.nsIScriptableInputStream);
 
     fstream.init(bugmail10, -1, 0, 0);
     stream.init(fstream);
     let original = stream.read(this._data.length);
     Assert.equal(this._data, original);
 
     do_timeout(0, endTest);
   },
-  onDataAvailable : function (aRequest, aContext, aInputStream, aOff, aCount) {
+  onDataAvailable(aRequest, aContext, aInputStream, aOff, aCount) {
     if (this._stream == null) {
       this._stream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
       this._stream.init(aInputStream);
     }
     this._data += this._stream.read(aCount);
   },
 };
 
--- a/mailnews/local/test/unit/test_over4GBMailboxes.js
+++ b/mailnews/local/test/unit/test_over4GBMailboxes.js
@@ -16,21 +16,24 @@
  * -  copyIntoOver4GiB_success_check1
  * -  copyIntoOver4GiB_success_check2
  * - compactOver4GiB
  * -  CompactListener_compactOver4GiB
  * - compactUnder4GiB
  * -  CompactListener_compactUnder4GiB
  */
 
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
+/* import-globals-from ../../../test/resources/messageGenerator.js */
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/alertTestUtils.js");
 load("../../../resources/messageGenerator.js");
 load("../../../resources/POP3pump.js");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/berkeleystore;1");
 
 // If we're running out of memory parsing the folder, lowering the
 // block size might help, though it will slow the test down and consume
 // more disk space.
 var kSparseBlockSize = 102400000;
@@ -38,55 +41,56 @@ var kSizeLimit = 0x100000000; // 4GiB
 var kNearLimit = kSizeLimit - 0x1000000; // -16MiB
 
 var gGotAlert = false;
 var gInboxFile = null;         // The mbox file storing the Inbox folder
 var gInboxSize = 0;            // The size of the Inbox folder
 var gInbox;                    // The nsIMsgFolder object of the Inbox folder in Local Folders
 var gExpectedNewMessages = 0;  // The number of messages pushed manually into the mbox file
 
+/* exported alert */
 // This alert() is triggered when file size becomes close (enough) to or
 // exceeds 4 GiB.
 // See hardcoded value in nsMsgBrkMBoxStore::HasSpaceAvailable().
 function alert(aDialogTitle, aText) {
   // See "/*/locales/en-US/chrome/*/messenger.properties > mailboxTooLarge".
   Assert.ok(aText.startsWith("The folder Inbox is full, and can't hold any more messages."));
   gGotAlert = true;
 }
 
 // A stub nsIMsgFolderListener that only listens to changes on Inbox and stores
 // the seen values for interesting folder properties so we can later test them.
 var FListener = {
   folderSize: [-1], // an array of seen values of "FolderSize"
   totalMsgs: [-1],  // an array of seen values of "TotalMessages"
 
   // Returns the value that is stored 'aBack' entries from the last one in the history.
-  sizeHistory: function (aBack) {
+  sizeHistory(aBack) {
     return this.folderSize[this.folderSize.length - 1 - aBack];
   },
-  msgsHistory: function (aBack) {
+  msgsHistory(aBack) {
     return this.totalMsgs[this.totalMsgs.length - 1 - aBack];
   },
 
   OnItemAdded: function act_add(aRDFParentItem, aItem) {},
   OnItemRemoved: function act_remove(aRDFParentItem, aItem) {},
-  OnItemPropertyChanged: function(aItem, aProperty, aOld, aNew) {},
-  OnItemIntPropertyChanged: function(aItem, aProperty, aOld, aNew) {
+  OnItemPropertyChanged(aItem, aProperty, aOld, aNew) {},
+  OnItemIntPropertyChanged(aItem, aProperty, aOld, aNew) {
     if (aItem === gInbox) {
       dump("Property change on folder Inbox:" + aProperty + "=" + aOld + "->" + aNew + "\n");
       if (aProperty == "FolderSize")
         this.folderSize.push(aNew);
       else if (aProperty == "TotalMessages")
         this.totalMsgs.push(aNew);
     }
   },
-  OnItemBoolPropertyChanged: function(aItem, aProperty, aOld, aNew) {},
-  OnItemUnicharPropertyChanged: function(aItem, aProperty, aOld, aNew) {},
-  OnItemPropertyFlagChanged: function(aItem, aProperty, aOld, aNew) {},
-  OnItemEvent: function(aFolder, aEvent) {},
+  OnItemBoolPropertyChanged(aItem, aProperty, aOld, aNew) {},
+  OnItemUnicharPropertyChanged(aItem, aProperty, aOld, aNew) {},
+  OnItemPropertyFlagChanged(aItem, aProperty, aOld, aNew) {},
+  OnItemEvent(aFolder, aEvent) {},
 };
 
 /**
  * Allow folders to grow over 4GB.
  */
 function allow4GBFolders(aOn) {
   Services.prefs.setBoolPref("mailnews.allowMboxOver4GB", aOn);
 }
@@ -117,18 +121,18 @@ function growInbox(aWantedSize) {
   // Grow local inbox to our wished size that is below the max limit.
   do {
     let sparseStart = gInboxFile.clone().fileSize + mboxString.length;
     let nextOffset = Math.min(sparseStart + kSparseBlockSize, aWantedSize - 2);
     if ((aWantedSize - (nextOffset + 2)) < (mboxString.length + 2))
       nextOffset = aWantedSize - 2;
 
     // Get stream to write a new message.
-    let reusable = new Object;
-    let newMsgHdr = new Object;
+    let reusable = {};
+    let newMsgHdr = {};
     let outputStream = plugStore.getNewMsgOutputStream(gInbox, newMsgHdr, reusable)
                                 .QueryInterface(Ci.nsISeekableStream);
     // Write message header.
     outputStream.write(mboxString, mboxString.length);
     outputStream.close();
 
     // "Add" a new (empty) sparse block at the end of the file.
     if (nextOffset - sparseStart == kSparseBlockSize)
@@ -156,36 +160,34 @@ function growInbox(aWantedSize) {
 
   Assert.equal(gInboxFile.clone().fileSize, aWantedSize);
   info("Local inbox size = " + localSize + "bytes = " +
        mailTestUtils.toMiBString(localSize));
   Assert.equal(localSize, aWantedSize);
   return msgsAdded;
 }
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   allow4GBFolders(false);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
   do_test_pending();
 
   gInbox = localAccountUtils.inboxFolder;
   gInboxFile = gInbox.filePath;
 
   let neededFreeSpace = kSizeLimit + 0x10000000; // +256MiB
   // On Windows, check whether the drive is NTFS. If it is, mark the file as
   // sparse. If it isn't, then bail out now, because in all probability it is
   // FAT32, which doesn't support file sizes greater than 4 GiB.
   if ("@mozilla.org/windows-registry-key;1" in Cc &&
-      mailTestUtils.get_file_system(gInboxFile) != "NTFS")
-  {
+      mailTestUtils.get_file_system(gInboxFile) != "NTFS") {
     dump("On Windows, this test only works on NTFS volumes.\n");
 
     endTest();
     return;
   }
 
   let freeDiskSpace = gInboxFile.diskSpaceAvailable;
   info("Free disk space = " + mailTestUtils.toMiBString(freeDiskSpace));
@@ -213,18 +215,17 @@ function run_test()
     Assert.equal(ex.result, Cr.NS_ERROR_NOT_INITIALIZED);
   }
   // Execution continues in downloadUnder4GiB() when done.
 }
 
 /**
  * Check we can download new mail when we are near 4GiB limit but do not cross it.
  */
-function downloadUnder4GiB()
-{
+function downloadUnder4GiB() {
   // Check fake POP3 server is ready.
   Assert.notEqual(gPOP3Pump.fakeServer, null);
 
   // Download a file that still fits into the limit.
   let bigFile = do_get_file("../../../data/mime-torture");
   Assert.ok(bigFile.fileSize >= 1024 * 1024);
   Assert.ok(bigFile.fileSize <= 1024 * 1024 * 2);
 
@@ -234,18 +235,17 @@ function downloadUnder4GiB()
   gPOP3Pump.run(Cr.NS_OK);
   // Execution continues in downloadOver4GiB_fail() when done.
 }
 
 /**
  * Bug 640371
  * Check we will not cross the 4GiB limit when downloading new mail.
  */
-function downloadOver4GiB_fail()
-{
+function downloadOver4GiB_fail() {
   let localInboxSize = gInboxFile.clone().fileSize;
   Assert.ok(localInboxSize >= kNearLimit);
   Assert.ok(localInboxSize < kSizeLimit);
   Assert.equal(gInbox.sizeOnDisk, localInboxSize);
   Assert.ok(gInbox.msgDatabase.summaryValid);
   // The big file is between 1 and 2 MiB. Append it 16 times to attempt to cross the 4GiB limit.
   gPOP3Pump.files = ["../../../data/mime-torture", "../../../data/mime-torture",
                      "../../../data/mime-torture", "../../../data/mime-torture",
@@ -260,18 +260,17 @@ function downloadOver4GiB_fail()
   gPOP3Pump.run(Cr.NS_ERROR_FAILURE);
   // Execution continues in downloadOver4GiB_success() when done.
 }
 
 /**
  * Bug 789679
  * Check we can cross the 4GiB limit when downloading new mail.
  */
-function downloadOver4GiB_success()
-{
+function downloadOver4GiB_success() {
   allow4GBFolders(true);
   // Grow inbox to size greater than the max limit (+16 MiB).
   gExpectedNewMessages = 16;
   // We are in the .onDone() callback of the previous run of gPOP3Pump
   // so we need a new POP3Pump so that internal variables of the previous
   // one don't get confused.
   // TODO: this whole test file should be converted to the new
   // Promise-based task framework to solve this problem cleanly.
@@ -290,18 +289,17 @@ function downloadOver4GiB_success()
   gPOP3Pump.run(Cr.NS_OK);
   // Execution continues in growOver4GiB_success_check() when done.
 }
 
 /**
  * Bug 608449
  * Check we can parse a folder if it is above 4GiB.
  */
-function downloadOver4GiB_success_check()
-{
+function downloadOver4GiB_success_check() {
   let localInboxSize = gInboxFile.clone().fileSize;
   dump("Local inbox size (after downloadOver4GiB_success) = " + localInboxSize + "\n");
   Assert.ok(localInboxSize > kSizeLimit);
   Assert.ok(gInbox.msgDatabase.summaryValid);
 
   // Bug 789679
   // Check if the public SizeOnDisk method can return sizes above 4GB.
   Assert.equal(gInbox.sizeOnDisk, localInboxSize);
@@ -327,50 +325,47 @@ function downloadOver4GiB_success_check(
 
   copyIntoOver4GiB_fail();
 }
 
 /**
  * Bug 598104
  * Check that copy operation does not allow to grow a local folder above 4 GiB.
  */
-function copyIntoOver4GiB_fail()
-{
+function copyIntoOver4GiB_fail() {
   allow4GBFolders(false);
   // Save initial file size.
   let localInboxSize = gInboxFile.clone().fileSize;
   info("Local inbox size (before copyFileMessageInLocalFolder()) = " +
        localInboxSize);
 
   // Use copyFileMessageInLocalFolder() to (try to) append another message
   // to local inbox.
   gGotAlert = false;
   let file = do_get_file("../../../data/mime-torture");
   copyFileMessageInLocalFolder(file, 0, "", gDummyMsgWindow, copyIntoOver4GiB_fail_check);
 }
 
-function copyIntoOver4GiB_fail_check(aMessageHeadersKeys, aStatus)
-{
+function copyIntoOver4GiB_fail_check(aMessageHeadersKeys, aStatus) {
   Assert.ok(!Components.isSuccessCode(aStatus));
   Assert.equal(aMessageHeadersKeys.length, 0);
   Assert.ok(gGotAlert);
 
   // Make sure inbox file did not grow (i.e., no data were appended).
   let newLocalInboxSize = gInboxFile.clone().fileSize;
   info("Local inbox size (after copyFileMessageInLocalFolder()) = " +
        newLocalInboxSize);
   copyIntoOver4GiB_success();
 }
 
 /**
  * Bug 789679
  * Check that copy operation does allow to grow a local folder above 4 GiB.
  */
-function copyIntoOver4GiB_success()
-{
+function copyIntoOver4GiB_success() {
   allow4GBFolders(true);
   // Append 2 new 2MB messages to the folder.
   gExpectedNewMessages = 2;
 
   // This message will be preserved in CompactUnder4GB.
   gGotAlert = false;
   let file = do_get_file("../../../data/mime-torture");
   copyFileMessageInLocalFolder(file, 0, "", gDummyMsgWindow, copyIntoOver4GiB_success_check1);
@@ -396,18 +391,17 @@ function copyIntoOver4GiB_success_check2
 
   compactOver4GiB();
 }
 
 /**
  * Bug 794303
  * Check we can compact a folder that stays above 4 GiB after compact.
  */
-function compactOver4GiB()
-{
+function compactOver4GiB() {
   gInboxSize = gInboxFile.clone().fileSize;
   Assert.ok(gInboxSize > kSizeLimit);
   Assert.equal(gInbox.expungedBytes, 0);
   // Delete the last small message at folder end.
   let enumerator = gInbox.messages;
   let messages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
   let sizeToExpunge = 0;
   while (enumerator.hasMoreElements()) {
@@ -436,18 +430,17 @@ function compactOver4GiB()
     compactUnder4GiB();
   }
 }
 
 /**
  * Bug 608449
  * Check we can compact a folder to get it under 4 GiB.
  */
-function compactUnder4GiB()
-{
+function compactUnder4GiB() {
   // The folder is still above 4GB.
   Assert.ok(gInboxFile.clone().fileSize > kSizeLimit);
   let folderSize = gInbox.sizeOnDisk;
   let totalMsgs = gInbox.getTotalMessages(false);
   // Let's close the database and re-open the folder (hopefully dumping memory caches)
   // and re-reading the values from disk (msg database). That is to test if
   // the values were properly serialized to the database.
   gInbox.ForceDBClosed();
@@ -477,58 +470,55 @@ function compactUnder4GiB()
   Assert.ok(sizeToExpunge > kSizeLimit);
 
   // Note: compact() will also add 'X-Mozilla-Status' and 'X-Mozilla-Status2'
   // lines to message(s).
   gInbox.compact(CompactListener_compactUnder4GiB, null);
   // Test ends after compaction is done.
 }
 
-var ParseListener_run_test =
-{
-  OnStartRunningUrl: function (aUrl) {},
-  OnStopRunningUrl: function (aUrl, aExitCode) {
+var ParseListener_run_test = {
+  OnStartRunningUrl(aUrl) {},
+  OnStopRunningUrl(aUrl, aExitCode) {
     // Check: reparse successful
     Assert.equal(aExitCode, Cr.NS_OK);
     Assert.notEqual(gInbox.msgDatabase, null);
     Assert.ok(gInbox.msgDatabase.summaryValid);
     // Bug 813459
     // Check if the OnItemIntPropertyChanged folder listener hook can return
     // values below 2^32 for properties which are not 64 bits long.
     Assert.equal(FListener.msgsHistory(0), gExpectedNewMessages);
     Assert.equal(FListener.msgsHistory(0), gInbox.getTotalMessages(false));
     Assert.equal(FListener.sizeHistory(0), gInbox.sizeOnDisk);
 
     downloadUnder4GiB();
-  }
+  },
 };
 
-var CompactListener_compactOver4GiB =
-{
-  OnStartRunningUrl: function (aUrl) {},
-  OnStopRunningUrl: function (aUrl, aExitCode) {
+var CompactListener_compactOver4GiB = {
+  OnStartRunningUrl(aUrl) {},
+  OnStopRunningUrl(aUrl, aExitCode) {
     // Check: message successfully copied.
     Assert.equal(aExitCode, Cr.NS_OK);
     Assert.ok(gInbox.msgDatabase.summaryValid);
     // Check that folder size is still above max limit ...
     let localInboxSize = gInbox.filePath.clone().fileSize;
     info("Local inbox size (after compact 1) = " + localInboxSize);
     Assert.ok(localInboxSize > kSizeLimit);
     // ... but it got smaller by removing 1 message.
     Assert.ok(gInboxSize > localInboxSize);
     Assert.equal(gInbox.sizeOnDisk, localInboxSize);
 
     compactUnder4GiB();
-  }
+  },
 };
 
-var CompactListener_compactUnder4GiB =
-{
-  OnStartRunningUrl: function (aUrl) {},
-  OnStopRunningUrl: function (aUrl, aExitCode) {
+var CompactListener_compactUnder4GiB = {
+  OnStartRunningUrl(aUrl) {},
+  OnStopRunningUrl(aUrl, aExitCode) {
     // Check: message successfully copied.
     Assert.equal(aExitCode, Cr.NS_OK);
     Assert.ok(gInbox.msgDatabase.summaryValid);
 
     // Check that folder size isn't much bigger than our sparse block size, ...
     let localInboxSize = gInbox.filePath.clone().fileSize;
     info("Local inbox size (after compact 2) = " + localInboxSize);
     Assert.equal(gInbox.sizeOnDisk, localInboxSize);
@@ -537,21 +527,20 @@ var CompactListener_compactUnder4GiB =
     Assert.equal(gInbox.getTotalMessages(false), 1);
     Assert.equal(FListener.sizeHistory(0), gInbox.sizeOnDisk);
     Assert.equal(FListener.msgsHistory(0), 1);
 
     // The message has its key preserved in compact.
     Assert.equal(gInbox.messages.getNext().QueryInterface(Ci.nsIMsgDBHdr).messageKey, 60);
 
     endTest();
-  }
+  },
 };
 
-function endTest()
-{
+function endTest() {
   MailServices.mailSession.RemoveFolderListener(FListener);
   // Free up disk space - if you want to look at the file after running
   // this test, comment out this line.
   gInbox.filePath.remove(false);
   Services.prefs.clearUserPref("mailnews.allowMboxOver4GB");
 
   do_test_finished();
 }
--- a/mailnews/local/test/unit/test_pop3AuthMethods.js
+++ b/mailnews/local/test/unit/test_pop3AuthMethods.js
@@ -1,73 +1,75 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Login tests for POP3
  *
  * Test code <copied from="test_pop3GetNewMail.js">
  */
 
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-
 var server;
-var daemon;
 var handler;
 var incomingServer;
 var thisTest;
-var test = null;
 
-var tests = [
-  { title: "Cleartext password, with server only supporting USER/PASS",
-    clientAuthMethod : Ci.nsMsgAuthMethod.passwordCleartext,
-    serverAuthMethods : [],
-    expectSuccess : true,
-    transaction: [ "AUTH", "CAPA", "USER fred", "PASS wilma", "STAT" ] },
+var tests = [{
+  title: "Cleartext password, with server only supporting USER/PASS",
+  clientAuthMethod: Ci.nsMsgAuthMethod.passwordCleartext,
+  serverAuthMethods: [],
+  expectSuccess: true,
+  transaction: ["AUTH", "CAPA", "USER fred", "PASS wilma", "STAT"],
+}, {
   // Just to make sure we clear the auth flags and re-issue "AUTH"
-  { title: "Second time Cleartext password, with server only supporting USER/PASS",
-    clientAuthMethod : Ci.nsMsgAuthMethod.passwordCleartext,
-    serverAuthMethods : [],
-    expectSuccess : true,
-    transaction: [ "AUTH", "CAPA", "USER fred", "PASS wilma", "STAT" ] },
-  { title: "Cleartext password, with server supporting AUTH PLAIN, LOGIN and CRAM",
-    clientAuthMethod : Ci.nsMsgAuthMethod.passwordCleartext,
-    serverAuthMethods : [ "PLAIN", "LOGIN", "CRAM-MD5" ],
-    expectSuccess : true,
-    transaction: [ "AUTH", "CAPA", "AUTH PLAIN", "STAT" ] },
-  { title: "Cleartext password, with server supporting only AUTH LOGIN",
-    clientAuthMethod : Ci.nsMsgAuthMethod.passwordCleartext,
-    serverAuthMethods : [ "LOGIN" ],
-    expectSuccess : true,
-    transaction: [ "AUTH", "CAPA", "AUTH LOGIN", "STAT" ] },
-  { title: "Encrypted password, with server supporting PLAIN and CRAM",
-    clientAuthMethod : Ci.nsMsgAuthMethod.passwordEncrypted,
-    serverAuthMethods : [ "PLAIN", "LOGIN", "CRAM-MD5" ],
-    expectSuccess : true,
-    transaction: [ "AUTH", "CAPA", "AUTH CRAM-MD5", "STAT" ] },
-  { title: "Encrypted password, with server only supporting AUTH PLAIN and LOGIN (must fail)",
-    clientAuthMethod : Ci.nsMsgAuthMethod.passwordEncrypted,
-    serverAuthMethods : [ "PLAIN", "LOGIN" ],
-    expectSuccess : false,
-    transaction: [ "AUTH", "CAPA"] },
-  { title: "Any secure method, with server supporting AUTH PLAIN and CRAM",
-    clientAuthMethod : Ci.nsMsgAuthMethod.secure,
-    serverAuthMethods : [ "PLAIN" , "LOGIN", "CRAM-MD5" ],
-    expectSuccess : true,
-    transaction: [ "AUTH", "CAPA", "AUTH CRAM-MD5", "STAT" ] },
-  { title: "Any secure method, with server only supporting AUTH PLAIN and LOGIN (must fail)",
-    clientAuthMethod : Ci.nsMsgAuthMethod.secure,
-    serverAuthMethods : [ "PLAIN" ],
-    expectSuccess : false,
-    transaction: [ "AUTH", "CAPA" ] }
-];
+  title: "Second time Cleartext password, with server only supporting USER/PASS",
+  clientAuthMethod: Ci.nsMsgAuthMethod.passwordCleartext,
+  serverAuthMethods: [],
+  expectSuccess: true,
+  transaction: ["AUTH", "CAPA", "USER fred", "PASS wilma", "STAT"],
+}, {
+  title: "Cleartext password, with server supporting AUTH PLAIN, LOGIN and CRAM",
+  clientAuthMethod: Ci.nsMsgAuthMethod.passwordCleartext,
+  serverAuthMethods: ["PLAIN", "LOGIN", "CRAM-MD5"],
+  expectSuccess: true,
+  transaction: ["AUTH", "CAPA", "AUTH PLAIN", "STAT"],
+}, {
+  title: "Cleartext password, with server supporting only AUTH LOGIN",
+  clientAuthMethod: Ci.nsMsgAuthMethod.passwordCleartext,
+  serverAuthMethods: ["LOGIN"],
+  expectSuccess: true,
+  transaction: ["AUTH", "CAPA", "AUTH LOGIN", "STAT"],
+}, {
+  title: "Encrypted password, with server supporting PLAIN and CRAM",
+  clientAuthMethod: Ci.nsMsgAuthMethod.passwordEncrypted,
+  serverAuthMethods: ["PLAIN", "LOGIN", "CRAM-MD5"],
+  expectSuccess: true,
+  transaction: ["AUTH", "CAPA", "AUTH CRAM-MD5", "STAT"],
+}, {
+  title: "Encrypted password, with server only supporting AUTH PLAIN and LOGIN (must fail)",
+  clientAuthMethod: Ci.nsMsgAuthMethod.passwordEncrypted,
+  serverAuthMethods: ["PLAIN", "LOGIN"],
+  expectSuccess: false,
+  transaction: ["AUTH", "CAPA"],
+}, {
+  title: "Any secure method, with server supporting AUTH PLAIN and CRAM",
+  clientAuthMethod: Ci.nsMsgAuthMethod.secure,
+  serverAuthMethods: ["PLAIN", "LOGIN", "CRAM-MD5"],
+  expectSuccess: true,
+  transaction: ["AUTH", "CAPA", "AUTH CRAM-MD5", "STAT"],
+}, {
+  title: "Any secure method, with server only supporting AUTH PLAIN and LOGIN (must fail)",
+  clientAuthMethod: Ci.nsMsgAuthMethod.secure,
+  serverAuthMethods: ["PLAIN"],
+  expectSuccess: false,
+  transaction: ["AUTH", "CAPA"],
+}];
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       if (thisTest.expectSuccess)
         Assert.equal(result, 0);
       else
         Assert.notEqual(result, 0);
 
       var transaction = server.playTransaction();
       do_check_transaction(transaction, thisTest.transaction);
@@ -76,17 +78,17 @@ var urlListener =
     } catch (e) {
       server.stop();
       var thread = gThreadManager.currentThread;
       while (thread.hasPendingEvents())
         thread.processNextEvent(true);
 
       do_throw(e);
     }
-  }
+  },
 };
 
 function checkBusy() {
   if (tests.length == 0) {
     incomingServer.closeCachedConnections();
 
     // No more tests, let everything finish
     server.stop();
@@ -137,45 +139,42 @@ function testNext() {
     server.performTest();
   } catch (e) {
     server.stop();
     do_throw(e);
   }
 }
 
 // <copied from="head_maillocal.js::createPop3ServerAndLocalFolders()">
-function createPop3Server()
-{
+function createPop3Server() {
   let incoming = MailServices.accounts.createIncomingServer("fred", "localhost", "pop3");
   incoming.port = server.port;
   incoming.password = "wilma";
   return incoming;
 }
-//</copied>
+// </copied>
 
-function deletePop3Server()
-{
+function deletePop3Server() {
   if (!incomingServer)
     return;
   MailServices.accounts.removeIncomingServer(incomingServer, true);
   incomingServer = null;
 }
 
 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);
 
-  ssd = setupServerDaemon();
-  daemon = ssd[0];
+  let ssd = setupServerDaemon();
   server = ssd[1];
   handler = ssd[2];
   server.start();
 
-  //incomingServer = createPop3ServerAndLocalFolders();
+  // incomingServer = createPop3ServerAndLocalFolders();
   localAccountUtils.loadLocalMailAccount();
 
   do_test_pending();
 
   testNext();
 }
--- a/mailnews/local/test/unit/test_pop3Download.js
+++ b/mailnews/local/test/unit/test_pop3Download.js
@@ -1,82 +1,78 @@
 /**
  * The intent of this file is to test that pop3 download code message storage
  * works correctly.
  */
+
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var testSubjects = ["[Bug 397009] A filter will let me tag, but not untag",
                     "Hello, did you receive my bugmail?",
                     "[Bug 655578] list-id filter broken"];
 
 var gMsgHdrs = [];
 var gHdrIndex = 0;
 var gFiles = ["../../../data/bugmail1",
               "../../../data/draft1",
               "../../../data/bugmail19"];
 
 // This combination of prefs is required to reproduce bug 713611, which
 // is what this test is about.
 Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
 Services.prefs.setBoolPref("mail.server.default.leave_on_server", true);
 
-function run_test()
-{
+function run_test() {
   // add 3 messages
   gPOP3Pump.files = gFiles;
   gPOP3Pump.onDone = continueTest;
   do_test_pending();
   gPOP3Pump.run();
 }
 
-function continueTest()
-{
+function continueTest() {
   // get message headers for the inbox folder
   let enumerator = localAccountUtils.inboxFolder.msgDatabase.EnumerateMessages();
   var msgCount = 0;
-  let hdr;
-  while (enumerator.hasMoreElements())
-  {
+  while (enumerator.hasMoreElements()) {
     let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     gMsgHdrs.push(hdr);
     Assert.equal(hdr.subject, testSubjects[msgCount++]);
   }
   Assert.equal(msgCount, 3);
   gPOP3Pump = null;
   streamNextMessage();
 }
 
-function streamNextMessage()
-{
+function streamNextMessage() {
   let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
   let msghdr = gMsgHdrs[gHdrIndex];
   let msgURI = msghdr.folder.getUriForMsg(msghdr);
   let msgServ = messenger.messageServiceFromURI(msgURI);
   msgServ.streamMessage(msgURI, gStreamListener, null, null, false, "", true);
 }
 
-gStreamListener = {
-  QueryInterface : ChromeUtils.generateQI([Ci.nsIStreamListener]),
-  _stream : null,
-  _data : null,
-  onStartRequest : function (aRequest, aContext) {
+var gStreamListener = {
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIStreamListener]),
+  _stream: null,
+  _data: null,
+  onStartRequest(aRequest, aContext) {
     this._stream = null;
     this._data = "";
   },
-  onStopRequest : function (aRequest, aContext, aStatusCode) {
+  onStopRequest(aRequest, aContext, aStatusCode) {
     // check that the streamed message starts with "From "
     Assert.ok(this._data.startsWith("From "));
     if (++gHdrIndex == gFiles.length)
       do_test_finished();
     else
       streamNextMessage();
   },
-  onDataAvailable : function (aRequest, aContext, aInputStream, aOff, aCount) {
+  onDataAvailable(aRequest, aContext, aInputStream, aOff, aCount) {
     if (this._stream == null) {
       this._stream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
       this._stream.init(aInputStream);
     }
     this._data += this._stream.read(aCount);
   },
 };
 
--- a/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js
+++ b/mailnews/local/test/unit/test_pop3DownloadTempFileHandling.js
@@ -1,45 +1,43 @@
 /**
  * The intent of this file is to test temp file handling when
  * downloading multiple pop3 messages with quarantining turned on.
  *
  * Original author: David Bienvenu <dbienvenu@mozilla.com>
  */
+
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var testSubjects = ["[Bug 397009] A filter will let me tag, but not untag",
                     "Hello, did you receive my bugmail?"];
 var gExpectedFiles;
 
-function run_test()
-{
+function run_test() {
   Services.prefs.setBoolPref("mailnews.downloadToTempFile", true);
   gExpectedFiles = createExpectedTemporaryFiles(2);
   // add 2 messages
   gPOP3Pump.files = ["../../../data/bugmail1",
                      "../../../data/draft1"];
   gPOP3Pump.onDone = continueTest;
   do_test_pending();
   gPOP3Pump.run();
 }
 
-function continueTest()
-{
+function continueTest() {
   dump("temp file path = " + gExpectedFiles[0].path + "\n");
   dump("temp file path = " + gExpectedFiles[1].path + "\n");
   for (let expectedFile of gExpectedFiles)
     Assert.ok(!expectedFile.exists());
 
   // get message headers for the inbox folder
   let enumerator = localAccountUtils.inboxFolder.msgDatabase.EnumerateMessages();
   var msgCount = 0;
-  while (enumerator.hasMoreElements())
-  {
+  while (enumerator.hasMoreElements()) {
     let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     Assert.equal(hdr.subject, testSubjects[msgCount++]);
   }
   Assert.equal(msgCount, 2);
   gPOP3Pump = null;
   do_test_finished();
 }
 
@@ -47,17 +45,17 @@ function createExpectedTemporaryFiles(nu
   function createTemporaryFile() {
     let file = Services.dirsvc.get("TmpD", Ci.nsIFile);
     file.append("newmsg");
     file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
     return file;
   }
 
   let expectedFiles = [];
-  for (i = 0; i < numFiles; i++)
+  for (let i = 0; i < numFiles; i++)
     expectedFiles.push(createTemporaryFile());
 
   for (let expectedFile of expectedFiles)
     expectedFile.remove(false);
 
   return expectedFiles;
 }
 
--- a/mailnews/local/test/unit/test_pop3Duplicates.js
+++ b/mailnews/local/test/unit/test_pop3Duplicates.js
@@ -1,38 +1,36 @@
 /**
  * The intent of this file is to test duplicate handling options
  * in the pop3 download code.
  */
+
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var testSubjects = ["[Bug 397009] A filter will let me tag, but not untag",
                     "Hello, did you receive my bugmail?"];
 
-function run_test()
-{
+function run_test() {
   // Set duplicate action to be delete duplicates.
   Services.prefs.setIntPref("mail.server.default.dup_action",
                             Ci.nsIMsgIncomingServer.deleteDups);
   // add 3 messages, 2 of which are duplicates.
   gPOP3Pump.files = ["../../../data/bugmail1",
                      "../../../data/draft1",
                      "../../../data/bugmail1"];
   gPOP3Pump.onDone = continueTest;
   do_test_pending();
   gPOP3Pump.run();
 }
 
-function continueTest()
-{
+function continueTest() {
   // get message headers for the inbox folder
   let enumerator = localAccountUtils.inboxFolder.msgDatabase.EnumerateMessages();
   var msgCount = 0;
-  while (enumerator.hasMoreElements())
-  {
+  while (enumerator.hasMoreElements()) {
     let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     Assert.equal(hdr.subject, testSubjects[msgCount++]);
   }
   Assert.equal(msgCount, 2);
   gPOP3Pump = null;
   do_test_finished();
 }
--- a/mailnews/local/test/unit/test_pop3FilterActions.js
+++ b/mailnews/local/test/unit/test_pop3FilterActions.js
@@ -1,43 +1,39 @@
 /*
  * This file tests that a pop3 add tag filter writes the new tag
  * into the message keywords header. It also tests marking read,
  * and flagging messages.
  *
  * Original author: David Bienvenu <dbienvenu@mozilla.com>
  */
 
-
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
 var gFiles = ["../../../data/bugmail10", "../../../data/bugmail11"];
 
 Services.prefs.setBoolPref("mail.server.default.leave_on_server", true);
 
 // Currently we have two mailbox storage formats.
 var gPluggableStores = [
   "@mozilla.org/msgstore/berkeleystore;1",
-  "@mozilla.org/msgstore/maildirstore;1"
+  "@mozilla.org/msgstore/maildirstore;1",
 ];
 
 // Map subject to previews using subject as the key.
 var previews = {
-"[Bug 436880] IMAP itemDeleted and itemMoveCopyCompleted notifications quite broken": 'Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----',
-"Bugzilla: confirm account creation": 'Bugzilla has received a request to create a user account using your email address (example@example.org). To confirm that you want to create an account using that email address, visit the following link: https://bugzilla.mozilla.org/token.cgi?t=xxx'
-}
+  "[Bug 436880] IMAP itemDeleted and itemMoveCopyCompleted notifications quite broken": "Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----",
+  "Bugzilla: confirm account creation": "Bugzilla has received a request to create a user account using your email address (example@example.org). To confirm that you want to create an account using that email address, visit the following link: https://bugzilla.mozilla.org/token.cgi?t=xxx",
+};
 
 var gFilter; // the test filter
 var gFilterList;
-var gTestArray =
-[
+var gTestArray = [
   function createFilters() {
     gFilterList = gPOP3Pump.fakeServer.getFilterList(null);
     gFilter = gFilterList.createFilter("AddKeyword");
     let searchTerm = gFilter.createTerm();
     searchTerm.matchAll = true;
     gFilter.appendTerm(searchTerm);
     let tagAction = gFilter.createAction();
     tagAction.type = Ci.nsMsgFilterAction.AddTag;
@@ -87,67 +83,62 @@ var gTestArray =
     while (enumerator.hasMoreElements()) {
       let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
       keys.push(hdr.messageKey);
       hdrs.push(hdr);
     }
     Assert.ok(!localAccountUtils.inboxFolder
                                 .fetchMsgPreviewText(keys, keys.length,
                                                      false, null));
-    let preview1 = hdrs[0].getStringProperty('preview');
-    let preview2 = hdrs[1].getStringProperty('preview');
+    let preview1 = hdrs[0].getStringProperty("preview");
+    let preview2 = hdrs[1].getStringProperty("preview");
     Assert.equal(preview1, previews[hdrs[0].subject]);
     Assert.equal(preview2, previews[hdrs[1].subject]);
-    Assert.equal(hdrs[0].getStringProperty('keywords'), "TheTag");
-    Assert.equal(hdrs[1].getStringProperty('keywords'), "TheTag");
+    Assert.equal(hdrs[0].getStringProperty("keywords"), "TheTag");
+    Assert.equal(hdrs[1].getStringProperty("keywords"), "TheTag");
     Assert.equal(hdrs[0].flags, Ci.nsMsgMessageFlags.Read |
                                 Ci.nsMsgMessageFlags.Marked);
     Assert.equal(hdrs[1].flags, Ci.nsMsgMessageFlags.Read |
                                 Ci.nsMsgMessageFlags.Marked);
-  }
+  },
 ];
 
-function folderCount(folder)
-{
+function folderCount(folder) {
   let enumerator = folder.msgDatabase.EnumerateMessages();
   let count = 0;
-  while (enumerator.hasMoreElements())
-  {
+  while (enumerator.hasMoreElements()) {
     count++;
-    let hdr = enumerator.getNext();
+    enumerator.getNext();
   }
   return count;
 }
 
-function setup_store(storeID)
-{
+function setup_store(storeID) {
   return function _setup_store() {
     // Initialize pop3Pump with correct mailbox format.
     gPOP3Pump.resetPluggableStore(storeID);
 
     // Set the default mailbox store.
     Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                                storeID);
 
     // Make sure we're not quarantining messages
     Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
 
     if (!localAccountUtils.inboxFolder)
       localAccountUtils.loadLocalMailAccount();
-  }
+  };
 }
 
-function run_test()
-{
+function run_test() {
   for (let store of gPluggableStores) {
     add_task(setup_store(store));
     gTestArray.forEach(x => add_task(x));
   }
 
   add_task(exitTest);
   run_next_test();
 }
 
-function exitTest()
-{
+function exitTest() {
   info("Exiting mail tests\n");
   gPOP3Pump = null;
 }
--- a/mailnews/local/test/unit/test_pop3GSSAPIFail.js
+++ b/mailnews/local/test/unit/test_pop3GSSAPIFail.js
@@ -13,59 +13,59 @@
  * of reality of the above cases.
  *
  * Actually, we (more precisely the OS GSSAPI lib) fail out of band
  * in the Kerberos protocol, before the AUTH GSSAPI command is even issued.
  *
  * @author Ben Bucksch
  */
 
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-
 var server;
 var daemon;
 var authSchemes;
 var incomingServer;
 var thisTest;
-var test = null;
 
-var tests = [
-  { title: "GSSAPI auth, server with GSSAPI only",
-    clientAuthMethod : Ci.nsMsgAuthMethod.GSSAPI,
-    serverAuthMethods : [ "GSSAPI" ],
-    expectSuccess : false,
-    transaction: [ "AUTH", "CAPA" ] },
-    // First GSSAPI step happens and fails out of band, thus no "AUTH GSSAPI"
-  { title: "GSSAPI auth, server with GSSAPI and CRAM-MD5",
-    clientAuthMethod : Ci.nsMsgAuthMethod.GSSAPI,
-    serverAuthMethods : [ "GSSAPI", "CRAM-MD5" ],
-    expectSuccess : false,
-    transaction: [ "AUTH", "CAPA" ] },
-  { title: "Any secure auth, server with GSSAPI only",
-    clientAuthMethod : Ci.nsMsgAuthMethod.secure,
-    serverAuthMethods : [ "GSSAPI" ],
-    expectSuccess : false,
-    transaction: [ "AUTH", "CAPA" ] },
-  { title: "Any secure auth, server with GSSAPI and CRAM-MD5",
-    clientAuthMethod : Ci.nsMsgAuthMethod.secure,
-    serverAuthMethods : [ "GSSAPI", "CRAM-MD5" ],
-    expectSuccess : true,
-    transaction: [ "AUTH", "CAPA", "AUTH CRAM-MD5", "STAT" ] },
-  { title: "Encrypted password, server with GSSAPI and CRAM-MD5",
-    clientAuthMethod : Ci.nsMsgAuthMethod.passwordEncrypted,
-    serverAuthMethods : [ "GSSAPI", "CRAM-MD5" ],
-    expectSuccess : true,
-    transaction: [ "AUTH", "CAPA", "AUTH CRAM-MD5", "STAT" ] },
-];
+var tests = [{
+  title: "GSSAPI auth, server with GSSAPI only",
+  clientAuthMethod: Ci.nsMsgAuthMethod.GSSAPI,
+  serverAuthMethods: ["GSSAPI"],
+  expectSuccess: false,
+  transaction: ["AUTH", "CAPA"],
+}, {
+  // First GSSAPI step happens and fails out of band, thus no "AUTH GSSAPI"
+  title: "GSSAPI auth, server with GSSAPI and CRAM-MD5",
+  clientAuthMethod: Ci.nsMsgAuthMethod.GSSAPI,
+  serverAuthMethods: ["GSSAPI", "CRAM-MD5"],
+  expectSuccess: false,
+  transaction: ["AUTH", "CAPA"],
+}, {
+  title: "Any secure auth, server with GSSAPI only",
+  clientAuthMethod: Ci.nsMsgAuthMethod.secure,
+  serverAuthMethods: ["GSSAPI"],
+  expectSuccess: false,
+  transaction: ["AUTH", "CAPA"],
+}, {
+  title: "Any secure auth, server with GSSAPI and CRAM-MD5",
+  clientAuthMethod: Ci.nsMsgAuthMethod.secure,
+  serverAuthMethods: ["GSSAPI", "CRAM-MD5"],
+  expectSuccess: true,
+  transaction: ["AUTH", "CAPA", "AUTH CRAM-MD5", "STAT"],
+}, {
+  title: "Encrypted password, server with GSSAPI and CRAM-MD5",
+  clientAuthMethod: Ci.nsMsgAuthMethod.passwordEncrypted,
+  serverAuthMethods: ["GSSAPI", "CRAM-MD5"],
+  expectSuccess: true,
+  transaction: ["AUTH", "CAPA", "AUTH CRAM-MD5", "STAT"],
+}];
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       if (thisTest.expectSuccess)
         Assert.equal(result, 0);
       else
         Assert.notEqual(result, 0);
 
       var transaction = server.playTransaction();
       do_check_transaction(transaction, thisTest.transaction);
@@ -74,17 +74,17 @@ var urlListener =
     } catch (e) {
       server.stop();
       var thread = gThreadManager.currentThread;
       while (thread.hasPendingEvents())
         thread.processNextEvent(true);
 
       do_throw(e);
     }
-  }
+  },
 };
 
 function checkBusy() {
   if (tests.length == 0) {
     incomingServer.closeCachedConnections();
 
     // No more tests, let everything finish
     server.stop();
@@ -134,65 +134,60 @@ function testNext() {
     server.performTest();
   } catch (e) {
     server.stop();
     do_throw(e);
   }
 }
 
 // <copied from="head_maillocal.js::createPop3ServerAndLocalFolders()">
-function createPop3Server()
-{
+function createPop3Server() {
   let incoming = MailServices.accounts.createIncomingServer("fred", "localhost", "pop3");
   incoming.port = server.port;
   incoming.password = "wilma";
   return incoming;
 }
-//</copied>
+// </copied>
 
-function deletePop3Server()
-{
+function deletePop3Server() {
   if (!incomingServer)
     return;
   MailServices.accounts.removeIncomingServer(incomingServer, true);
   incomingServer = null;
 }
 
-function GSSAPIFail_handler(daemon)
-{
-  POP3_RFC5034_handler.call(this, daemon);
+function GSSAPIFail_handler(daemon_) {
+  POP3_RFC5034_handler.call(this, daemon_);
 }
 GSSAPIFail_handler.prototype = {
-  __proto__ : POP3_RFC5034_handler.prototype, // inherit
-  _needGSSAPI : false,
+  __proto__: POP3_RFC5034_handler.prototype, // inherit
+  _needGSSAPI: false,
   // kAuthSchemes will be set by test
 
-  AUTH: function(restLine)
-  {
+  AUTH(restLine) {
     var scheme = restLine.split(" ")[0];
-    if (scheme == "GSSAPI")
-    {
+    if (scheme == "GSSAPI") {
       this._multiline = true;
       this._needGSSAPI = true;
       return "+";
     }
     return POP3_RFC5034_handler.prototype.AUTH.call(this, restLine); // call parent
   },
-  onMultiline: function(line) {
+  onMultiline(line) {
     if (this._needGSSAPI) {
       this._multiline = false;
       this._needGSSAPI = false;
       return "-ERR hm.... shall I allow you? hm... NO.";
     }
 
     if (POP3_RFC5034_handler.prototype.onMultiline)
       return POP3_RFC5034_handler.prototype.onMultiline.call(this, line); // call parent
     return undefined;
-  }
-}
+  },
+};
 
 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);
 
@@ -200,15 +195,15 @@ function run_test() {
   function createHandler(d) {
     var handler = new GSSAPIFail_handler(d);
     handler.kAuthSchemes = authSchemes;
     return handler;
   }
   server = new nsMailServer(createHandler, daemon);
   server.start();
 
-  //incomingServer = createPop3ServerAndLocalFolders();
+  // incomingServer = createPop3ServerAndLocalFolders();
   localAccountUtils.loadLocalMailAccount();
 
   do_test_pending();
 
   testNext();
 }
--- a/mailnews/local/test/unit/test_pop3GetNewMail.js
+++ b/mailnews/local/test/unit/test_pop3GetNewMail.js
@@ -1,60 +1,58 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Protocol tests for POP3.
  */
-var test = null;
 var server;
 var daemon;
 var incomingServer;
 var thisTest;
 
-var tests = [
-  { title: "Get New Mail, No Messages",
-    messages: [],
-    transaction: [ "AUTH", "CAPA", "AUTH PLAIN", "STAT" ] },
-  { title: "Get New Mail, No Messages 2",
-    messages: [],
-    transaction: [ "CAPA", "AUTH PLAIN", "STAT" ] },
-  { title: "Get New Mail, One Message",
-    messages: ["message1.eml"],
-    transaction: [ "CAPA", "AUTH PLAIN", "STAT", "LIST",
-                   "UIDL", "RETR 1", "DELE 1" ] }
-];
+var tests = [{
+  title: "Get New Mail, No Messages",
+  messages: [],
+  transaction: ["AUTH", "CAPA", "AUTH PLAIN", "STAT"],
+}, {
+  title: "Get New Mail, No Messages 2",
+  messages: [],
+  transaction: ["CAPA", "AUTH PLAIN", "STAT"],
+}, {
+  title: "Get New Mail, One Message",
+  messages: ["message1.eml"],
+  transaction: ["CAPA", "AUTH PLAIN", "STAT", "LIST", "UIDL", "RETR 1", "DELE 1"],
+}];
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       var transaction = server.playTransaction();
 
       do_check_transaction(transaction, thisTest.transaction);
 
       Assert.equal(localAccountUtils.inboxFolder.getTotalMessages(false),
                    thisTest.messages.length);
 
       Assert.equal(result, 0);
-    }
-    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);
     }
 
     // Let OnStopRunningUrl return cleanly before doing anything else.
     do_timeout(0, checkBusy);
-  }
+  },
 };
 
 function checkBusy() {
   if (tests.length == 0) {
     incomingServer.closeCachedConnections();
 
     // No more tests, let everything finish
     server.stop();
--- a/mailnews/local/test/unit/test_pop3MoveFilter.js
+++ b/mailnews/local/test/unit/test_pop3MoveFilter.js
@@ -1,44 +1,40 @@
 /*
  * This file tests that a pop3 move filter doesn't leave the
  * original message in the inbox.
  *
  * Original author: David Bienvenu <dbienvenu@mozilla.com>
  */
 
-
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
 var gFiles = ["../../../data/bugmail10", "../../../data/bugmail11"];
 
 // make sure limiting download size doesn't causes issues with move filters.
 Services.prefs.setBoolPref("mail.server.default.limit_offline_message_size", true);
 Services.prefs.setBoolPref("mail.server.default.leave_on_server", true);
 
 // Currently we have two mailbox storage formats.
 var gPluggableStores = [
   "@mozilla.org/msgstore/berkeleystore;1",
-  "@mozilla.org/msgstore/maildirstore;1"
+  "@mozilla.org/msgstore/maildirstore;1",
 ];
 
 var previews = {
-"[Bug 436880] IMAP itemDeleted and itemMoveCopyCompleted notifications quite broken": 'Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----',
-"Bugzilla: confirm account creation": 'Bugzilla has received a request to create a user account using your email address (example@example.org). To confirm that you want to create an account using that email address, visit the following link: https://bugzilla.mozilla.org/token.cgi?t=xxx'
+"[Bug 436880] IMAP itemDeleted and itemMoveCopyCompleted notifications quite broken": "Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----",
+"Bugzilla: confirm account creation": "Bugzilla has received a request to create a user account using your email address (example@example.org). To confirm that you want to create an account using that email address, visit the following link: https://bugzilla.mozilla.org/token.cgi?t=xxx",
 };
 
 var gMoveFolder;
 var gFilter; // the test filter
 var gFilterList;
-var gTestArray =
-[
+var gTestArray = [
   function createFilters() {
     gFilterList = gPOP3Pump.fakeServer.getFilterList(null);
     gFilter = gFilterList.createFilter("MoveAll");
     let searchTerm = gFilter.createTerm();
     searchTerm.matchAll = true;
     gFilter.appendTerm(searchTerm);
     let moveAction = gFilter.createAction();
     moveAction.type = Ci.nsMsgFilterAction.MoveToFolder;
@@ -62,80 +58,74 @@ var gTestArray =
     // the mail.
     localAccountUtils.inboxFolder.msgDatabase.summaryValid = false;
     localAccountUtils.inboxFolder.msgDatabase = null;
     localAccountUtils.inboxFolder.ForceDBClosed();
     let promiseUrlListener = new PromiseTestUtils.PromiseUrlListener();
     try {
       localAccountUtils.inboxFolder
                        .getDatabaseWithReparse(promiseUrlListener, null);
-    } catch(ex) {
+    } catch (ex) {
       await promiseUrlListener.promise;
       Assert.ok(ex.result == Cr.NS_ERROR_NOT_INITIALIZED);
       return;
     }
     // This statement isn't reached since the error is thrown.
     Assert.ok(false);
   },
   function verifyMessages() {
     let hdrs = [];
     let keys = [];
     let enumerator = gMoveFolder.msgDatabase.EnumerateMessages();
-    while (enumerator.hasMoreElements())
-    {
+    while (enumerator.hasMoreElements()) {
       let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
       keys.push(hdr.messageKey);
       hdrs.push(hdr);
     }
     Assert.ok(!gMoveFolder.fetchMsgPreviewText(keys, keys.length, false,
                                                null));
-    Assert.equal(hdrs[0].getStringProperty('preview'), previews[hdrs[0].subject]);
-    Assert.equal(hdrs[1].getStringProperty('preview'), previews[hdrs[1].subject]);
+    Assert.equal(hdrs[0].getStringProperty("preview"), previews[hdrs[0].subject]);
+    Assert.equal(hdrs[1].getStringProperty("preview"), previews[hdrs[1].subject]);
   },
 ];
 
-function folderCount(folder)
-{
+function folderCount(folder) {
   let enumerator = folder.msgDatabase.EnumerateMessages();
   let count = 0;
-  while (enumerator.hasMoreElements())
-  {
+  while (enumerator.hasMoreElements()) {
     count++;
-    let hdr = enumerator.getNext();
+    enumerator.getNext();
   }
   return count;
 }
 
-function setup_store(storeID)
-{
+function setup_store(storeID) {
   return function _setup_store() {
     // Reset pop3Pump with correct mailbox format.
     gPOP3Pump.resetPluggableStore(storeID);
 
     // Make sure we're not quarantining messages
     Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
 
     if (!localAccountUtils.inboxFolder)
       localAccountUtils.loadLocalMailAccount();
 
     gMoveFolder = localAccountUtils.rootFolder
                                    .createLocalSubfolder("MoveFolder");
-  }
+  };
 }
 
-function run_test()
-{
+function run_test() {
   for (let store of gPluggableStores) {
     add_task(setup_store(store));
     gTestArray.forEach(x => add_task(x));
   }
 
   add_task(exitTest);
   run_next_test();
 }
 
-function exitTest()
-{
+function exitTest() {
   // Cleanup and exit the test.
   info("Exiting mail tests\n");
   gPOP3Pump = null;
 }
 
--- a/mailnews/local/test/unit/test_pop3MoveFilter2.js
+++ b/mailnews/local/test/unit/test_pop3MoveFilter2.js
@@ -1,37 +1,34 @@
 /*
  * This file tests that a pop3 move filter doesn't reuse msg hdr
  * info from previous moves.
  *
  * Original author: David Bienvenu <dbienvenu@mozilla.com>
  */
 
 
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
 var gFiles = ["../../../data/bugmail10", "../../../data/basic1"];
 
 Services.prefs.setBoolPref("mail.server.default.leave_on_server", true);
 
 // Currently we have two mailbox storage formats.
 var gPluggableStores = [
   "@mozilla.org/msgstore/berkeleystore;1",
-  "@mozilla.org/msgstore/maildirstore;1"
+  "@mozilla.org/msgstore/maildirstore;1",
 ];
-var basic1_preview = 'Hello, world!';
-var bugmail10_preview = 'Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----';
+var basic1_preview = "Hello, world!";
+var bugmail10_preview = "Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----";
 
 var gMoveFolder;
 var gFilter; // the test filter
 var gFilterList;
-var gTestArray =
-[
+var gTestArray = [
   function createFilters() {
     gFilterList = gPOP3Pump.fakeServer.getFilterList(null);
     // create a cc filter which will match the first message but not the second.
     gFilter = gFilterList.createFilter("MoveCc");
     let searchTerm = gFilter.createTerm();
     searchTerm.attrib = Ci.nsMsgSearchAttrib.CC;
     searchTerm.op = Ci.nsMsgSearchOp.Contains;
     var oldValue = searchTerm.value;
@@ -62,71 +59,66 @@ var gTestArray =
     let hdrs = [];
     let keys = [];
     let enumerator = gMoveFolder.msgDatabase.EnumerateMessages();
     let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     keys.push(hdr.messageKey);
     hdrs.push(hdr);
     Assert.ok(!gMoveFolder.fetchMsgPreviewText(keys, keys.length,
                                                false, null));
-    Assert.equal(hdrs[0].getStringProperty('preview'), bugmail10_preview);
+    Assert.equal(hdrs[0].getStringProperty("preview"), bugmail10_preview);
     // check inbox message
     hdrs = [];
     keys = [];
     enumerator = localAccountUtils.inboxFolder.msgDatabase.EnumerateMessages();
     hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     keys.push(hdr.messageKey);
     hdrs.push(hdr);
     Assert.ok(!localAccountUtils.inboxFolder
                                 .fetchMsgPreviewText(keys, keys.length,
                                                      false, null));
-    Assert.equal(hdrs[0].getStringProperty('preview'), basic1_preview);
-  }
+    Assert.equal(hdrs[0].getStringProperty("preview"), basic1_preview);
+  },
 ];
 
-function folderCount(folder)
-{
+function folderCount(folder) {
   let enumerator = folder.msgDatabase.EnumerateMessages();
   let count = 0;
-  while (enumerator.hasMoreElements())
-  {
+  while (enumerator.hasMoreElements()) {
     count++;
-    let hdr = enumerator.getNext();
+    enumerator.getNext();
   }
   return count;
 }
 
-function setup_store(storeID)
-{
+function setup_store(storeID) {
   return function _setup_store() {
     // Initialize pop3Pump with correct mailbox format.
     gPOP3Pump.resetPluggableStore(storeID);
 
     // Set the default mailbox store.
     Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                                storeID);
 
     // Make sure we're not quarantining messages
     Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
     if (!localAccountUtils.inboxFolder)
       localAccountUtils.loadLocalMailAccount();
 
     gMoveFolder = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder");
-  }
+  };
 }
 
-function run_test()
-{
+function run_test() {
   for (let store of gPluggableStores) {
     add_task(setup_store(store));
     gTestArray.forEach(x => add_task(x));
   }
 
   add_task(exitTest);
   run_next_test();
 }
 
-function exitTest()
-{
+function exitTest() {
   // Cleanup and exit the test.
   info("Exiting mail tests\n");
   gPOP3Pump = null;
 }
--- a/mailnews/local/test/unit/test_pop3MultiCopy.js
+++ b/mailnews/local/test/unit/test_pop3MultiCopy.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * This tests that copied multiple messages in maildir are correct.
  */
 
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
 ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
 var testSubjects = ["[Bug 397009] A filter will let me tag, but not untag",
                     "Hello, did you receive my bugmail?"];
 
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/maildirstore;1");
@@ -78,17 +79,13 @@ add_task(async function runPump() {
     Assert.ok(subjects.includes(subject));
   }
 
   // Make sure the body matches the message.
   enumerator = testFolder.msgDatabase.EnumerateMessages();
   while (enumerator.hasMoreElements()) {
     let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     let body = mailTestUtils.loadMessageToString(testFolder, hdr);
-    Assert.ok(body.indexOf(hdr.subject) >= 0);
+    Assert.ok(body.includes(hdr.subject));
   }
 
   gPOP3Pump = null;
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/local/test/unit/test_pop3MultiCopy2.js
+++ b/mailnews/local/test/unit/test_pop3MultiCopy2.js
@@ -1,16 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * This tests that moved multiple messages from maildir->mbox and
    mbox->maildir are correct.
  */
 
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
 ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/maildirstore;1");
 
 var gInboxFolder, gTestFolder;
 
@@ -79,17 +80,17 @@ add_task(async function maildirToMbox() 
     Assert.ok(subjects.includes(subject));
   }
 
   // Make sure the body matches the message.
   enumerator = gTestFolder.msgDatabase.EnumerateMessages();
   while (enumerator.hasMoreElements()) {
     let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     let body = mailTestUtils.loadMessageToString(gTestFolder, hdr);
-    Assert.ok(body.indexOf(hdr.subject) >= 0);
+    Assert.ok(body.includes(hdr.subject));
   }
 });
 
 add_task(async function mboxToMaildir() {
   // Test for multiple message copy for mbox->maildir.
 
   // Accumulate messages to copy.
   let messages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
@@ -127,42 +128,37 @@ add_task(async function mboxToMaildir() 
     Assert.ok(subjects.includes(subject));
   }
 
   // Make sure the body matches the message.
   enumerator = gInboxFolder.msgDatabase.EnumerateMessages();
   while (enumerator.hasMoreElements()) {
     let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     let body = mailTestUtils.loadMessageToString(gInboxFolder, hdr);
-    Assert.ok(body.indexOf(hdr.subject) >= 0);
+    Assert.ok(body.includes(hdr.subject));
   }
 });
 
 add_task(function testCleanup() {
   gPOP3Pump = null;
 });
 
-function run_test() {
-  run_next_test();
-}
-
 // Clone of POP3pump resetPluggableStore that does not reset local folders.
-function resetPluggableStoreLocal(aStoreContractID)
-{
+function resetPluggableStoreLocal(aStoreContractID) {
   Services.prefs.setCharPref("mail.serverDefaultStoreContractID", aStoreContractID);
 
   // Cleanup existing files, server and account instances, if any.
   if (gPOP3Pump._server)
     gPOP3Pump._server.stop();
 
   if (gPOP3Pump.fakeServer && gPOP3Pump.fakeServer.valid) {
     gPOP3Pump.fakeServer.closeCachedConnections();
     MailServices.accounts.removeIncomingServer(gPOP3Pump.fakeServer, false);
   }
 
   gPOP3Pump.fakeServer = localAccountUtils.create_incoming_server("pop3",
       gPOP3Pump.kPOP3_PORT, "fred", "wilma");
 
-  //localAccountUtils.clearAll();
+  // localAccountUtils.clearAll();
 
   gPOP3Pump._incomingServer = gPOP3Pump.fakeServer;
   gPOP3Pump._mailboxStoreContractID = aStoreContractID;
-};
+}
--- a/mailnews/local/test/unit/test_pop3Password.js
+++ b/mailnews/local/test/unit/test_pop3Password.js
@@ -1,59 +1,54 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Authentication tests for POP3.
  */
 
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-
+/* import-globals-from ../../../test/resources/passwordStorage.js */
 load("../../../resources/passwordStorage.js");
 
-var test = null;
 var server;
 var daemon;
 var incomingServer;
 var thisTest;
 
-var tests = [
-  { title: "Get New Mail, One Message",
-    messages: ["message1.eml"],
-    transaction: [ "AUTH", "CAPA", "AUTH PLAIN", "STAT", "LIST",
-                   "UIDL", "RETR 1", "DELE 1" ] }
-];
+var tests = [{
+  title: "Get New Mail, One Message",
+  messages: ["message1.eml"],
+  transaction: ["AUTH", "CAPA", "AUTH PLAIN", "STAT", "LIST", "UIDL", "RETR 1", "DELE 1"],
+}];
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       var transaction = server.playTransaction();
 
       do_check_transaction(transaction, thisTest.transaction);
 
       Assert.equal(localAccountUtils.inboxFolder.getTotalMessages(false),
                    thisTest.messages.length);
 
       Assert.equal(result, 0);
-    }
-    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);
     }
 
     // Let OnStopRunningUrl return cleanly before doing anything else.
     do_timeout(0, checkBusy);
-  }
+  },
 };
 
 function checkBusy() {
   if (tests.length == 0) {
     incomingServer.closeCachedConnections();
 
     // No more tests, let everything finish
     server.stop();
@@ -100,17 +95,17 @@ function testNext() {
     do_throw(e);
   } finally {
     var thread = gThreadManager.currentThread;
     while (thread.hasPendingEvents())
       thread.processNextEvent(true);
   }
 }
 
-add_task(async function () {
+add_task(async function() {
   // 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);
 
   // Prepare files for passwords (generated by a script in bug 1018624).
   await setupForPassword("signons-mailnews1.8.json");
@@ -139,12 +134,8 @@ add_task(async function () {
   // Check that we haven't got any messages in the folder, if we have its a test
   // setup issue.
   Assert.equal(localAccountUtils.inboxFolder.getTotalMessages(false), 0);
 
   do_test_pending();
 
   testNext();
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/local/test/unit/test_pop3Password2.js
+++ b/mailnews/local/test/unit/test_pop3Password2.js
@@ -1,61 +1,56 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Authentication tests for POP3 - checks for servers whose details have
  * changed (e.g. realusername and realhostname are different from username and
  * hostname).
  */
 
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-
+/* import-globals-from ../../../test/resources/passwordStorage.js */
 load("../../../resources/passwordStorage.js");
 
-var test = null;
 var server;
 var daemon;
 var incomingServer;
 var thisTest;
 
-var tests = [
-  { title: "Get New Mail, One Message",
-    messages: ["message1.eml"],
-    transaction: [ "AUTH", "CAPA", "AUTH PLAIN", "STAT", "LIST",
-                   "UIDL", "RETR 1", "DELE 1" ] }
-];
+var tests = [{
+  title: "Get New Mail, One Message",
+  messages: ["message1.eml"],
+  transaction: ["AUTH", "CAPA", "AUTH PLAIN", "STAT", "LIST", "UIDL", "RETR 1", "DELE 1"],
+}];
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       var transaction = server.playTransaction();
 
       do_check_transaction(transaction, thisTest.transaction);
 
       Assert.equal(localAccountUtils.inboxFolder.getTotalMessages(false),
                    thisTest.messages.length);
 
       Assert.equal(result, 0);
-    }
-    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);
     }
 
     // Let OnStopRunningUrl return cleanly before doing anything else.
     do_timeout(0, checkBusy);
-  }
+  },
 };
 
 function checkBusy() {
   if (tests.length == 0) {
     incomingServer.closeCachedConnections();
 
     // No more tests, let everything finish
     server.stop();
@@ -102,17 +97,17 @@ function testNext() {
     do_throw(e);
   } finally {
     var thread = gThreadManager.currentThread;
     while (thread.hasPendingEvents())
       thread.processNextEvent(true);
   }
 }
 
-add_task(async function () {
+add_task(async function() {
   // 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);
 
   // These preferences set up a local pop server that has had its hostname
   // and username changed from the original settings. We can't do this by
@@ -174,12 +169,8 @@ add_task(async function () {
   // Check that we haven't got any messages in the folder, if we have its a test
   // setup issue.
   Assert.equal(localAccountUtils.inboxFolder.getTotalMessages(false), 0);
 
   do_test_pending();
 
   testNext();
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/local/test/unit/test_pop3Password3.js
+++ b/mailnews/local/test/unit/test_pop3Password3.js
@@ -1,25 +1,23 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Extra tests for POP3 passwords (forgetPassword)
  */
 
-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 kUser1 = "testpop3";
 var kUser2 = "testpop3a";
 var kProtocol = "pop3";
 var kHostname = "localhost";
 var kServerUrl = "mailbox://" + 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-multiple.json");
 
   // Set up the basic accounts and folders.
   // We would use createPop3ServerAndLocalFolders() however we want to have
   // a different username and NO password for this test (as we expect to load
   // it from the signons json file in which the login information is stored).
   localAccountUtils.loadLocalMailAccount();
@@ -68,12 +66,8 @@ add_task(async function () {
   incomingServer2.realUsername = "testpop";
 
   logins = Services.logins.findLogins(count, kServerUrl, null, kServerUrl);
 
   // There should be no login left.
   Assert.equal(count.value, 0);
   Assert.equal(logins.length, 0);
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/local/test/unit/test_pop3PasswordFailure.js
+++ b/mailnews/local/test/unit/test_pop3PasswordFailure.js
@@ -4,38 +4,38 @@
  *   - 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:///modules/MailServices.jsm");
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
+/* import-globals-from ../../../test/resources/passwordStorage.js */
+/* import-globals-from ../../../test/resources/mailTestUtils.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/alertTestUtils.js");
 load("../../../resources/passwordStorage.js");
 load("../../../resources/mailTestUtils.js");
 load("../../../resources/asyncTestUtils.js");
 
-var test = null;
 var server;
 var daemon;
 var incomingServer;
 var attempt = 0;
 
 var kUserName = "testpop3";
 var kInvalidPassword = "pop3test";
 var kValidPassword = "testpop3";
 
-function alert(aDialogText, aText)
-{
+/* exported alert, confirmEx, promptPasswordPS */
+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");
 }
 
@@ -77,59 +77,56 @@ function promptPasswordPS(aParent, aDial
 function getPopMail() {
   MailServices.pop3.GetNewMail(gDummyMsgWindow, urlListener, localAccountUtils.inboxFolder,
                                incomingServer);
 
   server.performTest();
   return false;
 }
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
-      var transaction = server.playTransaction();
+      server.playTransaction();
 
       // On the last attempt, we should have successfully got one mail.
       Assert.equal(localAccountUtils.inboxFolder.getTotalMessages(false),
                    attempt == 4 ? 1 : 0);
 
       // If we've just cancelled, expect binding aborted rather than success.
       Assert.equal(result, attempt == 2 ? Cr.NS_BINDING_ABORTED : 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,
-  end_test
-]
+  end_test,
+];
 
 function actually_run_test() {
   daemon.setMessages(["message1.eml"]);
   async_run_tests(tests);
 }
 
-function* getMail1()
-{
+function* getMail1() {
   dump("\nGet Mail 1\n");
 
   // Now get mail
   getPopMail();
   yield false;
 
   dump("\nGot Mail 1\n");
 
@@ -144,18 +141,17 @@ function* getMail1()
   Assert.equal(count.value, 1);
   Assert.equal(logins[0].username, kUserName);
   Assert.equal(logins[0].password, kInvalidPassword);
 
   server.resetTest();
   yield true;
 }
 
-function* getMail2()
-{
+function* getMail2() {
   dump("\nGet Mail 2\n");
 
   // Now get the mail
   getPopMail();
   yield false;
   dump("\nGot Mail 2\n");
 
   // Now check the new one has been saved.
@@ -164,22 +160,21 @@ function* getMail2()
                                           "mailbox://localhost");
 
   Assert.equal(count.value, 1);
   Assert.equal(logins[0].username, kUserName);
   Assert.equal(logins[0].password, kValidPassword);
   yield true;
 }
 
-function* end_test()
-{
+function* end_test() {
   do_test_finished();
 }
 
-add_task(async function () {
+add_task(async function() {
   // 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).
@@ -211,12 +206,8 @@ add_task(async function () {
   // Check that we haven't got any messages in the folder, if we have its a test
   // setup issue.
   Assert.equal(localAccountUtils.inboxFolder.getTotalMessages(false), 0);
 
   do_test_pending();
 
   actually_run_test();
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/local/test/unit/test_pop3PasswordFailure2.js
+++ b/mailnews/local/test/unit/test_pop3PasswordFailure2.js
@@ -4,39 +4,40 @@
  *   - 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 attempt = 0;
 var count = {};
 var logins;
 
 var kUserName = "testpop3";
 var kInvalidPassword = "pop3test";
 var kValidPassword = "testpop3";
 
-function alert(aDialogText, aText)
-{
+/* exported alert, confirmEx, promptPasswordPS */
+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");
 }
 
@@ -75,51 +76,49 @@ function promptPasswordPS(aParent, aDial
   return false;
 }
 
 function getPopMail() {
   MailServices.pop3.GetNewMail(gDummyMsgWindow, urlListener, localAccountUtils.inboxFolder,
                                incomingServer);
 }
 
-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(localAccountUtils.inboxFolder.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");
       Assert.equal(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 actually_run_test() {
   daemon.setMessages(["message1.eml"]);
   async_run_tests(tests);
 }
 
 function* getMail1() {
   dump("\nGet Mail 1\n");
@@ -159,18 +158,17 @@ function* endTest() {
                                       "mailbox://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/local/test/unit/test_pop3PasswordFailure3.js
+++ b/mailnews/local/test/unit/test_pop3PasswordFailure3.js
@@ -6,39 +6,40 @@
  *   - 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 attempt = 0;
 var count = {};
 var logins;
 
 var kUserName = "testpop3";
 var kInvalidPassword = "pop3test";
 var kValidPassword = "testpop3";
 
-function alert(aDialogText, aText)
-{
+/* exported alert, confirmEx, promptPasswordPS */
+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");
 }
 
@@ -77,51 +78,49 @@ function promptPasswordPS(aParent, aDial
   return false;
 }
 
 function getPopMail() {
   MailServices.pop3.GetNewMail(gDummyMsgWindow, urlListener, localAccountUtils.inboxFolder,
                                incomingServer);
 }
 
-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(localAccountUtils.inboxFolder.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");
       Assert.equal(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 actually_run_test() {
   daemon.setMessages(["message1.eml"]);
   async_run_tests(tests);
 }
 
 function* getMail1() {
   dump("\nGet Mail 1\n");
@@ -161,18 +160,17 @@ function* endTest() {
                                       "mailbox://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/local/test/unit/test_pop3Proxy.js
+++ b/mailnews/local/test/unit/test_pop3Proxy.js
@@ -42,12 +42,8 @@ add_task(async function downloadEmail() 
   equal(localAccountUtils.inboxFolder.getTotalMessages(false), 1);
 });
 
 add_task(async function cleanUp() {
   NetworkTestUtils.shutdownServers();
   incomingServer.closeCachedConnections();
   server.stop();
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/local/test/unit/test_pop3Pump.js
+++ b/mailnews/local/test/unit/test_pop3Pump.js
@@ -1,12 +1,13 @@
 /**
  * The intent of this file is to demonstrate a minimal
  * POP3 unit test using the testing file POP3Pump.js
  */
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
 
 var testSubjects = ["[Bug 397009] A filter will let me tag, but not untag",
                     "Hello, did you receive my bugmail?"];
 
 add_task(async function runPump() {
   // demonstration of access to the local inbox folder
   dump("local inbox folder " + localAccountUtils.inboxFolder.URI + " is loaded\n");
@@ -23,12 +24,8 @@ add_task(async function runPump() {
   while (enumerator.hasMoreElements()) {
     msgCount++;
     let hdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     Assert.equal(hdr.subject, testSubjects[msgCount - 1]);
   }
   Assert.equal(msgCount, 2);
   gPOP3Pump = null;
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/local/test/unit/test_pop3ServerBrokenCRAMDisconnect.js
+++ b/mailnews/local/test/unit/test_pop3ServerBrokenCRAMDisconnect.js
@@ -18,77 +18,72 @@
  *    and start with the next in list, not trying the broken one again.
  *    We currently neither retry nor remember.
  * - incomingServer thinks it is still running/busy although the connection is
  *    clearly done and over.
  *
  * @author Ben Bucksch
  */
 
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-
 var server;
 var daemon;
 var incomingServer;
-var test = "Server which advertises CRAM-MD5, but closes the connection when it's tried";
+test = "Server which advertises CRAM-MD5, but closes the connection when it's tried";
 // that's how it currently looks like (we fail to log in):
-var expectedTransaction = [ "AUTH", "CAPA", "AUTH CRAM-MD5" ];
+var expectedTransaction = ["AUTH", "CAPA", "AUTH CRAM-MD5"];
 // TODO that's how it should look like (we start a new connection and try another scheme):
-//const expectedTransaction = [ "AUTH", "CAPA", "AUTH CRAM-MD5", "CAPA", "AUTH PLAIN", "STAT" ];
+// const expectedTransaction = ["AUTH", "CAPA", "AUTH CRAM-MD5", "CAPA", "AUTH PLAIN", "STAT"];
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       // We should be getting an error here, because we couldn't log in.
       Assert.equal(result, Cr.NS_ERROR_FAILURE);
 
       var transaction = server.playTransaction();
       do_check_transaction(transaction, expectedTransaction);
 
       do_timeout(0, endTest);
     } catch (e) {
       server.stop();
       var thread = gThreadManager.currentThread;
       while (thread.hasPendingEvents())
         thread.processNextEvent(true);
 
       do_throw(e);
     }
-  }
+  },
 };
 
 function endTest() {
   // No more tests, let everything finish
   server.stop();
 
   var thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
 
   do_test_finished();
 }
 
-function CRAMFail_handler(daemon)
-{
-  POP3_RFC5034_handler.call(this, daemon);
+function CRAMFail_handler(daemon_) {
+  POP3_RFC5034_handler.call(this, daemon_);
 
   this._kAuthSchemeStartFunction["CRAM-MD5"] = this.killConn;
 }
 CRAMFail_handler.prototype = {
-  __proto__ : POP3_RFC5034_handler.prototype, // inherit
+  __proto__: POP3_RFC5034_handler.prototype, // inherit
 
-  killConn : function()
-  {
+  killConn() {
     this.closing = true;
     return "-ERR I don't feel like it";
-  }
-}
+  },
+};
 
 function run_test() {
   try {
     do_test_pending();
 
     // Disable new mail notifications
     Services.prefs.setBoolPref("mail.biff.play_sound", false);
     Services.prefs.setBoolPref("mail.biff.show_alert", false);
--- a/mailnews/local/test/unit/test_pop3ServerBrokenCRAMFail.js
+++ b/mailnews/local/test/unit/test_pop3ServerBrokenCRAMFail.js
@@ -1,42 +1,40 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /**
  * Server which advertises CRAM-MD5, but fails when it's tried.
  * This reportedly happens for some misconfigured servers.
  */
-ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var server;
 var daemon;
 var incomingServer;
-var test = "Server which advertises CRAM-MD5, but fails when it's tried";
-var expectedTransaction = [ "AUTH", "CAPA", "AUTH CRAM-MD5", "AUTH PLAIN", "STAT" ];
+test = "Server which advertises CRAM-MD5, but fails when it's tried";
+var expectedTransaction = ["AUTH", "CAPA", "AUTH CRAM-MD5", "AUTH PLAIN", "STAT"];
 
-var urlListener =
-{
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, result) {
+  OnStopRunningUrl(url, result) {
     try {
       Assert.equal(result, 0);
 
       var transaction = server.playTransaction();
       do_check_transaction(transaction, expectedTransaction);
 
       do_timeout(0, checkBusy);
     } catch (e) {
       server.stop();
       var thread = gThreadManager.currentThread;
       while (thread.hasPendingEvents())
         thread.processNextEvent(true);
 
       do_throw(e);
     }
-  }
+  },
 };
 
 function checkBusy() {
   // If the server hasn't quite finished, just delay a little longer.
   if (incomingServer.serverBusy ||
       (incomingServer instanceof Ci.nsIPop3IncomingServer &&
        incomingServer.runningProtocol)) {
     do_timeout(20, checkBusy);
@@ -54,32 +52,30 @@ function endTest() {
 
   var thread = gThreadManager.currentThread;
   while (thread.hasPendingEvents())
     thread.processNextEvent(true);
 
   do_test_finished();
 }
 
-function CRAMFail_handler(daemon)
-{
-  POP3_RFC5034_handler.call(this, daemon);
+function CRAMFail_handler(daemon_) {
+  POP3_RFC5034_handler.call(this, daemon_);
 
   this._kAuthSchemeStartFunction["CRAM-MD5"] = this.killConn;
 }
 CRAMFail_handler.prototype = {
-  __proto__ : POP3_RFC5034_handler.prototype, // inherit
+  __proto__: POP3_RFC5034_handler.prototype, // inherit
 
-  killConn : function()
-  {
+  killConn() {
     this._multiline = false;
     this._state = kStateAuthNeeded;
     return "-ERR I just pretended to implement CRAM-MD5";
-  }
-}
+  },
+};
 
 function run_test() {
   try {
     do_test_pending();
 
     // Disable new mail notifications
     Services.prefs.setBoolPref("mail.biff.play_sound", false);
     Services.prefs.setBoolPref("mail.biff.show_alert", false);
--- a/mailnews/local/test/unit/test_preview.js
+++ b/mailnews/local/test/unit/test_preview.js
@@ -1,12 +1,12 @@
 var bugmail10 = do_get_file("../../../data/bugmail10");
 var bugmail11 = do_get_file("../../../data/bugmail11");
-var bugmail10_preview = 'Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----';
-var bugmail11_preview = 'Bugzilla has received a request to create a user account using your email address (example@example.org). To confirm that you want to create an account using that email address, visit the following link: https://bugzilla.mozilla.org/token.cgi?t=xxx';
+var bugmail10_preview = "Do not reply to this email. You can add comments to this bug at https://bugzilla.mozilla.org/show_bug.cgi?id=436880 -- Configure bugmail: https://bugzilla.mozilla.org/userprefs.cgi?tab=email ------- You are receiving this mail because: -----";
+var bugmail11_preview = "Bugzilla has received a request to create a user account using your email address (example@example.org). To confirm that you want to create an account using that email address, visit the following link: https://bugzilla.mozilla.org/token.cgi?t=xxx";
 
 function run_test() {
   do_test_pending();
   copyFileMessageInLocalFolder(bugmail10, 0, "", null, copy_next_message);
 }
 
 function copy_next_message(aMessageHeaderKeys, aStatus) {
   copyFileMessageInLocalFolder(bugmail11, 0, "", null, test_preview);
@@ -14,15 +14,18 @@ function copy_next_message(aMessageHeade
 
 function test_preview(aMessageHeaderKeys, aStatus) {
   let headerKeys = aMessageHeaderKeys;
   Assert.notEqual(headerKeys, null);
   Assert.equal(headerKeys.length, 2);
   try {
     localAccountUtils.inboxFolder.fetchMsgPreviewText(headerKeys,
                                           headerKeys.length, false, null);
-    Assert.equal(localAccountUtils.inboxFolder.GetMessageHeader(headerKeys[0]).getStringProperty('preview'),
+    Assert.equal(localAccountUtils.inboxFolder.GetMessageHeader(headerKeys[0]).getStringProperty("preview"),
                  bugmail10_preview);
-    Assert.equal(localAccountUtils.inboxFolder.GetMessageHeader(headerKeys[1]).getStringProperty('preview'),
+    Assert.equal(localAccountUtils.inboxFolder.GetMessageHeader(headerKeys[1]).getStringProperty("preview"),
                  bugmail11_preview);
-  } catch(ex) {dump(ex); do_throw(ex) }
+  } catch (ex) {
+    dump(ex);
+    do_throw(ex);
+  }
   do_test_finished();
 }
--- a/mailnews/local/test/unit/test_saveMessage.js
+++ b/mailnews/local/test/unit/test_saveMessage.js
@@ -5,23 +5,22 @@
 ChromeUtils.import("resource:///modules/IOUtils.js");
 
 var MSG_LINEBREAK = "\r\n";
 var dot = do_get_file("data/dot");
 var saveFile = Services.dirsvc.get("TmpD", Ci.nsIFile);
 saveFile.append(dot.leafName + ".eml");
 saveFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
 
-function run_test()
-{
+function run_test() {
   registerCleanupFunction(teardown);
   do_test_pending();
   do_timeout(10000, function() {
-    do_throw('SaveMessageToDisk did not complete within 10 seconds' +
-      '(incorrect messageURI?). ABORTING.');
+    do_throw("SaveMessageToDisk did not complete within 10 seconds" +
+      "(incorrect messageURI?). ABORTING.");
   });
   copyFileMessageInLocalFolder(dot, 0, "", null, save_message);
 }
 
 function save_message(aMessageHeaderKeys, aStatus) {
   let headerKeys = aMessageHeaderKeys;
   Assert.notEqual(headerKeys, null);
 
@@ -39,22 +38,22 @@ function check_each_line(aExpectedLines,
 
   expectedStrings.shift();
   Assert.equal(expectedStrings.length, actualStrings.length);
   for (let line = 0; line < expectedStrings.length; line++)
     Assert.equal(expectedStrings[line], actualStrings[line]);
 }
 
 var UrlListener = {
-  OnStartRunningUrl: function(aUrl) {
+  OnStartRunningUrl(aUrl) {
   },
-  OnStopRunningUrl: function(aUrl, aExitCode) {
+  OnStopRunningUrl(aUrl, aExitCode) {
     Assert.equal(aExitCode, 0);
     check_each_line(IOUtils.loadFileToString(dot),
                     IOUtils.loadFileToString(saveFile));
     do_test_finished();
-  }
+  },
 };
 
 function teardown() {
   if (saveFile.exists())
     saveFile.remove(false);
 }
--- a/mailnews/local/test/unit/test_streamHeaders.js
+++ b/mailnews/local/test/unit/test_streamHeaders.js
@@ -5,116 +5,118 @@
  /**
  * This mainly tests that streamHeaders does not result in the crash
  * of bug 752768
  *
  * adapted from test_pop3Pump.js by Kent James <kent@caspia.com>
  */
 
 // async support
+/* 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/POP3pump.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/alertTestUtils.js");
 
 load("../../../resources/POP3pump.js");
 
 var testSubjects = ["Hello, did you receive my bugmail?"];
-var tests = [loadMessages,
-             goodStreaming,
-             badStreaming,
-            ];
+var tests = [
+  loadMessages,
+  goodStreaming,
+  badStreaming,
+];
 
-function run_test()
-{
+function run_test() {
   async_run_tests(tests);
 }
 
 var gHdr;
-function* loadMessages()
-{
+function* loadMessages() {
   gPOP3Pump.files = ["../../../data/draft1"];
   gPOP3Pump.onDone = async_driver;
   gPOP3Pump.run();
   yield false;
 
   // get message headers for the inbox folder
   let enumerator = localAccountUtils.inboxFolder.msgDatabase.EnumerateMessages();
   var msgCount = 0;
-  while(enumerator.hasMoreElements())
-  {
+  while (enumerator.hasMoreElements()) {
     msgCount++;
     gHdr = enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     Assert.equal(gHdr.subject, testSubjects[msgCount - 1]);
   }
   Assert.equal(msgCount, 1);
   gPOP3Pump = null;
 }
 
-function* goodStreaming()
-{
+function* goodStreaming() {
   // try to stream the headers of the last message
   let uri = gHdr.folder.getUriForMsg(gHdr);
   let messageService = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger)
                                                      .messageServiceFromURI(uri);
   messageService.streamHeaders(uri, createStreamListener(
     function theString(k) {
-      dump('the string:\n' + k + '\n');
+      dump("the string:\n" + k + "\n");
       // The message contains this header
       Assert.ok(k.includes("X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0"));
       async_driver();
     }), null, true);
   yield false;
 }
 
 // crash from bug 752768
-function badStreaming()
-{
+function badStreaming() {
   // try to stream the headers of the last message
   let folder = gHdr.folder;
   let uri = folder.getUriForMsg(gHdr);
 
   let dbFile = folder.summaryFile;
   // force invalid database
   folder.msgDatabase.ForceClosed();
   dbFile.remove(false);
   folder.msgDatabase = null;
 
   let messageService = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger)
                                                      .messageServiceFromURI(uri);
   let haveError = false;
   try {
     messageService.streamHeaders(uri, createStreamListener(
-      function theString(k) {} ), null, true);
-  } catch (e) {haveError = true;}
+      function theString(k) {}), null, true);
+  } catch (e) {
+    haveError = true;
+  }
   Assert.ok(haveError);
 }
 
 // This function is adapted from the Conversations addon, which
 //  seems to be one of the drivers for the creation of streamHeaders
 /**
  * Creates a stream listener that will call k once done, passing it the string
  * that has been read.
  */
 function createStreamListener(k) {
   return {
     _data: "",
-    _stream : null,
+    _stream: null,
 
     QueryInterface:
       ChromeUtils.generateQI([Ci.nsIStreamListener, Ci.nsIRequestObserver]),
 
     // nsIRequestObserver
-    onStartRequest: function(aRequest, aContext) {
+    onStartRequest(aRequest, aContext) {
     },
-    onStopRequest: function(aRequest, aContext, aStatusCode) {
+    onStopRequest(aRequest, aContext, aStatusCode) {
       k(this._data);
     },
 
     // nsIStreamListener
-    onDataAvailable: function(aRequest, aContext, aInputStream, aOffset, aCount) {
+    onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount) {
       if (this._stream == null) {
         this._stream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
         this._stream.init(aInputStream);
       }
       this._data += this._stream.read(aCount);
-    }
+    },
   };
 }
--- a/mailnews/local/test/unit/test_undoDelete.js
+++ b/mailnews/local/test/unit/test_undoDelete.js
@@ -1,53 +1,51 @@
 // This file tests undoing of an local folder message deleted to the trash.
 //
 // Original Author: David Bienvenu <dbienvenu@mozilla.com>
 
-ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-
 // Globals
 var gMsg1;
 var gMessages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
 var gMsgWindow;
 var gCurTestNum;
 var gMsgId1;
 var gTestFolder;
 
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/messageModifier.js */
+/* import-globals-from ../../../test/resources/messageGenerator.js */
+/* import-globals-from ../../../test/resources/messageInjection.js */
 load("../../../resources/asyncTestUtils.js");
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 load("../../../resources/messageModifier.js");
 load("../../../resources/messageGenerator.js");
 load("../../../resources/messageInjection.js");
 
-var gTestArray =
-[
+var gTestArray = [
   function deleteMessage() {
     let msgToDelete = mailTestUtils.firstMsgHdr(gTestFolder);
     gMsgId1 = msgToDelete.messageId;
     gMessages.appendElement(msgToDelete);
     gTestFolder.deleteMessages(gMessages, gMsgWindow, false, true, CopyListener,
                                true);
   },
   function undoDelete() {
     gMsgWindow.transactionManager.undoTransaction();
     // There's no listener for this, so we'll just have to wait a little.
-    do_timeout(1500, function(){doTest(++gCurTestNum);});
+    do_timeout(1500, function() { doTest(++gCurTestNum); });
   },
   function verifyFolders() {
     let msgRestored = gTestFolder.msgDatabase.getMsgHdrForMessageID(gMsgId1);
     let msg = mailTestUtils.loadMessageToString(gTestFolder, msgRestored);
     Assert.equal(msg, gMsg1.toMboxString());
     doTest(++gCurTestNum);
   },
 ];
 
-function run_test()
-{
+function run_test() {
   configure_message_injection({mode: "local"});
 
   gMsgWindow = Cc["@mozilla.org/messenger/msgwindow;1"]
                   .createInstance(Ci.nsIMsgWindow);
 
   var messageGenerator = new MessageGenerator();
   gMsg1 = messageGenerator.makeMessage();
   let msg2 = messageGenerator.makeMessage({inReplyTo: gMsg1});
@@ -56,82 +54,73 @@ function run_test()
   messages = messages.concat([gMsg1, msg2]);
   let msgSet = new SyntheticMessageSet(messages);
   gTestFolder = make_empty_folder();
   add_sets_to_folder(gTestFolder, [msgSet]);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
   do_test_pending();
-  //start first test
+  // start first test
   doTest(1);
 }
 
-function doTest(test)
-{
-  if (test <= gTestArray.length)
-  {
+function doTest(test) {
+  if (test <= gTestArray.length) {
     dump("Doing test " + test + "\n");
     gCurTestNum = test;
 
     var testFn = gTestArray[test - 1];
     // Set a limit of ten seconds; if the notifications haven't arrived by then there's a problem.
-    do_timeout(10000, function(){
+    do_timeout(10000, function() {
         if (gCurTestNum == test)
           do_throw("Notifications not received in 10000 ms for operation " + testFn.name);
         }
       );
     try {
     testFn();
-    } catch(ex) {
-      do_throw ('TEST FAILED ' + ex);
+    } catch (ex) {
+      do_throw("TEST FAILED " + ex);
     }
-  }
-  else
-  {
+  } else {
     do_timeout(1000, endTest);
   }
 }
 
 // nsIMsgCopyServiceListener implementation - runs next test when copy
 // is completed.
-var CopyListener =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey){},
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus)
-  {
+var CopyListener = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {},
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) {
     dump("in OnStopCopy " + gCurTestNum + "\n");
     // Check: message successfully copied.
     Assert.equal(aStatus, 0);
     // Ugly hack: make sure we don't get stuck in a JS->C++->JS->C++... call stack
     // This can happen with a bunch of synchronous functions grouped together, and
     // can even cause tests to fail because they're still waiting for the listener
     // to return
-    do_timeout(0, function(){doTest(++gCurTestNum);});
-  }
+    do_timeout(0, function() { doTest(++gCurTestNum); });
+  },
 };
 
-
+/* exported URLListener */
 // nsIURLListener implementation - runs next test
-var URLListener =
-{
-  OnStartRunningUrl: function(aURL) {},
-  OnStopRunningUrl: function(aURL, aStatus)
-  {
+var URLListener = {
+  OnStartRunningUrl(aURL) {},
+  OnStopRunningUrl(aURL, aStatus) {
     dump("in OnStopRunningURL " + gCurTestNum + "\n");
     Assert.equal(aStatus, 0);
-    do_timeout(0, function(){doTest(++gCurTestNum);});
-  }
-}
+    do_timeout(0, function() { doTest(++gCurTestNum); });
+  },
+};
 
-function endTest()
-{
+function endTest() {
   // Cleanup, null out everything
   gMessages.clear();
   gMsgWindow.closeWindow();
   gMsgWindow = null;
   localAccountUtils.inboxFolder = null;
   localAccountUtils.incomingServer = null;
 
   do_test_finished(); // for the one in run_test()
--- a/mailnews/local/test/unit/test_verifyLogon.js
+++ b/mailnews/local/test/unit/test_verifyLogon.js
@@ -1,50 +1,44 @@
 /**
  * This test checks to see if the pop3 verify logon handles password failure correctly.
  * The steps are:
  *   - Set an invalid password on the server object.
  *   - Check that verifyLogon fails
  */
 
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource:///modules/MailServices.jsm");
-
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
 load("../../../resources/alertTestUtils.js");
 
-var test = null;
 var server;
 var daemon;
 var incomingServer;
-var pop3Service;
-var attempt = 0;
 
 var kUserName = "testpop3";
 var kInvalidPassword = "pop3test";
 var kValidPassword = "testpop3";
 
 function verifyPop3Logon(validPassword) {
   incomingServer.password = (validPassword) ? kValidPassword : kInvalidPassword;
   urlListener.expectSuccess = validPassword;
   let uri = incomingServer.verifyLogon(urlListener, gDummyMsgWindow);
   // clear msgWindow so url won't prompt for passwords.
   uri.QueryInterface(Ci.nsIMsgMailNewsUrl).msgWindow = null;
 
   server.performTest();
   return false;
 }
 
-var urlListener =
-{
-  expectSucess : false,
-  OnStartRunningUrl: function (url) {
+var urlListener = {
+  expectSucess: false,
+  OnStartRunningUrl(url) {
   },
-  OnStopRunningUrl: function (url, aResult) {
+  OnStopRunningUrl(url, aResult) {
     Assert.equal(Components.isSuccessCode(aResult), this.expectSuccess);
-  }
+  },
 };
 
 function actually_run_test() {
   daemon.setMessages(["message1.eml"]);
 
   // check that verifyLogon fails with bad password
   verifyPop3Logon(false);
 
@@ -57,18 +51,17 @@ function verifyGoodLogon() {
 
   // check that verifyLogon succeeds with good password
   verifyPop3Logon(true);
 
   dump("\nverify logon true 1\n");
   do_test_finished();
 }
 
-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);
   // Set up the Server
   daemon = new pop3Daemon();
   function createHandler(d) {
@@ -83,18 +76,15 @@ function run_test()
   server.start();
 
   // Set up the basic accounts and folders.
   // We would use createPop3ServerAndLocalFolders() however we want to have
   // a different username and NO password for this test (as we expect to load
   // it from the signons json file in which the login information is stored).
   localAccountUtils.loadLocalMailAccount();
 
-
-  incomingServer = MailServices.accounts
-                    .createIncomingServer(kUserName,"localhost", "pop3");
-
+  incomingServer = MailServices.accounts.createIncomingServer(kUserName, "localhost", "pop3");
   incomingServer.port = server.port;
 
   do_test_pending();
 
   actually_run_test();
 }