Bug 1515877 - Turn on ESLint in mailnews/base/test draft
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 15 Mar 2019 14:38:18 +1300
changeset 72382 30d3fb2925e9a70cecf03b59b8bd3086afc70e36
parent 72380 0cffb1aa9e14fcad79b9a7c9467dc5aa8e019dbf
child 72383 13dbf9dc1071b423c7d07ecb2efebfed8abbc892
push id8083
push usermozilla@jorgk.com
push dateFri, 29 Mar 2019 09:40:03 +0000
treeherdertry-comm-central@13dbf9dc1071 [default view] [failures only]
bugs1515877
Bug 1515877 - Turn on ESLint in mailnews/base/test
.eslintignore
mailnews/base/test/unit/.eslintrc.js
mailnews/base/test/unit/test_accountMgr.js
mailnews/base/test/unit/test_accountMgrCustomTypes.js
mailnews/base/test/unit/test_accountMigration.js
mailnews/base/test/unit/test_acctRepair.js
mailnews/base/test/unit/test_base64_decoding.js
mailnews/base/test/unit/test_bccInDatabase.js
mailnews/base/test/unit/test_bug366491.js
mailnews/base/test/unit/test_bug404489.js
mailnews/base/test/unit/test_bug428427.js
mailnews/base/test/unit/test_bug434810.js
mailnews/base/test/unit/test_bug471682.js
mailnews/base/test/unit/test_bug514945.js
mailnews/base/test/unit/test_compactColumnSave.js
mailnews/base/test/unit/test_compactFailure.js
mailnews/base/test/unit/test_converterDeferredAccount.js
mailnews/base/test/unit/test_copyChaining.js
mailnews/base/test/unit/test_copyThenMoveManual.js
mailnews/base/test/unit/test_copyToInvalidDB.js
mailnews/base/test/unit/test_detachToFile.js
mailnews/base/test/unit/test_emptyTrash.js
mailnews/base/test/unit/test_fix_deferred_accounts.js
mailnews/base/test/unit/test_folderCompact.js
mailnews/base/test/unit/test_folderLookupService.js
mailnews/base/test/unit/test_formatFileSize.js
mailnews/base/test/unit/test_getMsgTextFromStream.js
mailnews/base/test/unit/test_headerFoldingInDatabase.js
mailnews/base/test/unit/test_hostnameUtils.js
mailnews/base/test/unit/test_imapPump.js
mailnews/base/test/unit/test_inheritedFolderProperties.js
mailnews/base/test/unit/test_iteratorUtils.js
mailnews/base/test/unit/test_jsTreeSelection.js
mailnews/base/test/unit/test_junkWhitelisting.js
mailnews/base/test/unit/test_junkingWhenDisabled.js
mailnews/base/test/unit/test_loadVirtualFolders.js
mailnews/base/test/unit/test_mailstoreConverter.js
mailnews/base/test/unit/test_mimemaltdetach.js
mailnews/base/test/unit/test_newMailNotification.js
mailnews/base/test/unit/test_nsIFolderListener.js
mailnews/base/test/unit/test_nsIMsgContentPolicy.js
mailnews/base/test/unit/test_nsIMsgFolder.js
mailnews/base/test/unit/test_nsIMsgFolderListener.js
mailnews/base/test/unit/test_nsIMsgFolderListenerLocal.js
mailnews/base/test/unit/test_nsIMsgTagService.js
mailnews/base/test/unit/test_nsMailDirProvider.js
mailnews/base/test/unit/test_nsMsgDBView.js
mailnews/base/test/unit/test_nsMsgDBView_headerValues.js
mailnews/base/test/unit/test_nsMsgMailSession_Alerts.js
mailnews/base/test/unit/test_nsMsgMailSession_Listeners.js
mailnews/base/test/unit/test_nsMsgTraitService.js
mailnews/base/test/unit/test_postPluginFilters.js
mailnews/base/test/unit/test_quarantineFilterMove.js
mailnews/base/test/unit/test_retention.js
mailnews/base/test/unit/test_search.js
mailnews/base/test/unit/test_searchAddressInAb.js
mailnews/base/test/unit/test_searchBody.js
mailnews/base/test/unit/test_searchBoolean.js
mailnews/base/test/unit/test_searchChaining.js
mailnews/base/test/unit/test_searchCustomTerm.js
mailnews/base/test/unit/test_searchJunk.js
mailnews/base/test/unit/test_searchLocalizationStrings.js
mailnews/base/test/unit/test_searchTag.js
mailnews/base/test/unit/test_searchUint32HdrProperty.js
mailnews/base/test/unit/test_testsuite_base64.js
mailnews/base/test/unit/test_testsuite_fakeserverAuth.js
mailnews/base/test/unit/test_testsuite_fakeserver_imapd_gmail.js
mailnews/base/test/unit/test_testsuite_fakeserver_imapd_list-extended.js
mailnews/base/test/unit/test_viewSortByAddresses.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -30,17 +30,21 @@ chat/chat-prefs.js
 chat/modules/BigInteger.jsm
 chat/protocols/matrix/matrix-sdk/**
 chat/protocols/twitter/twitter-text.jsm
 # preprocessed files
 chat/content/imtooltip.xml
 
 # mailnews exclusions
 mailnews/mailnews.js
-mailnews/base/*
+mailnews/base/content/*
+mailnews/base/prefs/*
+mailnews/base/search/*
+mailnews/base/src/*
+mailnews/base/util/*
 mailnews/build/*
 mailnews/compose/*
 mailnews/db/*
 mailnews/imap/*
 mailnews/import/*
 mailnews/intl/*
 mailnews/jsaccount/*
 mailnews/mime/*
new file mode 100644
--- /dev/null
+++ b/mailnews/base/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/base/test/unit/test_accountMgr.js
+++ b/mailnews/base/test/unit/test_accountMgr.js
@@ -5,18 +5,17 @@
 /**
  * This tests that we cleanup the account prefs when the account manager is
  * loaded. This entails removing duplicate accounts from
  * mail.accountmanager.accounts list, and removing duplicate accounts with
  * the same server.
  */
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-function run_test()
-{
+function run_test() {
   // Create account prefs with both kinds of duplication.
 
   Services.prefs.setCharPref("mail.account.account1.identities", "id1");
   Services.prefs.setCharPref("mail.account.account1.server", "server1");
   Services.prefs.setCharPref("mail.account.account2.identities", "id2");
   Services.prefs.setCharPref("mail.account.account2.server", "server2");
   Services.prefs.setCharPref("mail.account.account4.identities", "id2");
   Services.prefs.setCharPref("mail.account.account4.server", "server4");
@@ -66,17 +65,17 @@ function run_test()
   Assert.equal(defaultAccount, null);
 
   // Remove an account, and verify that the account list pref looks OK:
   let server = MailServices.accounts.getIncomingServer("server4");
 
   // We need to get the root folder to read from the folder cache
   // before it gets removed or else we'll assert, because we're
   // not completely initialized...
-  let flags = server.rootFolder.flags;
+  server.rootFolder.flags;
 
   MailServices.accounts.removeAccount(MailServices.accounts.FindAccountForServer(server));
   Assert.equal(MailServices.accounts.accounts.length, 2);
   Assert.equal(Services.prefs.getCharPref("mail.accountmanager.accounts"),
                "account1,account5");
   // make sure cleaning up duplicate accounts didn't hork accounts
   Assert.equal(Services.prefs.getCharPref("mail.account.account1.server"),
                "server1");
--- a/mailnews/base/test/unit/test_accountMgrCustomTypes.js
+++ b/mailnews/base/test/unit/test_accountMgrCustomTypes.js
@@ -5,18 +5,17 @@
 /**
  * This tests that accounts with invalid types, such as could be created
  *  from an extension, do not disappear immediately when the extension
  *  is unloaded.
  *
  * Adapted from test_AccountMgr.js by Kent James <kent@caspia.com>
  */
 
-function run_test()
-{
+function run_test() {
   Services.prefs.setCharPref("mail.account.account1.identities", "id1");
   Services.prefs.setCharPref("mail.account.account1.server", "server1");
   Services.prefs.setCharPref("mail.account.account2.identities", "id2");
   Services.prefs.setCharPref("mail.account.account2.server", "server2");
   Services.prefs.setCharPref("mail.server.server1.hostname", "Local Folders");
   Services.prefs.setCharPref("mail.server.server1.type", "none");
   Services.prefs.setCharPref("mail.server.server1.userName", "nobody");
   Services.prefs.setCharPref("mail.server.server1.directory-rel",
@@ -67,17 +66,17 @@ function run_test()
   // make it bad again, and reload it to restart the timeout before delete
   MailServices.accounts.UnloadAccounts();
   Services.prefs.setCharPref("mail.server.server2.type", "invalid");
   Assert.equal(MailServices.accounts.accounts.length, 2);
   MailServices.accounts.UnloadAccounts();
 
   // now let the bad type timeout, and watch it magically disappear!
   do_test_pending();
-  do_timeout(3000, function () {
+  do_timeout(3000, function() {
     Assert.equal(MailServices.accounts.accounts.length, 2);
 
     // it is now gone
     Assert.equal(Services.prefs.getCharPref("mail.accountmanager.accounts"),
                  "account1," + newAccount.key);
 
     do_test_finished();
   });
--- a/mailnews/base/test/unit/test_accountMigration.js
+++ b/mailnews/base/test/unit/test_accountMigration.js
@@ -2,20 +2,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * This tests that we don't try to reset the mail.server.server<n>.authMethod
  * preference every time we run the migration code, and other migration stuff
  */
 
-// make xpcshell-tests TEST_PATH=mailnews/base/test/unit/test_accountMigration.js
-
 var {migrateMailnews} = ChromeUtils.import("resource:///modules/mailnewsMigrator.js");
 
+/* import-globals-from ../../../test/resources/abSetup.js */
 load("../../../resources/abSetup.js");
 
 function run_test() {
   // Set up some basic accounts with limited prefs - enough to satisfy the
   // migrator.
   Services.prefs.setCharPref("mail.account.account1.server", "server1");
   Services.prefs.setCharPref("mail.account.account2.server", "server2");
 
--- a/mailnews/base/test/unit/test_acctRepair.js
+++ b/mailnews/base/test/unit/test_acctRepair.js
@@ -4,18 +4,17 @@
 
 /**
  * This tests that we recover from having a local folders server
  * without having an account that points at it.
  */
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-function run_test()
-{
+function run_test() {
   // Create account prefs with both kinds of duplication.
 
   Services.prefs.setCharPref("mail.account.account2.identities", "id2");
   Services.prefs.setCharPref("mail.account.account2.server", "server1");
   Services.prefs.setCharPref("mail.account.account6.identities", "id3");
   Services.prefs.setCharPref("mail.account.account6.server", "server5");
   Services.prefs.setCharPref("mail.server.server1.hostname",
                              "Local Folders");
--- a/mailnews/base/test/unit/test_base64_decoding.js
+++ b/mailnews/base/test/unit/test_base64_decoding.js
@@ -1,96 +1,81 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This tests that we do not crash when loading the email bodySearchCrash,
 // which was fixed in bug 465805
 
+/* import-globals-from ../../../test/resources/searchTestUtils.js */
 load("../../../resources/searchTestUtils.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var nsMsgSearchScope = Ci.nsMsgSearchScope;
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp = Ci.nsMsgSearchOp;
-
-var Contains = nsMsgSearchOp.Contains;
+var Contains = Ci.nsMsgSearchOp.Contains;
+var Body = Ci.nsMsgSearchAttrib.Body;
 
-var offlineMail = nsMsgSearchScope.offlineMail;
-var offlineMailFilter = nsMsgSearchScope.offlineMailFilter;
-
-var Body = nsMsgSearchAttrib.Body;
-
-var Files =
-[
+var Files = [
   "../../../data/bugmail1",
   "../../../data/bodySearchCrash",            // Test for bug 465805.
-  "../../../data/base64-with-whitespace.eml"  // Test for bug 1487421.
-]
+  "../../../data/base64-with-whitespace.eml", // Test for bug 1487421.
+];
 
-var Tests =
-[
-
-// this number appears in bugmail1
-  { value: "432710",
+var Tests = [
+  {
+    // this number appears in bugmail1
+    value: "432710",
     attrib: Body,
     op: Contains,
-    count: 1 },
-
-// this appears in base64-with-whitespace.eml
-  { value: "abcdefghijklmnopqrstuvwxyz",
+    count: 1,
+  }, {
+    // this appears in base64-with-whitespace.eml
+    value: "abcdefghijklmnopqrstuvwxyz",
     attrib: Body,
     op: Contains,
-    count: 1 },
-]
+    count: 1,
+  },
+];
 
-function run_test()
-{
+function run_test() {
   // Setup local mail accounts.
   localAccountUtils.loadLocalMailAccount();
 
   // Get a message into the local filestore. function testBodySearch() continues the testing after the copy.
   do_test_pending();
   copyListener.OnStopCopy(null);
   return true;
 }
 
-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) {
     let fileName = Files.shift();
-    if (fileName)
-    {
+    if (fileName) {
       let file = do_get_file(fileName);
       MailServices.copy.CopyFileMessage(file, localAccountUtils.inboxFolder, null,
                                         false, 0, "", copyListener, null);
+    } else {
+      testBodySearch();
     }
-    else
-      testBodySearch();
-  }
+  },
 };
 
 // Runs at completion of copy
 
 // process each test from queue, calls itself upon completion of each search
-var testObject;
-function testBodySearch()
-{
+function testBodySearch() {
   print("Test Body Search");
   var test = Tests.shift();
-  if (test)
-  {
-    testObject = new TestSearch(localAccountUtils.inboxFolder,
-                         test.value,
-                         test.attrib,
-                         test.op,
-                         test.count,
-                         testBodySearch);
+  if (test) {
+    new TestSearch(localAccountUtils.inboxFolder,
+                   test.value,
+                   test.attrib,
+                   test.op,
+                   test.count,
+                   testBodySearch);
+  } else {
+    do_test_finished();
   }
-  else
-    do_test_finished();
 }
--- a/mailnews/base/test/unit/test_bccInDatabase.js
+++ b/mailnews/base/test/unit/test_bccInDatabase.js
@@ -5,42 +5,39 @@
 /*
  * Testing of bcc in message summary file added in bug 481667
  */
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var hdr;
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
-  var copyListener =
-  {
-    OnStartCopy: function() {},
-    OnProgress: function(aProgress, aProgressMax) {},
-    SetMessageKey: function(aKey) {
+  var copyListener = {
+    OnStartCopy() {},
+    OnProgress(aProgress, aProgressMax) {},
+    SetMessageKey(aKey) {
       hdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);
     },
-    SetMessageId: function(aMessageId) {},
-    OnStopCopy: function(aStatus) { continueTest();}
+    SetMessageId(aMessageId) {},
+    OnStopCopy(aStatus) { continueTest(); },
   };
 
   // Get a message into the local filestore.
   var draft = do_get_file("../../../data/draft1");
   do_test_pending();
   MailServices.copy.CopyFileMessage(draft, localAccountUtils.inboxFolder, null, false, 0,
                                     "", copyListener, null);
 }
 
-function continueTest()
-{
-  //dump("\nbccList >" + hdr.bccList);
-  //dump("\nccList >" + hdr.ccList);
-  //dump("\n");
+function continueTest() {
+  // dump("\nbccList >" + hdr.bccList);
+  // dump("\nccList >" + hdr.ccList);
+  // dump("\n");
   Assert.ok(hdr.bccList.includes("Another Person"));
   Assert.ok(hdr.bccList.includes("<u1@example.com>"));
   Assert.ok(!hdr.bccList.includes("IDoNotExist"));
   hdr = null;
   do_test_finished();
 }
 
--- a/mailnews/base/test/unit/test_bug366491.js
+++ b/mailnews/base/test/unit/test_bug366491.js
@@ -2,98 +2,93 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // tests return of junk percent from bayesian filter
 
 // main setup
 
 // only needed during debug
-//do_import_script("mailnews/extensions/bayesian-spam-filter/test/resources/trainingfile.js");
+// do_import_script("mailnews/extensions/bayesian-spam-filter/test/resources/trainingfile.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 // local constants
 var kUnclassified = MailServices.junk.UNCLASSIFIED;
 var kJunk = MailServices.junk.JUNK;
 var kGood = MailServices.junk.GOOD;
 
 /*
  * This test is not intended to check the spam calculations,
  * but only that the junk percent is transmitted (particularly
  * for intermediate values). The test
  * junkPercent values below were calculated by the plugin,
  * not indepedently verified.
  */
 
-var tests =
-[
-  {fileName: "ham2.eml",
-   junkPercent: 8},
-  {fileName: "spam2.eml",
-   junkPercent: 81},
+var tests = [
+  {
+    fileName: "ham2.eml",
+    junkPercent: 8,
+  }, {
+    fileName: "spam2.eml",
+    junkPercent: 81,
+  },
 ];
 
-var emails =
-[
-  {fileName: "ham1.eml",
-   classification: kGood},
-  {fileName: "spam1.eml",
-   classification: kJunk},
+var emails = [
+  {
+    fileName: "ham1.eml",
+    classification: kGood,
+  }, {
+    fileName: "spam1.eml",
+    classification: kJunk,
+  },
 ];
 
 // main test
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
   do_test_pending();
   doTestingListener.onMessageClassified(null, null, null);
   return true;
-};
+}
 
 var haveClassification = false;
-var doTestingListener =
-{
-  onMessageClassified: function(aMsgURI, aClassification, aJunkPercent)
-  {
+var doTestingListener = {
+  onMessageClassified(aMsgURI, aClassification, aJunkPercent) {
     // Do we have more training emails? If so, train
     var email = emails.shift();
-    if (email)
-    {
+    if (email) {
       MailServices.junk.setMessageClassification(getSpec(email.fileName),
         kUnclassified, email.classification, null, doTestingListener);
       return;
     }
 
     if (!aMsgURI)
       return; // ignore end of batch
 
     // Have we completed a classification? If so, test
-    if (haveClassification)
-    {
+    if (haveClassification) {
       let test = tests.shift();
       Assert.equal(getSpec(test.fileName), aMsgURI);
       Assert.equal(test.junkPercent, aJunkPercent);
     }
 
     // Do we have more classifications to do? Then classify the first one.
-    if (tests.length)
-    {
+    if (tests.length) {
       haveClassification = true;
       MailServices.junk.classifyMessage(getSpec(tests[0].fileName),
         null, doTestingListener);
-      return;
+    } else {
+      do_test_finished();
     }
-
-    else
-      do_test_finished();
-  }
+  },
 };
 
 // helper functions
 
-function getSpec(aFileName)
-{
+function getSpec(aFileName) {
   var file = do_get_file("../../../extensions/bayesian-spam-filter/test/unit/resources/" + aFileName);
   var uri = Services.io.newFileURI(file).QueryInterface(Ci.nsIURL);
   uri = uri.mutate().setQuery("type=application/x-message-display").finalize();
   return uri.spec;
 }
--- a/mailnews/base/test/unit/test_bug404489.js
+++ b/mailnews/base/test/unit/test_bug404489.js
@@ -1,68 +1,70 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Tests that custom headers like "Sender" work (bug 404489)
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var nsMsgSearchScope = Ci.nsMsgSearchScope;
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp = Ci.nsMsgSearchOp;
-var Contains = nsMsgSearchOp.Contains;
-var offlineMail = nsMsgSearchScope.offlineMail;
+var Contains = Ci.nsMsgSearchOp.Contains;
 var gArrayHdrs = ["X-Bugzilla-Who", "Sender"];
-var gFirstHeader = nsMsgSearchAttrib.OtherHeader + 1;
+var gFirstHeader = Ci.nsMsgSearchAttrib.OtherHeader + 1;
 var fileName = "../../../data/SenderHeader";
 
-var Tests =
-[
+var Tests = [
   /* test header:
   X-Bugzilla-Who: bugmail@example.org
 
   This just shows that normal custom headers work
   */
-  { testValue: "bugmail",
+  {
+    testValue: "bugmail",
     attrib: gFirstHeader,
     op: Contains,
-    count: 1},
-  { testValue: "ThisIsNotThere",
+    count: 1,
+  }, {
+    testValue: "ThisIsNotThere",
     attrib: gFirstHeader,
     op: Contains,
-    count: 0},
+    count: 0,
+  },
   /* test header:
   Sender: iamthesender@example.com
 
   This is the main fix of bug 404489, that we can use Sender as a header
   */
-  { testValue: "iamthesender",
+  {
+    testValue: "iamthesender",
     attrib: gFirstHeader + 1,
     op: Contains,
-    count: 1},
+    count: 1,
+  },
   /* test header:
   From: bugzilla-daemon@mozilla.invalid
 
   Here we show that the "From" header does not fire tests for the
   "Sender" arbitrary headers, but does fire the standard test
   for nsMsgSenderAttrib.Sender
   */
-  { testValue: "bugzilla",
+  {
+    testValue: "bugzilla",
     attrib: gFirstHeader + 1,
     op: Contains,
-    count: 0},
-  { testValue: "bugzilla",
+    count: 0,
+  }, {
+    testValue: "bugzilla",
     attrib: Ci.nsMsgSearchAttrib.Sender,
     op: Contains,
-    count: 1}
+    count: 1,
+  },
 ];
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   // add the custom headers into the preferences file, ":" delimited
 
   var hdrs;
   if (gArrayHdrs.length == 1)
     hdrs = gArrayHdrs;
   else
@@ -72,41 +74,36 @@ function run_test()
   // Get a message into the local filestore. function continue_test() continues the testing after the copy.
   do_test_pending();
   var file = do_get_file(fileName);
   MailServices.copy.CopyFileMessage(file, localAccountUtils.inboxFolder, null, false, 0,
                                     "", copyListener, null);
   return true;
 }
 
-var copyListener =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey) { },
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus) { continue_test();}
+var copyListener = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) { },
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) { continue_test(); },
 };
 
 // Runs at completion of each copy
 // process each test from queue, calls itself upon completion of each search
-var testObject;
-function continue_test()
-{
+function continue_test() {
   var test = Tests.shift();
-  if (test)
-    testObject = new TestSearchx(localAccountUtils.inboxFolder,
-                                 test.testValue,
-                                 test.attrib,
-                                 test.op,
-                                 test.count,
-                                 continue_test);
-  else
-  {
-    testObject = null;
+  if (test) {
+    new TestSearchx(localAccountUtils.inboxFolder,
+                    test.testValue,
+                    test.attrib,
+                    test.op,
+                    test.count,
+                    continue_test);
+  } else {
     do_test_finished();
   }
 }
 
 /*
  * TestSearchx: Class to test number of search hits
  *
  * @param aFolder:   the folder to search
@@ -118,30 +115,27 @@ function continue_test()
  *
  * @param aAttrib:   attribute for the search (Ci.nsMsgSearchAttrib.Size, etc.)
  * @param aOp:       operation for the search (Ci.nsMsgSearchOp.Contains, etc.)
  * @param aHitCount: expected number of search hits
  * @param onDone:    function to call on completion of search
  *
  */
 
-function TestSearchx(aFolder, aValue, aAttrib, aOp, aHitCount, onDone)
-{
-  var searchListener =
-  {
-    onSearchHit: function(dbHdr, folder) { hitCount++; },
-    onSearchDone: function(status)
-    {
+function TestSearchx(aFolder, aValue, aAttrib, aOp, aHitCount, onDone) {
+  var searchListener = {
+    onSearchHit(dbHdr, folder) { hitCount++; },
+    onSearchDone(status) {
       print("Finished search does " + aHitCount + " equal " + hitCount + "?");
       searchSession = null;
       Assert.equal(aHitCount, hitCount);
       if (onDone)
         onDone();
     },
-    onNewSearch: function() {hitCount = 0;}
+    onNewSearch() { hitCount = 0; },
   };
 
   // define and initiate the search session
 
   var hitCount;
   var searchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                         .createInstance(Ci.nsIMsgSearchSession);
   searchSession.addScopeTerm(Ci.nsMsgSearchScope.offlineMail, aFolder);
@@ -171,17 +165,17 @@ function TestSearchx(aFolder, aValue, aA
     value.label = aValue;
   else if (aAttrib == Ci.nsMsgSearchAttrib.JunkStatus)
     value.junkStatus = aValue;
   else if (aAttrib == Ci.nsMsgSearchAttrib.HasAttachmentStatus)
     value.status = Ci.nsMsgMessageFlags.Attachment;
   else
     value.str = aValue;
   searchTerm.value = value;
-  if (aAttrib > nsMsgSearchAttrib.OtherHeader)
-    searchTerm.arbitraryHeader = gArrayHdrs[aAttrib - 1 - nsMsgSearchAttrib.OtherHeader];
+  if (aAttrib > Ci.nsMsgSearchAttrib.OtherHeader)
+    searchTerm.arbitraryHeader = gArrayHdrs[aAttrib - 1 - Ci.nsMsgSearchAttrib.OtherHeader];
   searchTerm.op = aOp;
   searchTerm.booleanAnd = false;
   searchSession.appendTerm(searchTerm);
   searchSession.registerListener(searchListener);
   searchSession.search(null);
 }
 
--- a/mailnews/base/test/unit/test_bug428427.js
+++ b/mailnews/base/test/unit/test_bug428427.js
@@ -1,74 +1,69 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Test of message count changes in virtual folder views
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var dbviewContractId = "@mozilla.org/messenger/msgdbview;1?type=" + "quicksearch";
-var dbView = Cc[dbviewContractId].createInstance(Ci.nsIMsgDBView);
 var bugmail1 = do_get_file("../../../data/bugmail1");
 // main test
 
 // the headers for the test messages. All messages are identical, but
 // have different properties set on them.
 var hdrs = [];
 
 // how many identical messages to load
 var messageCount = 5;
 
 // tag used with test messages
 var tag1 = "istag";
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   // Get messageCount messages into the local filestore.
   do_test_pending();
 
   // function setupVirtualFolder() continues the testing after CopyFileMessage.
   MailServices.copy.CopyFileMessage(bugmail1, localAccountUtils.inboxFolder, null, false,
                                     0, "", copyListener, null);
   return true;
 }
 
 // nsIMsgCopyServiceListener implementation
-var copyListener =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey)
-  {
+var copyListener = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {
     hdrs.push(localAccountUtils.inboxFolder.GetMessageHeader(aKey));
   },
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus)
-  {
-    if (--messageCount)
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) {
+    if (--messageCount) {
       MailServices.copy.CopyFileMessage(bugmail1, localAccountUtils.inboxFolder, null,
-                                  false, 0, "", copyListener, null);
-    else {
+                                        false, 0, "", copyListener, null);
+    } else {
       try {
-      setupVirtualFolder();
-      } catch (ex) {dump(ex);}
+        setupVirtualFolder();
+      } catch (ex) {
+        dump(ex);
+      }
     }
-  }
+  },
 };
 
 var virtualFolder;
 var numTotalMessages;
 var numUnreadMessages;
 
 // virtual folder setup
-function setupVirtualFolder()
-{
+function setupVirtualFolder() {
   // add as valid tag tag1, though probably not really necessary
   MailServices.tags.addTagForKey(tag1, tag1, null, null);
 
   // add tag1 to 4 messages
   var messages0to3 = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
   for (var i = 0; i <= 3; i++)
     messages0to3.appendElement(hdrs[i]);
   localAccountUtils.inboxFolder.addKeywordsToMessages(messages0to3, tag1);
@@ -87,79 +82,74 @@ function setupVirtualFolder()
   // search will look for tag tag1 in the inbox folder
   var searchTerm = makeSearchTerm(localAccountUtils.inboxFolder, tag1,
     Ci.nsMsgSearchAttrib.Keywords, Ci.nsMsgSearchOp.Contains);
 
   dump("creating virtual folder\n");
   var rootFolder = localAccountUtils.incomingServer.rootMsgFolder;
   virtualFolder = CreateVirtualFolder("VfTest", rootFolder,
                                       localAccountUtils.inboxFolder.URI, searchTerm, false);
-  var count= new Object;
+
   // Setup search session. Execution continues with testVirtualFolder()
   // after search is done.
 
   var searchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                         .createInstance(Ci.nsIMsgSearchSession);
   searchSession.addScopeTerm(Ci.nsMsgSearchScope.offlineMail,
                              localAccountUtils.inboxFolder);
   searchSession.appendTerm(searchTerm, false);
   searchSession.registerListener(searchListener);
   dump("starting search of vf\n");
   searchSession.search(null);
 }
 
 // partially based on gSearchNotificationListener in searchBar.js
 // nsIMsgSearchNotify implementation
-var searchListener =
-{
-  onNewSearch: function()
-  {
+var searchListener = {
+  onNewSearch() {
     dump("in onnewsearch\n");
     numTotalMessages = 0;
     numUnreadMessages = 0;
   },
-  onSearchHit: function(dbHdr, folder)
-  {
+  onSearchHit(dbHdr, folder) {
     print("Search hit, isRead is " + dbHdr.isRead);
     numTotalMessages++;
     if (!dbHdr.isRead)
       numUnreadMessages++;
   },
-  onSearchDone: function(status)
-  {
+  onSearchDone(status) {
     print("Finished search hitCount = " + numTotalMessages);
     var db = virtualFolder.msgDatabase;
     var dbFolderInfo = db.dBFolderInfo;
     dbFolderInfo.numMessages = numTotalMessages;
     dbFolderInfo.numUnreadMessages = numUnreadMessages;
     virtualFolder.updateSummaryTotals(true);
     print("virtual folder unread is " + virtualFolder.getNumUnread(false));
     testVirtualFolder();
-  }
+  },
 };
 
-function testVirtualFolder()
-{
-  /*** basic functionality tests ***/
+function testVirtualFolder() {
+  // basic functionality tests
 
   // total messages matching search
   Assert.equal(4, virtualFolder.getTotalMessages(false));
 
   // total unread messages in search
   Assert.equal(3, virtualFolder.getNumUnread(false));
 
   // change unread of one item in search to decrease count
   var message0 = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
   message0.appendElement(hdrs[0]);
   localAccountUtils.inboxFolder.markMessagesRead(message0, true);
   virtualFolder.updateSummaryTotals(true);
 
   Assert.equal(2, virtualFolder.getNumUnread(false));
 
-  /*** failures fixed in this bug ***/
+  // failures fixed in this bug
 
   // remove tag from one item to decrease count
   var message1 = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
   message1.appendElement(hdrs[1]);
 
   localAccountUtils.inboxFolder.removeKeywordsFromMessages(message1, tag1);
   virtualFolder.updateSummaryTotals(true);
   Assert.equal(3, virtualFolder.getTotalMessages(false));
@@ -170,58 +160,54 @@ function testVirtualFolder()
 
   do_test_finished();
   return true;
 }
 
 // helper functions
 
 // adapted from commandglue.js
-function CreateVirtualFolder(newName, parentFolder, searchFolderURIs, searchTerm, searchOnline)
-{
+function CreateVirtualFolder(newName, parentFolder, searchFolderURIs, searchTerm, searchOnline) {
   var newFolder = parentFolder.addSubfolder(newName);
   newFolder.setFlag(Ci.nsMsgFolderFlags.Virtual);
   var vfdb = newFolder.msgDatabase;
-  var searchTerms = [];
   var searchTermString = getSearchTermString(searchTerm);
 
   var dbFolderInfo = vfdb.dBFolderInfo;
   // set the view string as a property of the db folder info
   // set the original folder name as well.
   dbFolderInfo.setCharProperty("searchStr", searchTermString);
   dbFolderInfo.setCharProperty("searchFolderUri", searchFolderURIs);
   dbFolderInfo.setBooleanProperty("searchOnline", searchOnline);
   // This fails because the folder doesn't exist - why were we doing it?
   //  vfdb.summaryValid = true;
   vfdb.Close(true);
   // use acctMgr to setup the virtual folder listener
   var acctMgr = MailServices.accounts.QueryInterface(Ci.nsIFolderListener);
-  //print(acctMgr);
+  // print(acctMgr);
   acctMgr.OnItemAdded(null, newFolder);
   return newFolder;
 }
 
-function getSearchTermString(term)
-{
+function getSearchTermString(term) {
   var condition = "";
 
   if (condition.length > 1)
-    condition += ' ';
+    condition += " ";
 
   if (term.matchAll)
     condition = "ALL";
   condition += (term.booleanAnd) ? "AND (" : "OR (";
-  condition += term.termAsString + ')';
+  condition += term.termAsString + ")";
   return condition;
 }
 
 // Create a search term for searching aFolder
 //   using aAttrib, aOp, and string aStrValue
-function makeSearchTerm(aFolder, aStrValue, aAttrib, aOp)
-{
+function makeSearchTerm(aFolder, aStrValue, aAttrib, aOp) {
   // use a temporary search session
   var searchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                         .createInstance(Ci.nsIMsgSearchSession);
   searchSession.addScopeTerm(Ci.nsMsgSearchScope.offlineMail, aFolder);
   var searchTerm = searchSession.createTerm();
   var value = searchTerm.value;
   value.str = aStrValue;
   searchTerm.value = value;
--- a/mailnews/base/test/unit/test_bug434810.js
+++ b/mailnews/base/test/unit/test_bug434810.js
@@ -1,18 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Test of setup of localMailFolders
 
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   var rootFolder = localAccountUtils.incomingServer.rootFolder;
 
   var msgProps = Services.strings.createBundle("chrome://messenger/locale/messenger.properties");
 
   var expectedFolders = [ "Inbox" ]; // Inbox hard-coded in localAccountUtils.js
 
--- a/mailnews/base/test/unit/test_bug471682.js
+++ b/mailnews/base/test/unit/test_bug471682.js
@@ -12,93 +12,83 @@ var {MailServices} = ChromeUtils.import(
 
 var bugmail1 = do_get_file("../../../data/bugmail1");
 var gHdr; // header of test message in local folder
 
 localAccountUtils.loadLocalMailAccount();
 // create a subfolder as a target for copies
 var gSubfolder = localAccountUtils.inboxFolder.createLocalSubfolder("subfolder");
 
-function run_test()
-{
+function run_test() {
   // make sure we're using berkeley mailbox format here since this test
   // assumes berkeley mailbox format.
   if (Services.prefs.getCharPref("mail.serverDefaultStoreContractID") !=
       "@mozilla.org/msgstore/berkeleystore;1")
     return;
 
   do_test_pending();
   // step 1: copy a message into the local inbox
   MailServices.copy.CopyFileMessage(bugmail1, localAccountUtils.inboxFolder, null,
                                     false, 0, "", step2, null);
-  return;
 }
 
 // step 2: copy one message into a subfolder to establish an
 //         mbox file time and size
 // nsIMsgCopyServiceListener implementation
-var step2 =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey)
-  {
+var step2 = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {
     dump("in set message key\n");
     gHdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);
   },
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus)
-  {
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) {
     Assert.notEqual(gHdr, null);
     // copy the message into the subfolder
     var messages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
     messages.appendElement(gHdr);
     MailServices.copy.CopyMessages(localAccountUtils.inboxFolder, messages, gSubfolder,
                                    false, step3, null, false);
-  }
+  },
 };
 
 // step 3: after the copy, delay to allow copy to complete and allow possible
 //         file error time
 // nsIMsgCopyServiceListener implementation
-var step3 =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey) {},
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus)
-  {
+var step3 = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {},
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) {
     do_timeout(2000, step4);
-  }
-}
+  },
+};
 
 // step 4: start a second copy
-function step4()
-{
+function step4() {
   var messages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
   messages.appendElement(gHdr);
   MailServices.copy.CopyMessages(localAccountUtils.inboxFolder, messages, gSubfolder,
                                  false, step5, null, false);
 }
 
 // step 5:  actual tests of file size and date
 // nsIMsgCopyServiceListener implementation
-var step5 =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey) {},
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus)
-  {
+var step5 = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {},
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) {
     var dbSize = gSubfolder.msgDatabase.dBFolderInfo.folderSize;
     var dbDate = gSubfolder.msgDatabase.dBFolderInfo.folderDate;
     var filePath = gSubfolder.filePath;
-    var date = parseInt(filePath.lastModifiedTime/1000);
+    var date = parseInt(filePath.lastModifiedTime / 1000);
     var size = filePath.fileSize;
     Assert.equal(size, dbSize);
     Assert.equal(date, dbDate);
     // End of test, so release our header reference
     gHdr = null;
     do_test_finished();
-  }
-}
+  },
+};
--- a/mailnews/base/test/unit/test_bug514945.js
+++ b/mailnews/base/test/unit/test_bug514945.js
@@ -1,36 +1,36 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Testing of GetAvailable crashes in bug 514945
  */
 
-function run_test()
-{
-  const kValidityManager = Cc['@mozilla.org/mail/search/validityManager;1']
+function run_test() {
+  const kValidityManager = Cc["@mozilla.org/mail/search/validityManager;1"]
                              .getService(Ci.nsIMsgSearchValidityManager);
 
   let validityTable = kValidityManager.getTable(Ci.nsMsgSearchScope.offlineMail);
 
   // When we try to access a bad value of getAvailable, it should give an error,
   //  not crash.
   let BAD_VALUE = 1000000; // some large value that is beyond the array bounds
   let haveExpectedError = false;
   try {
-    let isAvailable = validityTable.getAvailable(Ci.nsMsgSearchAttrib.Subject, BAD_VALUE);
-  } catch (e) { dump('Error but no crash, this is what we want:' + e + '\n');
-                haveExpectedError = true;
-              }
+    validityTable.getAvailable(Ci.nsMsgSearchAttrib.Subject, BAD_VALUE);
+  } catch (e) {
+    dump("Error but no crash, this is what we want:" + e + "\n");
+    haveExpectedError = true;
+  }
 
   Assert.ok(haveExpectedError);
 
-// One of the causes of this is that search term operators are not being
-//  initialized, resulting in random values of the operator. Make sure that is
-//  fixed.
+  // One of the causes of this is that search term operators are not being
+  //  initialized, resulting in random values of the operator. Make sure that is
+  //  fixed.
 
   const kSearchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                         .createInstance(Ci.nsIMsgSearchSession);
   let searchTerm = kSearchSession.createTerm();
   Assert.equal(searchTerm.op, Ci.nsMsgSearchOp.Contains);
 }
--- a/mailnews/base/test/unit/test_compactColumnSave.js
+++ b/mailnews/base/test/unit/test_compactColumnSave.js
@@ -30,159 +30,144 @@ Services.prefs.setCharPref("mail.serverD
                            "@mozilla.org/msgstore/berkeleystore;1");
 
 // Globals
 var gMsgFile1, gMsgFile2, gMsgFile3;
 var gLocalFolder2;
 
 var gCurTestNum;
 
-var gMsgHdrs = new Array();
+var gMsgHdrs = [];
 
 var PERSISTED_COLUMN_PROPERTY_NAME = "columnStates";
 var columnJSON = '{"threadCol":{"visible":true,"ordinal":"1"},"flaggedCol":{"visible":true,"ordinal":"4"},"attachmentCol":{"visible":true,"ordinal":"5"},"subjectCol":{"visible":true,"ordinal":"7"},"unreadButtonColHeader":{"visible":true,"ordinal":"9"},"senderCol":{"visible":true,"ordinal":"11"},"recipientCol":{"visible":false,"ordinal":"13"},"junkStatusCol":{"visible":true,"ordinal":"15"},"receivedCol":{"visible":true,"ordinal":"17"},"dateCol":{"visible":true,"ordinal":"19"},"statusCol":{"visible":false,"ordinal":"21"},"sizeCol":{"visible":true,"ordinal":"23"},"tagsCol":{"visible":false,"ordinal":"25"},"accountCol":{"visible":false,"ordinal":"27"},"priorityCol":{"visible":false,"ordinal":"29"},"unreadCol":{"visible":false,"ordinal":"31"},"totalCol":{"visible":false,"ordinal":"33"},"locationCol":{"visible":false,"ordinal":"35"},"idCol":{"visible":false,"ordinal":"37"}}';
 
 function setColumnStates(folder) {
   let msgDatabase = folder.msgDatabase;
   let dbFolderInfo = msgDatabase.dBFolderInfo;
-  dbFolderInfo.setCharProperty(this.PERSISTED_COLUMN_PROPERTY_NAME, columnJSON);
+  dbFolderInfo.setCharProperty(PERSISTED_COLUMN_PROPERTY_NAME, columnJSON);
   msgDatabase.Commit(Ci.nsMsgDBCommitType.kLargeCommit);
 }
 
 function checkPersistentState(folder) {
   let msgDatabase = folder.msgDatabase;
   let dbFolderInfo = msgDatabase.dBFolderInfo;
-  let state = dbFolderInfo.getCharProperty(this.PERSISTED_COLUMN_PROPERTY_NAME);
+  let state = dbFolderInfo.getCharProperty(PERSISTED_COLUMN_PROPERTY_NAME);
   Assert.equal(state, columnJSON);
-  do_timeout(0, function(){doTest(++gCurTestNum);});
+  do_timeout(0, function() { doTest(++gCurTestNum); });
 }
 
 
 // nsIMsgCopyServiceListener implementation
-var copyListener =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey)
-  {
+var copyListener = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {
     try {
       let hdr = gLocalFolder2.GetMessageHeader(aKey);
-      gMsgHdrs.push({hdr: hdr, ID: hdr.messageId});
-    }
-    catch(e) {
+      gMsgHdrs.push({hdr, ID: hdr.messageId});
+    } catch (e) {
       dump("SetMessageKey failed: " + e + "\n");
     }
   },
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus)
-  {
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) {
     // 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); });
+  },
 };
 
-var urlListener =
-{
-  OnStartRunningUrl: function (aUrl) {
+var urlListener = {
+  OnStartRunningUrl(aUrl) {
   },
-  OnStopRunningUrl: function (aUrl, aExitCode) {
+  OnStopRunningUrl(aUrl, aExitCode) {
     // Check: message successfully copied.
     Assert.equal(aExitCode, 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); });
+  },
 };
 
-function copyFileMessage(file, destFolder, isDraftOrTemplate)
-{
+function copyFileMessage(file, destFolder, isDraftOrTemplate) {
   MailServices.copy.CopyFileMessage(file, destFolder, null, isDraftOrTemplate, 0, "", copyListener, null);
 }
 
-function deleteMessages(srcFolder, items)
-{
+function deleteMessages(srcFolder, items) {
   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-  items.forEach(function (item) {
+  items.forEach(function(item) {
     array.appendElement(item);
   });
 
   srcFolder.deleteMessages(array, null, false, true, copyListener, true);
 }
 
 /*
  * TESTS
  */
 
 // Beware before commenting out a test -- later tests might just depend on earlier ones
-var gTestArray =
-[
+var gTestArray = [
   // Copying messages from files
   function testCopyFileMessage1() { copyFileMessage(gMsgFile1, gLocalFolder2, false); },
   function testCopyFileMessage2() { copyFileMessage(gMsgFile2, gLocalFolder2, false); },
   function testCopyFileMessage3() { copyFileMessage(gMsgFile3, gLocalFolder2, true); },
 
   // Deleting messages
   function testDeleteMessages1() { // delete to trash
     deleteMessages(gLocalFolder2, [gMsgHdrs[0].hdr], false, false);
   },
-  function checkBeforeCompact()
-  {
+  function checkBeforeCompact() {
     checkPersistentState(gLocalFolder2);
   },
-  function compactFolder()
-  {
+  function compactFolder() {
     gLocalFolder2.compact(urlListener, null);
   },
-  function checkAfterCompact()
-  {
+  function checkAfterCompact() {
     checkPersistentState(gLocalFolder2);
   },
 ];
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
   // Load up some messages so that we can copy them in later.
   gMsgFile1 = do_get_file("../../../data/bugmail10");
   gMsgFile2 = do_get_file("../../../data/bugmail11");
   gMsgFile3 = do_get_file("../../../data/draft1");
 
   // Create another folder to move and copy messages around, and force initialization.
   gLocalFolder2 = localAccountUtils.rootFolder.createLocalSubfolder("folder2");
-  let folderName = gLocalFolder2.prettyName;
   setColumnStates(gLocalFolder2);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of all the operations.
   do_test_pending();
 
 //  do_test_finished();
   // Do the test.
   doTest(1);
 }
 
-function doTest(test)
-{
-  if (test <= gTestArray.length)
-  {
+function doTest(test) {
+  if (test <= gTestArray.length) {
     gCurTestNum = test;
-    var testFn = gTestArray[test-1];
+    var testFn = gTestArray[test - 1];
     // Set a limit of 10 seconds; if the notifications haven't arrived by
     // then, there's a problem.
     do_timeout(10000, function() {
       if (gCurTestNum == test)
         do_throw("Notifications not received in 10000 ms for operation " + testFn.name);
     });
     try {
-    testFn();
-    } catch(ex) {dump(ex);}
-  }
-  else
-  {
+      testFn();
+    } catch (ex) {
+      dump(ex);
+    }
+  } else {
     do_test_finished(); // for the one in run_test()
   }
 }
--- a/mailnews/base/test/unit/test_compactFailure.js
+++ b/mailnews/base/test/unit/test_compactFailure.js
@@ -1,12 +1,15 @@
 
 const {toXPCOMArray} = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 const {MockFactory} = ChromeUtils.import("resource://testing-common/mailnews/MockFactory.js");
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/messageGenerator.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/messageGenerator.js");
 
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/berkeleystore;1");
 
 var gTargetFolder;
@@ -17,55 +20,55 @@ logHelperAllowedErrors.push(Cr.NS_ERROR_
 logHelperAllowedErrors.push(Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST);
 
 function LockedFileOutputStream() {
 }
 
 LockedFileOutputStream.prototype = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsIFileOutputStream]),
 
-  init: function(file, ioFlags, perm, behaviorFlags) {
+  init(file, ioFlags, perm, behaviorFlags) {
     throw Cr.NS_ERROR_FILE_IS_LOCKED;
   },
-}
+};
 
 var MsgDBServiceFailure = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsIMsgDBService]),
 
-  openMailDBFromFile: function(file, folder, create, leaveInvalidDB) {
+  openMailDBFromFile(file, folder, create, leaveInvalidDB) {
     if (folder.name == "ShouldFail")
       throw Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
     return this._genuine.openMailDBFromFile(file, folder, create, leaveInvalidDB);
   },
 
-  openFolderDB: function(folder, leaveInvalidDB) {
+  openFolderDB(folder, leaveInvalidDB) {
     return this._genuine.openFolderDB(folder, leaveInvalidDB);
   },
-  asyncOpenFolderDB: function(folder, leaveInvalidDB) {
+  asyncOpenFolderDB(folder, leaveInvalidDB) {
     return this._genuine.asyncOpenFolderDB(folder, leaveInvalidDB);
   },
-  openMore: function(db, timeHint) {
+  openMore(db, timeHint) {
     return this._genuine.openMore(db, timeHint);
   },
-  createNewDB: function(folder) {
+  createNewDB(folder) {
     return this._genuine.createNewDB(folder);
   },
-  registerPendingListener: function(folder, listener) {
+  registerPendingListener(folder, listener) {
     this._genuine.registerPendingListener(folder, listener);
   },
-  unregisterPendingListener: function(listener) {
+  unregisterPendingListener(listener) {
     this._genuine.unregisterPendingListener(listener);
   },
-  cachedDBForFolder: function(folder) {
+  cachedDBForFolder(folder) {
     return this._genuine.cachedDBFolder(folder);
   },
   get openDBs() {
     return this._genuine.oenDBs;
-  }
-}
+  },
+};
 
 function setup_output_stream_stub() {
   gUuid = MockFactory.register("@mozilla.org/network/file-output-stream;1",
                               LockedFileOutputStream);
 }
 
 function teardown_output_stream_stub() {
   MockFactory.unregister(gUuid);
@@ -120,17 +123,17 @@ function compact_with_exception(expected
   let compactor = Cc["@mozilla.org/messenger/localfoldercompactor;1"]
                     .createInstance(Ci.nsIMsgFolderCompactor);
   let listener = new AsyncUrlListener(null, function(url, exitCode) {
     do_throw("This listener should not be called back.");
   });
   try {
     compactor.compact(gTargetFolder, false, listener, null);
     do_throw("nsIMsgFolderCompactor.compact did not fail.");
-  } catch(ex) {
+  } catch (ex) {
     Assert.equal(expectedException, ex.result);
   }
 }
 
 function test_compact_without_crash() {
   compact_with_exception(Cr.NS_ERROR_FILE_IS_LOCKED);
 }
 
--- a/mailnews/base/test/unit/test_converterDeferredAccount.js
+++ b/mailnews/base/test/unit/test_converterDeferredAccount.js
@@ -12,48 +12,46 @@ const {allAccountsSorted} = ChromeUtils.
 // XXX: merge into test_converter.js
 
 var log = Log.repository.getLogger("MailStoreConverter");
 
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/berkeleystore;1");
 
 // No. of messages/files and folders copied.
-var gProgressValue = 0;
 var gMsgHdrs = [];
 // {nsIMsgLocalMailFolder} folder carrying messages for the pop server.
 var gInbox;
 // {nsIMsgIncomingServer} server for first deferred pop account.
 var gServer1;
 // {nsIMsgIncomingServer} server for second deferred pop account.
 var gServer2;
 // {nsIMsgIncomingServer} server to convert.
 var gServer;
 
 var copyListenerWrap = {
-  SetMessageKey: function(aKey) {
+  SetMessageKey(aKey) {
     let hdr = gInbox.GetMessageHeader(aKey);
-    gMsgHdrs.push({hdr: hdr, ID: hdr.messageId});
+    gMsgHdrs.push({hdr, ID: hdr.messageId});
   },
-  OnStopCopy: function(aStatus) {
+  OnStopCopy(aStatus) {
     // Check: message successfully copied.
     Assert.equal(aStatus, 0);
-  }
+  },
 };
 
-var EventTarget = function () {
-  this.dispatchEvent = function (event) {
+var EventTarget = function() {
+  this.dispatchEvent = function(event) {
     if (event.type == "progress") {
       log.trace("Progress: " + event.detail);
     }
   };
 };
 
-function copyFileMessage(file, destFolder, isDraftOrTemplate)
-{
+function copyFileMessage(file, destFolder, isDraftOrTemplate) {
   let listener = new PromiseTestUtils.PromiseCopyListener(copyListenerWrap);
   MailServices.copy.CopyFileMessage(file, destFolder, null, isDraftOrTemplate,
                                     0, "", listener, null);
   return listener.promise;
 }
 
 /**
  * Check that conversion worked for the given source.
@@ -62,34 +60,34 @@ function copyFileMessage(file, destFolde
  */
 function checkConversion(source, target) {
   let sourceContents = source.directoryEntries;
 
   while (sourceContents.hasMoreElements()) {
     let sourceContent = sourceContents.getNext().QueryInterface(Ci.nsIFile);
     let sourceContentName = sourceContent.leafName;
     let ext = sourceContentName.substr(-4);
-    let targetFile = FileUtils.File(OS.Path.join(target.path,sourceContentName));
+    let targetFile = FileUtils.File(OS.Path.join(target.path, sourceContentName));
     log.debug("Checking path: " + targetFile.path);
     if (ext == ".dat") {
       Assert.ok(targetFile.exists());
     } else if (sourceContent.isDirectory()) {
       Assert.ok(targetFile.exists());
       checkConversion(sourceContent, targetFile);
     } else if (ext != ".msf") {
       Assert.ok(targetFile.exists());
-      let cur = FileUtils.File(OS.Path.join(targetFile.path,"cur"));
+      let cur = FileUtils.File(OS.Path.join(targetFile.path, "cur"));
       Assert.ok(cur.exists());
-      let tmp = FileUtils.File(OS.Path.join(targetFile.path,"tmp"));
+      let tmp = FileUtils.File(OS.Path.join(targetFile.path, "tmp"));
       Assert.ok(tmp.exists());
       if (targetFile.leafName == "Inbox") {
         let curContents = cur.directoryEntries;
         let curContentsCount = 0;
         while (curContents.hasMoreElements()) {
-          let curContent = curContents.getNext();
+          curContents.getNext();
           curContentsCount++;
         }
         Assert.equal(curContentsCount, 1000);
       }
     }
   }
 }
 
@@ -167,13 +165,13 @@ add_task(function testMaildirConversion(
                                       new EventTarget());
   let originalRootFolder = gServer.rootFolder.filePath;
 
   pConverted.then(function(val) {
     log.debug("Conversion done: " + originalRootFolder.path + " => " + val);
     let newRootFolder = gServer.rootFolder.filePath;
     checkConversion(originalRootFolder, newRootFolder);
     do_test_finished();
-  }).catch (function(reason) {
+  }).catch(function(reason) {
     log.error("Conversion failed: " + reason.error);
-    ok(false); //Fail the test!
+    ok(false); // Fail the test!
   });
 });
--- a/mailnews/base/test/unit/test_copyChaining.js
+++ b/mailnews/base/test/unit/test_copyChaining.js
@@ -1,60 +1,56 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Test of chaining copies between the same folders
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
 load("../../../resources/messageGenerator.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var gCopySource;
 var gCopyDest;
 var gMsgEnumerator;
 var gCurTestNum = 1;
 
 // main test
 
-var hdrs = [];
-
-var gTestArray =
-[
+var gTestArray = [
   function copyMsg1() {
     gMsgEnumerator = gCopySource.msgDatabase.EnumerateMessages();
     CopyNextMessage();
   },
   function copyMsg2() {
     CopyNextMessage();
   },
   function copyMsg3() {
     CopyNextMessage();
   },
   function copyMsg4() {
     CopyNextMessage();
   },
 ];
 
-function CopyNextMessage()
-{
+function CopyNextMessage() {
   if (gMsgEnumerator.hasMoreElements()) {
     let msgHdr = gMsgEnumerator.getNext().QueryInterface(
       Ci.nsIMsgDBHdr);
     var messages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
     messages.appendElement(msgHdr);
     MailServices.copy.CopyMessages(gCopySource, messages, gCopyDest, true,
                                    copyListener, null, false);
+  } else {
+    do_throw("TEST FAILED - out of messages");
   }
-  else
-    do_throw ('TEST FAILED - out of messages');
 }
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
   let messageGenerator = new MessageGenerator();
   let scenarioFactory = new MessageScenarioFactory(messageGenerator);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
   do_test_pending();
 
@@ -64,50 +60,45 @@ function run_test()
   messages = messages.concat(scenarioFactory.directReply(10));
   gCopySource = localAccountUtils.rootFolder.createLocalSubfolder("copySource");
   addMessagesToFolder(messages, gCopySource);
 
   mailTestUtils.updateFolderAndNotify(gCopySource, doTest);
   return true;
 }
 
-function doTest()
-{
+function doTest() {
   var test = gCurTestNum;
-  if (test <= gTestArray.length)
-  {
-    var testFn = gTestArray[test-1];
+  if (test <= gTestArray.length) {
+    var testFn = gTestArray[test - 1];
     dump("Doing test " + test + " " + testFn.name + "\n");
 
     try {
       testFn();
-    } catch(ex) {
-      do_throw ('TEST FAILED ' + ex);
+    } catch (ex) {
+      do_throw("TEST FAILED " + ex);
     }
+  } else {
+    endTest();
   }
-  else
-    endTest();
 }
 
-function endTest()
-{
+function endTest() {
   // Cleanup, null out everything
   dump(" Exiting mail tests\n");
   gMsgEnumerator = null;
   do_test_finished(); // for the one in run_test()
 }
 
 // nsIMsgCopyServiceListener implementation
-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) {
     // Check: message successfully copied.
     Assert.equal(aStatus, 0);
     ++gCurTestNum;
     doTest();
-  }
+  },
 };
 
--- a/mailnews/base/test/unit/test_copyThenMoveManual.js
+++ b/mailnews/base/test/unit/test_copyThenMoveManual.js
@@ -1,27 +1,27 @@
 /*
  * This file tests copy followed by a move in a single filter.
  * Tests fix from bug 448337.
  *
  * Original author: Kent James <kent@caspia.com>
  */
 
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 const {PromiseTestUtils} = ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
 var gFiles = ["../../../data/bugmail1"];
 var gCopyFolder;
 var gMoveFolder;
 var gFilter; // the test filter
 var gFilterList;
-var gTestArray =
-[
+var gTestArray = [
   function createFilters() {
     // setup manual copy then move mail filters on the inbox
     gFilterList = localAccountUtils.incomingServer.getFilterList(null);
     gFilter = gFilterList.createFilter("copyThenMoveAll");
     let searchTerm = gFilter.createTerm();
     searchTerm.matchAll = true;
     gFilter.appendTerm(searchTerm);
     let copyAction = gFilter.createAction();
@@ -85,33 +85,30 @@ var gTestArray =
     // operation was a move
     Assert.equal(folderCount(localAccountUtils.inboxFolder), 0);
   },
   function endTest() {
     // Cleanup, null out everything, close all cached connections and stop the
     // server
     dump(" Exiting mail tests\n");
     gPOP3Pump = null;
-  }
+  },
 ];
 
-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 run_test()
-{
+function run_test() {
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
 
   gCopyFolder = localAccountUtils.rootFolder.createLocalSubfolder("CopyFolder");
   gMoveFolder = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder");
 
   gTestArray.forEach(x => add_task(x));
 
--- a/mailnews/base/test/unit/test_copyToInvalidDB.js
+++ b/mailnews/base/test/unit/test_copyToInvalidDB.js
@@ -1,25 +1,28 @@
 /*
  * Simple tests for copying local messages to a folder whose db is missing
  * or invalid
  */
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
+/* import-globals-from ../../../test/resources/messageModifier.js */
+/* import-globals-from ../../../test/resources/messageInjection.js */
 load("../../../resources/messageGenerator.js");
 load("../../../resources/messageModifier.js");
 load("../../../resources/messageInjection.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var gMsg1;
-var gMessages = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-var gCurTestNum;
 var gMsgId1;
 
 var gTestFolder, gTestFolder2;
 
 function* setup_globals(aNextFunc) {
   var messageGenerator = new MessageGenerator();
   gMsg1 = messageGenerator.makeMessage();
   let msg2 = messageGenerator.makeMessage({inReplyTo: gMsg1});
--- a/mailnews/base/test/unit/test_detachToFile.js
+++ b/mailnews/base/test/unit/test_detachToFile.js
@@ -1,68 +1,66 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Tests nsIMessenger's detachAttachmentsWOPrompts
  */
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 
 // javascript mime emitter functions
 var mimeMsg = {};
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource:///modules/gloda/mimemsg.js", mimeMsg);
 
 var tests = [
   startCopy,
   startMime,
   startDetach,
   testDetach,
-]
+];
 
-function* startCopy()
-{
+function* startCopy() {
   // Get a message into the local filestore.
   var mailFile = do_get_file("../../../data/external-attach-test");
   MailServices.copy.CopyFileMessage(mailFile, localAccountUtils.inboxFolder, null,
                                     false, 0, "", asyncCopyListener, null);
   yield false;
 }
 
 // process the message through mime
-function* startMime()
-{
+function* startMime() {
   let msgHdr = mailTestUtils.firstMsgHdr(localAccountUtils.inboxFolder);
 
   mimeMsg.MsgHdrToMimeMessage(msgHdr, gCallbackObject, gCallbackObject.callback,
                               true /* allowDownload */);
   yield false;
 }
 
 // detach any found attachments
-function* startDetach()
-{
+function* startDetach() {
   let msgHdr = mailTestUtils.firstMsgHdr(localAccountUtils.inboxFolder);
   let msgURI = msgHdr.folder.generateMessageURI(msgHdr.messageKey);
 
   let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
   let attachment = gCallbackObject.attachments[0];
 
   messenger.detachAttachmentsWOPrompts(do_get_profile(), 1,
                                        [attachment.contentType], [attachment.url],
                                        [attachment.name], [msgURI], asyncUrlListener);
   yield false;
 }
 
 // test that the detachment was successful
-function* testDetach()
-{
+function* testDetach() {
   // This test seems to fail on Linux without the following delay.
   do_timeout(200, async_driver);
   yield false;
   // The message contained a file "check.pdf" which should
   //  now exist in the profile directory.
   let checkFile = do_get_profile().clone();
   checkFile.append("check.pdf");
   Assert.ok(checkFile.exists());
@@ -80,22 +78,21 @@ function* testDetach()
 function SaveAttachmentCallback() {
   this.attachments = null;
 }
 
 SaveAttachmentCallback.prototype = {
   callback: function saveAttachmentCallback_callback(aMsgHdr, aMimeMessage) {
     this.attachments = aMimeMessage.allAttachments;
     async_driver();
-  }
-}
+  },
+};
 var gCallbackObject = new SaveAttachmentCallback();
 
-function run_test()
-{
+function run_test() {
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
   async_run_tests(tests);
 }
 
 /*
  * Get the full message content.
  *
--- a/mailnews/base/test/unit/test_emptyTrash.js
+++ b/mailnews/base/test/unit/test_emptyTrash.js
@@ -16,158 +16,143 @@
   */
 
 // Globals
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var gMsgFile1;
 var gLocalTrashFolder;
 var gCurTestNum;
-var gMsgHdrs = new Array();
+var gMsgHdrs = [];
 var gRootFolder;
 
 var nsIMFNService = Ci.nsIMsgFolderNotificationService;
-var nsIMFListener = Ci.nsIMsgFolderListener;
 
 // nsIMsgCopyServiceListener implementation
-var copyListener =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey)
-  {
+var copyListener = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) {
     let hdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);
-    gMsgHdrs.push({hdr: hdr, ID: hdr.messageId});
+    gMsgHdrs.push({hdr, ID: hdr.messageId});
   },
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus)
-  {
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) {
     // 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); });
+  },
 };
 
-var urlListener =
-{
-  OnStartRunningUrl: function (aUrl) {
+var urlListener = {
+  OnStartRunningUrl(aUrl) {
   },
-  OnStopRunningUrl: function (aUrl, aExitCode) {
+  OnStopRunningUrl(aUrl, aExitCode) {
     // Check: message successfully copied.
     Assert.equal(aExitCode, 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); });
+  },
 };
 
-function copyFileMessage(file, destFolder, isDraftOrTemplate)
-{
+function copyFileMessage(file, destFolder, isDraftOrTemplate) {
   MailServices.copy.CopyFileMessage(file, destFolder, null, isDraftOrTemplate, 0, "", copyListener, null);
 }
 
-function deleteMessages(srcFolder, items)
-{
+function deleteMessages(srcFolder, items) {
   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-  items.forEach(function (item) {
+  items.forEach(function(item) {
     array.appendElement(item);
   });
 
   srcFolder.deleteMessages(array, null, false, true, copyListener, true);
 }
 
 /*
  * TESTS
  */
 
 // Beware before commenting out a test -- later tests might just depend on earlier ones
-var gTestArray =
-[
+var gTestArray = [
   // Copying message from file
   function testCopyFileMessage1() {
     copyFileMessage(gMsgFile1, localAccountUtils.inboxFolder, false);
   },
 
   // Delete message
   function testDeleteMessage() { // delete to trash
     // Let's take a moment to re-initialize stuff that got moved
     let inboxDB = localAccountUtils.inboxFolder.msgDatabase;
     gMsgHdrs[0].hdr = inboxDB.getMsgHdrForMessageID(gMsgHdrs[0].ID);
 
     // Now delete the message
     deleteMessages(localAccountUtils.inboxFolder, [gMsgHdrs[0].hdr], false, false);
   },
-  function emptyTrash()
-  {
+  function emptyTrash() {
     gRootFolder = localAccountUtils.incomingServer.rootMsgFolder;
     gLocalTrashFolder = gRootFolder.getChildNamed("Trash");
     // hold onto a db to make sure that empty trash deals with the case
     // of someone holding onto the db, but the trash folder has a null db.
-    let gLocalTrashDB = gLocalTrashFolder.msgDatabase;
+    let gLocalTrashDB = gLocalTrashFolder.msgDatabase; // eslint-disable-line no-unused-vars
     gLocalTrashFolder.msgDatabase = null;
     // this is synchronous
     gLocalTrashFolder.emptyTrash(null, null);
     // check that the trash folder is 0 size, that the db has a 0 message count
     // and has no messages.
     Assert.equal(0, gLocalTrashFolder.filePath.fileSize);
     Assert.equal(0, gLocalTrashFolder.msgDatabase.dBFolderInfo.numMessages);
     let enumerator = gLocalTrashFolder.msgDatabase.EnumerateMessages();
     Assert.equal(false, enumerator.hasMoreElements());
     urlListener.OnStopRunningUrl(null, 0);
-  }
+  },
 ];
 
 // Our listener, which captures events.
 function gMFListener() {}
-gMFListener.prototype =
-{
-  folderDeleted: function (aFolder)
-  {
+gMFListener.prototype = {
+  folderDeleted(aFolder) {
     aFolder.msgDatabase = null;
   },
 };
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
   // Load up a message so that we can copy it in later.
   gMsgFile1 = do_get_file("../../../data/bugmail10");
   // our front end code clears the msg db when it gets told the folder for
   // an open view has been deleted - so simulate that.
   var folderDeletedListener = new gMFListener();
   MailServices.mfn.addListener(folderDeletedListener, nsIMFNService.folderDeleted);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of all the operations.
   do_test_pending();
 
   // Do the test.
   doTest(1);
 }
 
-function doTest(test)
-{
-  if (test <= gTestArray.length)
-  {
+function doTest(test) {
+  if (test <= gTestArray.length) {
     gCurTestNum = test;
 
-    var testFn = gTestArray[test-1];
+    var testFn = gTestArray[test - 1];
     // Set a limit of three seconds; if the notifications haven't arrived by then there's a problem.
-    do_timeout(10000, function(){
-        if (gCurTestNum == test)
-          do_throw("Notifications not received in 10000 ms for operation " + testFn.name);
-        }
-      );
+    do_timeout(10000, function() {
+      if (gCurTestNum == test)
+        do_throw("Notifications not received in 10000 ms for operation " + testFn.name);
+    });
     try {
-    testFn();
-    } catch(ex) {dump(ex);}
-  }
-  else
-  {
+      testFn();
+    } catch (ex) {
+      dump(ex);
+    }
+  } else {
     gMsgHdrs = null;
     do_test_finished(); // for the one in run_test()
   }
 }
--- a/mailnews/base/test/unit/test_fix_deferred_accounts.js
+++ b/mailnews/base/test/unit/test_fix_deferred_accounts.js
@@ -3,18 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * This tests that we cleanup the account prefs when a pop3 account has
  * been deferred to a hidden account.
  */
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-function run_test()
-{
+function run_test() {
   // Create account prefs with a pop3 account deferred to a hidden account.
 
   Services.prefs.setCharPref("mail.account.account1.identities", "id1");
   Services.prefs.setCharPref("mail.account.account1.server", "server1");
   Services.prefs.setCharPref("mail.account.account2.server", "server2");
   Services.prefs.setCharPref("mail.account.account4.identities", "id2");
   Services.prefs.setCharPref("mail.account.account4.server", "server4");
   Services.prefs.setCharPref("mail.account.account5.identities", "id3");
--- a/mailnews/base/test/unit/test_folderCompact.js
+++ b/mailnews/base/test/unit/test_folderCompact.js
@@ -18,146 +18,129 @@
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 const {PromiseTestUtils} = ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/berkeleystore;1");
 
 // Globals
 var gMsgFile1, gMsgFile2, gMsgFile3;
-var gMsg1ID = "200806061706.m56H6RWT004933@mrapp54.mozilla.org";
 var gMsg2ID = "200804111417.m3BEHTk4030129@mrapp51.mozilla.org";
 var gMsg3ID = "4849BF7B.2030800@example.com";
 var gLocalFolder2;
 var gLocalFolder3;
-var gLocalTrashFolder;
-var gCurTestNum;
 // After a compact (or other operation), this is what we expect the
 // folder size to be.
 var gExpectedFolderSize;
-var gMsgHdrs = new Array();
+var gMsgHdrs = [];
 var gExpectedInboxSize;
 var gExpectedFolder2Size;
 var gExpectedFolder3Size;
 var gMsgLinebreak = "";
 
 // Transfer message keys between function calls.
 var gMsgKeys = [];
 
 // nsIMsgCopyServiceListener implementation
-var copyListenerWrap =
-{
-  SetMessageKey: function(aKey)
-  {
+var copyListenerWrap = {
+  SetMessageKey(aKey) {
     let hdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);
-    gMsgHdrs.push({hdr: hdr, ID: hdr.messageId});
+    gMsgHdrs.push({hdr, ID: hdr.messageId});
   },
-  OnStopCopy: function(aStatus)
-  {
+  OnStopCopy(aStatus) {
     // Check: message successfully copied.
     Assert.equal(aStatus, 0);
-  }
+  },
 };
 
-var urlListenerWrap =
-{
-  OnStopRunningUrl: function (aUrl, aExitCode) {
+var urlListenerWrap = {
+  OnStopRunningUrl(aUrl, aExitCode) {
     // Check: message successfully copied.
     Assert.equal(aExitCode, 0);
 
     if (gMsgKeys.length > 0) {
       // Bug 854798: Check if the new message keys are the same as before compaction.
       let folderMsgs = gMsgKeys.folder.messages;
       // First message was deleted so skip it in the old array.
       for (let i = 1; i < gMsgKeys.length; i++) {
         Assert.ok(folderMsgs.hasMoreElements());
         let header = folderMsgs.getNext().QueryInterface(Ci.nsIMsgDBHdr);
         Assert.equal(header.messageKey, gMsgKeys[i]);
       }
       Assert.ok(!folderMsgs.hasMoreElements());
       gMsgKeys.length = 0;
     }
-  }
+  },
 };
 
-function copyFileMessage(file, destFolder, isDraftOrTemplate)
-{
+function copyFileMessage(file, destFolder, isDraftOrTemplate) {
   let listener = new PromiseTestUtils.PromiseCopyListener(copyListenerWrap);
   MailServices.copy.CopyFileMessage(file, destFolder, null, isDraftOrTemplate, 0, "", listener, null);
   return listener.promise;
 }
 
-function copyMessages(items, isMove, srcFolder, destFolder)
-{
+function copyMessages(items, isMove, srcFolder, destFolder) {
   let listener = new PromiseTestUtils.PromiseCopyListener(copyListenerWrap);
   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-  items.forEach(function (item) {
+  items.forEach(function(item) {
     array.appendElement(item);
   });
   MailServices.copy.CopyMessages(srcFolder, array, destFolder, isMove, listener, null, true);
   return listener.promise;
 }
 
-function deleteMessages(srcFolder, items)
-{
+function deleteMessages(srcFolder, items) {
   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-  items.forEach(function (item) {
+  items.forEach(function(item) {
     array.appendElement(item);
   });
 
   let listener = new PromiseTestUtils.PromiseCopyListener(copyListenerWrap);
   srcFolder.deleteMessages(array, null, false, true, listener, true);
   return listener.promise;
 }
 
-function calculateFolderSize(folder)
-{
+function calculateFolderSize(folder) {
   let msgDB = folder.msgDatabase;
   let enumerator = msgDB.EnumerateMessages();
   let totalSize = 0;
-  if (enumerator)
-  {
+  if (enumerator) {
     if (gMsgLinebreak == "") {
       // Figure out what the linebreak sequence is on the platform running the tests.
       gMsgLinebreak = "@mozilla.org/windows-registry-key;1" in Cc ? "\r\n" : "\n";
     }
-    while (enumerator.hasMoreElements())
-    {
+    while (enumerator.hasMoreElements()) {
       var header = enumerator.getNext();
       if (header instanceof Ci.nsIMsgDBHdr)
         totalSize += header.messageSize + gMsgLinebreak.length;
     }
   }
   return totalSize;
 }
 
-function verifyMsgOffsets(folder)
-{
+function verifyMsgOffsets(folder) {
   let msgDB = folder.msgDatabase;
   let enumerator = msgDB.EnumerateMessages();
-  if (enumerator)
-  {
-    while (enumerator.hasMoreElements())
-    {
+  if (enumerator) {
+    while (enumerator.hasMoreElements()) {
       let header = enumerator.getNext();
       if (header instanceof Ci.nsIMsgDBHdr) {
         let storeToken = header.getStringProperty("storeToken");
         Assert.equal(storeToken, header.messageOffset);
       }
     }
   }
 }
 
 /*
  * TESTS
  */
 
 // Beware before commenting out a test -- later tests might just depend on earlier ones
-var gTestArray =
-[
+var gTestArray = [
   // Copying messages from files
   async function testCopyFileMessage1() {
     await copyFileMessage(gMsgFile1, localAccountUtils.inboxFolder, false);
   },
   async function testCopyFileMessage2() {
     await copyFileMessage(gMsgFile2, localAccountUtils.inboxFolder, false);
   },
   async function testCopyFileMessage3() {
@@ -194,18 +177,17 @@ var gTestArray =
       gMsgKeys.push(header.messageKey);
     }
 
     // Now delete the message
     await deleteMessages(gLocalFolder3, [gMsgHdrs[0].hdr], false, false);
 
     showMessages(gLocalFolder3, "after deleting 1 message to trash");
   },
-  async function compactFolder()
-  {
+  async function compactFolder() {
     gExpectedFolderSize = calculateFolderSize(gLocalFolder3);
     Assert.notEqual(gLocalFolder3.expungedBytes, 0);
     let listener = new PromiseTestUtils.PromiseUrlListener(urlListenerWrap);
     gLocalFolder3.compact(listener, null);
     await listener.promise;
 
     showMessages(gLocalFolder3, "after compact");
   },
@@ -223,29 +205,28 @@ var gTestArray =
       gMsgKeys.push(header.messageKey);
     }
 
     // Now delete the message
     await deleteMessages(gLocalFolder2, [gMsgHdrs[0].hdr], false, false);
 
     showMessages(gLocalFolder2, "after deleting 1 message");
   },
-  async function compactAllFolders()
-  {
+  async function compactAllFolders() {
     gExpectedInboxSize = calculateFolderSize(localAccountUtils.inboxFolder);
     gExpectedFolder2Size = calculateFolderSize(gLocalFolder2);
     gExpectedFolder3Size = calculateFolderSize(gLocalFolder3);
 
     // Save the first message key, which will change after compact with
     // rebuild.
     let f2m2Key =
       gLocalFolder2.msgDatabase.getMsgHdrForMessageID(gMsg2ID).messageKey;
 
     // force expunged bytes count to get cached.
-    let localFolder2ExpungedBytes = gLocalFolder2.expungedBytes;
+    gLocalFolder2.expungedBytes;
     // mark localFolder2 as having an invalid db, and remove it
     // for good measure.
     gLocalFolder2.msgDatabase.summaryValid = false;
     gLocalFolder2.msgDatabase = null;
     gLocalFolder2.ForceDBClosed();
     let dbPath = gLocalFolder2.filePath;
     dbPath.leafName = dbPath.leafName + ".msf";
     dbPath.remove(false);
@@ -258,20 +239,20 @@ var gTestArray =
                                            .messageKey;
 
     // We used to check here that the keys did not change during rebuild.
     // But that is no true in general, it was only conicidental since the
     // checked folder had never been compacted, so the key equaled the offset.
     // We do not in guarantee that, indeed after rebuild we expect the keys
     // to change.
     let checkResult = {
-      OnStopRunningUrl: function (aUrl, aExitCode) {
-      // Check: message successfully compacted.
-      Assert.equal(aExitCode, 0);
-      }
+      OnStopRunningUrl(aUrl, aExitCode) {
+        // Check: message successfully compacted.
+        Assert.equal(aExitCode, 0);
+      },
     };
     let listener = new PromiseTestUtils.PromiseUrlListener(checkResult);
     localAccountUtils.inboxFolder.compactAll(listener, null, true);
     await listener.promise;
 
     showMessages(localAccountUtils.inboxFolder, "after compactAll");
     showMessages(gLocalFolder2, "after compactAll");
 
@@ -285,49 +266,45 @@ var gTestArray =
     let message2 = gLocalFolder2.msgDatabase.getMsgHdrForMessageID(gMsg2ID);
     Assert.ok(message2);
     Assert.ok(gLocalFolder2.msgDatabase.getMsgHdrForMessageID(gMsg3ID));
 
     // In folder2, gMsg2ID is the first message. After compact with database
     // rebuild, that key has now changed.
     Assert.notEqual(message2.messageKey, f2m2Key);
   },
-  function lastTestCheck()
-  {
+  function lastTestCheck() {
     Assert.equal(gExpectedInboxSize, localAccountUtils.inboxFolder.filePath.fileSize);
     Assert.equal(gExpectedFolder2Size, gLocalFolder2.filePath.fileSize);
     Assert.equal(gExpectedFolder3Size, gLocalFolder3.filePath.fileSize);
     verifyMsgOffsets(gLocalFolder2);
     verifyMsgOffsets(gLocalFolder3);
     verifyMsgOffsets(localAccountUtils.inboxFolder);
-  }
+  },
 ];
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
   // Load up some messages so that we can copy them in later.
   gMsgFile1 = do_get_file("../../../data/bugmail10");
   gMsgFile2 = do_get_file("../../../data/bugmail11");
   gMsgFile3 = do_get_file("../../../data/draft1");
 
   // Create another folder to move and copy messages around, and force initialization.
   gLocalFolder2 = localAccountUtils.rootFolder.createLocalSubfolder("folder2");
-  let folderName = gLocalFolder2.prettyName;
+
   // Create a third folder for more testing.
   gLocalFolder3 = localAccountUtils.rootFolder.createLocalSubfolder("folder3");
-  folderName = gLocalFolder3.prettyName;
 
   gTestArray.forEach(x => add_task(x));
   run_next_test();
 }
 
 // debug utility to show the key/offset/ID relationship of messages in a folder
-function showMessages(folder, text)
-{
+function showMessages(folder, text) {
   dump("Show messages for folder <" + folder.name + "> " + text + "\n");
   let folderMsgs = folder.messages;
   while (folderMsgs.hasMoreElements()) {
     let header = folderMsgs.getNext().QueryInterface(Ci.nsIMsgDBHdr);
     dump("key: " + header.messageKey +
           " offset: " + header.messageOffset +
           " ID: " + header.messageId +
           "\n");
--- a/mailnews/base/test/unit/test_folderLookupService.js
+++ b/mailnews/base/test/unit/test_folderLookupService.js
@@ -1,17 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * This tests that nsIFolderLookupService works according to specification.
  */
-var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-
 var kRootURI = "mailbox://nobody@Local%20Folders";
 
 function run_test() {
   let fls = Cc["@mozilla.org/mail/folder-lookup;1"]
               .getService(Ci.nsIFolderLookupService);
 
   // Make sure that the local mail account exists.
   localAccountUtils.loadLocalMailAccount();
--- a/mailnews/base/test/unit/test_formatFileSize.js
+++ b/mailnews/base/test/unit/test_formatFileSize.js
@@ -1,27 +1,29 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Tests for the formatFileSize method.
  */
 
-load("../../../../mailnews/resources/logHelper.js");
-load("../../../../mailnews/resources/asyncTestUtils.js");
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+load("../../../resources/logHelper.js");
+load("../../../resources/asyncTestUtils.js");
 
 var gStringBundle = Services.strings.createBundle(
   "chrome://messenger/locale/messenger.properties");
 
 var gMessenger = Cc["@mozilla.org/messenger;1"]
                    .createInstance(Ci.nsIMessenger);
 
 function isDigit(c) {
-  return "0123456789".indexOf(c) != -1;
+  return "0123456789".includes(c);
 }
 
 function test_formatFileSize(aArgs) {
   const strings = {  b: "byteAbbreviation2",
                     kb: "kiloByteAbbreviation2",
                     mb: "megaByteAbbreviation2",
                     gb: "gigaByteAbbreviation2" };
 
@@ -37,39 +39,39 @@ function test_formatFileSize(aArgs) {
     actual = actual.substring(0, separatorPos) + "." + actual.substr(separatorPos + 1);
 
   Assert.equal(actual, expected);
 }
 
 /* ===== Driver ===== */
 
 var test_data = [
-  { bytes:                   0, useKB: false, mantissa:    "0", units:  "b" },
-  { bytes:                   1, useKB: false, mantissa:    "1", units:  "b" },
-  { bytes:                  10, useKB: false, mantissa:   "10", units:  "b" },
-  { bytes:                 999, useKB: false, mantissa:  "999", units:  "b" },
-  { bytes:                1000, useKB: false, mantissa:  "1.0", units: "kb" },
-  { bytes:                1024, useKB: false, mantissa:  "1.0", units: "kb" },
-  { bytes:             10*1024, useKB: false, mantissa: "10.0", units: "kb" },
-  { bytes:            999*1024, useKB: false, mantissa:  "999", units: "kb" },
-  { bytes:           1000*1024, useKB: false, mantissa:  "1.0", units: "mb" },
-  { bytes:           1024*1024, useKB: false, mantissa:  "1.0", units: "mb" },
-  { bytes:        10*1024*1024, useKB: false, mantissa: "10.0", units: "mb" },
-  { bytes:       999*1024*1024, useKB: false, mantissa:  "999", units: "mb" },
-  { bytes:      1000*1024*1024, useKB: false, mantissa:  "1.0", units: "gb" },
-  { bytes:      1024*1024*1024, useKB: false, mantissa:  "1.0", units: "gb" },
-  { bytes:   10*1024*1024*1024, useKB: false, mantissa: "10.0", units: "gb" },
-  { bytes:  999*1024*1024*1024, useKB: false, mantissa:  "999", units: "gb" },
-  { bytes: 1000*1024*1024*1024, useKB: false, mantissa: "1000", units: "gb" },
+  { bytes:                         0, useKB: false, mantissa:    "0", units:  "b" },
+  { bytes:                         1, useKB: false, mantissa:    "1", units:  "b" },
+  { bytes:                        10, useKB: false, mantissa:   "10", units:  "b" },
+  { bytes:                       999, useKB: false, mantissa:  "999", units:  "b" },
+  { bytes:                      1000, useKB: false, mantissa:  "1.0", units: "kb" },
+  { bytes:                      1024, useKB: false, mantissa:  "1.0", units: "kb" },
+  { bytes:                 10 * 1024, useKB: false, mantissa: "10.0", units: "kb" },
+  { bytes:                999 * 1024, useKB: false, mantissa:  "999", units: "kb" },
+  { bytes:               1000 * 1024, useKB: false, mantissa:  "1.0", units: "mb" },
+  { bytes:               1024 * 1024, useKB: false, mantissa:  "1.0", units: "mb" },
+  { bytes:          10 * 1024 * 1024, useKB: false, mantissa: "10.0", units: "mb" },
+  { bytes:         999 * 1024 * 1024, useKB: false, mantissa:  "999", units: "mb" },
+  { bytes:        1000 * 1024 * 1024, useKB: false, mantissa:  "1.0", units: "gb" },
+  { bytes:        1024 * 1024 * 1024, useKB: false, mantissa:  "1.0", units: "gb" },
+  { bytes:   10 * 1024 * 1024 * 1024, useKB: false, mantissa: "10.0", units: "gb" },
+  { bytes:  999 * 1024 * 1024 * 1024, useKB: false, mantissa:  "999", units: "gb" },
+  { bytes: 1000 * 1024 * 1024 * 1024, useKB: false, mantissa: "1000", units: "gb" },
 
-  { bytes:                   0, useKB: true,  mantissa:    "0", units: "kb" },
-  { bytes:                   1, useKB: true,  mantissa:  "0.1", units: "kb" },
-  { bytes:                 500, useKB: true,  mantissa:  "0.5", units: "kb" },
-  { bytes:                 999, useKB: true,  mantissa:  "1.0", units: "kb" },
+  { bytes:                         0, useKB: true,  mantissa:    "0", units: "kb" },
+  { bytes:                         1, useKB: true,  mantissa:  "0.1", units: "kb" },
+  { bytes:                       500, useKB: true,  mantissa:  "0.5", units: "kb" },
+  { bytes:                       999, useKB: true,  mantissa:  "1.0", units: "kb" },
 ];
 
 var tests = [
-  parameterizeTest(test_formatFileSize, test_data)
+  parameterizeTest(test_formatFileSize, test_data),
 ];
 
 function run_test() {
   async_run_tests(tests);
 }
--- a/mailnews/base/test/unit/test_getMsgTextFromStream.js
+++ b/mailnews/base/test/unit/test_getMsgTextFromStream.js
@@ -9,26 +9,29 @@
 /**
  * Test suite for GetMsgTextFromStream.
  *
  * Currently tests: text/plain, text/html -- with tags stripped and without,
  * base64, multipart.
  * Does not currently test: quoted-printable, stripping quotes, UTF-8, small values of
  * bytesToRead.
  */
-var kDataRoot = "../../../data/"
+var kDataRoot = "../../../data/";
 
-function create(fileName, bytes, compressQuotes, stripHTML, outContentType)
-{
-  return {name: fileName, bytesToRead: bytes, compressQuotes: compressQuotes, stripHTML: stripHTML,
-          contentType: outContentType};
+function create(fileName, bytes, compressQuotes, stripHTML, outContentType) {
+  return {
+    name: fileName,
+    bytesToRead: bytes,
+    compressQuotes,
+    stripHTML,
+    contentType: outContentType,
+  };
 }
 
-var gTestFiles =
-[
+var gTestFiles = [
   create("basic1", 1024, false, false, "text/plain"), // Simple plain text
   create("basic1", 1024, false, true, "text/plain"), // should be same as above
   create("basic2", 1024, false, false, "text/html"), // Simple HTML
   create("basic3", 1024, false, true, "text/html"), // HTML with tags stripped out
   create("basic4", 1024, false, false, "text/plain"), // No content type, should be assumed to be text/plain
   create("basic4", 1024, false, true, "text/plain"),
   create("basic5", 1024, false, false, "text/plain"), // HTML content in text/plain
   create("basic5", 1024, false, true, "text/plain"),
@@ -44,26 +47,24 @@ var gTestFiles =
   create("multipart4", 1024, false, true, "text/plain"),
   create("multipart-base64-1", 1024, false, false, "text/plain"), // base64 encoded text
   create("multipart-base64-1", 1024, false, true, "text/plain"),
   create("multipart-base64-2", 1024, false, false, "text/html"),
   create("multipart-base64-3", 1024, false, true, "text/html"),
   create("multipart-complex1", 1024, false, true, "text/html"), // Things get more complex here
   create("multipart-complex2", 1024, false, false, "text/plain"),
   create("multipart-complex2", 1024, false, true, "text/plain"),
-]
+];
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
   var folder = localAccountUtils.incomingServer.rootMsgFolder;
 
-  gTestFiles.forEach(function (test)
-  {
-    dump("Testing "+test.name+"\n");
+  gTestFiles.forEach(function(test) {
+    dump("Testing " + test.name + "\n");
     var inFile = do_get_file(kDataRoot + test.name);
     var inStream = Cc["@mozilla.org/network/file-input-stream;1"]
                      .createInstance(Ci.nsIFileInputStream);
     inStream.init(inFile, -1, -1, Ci.nsIFileInputStream.CLOSE_ON_EOF);
 
     // Now get the message body using getMsgTextFromStream
     var contentType = {};
     var body = folder.getMsgTextFromStream(inStream, "", test.bytesToRead, 65536,
--- a/mailnews/base/test/unit/test_headerFoldingInDatabase.js
+++ b/mailnews/base/test/unit/test_headerFoldingInDatabase.js
@@ -6,39 +6,36 @@
  * Testing header folding in nsParseMailMessageState::ParseHeaders(),
  * see bug 1454257 and bug 1456001.
  */
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var hdr;
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
-  var copyListener =
-  {
-    OnStartCopy: function() {},
-    OnProgress: function(aProgress, aProgressMax) {},
-    SetMessageKey: function(aKey) {
+  var copyListener = {
+    OnStartCopy() {},
+    OnProgress(aProgress, aProgressMax) {},
+    SetMessageKey(aKey) {
       hdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);
     },
-    SetMessageId: function(aMessageId) {},
-    OnStopCopy: function(aStatus) { continueTest();}
+    SetMessageId(aMessageId) {},
+    OnStopCopy(aStatus) { continueTest(); },
   };
 
   // Get a message into the local filestore.
   var message = do_get_file("../../../data/badly-folded-headers.eml");
   do_test_pending();
   MailServices.copy.CopyFileMessage(message, localAccountUtils.inboxFolder, null, false, 0,
                                     "", copyListener, null);
 }
 
-function continueTest()
-{
+function continueTest() {
   Assert.equal(hdr.author, "sender@example.com");
   Assert.equal(hdr.recipients, "\"Recipient  with  spaces\" <recipient@example.com>");
   Assert.equal(hdr.subject, "Badly folded headers, one line with   space   between   To and From");
   hdr = null;
   do_test_finished();
 }
 
--- a/mailnews/base/test/unit/test_hostnameUtils.js
+++ b/mailnews/base/test/unit/test_hostnameUtils.js
@@ -93,17 +93,17 @@ function test_IPaddresses() {
     [ true, "0x7f.100.1000",                              false,    true,    true,   "127.100.3.232" ],
     [ true, "0xff.100.1024",                              false,    false,    true,   "255.100.4.0" ],
     [ true, "0xC0.0xA8.0x2A48",                           false,    true,    true,   "192.168.42.72" ],
     [ true, "0xC0.0xA82A48",                              false,    true,    true,   "192.168.42.72" ],
     [ true, "0xC0A82A48",                                 false,    true,    true,   "192.168.42.72" ],
     [ true, "0324.062477106",                             false,    false,    true,   "212.202.126.70" ],
 
     [ false, "0.0.1000",                                  false,    false,    true ],
-    [ false, "0324.06247710677",                          false,    false,    true ]
+    [ false, "0324.06247710677",                          false,    false,    true ],
   ];
 
   for (let item of kIPsToTest) {
     let result = null;
     let [isValid, address, isIPv6, isLocal, isExtended, wantedResult] = item;
     if (!wantedResult)
       wantedResult = isValid ? address : null;
 
@@ -168,17 +168,17 @@ function test_hostnames() {
     [ false, "server.badcompany-.invalid" ],
     [ false, "server.bad company.invalid" ],
     [ false, "server.b…dcompany.invalid" ],
     [ false, ".server.badcompany.invalid" ],
     [ false, "make-this-a-long-host-name-component-that-is-over-63-characters-long.invalid" ],
     [ false, "append-strings-to-make-this-a-too-long-host-name.that-is-really-over-255-characters-long.invalid." +
              "append-strings-to-make-this-a-too-long-host-name.that-is-really-over-255-characters-long.invalid." +
              "append-strings-to-make-this-a-too-long-host-name.that-is-really-over-255-characters-long.invalid." +
-             "append-strings-to-make-this-a-too-long-host-name.that-is-really-over-255-characters-long.invalid" ]
+             "append-strings-to-make-this-a-too-long-host-name.that-is-really-over-255-characters-long.invalid" ],
   ];
 
   for (let item of kHostsToTest) {
     let result = null;
     let [wantedResult, hostname] = item;
     wantedResult = wantedResult ? hostname : null;
 
     result = isLegalHostName(hostname);
--- a/mailnews/base/test/unit/test_imapPump.js
+++ b/mailnews/base/test/unit/test_imapPump.js
@@ -2,69 +2,55 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Simple demonstration of the imap pump test method.
  */
 
 // async support
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/alertTestUtils.js");
 const {PromiseTestUtils} = ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
 // IMAP pump
 var {
   IMAPPump,
   setupIMAPPump,
   teardownIMAPPump,
 } = ChromeUtils.import("resource://testing-common/mailnews/IMAPpump.js");
 var {
-  imapDaemon,
-  imapMailbox,
   imapMessage,
-  IMAP_RFC3501_handler,
-  configurations,
-  mixinExtension,
-  IMAP_GMAIL_extension,
-  IMAP_MOVE_extension,
-  IMAP_CUSTOM_extension,
-  IMAP_RFC2197_extension,
-  IMAP_RFC2342_extension,
-  IMAP_RFC3348_extension,
-  IMAP_RFC4315_extension,
-  IMAP_RFC5258_extension,
-  IMAP_RFC2195_extension,
 } = ChromeUtils.import("resource://testing-common/mailnews/imapd.js");
 
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var {fsDebugAll} = ChromeUtils.import("resource://testing-common/mailnews/maild.js");
 
 // Globals
 
 // Messages to load must have CRLF line endings, that is Windows style
 var gMessage = "bugmail10"; // message file used as the test message
 
 // Definition of tests
 
 // load and update a message in the imap fake server
 
-var gTestArray =
-[
+var gTestArray = [
   // initial setup of IMAP environment
   setupIMAPPump,
 
   // optionally set server parameters, here enabling debug messages
   function serverParms() {
     IMAPPump.server.setDebugLevel(fsDebugAll);
   },
 
   // the main test
-  async function loadImapMessage()
-  {
+  async function loadImapMessage() {
     IMAPPump.mailbox.addMessage(
       new imapMessage(specForFileName(gMessage),
                       IMAPPump.mailbox.uidnext++, []));
     let promiseUrlListener = new PromiseTestUtils.PromiseUrlListener();
     IMAPPump.inbox.updateFolderWithListener(gDummyMsgWindow, promiseUrlListener);
     await promiseUrlListener.promise;
 
     Assert.equal(1, IMAPPump.inbox.getTotalMessages(false));
--- a/mailnews/base/test/unit/test_inheritedFolderProperties.js
+++ b/mailnews/base/test/unit/test_inheritedFolderProperties.js
@@ -1,18 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Testing of inherited folder properties
  */
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
   var rootFolder = localAccountUtils.incomingServer.rootMsgFolder;
 
   // add subfolders to the inbox
   const subFolder11 = localAccountUtils.inboxFolder.createLocalSubfolder("subfolder11")
                          .QueryInterface(Ci.nsIMsgLocalMailFolder);
   const subFolder12 = localAccountUtils.inboxFolder.createLocalSubfolder("subfolder12")
                          .QueryInterface(Ci.nsIMsgLocalMailFolder);
@@ -99,10 +98,9 @@ function run_test()
   // clear the global value and the root value
   Services.prefs.clearUserPref(globalPref);
   localAccountUtils.incomingServer.setCharValue(propertyName, "");
   Assert.equal(rootFolder.getInheritedStringProperty(propertyName), null);
   Assert.equal(subFolder11.getInheritedStringProperty(propertyName), folderValue);
   Assert.equal(subFolder12.getInheritedStringProperty(propertyName), null);
   Assert.equal(subFolder21.getInheritedStringProperty(propertyName), folderValue2);
   Assert.equal(subFolder22.getInheritedStringProperty(propertyName), null);
-
 }
--- a/mailnews/base/test/unit/test_iteratorUtils.js
+++ b/mailnews/base/test/unit/test_iteratorUtils.js
@@ -6,17 +6,16 @@
  * Tests for iteratorUtils.jsm. Currently this tests:
  * - toArray
  * - toXPCOMArray
  * - fixIterator
  */
 
 var iteratorUtils = {};
 ChromeUtils.import("resource:///modules/iteratorUtils.jsm", iteratorUtils);
-Cu.importGlobalProperties(["DOMParser"]);
 
 var gDOMParser = new DOMParser();
 
 /**
  * Given the name of an XML file, returns the node representation of the file.
  */
 function parse_xml_file(aFileName) {
   let file = do_get_file(aFileName);
@@ -95,17 +94,17 @@ function test_fixIterator() {
     // A specific exception is the correct behaviour here.
     if (e.message == "An unsupported object sent to fixIterator: [object Object]")
       thrown = true;
   }
   Assert.ok(thrown);
 
   thrown = false;
   try {
-    let result = iteratorUtils.toXPCOMArray(tryIterate, Ci.nsIArray);
+    iteratorUtils.toXPCOMArray(tryIterate, Ci.nsIArray);
   } catch (e) {
     // A specific exception is the correct behaviour here.
     if (e.message == "An unsupported interface requested from toXPCOMArray: nsIArray")
       thrown = true;
   }
   Assert.ok(thrown);
 }
 
@@ -127,33 +126,33 @@ function test_toArray_NodeList() {
     Assert.equal(node, childArray[i]);
 }
 
 /**
  * Test that toArray works correctly with the build-in generator construct.
  */
 function test_toArray_builtin_generator() {
   let arr = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
-  let generator = function*() {
+  let generator = function* () {
     for (let elem of arr) {
       yield elem;
     }
-  }
+  };
   // The resulting array should be the same as 'arr'.
   let generatorArray = iteratorUtils.toArray(generator);
   Assert.equal(arr.length, generatorArray.length);
   for (let i in arr) {
     Assert.equal(arr[i], generatorArray[i]);
   }
 
   // Bug 1126509, test that toArray rejects unknown objects.
   let thrown = false;
   let tryIterate = { item: "An object, that is not supported by toArray." };
   try {
-    let result = iteratorUtils.toArray(tryIterate);
+    iteratorUtils.toArray(tryIterate);
   } catch (e) {
     // A specific exception is the correct behaviour here.
     if (e.message == "An unsupported object sent to toArray: [object Object]")
       thrown = true;
   }
   Assert.ok(thrown);
 }
 
--- a/mailnews/base/test/unit/test_jsTreeSelection.js
+++ b/mailnews/base/test/unit/test_jsTreeSelection.js
@@ -1,30 +1,29 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const {JSTreeSelection} = ChromeUtils.import("resource:///modules/jsTreeSelection.js");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var fakeView = {
   rowCount: 101,
-  selectionChanged: function() {
+  selectionChanged() {
   },
   QueryInterface: ChromeUtils.generateQI(
     [Ci.nsITreeView]),
 };
 
 var sel = new JSTreeSelection(null);
 sel.view = fakeView;
 
 function bad_ranges(aMsg, aExpected) {
   let s = "\x1b[1;31m!!! BAD RANGES: " + aMsg + "\n";
   s += "Selection ranges: " + sel._ranges.length + ":";
-  for (let [low,high] of sel._ranges) {
+  for (let [low, high] of sel._ranges) {
     s += " " + low + "-" + high;
   }
 
   s += "\nExpected ranges: " + aExpected.length + ":";
   for (let i = 0; i < aExpected.length; i++) {
     s += " " + aExpected[i][0] + "-" + aExpected[i][1];
   }
 
@@ -35,17 +34,17 @@ function bad_ranges(aMsg, aExpected) {
 }
 
 function assert_selection_ranges(...aArgs) {
   if (sel._ranges.length != aArgs.length)
     bad_ranges("Wrong number of ranges!", aArgs);
 
   let i = 0;
   let ourCount = 0;
-  for (let [slow,shigh] of sel._ranges) {
+  for (let [slow, shigh] of sel._ranges) {
     let [dlow, dhigh] = aArgs[i++];
     if (dlow != slow || dhigh != shigh)
       bad_ranges("Range mis-match on index " + i, aArgs);
     ourCount += shigh - slow + 1;
   }
 
   if (ourCount != sel.count)
     bad_ranges("Count was wrong! We counted " + ourCount + " but they say " +
@@ -80,24 +79,24 @@ function assert_not_selected(aIndex) {
 var ansel = assert_not_selected;
 
 function run_test() {
   // -- select
   sel.select(1);
   asel(1);
   ansel(0);
   ansel(2);
-  asr([1,1]);
+  asr([1, 1]);
   aci(1);
 
   sel.select(2);
   asel(2);
   ansel(1);
   ansel(3);
-  asr([2,2]);
+  asr([2, 2]);
   aci(2);
 
   // -- clearSelection
   sel.clearSelection();
   asr();
   aci(2); // should still be the same...
 
   // -- toggleSelect
--- a/mailnews/base/test/unit/test_junkWhitelisting.js
+++ b/mailnews/base/test/unit/test_junkWhitelisting.js
@@ -2,19 +2,21 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Testing of junk whitelisting
  */
 
 // add address book setup
+/* import-globals-from ../../../test/resources/abSetup.js */
 load("../../../resources/abSetup.js");
 
 // add fake POP3 server driver
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 /*
  * The address available in the test address book is "PrimaryEmail1@test.invalid"
  * Test emails may also include the address "invalid@example.com"
  *
@@ -25,59 +27,54 @@ var {MailServices} = ChromeUtils.import(
  *    1        3          I
  *
  */
 
 // indices into hdrs[] of email by domain
 var kDomainTest = 0;
 var kDomainExample = 1;
 
-var Files =
-[
+var Files = [
   "../../../data/bugmail1",
-  "../../../data/bugmail3"
-]
+  "../../../data/bugmail3",
+];
 
 var hdrs = [];
 
-function run_test()
-{
-
+function run_test() {
   // Test setup - copy the data file into place
   var testAB = do_get_file("../../../addrbook/test/unit/data/cardForEmail.mab");
 
   // Copy the file to the profile directory for a PAB (this is the personal address book)
   testAB.copyTo(do_get_profile(), kPABData.fileName);
 
   do_test_pending();
 
   // kick off copying
   gPOP3Pump.files = Files;
   gPOP3Pump.onDone = continueTest;
   gPOP3Pump.run();
 }
 
-function continueTest()
-{
+function continueTest() {
   // get the message headers
   let headerEnum = localAccountUtils.inboxFolder.messages;
   while (headerEnum.hasMoreElements())
     hdrs.push(headerEnum.getNext().QueryInterface(Ci.nsIMsgDBHdr));
 
   // check with spam properties set on the local server
   doChecks(localAccountUtils.incomingServer);
 
   // Free our globals
   hdrs = null;
   gPOP3Pump = null;
   do_test_finished();
 }
 
-function doChecks(server)
-{
+function doChecks(server) {
   let spamSettings = server.spamSettings;
 
   // default is to use the whitelist
   Assert.ok(spamSettings.useWhiteList);
 
   // check email with the address PrimaryEmail1@test.invalid
   Assert.ok(spamSettings.checkWhiteList(hdrs[kDomainTest]));
 
--- a/mailnews/base/test/unit/test_junkingWhenDisabled.js
+++ b/mailnews/base/test/unit/test_junkingWhenDisabled.js
@@ -1,75 +1,68 @@
 /*
  * Test that junk actions work even when the bayes filtering of incoming
  *  messages is disabled, as fixed in bug 487610. Test developed by Kent
  *  James using test_nsMsgDBView.js as a base.
  */
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
+/* import-globals-from ../../../test/resources/messageModifier.js */
+/* import-globals-from ../../../test/resources/messageInjection.js */
 load("../../../resources/messageGenerator.js");
 load("../../../resources/messageModifier.js");
 load("../../../resources/messageInjection.js");
 
 const {JSTreeSelection} = ChromeUtils.import("resource:///modules/jsTreeSelection.js");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var nsIMFNService = Ci.nsIMsgFolderNotificationService;
 
 // fake objects needed to get nsMsgDBView to operate on selected messages.
 // Warning: these are partial implementations. If someone adds additional
 // calls to these objects in nsMsgDBView and friends, it will also
 // be necessary to add fake versions of those calls here.
 
-var gFakeView = {
-  rowCount: 1,
-  selectionChanged: function() {
-  },
-  QueryInterface: ChromeUtils.generateQI([Ci.nsITreeView]),
-};
-
 var gFakeSelection = new JSTreeSelection(null);
 
 // Items used to add messages to the folder
 
 var gMessageGenerator = new MessageGenerator();
-var gScenarioFactory = new MessageScenarioFactory(gMessageGenerator);
 
 var gLocalInboxFolder;
 var gListener;
 
 function setup_globals(aNextFunc) {
   // build up a message
   let messages = [];
   let msg1 = gMessageGenerator.makeMessage();
   messages = messages.concat([msg1]);
   let msgSet = new SyntheticMessageSet(messages);
 
   return add_sets_to_folders(gLocalInboxFolder, [msgSet]);
 }
 
 var gCommandUpdater = {
-  updateCommandStatus : function()
-  {
+  updateCommandStatus() {
     // the back end is smart and is only telling us to update command status
     // when the # of items in the selection has actually changed.
   },
 
-  displayMessageChanged : function(aFolder, aSubject, aKeywords)
-  {
+  displayMessageChanged(aFolder, aSubject, aKeywords) {
   },
 
-  updateNextMessageAfterDelete : function()
-  {
+  updateNextMessageAfterDelete() {
   },
-  summarizeSelection : function() {return false;}
+  summarizeSelection() { return false; },
 };
 
 var gDBView;
 var gTreeView;
 
 var SortType = Ci.nsMsgViewSortType;
 var SortOrder = Ci.nsMsgViewSortOrder;
 var ViewFlags = Ci.nsMsgViewFlagsType;
@@ -96,53 +89,49 @@ var tests_for_all_views = [
   // In the proposed fix for bug 487610, the first call to junk messages
   //  only creates the junk folder, it does not actually successfully move
   //  messages. So we junk messages twice so we can really see a move. But
   //  if that gets fixed and the messages actually move on the first call,
   //  I want this test to succeed as well. So I don't actually count how
   //  many messages get moved, just that some do on the second move.
   junkMessages,
   addMessages,
-  junkMessages
+  junkMessages,
 ];
 
 function addMessages() {
   // add another message in case the first one moved
   let messages = [];
   let msg1 = gMessageGenerator.makeMessage();
   messages = messages.concat([msg1]);
   let msgSet = new SyntheticMessageSet(messages);
   return add_sets_to_folders(gLocalInboxFolder, [msgSet]);
 }
 
 function* junkMessages() {
-
   // select and junk all messages
   gDBView.doCommand(Ci.nsMsgViewCommandType.selectAll);
   gDBView.doCommand(Ci.nsMsgViewCommandType.junk);
   yield false;
 }
 
 // Our listener, which captures events and does the real tests.
 function gMFListener() {}
-gMFListener.prototype =
-{
+gMFListener.prototype = {
 
-  msgsMoveCopyCompleted: function (aMove, aSrcMsgs, aDestFolder, aDestMsgs)
-  {
+  msgsMoveCopyCompleted(aMove, aSrcMsgs, aDestFolder, aDestMsgs) {
     Assert.ok(aDestFolder.getFlag(Ci.nsMsgFolderFlags.Junk));
     // I tried to test this by counting messages in the folder, didn't work.
     //  Maybe all updates are not completed yet. Anyway I do it by just
     //  making sure there is something in the destination array.
     Assert.ok(aDestMsgs.length > 0);
     async_driver();
   },
 
-  folderAdded: function (aFolder)
-  {
+  folderAdded(aFolder) {
     // this should be a junk folder
     Assert.ok(aFolder.getFlag(Ci.nsMsgFolderFlags.Junk));
     async_driver();
   },
 
 };
 
 function run_test() {
--- a/mailnews/base/test/unit/test_loadVirtualFolders.js
+++ b/mailnews/base/test/unit/test_loadVirtualFolders.js
@@ -8,18 +8,17 @@
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 // As currently written, this test will only work with Berkeley store.
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/berkeleystore;1");
 
 // main test
 
-function run_test()
-{
+function run_test() {
   let vfdat = do_get_file("../../../data/test_virtualFolders.dat");
 
   vfdat.copyTo(do_get_profile(), "virtualFolders.dat");
   localAccountUtils.loadLocalMailAccount();
   let localMailDir = do_get_profile().clone();
   localMailDir.append("Mail");
   localMailDir.append("Local Folders");
   localMailDir.append("unread-local");
--- a/mailnews/base/test/unit/test_mailstoreConverter.js
+++ b/mailnews/base/test/unit/test_mailstoreConverter.js
@@ -1,19 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-var {FileUtils} = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
 const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm");
-var {PromiseTestUtils} = ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
-var {convertMailStoreTo, terminateWorkers} = ChromeUtils.import("resource:///modules/mailstoreConverter.jsm");
-const {Log} = ChromeUtils.import("resource://gre/modules/Log.jsm");
+var {convertMailStoreTo} = ChromeUtils.import("resource:///modules/mailstoreConverter.jsm");
 
-var log = Log.repository.getLogger("MailStoreConverter");
 Services.prefs.setCharPref("mail.serverDefaultStoreContractID",
                            "@mozilla.org/msgstore/berkeleystore;1");
 
 // Test data for round-trip test.
 let testEmails = [
   // Base64 encoded bodies.
   "../../../data/01-plaintext.eml",
   "../../../data/02-plaintext+attachment.eml",
@@ -169,33 +165,16 @@ async function tempDir(prefix) {
       if (!(e instanceof OS.File.Error && e.becauseExists)) {
         throw e;
       }
     }
   }
 }
 
 /**
- * Create a temporary (and empty) file. The caller is responsible for deleting it.
- *
- * @param {String} baseName - name to base the temp filename upon
- *                            (eg "...tmpdir/<baseName>-<randomhexdigits>")
- * @returns {String} full path of new file.
- */
-async function tempFile(baseName) {
-  if (!baseName) {
-    baseName = "tmp";
-  }
-  let tmpDir = OS.Constants.Path.tmpDir;
-  let u = await OS.File.openUnique(OS.Path.join(tmpDir, baseName));
-  u.file.close();
-  return u.path;
-}
-
-/**
  * Test that messages survive unscathed in a roundtrip conversion,
  * maildir -> mbox -> maildir.
  * The final mailbox should have an identical set of files to the initial one,
  * albeit with different filenames.
  * Purely filesystem based.
  *
  * Would be nice to do a mbox->maildir->mbox roundtrip too, but that'd involve
  * parsing the mbox files to compare them (can't just compare mbox files because
--- a/mailnews/base/test/unit/test_mimemaltdetach.js
+++ b/mailnews/base/test/unit/test_mimemaltdetach.js
@@ -2,68 +2,66 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Tests nsIMessenger's detachAttachmentsWOPrompts of Mime multi-part
  * alternative messages.
  */
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 
 // javascript mime emitter functions
 var mimeMsg = {};
 ChromeUtils.import("resource:///modules/gloda/mimemsg.js", mimeMsg);
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var tests = [
   startCopy,
   startMime,
   startDetach,
   testDetach,
-]
+];
 
-function* startCopy()
-{
+function* startCopy() {
   // Get a message into the local filestore.
   let mailFile = do_get_file("../../../data/multipartmalt-detach");
   MailServices.copy.CopyFileMessage(mailFile, localAccountUtils.inboxFolder, null,
                                     false, 0, "", asyncCopyListener, null);
   yield false;
 }
 
 // process the message through mime
-function* startMime()
-{
+function* startMime() {
   let msgHdr = mailTestUtils.firstMsgHdr(localAccountUtils.inboxFolder);
 
   mimeMsg.MsgHdrToMimeMessage(msgHdr, gCallbackObject, gCallbackObject.callback,
                               true /* allowDownload */);
   yield false;
 }
 
 // detach any found attachments
-function* startDetach()
-{
+function* startDetach() {
   let msgHdr = mailTestUtils.firstMsgHdr(localAccountUtils.inboxFolder);
   let msgURI = msgHdr.folder.generateMessageURI(msgHdr.messageKey);
 
   let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
   let attachment = gCallbackObject.attachments[0];
 
   messenger.detachAttachmentsWOPrompts(do_get_profile(), 1,
                                        [attachment.contentType], [attachment.url],
                                        [attachment.name], [msgURI], asyncUrlListener);
   yield false;
 }
 
 // test that the detachment was successful
-function* testDetach()
-{
+function* testDetach() {
   // This test seems to fail on Linux without the following delay.
   do_timeout(200, async_driver);
   yield false;
   // The message contained a file "head_update.txt" which should
   //  now exist in the profile directory.
   let checkFile = do_get_profile().clone();
   checkFile.append("head_update.txt");
   Assert.ok(checkFile.exists());
@@ -84,22 +82,21 @@ function* testDetach()
 function SaveAttachmentCallback() {
   this.attachments = null;
 }
 
 SaveAttachmentCallback.prototype = {
   callback: function saveAttachmentCallback_callback(aMsgHdr, aMimeMessage) {
     this.attachments = aMimeMessage.allAttachments;
     async_driver();
-  }
-}
+  },
+};
 var gCallbackObject = new SaveAttachmentCallback();
 
-function run_test()
-{
+function run_test() {
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
   async_run_tests(tests);
 }
 
 /*
  * Get the full message content.
  *
--- a/mailnews/base/test/unit/test_newMailNotification.js
+++ b/mailnews/base/test/unit/test_newMailNotification.js
@@ -65,51 +65,47 @@ add_test(function testMultiListeners() {
 });
 
 var countInboxesPref = "mail.notification.count.inbox_only";
 
 /* Make sure we get a notification call when the unread count changes on an Inbox */
 add_test(function testNotifyInbox() {
   let notified = false;
   let mockListener = {
-    onCountChanged: function TNU_onCountChanged(count) {notified = true;}
+    onCountChanged: function TNU_onCountChanged(count) { notified = true; },
   };
   let folder = {
     URI: "Test Inbox",
-    flags: Ci.nsMsgFolderFlags.Mail | Ci.nsMsgFolderFlags.Inbox
+    flags: Ci.nsMsgFolderFlags.Mail | Ci.nsMsgFolderFlags.Inbox,
   };
 
   let notif = MailServices.newMailNotification.wrappedJSObject;
   notif.addListener(mockListener, iNMNS.count);
 
   notif.OnItemIntPropertyChanged(folder, "TotalUnreadMessages", 0, 2);
   Assert.ok(notified);
 
   // Special folders should never count
   let special = {
     URI: "Test Special",
-    flags: Ci.nsMsgFolderFlags.Mail | Ci.nsMsgFolderFlags.Junk
+    flags: Ci.nsMsgFolderFlags.Mail | Ci.nsMsgFolderFlags.Junk,
   };
   notified = false;
   notif.OnItemIntPropertyChanged(special, "TotalUnreadMessages", 0, 2);
   Assert.ok(!notified);
 
   // by default, non-inbox should not count
   let nonInbox = {
     URI: "Test Non-Inbox",
-    flags: Ci.nsMsgFolderFlags.Mail
+    flags: Ci.nsMsgFolderFlags.Mail,
   };
   notified = false;
   notif.OnItemIntPropertyChanged(nonInbox, "TotalUnreadMessages", 0, 2);
   Assert.ok(!notified);
 
   // Try setting the pref to count non-inboxes and notifying a non-inbox
   Services.prefs.setBoolPref(countInboxesPref, false);
   notified = false;
   notif.OnItemIntPropertyChanged(nonInbox, "TotalUnreadMessages", 0, 2);
   Assert.ok(notified);
 
   run_next_test();
 });
-
-function run_test() {
-  run_next_test();
-}
--- a/mailnews/base/test/unit/test_nsIFolderListener.js
+++ b/mailnews/base/test/unit/test_nsIFolderListener.js
@@ -1,45 +1,49 @@
 /*
  * Test that adding nsIFolderListener in js does not cause any crash.
  */
 
-var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* 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/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/messageModifier.js");
 load("../../../resources/messageGenerator.js");
 load("../../../resources/messageInjection.js");
 
 var folderListener = {
-  OnItemAdded: function() {},
-  OnItemRemoved: function() {},
-  OnItemPropertyChanged: function() {},
-  OnItemIntPropertyChanged: function() {},
-  OnItemBoolPropertyChanged: function() {},
-  OnItemUnicharPropertyChanged: function() {},
-  OnItemPropertyFlagChanged: function() {},
-  OnItemEvent: function() {},
-}
+  OnItemAdded() {},
+  OnItemRemoved() {},
+  OnItemPropertyChanged() {},
+  OnItemIntPropertyChanged() {},
+  OnItemBoolPropertyChanged() {},
+  OnItemUnicharPropertyChanged() {},
+  OnItemPropertyFlagChanged() {},
+  OnItemEvent() {},
+};
 
 var targetFolder;
 
 var tests = [
   function setup() {
     gMessageGenerator = new MessageGenerator();
 
     configure_message_injection({mode: "local"});
 
     targetFolder = make_empty_folder();
     targetFolder.AddFolderListener(folderListener);
     registerCleanupFunction(function() {
       targetFolder.RemoveFolderListener(folderListener);
     });
   },
   async function create_new_message() {
-    let [msgSet] = make_new_sets_in_folder(targetFolder, [{count: 1}]);
+    make_new_sets_in_folder(targetFolder, [{count: 1}]);
     await wait_for_message_injection();
-  }
+  },
 ];
 
 function run_test() {
   async_run_tests(tests);
 }
--- a/mailnews/base/test/unit/test_nsIMsgContentPolicy.js
+++ b/mailnews/base/test/unit/test_nsIMsgContentPolicy.js
@@ -1,19 +1,17 @@
 /* -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /*
  * Test suite for nsIMsgContentPolicy to check we could add/remove customized protocol to
  * nsMsgContentPolicy.
  */
 const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
 function makeURI(aURL) {
-  var ioService = Cc["@mozilla.org/network/io-service;1"]
-                    .getService(Ci.nsIIOService);
-  return ioService.newURI(aURL);
+  return Services.io.newURI(aURL);
 }
 
 function run_test() {
   var content_policy = Cc["@mozilla.org/messenger/content-policy;1"]
                          .getService(Ci.nsIContentPolicy);
 
   Assert.ok(content_policy);
 
@@ -27,17 +25,17 @@ function run_test() {
   var content_uri = makeURI("custom-scheme://custom_content_url/1.jsp");
   Assert.ok(content_uri);
 
   let tmpChannel = NetUtil.newChannel({
     uri: content_uri,
     // Needs one of 'loadingNode', 'loadingPrincipal' or 'loadUsingSystemPrincipal' which we don't have.
     // Even with `loadUsingSystemPrincipal: true` this fails with "unknown protocol". See bug 1446587.
     securityFlags: Ci.nsILoadInfo.SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK,
-    contentPolicyType: Ci.nsIContentPolicy.TYPE_IMAGE
+    contentPolicyType: Ci.nsIContentPolicy.TYPE_IMAGE,
   });
   let tmpLoadInfo = tmpChannel.loadInfo;
 
   var decision = content_policy.shouldLoad(content_uri, tmpLoadInfo, "img/jpeg");
   Assert.notEqual(decision,
                   Ci.nsIContentPolicy.ACCEPT,
                   "customized protocol should not load");
 
@@ -49,10 +47,10 @@ function run_test() {
                "customized protocol should load");
 
   msg_content_policy.removeExposedProtocol("custom-scheme");
 
   decision = content_policy.shouldLoad(content_uri, tmpLoadInfo, "img/jpeg");
   Assert.notEqual(decision,
                   Ci.nsIContentPolicy.ACCEPT,
                   "customized protocol should not load");
-};
+}
 
--- a/mailnews/base/test/unit/test_nsIMsgFolder.js
+++ b/mailnews/base/test/unit/test_nsIMsgFolder.js
@@ -18,27 +18,25 @@ function run_test() {
   // Add a sub folder to ensure that we have some folders created
   root.createSubfolder("folder1", null);
 
   // Test - getChildNamed
 
   var caught = false;
   try {
     root.getChildNamed("folder");
-  }
-  catch (e) {
+  } catch (e) {
     caught = true;
   }
   Assert.equal(caught, true);
 
   caught = false;
   try {
     root.getChildNamed("Trash1");
-  }
-  catch (e) {
+  } catch (e) {
     caught = true;
   }
   Assert.equal(caught, true);
 
   var folder1 = root.getChildNamed("folder1");
 
   Assert.notEqual(folder1, folder2);
   Assert.equal(folder1.prettyName, "folder1");
--- a/mailnews/base/test/unit/test_nsIMsgFolderListener.js
+++ b/mailnews/base/test/unit/test_nsIMsgFolderListener.js
@@ -8,169 +8,153 @@
 
 /*
  * Test suite for basic functionality with nsIMsgFolderListeners.
  */
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var nsIMFNService = Ci.nsIMsgFolderNotificationService;
-var nsIMFListener = Ci.nsIMsgFolderListener;
 
-
-var gIndividualFlags =
-[
+var gIndividualFlags = [
   nsIMFNService.msgAdded,
   nsIMFNService.msgsClassified,
   nsIMFNService.msgsDeleted,
   nsIMFNService.msgsMoveCopyCompleted,
   nsIMFNService.msgKeyChanged,
   nsIMFNService.folderAdded,
   nsIMFNService.folderDeleted,
   nsIMFNService.folderMoveCopyCompleted,
   nsIMFNService.folderRenamed,
   nsIMFNService.itemEvent,
 ];
 
 // Our listener, which captures events.
 function gMFListener() {}
-gMFListener.prototype =
-{
+gMFListener.prototype = {
   mReceived: 0,
   mRemoveSelf: false,
-  msgAdded: function (aMsg)
-  {
+  msgAdded(aMsg) {
     Assert.equal(this.mReceived & nsIMFNService.msgAdded, 0);
     this.mReceived |= nsIMFNService.msgAdded;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  msgsClassified: function (aMsgs, aJunkProcessed, aTraitProcessed)
-  {
+  msgsClassified(aMsgs, aJunkProcessed, aTraitProcessed) {
     Assert.equal(this.mReceived & nsIMFNService.msgsClassified, 0);
     this.mReceived |= nsIMFNService.msgsClassified;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  msgsDeleted: function (aMsgs)
-  {
+  msgsDeleted(aMsgs) {
     Assert.equal(this.mReceived & nsIMFNService.msgsDeleted, 0);
     this.mReceived |= nsIMFNService.msgsDeleted;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  msgsMoveCopyCompleted: function (aMove, aSrcMsgs, aDestFolder, aDestMsgs)
-  {
+  msgsMoveCopyCompleted(aMove, aSrcMsgs, aDestFolder, aDestMsgs) {
     Assert.equal(this.mReceived & nsIMFNService.msgsMoveCopyCompleted, 0);
     this.mReceived |= nsIMFNService.msgsMoveCopyCompleted;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  msgKeyChanged: function(aOldMsgKey, aNewMsgHdr)
-  {
+  msgKeyChanged(aOldMsgKey, aNewMsgHdr) {
     Assert.equal(this.mReceived & nsIMFNService.msgKeyChanged, 0);
     this.mReceived |= nsIMFNService.msgKeyChanged;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  folderAdded: function (aFolder)
-  {
+  folderAdded(aFolder) {
     Assert.equal(this.mReceived & nsIMFNService.folderAdded, 0);
     this.mReceived |= nsIMFNService.folderAdded;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  folderDeleted: function (aFolder)
-  {
+  folderDeleted(aFolder) {
     Assert.equal(this.mReceived & nsIMFNService.folderDeleted, 0);
     this.mReceived |= nsIMFNService.folderDeleted;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  folderMoveCopyCompleted: function (aMove, aSrcFolder, aDestFolder)
-  {
+  folderMoveCopyCompleted(aMove, aSrcFolder, aDestFolder) {
     Assert.equal(this.mReceived & nsIMFNService.folderMoveCopyCompleted, 0);
     this.mReceived |= nsIMFNService.folderMoveCopyCompleted;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  folderRenamed: function (aOrigFolder, aNewFolder)
-  {
+  folderRenamed(aOrigFolder, aNewFolder) {
     Assert.equal(this.mReceived & nsIMFNService.folderRenamed, 0);
     this.mReceived |= nsIMFNService.folderRenamed;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
   },
 
-  itemEvent: function (aItem, aEvent, aData, aString)
-  {
+  itemEvent(aItem, aEvent, aData, aString) {
     Assert.equal(this.mReceived & nsIMFNService.itemEvent, 0);
     this.mReceived |= nsIMFNService.itemEvent;
     if (this.mRemoveSelf)
       MailServices.mfn.removeListener(this);
-  }
+  },
 };
 
-function NotifyMsgFolderListeners()
-{
+function NotifyMsgFolderListeners() {
   MailServices.mfn.notifyMsgAdded(null);
   MailServices.mfn.notifyMsgsClassified(null, null, null);
   MailServices.mfn.notifyMsgsDeleted(null);
   MailServices.mfn.notifyMsgsMoveCopyCompleted(null, null, null, null);
   MailServices.mfn.notifyMsgKeyChanged(null, null);
   MailServices.mfn.notifyFolderAdded(null);
   MailServices.mfn.notifyFolderDeleted(null);
   MailServices.mfn.notifyFolderMoveCopyCompleted(null, null, null);
   MailServices.mfn.notifyFolderRenamed(null, null);
   MailServices.mfn.notifyItemEvent(null, null, null, null);
 }
 
-function run_test()
-{
+function run_test() {
   // Test: Add listeners
   var singleListeners = [];
 
-  var addAListener = function (flag) {
+  var addAListener = function(flag) {
     var listener = new gMFListener();
     MailServices.mfn.addListener(listener, flag);
     singleListeners.push(listener);
   };
 
   gIndividualFlags.forEach(addAListener);
 
   // Test: Notify the listeners of all events.
   NotifyMsgFolderListeners();
 
   // Test: check whether the correct number of notifications have been received.
   // Then remove the listeners
-  var checkFlag = function (flag) {
+  var checkFlag = function(flag) {
     var listener = singleListeners.shift();
     Assert.equal(listener.mReceived, flag);
     listener.mRemoveSelf = true;
     listener.mReceived = 0;
     singleListeners.push(listener);
   };
   gIndividualFlags.forEach(checkFlag);
 
   // We'll do one more set of notifications, and remove ourselves in the middle of them
   NotifyMsgFolderListeners();
 
   // Test: all listeners should be removed at this point
   Assert.ok(!MailServices.mfn.hasListeners);
 
   // Test: Send notifications again. Check that we don't receive any notifications.
-  singleListeners.forEach(function (listener) { listener.mReceived = 0; });
+  singleListeners.forEach(function(listener) { listener.mReceived = 0; });
 
   NotifyMsgFolderListeners();
 
   var checkNotReceived = function() {
     Assert.equal(singleListeners.shift().mReceived, 0);
-  }
+  };
   gIndividualFlags.forEach(checkNotReceived);
 }
--- a/mailnews/base/test/unit/test_nsIMsgFolderListenerLocal.js
+++ b/mailnews/base/test/unit/test_nsIMsgFolderListenerLocal.js
@@ -14,121 +14,114 @@
   * - Adding new folders
   * - Copy messages from files into the db
   * - Moving and copying one or more messages from one local folder to another
   * - Moving folders, with and without subfolders
   * - Renaming folders
   * - Deleting messages and folders, to trash and from trash (permanently)
   */
 
+/* import-globals-from ../../../test/resources/msgFolderListenerSetup.js */
 load("../../../resources/msgFolderListenerSetup.js");
 
 // Globals
 var gMsgFile1, gMsgFile2, gMsgFile3;
 var gRootFolder;
 var gLocalFolder2;
 var gLocalFolder3;
 var gLocalTrashFolder;
 
 // storeIn takes a string containing the variable to store the new folder in
-function addFolder(parent, folderName, storeIn)
-{
+function addFolder(parent, folderName, storeIn) {
   gExpectedEvents = [[MailServices.mfn.folderAdded, parent, folderName, storeIn]];
   // We won't receive a copy listener notification for this
   gCurrStatus |= kStatus.onStopCopyDone;
   parent.createSubfolder(folderName, null);
   gCurrStatus |= kStatus.functionCallDone;
   if (gCurrStatus == kStatus.everythingDone)
     resetStatusAndProceed();
 }
 
 /**
  * This will introduce a new message to the system which will generate an added
  * notification and subsequently a classification notification.  For the
  * classification because no messages have yet been marked as junk and there
  * are no traits configured, aJunkProcessed and aTraitProcessed will be false.
  */
-function copyFileMessage(file, destFolder, isDraftOrTemplate)
-{
+function copyFileMessage(file, destFolder, isDraftOrTemplate) {
   copyListener.mFolderStoredIn = destFolder;
   gExpectedEvents = [[MailServices.mfn.msgAdded, gHdrsReceived],
                      [MailServices.mfn.msgsClassified, gHdrsReceived, false, false]];
   MailServices.copy.CopyFileMessage(file, destFolder, null, isDraftOrTemplate, 0, "",
                                     copyListener, null);
   gCurrStatus |= kStatus.functionCallDone;
   if (gCurrStatus == kStatus.everythingDone)
     resetStatusAndProceed();
 }
 
-function copyMessages(items, isMove, srcFolder, destFolder)
-{
+function copyMessages(items, isMove, srcFolder, destFolder) {
   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-  items.forEach(function (item) {
+  items.forEach(function(item) {
     array.appendElement(item);
   });
   gExpectedEvents = [
     [MailServices.mfn.msgsMoveCopyCompleted, isMove, items, destFolder, true]];
   MailServices.copy.CopyMessages(srcFolder, array, destFolder, isMove, copyListener,
                                  null, true);
   gCurrStatus |= kStatus.functionCallDone;
   if (gCurrStatus == kStatus.everythingDone)
     resetStatusAndProceed();
 }
 
-function copyFolders(items, isMove, destFolder)
-{
+function copyFolders(items, isMove, destFolder) {
   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-  items.forEach(function (item) {
+  items.forEach(function(item) {
     array.appendElement(item);
   });
   gExpectedEvents = [[MailServices.mfn.folderMoveCopyCompleted, isMove, items, destFolder]];
   MailServices.copy.CopyFolders(array, destFolder, isMove, copyListener, null);
   gCurrStatus |= kStatus.functionCallDone;
   if (gCurrStatus == kStatus.everythingDone)
     resetStatusAndProceed();
 }
 
-function deleteMessages(srcFolder, items, deleteStorage, isMove)
-{
+function deleteMessages(srcFolder, items, deleteStorage, isMove) {
   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
-  items.forEach(function (item) {
+  items.forEach(function(item) {
     array.appendElement(item);
   });
   // We should only get the delete notification only if we are not moving, and are deleting from
   // the storage/trash. We should get only the move/copy notification if we aren't.
   var isTrashFolder = srcFolder.getFlag(Ci.nsMsgFolderFlags.Trash);
-  if (!isMove && (deleteStorage || isTrashFolder))
-  {
+  if (!isMove && (deleteStorage || isTrashFolder)) {
     // We won't be getting any OnStopCopy notification in this case
     gCurrStatus = kStatus.onStopCopyDone;
     gExpectedEvents = [[MailServices.mfn.msgsDeleted, items]];
-  }
-  else
+  } else {
     // We have to be getting a move notification, even if isMove is false
     gExpectedEvents = [[MailServices.mfn.msgsMoveCopyCompleted, true, items,
                         gLocalTrashFolder, true]];
+  }
 
   srcFolder.deleteMessages(array, null, deleteStorage, isMove, copyListener, true);
   gCurrStatus |= kStatus.functionCallDone;
   if (gCurrStatus == kStatus.everythingDone)
     resetStatusAndProceed();
 }
 
-function renameFolder(folder, newName)
-{
+function renameFolder(folder, newName) {
   gExpectedEvents = [[MailServices.mfn.folderRenamed, [folder], newName]];
   gCurrStatus = kStatus.onStopCopyDone;
   folder.rename(newName, null);
   gCurrStatus |= kStatus.functionCallDone;
   if (gCurrStatus == kStatus.everythingDone)
     resetStatusAndProceed();
 }
 
-function deleteFolder(folder, child)
-{
+function deleteFolder(folder, child) {
   var array = Cc["@mozilla.org/array;1"]
                 .createInstance(Ci.nsIMutableArray);
   array.appendElement(folder);
   // We won't be getting any OnStopCopy notification at all
   // XXX delete to trash should get one, but we'll need to pass the listener
   // somehow to deleteSubFolders
   gCurrStatus = kStatus.onStopCopyDone;
   // If ancestor is trash, expect a folderDeleted, otherwise expect
@@ -144,35 +137,33 @@ function deleteFolder(folder, child)
                         [folder], gLocalTrashFolder]];
 
   folder.parent.deleteSubFolders(array, null);
   gCurrStatus |= kStatus.functionCallDone;
   if (gCurrStatus == kStatus.everythingDone)
     resetStatusAndProceed();
 }
 
-function compactFolder(folder)
-{
+function compactFolder(folder) {
   gExpectedEvents = [[MailServices.mfn.itemEvent, folder, "FolderCompactStart"],
                      [MailServices.mfn.itemEvent, folder, "FolderCompactFinish"]];
   // We won't receive a copy listener notification for this
   gCurrStatus |= kStatus.onStopCopyDone;
   folder.compact(null, null);
   gCurrStatus |= kStatus.functionCallDone;
   if (gCurrStatus == kStatus.everythingDone)
     resetStatusAndProceed();
 }
 
 /*
  * TESTS
  */
 
 // Beware before commenting out a test -- later tests might just depend on earlier ones
-var gTestArray =
-[
+var gTestArray = [
   // Adding folders
   // Create another folder to move and copy messages around, and force initialization.
   function addFolder1() {
     addFolder(gRootFolder, "folder2", function(folder) { gLocalFolder2 = folder; });
   },
   // Create a third folder for more testing.
   function addFolder2() {
     addFolder(gRootFolder, "folder3", function(folder) { gLocalFolder3 = folder; });
@@ -293,30 +284,30 @@ var gTestArray =
   // Inbox
   // Trash
   // -folder2
   // --folder3
   function deleteFolder4() {
     // Let's take a moment to re-initialize stuff that got moved
     gLocalFolder2 = gLocalTrashFolder.getChildNamed("folder2");
     gLocalFolder3 = gLocalFolder2.getChildNamed("folder3");
-    deleteFolder(gLocalFolder2, gLocalFolder3); },
+    deleteFolder(gLocalFolder2, gLocalFolder3);
+  },
   function compactInbox() {
     if (localAccountUtils.inboxFolder.msgStore.supportsCompaction)
       compactFolder(localAccountUtils.inboxFolder);
     else
       doTest(++gTest);
-  }
+  },
 ];
   // Folder structure should just be
   // Inbox
   // Trash
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   // Add a listener.
   MailServices.mfn.addListener(gMFListener, allTestedEvents);
 
   // Load up some messages so that we can copy them in later.
   gMsgFile1 = do_get_file("../../../data/bugmail10");
   gMsgFile2 = do_get_file("../../../data/bugmail11");
@@ -328,31 +319,27 @@ function run_test()
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of all the operations.
   do_test_pending();
 
   // Do the test.
   doTest(1);
 }
 
-function doTest(test)
-{
-  if (test <= gTestArray.length)
-  {
-    var testFn = gTestArray[test-1];
+function doTest(test) {
+  if (test <= gTestArray.length) {
+    var testFn = gTestArray[test - 1];
     // Set a limit of 10 seconds; if the notifications haven't arrived by then there's a problem.
-    do_timeout(10000, function(){
+    do_timeout(10000, function() {
         if (gTest == test)
           do_throw("Notifications not received in 10000 ms for operation " + testFn.name +
             ", current status is " + gCurrStatus);
         }
       );
     dump("=== Test: " + testFn.name + "\n");
     testFn();
-  }
-  else
-  {
+  } else {
     gHdrsReceived = null;
     gMsgHdrs = null;
     MailServices.mfn.removeListener(gMFListener);
     do_test_finished(); // for the one in run_test()
   }
 }
--- a/mailnews/base/test/unit/test_nsIMsgTagService.js
+++ b/mailnews/base/test/unit/test_nsIMsgTagService.js
@@ -7,18 +7,17 @@
  *
  * Specifically tests changes implemented in bug 217034
  * Does not do comprehensive testing.
  *
  */
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-function run_test()
-{
+function run_test() {
   // These are both tags and keys. Note keys are forced to be lower case
   const tag1 = "istag";
   const tag2 = "notistag";
   const tag3 = "istagnot";
   const tag4 = "istagtoo";
 
   // add a tag
   MailServices.tags.addTagForKey(tag1, tag1, null, null);
@@ -53,18 +52,17 @@ function run_test()
   // add many tags and check again
   for (i = 0; i < 100; i++)
     MailServices.tags.addTagForKey(i, "lotsatags" + i, null, null);
   Assert.ok(!MailServices.tags.isValidKey(tag1));
   Assert.ok(!MailServices.tags.isValidKey(tag2));
   Assert.ok(!MailServices.tags.isValidKey(tag3));
   Assert.ok(MailServices.tags.isValidKey(tag4));
 
-  for (i = 0; i < 100; i++)
-  {
+  for (i = 0; i < 100; i++) {
     Assert.ok(MailServices.tags.isValidKey(i));
     // make sure it knows the difference betweens tags and keys
     Assert.ok(!MailServices.tags.isValidKey("lotsatags" + i));
     // are we confused by key at start of tag?
     Assert.ok(!MailServices.tags.isValidKey(i + "lotsatags"));
   }
 }
 
--- a/mailnews/base/test/unit/test_nsMailDirProvider.js
+++ b/mailnews/base/test/unit/test_nsMailDirProvider.js
@@ -14,9 +14,9 @@ function run_test() {
 
   items.forEach(function(item) {
     var dir = Services.dirsvc.get(item.key, Ci.nsIFile);
     dump(do_get_profile().path + " " + dir.path + "\n");
     Assert.ok(do_get_profile().equals(dir.parent));
 
     Assert.equal(dir.leafName, item.value);
   });
-};
+}
--- a/mailnews/base/test/unit/test_nsMsgDBView.js
+++ b/mailnews/base/test/unit/test_nsMsgDBView.js
@@ -4,20 +4,26 @@
  *
  * Things we really should do:
  * - Test that secondary sorting works, especially when the primary column is
  *   a custom column.
  *
  * You may also want to look into the test_viewWrapper_*.js tests as well.
  */
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/abSetup.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/abSetup.js");
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
+/* import-globals-from ../../../test/resources/messageModifier.js */
+/* import-globals-from ../../../test/resources/messageInjection.js */
 load("../../../resources/messageGenerator.js");
 load("../../../resources/messageModifier.js");
 load("../../../resources/messageInjection.js");
 
 const {JSTreeSelection} = ChromeUtils.import("resource:///modules/jsTreeSelection.js");
 
 // Items used to add messages to the folder
 var gMessageGenerator = new MessageGenerator();
@@ -30,24 +36,25 @@ function setup_globals(aNextFunc) {
   // build up a diverse list of messages
   let messages = [];
   messages = messages.concat(gScenarioFactory.directReply(10));
   // the message generator uses a constanty incrementing counter, so we need to
   //  mix up the order of messages ourselves to ensure that the timestamp
   //  ordering is not already in order.  (a poor test of sorting otherwise.)
   messages = gScenarioFactory.directReply(6).concat(messages);
 
-  messages = messages.concat(gScenarioFactory.fullPyramid(3,3));
+  messages = messages.concat(gScenarioFactory.fullPyramid(3, 3));
   let siblingMessages = gScenarioFactory.siblingsMissingParent();
   // cut off "Re: " part
   gSiblingsMissingParentsSubject = siblingMessages[0].subject.slice(4);
   dump("siblings subect = " + gSiblingsMissingParentsSubject + "\n");
   messages = messages.concat(siblingMessages);
   messages = messages.concat(gScenarioFactory.missingIntermediary());
-  messages.concat(gMessageGenerator.makeMessage({age: {days: 2, hours: 1}}));
+  // This next line was found to be faulty during linting, but fixing it breaks the test.
+  // messages.concat(gMessageGenerator.makeMessage({age: {days: 2, hours: 1}}));
 
   // build a hierarchy like this (the UID order corresponds to the date order)
   //   1
   //    2
   //     4
   //    3
   let msg1 = gMessageGenerator.makeMessage();
   let msg2 = gMessageGenerator.makeMessage({inReplyTo: msg1});
@@ -61,30 +68,27 @@ function setup_globals(aNextFunc) {
   messages = messages.concat([msgSmallerKey, msgBiggerKey]);
   let msgSet = new SyntheticMessageSet(messages);
 
   gTestFolder = make_empty_folder();
   return add_sets_to_folders(gTestFolder, [msgSet]);
 }
 
 var gCommandUpdater = {
-  updateCommandStatus : function()
-  {
+  updateCommandStatus() {
     // the back end is smart and is only telling us to update command status
     // when the # of items in the selection has actually changed.
   },
 
-  displayMessageChanged : function(aFolder, aSubject, aKeywords)
-  {
+  displayMessageChanged(aFolder, aSubject, aKeywords) {
   },
 
-  updateNextMessageAfterDelete : function()
-  {
+  updateNextMessageAfterDelete() {
   },
-  summarizeSelection : function() {return false;}
+  summarizeSelection() { return false; },
 };
 
 /**
  * Create a synthetic message by passing the provided aMessageArgs to
  *  the message generator, then add the resulting message to the given
  *  folder (or gTestFolder if no folder is provided).
  *
  * @TODO change callers to use more generic messageInjection mechanisms.
@@ -102,27 +106,26 @@ function make_and_add_message(aMessageAr
 var WHITESPACE = "                                              ";
 /**
  * Print out the current db view as best we can.
  */
 function dump_view_contents() {
   dump("********* Current View State\n");
   for (let iViewIndex = 0; iViewIndex < gTreeView.rowCount; iViewIndex++) {
     let level = gTreeView.getLevel(iViewIndex);
-    let viewFlags = gDBView.viewFlags;
     let flags = gDBView.getFlagsAt(iViewIndex);
 
     let s = WHITESPACE.substr(0, level * 2);
     if (gTreeView.isContainer(iViewIndex))
       s += gTreeView.isContainerOpen(iViewIndex) ? "- " : "+ ";
     else
       s += ". ";
     if (flags & MSG_VIEW_FLAG_DUMMY)
       s += "dummy: ";
-    s += gDBView.cellTextForColumn(iViewIndex, "subject")
+    s += gDBView.cellTextForColumn(iViewIndex, "subject");
     dump(s + "\n");
   }
   dump("********* end view state\n");
 }
 
 function view_throw(why) {
   dump_view_contents();
   do_throw(why);
@@ -190,56 +193,51 @@ function assert_view_message_at_indices(
       let hdrAt = gDBView.getMsgHdrAt(thing);
       if (curHdr != hdrAt) {
         view_throw("Expected hdr at " + thing + " to be " +
                   curHdr.messageKey + ":" +
                    curHdr.mime2DecodedSubject.substr(0, 30) + " not " +
                   hdrAt.messageKey + ":" +
                     hdrAt.mime2DecodedSubject.substr(0, 30));
       }
+    } else {
+      // synthetic message, get the header...
+      curHdr = gTestFolder.msgDatabase.getMsgHdrForMessageID(thing.messageId);
     }
-
-    // synthetic message, get the header...
-    else
-      curHdr = gTestFolder.msgDatabase.getMsgHdrForMessageID(thing.messageId);
   }
 }
 
 var authorFirstLetterCustomColumn = {
-  getCellText: function(row, col) {
-    let folder = this.dbView.getFolderForViewIndex(row);
+  getCellText(row, col) {
     let msgHdr = this.dbView.getMsgHdrAt(row);
     return msgHdr.mime2DecodedAuthor.charAt(0).toUpperCase() || "?";
   },
-  getSortStringForRow: function(msgHdr) {
+  getSortStringForRow(msgHdr) {
     // charAt(0) is a quote, charAt(1) is the first letter!
     return msgHdr.mime2DecodedAuthor.charAt(1).toUpperCase() || "?";
   },
-  isString: function() {
+  isString() {
     return true;
   },
 
-  getCellProperties:   function(row, col) { return ""; },
-  getRowProperties:    function(row) { return ""; },
-  getImageSrc:         function(row, col) {return null;},
-  getSortLongForRow:   function(hdr) {return 0;}
+  getCellProperties(row, col) { return ""; },
+  getRowProperties(row) { return ""; },
+  getImageSrc(row, col) { return null; },
+  getSortLongForRow(hdr) { return 0; },
 };
 
 var gDBView;
 var gTreeView;
 
 var ViewType = Ci.nsMsgViewType;
 var SortType = Ci.nsMsgViewSortType;
 var SortOrder = Ci.nsMsgViewSortOrder;
 var ViewFlags = Ci.nsMsgViewFlagsType;
-var MsgFlags = Ci.nsMsgMessageFlags;
 
 var MSG_VIEW_FLAG_DUMMY = 0x20000000;
-var MSG_VIEW_FLAG_HASCHILDREN = 0x40000000;
-var MSG_VIEW_FLAG_ISTHREAD = 0x8000000;
 
 var gFakeSelection = new JSTreeSelection(null);
 
 function setup_view(aViewType, aViewFlags, aTestFolder) {
   let dbviewContractId = "@mozilla.org/messenger/msgdbview;1?type=" + aViewType;
 
   if (aTestFolder == null)
     aTestFolder = gTestFolder;
@@ -313,18 +311,17 @@ function setup_group_view(aSortType, aSo
 /**
  * Comparison func for built-in types (including strings, so no subtraction.)
  */
 function generalCmp(a, b) {
   if (a < b)
     return -1;
   else if (a > b)
     return 1;
-  else
-    return 0;
+  return 0;
 }
 
 /**
  * Check that sort order and grouping logic (if applicable) are doing the right
  *  thing.
  *
  * In the case of groups (indicated by dummy headers), we want to ignore the
  *  dummies and 1) make sure all the values in the group have the same value,
@@ -359,18 +356,17 @@ function ensure_view_ordering(aSortBy, a
   //  realize that it shouldn't do the right thing, so it can just change the
   //  sort.  (of course, under the hood, it is actually creating a new view...)
   if ((gDBView.viewFlags & ViewFlags.kGroupBySort) &&
       (gDBView.viewType != ViewType.eShowSearch)) {
     // we must close to re-open (or we could just use a new view)
     let msgFolder = gDBView.msgFolder;
     gDBView.close();
     gDBView.open(msgFolder, aSortBy, aDirection, gDBView.viewFlags, {});
-  }
-  else {
+  } else {
     gDBView.sort(aSortBy, aDirection);
   }
 
   let comparisonValuesByLevel = [];
   let expectedLevel0CmpResult = (aDirection == SortOrder.ascending ? 1 : -1);
   let comparator = generalCmp;
 
   let dummyCount = 0, emptyDummyCount = 0;
@@ -427,19 +423,18 @@ function ensure_view_ordering(aSortBy, a
     }
 
     // is this level new to our comparisons?  then track it...
     if (level >= comparisonValuesByLevel.length) {
       // null-fill any gaps (due to, say, dummy nodes)
       while (comparisonValuesByLevel.length <= level)
         comparisonValuesByLevel.push(null);
       comparisonValuesByLevel.push(curValue);
-    }
-    else { // otherwise compare it
-      let prevValue = comparisonValuesByLevel[level-1];
+    } else { // otherwise compare it
+      let prevValue = comparisonValuesByLevel[level - 1];
       let cmpResult = comparator(curValue, prevValue);
       let expectedCmpResult = (level > 0) ? 1 : expectedLevel0CmpResult;
       if (cmpResult && cmpResult != expectedCmpResult)
         do_throw("Ordering failure on key " + msgHdr.messageKey + ". " +
                  curValue + " should have been " +
                  (expectedCmpResult == 1 ? ">=" : "<=") + " " +
                  prevValue + " but was not.");
     }
@@ -451,53 +446,53 @@ function ensure_view_ordering(aSortBy, a
     dump("  saw " + dummyCount + " dummy headers (" + emptyDummyCount +
          " empty).\n");
 }
 
 /**
  * Test sorting functionality.
  */
 function test_sort_columns() {
-  ensure_view_ordering(SortType.byDate, SortOrder.descending, 'date',
+  ensure_view_ordering(SortType.byDate, SortOrder.descending, "date",
     function getDateAgeBucket(msgHdr) {
       // so, this is a cop-out, but we know that the date age bucket for our
       //  generated messages is always more than 2-weeks ago!
       return 5;
     });
-  ensure_view_ordering(SortType.byDate, SortOrder.ascending, 'date',
+  ensure_view_ordering(SortType.byDate, SortOrder.ascending, "date",
     function getDateAgeBucket(msgHdr) {
       // so, this is a cop-out, but we know that the date age bucket for our
       //  generated messages is always more than 2-weeks ago!
       return 5;
     });
   // (note, subject doesn't use dummy groups and so won't have grouping tested)
-  ensure_view_ordering(SortType.bySubject, SortOrder.ascending, 'mime2DecodedSubject');
-  ensure_view_ordering(SortType.byAuthor, SortOrder.ascending, 'mime2DecodedAuthor');
+  ensure_view_ordering(SortType.bySubject, SortOrder.ascending, "mime2DecodedSubject");
+  ensure_view_ordering(SortType.byAuthor, SortOrder.ascending, "mime2DecodedAuthor");
   // Id
   // Thread
   // Priority
   // Status
   // Size
   // Flagged
   // Unread
-  ensure_view_ordering(SortType.byRecipient, SortOrder.ascending, 'mime2DecodedRecipients');
+  ensure_view_ordering(SortType.byRecipient, SortOrder.ascending, "mime2DecodedRecipients");
   // Location
   // Tags
   // JunkStatus
   // Attachments
   // Account
   // Custom
   ensure_view_ordering(SortType.byCustom, SortOrder.ascending,
-    function (msgHdr) {
+    function(msgHdr) {
       return authorFirstLetterCustomColumn.getSortStringForRow(msgHdr);
     });
   // Received
 }
 
-function  test_number_of_messages() {
+function test_number_of_messages() {
   // Bug 574799
   if (gDBView.numMsgsInView != gTestFolder.getTotalMessages(false))
     do_throw("numMsgsInView is " + gDBView.numMsgsInView + " but should be " +
              gTestFolder.getTotalMessages(false) + "\n");
   // Bug 600140
   // Maybe elided so open it, now only consider the first one
   if (gDBView.isContainer(0) && !gDBView.isContainerOpen(0))
     gDBView.toggleOpenState(0);
@@ -519,35 +514,35 @@ function test_selected_messages() {
   // Select one message
   gTreeView.selection.select(1);
   let selectedMessages = gDBView.getSelectedMsgHdrs();
 
   if (selectedMessages.length != 1)
     do_throw("getSelectedMsgHdrs.length is " + selectedMessages.length +
              " but should be 1\n");
 
-  let firstSelectedMsg = gDBView.hdrForFirstSelectedMessage
+  let firstSelectedMsg = gDBView.hdrForFirstSelectedMessage;
   if (selectedMessages[0] != firstSelectedMsg)
     do_throw("getSelectedMsgHdrs[0] is " + selectedMessages[0].messageKey +
-             " but should be " + firstSelectedMsg.messageKey +"\n");
+             " but should be " + firstSelectedMsg.messageKey + "\n");
 
   // Select all messages
   gTreeView.selection.selectAll();
   if (gDBView.numSelected != gTreeView.rowCount)
     do_throw("numSelected is " + gDBView.numSelected + " but should be " +
              gTreeView.rowCount + "\n");
 
   selectedMessages = gDBView.getSelectedMsgHdrs();
   if (selectedMessages.length != gTestFolder.getTotalMessages(false))
     do_throw("getSelectedMsgHdrs.length is " + selectedMessages.length +
              " but should be " + gTestFolder.getTotalMessages(false) + "\n");
 
   for (let i = 0; i < selectedMessages.length; i++) {
     let expectedHdr = gDBView.getMsgHdrAt(i);
-    if (selectedMessages.indexOf(expectedHdr) == -1) {
+    if (!selectedMessages.includes(expectedHdr)) {
       view_throw("Expected " + expectedHdr.messageKey + ":" +
                  expectedHdr.mime2DecodedSubject.substr(0, 30) +
                  " to be selected, but it wasn't\n");
     }
   }
 
   gTreeView.selection.clearSelection();
 }
@@ -573,40 +568,37 @@ function test_insert_remove_view_rows() 
     view_throw("msgKey is " + key + " but should be " + msgKey + "\n");
   gDBView.removeTreeRows(index, rows);
   assert_view_row_count(startCount);
 
   // These should fail.
   try {
     gDBView.insertTreeRows(startCount + 10, rows, msgKey, flags, level, folder);
     view_throw("expected exception not caught; inserting at illegal index \n");
-  }
-  catch (ex) {}
+  } catch (ex) {}
   try {
     gDBView.insertTreeRows(index, rows, msgKey, flags, level, folder);
     gDBView.removeTreeRows(index, gTreeView.rowCount + 10);
     view_throw("expected exception not caught; removing illegal rows \n");
-  }
-  catch (ex) {
+  } catch (ex) {
     gDBView.removeTreeRows(index, rows);
   }
   if (xfview)
     try {
       gDBView.insertTreeRows(index, rows, msgKey, flags, level, null);
       view_throw("expected exception not caught; folder required for xfvf view \n");
-    }
-    catch (ex) {}
+    } catch (ex) {}
 }
 
 function test_msg_added_to_search_view() {
   // if the view is a non-grouped search view, test adding a header to
   // the search results, and verify it gets put at top.
-  if (! (gDBView.viewFlags & ViewFlags.kGroupBySort)) {
+  if (!(gDBView.viewFlags & ViewFlags.kGroupBySort)) {
     gDBView.sort(SortType.byDate, SortOrder.descending);
-    let [synMsg, synSet] = make_and_add_message();
+    let [synMsg] = make_and_add_message();
     let msgHdr = gTestFolder.msgDatabase.getMsgHdrForMessageID(synMsg.messageId);
     gDBView.QueryInterface(Ci.nsIMsgSearchNotify)
             .onSearchHit(msgHdr, msgHdr.folder);
     assert_view_message_at_indices(synMsg, 0);
   }
 }
 
 function IsHdrChildOf(possibleParent, possibleChild) {
@@ -617,22 +609,21 @@ function IsHdrChildOf(possibleParent, po
       return true;
   }
   return false;
 }
 
 // This could be part of ensure_view_ordering() but I don't want to make that
 // function any harder to read.
 function test_threading_levels() {
-
   if (!gTreeView.rowCount)
     do_throw("There are no rows in my folder! I can't test anything!");
   // only look at threaded, non-grouped views.
   if ((gDBView.viewFlags & ViewFlags.kGroupBySort) ||
-      ! (gDBView.viewFlags & ViewFlags.kThreadedDisplay))
+      !(gDBView.viewFlags & ViewFlags.kThreadedDisplay))
     return;
 
   let prevLevel = 1;
   let prevMsgHdr;
   for (let iViewIndex = 0; iViewIndex < gTreeView.rowCount; iViewIndex++) {
     let msgHdr = gDBView.getMsgHdrAt(iViewIndex);
     let level = gTreeView.getLevel(iViewIndex);
     if (level > prevLevel && msgHdr.subject != gSiblingsMissingParentsSubject) {
@@ -672,32 +663,31 @@ function test_qs_results() {
     view_throw("second message should be at level 1");
   if (gTreeView.getLevel(2) != 2)
     view_throw("third message should be at level 2");
   test_threading_levels();
 }
 
 function test_group_sort_collapseAll_expandAll_threading() {
   // - start with an empty folder
-  let save_gTestFolder = gTestFolder;
   gTestFolder = make_empty_folder();
 
   // - create a normal unthreaded view
   setup_view("threaded", 0);
 
   // - ensure it's empty
   assert_view_empty();
 
   // - add 3 messages:
   // msg1: from A, custom column val A, to be starred
   // msg2: from A, custom column val A
   // msg3: from B, custom column val B
-  let [smsg1, synSet1] = make_and_add_message({from: ["A", "A@a.invalid"]});
-  let [smsg2, synSet2] = make_and_add_message({from: ["A", "A@a.invalid"]});
-  let [smsg3, synSet3] = make_and_add_message({from: ["B", "B@b.invalid"]});
+  let [smsg1] = make_and_add_message({from: ["A", "A@a.invalid"]});
+  make_and_add_message({from: ["A", "A@a.invalid"]});
+  let [smsg3] = make_and_add_message({from: ["B", "B@b.invalid"]});
 
   assert_view_row_count(3);
   gDBView.getMsgHdrAt(0).markFlagged(true);
   if (!gDBView.getMsgHdrAt(0).isFlagged)
     view_throw("Expected smsg1 to be flagged");
 
   // - create grouped view; open folder in byFlagged AZ sort
   setup_group_view(SortType.byFlagged, SortOrder.ascending, gTestFolder);
@@ -755,17 +745,16 @@ function test_group_sort_collapseAll_exp
   assert_view_index_is_not_dummy(3);
   assert_view_index_is_not_dummy(4);
   if (authorFirstLetterCustomColumn.getSortStringForRow(gDBView.getMsgHdrAt(4)) != "A")
     view_throw("Expected grouped by custom column, ZA sortOrder smsg2 value to be A");
 }
 
 function* test_group_dummies_under_mutation_by_date() {
   // - start with an empty folder
-  let save_gTestFolder = gTestFolder;
   gTestFolder = make_empty_folder();
 
   // - create the view
   setup_view("group", ViewFlags.kGroupBySort);
   gDBView.sort(SortType.byDate, SortOrder.ascending);
 
   // - ensure it's empty
   assert_view_empty();
@@ -791,17 +780,17 @@ function* test_group_dummies_under_mutat
   // - move the messages to the trash
   yield async_trash_messages(synSet);
 
   // - make sure the message and dummy disappear
   assert_view_empty();
 
   // - add two messages from this week (same date bucket concerns)
   let [newer, newerSet] = make_and_add_message({age: {days: 2, hours: 1}});
-  let [older, olderSet] = make_and_add_message({age: {days: 2, hours: 2}});
+  let [older] = make_and_add_message({age: {days: 2, hours: 2}});
 
   // - sanity check addition
   assert_view_row_count(3); // 2 messages + 1 dummy
   assert_view_index_is_dummy(0);
   assert_view_index_is_not_dummy(1, 2);
   // the dummy should be based off the older guy
   assert_view_message_at_indices(older, 0, 1);
   assert_view_message_at_indices(newer, 2);
@@ -923,44 +912,44 @@ function test_thread_sorting() {
 
 var view_types = [
   ["threaded", ViewFlags.kThreadedDisplay],
   ["quicksearch", ViewFlags.kThreadedDisplay],
   ["search", ViewFlags.kThreadedDisplay],
   ["search", ViewFlags.kGroupBySort],
   ["xfvf", ViewFlags.kNone],
    // group does unspeakable things to gTestFolder, so put it last.
-  ["group", ViewFlags.kGroupBySort]
+  ["group", ViewFlags.kGroupBySort],
 ];
 
 var tests_for_all_views = [
   test_sort_columns,
   test_number_of_messages,
   test_selected_messages,
-  test_insert_remove_view_rows
+  test_insert_remove_view_rows,
 ];
 
 var tests_for_specific_views = {
   group: [
     test_group_sort_collapseAll_expandAll_threading,
-    test_group_dummies_under_mutation_by_date
+    test_group_dummies_under_mutation_by_date,
   ],
   threaded: [
     test_expand_collapse,
-    test_thread_sorting
+    test_thread_sorting,
   ],
   search: [
-    test_msg_added_to_search_view
+    test_msg_added_to_search_view,
   ],
   quicksearch: [
-    test_qs_results
+    test_qs_results,
   ],
   xfvf: [
-    test_xfvf_threading
-  ]
+    test_xfvf_threading,
+  ],
 };
 
 function run_test() {
   configure_message_injection({mode: "local"});
   do_test_pending();
   async_run({func: actually_run_test});
 }
 
--- a/mailnews/base/test/unit/test_nsMsgDBView_headerValues.js
+++ b/mailnews/base/test/unit/test_nsMsgDBView_headerValues.js
@@ -1,51 +1,86 @@
 /* Test that nsMsgDBView properly reports the values of messages in the display.
  */
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/abSetup.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/abSetup.js");
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
+/* import-globals-from ../../../test/resources/messageModifier.js */
+/* import-globals-from ../../../test/resources/messageInjection.js */
 load("../../../resources/messageGenerator.js");
 load("../../../resources/messageModifier.js");
 load("../../../resources/messageInjection.js");
 
-var ViewType = Ci.nsMsgViewType;
 var SortType = Ci.nsMsgViewSortType;
 var SortOrder = Ci.nsMsgViewSortOrder;
 
 // This is an array of the actual test data. Each test datum is an array of two
 // elements: the first element is the argument into a simple message generator,
 // and the second element is a map of column names to expected values when
 // requesting the cell text for a given column name.
 var tests = [
-  [{from: "John Doe <db@tinderbox.invalid>"}, {senderCol: "John Doe"}],
-  [{from: "\"Doe, John\" <db@tinderbox.invalid>"}, {senderCol: "Doe, John"}],
+  [
+    {from: "John Doe <db@tinderbox.invalid>"},
+    {senderCol: "John Doe"},
+  ],
+  [
+    {from: "\"Doe, John\" <db@tinderbox.invalid>"},
+    {senderCol: "Doe, John"},
+  ],
   // Multiple senders are indicated with 'et al.' suffix.
-  [{from: "John Doe <db@tinderbox.invalid>, Sally Ann <db@null.invalid>"},
-    {senderCol: "John Doe et al."}],
-  [{from: "=?UTF-8?Q?David_H=C3=A5s=C3=A4ther?= <db@null.invalid>"},
-    {senderCol: "David Håsäther"}],
-  [{from: "=?UTF-8?Q?H=C3=A5s=C3=A4ther=2C_David?= <db@null.invalid>"},
-    {senderCol: "Håsäther, David"}],
-  [{from: "\"Håsäther, David\" <db@null.invalid>"},
-    {senderCol: "Håsäther, David"}],
-  [{from: "David Håsäther <db@null.invalid>"},
-    {senderCol: "David Håsäther"}],
-  [{from: "\xC2\xAB\xCE\xA0\xCE\x9F\xCE\x9B\xCE\x99\xCE\xA4\xCE\x97\xCE\xA3\xC2\xBB"},
-    {senderCol: "«ΠΟΛΙΤΗΣ»"}],
-  [{from: "John Doe \xF5  <db@null.invalid>",
-     clobberHeaders: { "Content-type" : "text/plain; charset=ISO-8859-1" }},
-    {senderCol: "John Doe õ"}],
-  [{from: "John Doe \xF5 <db@null.invalid>",
-     clobberHeaders: { "Content-type" : "text/plain; charset=ISO-8859-2" }},
-    {senderCol: "John Doe ő"}],
-  [{from: "=?UTF-8?Q?H=C3=A5s=C3=A4ther=2C_David?= <db@null.invalid>",
-     clobberHeaders: { "Content-type" : "text/plain; charset=ISO-8859-2" }},
-    {senderCol: "Håsäther, David"}],
+  [
+    {from: "John Doe <db@tinderbox.invalid>, Sally Ann <db@null.invalid>"},
+    {senderCol: "John Doe et al."},
+  ],
+  [
+    {from: "=?UTF-8?Q?David_H=C3=A5s=C3=A4ther?= <db@null.invalid>"},
+    {senderCol: "David Håsäther"},
+  ],
+  [
+    {from: "=?UTF-8?Q?H=C3=A5s=C3=A4ther=2C_David?= <db@null.invalid>"},
+    {senderCol: "Håsäther, David"},
+  ],
+  [
+    {from: "\"Håsäther, David\" <db@null.invalid>"},
+    {senderCol: "Håsäther, David"},
+  ],
+  [
+    {from: "David Håsäther <db@null.invalid>"},
+    {senderCol: "David Håsäther"},
+  ],
+  [
+    {from: "\xC2\xAB\xCE\xA0\xCE\x9F\xCE\x9B\xCE\x99\xCE\xA4\xCE\x97\xCE\xA3\xC2\xBB"},
+    {senderCol: "«ΠΟΛΙΤΗΣ»"},
+  ],
+  [
+    {
+      from: "John Doe \xF5  <db@null.invalid>",
+      clobberHeaders: { "Content-type": "text/plain; charset=ISO-8859-1" },
+    },
+    {senderCol: "John Doe õ"},
+  ],
+  [
+    {
+      from: "John Doe \xF5 <db@null.invalid>",
+      clobberHeaders: { "Content-type": "text/plain; charset=ISO-8859-2" },
+    },
+    {senderCol: "John Doe ő"},
+  ],
+  [
+    {
+      from: "=?UTF-8?Q?H=C3=A5s=C3=A4ther=2C_David?= <db@null.invalid>",
+      clobberHeaders: { "Content-type": "text/plain; charset=ISO-8859-2" },
+    },
+    {senderCol: "Håsäther, David"},
+  ],
 ];
 
 function* real_test() {
   // Add the messages to the folder
   let msgGenerator = new MessageGenerator();
   let genMessages = tests.map(data => msgGenerator.makeMessage(data[0]));
   let folder = make_empty_folder();
   yield add_sets_to_folder(folder, [new SyntheticMessageSet(genMessages)]);
@@ -58,17 +93,17 @@ function* real_test() {
   var outCount = {};
   dbView.open(folder, SortType.byDate, SortOrder.ascending, 0, outCount);
 
   // Did we add all the messages properly?
   let treeView = dbView.QueryInterface(Ci.nsITreeView);
   Assert.equal(treeView.rowCount, tests.length);
 
   // For each test, make sure that the display is correct.
-  tests.forEach(function (data, i) {
+  tests.forEach(function(data, i) {
     info("Checking data for " + uneval(data));
     let expected = data[1];
     for (let column in expected) {
       Assert.equal(dbView.cellTextForColumn(i, column), expected[column]);
     }
   });
 }
 
--- a/mailnews/base/test/unit/test_nsMsgMailSession_Alerts.js
+++ b/mailnews/base/test/unit/test_nsMsgMailSession_Alerts.js
@@ -1,78 +1,78 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /*
  * Test suite for nsMsgMailSession functions relating to alerts and their
  * listeners.
  */
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
 load("../../../resources/alertTestUtils.js");
 
 var gDialogTitle = null;
 var gText = null;
 
 function reset() {
   gDialogTitle = null;
   gText = null;
 }
 
+/* exported alert */// Used in alertTestUtils.
 function alert(aDialogTitle, aText) {
   Assert.equal(gDialogTitle, null);
   Assert.equal(gText, null);
 
   gDialogTitle = aDialogTitle;
   gText = aText;
 }
 
 var msgWindow = {
   get promptDialog() {
     return alertUtilsPrompts;
   },
 
-  QueryInterface: ChromeUtils.generateQI([Ci.nsIMsgWindow])
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIMsgWindow]),
 };
 
 var msgUrl = {
   _msgWindow: null,
 
   get msgWindow() {
     return this._msgWindow;
   },
 
-  QueryInterface: ChromeUtils.generateQI([Ci.nsIMsgMailNewsUrl])
+  QueryInterface: ChromeUtils.generateQI([Ci.nsIMsgMailNewsUrl]),
 };
 
 function alertListener() {}
 
 alertListener.prototype = {
   mReturn: false,
   mMessage: null,
   mMsgWindow: null,
 
-  reset: function () {
+  reset() {
     this.mMessage = null;
     this.mMsgWindow = null;
   },
 
-  onAlert: function (aMessage, aMsgWindow) {
+  onAlert(aMessage, aMsgWindow) {
     Assert.equal(this.mMessage, null);
     Assert.equal(this.mMsgWindow, null);
 
     this.mMessage = aMessage;
     this.mMsgWindow = aMsgWindow;
 
     return this.mReturn;
-  }
+  },
 };
 
-function run_test()
-{
+function run_test() {
   // Test - No listeners, check alert tries to alert the user.
 
   reset();
 
   msgUrl._msgWindow = msgWindow;
 
   MailServices.mailSession.alertUser("test message", msgUrl);
 
--- a/mailnews/base/test/unit/test_nsMsgMailSession_Listeners.js
+++ b/mailnews/base/test/unit/test_nsMsgMailSession_Listeners.js
@@ -1,69 +1,68 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /*
  * Test suite for nsMsgMailSession functions relating to listeners.
  */
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var nsIFolderListener = Ci.nsIFolderListener;
 var numListenerFunctions = 8;
 
-var gMailSessionNotifier = MailServices.mailSession.QueryInterface(nsIFolderListener);
+var gMailSessionNotifier = MailServices.mailSession.QueryInterface(Ci.nsIFolderListener);
 
 var gFLAll;
 var gFLSingle = new Array(numListenerFunctions);
 
 function fL() {}
 
 fL.prototype = {
   mReceived: 0,
   mAutoRemoveItem: false,
 
-  OnItemAdded: function (parentItem, item) {
-    this.mReceived |= nsIFolderListener.added;
+  OnItemAdded(parentItem, item) {
+    this.mReceived |= Ci.nsIFolderListener.added;
     if (this.mAutoRemoveItem)
       MailServices.mailSession.RemoveFolderListener(this);
   },
-  OnItemRemoved: function (parentItem, item) {
-    this.mReceived |= nsIFolderListener.removed;
+  OnItemRemoved(parentItem, item) {
+    this.mReceived |= Ci.nsIFolderListener.removed;
     if (this.mAutoRemoveItem)
       MailServices.mailSession.RemoveFolderListener(this);
   },
-  OnItemPropertyChanged: function (item, property, oldValue, newValue) {
-    this.mReceived |= nsIFolderListener.propertyChanged;
+  OnItemPropertyChanged(item, property, oldValue, newValue) {
+    this.mReceived |= Ci.nsIFolderListener.propertyChanged;
     if (this.mAutoRemoveItem)
       MailServices.mailSession.RemoveFolderListener(this);
   },
-  OnItemIntPropertyChanged: function (item, property, oldValue, newValue) {
-    this.mReceived |= nsIFolderListener.intPropertyChanged;
+  OnItemIntPropertyChanged(item, property, oldValue, newValue) {
+    this.mReceived |= Ci.nsIFolderListener.intPropertyChanged;
     if (this.mAutoRemoveItem)
       MailServices.mailSession.RemoveFolderListener(this);
   },
-  OnItemBoolPropertyChanged: function (item, property, oldValue, newValue) {
-    this.mReceived |= nsIFolderListener.boolPropertyChanged;
+  OnItemBoolPropertyChanged(item, property, oldValue, newValue) {
+    this.mReceived |= Ci.nsIFolderListener.boolPropertyChanged;
     if (this.mAutoRemoveItem)
       MailServices.mailSession.RemoveFolderListener(this);
   },
-  OnItemUnicharPropertyChanged: function (item, property, oldValue, newValue) {
-    this.mReceived |= nsIFolderListener.unicharPropertyChanged;
+  OnItemUnicharPropertyChanged(item, property, oldValue, newValue) {
+    this.mReceived |= Ci.nsIFolderListener.unicharPropertyChanged;
     if (this.mAutoRemoveItem)
       MailServices.mailSession.RemoveFolderListener(this);
   },
-  OnItemPropertyFlagChanged: function (item, property, oldValue, newValue) {
-    this.mReceived |= nsIFolderListener.propertyFlagChanged;
+  OnItemPropertyFlagChanged(item, property, oldValue, newValue) {
+    this.mReceived |= Ci.nsIFolderListener.propertyFlagChanged;
     if (this.mAutoRemoveItem)
       MailServices.mailSession.RemoveFolderListener(this);
   },
-  OnItemEvent: function (parentItem, item) {
-    this.mReceived |= nsIFolderListener.event;
+  OnItemEvent(parentItem, item) {
+    this.mReceived |= Ci.nsIFolderListener.event;
     if (this.mAutoRemoveItem)
       MailServices.mailSession.RemoveFolderListener(this);
-  }
+  },
 };
 
 function NotifyMailSession() {
     gMailSessionNotifier.OnItemAdded(null, null);
     gMailSessionNotifier.OnItemRemoved(null, null);
     gMailSessionNotifier.OnItemPropertyChanged(null, null, null, null);
     gMailSessionNotifier.OnItemIntPropertyChanged(null, null, null, null);
     gMailSessionNotifier.OnItemBoolPropertyChanged(null, null, null, null);
@@ -76,17 +75,17 @@ function run_test() {
   var i;
 
   Assert.ok(MailServices.mailSession != null);
 
   // Test - Add a listener
 
   gFLAll = new fL;
 
-  MailServices.mailSession.AddFolderListener(gFLAll, nsIFolderListener.all);
+  MailServices.mailSession.AddFolderListener(gFLAll, Ci.nsIFolderListener.all);
 
   for (i = 0; i < numListenerFunctions; ++i) {
     gFLSingle[i] = new fL;
     MailServices.mailSession.AddFolderListener(gFLSingle[i], Math.pow(2, i));
   }
 
   // Test - Notify listener on all available items
 
@@ -125,9 +124,9 @@ function run_test() {
   gFLAll.mReceived = 0;
 
   for (i = 0; i < numListenerFunctions; ++i)
     Assert.equal(gFLSingle[i].mReceived, 0);
 
   // Test - Remove main listener
 
   MailServices.mailSession.RemoveFolderListener(gFLAll);
-};
+}
--- a/mailnews/base/test/unit/test_nsMsgTraitService.js
+++ b/mailnews/base/test/unit/test_nsMsgTraitService.js
@@ -10,20 +10,18 @@ var kJunkId = "mailnews@mozilla.org#junk
 var kGoodId = "mailnews@mozilla.org#good";
 var kGoodIndex = Ci.nsIJunkMailPlugin.GOOD_TRAIT;
 var kJunkIndex = Ci.nsIJunkMailPlugin.JUNK_TRAIT;
 
 // a dummy set of traits
 var proId = "TheProTrait";
 var proName = "ProName";
 var antiId = "TheAntiTrait";
-var antiName = "AntiName";
 
-function run_test()
-{
+function run_test() {
   // Check lastIndex prior to adding, 3 - 1000 are reserved for mailnews
   Assert.equal(ts.lastIndex, 1000);
 
   // basic junk as traits should be setup automatically
   Assert.equal(kGoodId,
                Services.prefs.getCharPref("mailnews.traits.id." + kGoodIndex));
   Assert.equal(kJunkId,
                Services.prefs.getCharPref("mailnews.traits.id." + kJunkIndex));
@@ -94,29 +92,25 @@ function run_test()
   // remove the pro trait
   ts.unRegisterTrait(proId);
   Assert.ok(!ts.isRegistered(proId));
 
   // check that this is also removed from prefs. The get calls should fail
   try {
     Services.prefs.getCharPref("mailnews.traits.id." + proIndex);
     Assert.ok(false);
-  }
-  catch (e) {}
+  } catch (e) {}
 
   try {
     Services.prefs.getCharPref("mailnews.traits.name." + proIndex);
     Assert.ok(false);
-  }
-  catch (e) {}
+  } catch (e) {}
 
   try {
     Services.prefs.getBoolPref("mailnews.traits.enabled." + proIndex);
     Assert.ok(false);
-  }
-  catch (e) {}
+  } catch (e) {}
 
   try {
     Services.prefs.getCharPref("mailnews.traits.antiId." + proIndex);
     Assert.ok(false);
-  }
-  catch(e) {}
+  } catch (e) {}
 }
--- a/mailnews/base/test/unit/test_postPluginFilters.js
+++ b/mailnews/base/test/unit/test_postPluginFilters.js
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * tests post-plugin message filters as implemented in bug 198100
  */
 
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
 
 // Globals
 
 var gDbService = Cc["@mozilla.org/msgDatabase/msgDBService;1"]
                      .getService(Ci.nsIMsgDBService);
 
 // command functions for test data
@@ -22,52 +23,45 @@ var gMsgHdr; // current message header
 
 var kJunkFile = "../../../data/bugmail1";
 var kGoodFile = "../../../data/draft1";
 
 var kPriorityLow = 3;
 var kPriorityHigh = 5;
 var gInboxListener; // database listener object
 
-var gTests =
-[
-  // train two different messages
+var gTests = [
   {
+    // train two different messages
     command: kTrain,
     fileName: kGoodFile,
     traitId: MailServices.junk.GOOD_TRAIT,
-  },
-  {
+  }, {
     command: kTrain,
     fileName: kJunkFile,
     traitId: MailServices.junk.JUNK_TRAIT,
-  },
-  // test a filter that acts on GOOD messages
-  {
+  }, {
+    // test a filter that acts on GOOD messages
     command: kClass,
     fileName: kGoodFile,
-    test: function testClassGood() {
+    test() {
       Assert.equal(kPriorityHigh, gMsgHdr.priority);
-    }
-  },
-  // test a filter that acts on JUNK messages
-  {
+    },
+  }, {
+    // test a filter that acts on JUNK messages
     command: kClass,
     fileName: kJunkFile,
-    test: function testClassJunk() {
+    test() {
       Assert.equal(kPriorityLow, gMsgHdr.priority);
-    }
-  },
-  /**/
-]
+    },
+  }
+];
 
 // main test
-function run_test()
-{
-
+function run_test() {
   // Setup some incoming filters, setting junk priority low, and good high.
 
   // Can't use the fake server, must use the deferredTo local server!
   let filterList = localAccountUtils.incomingServer.getFilterList(null);
 
   // junkIsLow filter
   let filter = filterList.createFilter("junkIsLow");
   let searchTerm = filter.createTerm();
@@ -111,145 +105,115 @@ function run_test()
   gInboxListener = new DBListener();
   gDbService.registerPendingListener(localAccountUtils.inboxFolder, gInboxListener);
 
   do_test_pending();
 
   startCommand();
 }
 
-function endTest()
-{
+function endTest() {
   // Cleanup
   dump(" Exiting mail tests\n");
   if (gInboxListener)
     gDbService.unregisterPendingListener(gInboxListener);
 
   gPOP3Pump = null;
 
   do_test_finished(); // for the one in run_test()
 }
 
-var classifyListener =
-{
-  //nsIMsgTraitClassificationListener implementation
-  onMessageTraitsClassified: function(aMsgURI, {}, aTraits, aPercents)
-  {
-    //print("Message URI is " + aMsgURI);
+var classifyListener = {
+  // nsIMsgTraitClassificationListener implementation
+  onMessageTraitsClassified(aMsgURI, aTraitCount, aTraits, aPercents) {
+    // print("Message URI is " + aMsgURI);
     if (!aMsgURI)
-      return; //ignore end-of-batch signal
+      return; // ignore end-of-batch signal
 
     startCommand();
-  }
+  },
 };
 
 // nsIDBChangeListener implementation.
-function DBListener()
-{
+function DBListener() {
 }
 
-DBListener.prototype =
-{
-  onHdrFlagsChanged:
-    function onHdrFlagsChanged(aHdrChanged, aOldFlags, aNewFlags, aInstigator)
-    {
-    },
+DBListener.prototype = {
+  onHdrFlagsChanged(aHdrChanged, aOldFlags, aNewFlags, aInstigator) {
+  },
+
+  onHdrDeleted(aHdrChanged, aParentKey, Flags, aInstigator) {
+  },
 
-  onHdrDeleted:
-    function onHdrDeleted(aHdrChanged, aParentKey, Flags, aInstigator)
-    {
-    },
+  onHdrAdded(aHdrChanged, aParentKey, aFlags, aInstigator) {
+    gMsgHdr = aHdrChanged;
+  },
 
-  onHdrAdded:
-    function onHdrAdded(aHdrChanged, aParentKey, aFlags, aInstigator)
-    {
-      gMsgHdr = aHdrChanged;
-    },
-
-  onParentChanged:
-    function onParentChanged(aKeyChanged, oldParent, newParent, aInstigator)
-    {
-    },
+  onParentChanged(aKeyChanged, oldParent, newParent, aInstigator) {
+  },
 
-  onAnnouncerGoingAway:
-    function onAnnouncerGoingAway(instigator)
-    {
-      if (gInboxListener)
-      {
-        try {
-          IMAPPump.inbox.msgDatabase.RemoveListener(gInboxListener);
-        }
-        catch (e) {dump(" listener not found\n");}
+  onAnnouncerGoingAway(instigator) {
+    if (gInboxListener) {
+      try {
+        POP3Pump.inbox.msgDatabase.RemoveListener(gInboxListener);
+      } catch (e) {
+        dump(" listener not found\n");
       }
-    },
+    }
+  },
 
-  onReadChanged:
-    function onReadChanged(aInstigator)
-    {
-    },
-
-  onJunkScoreChanged:
-    function onJunkScoreChanged(aInstigator)
-    {
-    },
+  onReadChanged(aInstigator) {
+  },
 
-  onHdrPropertyChanged:
-    function onHdrPropertyChanged(aHdrToChange, aPreChange, aStatus, aInstigator)
-    {
-    },
-  onEvent:
-    function onEvent(aDB, aEvent)
-    {
-    },
+  onJunkScoreChanged(aInstigator) {
+  },
 
+  onHdrPropertyChanged(aHdrToChange, aPreChange, aStatus, aInstigator) {
+  },
+  onEvent(aDB, aEvent) {
+  },
 };
 
-
 // start the next test command
-function startCommand()
-{
-  if (gTest && gTest.test)
-  {
+function startCommand() {
+  if (gTest && gTest.test) {
     dump("doing test " + gTest.test.name + "\n");
     gTest.test();
   }
-  if (!gTests.length)       // Do we have more commands?
-  {
+  if (!gTests.length) { // Do we have more commands?
     // no, all done
     endTest();
     return;
   }
 
   gTest = gTests.shift();
-  switch (gTest.command)
-  {
+  switch (gTest.command) {
     case kTrain:
       // train message
       var proArray = [];
       proArray.push(gTest.traitId);
 
       MailServices.junk.setMsgTraitClassification(
-        getSpec(gTest.fileName), //in string aMsgURI
+        getSpec(gTest.fileName), // in string aMsgURI
         0,
         null,         // in nsIArray aOldTraits
         proArray.length,
         proArray,     // in nsIArray aNewTraits
         classifyListener); // [optional] in nsIMsgTraitClassificationListener aTraitListener
         // null,      // [optional] in nsIMsgWindow aMsgWindow
         // null,      // [optional] in nsIJunkMailClassificationListener aJunkListener
       break;
 
     case kClass:
       // classify message
       gPOP3Pump.files = [gTest.fileName];
-      gPOP3Pump.onDone = function(){do_timeout(100, startCommand);};
+      gPOP3Pump.onDone = function() { do_timeout(100, startCommand); };
       gPOP3Pump.run();
       break;
   }
 }
 
-function getSpec(aFileName)
-{
+function getSpec(aFileName) {
   var file = do_get_file(aFileName);
   var uri = Services.io.newFileURI(file).QueryInterface(Ci.nsIURL);
   uri = uri.mutate().setQuery("type=application/x-message-display").finalize();
   return uri.spec;
 }
--- a/mailnews/base/test/unit/test_quarantineFilterMove.js
+++ b/mailnews/base/test/unit/test_quarantineFilterMove.js
@@ -6,25 +6,26 @@
  * tests message moves with filter and quarantine enabled per bug 582918.
  * It then tests that subsequent moves of the filtered messages work.
  *
  * adapted from test_copyThenMoveManual.js
  */
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 const {PromiseTestUtils} = ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
+
+/* import-globals-from ../../../test/resources/POP3pump.js */
 load("../../../resources/POP3pump.js");
 
 var gFiles = ["../../../data/bugmail1", "../../../data/bugmail10"];
 
 var gMoveFolder, gMoveFolder2;
 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;
@@ -80,35 +81,32 @@ var gTestArray =
     let messageContent = getContentFromMessage(firstMsgHdr);
     Assert.ok(messageContent.includes("Some User <bugmail@example.org> changed"));
     messageContent = getContentFromMessage(secondMsgHdr);
     Assert.ok(messageContent.includes("https://bugzilla.mozilla.org/show_bug.cgi?id=436880"));
   },
   function endTest() {
     dump("Exiting mail tests\n");
     gPOP3Pump = null;
-  }
+  },
 ];
 
-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 run_test()
-{
+function run_test() {
   /* may not work in Linux */
-  //if ("@mozilla.org/gnome-gconf-service;1" in Cc)
+  // if ("@mozilla.org/gnome-gconf-service;1" in Cc)
   //  return;
   /**/
   // quarantine messages
   Services.prefs.setBoolPref("mailnews.downloadToTempFile", true);
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
 
   gMoveFolder = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder");
--- a/mailnews/base/test/unit/test_retention.js
+++ b/mailnews/base/test/unit/test_retention.js
@@ -1,15 +1,20 @@
 /*
  * Simple tests for retention settings. In particular, we'd like to make
  * sure that applying retention settings works with the new code that avoids
  * opening db's to apply retention settings if the folder doesn't override
  * the server defaults.
  */
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/messageGenerator.js */
+/* import-globals-from ../../../test/resources/messageModifier.js */
+/* import-globals-from ../../../test/resources/messageInjection.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 
 load("../../../resources/messageGenerator.js");
 load("../../../resources/messageModifier.js");
 load("../../../resources/messageInjection.js");
 
 var gMessageGenerator = new MessageGenerator();
--- a/mailnews/base/test/unit/test_search.js
+++ b/mailnews/base/test/unit/test_search.js
@@ -3,479 +3,536 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Testing of general mail search features.
  *
  * This tests some search attributes not tested by other specific tests,
  * e.g., test_searchTag.js or test_searchJunk.js
  */
+/* import-globals-from ../../../test/resources/searchTestUtils.js */
 load("../../../resources/searchTestUtils.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var nsMsgSearchScope = Ci.nsMsgSearchScope;
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp = Ci.nsMsgSearchOp;
-
-var Isnt = nsMsgSearchOp.Isnt;
-var Is = nsMsgSearchOp.Is;
-var IsEmpty = nsMsgSearchOp.IsEmpty;
-var IsntEmpty = nsMsgSearchOp.IsntEmpty;
-var Contains = nsMsgSearchOp.Contains;
-var DoesntContain = nsMsgSearchOp.DoesntContain;
-var BeginsWith = nsMsgSearchOp.BeginsWith;
-var EndsWith = nsMsgSearchOp.EndsWith;
-var IsBefore = nsMsgSearchOp.IsBefore; // control entry not enabled
-var IsAfter = nsMsgSearchOp.IsAfter;
-var IsHigherThan = nsMsgSearchOp.IsHigherThan;
-var IsLowerThan = nsMsgSearchOp.IsLowerThan;
+var Isnt = Ci.nsMsgSearchOp.Isnt;
+var Is = Ci.nsMsgSearchOp.Is;
+var Contains = Ci.nsMsgSearchOp.Contains;
+var DoesntContain = Ci.nsMsgSearchOp.DoesntContain;
+var BeginsWith = Ci.nsMsgSearchOp.BeginsWith;
+var EndsWith = Ci.nsMsgSearchOp.EndsWith;
+var IsBefore = Ci.nsMsgSearchOp.IsBefore; // control entry not enabled
+var IsAfter = Ci.nsMsgSearchOp.IsAfter;
+var IsHigherThan = Ci.nsMsgSearchOp.IsHigherThan;
+var IsLowerThan = Ci.nsMsgSearchOp.IsLowerThan;
 
-var offlineMail = nsMsgSearchScope.offlineMail;
-var onlineMail = nsMsgSearchScope.onlineMail;
-var offlineMailFilter = nsMsgSearchScope.offlineMailFilter;
-var onlineMailFilter = nsMsgSearchScope.onlineMailFilter;
-var news = nsMsgSearchScope.news; // control entry not enabled
+var OtherHeader = Ci.nsMsgSearchAttrib.OtherHeader;
+var From = Ci.nsMsgSearchAttrib.Sender;
+var Subject = Ci.nsMsgSearchAttrib.Subject;
+var Priority = Ci.nsMsgSearchAttrib.Priority;
+var SDate = Ci.nsMsgSearchAttrib.Date;
 
-var OtherHeader = nsMsgSearchAttrib.OtherHeader;
-var From = nsMsgSearchAttrib.Sender;
-var Subject = nsMsgSearchAttrib.Subject;
-var Priority = nsMsgSearchAttrib.Priority;
-var SDate = nsMsgSearchAttrib.Date;
-
-var Tests =
-[
+var Tests = [
   // test the To: header
-  { testString: "PrimaryEmail1@test.invalid",
+  {
+    testString: "PrimaryEmail1@test.invalid",
     testAttribute: From,
     op: Is,
-    count: 1 },
-  { testString: "PrimaryEmail1@test.invalid",
+    count: 1,
+  }, {
+    testString: "PrimaryEmail1@test.invalid",
     testAttribute: From,
     op: Isnt,
-    count: 0 },
-  { testString: "PrimaryEmail",
+    count: 0,
+  }, {
+    testString: "PrimaryEmail",
     testAttribute: From,
     op: BeginsWith,
-    count: 1 },
-  { testString: "invalid",
+    count: 1,
+  }, {
+    testString: "invalid",
     testAttribute: From,
     op: BeginsWith,
-    count: 0 },
-  { testString: "invalid",
+    count: 0,
+  }, {
+    testString: "invalid",
     testAttribute: From,
     op: EndsWith,
-    count: 1},
-  { testString: "Primary",
+    count: 1,
+  }, {
+    testString: "Primary",
     testAttribute: From,
     op: EndsWith,
-    count: 0},
-  { testString: "QAContact",
+    count: 0,
+  }, {
+    testString: "QAContact",
     testAttribute: OtherHeader,
     op: BeginsWith,
-    count: 1},
-  { testString: "filters",
+    count: 1,
+  }, {
+    testString: "filters",
     testAttribute: OtherHeader,
     op: BeginsWith,
-    count: 0},
-  { testString: "mail.bugs",
+    count: 0,
+  }, {
+    testString: "mail.bugs",
     testAttribute: OtherHeader,
     op: EndsWith,
-    count: 1},
-  { testString: "QAContact",
+    count: 1,
+  }, {
+    testString: "QAContact",
     testAttribute: OtherHeader,
     op: EndsWith,
-    count: 0},
-  { testString: "QAcontact filters@mail.bugs",
+    count: 0,
+  }, {
+    testString: "QAcontact filters@mail.bugs",
     testAttribute: OtherHeader,
     op: Is,
-    count: 1},
-  { testString: "filters@mail.bugs",
+    count: 1,
+  }, {
+    testString: "filters@mail.bugs",
     testAttribute: OtherHeader,
     op: Is,
-    count: 0},
-  { testString: "QAcontact filters@mail.bugs",
+    count: 0,
+  }, {
+    testString: "QAcontact filters@mail.bugs",
     testAttribute: OtherHeader,
     op: Isnt,
-    count: 0},
-  { testString: "QAcontact",
+    count: 0,
+  }, {
+    testString: "QAcontact",
     testAttribute: OtherHeader,
     op: Isnt,
-    count: 1},
-  { testString: "filters",
+    count: 1,
+  }, {
+    testString: "filters",
     testAttribute: OtherHeader,
     op: Contains,
-    count: 1},
-  { testString: "foobar",
+    count: 1,
+  }, {
+    testString: "foobar",
     testAttribute: OtherHeader,
     op: Contains,
-    count: 0},
-
+    count: 0,
+  },
   // test header with multiple occurences
-  { testString: "one value",
+  {
+    testString: "one value",
     testAttribute: OtherHeader,
     op: Is,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "second",
+    count: 1,
+  }, {
+    testString: "second",
     testAttribute: OtherHeader,
     op: Is,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "third value for test purposes",
+    count: 1,
+  }, {
+    testString: "third value for test purposes",
     testAttribute: OtherHeader,
     op: Is,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "multiline value that needs to be handled.",
+    count: 1,
+  }, {
+    testString: "multiline value that needs to be handled.",
     testAttribute: OtherHeader,
     op: Is,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "one value",
+    count: 1,
+  }, {
+    testString: "one value",
     testAttribute: OtherHeader,
     op: Isnt,
     customHeader: "X-Duplicated-Header",
-    count: 0},
-  { testString: "second",
+    count: 0,
+  }, {
+    testString: "second",
     testAttribute: OtherHeader,
     op: Isnt,
     customHeader: "X-Duplicated-Header",
-    count: 0},
-  { testString: "third value for test purposes",
+    count: 0,
+  }, {
+    testString: "third value for test purposes",
     testAttribute: OtherHeader,
     op: Isnt,
     customHeader: "X-Duplicated-Header",
-    count: 0},
-  { testString: "multiline value that needs to be handled.",
+    count: 0,
+  }, {
+    testString: "multiline value that needs to be handled.",
     testAttribute: OtherHeader,
     op: Isnt,
     customHeader: "X-Duplicated-Header",
-    count: 0},
-
-  { testString: "one",
+    count: 0,
+  }, {
+    testString: "one",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "second",
+    count: 1,
+  }, {
+    testString: "second",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "purposes",
+    count: 1,
+  }, {
+    testString: "purposes",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "value",
+    count: 1,
+  }, {
+    testString: "value",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "that needs to be",
+    count: 1,
+  }, {
+    testString: "that needs to be",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "fifth",
+    count: 1,
+  }, {
+    testString: "fifth",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-    { testString: "is the end my",
+    count: 1,
+  }, {
+    testString: "is the end my",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "the end",
+    count: 1,
+  }, {
+    testString: "the end",
     testAttribute: OtherHeader,
     op: EndsWith,
     customHeader: "X-Duplicated-Header",
-    count: 0},
-  { testString: "handled.",
+    count: 0,
+  }, {
+    testString: "handled.",
     testAttribute: OtherHeader,
     op: EndsWith,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "one value",
+    count: 1,
+  }, {
+    testString: "one value",
     testAttribute: OtherHeader,
     op: EndsWith,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "third",
+    count: 1,
+  }, {
+    testString: "third",
+    testAttribute: OtherHeader,
+    op: BeginsWith,
+    customHeader: "X-Duplicated-Header",
+    count: 1,
+  }, {
+    testString: "This is",
     testAttribute: OtherHeader,
     op: BeginsWith,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-  { testString: "This is",
-    testAttribute: OtherHeader,
-    op: BeginsWith,
-    customHeader: "X-Duplicated-Header",
-    count: 1},
+    count: 1,
+  },
 
-  { testString: "nothing",
+  {
+    testString: "nothing",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header",
-    count: 0},
-  { testString: "nothing",
+    count: 0,
+  }, {
+    testString: "nothing",
     testAttribute: OtherHeader,
     op: DoesntContain,
     customHeader: "X-Duplicated-Header",
-    count: 1},
-
-  { testString: "this header tests DB string properties",
-    testAttribute: OtherHeader,
-    op: Is,
-    customHeader: "X-Duplicated-Header-DB",
-    count: 1},
-  { testString: "which can be handled",
+    count: 1,
+  }, {
+    testString: "this header tests DB string properties",
     testAttribute: OtherHeader,
     op: Is,
     customHeader: "X-Duplicated-Header-DB",
-    count: 1},
-  { testString: "differently than X-Duplicated-Header, so better test it",
+    count: 1,
+  }, {
+    testString: "which can be handled",
     testAttribute: OtherHeader,
     op: Is,
     customHeader: "X-Duplicated-Header-DB",
-    count: 1},
-  { testString: "this header tests DB string properties",
+    count: 1,
+  }, {
+    testString: "differently than X-Duplicated-Header, so better test it",
     testAttribute: OtherHeader,
-    op: Isnt,
+    op: Is,
     customHeader: "X-Duplicated-Header-DB",
-    count: 0},
-  { testString: "which can be handled",
+    count: 1,
+  }, {
+    testString: "this header tests DB string properties",
     testAttribute: OtherHeader,
     op: Isnt,
     customHeader: "X-Duplicated-Header-DB",
-    count: 0},
-  { testString: "differently than X-Duplicated-Header, so better test it",
+    count: 0,
+  }, {
+    testString: "which can be handled",
     testAttribute: OtherHeader,
     op: Isnt,
     customHeader: "X-Duplicated-Header-DB",
-    count: 0},
-  { testString: "than X-Duplicated-Header,",
+    count: 0,
+  }, {
+    testString: "differently than X-Duplicated-Header, so better test it",
+    testAttribute: OtherHeader,
+    op: Isnt,
+    customHeader: "X-Duplicated-Header-DB",
+    count: 0,
+  }, {
+    testString: "than X-Duplicated-Header,",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Duplicated-Header-DB",
-    count: 1},
-  { testString: "than X-Duplicated-Header, so",
+    count: 1,
+  }, {
+    testString: "than X-Duplicated-Header, so",
     testAttribute: OtherHeader,
     op: DoesntContain,
     customHeader: "X-Duplicated-Header-DB",
-    count: 0},
-
+    count: 0,
+  },
   // test accumulation of received header
-  // only in first received
-  { testString: "caspiaco",
+  {
+    // only in first received
+    testString: "caspiaco",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "Received",
-    count: 1},
-  // only in second
-  { testString: "webapp01.sj.mozilla.com",
+    count: 1,
+  }, {
+    // only in second
+    testString: "webapp01.sj.mozilla.com",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "received",
-    count: 1},
-  // in neither
-  { testString: "not there",
+    count: 1,
+  }, {
+    // in neither
+    testString: "not there",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "received",
-    count: 0},
-  // not on first line of received
-  { testString: "m47LtAFJ007547",
+    count: 0,
+  }, {
+    // not on first line of received
+    testString: "m47LtAFJ007547",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "received",
-    count: 1},
-
+    count: 1,
+  },
   // test multiple line arbitrary headers
-  // in the first line
-  { testString: "SpamAssassin 3.2.3",
+  {
+    // in the first line
+    testString: "SpamAssassin 3.2.3",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Spam-Checker-Version",
-    count: 1},
-  // in the second line
-  { testString: "host29.example.com",
+    count: 1,
+  }, {
+    // in the second line
+    testString: "host29.example.com",
+    testAttribute: OtherHeader,
+    op: Contains,
+    customHeader: "X-Spam-Checker-Version",
+    count: 1,
+  }, {
+    // spans two lines with space
+    testString: "on host29.example.com",
     testAttribute: OtherHeader,
     op: Contains,
     customHeader: "X-Spam-Checker-Version",
-    count: 1},
-  // spans two lines with space
-   { testString: "on host29.example.com",
-     testAttribute: OtherHeader,
-     op: Contains,
-     customHeader: "X-Spam-Checker-Version",
-     count: 1},
-
+    count: 1,
+  },
   // subject spanning several lines
-  // on the first line
-   { testString: "A filter will",
-     testAttribute: Subject,
-     op: Contains,
-     count: 1},
-   { testString: "I do not exist",
-     testAttribute: Subject,
-     op: Contains,
-     count: 0},
-  // on the second line
-   { testString: "this message",
-     testAttribute: Subject,
-     op: Contains,
-     count: 1},
-  // spanning second and third line
-   { testString: "over many",
-     testAttribute: Subject,
-     op: Contains,
-     count: 1},
-
+  {
+    // on the first line
+    testString: "A filter will",
+    testAttribute: Subject,
+    op: Contains,
+    count: 1,
+  }, {
+    testString: "I do not exist",
+    testAttribute: Subject,
+    op: Contains,
+    count: 0,
+  }, {
+    // on the second line
+    testString: "this message",
+    testAttribute: Subject,
+    op: Contains,
+    count: 1,
+  }, {
+    // spanning second and third line
+    testString: "over many",
+    testAttribute: Subject,
+    op: Contains,
+    count: 1,
+  },
   // tests of custom headers db values
-    { testString: "a one line header",
-      dbHeader: "oneliner"},
-    { testString: "a two line header",
-      dbHeader: "twoliner"},
-    { testString: "a three line header with lotsa space and tabs",
-      dbHeader: "threeliner"},
-    { testString: "I have no space",
-      dbHeader: "nospace"},
-    { testString: "too much space",
-      dbHeader: "withspace"},
-
+  {
+    testString: "a one line header",
+    dbHeader: "oneliner",
+  }, {
+    testString: "a two line header",
+    dbHeader: "twoliner",
+  }, {
+    testString: "a three line header with lotsa space and tabs",
+    dbHeader: "threeliner",
+  }, {
+    testString: "I have no space",
+    dbHeader: "nospace",
+  }, {
+    testString: "too much space",
+    dbHeader: "withspace",
+  },
   // tests of custom db headers in a search
-    { testString: "one line",
-      testAttribute: OtherHeader,
-      op: Contains,
-      customHeader: "oneliner",
-      count: 1},
-    { testString: "two line header",
-      testAttribute: OtherHeader,
-      op: Contains,
-      customHeader: "twoliner",
-      count: 1},
-    { testString: "three line header with lotsa",
-      testAttribute: OtherHeader,
-      op: Contains,
-      customHeader: "threeliner",
-      count: 1},
-    { testString: "I have no space",
-      testAttribute: OtherHeader,
-      op: Contains,
-      customHeader: "nospace",
-      count: 1},
-    { testString: "too much space",
-      testAttribute: OtherHeader,
-      op: Contains,
-      customHeader: "withspace",
-      count: 1},
-
-    //test for priority
-    { testString: Ci.nsMsgPriority.lowest,
-      testAttribute: Priority,
-      op: IsHigherThan,
-      count: 1},
-    { testString: Ci.nsMsgPriority.low,
-      testAttribute: Priority,
-      op: Is,
-      count: 1},
-    { testString: Ci.nsMsgPriority.normal,
-      testAttribute: Priority,
-      op: IsLowerThan,
-      count: 1},
-    { testString: Ci.nsMsgPriority.lowest,
-      testAttribute: Priority,
-      op: Isnt,
-      count: 1},
-    { testString: Ci.nsMsgPriority.low,
-      testAttribute: Priority,
-      op: Isnt,
-      count: 0},
+  {
+    testString: "one line",
+    testAttribute: OtherHeader,
+    op: Contains,
+    customHeader: "oneliner",
+    count: 1,
+  }, {
+    testString: "two line header",
+    testAttribute: OtherHeader,
+    op: Contains,
+    customHeader: "twoliner",
+    count: 1,
+  }, {
+    testString: "three line header with lotsa",
+    testAttribute: OtherHeader,
+    op: Contains,
+    customHeader: "threeliner",
+    count: 1,
+  }, {
+    testString: "I have no space",
+    testAttribute: OtherHeader,
+    op: Contains,
+    customHeader: "nospace",
+    count: 1,
+  }, {
+    testString: "too much space",
+    testAttribute: OtherHeader,
+    op: Contains,
+    customHeader: "withspace",
+    count: 1,
+  },
+  // test for priority
+  {
+    testString: Ci.nsMsgPriority.lowest,
+    testAttribute: Priority,
+    op: IsHigherThan,
+    count: 1,
+  }, {
+    testString: Ci.nsMsgPriority.low,
+    testAttribute: Priority,
+    op: Is,
+    count: 1,
+  }, {
+    testString: Ci.nsMsgPriority.normal,
+    testAttribute: Priority,
+    op: IsLowerThan,
+    count: 1,
+  }, {
+    testString: Ci.nsMsgPriority.lowest,
+    testAttribute: Priority,
+    op: Isnt,
+    count: 1,
+  }, {
+    testString: Ci.nsMsgPriority.low,
+    testAttribute: Priority,
+    op: Isnt,
+    count: 0,
+  },
 
   // tests of Date header
   // The internal value of date in the search is PRTime (nanoseconds since Epoch).
   // Date().getTime() returns milliseconds since Epoch.
   // The dates used here are tailored for the ../../../data/bugmail12 message.
-  { testString: new Date("Wed, 7 May 2008 14:55:10 -0700").getTime() * 1000,
+  {
+    testString: new Date("Wed, 7 May 2008 14:55:10 -0700").getTime() * 1000,
     testAttribute: SDate,
     op: Is,
-    count: 1},
-  { testString: new Date("Thu, 8 May 2008 14:55:10 -0700").getTime() * 1000,
+    count: 1,
+  }, {
+    testString: new Date("Thu, 8 May 2008 14:55:10 -0700").getTime() * 1000,
     testAttribute: SDate,
     op: IsBefore,
-    count: 1},
-  { testString: new Date("Tue, 6 May 2008 14:55:10 -0700").getTime() * 1000,
+    count: 1,
+  }, {
+    testString: new Date("Tue, 6 May 2008 14:55:10 -0700").getTime() * 1000,
     testAttribute: SDate,
     op: IsAfter,
-    count: 1},
-  { testString: new Date("Tue, 6 May 2008 14:55:10 -0700").getTime() * 1000,
+    count: 1,
+  }, {
+    testString: new Date("Tue, 6 May 2008 14:55:10 -0700").getTime() * 1000,
     testAttribute: SDate,
     op: Isnt,
-    count: 1},
-  // check bug 248808
-  { testString: new Date("Wed, 7 May 2008 14:55:10 -0700").getTime() * 1000,
+    count: 1,
+  }, {
+    // check bug 248808
+    testString: new Date("Wed, 7 May 2008 14:55:10 -0700").getTime() * 1000,
     testAttribute: SDate,
     op: IsBefore,
-    count: 0},
-  { testString: new Date("Wed, 7 May 2008 14:55:10 -0700").getTime() * 1000,
+    count: 0,
+  }, {
+    testString: new Date("Wed, 7 May 2008 14:55:10 -0700").getTime() * 1000,
     testAttribute: SDate,
     op: IsAfter,
-    count: 0}
+    count: 0,
+  },
 ];
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
-  var copyListener =
-  {
-    OnStartCopy: function() {},
-    OnProgress: function(aProgress, aProgressMax) {},
-    SetMessageKey: function(aKey) {},
-    SetMessageId: function(aMessageId) {},
-    OnStopCopy: function(aStatus) { testSearch();}
+  var copyListener = {
+    OnStartCopy() {},
+    OnProgress(aProgress, aProgressMax) {},
+    SetMessageKey(aKey) {},
+    SetMessageId(aMessageId) {},
+    OnStopCopy(aStatus) { testSearch(); },
   };
 
   // set value of headers we want parsed into the db
   Services.prefs.setCharPref("mailnews.customDBHeaders",
           "oneLiner twoLiner threeLiner noSpace withSpace X-Duplicated-Header-DB");
   // Get a message into the local filestore. function testSearch() continues
   // the testing after the copy.
   var bugmail12 = do_get_file("../../../data/bugmail12");
   do_test_pending();
   MailServices.copy.CopyFileMessage(bugmail12, localAccountUtils.inboxFolder, null,
                                     false, 0, "", copyListener, null);
 }
 
 // process each test from queue, calls itself upon completion of each search
-var testObject;
-function testSearch()
-{
+function testSearch() {
   var test = Tests.shift();
-  if (test && test.dbHeader)
-  {
+  if (test && test.dbHeader) {
     //  test of a custom db header
     dump("testing dbHeader " + test.dbHeader + "\n");
     let customValue = mailTestUtils.firstMsgHdr(localAccountUtils.inboxFolder)
                                    .getProperty(test.dbHeader);
     Assert.equal(customValue, test.testString);
     do_timeout(0, testSearch);
-  }
-  else if (test)
-  {
+  } else if (test) {
     dump("testing for string '" + test.testString + "'\n");
-    testObject = new TestSearch(localAccountUtils.inboxFolder,
-                         test.testString,
-                         test.testAttribute,
-                         test.op,
-                         test.count,
-                         testSearch,
-                         null,
-                         test.customHeader ? test.customHeader : "X-Bugzilla-Watch-Reason");
-  }
-  else
-  {
-    testObject = null;
+    new TestSearch(localAccountUtils.inboxFolder,
+                   test.testString,
+                   test.testAttribute,
+                   test.op,
+                   test.count,
+                   testSearch,
+                   null,
+                   test.customHeader ? test.customHeader : "X-Bugzilla-Watch-Reason");
+  } else {
     do_test_finished();
   }
 }
--- a/mailnews/base/test/unit/test_searchAddressInAb.js
+++ b/mailnews/base/test/unit/test_searchAddressInAb.js
@@ -1,46 +1,44 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Testing of to, cc, toorcc in addressbook search features added in bug 187768
 // Added testing of AllAddresses from bug 310359
 
+/* import-globals-from ../../../test/resources/searchTestUtils.js */
 load("../../../resources/searchTestUtils.js");
 
 // add address book setup
+/* import-globals-from ../../../test/resources/abSetup.js */
 load("../../../resources/abSetup.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var ABUri = kPABData.URI;
 
-var nsMsgSearchScope = Ci.nsMsgSearchScope;
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp = Ci.nsMsgSearchOp;
-
-var IsntInAB = nsMsgSearchOp.IsntInAB;
-var IsInAB = nsMsgSearchOp.IsInAB;
-var IsBefore = nsMsgSearchOp.IsBefore; // control entry that is not enabled
-var Is = nsMsgSearchOp.Is;
-var Isnt = nsMsgSearchOp.Isnt;
+var IsntInAB = Ci.nsMsgSearchOp.IsntInAB;
+var IsInAB = Ci.nsMsgSearchOp.IsInAB;
+var IsBefore = Ci.nsMsgSearchOp.IsBefore; // control entry that is not enabled
+var Is = Ci.nsMsgSearchOp.Is;
+var Isnt = Ci.nsMsgSearchOp.Isnt;
 
-var offlineMail = nsMsgSearchScope.offlineMail;
-var onlineMail = nsMsgSearchScope.onlineMail;
-var offlineMailFilter = nsMsgSearchScope.offlineMailFilter;
-var onlineMailFilter = nsMsgSearchScope.onlineMailFilter;
-var news = nsMsgSearchScope.news; // control entry that is not enabled
+var offlineMail = Ci.nsMsgSearchScope.offlineMail;
+var onlineMail = Ci.nsMsgSearchScope.onlineMail;
+var offlineMailFilter = Ci.nsMsgSearchScope.offlineMailFilter;
+var onlineMailFilter = Ci.nsMsgSearchScope.onlineMailFilter;
+var news = Ci.nsMsgSearchScope.news; // control entry that is not enabled
 
-var Sender = nsMsgSearchAttrib.Sender;
-var To = nsMsgSearchAttrib.To;
-var CCopy = nsMsgSearchAttrib.CC;
-var ToOrCC = nsMsgSearchAttrib.ToOrCC;
-var AllAddresses = nsMsgSearchAttrib.AllAddresses;
-var Keywords = nsMsgSearchAttrib.Keywords; // control entry that is not enabled
+var Sender = Ci.nsMsgSearchAttrib.Sender;
+var To = Ci.nsMsgSearchAttrib.To;
+var CCopy = Ci.nsMsgSearchAttrib.CC;
+var ToOrCC = Ci.nsMsgSearchAttrib.ToOrCC;
+var AllAddresses = Ci.nsMsgSearchAttrib.AllAddresses;
+var Keywords = Ci.nsMsgSearchAttrib.Keywords; // control entry that is not enabled
 
 /*
  * The address available in the test address book is "PrimaryEmail1@test.invalid"
  * Test emails may also include the address "invalid@example.com"
  *
  *
  * Map of test email contents: (P is "Prim...", I is "inva.." address, N is none)
  *
@@ -52,109 +50,122 @@ var Keywords = nsMsgSearchAttrib.Keyword
  *    4         I         I       P     N
  *    5         P         I       P     N
  *    6         I         I,P     P,I   N
  *    7         I         I       I     P
  *    8         I         P       P     N
  *
  */
 
-var Tests =
-[
-  { value: ABUri,
+var Tests = [
+  {
+    value: ABUri,
     attrib: Sender,
     op: IsInAB,
-    count: 3 },
-  { value: ABUri,
+    count: 3,
+  }, {
+    value: ABUri,
     attrib: To,
     op: IsInAB,
-    count: 4 },
-  { value: ABUri,
+    count: 4,
+  }, {
+    value: ABUri,
     attrib: ToOrCC,
     op: IsInAB,
-    count: 6 },
-  { value: ABUri,
+    count: 6,
+  }, {
+    value: ABUri,
     attrib: AllAddresses,
     op: IsInAB,
-    count: 8 },
-  { value: ABUri,
+    count: 8,
+  }, {
+    value: ABUri,
     attrib: CCopy,
     op: IsInAB,
-    count: 5 },
-  { value: ABUri,
+    count: 5,
+  }, {
+    value: ABUri,
     attrib: Sender,
     op: IsntInAB,
-    count: 5 },
-  { value: ABUri,
+    count: 5,
+  }, {
+    value: ABUri,
     attrib: To,
     op: IsntInAB,
-    count: 5 },
-  { value: ABUri,
+    count: 5,
+  }, {
+    value: ABUri,
     attrib: ToOrCC,
     op: IsntInAB,
-    count: 6 },
-  { value: ABUri,
+    count: 6,
+  }, {
+    value: ABUri,
     attrib: AllAddresses,
     op: IsntInAB,
-    count: 7 },
-  { value: ABUri,
+    count: 7,
+  }, {
+    value: ABUri,
     attrib: CCopy,
     op: IsntInAB,
-    count: 4 },
-  { value: "PrimaryEmail1@test.invalid",
+    count: 4,
+  }, {
+    value: "PrimaryEmail1@test.invalid",
     attrib: AllAddresses,
     op: Is,
-    count: 8 },
-  { value: "PrimaryEmail1@test.invalid",
+    count: 8,
+  }, {
+    value: "PrimaryEmail1@test.invalid",
     attrib: AllAddresses,
     op: Isnt,
-    count: 0 },
-  { value: "invalid@example.com",
+    count: 0,
+  }, {
+    value: "invalid@example.com",
     attrib: AllAddresses,
     op: Is,
-    count: 7 },
-  { value: "invalid@example.com",
+    count: 7,
+  }, {
+    value: "invalid@example.com",
     attrib: AllAddresses,
     op: Isnt,
-    count: 1 },
-  { value: "PrimaryEmail1@test.invalid",
+    count: 1,
+  }, {
+    value: "PrimaryEmail1@test.invalid",
     attrib: ToOrCC,
     op: Is,
-    count: 6 },
-  { value: "PrimaryEmail1@test.invalid",
+    count: 6,
+  }, {
+    value: "PrimaryEmail1@test.invalid",
     attrib: ToOrCC,
     op: Isnt,
-    count: 2 },
-  { value: "invalid@example.com",
+    count: 2,
+  }, {
+    value: "invalid@example.com",
     attrib: ToOrCC,
     op: Is,
-    count: 6 },
-  { value: "invalid@example.com",
+    count: 6,
+  }, {
+    value: "invalid@example.com",
     attrib: ToOrCC,
     op: Isnt,
-    count: 2 },
-
+    count: 2,
+  }
 ];
 
-var Files =
-[
+var Files = [
   "../../../data/bugmail1",
   "../../../data/bugmail2",
   "../../../data/bugmail3",
   "../../../data/bugmail4",
   "../../../data/bugmail5",
   "../../../data/bugmail6",
   "../../../data/bugmail7",
-  "../../../data/bugmail8"
-]
+  "../../../data/bugmail8",
+];
 
-var messageKey, hdr;
-
-function run_test()
-{
+function run_test() {
   // Setup local mail accounts.
   localAccountUtils.loadLocalMailAccount();
 
     // Test setup - copy the data file into place
   var testAB = do_get_file("../../../addrbook/test/unit/data/cardForEmail.mab");
 
   // Copy the file to the profile directory for a PAB
   testAB.copyTo(do_get_profile(), kPABData.fileName);
@@ -257,48 +268,42 @@ function run_test()
   testValidityTable(news, IsBefore, Keywords, false);
 
   // Get a message into the local filestore. function testAbSearch() continues the testing after the copy.
   do_test_pending();
   copyListener.OnStopCopy(null);
   return true;
 }
 
-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) {
     var fileName = Files.shift();
-    if (fileName)
-    {
+    if (fileName) {
       var file = do_get_file(fileName);
       MailServices.copy.CopyFileMessage(file, localAccountUtils.inboxFolder, null,
                                         false, 0, "", copyListener, null);
+    } else {
+      testAbSearch();
     }
-    else
-      testAbSearch();
-  }
+  },
 };
 
 // Runs at completion of copy
 
 // process each test from queue, calls itself upon completion of each search
-var testObject;
-function testAbSearch()
-{
+function testAbSearch() {
   print("Test AbSearch");
   var test = Tests.shift();
-  if (test)
-  {
-    testObject = new TestSearch(localAccountUtils.inboxFolder,
-                         test.value,
-                         test.attrib,
-                         test.op,
-                         test.count,
-                         testAbSearch);
+  if (test) {
+    new TestSearch(localAccountUtils.inboxFolder,
+                   test.value,
+                   test.attrib,
+                   test.op,
+                   test.count,
+                   testAbSearch);
+  } else {
+    do_test_finished();
   }
-  else
-    do_test_finished();
 }
--- a/mailnews/base/test/unit/test_searchBody.js
+++ b/mailnews/base/test/unit/test_searchBody.js
@@ -1,41 +1,36 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * This tests various body search criteria.
  */
+/* import-globals-from ../../../test/resources/searchTestUtils.js */
 load("../../../resources/searchTestUtils.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var nsMsgSearchScope = Ci.nsMsgSearchScope;
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp = Ci.nsMsgSearchOp;
+var Isnt = Ci.nsMsgSearchOp.Isnt;
+var Is = Ci.nsMsgSearchOp.Is;
+var IsEmpty = Ci.nsMsgSearchOp.IsEmpty;
+var IsntEmpty = Ci.nsMsgSearchOp.IsntEmpty;
+var Contains = Ci.nsMsgSearchOp.Contains;
+var DoesntContain = Ci.nsMsgSearchOp.DoesntContain;
+var IsBefore = Ci.nsMsgSearchOp.IsBefore; // control entry not enabled
 
-var Isnt = nsMsgSearchOp.Isnt;
-var Is = nsMsgSearchOp.Is;
-var IsEmpty = nsMsgSearchOp.IsEmpty;
-var IsntEmpty = nsMsgSearchOp.IsntEmpty;
-var Contains = nsMsgSearchOp.Contains;
-var DoesntContain = nsMsgSearchOp.DoesntContain;
-var IsBefore = nsMsgSearchOp.IsBefore; // control entry not enabled
+var offlineMail = Ci.nsMsgSearchScope.offlineMail;
+var onlineMail = Ci.nsMsgSearchScope.onlineMail;
+var offlineMailFilter = Ci.nsMsgSearchScope.offlineMailFilter;
+var news = Ci.nsMsgSearchScope.news; // control entry not enabled
 
-var offlineMail = nsMsgSearchScope.offlineMail;
-var onlineMail = nsMsgSearchScope.onlineMail;
-var offlineMailFilter = nsMsgSearchScope.offlineMailFilter;
-var onlineMailFilter = nsMsgSearchScope.onlineMailFilter;
-var news = nsMsgSearchScope.news; // control entry not enabled
+var Body = Ci.nsMsgSearchAttrib.Body;
 
-var Body = nsMsgSearchAttrib.Body;
-
-var Files =
-[
+var Files = [
   "../../../data/base64-1",
   "../../../data/basic1",
   "../../../data/multipart-base64-2",
   "../../../data/bug132340",
   "../../../data/bad-charset.eml",
   "../../../data/HTML-with-split-tag1.eml",
   "../../../data/HTML-with-split-tag2.eml",
 
@@ -82,19 +77,18 @@ var Files =
   "../../../data/multipart-message-4.eml",  // plaintext+HTML, non-ASCII in HTML, has "bodyOfAttachedMessägeHTML"
 
   // Message using ISO-2022-JP and CTE: quoted-printable.
   "../../../data/iso-2022-jp-qp.eml",  // plaintext, has 日本 (Japan), we shouldn't find =1B$BF|K.
 
   // Message using ISO-2022-JP and 7bit, but containing something that looks like quoted-printable.
   // (bug 314637).
   "../../../data/iso-2022-jp-not-qp.eml",  // plaintext, has 現況 which contains =67.
-]
-var Tests =
-[
+];
+var Tests = [
   /* Translate Base64 messages */
   // "World!" is contained in three messages, but in bug132340 it's not in a text
   // part and should not be found.
   { value: "World!", op: Contains, count: 2 },
   /* Don't match the base64 text */
   { value: "DQp", op: Contains, count: 0 },
   /* Nested multipart/mixed, don't match */
   { value: "PGh", op: Contains, count: 0 },
@@ -191,38 +185,34 @@ function fixFile(file) {
   let ostream = Cc["@mozilla.org/network/file-output-stream;1"]
                   .createInstance(Ci.nsIFileOutputStream);
   ostream.init(targetFile, -1, -1, 0);
   ostream.write(data, data.length);
   ostream.close();
   return targetFile;
 }
 
-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) {
     var fileName = Files.shift();
-    if (fileName)
-    {
+    if (fileName) {
       var file = fixFile(do_get_file(fileName));
       MailServices.copy.CopyFileMessage(file, localAccountUtils.inboxFolder, null,
                                         false, 0, "", copyListener, null);
+    } else {
+      testBodySearch();
     }
-    else
-      testBodySearch();
-  }
+  },
 };
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   // test that validity table terms are valid
 
   // offline mail table
   testValidityTable(offlineMail, Contains, Body, true);
   testValidityTable(offlineMail, DoesntContain, Body, true);
   testValidityTable(offlineMail, Is, Body, true);
@@ -245,17 +235,17 @@ function run_test()
   testValidityTable(onlineMail, DoesntContain, Body, true);
   testValidityTable(onlineMail, Is, Body, false);
   testValidityTable(onlineMail, Isnt, Body, false);
   testValidityTable(onlineMail, IsEmpty, Body, false);
   testValidityTable(onlineMail, IsntEmpty, Body, false);
   testValidityTable(onlineMail, IsBefore, Body, false);
 
   // online mail filter
-  /*testValidityTable(onlineMailFilter, Contains, Body, true);
+  /* testValidityTable(onlineMailFilter, Contains, Body, true);
   testValidityTable(onlineMailFilter, DoesntContain, Body, true);
   testValidityTable(onlineMailFilter, Is, Body, false);
   testValidityTable(onlineMailFilter, Isnt, Body, false);
   testValidityTable(onlineMailFilter, IsEmpty, Body, false);
   testValidityTable(onlineMailFilter, IsntEmpty, Body, false);
   testValidityTable(onlineMailFilter, IsBefore, Body, false);*/
 
   // News does not support body tests
@@ -267,28 +257,22 @@ function run_test()
   testValidityTable(news, IsntEmpty, Body, false);
   testValidityTable(news, IsBefore, Body, false);
 
   do_test_pending();
   copyListener.OnStopCopy(null);
 }
 
 // process each test from queue, calls itself upon completion of each search
-var testObject;
-function testBodySearch()
-{
+function testBodySearch() {
   var test = Tests.shift();
-  if (test)
-  {
-    testObject = new TestSearch(localAccountUtils.inboxFolder,
-                         test.value,
-                         Body,
-                         test.op,
-                         test.count,
-                         testBodySearch);
-  }
-  else
-  {
-    testObject = null;
+  if (test) {
+    new TestSearch(localAccountUtils.inboxFolder,
+                   test.value,
+                   Body,
+                   test.op,
+                   test.count,
+                   testBodySearch);
+  } else {
     do_test_finished();
   }
 }
 
--- a/mailnews/base/test/unit/test_searchBoolean.js
+++ b/mailnews/base/test/unit/test_searchBoolean.js
@@ -8,113 +8,126 @@
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var gSearchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                         .createInstance(Ci.nsIMsgSearchSession);
 
 var gHdr; // the message header for the one mailbox message
 
-var Tests =
-[
-  { A: false,
+var Tests = [
+  {
+    A: false,
     B: false,
     C: false,
     D: false,
-    matches: false},
-  { A: false,
+    matches: false,
+  }, {
+    A: false,
     B: false,
     C: false,
     D: true,
-    matches: false},
-  { A: false,
+    matches: false,
+  }, {
+    A: false,
     B: false,
     C: true,
     D: false,
-    matches: false},
-  { A: false,
+    matches: false,
+  }, {
+    A: false,
     B: false,
     C: true,
     D: true,
-    matches: false},
-  { A: false,
+    matches: false,
+  }, {
+    A: false,
     B: true,
     C: false,
     D: false,
-    matches: false},
-  { A: false,
+    matches: false,
+  }, {
+    A: false,
     B: true,
     C: false,
     D: true,
-    matches: true},
-  { A: false,
+    matches: true,
+  }, {
+    A: false,
     B: true,
     C: true,
     D: false,
-    matches: true},
-  { A: false,
+    matches: true,
+  }, {
+    A: false,
     B: true,
     C: true,
     D: true,
-    matches: true},
-  { A: true,
+    matches: true,
+  }, {
+    A: true,
     B: false,
     C: false,
     D: false,
-    matches: false},
-  { A: true,
+    matches: false,
+  }, {
+    A: true,
     B: false,
     C: false,
     D: true,
-    matches: true},
-  { A: true,
+    matches: true,
+  }, {
+    A: true,
     B: false,
     C: true,
     D: false,
-    matches: true},
-  { A: true,
+    matches: true,
+  }, {
+    A: true,
     B: false,
     C: true,
     D: true,
-    matches: true},
-  { A: true,
+    matches: true,
+  }, {
+    A: true,
     B: true,
     C: false,
     D: false,
-    matches: false},
-  { A: true,
+    matches: false,
+  }, {
+    A: true,
     B: true,
     C: false,
     D: true,
-    matches: true},
-  { A: true,
+    matches: true,
+  }, {
+    A: true,
     B: true,
     C: true,
     D: false,
-    matches: true},
-  { A: true,
+    matches: true,
+  }, {
+    A: true,
     B: true,
     C: true,
     D: true,
-    matches: true},
+    matches: true,
+  },
 ];
 
 var gHitCount = 0;
-var searchListener =
-{
-  onSearchHit: function(dbHdr, folder) { gHitCount++; },
-  onSearchDone: function(status)
-  {
+var searchListener = {
+  onSearchHit(dbHdr, folder) { gHitCount++; },
+  onSearchDone(status) {
     testSearch();
   },
-  onNewSearch: function() {gHitCount = 0;}
+  onNewSearch() { gHitCount = 0; },
 };
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   /*
    * I want to create and test a search term that uses this expression:
    *   (A || B ) && (C || D)
    *
    * The logical expressions A, B, C, and D will be represented by header
    * string properties with values of T (true) or F (false).
@@ -144,52 +157,48 @@ function run_test()
                               localAccountUtils.inboxFolder);
   gSearchSession.registerListener(searchListener);
   // I tried using capital "A" but something makes it lower case internally, so it failed
   addSearchTerm("a", true, false, true);  // "(A"
   addSearchTerm("b", false, true, false); // " || B)"
   addSearchTerm("c", true, false, true);  // " && (C"
   addSearchTerm("d", false, true, false); // " || D)"
 
-  var copyListener =
-  {
-    OnStartCopy: function() {},
-    OnProgress: function(aProgress, aProgressMax) {},
-    SetMessageKey: function(aKey) {
+  var copyListener = {
+    OnStartCopy() {},
+    OnProgress(aProgress, aProgressMax) {},
+    SetMessageKey(aKey) {
       gHdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);
     },
-    SetMessageId: function(aMessageId) {},
-    OnStopCopy: function(aStatus) { testSearch();}
+    SetMessageId(aMessageId) {},
+    OnStopCopy(aStatus) { testSearch(); },
   };
 
   // Get a message into the local filestore. function testSearch() continues
   // the testing after the copy.
   var bugmail1 = do_get_file("../../../data/bugmail1");
   do_test_pending();
   MailServices.copy.CopyFileMessage(bugmail1, localAccountUtils.inboxFolder, null,
                                     false, 0, "", copyListener, null);
 }
 
 var gTest = null;
 // process each test from queue, calls itself upon completion of each search
-function testSearch()
-{
+function testSearch() {
   // tests the previous search
   if (gTest)
     Assert.equal(gHitCount, gTest.matches ? 1 : 0);
   gTest = Tests.shift();
-  if (gTest)
-  {
+  if (gTest) {
     gHdr.setStringProperty("a", gTest.A ? "T" : "F");
     gHdr.setStringProperty("b", gTest.B ? "T" : "F");
     gHdr.setStringProperty("c", gTest.C ? "T" : "F");
     gHdr.setStringProperty("d", gTest.D ? "T" : "F");
     try {
       gSearchSession.search(null);
+    } catch (e) {
+      dump(e);
     }
-    catch (e) {dump(e);}
-  }
-  else
-  {
+  } else {
     gSearchSession.unregisterListener(searchListener);
     do_test_finished();
   }
 }
--- a/mailnews/base/test/unit/test_searchChaining.js
+++ b/mailnews/base/test/unit/test_searchChaining.js
@@ -3,45 +3,30 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Test of chaining of search scopes in a search session. In particular,
 //  Bug 541969 made us not search an imap folder if the search scope before it
 // there was an empty local folder.
 
 // main test
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
 load("../../../resources/messageGenerator.js");
 
-var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 var {
   IMAPPump,
   setupIMAPPump,
   teardownIMAPPump,
 } = ChromeUtils.import("resource://testing-common/mailnews/IMAPpump.js");
 var {
-  imapDaemon,
-  imapMailbox,
   imapMessage,
-  IMAP_RFC3501_handler,
-  configurations,
-  mixinExtension,
-  IMAP_GMAIL_extension,
-  IMAP_MOVE_extension,
-  IMAP_CUSTOM_extension,
-  IMAP_RFC2197_extension,
-  IMAP_RFC2342_extension,
-  IMAP_RFC3348_extension,
-  IMAP_RFC4315_extension,
-  IMAP_RFC5258_extension,
-  IMAP_RFC2195_extension,
 } = ChromeUtils.import("resource://testing-common/mailnews/imapd.js");
 const {PromiseTestUtils} = ChromeUtils.import("resource://testing-common/mailnews/PromiseTestUtils.jsm");
 
-async function setupFolder()
-{
+async function setupFolder() {
   // add a single message to the imap inbox.
   let messages = [];
   let messageGenerator = new MessageGenerator();
   messages = messages.concat(messageGenerator.makeMessage());
   let synthMessage = messages[0];
 
   let msgURI =
     Services.io.newURI("data:text/plain;base64," +
@@ -50,18 +35,17 @@ async function setupFolder()
   IMAPPump.mailbox.addMessage(message);
 
   // update folder to download header.
   let listener = new PromiseTestUtils.PromiseUrlListener();
   IMAPPump.inbox.updateFolderWithListener(null, listener);
   await listener.promise;
 }
 
-async function searchTest()
-{
+async function searchTest() {
   // Get the IMAP inbox...
   var emptyLocal1 = localAccountUtils.rootFolder.createLocalSubfolder("empty 1");
 
   let searchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                         .createInstance(Ci.nsIMsgSearchSession);
 
   let searchTerm = searchSession.createTerm();
   searchTerm.matchAll = true;
@@ -74,38 +58,34 @@ async function searchTest()
   await listener.promise;
 
   // After the search completes, there still seem to be active URLs, so we
   //   have to wait before we are done and clear.
   await PromiseTestUtils.promiseDelay(1000);
 }
 
 // nsIMsgSearchNotify implementation
-var searchListener =
-{
+var searchListener = {
   numTotalMessages: 0,
   QueryInterface: ChromeUtils.generateQI([Ci.nsIMsgSearchNotify]),
-  onNewSearch: function()
-  {
+  onNewSearch() {
     this.numTotalMessages = 0;
   },
-  onSearchHit: function(dbHdr, folder)
-  {
+  onSearchHit(dbHdr, folder) {
     this.numTotalMessages++;
   },
-  onSearchDone: function(status)
-  {
+  onSearchDone(status) {
     Assert.equal(this.numTotalMessages, 1);
     return true;
-  }
+  },
 };
 
 var tests = [
   setupIMAPPump,
   setupFolder,
   searchTest,
-  teardownIMAPPump
+  teardownIMAPPump,
 ];
 
 function run_test() {
   tests.forEach(x => add_task(x));
   run_next_test();
 }
--- a/mailnews/base/test/unit/test_searchCustomTerm.js
+++ b/mailnews/base/test/unit/test_searchCustomTerm.js
@@ -1,108 +1,96 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Testing of custom search features.
  *
  */
+/* import-globals-from ../../../test/resources/searchTestUtils.js */
 load("../../../resources/searchTestUtils.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var kCustomId = "xpcomtest@mozilla.org#test";
 var gHdr;
 
-var Tests =
-[
-  { setValue: "iamgood",
+var Tests = [
+  {
+    setValue: "iamgood",
     testValue: "iamnotgood",
     op: Ci.nsMsgSearchOp.Is,
-    count: 0 },
-  { setValue: "iamgood",
+    count: 0,
+  }, {
+    setValue: "iamgood",
     testValue: "iamgood",
     op: Ci.nsMsgSearchOp.Is,
-    count: 1 }
-]
+    count: 1,
+  },
+];
 
 // nsIMsgSearchCustomTerm object
-var customTerm =
-{
+var customTerm = {
   id: kCustomId,
   name: "term name",
-  getEnabled: function(scope, op)
-    {
-      return scope == Ci.nsMsgSearchScope.offlineMail &&
-             op == Ci.nsMsgSearchOp.Is;
-    },
-  getAvailable: function(scope, op)
-    {
-      return scope == Ci.nsMsgSearchScope.offlineMail &&
-             op == Ci.nsMsgSearchOp.Is;
-    },
-  getAvailableOperators: function(scope, length)
-    {
-       length.value = 1;
-       return [Ci.nsMsgSearchOp.Is];
-    },
-  match: function(msgHdr, searchValue, searchOp)
-    {
-      switch (searchOp)
-      {
-        case Ci.nsMsgSearchOp.Is:
-          if (msgHdr.getProperty("theTestProperty") == searchValue)
-            return true;
-      }
-      return false;
+  getEnabled(scope, op) {
+    return scope == Ci.nsMsgSearchScope.offlineMail &&
+           op == Ci.nsMsgSearchOp.Is;
+  },
+  getAvailable(scope, op) {
+    return scope == Ci.nsMsgSearchScope.offlineMail &&
+           op == Ci.nsMsgSearchOp.Is;
+  },
+  getAvailableOperators(scope, length) {
+     length.value = 1;
+     return [Ci.nsMsgSearchOp.Is];
+  },
+  match(msgHdr, searchValue, searchOp) {
+    switch (searchOp) {
+      case Ci.nsMsgSearchOp.Is:
+        if (msgHdr.getProperty("theTestProperty") == searchValue)
+          return true;
     }
+    return false;
+  },
 };
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
   MailServices.filters.addCustomTerm(customTerm);
 
-  var copyListener =
-  {
-    OnStartCopy: function() {},
-    OnProgress: function(aProgress, aProgressMax) {},
-    SetMessageKey: function(aKey) {
+  var copyListener = {
+    OnStartCopy() {},
+    OnProgress(aProgress, aProgressMax) {},
+    SetMessageKey(aKey) {
       gHdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);
     },
-    SetMessageId: function(aMessageId) {},
-    OnStopCopy: function(aStatus) { doTest();}
+    SetMessageId(aMessageId) {},
+    OnStopCopy(aStatus) { doTest(); },
   };
 
   // Get a message into the local filestore.
   // function testSearch() continues the testing after the copy.
   let bugmail1 = do_get_file("../../../data/bugmail1");
   do_test_pending();
 
   MailServices.copy.CopyFileMessage(bugmail1, localAccountUtils.inboxFolder, null,
                                     false, 0, "", copyListener, null);
 }
 
-var testObject;
-
-function doTest()
-{
+function doTest() {
   let test = Tests.shift();
-  if (test)
-  {
+  if (test) {
     gHdr.setStringProperty("theTestProperty", test.setValue);
-    testObject = new TestSearch(localAccountUtils.inboxFolder,
-                         test.testValue,
-                         Ci.nsMsgSearchAttrib.Custom,
-                         test.op,
-                         test.count,
-                         doTest,
-                         kCustomId);
-  }
-  else
-  {
-    testObject = null;
+    new TestSearch(localAccountUtils.inboxFolder,
+                   test.testValue,
+                   Ci.nsMsgSearchAttrib.Custom,
+                   test.op,
+                   test.count,
+                   doTest,
+                   kCustomId);
+  } else {
     gHdr = null;
     do_test_finished();
   }
 }
 
--- a/mailnews/base/test/unit/test_searchJunk.js
+++ b/mailnews/base/test/unit/test_searchJunk.js
@@ -1,34 +1,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Testing of search by junk percent and junk score origin
 
+/* import-globals-from ../../../test/resources/searchTestUtils.js */
 load("../../../resources/searchTestUtils.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var nsMsgSearchScope = Ci.nsMsgSearchScope;
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp = Ci.nsMsgSearchOp;
+var IsGreaterThan = Ci.nsMsgSearchOp.IsGreaterThan;
+var IsLessThan = Ci.nsMsgSearchOp.IsLessThan;
+var Is = Ci.nsMsgSearchOp.Is;
+var Isnt = Ci.nsMsgSearchOp.Isnt;
+var IsEmpty = Ci.nsMsgSearchOp.IsEmpty;
+var IsntEmpty = Ci.nsMsgSearchOp.IsntEmpty;
 
-var IsGreaterThan = nsMsgSearchOp.IsGreaterThan;
-var IsLessThan = nsMsgSearchOp.IsLessThan;
-var Is = nsMsgSearchOp.Is;
-var Isnt = nsMsgSearchOp.Isnt;
-var IsEmpty = nsMsgSearchOp.IsEmpty;
-var IsntEmpty = nsMsgSearchOp.IsntEmpty;
+var offlineMail = Ci.nsMsgSearchScope.offlineMail;
 
-var offlineMail = nsMsgSearchScope.offlineMail;
-
-var JunkScoreOrigin = nsMsgSearchAttrib.JunkScoreOrigin;
-var JunkPercent = nsMsgSearchAttrib.JunkPercent;
-var JunkStatus = nsMsgSearchAttrib.JunkStatus;
+var JunkScoreOrigin = Ci.nsMsgSearchAttrib.JunkScoreOrigin;
+var JunkPercent = Ci.nsMsgSearchAttrib.JunkPercent;
+var JunkStatus = Ci.nsMsgSearchAttrib.JunkStatus;
 
 var fileName = "../../../data/bugmail1";
 
 /*
  * The search for junkpercent is defined as the effective value,
  * while the "junkpercent" database term is always the result
  * from the bayes filter. This is optimized to make views that
  * rely on junk percent search work with the best value for junk
@@ -36,186 +33,206 @@ var fileName = "../../../data/bugmail1";
  * to be saved for analysis.
  *
  * This means that the search for "junk percent" only uses the
  * database junkpercent value if junkscoreorigin is "plugin".
  * Otherwise, it uses junkstatus (if set) or defaults to 0
  * (not junk) if the message is unclassified.
  */
 
-var Tests =
-[
-  // test empty junk status
-  { junkScore: false,
+var Tests = [
+  {
+    // test empty junk status
+    junkScore: false,
     testValue: 90,
     attrib: JunkStatus,
     op: IsEmpty,
-    count: 1},
-  { junkScore: false,
+    count: 1,
+  }, {
+    junkScore: false,
     testValue: 90,
     attrib: JunkStatus,
     op: IsntEmpty,
-    count: 0},
-  { junkScore: "0",
+    count: 0,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "10",
     testValue: 90,
     attrib: JunkStatus,
     op: IsntEmpty,
-    count: 1},
-  { junkScore: "0",
+    count: 1,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "10",
     testValue: 90,
     attrib: JunkStatus,
     op: IsEmpty,
-    count: 0},
-  { junkScore: "100",
+    count: 0,
+  }, {
+    junkScore: "100",
     junkScoreOrigin: "plugin",
     junkPercent: "10",
     testValue: 90,
     attrib: JunkStatus,
     op: IsntEmpty,
-    count: 1},
-  { junkScore: "100",
+    count: 1,
+  }, {
+    junkScore: "100",
     junkScoreOrigin: "plugin",
     junkPercent: "10",
     testValue: 90,
     attrib: JunkStatus,
     op: IsEmpty,
-    count: 0},
-  // Use junkpercent from database
-  { junkScore: "0",
+    count: 0,
+  }, {
+    // Use junkpercent from database
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "10",
     testValue: 90,
     attrib: JunkPercent,
     op: IsGreaterThan,
-    count: 0},
-  { junkScore: "0",
+    count: 0,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "10",
     testValue: 90,
     attrib: JunkPercent,
     op: IsLessThan,
-    count: 1},
-  { junkScore: "0",
+    count: 1,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "10",
     testValue: 90,
     attrib: JunkPercent,
     op: Is,
-    count: 0},
-  { junkScore: "0",
+    count: 0,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "90",
     testValue: 10,
     attrib: JunkPercent,
     op: IsGreaterThan,
-    count: 1},
-  { junkScore: "0",
+    count: 1,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "90",
     testValue: 10,
     attrib: JunkPercent,
     op: IsLessThan,
-    count: 0},
-  { junkScore: "0",
+    count: 0,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "10",
     testValue: 10,
     attrib: JunkPercent,
     op: Is,
-    count: 1},
-
+    count: 1,
+  }, {
     // values set by user, use junkscore not junkpercent
-  { junkScore: "0",
+    junkScore: "0",
     junkScoreOrigin: "user",
     junkPercent: "90",
     testValue: 50,
     attrib: JunkPercent,
     op: IsGreaterThan,
-    count: 0},
-  { junkScore: "0",
+    count: 0,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "user",
     junkPercent: "90",
     testValue: 50,
     attrib: JunkPercent,
     op: IsLessThan,
-    count: 1},
-  { junkScore: "0",
+    count: 1,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "user",
     junkPercent: "90",
     testValue: 50,
     attrib: JunkPercent,
     op: Is,
-    count: 0},
-  { junkScore: "100",
+    count: 0,
+  }, {
+    junkScore: "100",
     junkScoreOrigin: "user",
     junkPercent: "10",
     testValue: 50,
     attrib: JunkPercent,
     op: IsGreaterThan,
-    count: 1},
-  { junkScore: "100",
+    count: 1,
+  }, {
+    junkScore: "100",
     junkScoreOrigin: "user",
     junkPercent: "10",
     testValue: 50,
     attrib: JunkPercent,
     op: IsLessThan,
-    count: 0},
-  { junkScore: "0",
+    count: 0,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "user",
     junkPercent: "90",
     testValue: 0,
     attrib: JunkPercent,
     op: Is,
-    count: 1},
+    count: 1,
+  }, {
     // default to 0 when nothing set
-  { junkScore: "",
+    junkScore: "",
     junkScoreOrigin: "",
     junkPercent: "",
     testValue: 0,
     attrib: JunkPercent,
     op: Is,
-    count: 1},
-
+    count: 1,
+  }, {
     // junkscoreorigin search tests
-  { junkScore: "0",
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "50",
     testValue: "plugin",
     attrib: JunkScoreOrigin,
     op: Is,
-    count: 1},
-  { junkScore: "0",
+    count: 1,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "plugin",
     junkPercent: "50",
     testValue: "plugin",
     attrib: JunkScoreOrigin,
     op: Isnt,
-    count: 0},
-  { junkScore: "0",
+    count: 0,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "filter",
     junkPercent: "50",
     testValue: "plugin",
     attrib: JunkScoreOrigin,
     op: Is,
-    count: 0},
-  { junkScore: "0",
+    count: 0,
+  }, {
+    junkScore: "0",
     junkScoreOrigin: "filter",
     junkPercent: "50",
     testValue: "plugin",
     attrib: JunkScoreOrigin,
     op: Isnt,
-    count: 1},
+    count: 1,
+  },
 ];
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   // test that validity table terms are valid
 
   // offline mail table
   testValidityTable(offlineMail, Is, JunkPercent, true);
   testValidityTable(offlineMail, Isnt, JunkPercent, false);
   testValidityTable(offlineMail, IsGreaterThan, JunkPercent, true);
@@ -230,46 +247,38 @@ function run_test()
   do_test_pending();
   var file = do_get_file(fileName);
   MailServices.copy.CopyFileMessage(file, localAccountUtils.inboxFolder, null, false, 0,
                                     "", copyListener, null);
   return true;
 }
 
 var hdr;
-var copyListener =
-{
-  OnStartCopy: function() {},
-  OnProgress: function(aProgress, aProgressMax) {},
-  SetMessageKey: function(aKey) { hdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);},
-  SetMessageId: function(aMessageId) {},
-  OnStopCopy: function(aStatus) { testJunkSearch();}
+var copyListener = {
+  OnStartCopy() {},
+  OnProgress(aProgress, aProgressMax) {},
+  SetMessageKey(aKey) { hdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey); },
+  SetMessageId(aMessageId) {},
+  OnStopCopy(aStatus) { testJunkSearch(); },
 };
 
 // Runs at completion of each copy
 // process each test from queue, calls itself upon completion of each search
-var testObject;
-function testJunkSearch()
-{
+function testJunkSearch() {
   var test = Tests.shift();
-  if (test)
-  {
-    if (test.junkScore)
-    {
+  if (test) {
+    if (test.junkScore) {
       hdr.setStringProperty("junkpercent", test.junkPercent);
       hdr.setStringProperty("junkscoreorigin", test.junkScoreOrigin);
       hdr.setStringProperty("junkscore", test.junkScore);
     }
 
-    testObject = new TestSearch(localAccountUtils.inboxFolder,
-                         test.testValue,
-                         test.attrib,
-                         test.op,
-                         test.count,
-                         testJunkSearch);
-  }
-  else
-  {
-    testObject = null;
+    new TestSearch(localAccountUtils.inboxFolder,
+                   test.testValue,
+                   test.attrib,
+                   test.op,
+                   test.count,
+                   testJunkSearch);
+  } else {
     hdr = null;
     do_test_finished();
   }
 }
--- a/mailnews/base/test/unit/test_searchLocalizationStrings.js
+++ b/mailnews/base/test/unit/test_searchLocalizationStrings.js
@@ -1,59 +1,52 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
  // tests that localization strings added in bug 484147 are defined in preferences
 
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-var gValidityManager = Cc['@mozilla.org/mail/search/validityManager;1']
+var gValidityManager = Cc["@mozilla.org/mail/search/validityManager;1"]
                            .getService(Ci.nsIMsgSearchValidityManager);
 
 var gStringBundle = Services.strings
                               .createBundle("chrome://messenger/locale/search-attributes.properties");
 
 // The following table of valid table scopes matches the allowable table
 // scopes in nsMsgSearchValidityManager::GetTable
-var kValidScopes =
-[
+var kValidScopes = [
   Ci.nsMsgSearchScope.offlineMail,
   Ci.nsMsgSearchScope.offlineMailFilter,
   Ci.nsMsgSearchScope.onlineMail,
   Ci.nsMsgSearchScope.onlineMailFilter,
   Ci.nsMsgSearchScope.news,
   Ci.nsMsgSearchScope.newsFilter,
   Ci.nsMsgSearchScope.localNews,
   Ci.nsMsgSearchScope.LDAP,
   Ci.nsMsgSearchScope.LDAPAnd,
   Ci.nsMsgSearchScope.LocalAB,
-  Ci.nsMsgSearchScope.LocalABAnd
+  Ci.nsMsgSearchScope.LocalABAnd,
 ];
 
-function run_test()
-{
-  for (var index = 0; index < kValidScopes.length; ++index)
-  {
+function run_test() {
+  for (var index = 0; index < kValidScopes.length; ++index) {
     let scope = kValidScopes[index];
     let table = gValidityManager.getTable(scope);
     let attributes = table.getAvailableAttributes({});
     let attribute;
-    while ((attribute = attributes.pop()) && attribute)
-    {
+    while ((attribute = attributes.pop()) && attribute) {
       let property = gValidityManager.getAttributeProperty(attribute);
       let valid = false;
       let localizedString;
-      try
-      {
+      try {
         localizedString = gStringBundle.GetStringFromName(property);
         valid = true;
-      }
-      catch (e)
-      {
+      } catch (e) {
         dump("\n" + e);
       }
       valid = valid && localizedString && (localizedString.length > 0);
       if (!valid)
         dump("\nNo valid property for scope = " + scope
               + " attribute = " + attribute
               + " property = " + property);
       Assert.ok(valid);
--- a/mailnews/base/test/unit/test_searchTag.js
+++ b/mailnews/base/test/unit/test_searchTag.js
@@ -4,287 +4,344 @@
 
 /*
  * Testing of tag search features.
  *
  * Specifically tests changes implemented in bug 217034
  * Does not do comprehensive testing.
  *
  */
+/* import-globals-from ../../../test/resources/searchTestUtils.js */
 load("../../../resources/searchTestUtils.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var nsMsgSearchScope = Ci.nsMsgSearchScope;
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp = Ci.nsMsgSearchOp;
+var Isnt = Ci.nsMsgSearchOp.Isnt;
+var Is = Ci.nsMsgSearchOp.Is;
+var IsEmpty = Ci.nsMsgSearchOp.IsEmpty;
+var IsntEmpty = Ci.nsMsgSearchOp.IsntEmpty;
+var Contains = Ci.nsMsgSearchOp.Contains;
+var DoesntContain = Ci.nsMsgSearchOp.DoesntContain;
+var IsBefore = Ci.nsMsgSearchOp.IsBefore; // control entry not enabled
 
-var Isnt = nsMsgSearchOp.Isnt;
-var Is = nsMsgSearchOp.Is;
-var IsEmpty = nsMsgSearchOp.IsEmpty;
-var IsntEmpty = nsMsgSearchOp.IsntEmpty;
-var Contains = nsMsgSearchOp.Contains;
-var DoesntContain = nsMsgSearchOp.DoesntContain;
-var IsBefore = nsMsgSearchOp.IsBefore; // control entry not enabled
+var offlineMail = Ci.nsMsgSearchScope.offlineMail;
+var onlineMail = Ci.nsMsgSearchScope.onlineMail;
+var offlineMailFilter = Ci.nsMsgSearchScope.offlineMailFilter;
+var onlineMailFilter = Ci.nsMsgSearchScope.onlineMailFilter;
+var news = Ci.nsMsgSearchScope.news; // control entry not enabled
 
-var offlineMail = nsMsgSearchScope.offlineMail;
-var onlineMail = nsMsgSearchScope.onlineMail;
-var offlineMailFilter = nsMsgSearchScope.offlineMailFilter;
-var onlineMailFilter = nsMsgSearchScope.onlineMailFilter;
-var news = nsMsgSearchScope.news; // control entry not enabled
-
-var Keywords = nsMsgSearchAttrib.Keywords;
+var Keywords = Ci.nsMsgSearchAttrib.Keywords;
 
 // test tags
 var Tag1 = "istag";
 var Tag2 = "notistag";
 var Tag3 = "istagnot";
 var Tag4 = "istagtoo";
 var Tag1Tag4 = Tag1 + " " + Tag4;
 var Tag1Tag3 = Tag1 + " " + Tag3;
 var Tag1Tag1 = Tag1 + " " + Tag1;
 
-var Tests =
-[
-// Message has a single valid tag
+var Tests = [
+  // Message has a single valid tag
   // test the valid tag
-  { msgTag: Tag1,
+  {
+    msgTag: Tag1,
     testTag: Tag1,
     op: Is,
-    count: 1 },
-  { msgTag: Tag1,
+    count: 1,
+  }, {
+    msgTag: Tag1,
     testTag: Tag1,
     op: Isnt,
-    count: 0 },
-  { msgTag: Tag1,
+    count: 0,
+  }, {
+    msgTag: Tag1,
     testTag: Tag1,
     op: Contains,
-    count: 1 },
-  { msgTag: Tag1,
+    count: 1,
+  }, {
+    msgTag: Tag1,
     testTag: Tag1,
     op: DoesntContain,
-    count: 0 },
-  { msgTag: Tag1,
+    count: 0,
+  }, {
+    msgTag: Tag1,
     testTag: Tag1,
     op: IsEmpty,
-    count: 0 },
-  { msgTag: Tag1,
+    count: 0,
+  }, {
+    msgTag: Tag1,
     testTag: Tag1,
     op: IsntEmpty,
-    count: 1 },
-  //test an invalid tag, should act like empty
-  { msgTag: Tag2,
+    count: 1,
+  },
+  // test an invalid tag, should act like empty
+  {
+    msgTag: Tag2,
     testTag: Tag1,
     op: Contains,
-    count: 0 },
-  { msgTag: Tag2,
+    count: 0,
+  }, {
+    msgTag: Tag2,
     testTag: Tag1,
     op: DoesntContain,
-    count: 1 },
-  { msgTag: Tag2,
+    count: 1,
+  }, {
+    msgTag: Tag2,
     testTag: Tag1,
     op: Is,
-    count: 0 },
-  { msgTag: Tag2,
+    count: 0,
+  }, {
+    msgTag: Tag2,
     testTag: Tag1,
     op: Isnt,
-    count: 1 },
-  { msgTag: Tag2,
+    count: 1,
+  }, {
+    msgTag: Tag2,
     testTag: Tag1,
     op: IsEmpty,
-    count: 1 },
-  { msgTag: Tag2,
+    count: 1,
+  }, {
+    msgTag: Tag2,
     testTag: Tag1,
     op: IsntEmpty,
-    count: 0 },
-//   Message has two valid tags
+    count: 0,
+  },
+  // Message has two valid tags
   // test first tag
-  { msgTag: Tag1Tag4,
+  {
+    msgTag: Tag1Tag4,
     testTag: Tag1,
     op: Is,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag1,
     op: Isnt,
-    count: 1 },
-  { msgTag: Tag1Tag4,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag1,
     op: Contains,
-    count: 1 },
-  { msgTag: Tag1Tag4,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag1,
     op: DoesntContain,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag1,
     op: IsEmpty,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag1,
     op: IsntEmpty,
-    count: 1 },
+    count: 1,
+  },
   // test second tag
-  { msgTag: Tag1Tag4,
+  {
+    msgTag: Tag1Tag4,
     testTag: Tag4,
     op: Is,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag4,
     op: Isnt,
-    count: 1 },
-  { msgTag: Tag1Tag4,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag4,
     op: Contains,
-    count: 1 },
-  { msgTag: Tag1Tag4,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag4,
     op: DoesntContain,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag4,
     op: IsEmpty,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag4,
     op: IsntEmpty,
-    count: 1 },
+    count: 1,
+  },
   // test tag not in message
-  { msgTag: Tag1Tag4,
+  {
+    msgTag: Tag1Tag4,
     testTag: Tag2,
     op: Is,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag2,
     op: Isnt,
-    count: 1 },
-  { msgTag: Tag1Tag4,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag2,
     op: Contains,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag2,
     op: DoesntContain,
-    count: 1 },
-  { msgTag: Tag1Tag4,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag2,
     op: IsEmpty,
-    count: 0 },
-  { msgTag: Tag1Tag4,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag4,
     testTag: Tag2,
     op: IsntEmpty,
-    count: 1 },
+    count: 1,
+  },
   // empty message
-  { msgTag: "",
+  {
+    msgTag: "",
     testTag: Tag2,
     op: Is,
-    count: 0 },
-  { msgTag: "",
+    count: 0,
+  }, {
+    msgTag: "",
     testTag: Tag2,
     op: Isnt,
-    count: 1 },
-  { msgTag: "",
+    count: 1,
+  }, {
+    msgTag: "",
     testTag: Tag2,
     op: Contains,
-    count: 0 },
-  { msgTag: "",
+    count: 0,
+  }, {
+    msgTag: "",
     testTag: Tag2,
     op: DoesntContain,
-    count: 1 },
-  { msgTag: "",
+    count: 1,
+  }, {
+    msgTag: "",
     testTag: Tag2,
     op: IsEmpty,
-    count: 1 },
-  { msgTag: "",
+    count: 1,
+  }, {
+    msgTag: "",
     testTag: Tag2,
     op: IsntEmpty,
-    count: 0 },
-// message with two tags, only one is valid
+    count: 0,
+  },
+  // message with two tags, only one is valid
   // test with the single valid tag
-  { msgTag: Tag1Tag3,
+  {
+    msgTag: Tag1Tag3,
     testTag: Tag1,
     op: Is,
-    count: 1 },
-  { msgTag: Tag1Tag3,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag1,
     op: Isnt,
-    count: 0 },
-  { msgTag: Tag1Tag3,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag1,
     op: Contains,
-    count: 1 },
-  { msgTag: Tag1Tag3,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag1,
     op: DoesntContain,
-    count: 0 },
-  { msgTag: Tag1Tag3,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag1,
     op: IsEmpty,
-    count: 0 },
-  { msgTag: Tag1Tag3,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag1,
     op: IsntEmpty,
-    count: 1 },
+    count: 1,
+  },
   // test with a tag not in the message
-  { msgTag: Tag1Tag3,
+  {
+    msgTag: Tag1Tag3,
     testTag: Tag2,
     op: Is,
-    count: 0 },
-  { msgTag: Tag1Tag3,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag2,
     op: Isnt,
-    count: 1 },
-  { msgTag: Tag1Tag3,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag2,
     op: Contains,
-    count: 0 },
-  { msgTag: Tag1Tag3,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag2,
     op: DoesntContain,
-    count: 1 },
-  { msgTag: Tag1Tag3,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag2,
     op: IsEmpty,
-    count: 0 },
-  { msgTag: Tag1Tag3,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag3,
     testTag: Tag2,
     op: IsntEmpty,
-    count: 1 },
-//   Message has a duplicated tag
+    count: 1,
+  },
+  // Message has a duplicated tag
   // test the tag
-  { msgTag: Tag1Tag1,
+  {
+    msgTag: Tag1Tag1,
     testTag: Tag1,
     op: Is,
-    count: 1 },
-  { msgTag: Tag1Tag1,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag1,
     testTag: Tag1,
     op: Isnt,
-    count: 0 },
-  { msgTag: Tag1Tag1,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag1,
     testTag: Tag1,
     op: Contains,
-    count: 1 },
-  { msgTag: Tag1Tag1,
+    count: 1,
+  }, {
+    msgTag: Tag1Tag1,
     testTag: Tag1,
     op: DoesntContain,
-    count: 0 },
-  { msgTag: Tag1Tag1,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag1,
     testTag: Tag1,
     op: IsEmpty,
-    count: 0 },
-  { msgTag: Tag1Tag1,
+    count: 0,
+  }, {
+    msgTag: Tag1Tag1,
     testTag: Tag1,
     op: IsntEmpty,
-    count: 1 },
-
+    count: 1,
+  },
 ];
 
 var hdr;
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
   // test that validity table terms are valid
 
   // offline mail table
   testValidityTable(offlineMail, Contains, Keywords, true);
   testValidityTable(offlineMail, DoesntContain, Keywords, true);
   testValidityTable(offlineMail, Is, Keywords, true);
@@ -333,49 +390,42 @@ function run_test()
   let tagArray = MailServices.tags.getAllTags({});
   for (var i = 0; i < tagArray.length; i++)
     MailServices.tags.deleteKey(tagArray[i].key);
 
   // add as valid tags Tag1 and Tag4
   MailServices.tags.addTagForKey(Tag1, Tag1, null, null);
   MailServices.tags.addTagForKey(Tag4, Tag4, null, null);
 
-  var copyListener =
-  {
-    OnStartCopy: function() {},
-    OnProgress: function(aProgress, aProgressMax) {},
-    SetMessageKey: function(aKey) {
+  var copyListener = {
+    OnStartCopy() {},
+    OnProgress(aProgress, aProgressMax) {},
+    SetMessageKey(aKey) {
       hdr = localAccountUtils.inboxFolder.GetMessageHeader(aKey);
     },
-    SetMessageId: function(aMessageId) {},
-    OnStopCopy: function(aStatus) { testKeywordSearch();}
+    SetMessageId(aMessageId) {},
+    OnStopCopy(aStatus) { testKeywordSearch(); },
   };
 
   // Get a message into the local filestore. function testKeywordSearch() continues the testing after the copy.
   var bugmail1 = do_get_file("../../../data/bugmail1");
   do_test_pending();
   MailServices.copy.CopyFileMessage(bugmail1, localAccountUtils.inboxFolder, null,
                                     false, 0, "", copyListener, null);
 }
 
 // process each test from queue, calls itself upon completion of each search
-var testObject;
-function testKeywordSearch()
-{
+function testKeywordSearch() {
   var test = Tests.shift();
-  if (test)
-  {
+  if (test) {
     hdr.setStringProperty("keywords", test.msgTag);
-    testObject = new TestSearch(localAccountUtils.inboxFolder,
-                         test.testTag,
-                         nsMsgSearchAttrib.Keywords,
-                         test.op,
-                         test.count,
-                         testKeywordSearch);
-  }
-  else
-  {
-    testObject = null;
+    new TestSearch(localAccountUtils.inboxFolder,
+                   test.testTag,
+                   Ci.nsMsgSearchAttrib.Keywords,
+                   test.op,
+                   test.count,
+                   testKeywordSearch);
+  } else {
     hdr = null;
     do_test_finished();
   }
 }
 
--- a/mailnews/base/test/unit/test_searchUint32HdrProperty.js
+++ b/mailnews/base/test/unit/test_searchUint32HdrProperty.js
@@ -1,119 +1,118 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Testing of Uint32HdrProperty search attribute. Adapted from test_search.js
  */
 
+/* import-globals-from ../../../test/resources/searchTestUtils.js */
 load("../../../resources/searchTestUtils.js");
 
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp = Ci.nsMsgSearchOp;
+var Isnt = Ci.nsMsgSearchOp.Isnt;
+var Is = Ci.nsMsgSearchOp.Is;
+var IsGreaterThan = Ci.nsMsgSearchOp.IsGreaterThan;
+var IsLessThan = Ci.nsMsgSearchOp.IsLessThan;
 
-var Isnt = nsMsgSearchOp.Isnt;
-var Is = nsMsgSearchOp.Is;
-var IsGreaterThan = nsMsgSearchOp.IsGreaterThan;
-var IsLessThan = nsMsgSearchOp.IsLessThan;
-
-var Uint32HdrProperty = nsMsgSearchAttrib.Uint32HdrProperty;
-
-var Tests =
-[
+var Tests = [
   // test a property that does not exist
-  { hdrProperty: "idonotexist",
+  {
+    hdrProperty: "idonotexist",
     op: Is,
     value: 1,
-    count: 0 },
-  { hdrProperty: "idonotexist",
+    count: 0,
+  }, {
+    hdrProperty: "idonotexist",
     op: Isnt,
     value: 1,
-    count: 1 },
+    count: 1,
+  },
   // add a property and test its value
-  { setup: function setupProperty() {
+  {
+    setup: function setupProperty() {
       let enumerator = localAccountUtils.inboxFolder.msgDatabase.EnumerateMessages();
-      while(enumerator.hasMoreElements())
+      while (enumerator.hasMoreElements())
         enumerator.getNext().QueryInterface(Ci.nsIMsgDBHdr).setUint32Property("iam23", 23);
     },
     hdrProperty: "iam23",
     op: Is,
     value: 23,
-    count: 1 },
-  { hdrProperty: "iam23",
+    count: 1,
+  }, {
+    hdrProperty: "iam23",
     op: Isnt,
     value: 23,
-    count: 0 },
-  { hdrProperty: "iam23",
+    count: 0,
+  }, {
+    hdrProperty: "iam23",
     op: Is,
     value: 17,
-    count: 0 },
-  { hdrProperty: "iam23",
+    count: 0,
+  }, {
+    hdrProperty: "iam23",
     op: Isnt,
     value: 17,
-    count: 1 },
-  { hdrProperty: "iam23",
+    count: 1,
+  }, {
+    hdrProperty: "iam23",
     op: IsGreaterThan,
     value: 25,
-    count: 0 },
-  { hdrProperty: "iam23",
+    count: 0,
+  }, {
+    hdrProperty: "iam23",
     op: IsLessThan,
     value: 25,
-    count: 1 },
-  { hdrProperty: "iam23",
+    count: 1,
+  }, {
+    hdrProperty: "iam23",
     op: IsGreaterThan,
     value: 17,
-    count: 1 },
-  { hdrProperty: "iam23",
+    count: 1,
+  }, {
+    hdrProperty: "iam23",
     op: IsLessThan,
     value: 17,
-    count: 0 },
+    count: 0,
+  },
 ];
 
-function run_test()
-{
+function run_test() {
   localAccountUtils.loadLocalMailAccount();
 
-  var copyListener =
-  {
-    OnStartCopy: function() {},
-    OnProgress: function(aProgress, aProgressMax) {},
-    SetMessageKey: function(aKey) {},
-    SetMessageId: function(aMessageId) {},
-    OnStopCopy: function(aStatus) { testSearch();}
+  var copyListener = {
+    OnStartCopy() {},
+    OnProgress(aProgress, aProgressMax) {},
+    SetMessageKey(aKey) {},
+    SetMessageId(aMessageId) {},
+    OnStopCopy(aStatus) { testSearch(); },
   };
 
   // Get a message into the local filestore. function testSearch() continues
   // the testing after the copy.
   var bugmail1 = do_get_file("../../../data/bugmail1");
   do_test_pending();
   MailServices.copy.CopyFileMessage(bugmail1, localAccountUtils.inboxFolder, null,
                                     false, 0, "", copyListener, null);
 }
 
 // process each test from queue, calls itself upon completion of each search
-var testObject;
-function testSearch()
-{
+function testSearch() {
   var test = Tests.shift();
-  if (test)
-  {
+  if (test) {
     if (test.setup)
       test.setup();
-    testObject = new TestSearch(localAccountUtils.inboxFolder,
-                         test.value,
-                         nsMsgSearchAttrib.Uint32HdrProperty,
-                         test.op,
-                         test.count,
-                         testSearch,
-                         null,
-                         null,
-                         test.hdrProperty);
-  }
-  else
-  {
-    testObject = null;
+    new TestSearch(localAccountUtils.inboxFolder,
+                   test.value,
+                   Ci.nsMsgSearchAttrib.Uint32HdrProperty,
+                   test.op,
+                   test.count,
+                   testSearch,
+                   null,
+                   null,
+                   test.hdrProperty);
+  } else {
     do_test_finished();
   }
 }
--- a/mailnews/base/test/unit/test_testsuite_base64.js
+++ b/mailnews/base/test/unit/test_testsuite_base64.js
@@ -2,22 +2,21 @@
  * Tests functions atob() and btoa() in mailnews/test/resources/mailTestUtils.js .
  *
  * Note:
  * btoa() = base64 encode
  * atob() = base64 decode
  * (i.e. "binary" = plain, and "ascii" = encoded)
  */
 
-function run_test()
-{
+function run_test() {
   var plain = "testtesttest";
   var encoded = "dGVzdHRlc3R0ZXN0";
 
   // correct encoding according to spec
   Assert.equal(btoa(plain), encoded); // encode
   Assert.equal(atob(encoded), plain); // decode
 
   // roundtrip works
   Assert.equal(atob(btoa(plain)), plain);
   Assert.equal(btoa(atob(encoded)), encoded);
   return true;
-};
+}
--- a/mailnews/base/test/unit/test_testsuite_fakeserverAuth.js
+++ b/mailnews/base/test/unit/test_testsuite_fakeserverAuth.js
@@ -4,59 +4,55 @@
  * fakeserver.
  *
  * Do NOT essentially re-code the auth schemes here,
  * just check roundtrips, against static values etc..
  */
 
 var {
   AuthPLAIN,
-  AuthLOGIN,
   AuthCRAM,
 } = ChromeUtils.import("resource://testing-common/mailnews/auth.js");
 
 var kUsername = "fred1";
 var kPassword = "wilma2";
 
-function run_test()
-{
+function run_test() {
   authPLAIN();
   authCRAMMD5();
   return true;
-};
+}
 
 /**
  * Test AUTH PLAIN
  */
-function authPLAIN()
-{
+function authPLAIN() {
   // roundtrip works
   var line = AuthPLAIN.encodeLine(kUsername, kPassword);
   var req = AuthPLAIN.decodeLine(line);
   Assert.equal(req.username, kUsername);
   Assert.equal(req.password, kPassword);
 
   // correct encoding
   Assert.equal(line, "AGZyZWQxAHdpbG1hMg==");
-};
+}
 
 /**
  * Test AUTH CRAM-MD5
  */
-function authCRAMMD5()
-{
+function authCRAMMD5() {
   // AuthCRAM.createChallenge() creates a different challenge each time
   var hardcodedChallenge = btoa("<123@fake.invalid>");
   var hardcodedResponse = "ZnJlZDEgOTA5YjgwMmM3NTI5NTJlYzI2NjgyMTNmYTdjNWU0ZjQ=";
 
   // correct encoding
   var req = AuthCRAM.decodeLine(hardcodedResponse);
   Assert.equal(req.username, kUsername);
   var expectedDigest = AuthCRAM.encodeCRAMMD5(hardcodedChallenge, kPassword);
   Assert.equal(req.digest, expectedDigest);
 
   var challenge = AuthCRAM.createChallenge("fake.invalid");
   challenge = atob(challenge); // decode. function currently returns it already encoded
   var challengeSplit = challenge.split("@");
   Assert.equal(challengeSplit.length, 2);
   Assert.equal(challengeSplit[1], "fake.invalid>");
   Assert.equal(challengeSplit[0][0], "<");
-};
+}
--- a/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_gmail.js
+++ b/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_gmail.js
@@ -2,16 +2,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Test that imapd.js fakeserver correctly emulates GMail server
 // That means X-GM-EXT-1 capability and GMail flavor XLIST
 // per https://developers.google.com/google-apps/gmail/imap_extensions
 
 // async support
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/alertTestUtils.js");
 
 // IMAP pump
 var {
   IMAPPump,
   setupIMAPPump,
@@ -24,74 +27,58 @@ var {Services} = ChromeUtils.import("res
 setupIMAPPump("GMail");
 // create our own handler so that we can call imapd functions directly
 var handler;
 
 // Definition of tests
 var tests = [
   setupMailboxes,
   testXlist,
-  endTest
-]
+  endTest,
+];
 
 // mbox mailboxes cannot contain both child mailboxes and messages, so this will
 // be one test case.
-function* setupMailboxes()
-{
+function* setupMailboxes() {
   IMAPPump.mailbox.specialUseFlag = "\\Inbox";
-  IMAPPump.daemon.createMailbox("[Gmail]", {flags : ["\\Noselect"]});
-  IMAPPump.daemon.createMailbox("[Gmail]/All Mail", {specialUseFlag : "\\AllMail"});
-  IMAPPump.daemon.createMailbox("[Gmail]/Drafts", {specialUseFlag : "\\Drafts"});
-  IMAPPump.daemon.createMailbox("[Gmail]/Sent", {specialUseFlag : "\\Sent"});
-  IMAPPump.daemon.createMailbox("[Gmail]/Spam", {specialUseFlag : "\\Spam"});
-  IMAPPump.daemon.createMailbox("[Gmail]/Starred", {specialUseFlag : "\\Starred"});
-  IMAPPump.daemon.createMailbox("[Gmail]/Trash", {specialUseFlag : "\\Trash"});
+  IMAPPump.daemon.createMailbox("[Gmail]", {flags: ["\\Noselect"]});
+  IMAPPump.daemon.createMailbox("[Gmail]/All Mail", {specialUseFlag: "\\AllMail"});
+  IMAPPump.daemon.createMailbox("[Gmail]/Drafts", {specialUseFlag: "\\Drafts"});
+  IMAPPump.daemon.createMailbox("[Gmail]/Sent", {specialUseFlag: "\\Sent"});
+  IMAPPump.daemon.createMailbox("[Gmail]/Spam", {specialUseFlag: "\\Spam"});
+  IMAPPump.daemon.createMailbox("[Gmail]/Starred", {specialUseFlag: "\\Starred"});
+  IMAPPump.daemon.createMailbox("[Gmail]/Trash", {specialUseFlag: "\\Trash"});
   IMAPPump.daemon.createMailbox("test", {});
 
   handler = IMAPPump.server._handlerCreator(IMAPPump.daemon);
-  let response = handler.onError('1', 'LOGIN user password');
-  Assert.ok(response.includes('OK'));
+  let response = handler.onError("1", "LOGIN user password");
+  Assert.ok(response.includes("OK"));
   // wait for imap pump to do its thing or else we get memory leaks
   IMAPPump.inbox.updateFolderWithListener(null, asyncUrlListener);
   yield false;
 }
 
 // test that 'XLIST "" "*"' returns the proper responses
-function* testXlist()
-{
-  let response = handler.onError('2', 'XLIST "" "*"');
+function* testXlist() {
+  let response = handler.onError("2", 'XLIST "" "*"');
 
   Assert.ok(response.includes('* LIST (\\HasNoChildren \\Inbox) "/" "INBOX"'));
   Assert.ok(response.includes('* LIST (\\Noselect \\HasChildren) "/" "[Gmail]"'));
   Assert.ok(response.includes('* LIST (\\HasNoChildren \\AllMail) "/" "[Gmail]/All Mail"'));
   Assert.ok(response.includes('* LIST (\\HasNoChildren \\Drafts) "/" "[Gmail]/Drafts"'));
   Assert.ok(response.includes('* LIST (\\HasNoChildren \\Sent) "/" "[Gmail]/Sent"'));
   Assert.ok(response.includes('* LIST (\\HasNoChildren \\Spam) "/" "[Gmail]/Spam"'));
   Assert.ok(response.includes('* LIST (\\HasNoChildren \\Starred) "/" "[Gmail]/Starred"'));
   Assert.ok(response.includes('* LIST (\\HasNoChildren \\Trash) "/" "[Gmail]/Trash"'));
   Assert.ok(response.includes('* LIST (\\HasNoChildren) "/" "test"'));
 
   yield true;
 }
 
 // Cleanup at end
-function endTest()
-{
+function endTest() {
   teardownIMAPPump();
 }
 
-function run_test()
-{
+function run_test() {
   Services.prefs.setBoolPref("mail.server.server1.autosync_offline_stores", false);
   async_run_tests(tests);
 }
-
-/*
- * helper functions
- */
-
-function recursiveDeleteMailboxes(aMailbox)
-{
-  for (var child of aMailbox.allChildren) {
-    recursiveDeleteMailboxes(child);
-  }
-  IMAPPump.daemon.deleteMailbox(aMailbox);
-}
--- a/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_list-extended.js
+++ b/mailnews/base/test/unit/test_testsuite_fakeserver_imapd_list-extended.js
@@ -1,16 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Test that imapd.js fakeserver correctly implements LIST-EXTENDED imap
 // extension (RFC 5258 - http://tools.ietf.org/html/rfc5258)
 
 // async support
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
+/* import-globals-from ../../../test/resources/alertTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/alertTestUtils.js");
 
 // IMAP pump
 var {
   IMAPPump,
   setupIMAPPump,
@@ -30,147 +33,126 @@ var handler;
 // Definition of tests
 var tests = [
   setupMailboxes,
   testList,
   testListSelectSubscribed,
   testListReturnChilderen,
   testListReturnSubscribed,
   testListSelectMultiple,
-  endTest
-]
+  endTest,
+];
 
 // mbox mailboxes cannot contain both child mailboxes and messages, so this will
 // be one test case.
-function* setupMailboxes()
-{
+function* setupMailboxes() {
   IMAPPump.mailbox.flags = ["\\Marked", "\\NoInferiors"];
   IMAPPump.mailbox.subscribed = true;
   IMAPPump.daemon.createMailbox("Fruit", {});
   IMAPPump.daemon.createMailbox("Fruit/Apple", {});
-  IMAPPump.daemon.createMailbox("Fruit/Banana", {subscribed : true});
-  IMAPPump.daemon.createMailbox("Fruit/Peach", {nonExistent : true,
-                                            subscribed : true});
+  IMAPPump.daemon.createMailbox("Fruit/Banana", {subscribed: true});
+  IMAPPump.daemon.createMailbox("Fruit/Peach", {nonExistent: true, subscribed: true});
   IMAPPump.daemon.createMailbox("Tofu", {});
-  IMAPPump.daemon.createMailbox("Vegetable", {subscribed : true});
-  IMAPPump.daemon.createMailbox("Vegetable/Broccoli", {subscribed : true});
+  IMAPPump.daemon.createMailbox("Vegetable", {subscribed: true});
+  IMAPPump.daemon.createMailbox("Vegetable/Broccoli", {subscribed: true});
   IMAPPump.daemon.createMailbox("Vegetable/Corn", {});
 
   handler = IMAPPump.server._handlerCreator(IMAPPump.daemon);
-  let response = handler.onError('1', 'LOGIN user password');
-  Assert.ok(response.includes('OK'));
+  let response = handler.onError("1", "LOGIN user password");
+  Assert.ok(response.includes("OK"));
   // wait for imap pump to do it's thing or else we get memory leaks
   IMAPPump.inbox.updateFolderWithListener(null, asyncUrlListener);
   yield false;
 }
 
 // test that 'LIST "" "*"' returns the proper responses (standard LIST usage)
-function* testList()
-{
-  let response = handler.onError('2', 'LIST "" "*"');
+function* testList() {
+  let response = handler.onError("2", 'LIST "" "*"');
 
   Assert.ok(response.includes('* LIST (\\Marked \\NoInferiors) "/" "INBOX"'));
   Assert.ok(response.includes('* LIST () "/" "Fruit"'));
   Assert.ok(response.includes('* LIST () "/" "Fruit/Apple"'));
   Assert.ok(response.includes('* LIST () "/" "Fruit/Banana"'));
   Assert.ok(response.includes('* LIST () "/" "Tofu"'));
   Assert.ok(response.includes('* LIST () "/" "Vegetable"'));
   Assert.ok(response.includes('* LIST () "/" "Vegetable/Broccoli"'));
   Assert.ok(response.includes('* LIST () "/" "Vegetable/Corn"'));
-  Assert.ok(!response.includes('Peach'));
+  Assert.ok(!response.includes("Peach"));
 
   yield true;
 }
 
 // test that 'LIST (SUBSCRIBED) "" "*"' returns the proper responses
-function* testListSelectSubscribed()
-{
-  let response = handler.onError('3', 'LIST (SUBSCRIBED) "" "*"');
+function* testListSelectSubscribed() {
+  let response = handler.onError("3", 'LIST (SUBSCRIBED) "" "*"');
 
   Assert.ok(response.includes('* LIST (\\Marked \\NoInferiors \\Subscribed) "/" "INBOX"'));
   Assert.ok(response.includes('* LIST (\\Subscribed) "/" "Fruit/Banana"'));
   Assert.ok(response.includes('* LIST (\\Subscribed \\NonExistent) "/" "Fruit/Peach"'));
   Assert.ok(response.includes('* LIST (\\Subscribed) "/" "Vegetable"'));
   Assert.ok(response.includes('* LIST (\\Subscribed) "/" "Vegetable/Broccoli"'));
   Assert.ok(!response.includes('"Fruit"'));
-  Assert.ok(!response.includes('Apple'));
-  Assert.ok(!response.includes('Tofu'));
-  Assert.ok(!response.includes('Corn'));
+  Assert.ok(!response.includes("Apple"));
+  Assert.ok(!response.includes("Tofu"));
+  Assert.ok(!response.includes("Corn"));
 
   yield true;
 }
 
 // test that 'LIST "" "%" RETURN (CHILDEREN)' returns the proper responses
-function* testListReturnChilderen()
-{
-  let response = handler.onError('4', 'LIST "" "%" RETURN (CHILDREN)');
+function* testListReturnChilderen() {
+  let response = handler.onError("4", 'LIST "" "%" RETURN (CHILDREN)');
 
   Assert.ok(response.includes('* LIST (\\Marked \\NoInferiors) "/" "INBOX"'));
   Assert.ok(response.includes('* LIST (\\HasChildren) "/" "Fruit"'));
   Assert.ok(response.includes('* LIST (\\HasNoChildren) "/" "Tofu"'));
   Assert.ok(response.includes('* LIST (\\HasChildren) "/" "Vegetable"'));
-  Assert.ok(!response.includes('Apple'));
-  Assert.ok(!response.includes('Banana'));
-  Assert.ok(!response.includes('Peach'));
-  Assert.ok(!response.includes('Broccoli'));
-  Assert.ok(!response.includes('Corn'));
+  Assert.ok(!response.includes("Apple"));
+  Assert.ok(!response.includes("Banana"));
+  Assert.ok(!response.includes("Peach"));
+  Assert.ok(!response.includes("Broccoli"));
+  Assert.ok(!response.includes("Corn"));
 
   yield true;
 }
 
 // test that 'LIST "" "*" RETURN (SUBSCRIBED)' returns the proper responses
-function* testListReturnSubscribed()
-{
-  let response = handler.onError('5', 'LIST "" "*" RETURN (SUBSCRIBED)');
+function* testListReturnSubscribed() {
+  let response = handler.onError("5", 'LIST "" "*" RETURN (SUBSCRIBED)');
 
   Assert.ok(response.includes('* LIST (\\Marked \\NoInferiors \\Subscribed) "/" "INBOX"'));
   Assert.ok(response.includes('* LIST () "/" "Fruit"'));
   Assert.ok(response.includes('* LIST () "/" "Fruit/Apple"'));
   Assert.ok(response.includes('* LIST (\\Subscribed) "/" "Fruit/Banana"'));
   Assert.ok(response.includes('* LIST () "/" "Tofu"'));
   Assert.ok(response.includes('* LIST (\\Subscribed) "/" "Vegetable"'));
   Assert.ok(response.includes('* LIST (\\Subscribed) "/" "Vegetable/Broccoli"'));
   Assert.ok(response.includes('* LIST () "/" "Vegetable/Corn"'));
-  Assert.ok(!response.includes('Peach'));
+  Assert.ok(!response.includes("Peach"));
 
   yield true;
 }
 
 // test that 'LIST "" ("INBOX" "Tofu" "Vegetable/%")' returns the proper responses
-function* testListSelectMultiple()
-{
-  let response = handler._dispatchCommand('LIST', ['', '("INBOX" "Tofu" "Vegetable/%")']);
+function* testListSelectMultiple() {
+  let response = handler._dispatchCommand("LIST", ["", '("INBOX" "Tofu" "Vegetable/%")']);
 
   Assert.ok(response.includes('* LIST (\\Marked \\NoInferiors) "/" "INBOX"'));
   Assert.ok(response.includes('* LIST () "/" "Tofu"'));
   Assert.ok(response.includes('* LIST () "/" "Vegetable/Broccoli"'));
   Assert.ok(response.includes('* LIST () "/" "Vegetable/Corn"'));
   Assert.ok(!response.includes('"Vegetable"'));
-  Assert.ok(!response.includes('Fruit'));
-  Assert.ok(!response.includes('Peach'));
+  Assert.ok(!response.includes("Fruit"));
+  Assert.ok(!response.includes("Peach"));
 
   yield true;
 }
 
 // Cleanup at end
-function endTest()
-{
+function endTest() {
   handler = null;
   teardownIMAPPump();
 }
 
-function run_test()
-{
+function run_test() {
   Services.prefs.setBoolPref("mail.server.server1.autosync_offline_stores", false);
   async_run_tests(tests);
 }
-
-/*
- * helper functions
- */
-
-function recursiveDeleteMailboxes(aMailbox)
-{
-  for (var child of aMailbox.allChildren) {
-    recursiveDeleteMailboxes(child);
-  }
-  IMAPPump.daemon.deleteMailbox(aMailbox);
-}
--- a/mailnews/base/test/unit/test_viewSortByAddresses.js
+++ b/mailnews/base/test/unit/test_viewSortByAddresses.js
@@ -1,26 +1,31 @@
 /*
  * Attempt to test nsMsgDBView's handling of sorting by sender/recipients
  * when using a display name from the address book.
  */
 
+/* import-globals-from ../../../test/resources/logHelper.js */
+/* import-globals-from ../../../test/resources/asyncTestUtils.js */
 load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 
+/* import-globals-from ../../../test/resources/messageGenerator.js */
+/* import-globals-from ../../../test/resources/messageModifier.js */
+/* import-globals-from ../../../test/resources/messageInjection.js */
+/* import-globals-from ../../../test/resources/abSetup.js */
 load("../../../resources/messageGenerator.js");
 load("../../../resources/messageModifier.js");
 load("../../../resources/messageInjection.js");
 load("../../../resources/abSetup.js");
 
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var {MailServices} = ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var gMessageGenerator = new MessageGenerator();
-var gScenarioFactory = new MessageScenarioFactory(gMessageGenerator);
 
 Services.prefs.setBoolPref("mail.showCondensedAddresses", true);
 
 var gTestFolder;
 
 // Setup the display name to be opposite of alphabetic order of e-mail address.
 var cards = [
   { email: "aaa@b.invalid", displayName: "4" },
@@ -58,65 +63,61 @@ function run_test() {
 
   let msgSet = new SyntheticMessageSet(messages);
 
   do_test_pending();
 
   gTestFolder = make_empty_folder();
   add_sets_to_folders(gTestFolder, [msgSet]);
   // - create the view
-  setup_view("threaded", ViewFlags.kNone);
+  setup_view("threaded", Ci.nsMsgViewFlagsType.kNone);
   // Check that sorting by sender uses the display name
-  gDBView.sort(SortType.byAuthor, SortOrder.ascending);
+  gDBView.sort(Ci.nsMsgViewSortType.byAuthor, Ci.nsMsgViewSortOrder.ascending);
   let sender1 = gDBView.cellTextForColumn(0, "senderCol");
   let sender2 = gDBView.cellTextForColumn(1, "senderCol");
 
   if (sender1 != 2)
     view_throw("expected sender 1 to be 2");
   if (sender2 != 4)
     view_throw("expected sender 2 to be 4");
 
-  gDBView.sort(SortType.byRecipient, SortOrder.ascending);
+  gDBView.sort(Ci.nsMsgViewSortType.byRecipient, Ci.nsMsgViewSortOrder.ascending);
   let recip1 = gDBView.cellTextForColumn(0, "recipientCol");
   let recip2 = gDBView.cellTextForColumn(1, "recipientCol");
 
   if (recip1 != 1)
     view_throw("expected recip 1 to be 1");
   if (recip2 != 3)
     view_throw("expected recip 2 to be 3");
 
   do_test_finished();
 }
 
 var gCommandUpdater = {
-  updateCommandStatus : function()
-  {
+  updateCommandStatus() {
     // the back end is smart and is only telling us to update command status
     // when the # of items in the selection has actually changed.
   },
 
-  displayMessageChanged : function(aFolder, aSubject, aKeywords)
-  {
+  displayMessageChanged(aFolder, aSubject, aKeywords) {
   },
 
-  updateNextMessageAfterDelete : function()
-  {
+  updateNextMessageAfterDelete() {
   },
-  summarizeSelection : function() {return false;}
+  summarizeSelection() { return false; },
 };
 
 var WHITESPACE = "                                              ";
 /**
  * Print out the current db view as best we can.
  */
 function dump_view_contents() {
   dump("********* Current View State\n");
   for (let iViewIndex = 0; iViewIndex < gTreeView.rowCount; iViewIndex++) {
     let level = gTreeView.getLevel(iViewIndex);
-    let viewFlags = gDBView.viewFlags;
     let flags = gDBView.getFlagsAt(iViewIndex);
 
     let s = WHITESPACE.substr(0, level * 2);
     if (gTreeView.isContainer(iViewIndex))
       s += gTreeView.isContainerOpen(iViewIndex) ? "- " : "+ ";
     else
       s += ". ";
     let MSG_VIEW_FLAG_DUMMY = 0x20000000;
@@ -132,35 +133,30 @@ function dump_view_contents() {
 
 function view_throw(why) {
   dump_view_contents();
   do_throw(why);
 }
 var gDBView;
 var gTreeView;
 
-var ViewType = Ci.nsMsgViewType;
-var SortType = Ci.nsMsgViewSortType;
-var SortOrder = Ci.nsMsgViewSortOrder;
-var ViewFlags = Ci.nsMsgViewFlagsType;
-
 function setup_view(aViewType, aViewFlags, aTestFolder) {
   let dbviewContractId = "@mozilla.org/messenger/msgdbview;1?type=" + aViewType;
 
   if (aTestFolder == null)
     aTestFolder = gTestFolder;
 
   // always start out fully expanded
-  aViewFlags |= ViewFlags.kExpandAll;
+  aViewFlags |= Ci.nsMsgViewFlagsType.kExpandAll;
 
   gDBView = Cc[dbviewContractId]
               .createInstance(Ci.nsIMsgDBView);
   gDBView.init(null, null, gCommandUpdater);
   var outCount = {};
   gDBView.open(aViewType != "search" ? aTestFolder : null,
-               SortType.byDate,
-               aViewType != "search" ? SortOrder.ascending : SortOrder.descending,
+               Ci.nsMsgViewSortType.byDate,
+               aViewType != "search" ? Ci.nsMsgViewSortOrder.ascending : Ci.nsMsgViewSortOrder.descending,
                aViewFlags, outCount);
   dump("  View Out Count: " + outCount.value + "\n");
 
   gTreeView = gDBView.QueryInterface(Ci.nsITreeView);
 }