Bug 1490448 - fix problems found by JS strict mode in MozMill tests. r=jorgk CLOSED TREE
authoraceman <acelists@atlas.sk>
Mon, 17 Sep 2018 12:52:00 +0200
changeset 33175 4769902c580ea46024026dba447f5a256ef66114
parent 33174 2977f7b7b8d661f1bd377786f3add1c1aa551d80
child 33176 03d79b0cf04825ec9cd17a9d254df09f74bf1e71
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersjorgk
bugs1490448
Bug 1490448 - fix problems found by JS strict mode in MozMill tests. r=jorgk CLOSED TREE
mail/test/mozmill/account/test-account-actions.js
mail/test/mozmill/account/test-account-tree.js
mail/test/mozmill/account/test-account-values.js
mail/test/mozmill/addrbook/test-address-book-panes.js
mail/test/mozmill/addrbook/test-address-book.js
mail/test/mozmill/attachment/test-attachment-size.js
mail/test/mozmill/attachment/test-attachment.js
mail/test/mozmill/composition/test-address-widgets.js
mail/test/mozmill/composition/test-drafts.js
mail/test/mozmill/composition/test-forward-headers.js
mail/test/mozmill/composition/test-forwarded-content.js
mail/test/mozmill/composition/test-save-changes-on-quit.js
mail/test/mozmill/content-tabs/test-plugin-crashing.js
mail/test/mozmill/downloads/test-about-downloads.js
mail/test/mozmill/folder-display/test-message-size.js
mail/test/mozmill/folder-display/test-pane-focus.js
mail/test/mozmill/folder-display/test-right-click-middle-click-folders.js
mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js
mail/test/mozmill/folder-display/test-savedsearch-reload-after-compact.js
mail/test/mozmill/folder-display/test-tooltip-multimessage.js
mail/test/mozmill/folder-pane/test-folder-pane.js
mail/test/mozmill/folder-tree-modes/test-custom-smart-folder.js
mail/test/mozmill/folder-tree-modes/test-mode-switching.js
mail/test/mozmill/folder-tree-modes/test-smart-folders.js
mail/test/mozmill/folder-widget/test-message-filters.js
mail/test/mozmill/instrumentation/test-instrument-setup.js
mail/test/mozmill/message-header/test-reply-identity.js
mail/test/mozmill/message-header/test-reply-to-list-from-address-selection.js
mail/test/mozmill/newmailaccount/test-newmailaccount.js
mail/test/mozmill/session-store/test-session-store.js
mail/test/mozmill/shared-modules/test-content-tab-helpers.js
mail/test/mozmill/shared-modules/test-folder-display-helpers.js
mail/test/mozmill/shared-modules/test-newmailaccount-helpers.js
mail/test/mozmill/shared-modules/test-nntp-helpers.js
mail/test/resources/mozmill/mozmill/extension/content/stdlib/httpd.js
--- a/mail/test/mozmill/account/test-account-actions.js
+++ b/mail/test/mozmill/account/test-account-actions.js
@@ -97,26 +97,27 @@ function subtest_check_account_actions(a
   close_popup(amc, amc.eid("accountActionsDropdown"));
 }
 
 function test_account_actions() {
   // IMAP account: can be default, can be removed.
   open_advanced_settings(function(amc) {
     subtest_check_account_actions(amc, imapAccount.key, true, true, true);
   });
+
   // NNTP (News) account: can't be default, can be removed.
   open_advanced_settings(function(amc) {
     subtest_check_account_actions(amc, nntpAccount.key, false, true, true);
   });
+
   // Local Folders account: can't be removed, can't be default.
-  localFoldersAccount = MailServices.accounts.FindAccountForServer(MailServices.accounts.localFoldersServer);
+  var localFoldersAccount = MailServices.accounts.FindAccountForServer(MailServices.accounts.localFoldersServer);
   open_advanced_settings(function(amc) {
     subtest_check_account_actions(amc, localFoldersAccount.key, false, false, true);
   });
-
   // SMTP server row: can't be removed, can't be default.
   open_advanced_settings(function(amc) {
     subtest_check_account_actions(amc, null, false, false, true);
   });
 
   // on the IMAP account, disable Delete Account menu item
   let disableItemPref = "mail.disable_button.delete_account";
 
--- a/mail/test/mozmill/account/test-account-tree.js
+++ b/mail/test/mozmill/account/test-account-tree.js
@@ -169,12 +169,12 @@ function subtest_check_selection_after_a
 
   // Remove our account.
   remove_account(gPopAccount, amc);
   // Now there should be only the original accounts left.
   assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
 
   // See if the currently selected account is the one next in the account list.
   let accountTree = amc.e("accounttree");
-  accountRow = accountTree.view.selection.currentIndex;
+  let accountRow = accountTree.view.selection.currentIndex;
   assert_equals(accountTree.view.getItemAtIndex(accountRow)._account,
                 accountList[accountIndex + 1]);
 }
--- a/mail/test/mozmill/account/test-account-values.js
+++ b/mail/test/mozmill/account/test-account-values.js
@@ -104,17 +104,17 @@ function subtest_check_default_CC_addres
  */
 function test_account_name() {
   // We already have a POP account ready.
   // Create also a NNTP server.
   let nntpServer = MailServices.accounts
     .createIncomingServer(null, "example.nntp.invalid", "nntp")
     .QueryInterface(Ci.nsINntpIncomingServer);
 
-  identity = MailServices.accounts.createIdentity();
+  let identity = MailServices.accounts.createIdentity();
   identity.email = "tinderbox2@example.invalid";
 
   let nntpAccount = MailServices.accounts.createAccount();
   nntpAccount.incomingServer = nntpServer;
   nntpAccount.addIdentity(identity);
 
   assert_equals(gPopAccount.incomingServer.prettyName, "nobody on example.invalid");
   assert_equals(nntpAccount.incomingServer.prettyName, "example.nntp.invalid");
--- a/mail/test/mozmill/addrbook/test-address-book-panes.js
+++ b/mail/test/mozmill/addrbook/test-address-book-panes.js
@@ -8,16 +8,18 @@
 
 "use strict";
 
 var MODULE_NAME = "test-address-book-panes";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["address-book-helpers", "folder-display-helpers"];
 
+var abController;
+
 function setupModule(module) {
   // We need this to get mc which is needed in open_address_book_window.
   let fdh = collector.getModule("folder-display-helpers");
   fdh.installInto(module);
   let abh = collector.getModule("address-book-helpers");
   abh.installInto(module);
 
   // Open the address book main window
--- a/mail/test/mozmill/addrbook/test-address-book.js
+++ b/mail/test/mozmill/addrbook/test-address-book.js
@@ -6,44 +6,33 @@
  * Tests for the address book.
  */
 
 "use strict";
 
 var MODULE_NAME = 'test-address-book';
 
 var RELATIVE_ROOT = '../shared-modules';
-var MODULE_REQUIRES = ['address-book-helpers', 'folder-display-helpers',
+var MODULE_REQUIRES = ["folder-display-helpers", "address-book-helpers",
                        'compose-helpers', 'window-helpers',
                        'prompt-helpers'];
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var abController = null;
-var addrBook1, addrBook2, addrBook3, addrBook4;
+var addrBook1, addrBook2, addrBook3, addrBook4, ldapBook;
 var mListA, mListB, mListC, mListD, mListE;
-var windowHelper;
 
 function setupModule(module)
 {
-  let fdh = collector.getModule('folder-display-helpers');
-  fdh.installInto(module);
-
-  let abh = collector.getModule('address-book-helpers');
-  abh.installInto(module);
-
-  let ch = collector.getModule('compose-helpers');
-  ch.installInto(module);
-
-  let ph = collector.getModule('prompt-helpers');
-  ph.installInto(module);
-
-  windowHelper = collector.getModule('window-helpers');
+  for (let lib of MODULE_REQUIRES) {
+    collector.getModule(lib).installInto(module);
+  }
 
   // Open the address book main window
   abController = open_address_book_window();
 
   // Let's add some new address books.  I'll add them
   // out of order to properly test the alphabetical
   // ordering of the address books.
   ldapBook = create_ldap_address_book("LDAP Book");
@@ -122,30 +111,30 @@ function test_persist_collapsed_and_expa
 {
   // Set the state of address books 1 and 3 to expanded
   set_address_books_expanded([addrBook1, addrBook3]);
 
   // Set address book 2 to be collapsed
   set_address_book_collapsed(addrBook2);
 
   // Now close and re-open the address book
-  abController.window.close();
+  close_address_book_window(abController);
   abController = open_address_book_window();
 
   assert_true(is_address_book_collapsed(addrBook2));
   assert_true(!is_address_book_collapsed(addrBook1));
   assert_true(!is_address_book_collapsed(addrBook3));
 
   // Now set the state of address books 1 and 3 to collapsed
   // and make sure 2 is expanded
   set_address_books_collapsed([addrBook1, addrBook3]);
   set_address_book_expanded(addrBook2);
 
   // Now close and re-open the address book
-  abController.window.close();
+  close_address_book_window(abController);
   abController = open_address_book_window();
 
   assert_true(!is_address_book_collapsed(addrBook2));
   assert_true(is_address_book_collapsed(addrBook1));
   assert_true(is_address_book_collapsed(addrBook3));
 }
 
 /* Test that if we try to delete a contact, that we are given
@@ -348,17 +337,17 @@ function test_writing_to_mailing_list() 
   // Now select the mailing list in the tree...
   select_address_book(addedList);
 
   // Focus it...
   abController.window.gDirTree.focus();
 
   // Assuming we've made it this far, now we just plan for the compose
   // window...
-  windowHelper.plan_for_new_window("msgcompose");
+  plan_for_new_window("msgcompose");
   // ... and click the "Write" button
   abController.click(abController.eid("button-newmessage"));
   let composeWin = wait_for_compose_window(abController);
   let to = composeWin.window.gMsgCompose.compFields.to;
 
   // Make sure we're writing to all contacts in the mailing list.
   for (let contact of contacts) {
     assert_true(to.includes(contact.primaryEmail));
--- a/mail/test/mozmill/attachment/test-attachment-size.js
+++ b/mail/test/mozmill/attachment/test-attachment-size.js
@@ -326,20 +326,18 @@ function check_total_attachment_size(cou
  * @param index the index of the message to check in the thread pane
  */
 function help_test_attachment_size(index) {
   be_in_folder(folder);
   let curMessage = select_click_row(index);
 
   let expectedSizes = messages[index].attachmentSizes;
   for (let i = 0; i < expectedSizes.length; i++) {
-    if(expectedSizes[i] == null) {
-      unknownSize = true;
+    if (expectedSizes[i] == null)
       check_no_attachment_size(i);
-    }
     else
       check_attachment_size(i, expectedSizes[i]);
   }
 
   let totalSize = messages[index].attachmentTotalSize;
   check_total_attachment_size(expectedSizes.length, totalSize.size,
                               totalSize.exact);
 }
--- a/mail/test/mozmill/attachment/test-attachment.js
+++ b/mail/test/mozmill/attachment/test-attachment.js
@@ -16,16 +16,17 @@ var MODULE_REQUIRES = ['folder-display-h
 
 var elib = {};
 ChromeUtils.import("chrome://mozmill/content/modules/elementslib.js", elib);
 var EventUtils = {};
 ChromeUtils.import("chrome://mozmill/content/stdlib/EventUtils.js", EventUtils);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var folder;
+var messages;
 
 var textAttachment =
   "One of these days... people like me will rise up and overthrow you, and " +
   "the end of tyranny by the homeostatic machine will have arrived. The day " +
   "of human values and compassion and simple warmth will return, and when " +
   "that happens someone like myself who has gone through an ordeal and who " +
   "genuinely needs hot coffee to pick him up and keep him functioning when " +
   "he has to function will get the hot coffee whether he happens to have a " +
--- a/mail/test/mozmill/composition/test-address-widgets.js
+++ b/mail/test/mozmill/composition/test-address-widgets.js
@@ -12,26 +12,30 @@ var MODULE_NAME = "test-address-widgets"
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers", "compose-helpers",
                          "window-helpers"];
 
 var cwc = null; // compose window controller
 var accountPOP3 = null;
 var accountNNTP = null;
+var originalAccountCount;
 
 function setupModule(module) {
   for (let lib of MODULE_REQUIRES) {
     collector.getModule(lib).installInto(module);
   }
 
   // Ensure we're in the tinderbox account as that has the right identities set
   // up for this test.
   let server = MailServices.accounts.FindServer("tinderbox", FAKE_SERVER_HOSTNAME, "pop3");
   accountPOP3 = MailServices.accounts.FindAccountForServer(server);
+
+  // There may be pre-existing accounts from other tests.
+  originalAccountCount = MailServices.accounts.allServers.length;
 };
 
 function teardownModule(module) {
 }
 
 /**
  * Check if the address type items are in the wished state.
  *
@@ -62,25 +66,22 @@ function check_mail_address_types() {
  * With a NNTP account, all address types should be enabled.
  */
 function check_nntp_address_types() {
   check_address_types_state(["addr_to", "addr_cc", "addr_reply", "addr_bcc",
                              "addr_newsgroups", "addr_followup"]);
 }
 
 function add_NNTP_account() {
-  // There may be pre-existing accounts from other tests.
-  originalAccountCount = MailServices.accounts.allServers.length;
-
   // Create a NNTP server
   let nntpServer = MailServices.accounts
     .createIncomingServer(null, "example.nntp.invalid", "nntp")
     .QueryInterface(Ci.nsINntpIncomingServer);
 
-  identity = MailServices.accounts.createIdentity();
+  let identity = MailServices.accounts.createIdentity();
   identity.email = "tinderbox2@example.invalid";
 
   accountNNTP = MailServices.accounts.createAccount();
   accountNNTP.incomingServer = nntpServer;
   accountNNTP.addIdentity(identity);
   // Now there should be 1 more account.
   assert_equals(MailServices.accounts.allServers.length, originalAccountCount + 1);
 }
--- a/mail/test/mozmill/composition/test-drafts.js
+++ b/mail/test/mozmill/composition/test-drafts.js
@@ -90,19 +90,19 @@ function internal_check_delivery_format(
 
   setup_msg_contents(cwc, "test@example.invalid",
                      "Testing storing of the composition properties in the draft!",
                      "Hello!");
 
   // Select our wanted format.
   if (!mc.mozmillModule.isMac) {
     cwc.click(cwc.eid("optionsMenu"));
-    formatMenu = cwc.click_menus_in_sequence(cwc.e("optionsMenuPopup"),
-                                             [ { id: "outputFormatMenu" },
-                                               { id: "format_both" } ]);
+    cwc.click_menus_in_sequence(cwc.e("optionsMenuPopup"),
+                                [ { id: "outputFormatMenu" },
+                                  { id: "format_both" } ]);
   } else {
     // On OS X the main menu seems not accessible for clicking from mozmill.
     assert_true(cwc.e("outputFormatMenu").getAttribute("oncommand").startsWith("OutputFormatMenuSelect("));
     cwc.window.OutputFormatMenuSelect(cwc.e("format_both"));
   }
 
   /**
    * Check if the right format is selected in the menu.
--- a/mail/test/mozmill/composition/test-forward-headers.js
+++ b/mail/test/mozmill/composition/test-forward-headers.js
@@ -12,33 +12,32 @@
 var MODULE_NAME = "test-forward-headers";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers", "compose-helpers", "window-helpers",
                          "message-helpers"];
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-var composeHelper = null;
 var cwc = null; // compose window controller
 var folder;
 var gDrafts;
 
 var setupModule = function (module) {
   let fdh = collector.getModule("folder-display-helpers");
   fdh.installInto(module);
-  composeHelper = collector.getModule("compose-helpers");
+  let composeHelper = collector.getModule("compose-helpers");
   composeHelper.installInto(module);
   let wh = collector.getModule("window-helpers");
   wh.installInto(module);
   let mh = collector.getModule("message-helpers");
   mh.installInto(module);
 
   folder = create_folder("Test");
-  thread1 = create_thread(10);
+  let thread1 = create_thread(10);
   add_sets_to_folders([folder], [thread1]);
 
   gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
 
   // Don't create paragraphs in the test.
   // The test checks for the first DOM node and expects a text and not
   // a paragraph.
   Services.prefs.setBoolPref("mail.compose.default_to_paragraph", false);
--- a/mail/test/mozmill/composition/test-forwarded-content.js
+++ b/mail/test/mozmill/composition/test-forwarded-content.js
@@ -9,34 +9,24 @@
 "use strict";
 
 var MODULE_NAME = "test-forwarded-content";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers",
                          "window-helpers", "compose-helpers"];
 
-var elib = {};
-ChromeUtils.import("chrome://mozmill/content/modules/elementslib.js", elib);
-
-var folderHelper = null;
-var windowindowHelperelper = null;
-var composeHelper = null;
-
 var folder = null;
 
-var setupModule = function(module) {
-  folderHelper = collector.getModule("folder-display-helpers");
-  folderHelper.installInto(module);
-  windowHelper = collector.getModule("window-helpers");
-  windowHelper.installInto(module);
-  composeHelper = collector.getModule("compose-helpers");
-  composeHelper.installInto(module);
+function setupModule(module) {
+  for (let lib of MODULE_REQUIRES) {
+    collector.getModule(lib).installInto(module);
+  }
 
-  folder = folderHelper.create_folder("Forward Content Testing");
+  folder = create_folder("Forward Content Testing");
   add_message_to_folder(folder, create_message({
     subject: "something like <foo@example>",
     body: {body: "Testing bug 397021!"},
   }));
 }
 
 /**
  * Test that the subject is set properly in the forwarded message content
--- a/mail/test/mozmill/composition/test-save-changes-on-quit.js
+++ b/mail/test/mozmill/composition/test-save-changes-on-quit.js
@@ -123,17 +123,17 @@ function test_can_quit_on_changes() {
 
   // Set the Mock Prompt Service to return true, so that we're
   // allowing the quit to occur.
   gMockPromptService.returnValue = DONT_SAVE;
 
   // Trigger the quit-application-request notification
   Services.obs.notifyObservers(cancelQuit, "quit-application-requested");
 
-  promptState = gMockPromptService.promptState;
+  let promptState = gMockPromptService.promptState;
   assert_not_equals(null, promptState, "Expected a confirmEx prompt");
 
   assert_equals("confirmEx", promptState.method);
   // Since we returned true on the confirmation dialog,
   // we should be quitting - so cancelQuit.data should now be
   // false
   assert_false(cancelQuit.data, "The quit request was cancelled");
 
--- a/mail/test/mozmill/content-tabs/test-plugin-crashing.js
+++ b/mail/test/mozmill/content-tabs/test-plugin-crashing.js
@@ -13,17 +13,17 @@ var frame = {};
 ChromeUtils.import("chrome://mozmill/content/modules/frame.js", frame);
 
 ChromeUtils.import('resource://gre/modules/Services.jsm');
 
 var gContentWindow = null;
 var gJSObject = null;
 var gTabDoc = null;
 var gOldStartPage = null;
-var gOldCrashReporterEnabled = null;
+var gOldPluginCrashDocPage = null;
 var crashReporter = null;
 var kPluginId = "test-plugin";
 var kStartPagePref = "mailnews.start_page.override_url";
 var kPluginCrashDocPref = "plugins.crash.supportUrl";
 // RELATIVE_ROOT messes with the collector, so we have to bring the path back
 // so we get the right path for the resources.
 var kUrl = collector.addHttpResource('../content-tabs/html', '');
 var kPluginUrl = kUrl + "plugin.html";
@@ -41,22 +41,18 @@ function setupModule(module) {
   gOldPluginCrashDocPage = Services.prefs.getCharPref(kPluginCrashDocPref);
 
   Services.prefs.setCharPref(kStartPagePref, kPluginUrl);
   Services.prefs.setCharPref(kPluginCrashDocPref, kPluginCrashDocUrl);
 
   try {
     crashReporter = Cc["@mozilla.org/toolkit/crash-reporter;1"]
                       .getService(Ci.nsICrashReporter);
-    // Force the crash reporter to be enabled, but record its old setting.
-    gOldCrashReporterEnabled = crashReporter.enabled;
-
-    if (!crashReporter.enabled) {
-      crashReporter.enabled = true;
-    }
+    // The crash reporter must be enabled.
+    assert_true(crashReporter.enabled, "Mandatory Crash reporter is not enabled");
   } catch (e) {
     // Crashreporter is not working.
   }
 
 
   /* Bug 689580 - these crash tests fail randomly on 64-bit OSX.  We'll
    * disable them for now, until we can figure out what's going on.
    */
@@ -76,19 +72,16 @@ function setupModule(module) {
       func.__force_skip__ = true;
     });
   }
   let plugin = get_test_plugin();
   plugin.enabledState = plugin.STATE_ENABLED;
 };
 
 function teardownModule(module) {
-  if (crashReporter)
-    crashReporter.enabled = gOldCrashReporterEnabled;
-
   Services.prefs.setCharPref(kStartPagePref, gOldStartPage);
   Services.prefs.setCharPref(kPluginCrashDocPref, gOldPluginCrashDocPage);
 }
 
 function setupTest() {
   let tab = open_content_tab_with_click(mc.menus.helpMenu.whatsNew, kPluginUrl);
   assert_tab_has_title(tab, "Plugin Test");
 
--- a/mail/test/mozmill/downloads/test-about-downloads.js
+++ b/mail/test/mozmill/downloads/test-about-downloads.js
@@ -15,17 +15,16 @@ var MODULE_NAME = "test-about-downloads"
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = [ 'attachment-helpers',
                         'content-tab-helpers',
                         'dom-helpers',
                         'folder-display-helpers',
                         'prompt-helpers',
                         'window-helpers' ];
 
-var mozmill = {}; ChromeUtils.import("chrome://mozmill/content/modules/mozmill.js", mozmill);
 var elementslib = {}; ChromeUtils.import("chrome://mozmill/content/modules/elementslib.js", elementslib);
 var downloads = {}; ChromeUtils.import("resource://gre/modules/Downloads.jsm", downloads);
 
 var downloadsTab;
 
 var attachmentFileNames = [
   "Attachment#1.txt",
   "Attachment#2.txt",
--- a/mail/test/mozmill/folder-display/test-message-size.js
+++ b/mail/test/mozmill/folder-display/test-message-size.js
@@ -19,23 +19,23 @@ var folder;
 
 function setupModule(module) {
   let fdh = collector.getModule('folder-display-helpers');
   fdh.installInto(module);
 
   folder = create_folder("MessageSizeA");
 
   // Create messages with sizes in the byte, KB, and MB ranges.
-  bytemsg = create_message({body: {body: " "}});
+  let bytemsg = create_message({body: {body: " "}});
 
-  kbstring = "x ".repeat(1024/2);
-  kbmsg = create_message({body: {body: kbstring}});
+  let kbstring = "x ".repeat(1024/2);
+  let kbmsg = create_message({body: {body: kbstring}});
 
-  mbstring = kbstring.repeat(1024);
-  mbmsg = create_message({body: {body: mbstring}});
+  let mbstring = kbstring.repeat(1024);
+  let mbmsg = create_message({body: {body: mbstring}});
 
   add_message_to_folder(folder, bytemsg);
   add_message_to_folder(folder, kbmsg);
   add_message_to_folder(folder, mbmsg);
 }
 
 function _help_test_message_size(index, unit) {
   be_in_folder(folder);
--- a/mail/test/mozmill/folder-display/test-pane-focus.js
+++ b/mail/test/mozmill/folder-display/test-pane-focus.js
@@ -16,17 +16,17 @@ var MODULE_REQUIRES = ["folder-display-h
 var folder;
 
 function setupModule(module) {
   let fdh = collector.getModule("folder-display-helpers");
   fdh.installInto(module);
 
   folder = create_folder("PaneFocus");
   let msg1 = create_thread(1);
-  thread = create_thread(3);
+  let thread = create_thread(3);
   let msg2 = create_thread(1);
   add_sets_to_folders([folder], [msg1, thread, msg2]);
 
   be_in_folder(folder);
   make_display_threaded();
   collapse_all_threads();
 }
 
--- a/mail/test/mozmill/folder-display/test-right-click-middle-click-folders.js
+++ b/mail/test/mozmill/folder-display/test-right-click-middle-click-folders.js
@@ -229,28 +229,28 @@ function _middle_click_on_existing_multi
   assert_folder_selected_and_displayed(folderA);
 }
 
 /**
  * Generate background and foreground tests for each middle click test.
  *
  * @param aTests an array of test names
  */
+var global = this;
 function _generate_background_foreground_tests(aTests) {
-  let self = this;
   for (let test of aTests) {
-    let helperFunc = this["_" + test + "_helper"];
-    this["test_" + test + "_background"] = function() {
+    let helperFunc = global["_" + test + "_helper"];
+    global["test_" + test + "_background"] = function() {
       set_context_menu_background_tabs(true);
-      helperFunc.apply(self, [true]);
+      helperFunc(true);
       reset_context_menu_background_tabs();
     };
-    this["test_" + test + "_foreground"] = function() {
+    global["test_" + test + "_foreground"] = function() {
       set_context_menu_background_tabs(false);
-      helperFunc.apply(self, [false]);
+      helperFunc(false);
       reset_context_menu_background_tabs();
     };
   }
 }
 
 _generate_background_foreground_tests([
   "middle_click_folder_with_nothing_selected",
   "middle_click_folder_with_one_thing_selected",
--- a/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js
+++ b/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js
@@ -394,28 +394,28 @@ function _middle_click_on_expanded_threa
   close_tab(tabMessage);
 }
 
 /**
  * Generate background and foreground tests for each middle click test.
  *
  * @param aTests an array of test names
  */
+var global = this;
 function _generate_background_foreground_tests(aTests) {
-  let self = this;
   for (let test of aTests) {
-    let helperFunc = this["_" + test + "_helper"];
-    this["test_" + test + "_background"] = function() {
+    let helperFunc = global["_" + test + "_helper"];
+    global["test_" + test + "_background"] = function() {
       set_context_menu_background_tabs(true);
-      helperFunc.apply(self, [true]);
+      helperFunc(true);
       reset_context_menu_background_tabs();
     };
-    this["test_" + test + "_foreground"] = function() {
+    global["test_" + test + "_foreground"] = function() {
       set_context_menu_background_tabs(false);
-      helperFunc.apply(self, [false]);
+      helperFunc(false);
       reset_context_menu_background_tabs();
     };
   }
 }
 
 _generate_background_foreground_tests([
   "middle_click_with_nothing_selected",
   "middle_click_with_one_thing_selected",
--- a/mail/test/mozmill/folder-display/test-savedsearch-reload-after-compact.js
+++ b/mail/test/mozmill/folder-display/test-savedsearch-reload-after-compact.js
@@ -9,46 +9,44 @@
 
 "use strict";
 
 var MODULE_NAME = "test-savedsearch-reload-after-compact";
 
 var RELATIVE_ROOT = '../shared-modules';
 var MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers'];
 
-var folderInbox, folderVirtual;
-
 function setupModule(module) {
   let fdh = collector.getModule('folder-display-helpers');
   fdh.installInto(module);
   let wh = collector.getModule('window-helpers');
   wh.installInto(module);
 }
 
 /**
  * Add some messages to a folder, delete the first one, and create a saved
  * search over the inbox and the folder. Then, compact folders.
  */
 function test_setup_virtual_folder_and_compact() {
-  otherFolder = create_folder("otherFolder");
+  let otherFolder = create_folder("otherFolder");
   let [msgSet] = make_new_sets_in_folder(otherFolder, [{count: 2}]);
 
   /**
    * We delete the first message in the local folder, so compaction of the
    * folder will invalidate the key of the second message in the folder. Then,
    * we select the second message and issue the compact. This causes saving the
    * selection on the compaction notification to fail. We test the saved search
    * view still gets rebuilt, such that there is a valid msg hdr at row 0.
    */
   be_in_folder(otherFolder);
   let curMessage = select_click_row(0);
   press_delete();
 
-  folderVirtual = create_virtual_folder([inboxFolder, otherFolder], {},
-                                        true, "SavedSearch");
+  let folderVirtual = create_virtual_folder([inboxFolder, otherFolder], {},
+                                            true, "SavedSearch");
 
   be_in_folder(folderVirtual);
   curMessage = select_click_row(0);
   let urlListener = {
     compactDone: false,
 
     OnStartRunningUrl: function (aUrl) {
     },
--- a/mail/test/mozmill/folder-display/test-tooltip-multimessage.js
+++ b/mail/test/mozmill/folder-display/test-tooltip-multimessage.js
@@ -15,17 +15,17 @@ var MODULE_REQUIRES = ['folder-display-h
 
 var folder;
 
 var setupModule = function(module) {
   let fdh = collector.getModule('folder-display-helpers');
   fdh.installInto(module);
 
   folder = create_folder("Test");
-  thread1 = create_thread(10);
+  let thread1 = create_thread(10);
   add_sets_to_folders([folder], [thread1]);
 };
 
 function test_tooltips() {
   // Trigger the message summary. This is needed otherwise we cannot compute the
   // style of aHTMLTooltip in mailWindow.js
   be_in_folder(folder);
   select_click_row(0);
--- a/mail/test/mozmill/folder-pane/test-folder-pane.js
+++ b/mail/test/mozmill/folder-pane/test-folder-pane.js
@@ -35,27 +35,31 @@ function test_all_folders_toggle_folder_
   collapse_folder(pop3Server.rootFolder);
   collapse_folder(MailServices.accounts.localFoldersServer.rootFolder);
 
   // All folders mode should give us only 2 rows to start
   // (tinderbox account and local folders)
   let accounts = 2;
   assert_folder_tree_view_row_count(accounts);
 
-  let inbox = trash = outbox = archives = folderPaneA = 1;
+  let inbox = 1;
+  let trash = 1;
+  let outbox = 1;
+  let archives = 1;
+  let folderPaneA = 1;
   // Create archives folder - this is ugly, but essentially the same as
   // what mailWindowOverlay.js does. We can't use the built-in helper
   // method to create the folder because we need the archive flag to get
   // set before the folder added notification is sent out, which means
   // creating the folder object via RDF, setting the flag, and then
   // creating the storage, which sends the notification.
   let rdfService = Cc['@mozilla.org/rdf/rdf-service;1']
                      .getService(Ci.nsIRDFService);
-  folder = rdfService.GetResource(pop3Server.rootFolder.URI + "/Archives").
-           QueryInterface(Ci.nsIMsgFolder);
+  let folder = rdfService.GetResource(pop3Server.rootFolder.URI + "/Archives")
+                         .QueryInterface(Ci.nsIMsgFolder);
   folder.setFlag(Ci.nsMsgFolderFlags.Archive);
   folder.createStorageIfMissing(null);
   // After creating Archives, account should have expanded
   // so that we should have 5 rows visible
   assert_folder_tree_view_row_count(accounts + inbox + trash +
                                     archives);
   // close the tinderbox server.
   mc.folderTreeView.toggleOpenState(0)
--- a/mail/test/mozmill/folder-tree-modes/test-custom-smart-folder.js
+++ b/mail/test/mozmill/folder-tree-modes/test-custom-smart-folder.js
@@ -16,17 +16,17 @@ var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers"];
 
 // spaces in the name are intentional
 var smartParentNameA="My Smart Folder A";
 var smartParentNameB="My Smart Folder B";
 
 var rootFolder;
 var inboxSubfolder, subfolderA, subfolderB;
-var smartInboxFolder;
+var smartFolderInbox;
 var smartFolderA;
 
 var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
 
 /**
  * create two smart folder types and two real folders, one for each
  * smart folder type
  */
--- a/mail/test/mozmill/folder-tree-modes/test-mode-switching.js
+++ b/mail/test/mozmill/folder-tree-modes/test-mode-switching.js
@@ -20,17 +20,19 @@ var inboxFolder;
 var unreadFolder;
 var favoriteFolder;
 var toggle_menu;
 var toggle_appmenu;
 var tree;
 var modeList_menu;
 var modeList_appmenu;
 var view_menu;
-var view_appmenu;
+var view_menupopup;
+var appmenu;
+var appmenu_popup;
 
 function setupModule(module) {
   for (let lib of MODULE_REQUIRES) {
     collector.getModule(lib).installInto(module);
   }
 
   rootFolder = inboxFolder.server.rootFolder;
 
@@ -48,17 +50,17 @@ function setupModule(module) {
   toggle_appmenu = mc.e("appmenu_compactFolderView");
 
   modeList_menu = mc.e("menu_FolderViewsPopup");
   modeList_appmenu = mc.e("appmenu_FolderViewsPopup");
 
   view_menu = mc.eid("menu_View");
   view_menupopup = mc.e("menu_View_Popup");
   appmenu = mc.eid("button-appmenu");
-  appmenupopup = mc.e("appmenu-popup");
+  appmenu_popup = mc.e("appmenu-popup");
 
   tree = mc.folderTreeView;
 
   select_no_folders();
 }
 
 /**
  * Check if both "Compact view" checkboxes in menu are of the expected state.
@@ -79,39 +81,40 @@ function assert_compact_state(aChecked, 
  * Check whether the expected folder mode is selected in menus and internally.
  *
  * @param aMode  The name of the expected mode.
  */
 function assert_mode_selected(aMode) {
   assert_equals(tree.mode, aMode);
   let baseMode = tree.baseMode();
   assert_compact_state(baseMode != tree.mode);
+  let popuplist;
   // We need to open the menu because only then the right mode is set in them.
   if (!mc.mozmillModule.isMac) {
     // On OS X the main menu seems not accessible for clicking from mozmill.
     mc.click(view_menu);
     popuplist = mc.click_menus_in_sequence(view_menupopup, [ { id: modeList_menu.parentNode.id } ], true);
     assert_true(modeList_menu.querySelector('[value="' + baseMode + '"]').hasAttribute("checked"));
     mc.close_popup_sequence(popuplist);
   }
   mc.click(appmenu);
-  popuplist = mc.click_menus_in_sequence(appmenupopup, [ { id: modeList_appmenu.parentNode.id } ], true);
+  popuplist = mc.click_menus_in_sequence(appmenu_popup, [ { id: modeList_appmenu.parentNode.id } ], true);
   assert_true(modeList_menu.querySelector('[value="' + baseMode + '"]').hasAttribute("checked"));
   mc.close_popup_sequence(popuplist);
 }
 
 /**
  * Toggle the folder mode by clicking in the menu.
  *
  * @param aMode  The base name of the mode to select.
  */
 function select_mode_in_menu(aMode) {
   mc.click(appmenu);
-  mc.click_menus_in_sequence(appmenupopup, [ { id: modeList_appmenu.parentNode.id },
-                                             { value: aMode } ]);
+  mc.click_menus_in_sequence(appmenu_popup, [ { id: modeList_appmenu.parentNode.id },
+                                              { value: aMode } ]);
 }
 
 /**
  * Toggle the Compact view option by clicking in the menu.
  */
 function toggle_compact_in_menu() {
   // For some reason, clicking the menuitem does not work by any means,
   // therefore we just simulate it here.
--- a/mail/test/mozmill/folder-tree-modes/test-smart-folders.js
+++ b/mail/test/mozmill/folder-tree-modes/test-smart-folders.js
@@ -160,17 +160,17 @@ function test_folder_flag_changes() {
   archive_selected_messages();
   let pop3Server = MailServices.accounts.FindServer("tinderbox", FAKE_SERVER_HOSTNAME, "pop3");
   let pop3Inbox = get_special_folder(Ci.nsMsgFolderFlags.Inbox, false, pop3Server);
   make_new_sets_in_folder(pop3Inbox, [{count: 1}]);
   mc.folderTreeView.selectFolder(pop3Inbox);
   select_click_row(0);
   archive_selected_messages();
 
-  smartArchiveFolder = get_smart_folder_named("Archives");
+  let smartArchiveFolder = get_smart_folder_named("Archives");
   let archiveScope = "|" + smartArchiveFolder.msgDatabase.dBFolderInfo
                      .getCharProperty("searchFolderUri") + "|";
   // We should have both this account, and a folder corresponding
   // to this year in the scope.
   rootFolder = inboxFolder.server.rootFolder;
   let archiveFolder = rootFolder.getChildNamed("Archives");
   assert_folder_and_children_in_scope(archiveFolder, archiveScope);
   archiveFolder = pop3Server.rootFolder.getChildNamed("Archives");
@@ -184,17 +184,17 @@ function test_folder_flag_changes() {
   // changed it.
   archiveScope = "|" + smartArchiveFolder.msgDatabase.dBFolderInfo
                  .getCharProperty("searchFolderUri") + "|";
 
   // figure out what we expect the archiveScope to now be.
   rootFolder = inboxFolder.server.rootFolder;
   let localArchiveFolder = rootFolder.getChildNamed("Archives");
   let allDescendants = localArchiveFolder.descendants;
-  desiredScope = "|" + localArchiveFolder.URI + "|";
+  let desiredScope = "|" + localArchiveFolder.URI + "|";
   for (let folder of fixIterator(allDescendants, Ci.nsIMsgFolder)) {
     desiredScope += folder.URI + "|";
   }
 
   if (archiveScope != desiredScope)
     throw "archive scope wrong after removing folder";
   assert_folder_and_children_not_in_scope(archiveFolder, archiveScope);
 }
--- a/mail/test/mozmill/folder-widget/test-message-filters.js
+++ b/mail/test/mozmill/folder-widget/test-message-filters.js
@@ -26,25 +26,22 @@ function setupModule(module)
   }
 
   setupNNTPDaemon();
 
   folderA = create_folder("FolderToolbarA");
   // we need one message to select and open
   make_new_sets_in_folder(folderA, [{count: 1}]);
 
-  server = setupLocalServer(NNTP_PORT);
+  setupLocalServer(NNTP_PORT);
 
   // Note, the uri is for hostname "invalid" which is the original uri. See
   // setupProtocolTest parameters.
   var prefix = "news://invalid:"+NNTP_PORT+"/";
 
-  // Test - group subscribe listing
-  test = "news:*";
-
   if (mc.mozmillModule.isMac) {
     test_customize_toolbar_doesnt_double_get_mail_menu.__force_skip__ = true;
   }
 }
 
 /*
  * Test that the message filter list shows newsgroup servers.
  */
@@ -54,17 +51,17 @@ function test_message_filter_shows_newsg
 
   // Open the "Tools » Message Filters…" window,
   // a.k.a. "tasksMenu » filtersCmd".
   plan_for_new_window("mailnews:filterlist");
   mc.menus.Tools.filtersCmd.click();
   let filterc = wait_for_new_window("mailnews:filterlist");
   wait_for_window_focused(filterc.window);
 
-  popup = filterc.eid("serverMenuPopup");
+  let popup = filterc.eid("serverMenuPopup");
   filterc.assertNode(popup);
   filterc.click(popup);
 
   let nntp = new elib.Elem(popup.node.children.item(2));
   filterc.assertNode(nntp);
   // We need to get the newsgroups to pop up somehow.
   // These all fail.
   //filterc.click(nntp);
--- a/mail/test/mozmill/instrumentation/test-instrument-setup.js
+++ b/mail/test/mozmill/instrumentation/test-instrument-setup.js
@@ -33,17 +33,17 @@ function setupModule(module) {
   let url = collector.addHttpResource("../account/xml", "autoconfig");
   Services.prefs.setCharPref("mailnews.auto_config_url", url);
 
   // Force .com MIME-Type to text/xml
   collector.httpd.registerContentType("com", "text/xml");
 }
 
 function test_mail_account_setup() {
-  awc = wait_for_existing_window("mail:autoconfig");
+  let awc = wait_for_existing_window("mail:autoconfig");
 
   // Input user's account information
   awc.e("realname").focus();
   input_value(awc, user.name);
   awc.keypress(null, "VK_TAB", {});
   input_value(awc, user.email);
 
   // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
--- a/mail/test/mozmill/message-header/test-reply-identity.js
+++ b/mail/test/mozmill/message-header/test-reply-identity.js
@@ -11,33 +11,25 @@
 "use strict";
 
 var MODULE_NAME = "test-reply-identity";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers",
                          "window-helpers", "compose-helpers"];
 
-var folderHelper = null;
-var windowindowHelperelper = null;
-var composeHelper = null;
-
 var testFolder = null;
 
 var identity1Email = "carl@example.com";
 var identity2Email = "lenny@springfield.invalid";
 
-var setupModule = function (module) {
-
-  folderHelper = collector.getModule("folder-display-helpers");
-  folderHelper.installInto(module);
-  windowHelper = collector.getModule("window-helpers");
-  windowHelper.installInto(module);
-  composeHelper = collector.getModule("compose-helpers");
-  composeHelper.installInto(module);
+function setupModule(module) {
+  for (let lib of MODULE_REQUIRES) {
+    collector.getModule(lib).installInto(module);
+  }
 
   addIdentitiesAndFolder();
   // Msg #0
   add_message_to_folder(testFolder, create_message({
     from: "Homer <homer@example.com>",
     to: "workers@springfield.invalid",
     subject: "no matching identity, like bcc/list",
     body: {body: "Alcohol is a way of life, alcohol is my way of life, and I aim to keep it."},
@@ -85,17 +77,17 @@ var setupModule = function (module) {
   add_message_to_folder(testFolder, create_message({
     from: identity2Email + " <" + identity2Email+ ">",
     to: "Marge <marge@example.com>",
     subject: "from second self",
     body: {body: "All my life I've had one dream, to achieve my many goals."}
   }));
 }
 
-var addIdentitiesAndFolder = function() {
+function addIdentitiesAndFolder() {
   let server = MailServices.accounts.createIncomingServer("nobody",
                                                           "Reply Identity Testing", "pop3");
   testFolder = server.rootFolder.QueryInterface(Ci.nsIMsgLocalMailFolder)
                      .createLocalSubfolder("Replies");
 
   let identity = MailServices.accounts.createIdentity();
   identity.email = identity1Email;
 
@@ -117,78 +109,78 @@ var checkReply = function (replyWin, exp
 }
 
 function test_reply_no_matching_identity() {
   be_in_folder(testFolder);
 
   let msg = select_click_row(0);
   assert_selected_and_displayed(mc, msg);
 
-  let replyWin = composeHelper.open_compose_with_reply();
+  let replyWin = open_compose_with_reply();
   // Should have selected the default identity.
   checkReply(replyWin, identity1Email);
   close_compose_window(replyWin);
 }
 
 function test_reply_matching_only_deliveredto() {
   be_in_folder(testFolder);
 
   let msg = select_click_row(1);
   assert_selected_and_displayed(mc, msg);
 
-  let replyWin = composeHelper.open_compose_with_reply();
+  let replyWin = open_compose_with_reply();
   // Should have selected the second id, which is listed in Delivered-To:.
   checkReply(replyWin, identity2Email);
   close_compose_window(replyWin);
 }
 
 function test_reply_matching_subaddress() {
   be_in_folder(testFolder);
 
   let msg = select_click_row(2);
   assert_selected_and_displayed(mc, msg);
 
-  let replyWin = composeHelper.open_compose_with_reply();
+  let replyWin = open_compose_with_reply();
   // Should have selected the first id, the email doesn't fully match.
   // other.lenny != "our" lenny
   checkReply(replyWin, identity1Email);
   close_compose_window(replyWin);
 }
 
 function test_reply_to_matching_second_id() {
   be_in_folder(testFolder);
 
   let msg = select_click_row(3);
   assert_selected_and_displayed(mc, msg);
 
-  let replyWin = composeHelper.open_compose_with_reply();
+  let replyWin = open_compose_with_reply();
   // Should have selected the second id, which was in To;.
   checkReply(replyWin, identity2Email);
   close_compose_window(replyWin);
 }
 
 function test_deliveredto_to_matching_only_parlty() {
   be_in_folder(testFolder);
 
   let msg = select_click_row(4);
   assert_selected_and_displayed(mc, msg);
 
-  let replyWin = composeHelper.open_compose_with_reply();
+  let replyWin = open_compose_with_reply();
   // Should have selected the (default) first id.
   checkReply(replyWin, identity1Email);
   close_compose_window(replyWin);
 }
 
 /**
  * A reply from self is treated as a follow-up. And this self
  * was the second identity, so the reply should also be from the second identity.
  */
 function test_reply_to_self_second_id() {
   be_in_folder(testFolder);
 
   let msg = select_click_row(5);
   assert_selected_and_displayed(mc, msg);
 
-  let replyWin = composeHelper.open_compose_with_reply();
+  let replyWin = open_compose_with_reply();
   // Should have selected the second id, which was in From.
   checkReply(replyWin, identity2Email);
   close_compose_window(replyWin, false /*no prompt*/);
 }
--- a/mail/test/mozmill/message-header/test-reply-to-list-from-address-selection.js
+++ b/mail/test/mozmill/message-header/test-reply-to-list-from-address-selection.js
@@ -9,40 +9,32 @@
 "use strict";
 
 var MODULE_NAME = "test-reply-to-list-from-address-selection";
 
 var RELATIVE_ROOT = '../shared-modules';
 var MODULE_REQUIRES = ['folder-display-helpers',
                        'window-helpers', 'compose-helpers'];
 
-var folderHelper = null;
-var windowindowHelperelper = null;
-var composeHelper = null;
-
 var testFolder = null;
 var msgHdr = null;
 var replyToListWindow = null;
 
 var identityString1 = "tinderbox_correct_identity@foo.invalid";
 
-var setupModule = function (module) {
-
-  folderHelper = collector.getModule('folder-display-helpers');
-  folderHelper.installInto(module);
-  windowHelper = collector.getModule('window-helpers');
-  windowHelper.installInto(module);
-  composeHelper = collector.getModule('compose-helpers');
-  composeHelper.installInto(module);
+function setupModule(module) {
+  for (let lib of MODULE_REQUIRES) {
+    collector.getModule(lib).installInto(module);
+  }
 
   addIdentitiesAndFolder();
   addMessageToFolder(testFolder);
 }
 
-var addMessageToFolder = function (aFolder) {
+function addMessageToFolder(aFolder) {
   var msgId = Cc["@mozilla.org/uuid-generator;1"]
                 .getService(Ci.nsIUUIDGenerator)
                 .generateUUID() + "@mozillamessaging.invalid";
 
   var source = "From - Sat Nov  1 12:39:54 2008\n" +
                 "X-Mozilla-Status: 0001\n" +
                 "X-Mozilla-Status2: 00000000\n" +
                 "Delivered-To: <tinderbox_identity333@foo.invalid>\n" +
@@ -65,17 +57,17 @@ var addMessageToFolder = function (aFold
   aFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
   aFolder.gettingNewMessages = true;
   aFolder.addMessage(source);
   aFolder.gettingNewMessages = false;
 
   return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
 }
 
-var addIdentitiesAndFolder = function() {
+function addIdentitiesAndFolder() {
   let identity2 = MailServices.accounts.createIdentity();
   //identity.fullName = "Tinderbox_Identity1";
   identity2.email="tinderbox_identity1@foo.invalid";
 
   let identity = MailServices.accounts.createIdentity();
   //identity.fullName = "Tinderbox_Identity1";
   identity.email = identityString1;
 
@@ -91,17 +83,17 @@ var addIdentitiesAndFolder = function() 
 }
 
 function test_Reply_To_List_From_Address() {
   be_in_folder(testFolder);
 
   let curMessage = select_click_row(0);
   assert_selected_and_displayed(mc, curMessage);
 
-  replyToListWindow = composeHelper.open_compose_with_reply_to_list();
+  replyToListWindow = open_compose_with_reply_to_list();
 
   var identityList = replyToListWindow.e("msgIdentity");
 
   // see if it's the correct identity selected
   if (!identityList.selectedItem.label.includes(identityString1))
     throw new Error("The From address is not correctly selected! Expected: "+
                     identityString1 + "; Actual: "  +
                     identityList.selectedItem.label);
--- a/mail/test/mozmill/newmailaccount/test-newmailaccount.js
+++ b/mail/test/mozmill/newmailaccount/test-newmailaccount.js
@@ -718,17 +718,17 @@ function subtest_search_button_disabled_
   type_in_search_name(w, "Dexter Morgan");
 
   // We already have at least one provider checked from the last case, so
   // the search submit button should become enabled
   wait_for_element_enabled(w, w.e("searchSubmit"), true);
 
   // Case 3:  Search input has text, no providers selected
   // Make sure no provider checkboxes are checked.
-  inputs = w.window.document.querySelectorAll('input[type="checkbox"]:checked');
+  let inputs = w.window.document.querySelectorAll('input[type="checkbox"]:checked');
   for (input of inputs) {
     mc.click(new elib.Elem(input));
   }
 
   // The search submit button should now be disabled
   wait_for_element_enabled(w, w.e("searchSubmit"), false);
 
   // We'll turn on a single provider now to enable the search button,
--- a/mail/test/mozmill/session-store/test-session-store.js
+++ b/mail/test/mozmill/session-store/test-session-store.js
@@ -412,29 +412,28 @@ async function test_bad_session_file_sim
                "saved state is bad so state object should be null");
 
   // The bad session file should now not exist.
   utils.waitFor(() => !sessionStoreManager.sessionFile.exists(),
                 "session file should now not exist");
 }
 
 function test_clean_shutdown_session_persistence_simple() {
-
   // open a few more 3pane windows
   for (var i = 0; i < 3; ++i) {
     open3PaneWindow();
   }
 
   // make sure we have a different window open, so that we don't start shutting
   // down just because the last window was closed
   let abwc = openAddressBook();
 
   // close all the 3pane windows
   let lastWindowState = null;
-  enumerator = Services.wm.getEnumerator("mail:3pane");
+  let enumerator = Services.wm.getEnumerator("mail:3pane");
   while (enumerator.hasMoreElements()) {
     let window = enumerator.getNext();
     if (!enumerator.hasMoreElements())
       lastWindowState = window.getWindowStateForSessionPersistence();
 
     close_window(new mozmill.controller.MozMillController(window));
   }
 
--- a/mail/test/mozmill/shared-modules/test-content-tab-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-content-tab-helpers.js
@@ -27,17 +27,17 @@ var EXT_PROTOCOL_SVC_CID = "@mozilla.org
 var folderDisplayHelper;
 var mc;
 var wh;
 
 var _originalBlocklistURL = null;
 
 // logHelper (and therefore folderDisplayHelper) exports
 var mark_failure;
-var gMockExtProtocolSvcReg;
+var gMockExtProtSvcReg;
 
 function setupModule() {
   folderDisplayHelper = collector.getModule('folder-display-helpers');
   mc = folderDisplayHelper.mc;
   mark_failure = folderDisplayHelper.mark_failure;
 
   wh = collector.getModule('window-helpers');
   let moh = collector.getModule('mock-object-helpers');
--- a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
@@ -159,17 +159,17 @@ function setupModule() {
     });
   // Listen for the fail event so that we can annotate the failure object
   //  with additional metadata.  This works out because we are directly handed
   //  a reference to the object that will be provided to the jsbridge and we
   //  can mutate it.  (The jsbridge is a global listener and so is guaranteed
   //  to be invoked after our specific named listener.)
   frame.events.addListener("fail", function(obj) {
       // normalize nsIExceptions so they look like JS exceptions...
-      rawex = obj.exception;
+      let rawex = obj.exception;
       if (obj.exception != null &&
           (obj.exception instanceof Ci.nsIException)) {
         obj.exception = {
           message: "nsIException: " + rawex.message + " (" + rawex.result + ")",
           fileName: rawex.filename,
           lineNumber: rawex.lineNumber,
           name: rawex.name,
           result: rawex.result,
--- a/mail/test/mozmill/shared-modules/test-newmailaccount-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-newmailaccount-helpers.js
@@ -187,15 +187,15 @@ var gConsoleListener = {
     this._sawMsg = false;
   },
 
   get sawMsg() {
     return this._sawMsg;
   },
 
   wait: function() {
-    self = this;
+    let self = this;
     mc.waitFor(function() {
       return self.sawMsg;
     },
     "Timed out waiting for console message: " + this._msg);
   },
 }
--- a/mail/test/mozmill/shared-modules/test-nntp-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-nntp-helpers.js
@@ -30,16 +30,18 @@ var groups = [
   ["test.subscribe.simple", true],
   ["test.filter", true]
 ];
 
 var folderDisplayHelper;
 var mc;
 var windowHelper;
 
+var testHelperModule;
+
 function setupModule() {
   folderDisplayHelper = collector.getModule('folder-display-helpers');
   mc = folderDisplayHelper.mc;
   windowHelper = collector.getModule('window-helpers');
   testHelperModule = {
     Cc: Cc,
     Ci: Ci,
     Cu: Cu,
--- a/mail/test/resources/mozmill/mozmill/extension/content/stdlib/httpd.js
+++ b/mail/test/resources/mozmill/mozmill/extension/content/stdlib/httpd.js
@@ -742,17 +742,18 @@ nsHttpServer.prototype =
     //     this._stopCallback by starting and immediately stopping this, at
     //     which point we'd be nulling out a field we no longer have a right to
     //     modify.
     //
     var callback = this._stopCallback;
     this._stopCallback = null;
     try
     {
-      callback();
+      if (typeof callback === "function")
+        callback();
     }
     catch (e)
     {
       // not throwing because this is specified as being usually (but not
       // always) asynchronous
       dump("!!! error running onStopped callback: " + e + "\n");
     }
   },