Bug 900881 Make localAccountUtils.js into a testing module - Part 4. Make it a real testing module. r=jcranmer,a=Standard8
authorMark Banner <bugzilla@standard8.plus.com>
Fri, 02 Aug 2013 18:11:30 +0100
changeset 15890 48f8a55002870d5671353b5c62bb0d53df7e82c9
parent 15889 26e6b490696462acc1ce81cc5a6887613ec27241
child 15891 9bd431f81f12d0cd424bd1e53e0c280312301f1f
push id942
push userbugzilla@standard8.plus.com
push dateMon, 05 Aug 2013 19:15:38 +0000
treeherdercomm-beta@0e1a1c4a9f0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcranmer, Standard8
bugs900881
Bug 900881 Make localAccountUtils.js into a testing module - Part 4. Make it a real testing module. r=jcranmer,a=Standard8
mail/components/test/unit/test_about_support.js
mailnews/Makefile.in
mailnews/base/test/unit/head_mailbase.js
mailnews/base/test/unit/test_copyChaining.js
mailnews/base/test/unit/test_copyThenMoveManual.js
mailnews/base/test/unit/test_quarantineFilterMove.js
mailnews/base/test/unit/test_searchChaining.js
mailnews/compose/test/unit/head_compose.js
mailnews/compose/test/unit/test_bug235432.js
mailnews/compose/test/unit/test_sendBackground.js
mailnews/compose/test/unit/test_sendMailAddressIDN.js
mailnews/compose/test/unit/test_sendMessageFile.js
mailnews/compose/test/unit/test_sendMessageLater.js
mailnews/compose/test/unit/test_sendMessageLater2.js
mailnews/compose/test/unit/test_sendMessageLater3.js
mailnews/compose/test/unit/test_temporaryFilesRemoved.js
mailnews/db/msgdb/test/unit/head_maildb.js
mailnews/extensions/bayesian-spam-filter/test/unit/head_bayes.js
mailnews/extensions/mdn/test/unit/head_mdn.js
mailnews/imap/test/unit/head_server.js
mailnews/imap/test/unit/test_copyThenMove.js
mailnews/imap/test/unit/test_imapFilterActions.js
mailnews/imap/test/unit/test_imapFolderCopy.js
mailnews/local/test/unit/head_maillocal.js
mailnews/local/test/unit/test_pop3FilterActions.js
mailnews/local/test/unit/test_pop3MoveFilter.js
mailnews/local/test/unit/test_pop3MoveFilter2.js
mailnews/mime/test/unit/test_mimeStreaming.js
mailnews/news/test/unit/head_server_setup.js
mailnews/test/resources/IMAPpump.js
mailnews/test/resources/POP3pump.js
mailnews/test/resources/localAccountUtils.js
--- a/mail/components/test/unit/test_about_support.js
+++ b/mail/components/test/unit/test_about_support.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
-load("../../../../mailnews/resources/localAccountUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 /*
  * Test the about:support module.
  */
 
 let gAccountList = [{
   type: "pop3",
   port: 1234,
--- a/mailnews/Makefile.in
+++ b/mailnews/Makefile.in
@@ -17,16 +17,17 @@ DEFINES += -DOS_ARCH=$(OS_ARCH) \
            -DNO_NSPR_10_SUPPORT \
            $(NULL)
 
 ifdef ENABLE_TESTS
 RESDIR = $(srcdir)/test/resources
 FAKESERVER := $(srcdir)/test/fakeserver
 TESTING_JS_MODULE_DIR = mailnews
 TESTING_JS_MODULES += \
+	$(RESDIR)/localAccountUtils.js \
 	$(RESDIR)/mailDirService.js \
 	$(RESDIR)/mailTestUtils.js \
 	$(FAKESERVER)/auth.js \
 	$(FAKESERVER)/imapd.js \
 	$(FAKESERVER)/maild.js \
 	$(FAKESERVER)/nntpd.js \
 	$(FAKESERVER)/pop3d.js \
 	$(FAKESERVER)/smtpd.js \
--- a/mailnews/base/test/unit/head_mailbase.js
+++ b/mailnews/base/test/unit/head_mailbase.js
@@ -1,16 +1,15 @@
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://testing-common/mailnews/mailDirService.js");
 Components.utils.import("resource://testing-common/mailnews/mailTestUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var CC = Components.Constructor;
 
 var gProfileDir = ProfileDir.initialize(do_get_profile());
 
 var gDEPTH = "../../../../";
-
-load("../../../../mailnews/resources/localAccountUtils.js");
--- a/mailnews/base/test/unit/test_copyChaining.js
+++ b/mailnews/base/test/unit/test_copyChaining.js
@@ -57,18 +57,17 @@ function run_test()
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
   do_test_pending();
 
   gCopyDest = localAccountUtils.inboxFolder.createLocalSubfolder("copyDest");
   // build up a diverse list of messages
   let messages = [];
   messages = messages.concat(scenarioFactory.directReply(10));
-  gCopySource = localAccountUtils.incomingServer
-                                 .rootMsgFolder.createLocalSubfolder("copySource");
+  gCopySource = localAccountUtils.rootFolder.createLocalSubfolder("copySource");
   addMessagesToFolder(messages, gCopySource);
 
   mailTestUtils.updateFolderAndNotify(gCopySource, doTest);
   return true;
 }
 
 function doTest()
 {
--- a/mailnews/base/test/unit/test_copyThenMoveManual.js
+++ b/mailnews/base/test/unit/test_copyThenMoveManual.js
@@ -103,20 +103,18 @@ function folderCount(folder)
   return count;
 }
 
 function run_test()
 {
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
 
-  gCopyFolder = localAccountUtils.incomingServer
-                                 .rootFolder.createLocalSubfolder("CopyFolder");
-  gMoveFolder = localAccountUtils.incomingServer
-                                 .rootFolder.createLocalSubfolder("MoveFolder");
+  gCopyFolder = localAccountUtils.rootFolder.createLocalSubfolder("CopyFolder");
+  gMoveFolder = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder");
 
   MailServices.mailSession.AddFolderListener(FolderListener, Ci.nsIFolderListener.event |
                                                              Ci.nsIFolderListener.added |
                                                              Ci.nsIFolderListener.removed);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
   do_test_pending();
--- a/mailnews/base/test/unit/test_quarantineFilterMove.js
+++ b/mailnews/base/test/unit/test_quarantineFilterMove.js
@@ -110,20 +110,18 @@ function run_test()
   //  return;
   /**/
 
   // quarantine messages
   Services.prefs.setBoolPref("mailnews.downloadToTempFile", true);
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
 
-  gMoveFolder = localAccountUtils.incomingServer.rootMsgFolder
-                  .createLocalSubfolder("MoveFolder");
-  gMoveFolder2 = localAccountUtils.incomingServer.rootMsgFolder
-                  .createLocalSubfolder("MoveFolder2");
+  gMoveFolder = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder");
+  gMoveFolder2 = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder2");
 
   MailServices.mailSession.AddFolderListener(FolderListener, Ci.nsIFolderListener.event |
                                                              Ci.nsIFolderListener.added |
                                                              Ci.nsIFolderListener.removed);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
   do_test_pending();
--- a/mailnews/base/test/unit/test_searchChaining.js
+++ b/mailnews/base/test/unit/test_searchChaining.js
@@ -84,18 +84,17 @@ var UrlListener =
     do_check_eq(rc, 0);
     searchTest();
   }
 };
 
 function searchTest()
 {
   // Get the IMAP inbox...
-  var emptyLocal1 = localAccountUtils.incomingServer
-                                     .rootFolder.createLocalSubfolder("empty 1");
+  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;
   searchSession.appendTerm(searchTerm);
   searchSession.addScopeTerm(Ci.nsMsgSearchScope.offlineMail, emptyLocal1);
--- a/mailnews/compose/test/unit/head_compose.js
+++ b/mailnews/compose/test/unit/head_compose.js
@@ -1,24 +1,23 @@
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource:///modules/IOUtils.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://testing-common/mailnews/mailDirService.js");
 Components.utils.import("resource://testing-common/mailnews/mailTestUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var CC = Components.Constructor;
 
 var gProfileDir = ProfileDir.initialize(do_get_profile());
 
-load("../../../resources/localAccountUtils.js");
-
 // Import the required setup scripts.
 load("../../../resources/abSetup.js");
 
 // Import the smtp server scripts
 Components.utils.import("resource://testing-common/mailnews/maild.js");
 Components.utils.import("resource://testing-common/mailnews/smtpd.js");
 Components.utils.import("resource://testing-common/mailnews/auth.js");
 
@@ -127,17 +126,17 @@ function createMessage(aAttachment) {
                  .createInstance(Ci.nsIMsgCompFields);
   let params = Cc["@mozilla.org/messengercompose/composeparams;1"]
                  .createInstance(Ci.nsIMsgComposeParams);
   params.composeFields = fields;
 
   let msgCompose = MailServices.compose.initCompose(params);
   let identity = getSmtpIdentity(null, getBasicSmtpServer());
 
-  let rootFolder = localAccountUtils.incomingServer.rootMsgFolder;
+  let rootFolder = localAccountUtils.rootFolder;
   gDraftFolder = null;
   // Make sure the drafts folder is empty
   try {
     gDraftFolder = rootFolder.getChildNamed("Drafts");
     // try to delete
     rootFolder.propagateDelete(gDraftFolder, true, null);
   } catch (e) {
     // we don't have to remove the folder because it doen't exist yet
--- a/mailnews/compose/test/unit/test_bug235432.js
+++ b/mailnews/compose/test/unit/test_bug235432.js
@@ -107,18 +107,17 @@ function run_test() {
 
 function send_message_later(aMessageHeaderKeys, aStatus) {
   let compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
                      .createInstance(Ci.nsIMsgCompFields);
   let params = Cc["@mozilla.org/messengercompose/composeparams;1"]
                  .createInstance(Ci.nsIMsgComposeParams);
   params.composeFields = compFields;
   let msgCompose = MailServices.compose.initCompose(params);
-  let rootFolder = localAccountUtils.incomingServer.rootMsgFolder;
-  rootFolder.createLocalSubfolder("Drafts");
+  localAccountUtils.rootFolder.createLocalSubfolder("Drafts");
 
   let smtpServer = getBasicSmtpServer();
   let identity = getSmtpIdentity(kSender, smtpServer);
 
   compFields.from = identity.email;
   compFields.to = kTo;
 
   let msgHdr = localAccountUtils.inboxFolder.GetMessageHeader(aMessageHeaderKeys[0]);
--- a/mailnews/compose/test/unit/test_sendBackground.js
+++ b/mailnews/compose/test/unit/test_sendBackground.js
@@ -106,18 +106,17 @@ function run_test() {
 
   var smtpServer = getBasicSmtpServer();
   identity = getSmtpIdentity(kSender, smtpServer);
 
   account.addIdentity(identity);
   account.defaultIdentity = identity;
   account.incomingServer = incomingServer;
 
-  sentFolder = localAccountUtils.incomingServer
-                                .rootMsgFolder.createLocalSubfolder("Sent");
+  sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
 
   do_check_eq(identity.doFcc, true);
 
   // Now prepare to actually "send" the message later, i.e. dump it in the
   // unsent messages folder.
 
   var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
                      .createInstance(Ci.nsIMsgCompFields);
--- a/mailnews/compose/test/unit/test_sendMailAddressIDN.js
+++ b/mailnews/compose/test/unit/test_sendMailAddressIDN.js
@@ -175,18 +175,17 @@ function run_test()
   registerAlertTestUtils();
   var composeProps = Services.strings.createBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties");
   expectedAlertMessage = composeProps.GetStringFromName("errorIllegalLocalPart")
                                      .replace("%s", kToInvalid);
 
   // Ensure we have at least one mail account
   localAccountUtils.loadLocalMailAccount();
   MailServices.accounts.setSpecialFolders();
-  sentFolder = localAccountUtils.incomingServer
-                                .rootMsgFolder.createLocalSubfolder("Sent");
+  sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
 
   // Test 1:
   // Plain ASCII recipient address.
   test = kToASCII;
   DoSendTest(kToASCII, kToASCII, 0);
 
   // Test 2:
   // The recipient's domain part contains a non-ASCII character, hence the
--- a/mailnews/compose/test/unit/test_sendMessageFile.js
+++ b/mailnews/compose/test/unit/test_sendMessageFile.js
@@ -114,18 +114,17 @@ function run_test() {
   // Ensure we have at least one mail account
   localAccountUtils.loadLocalMailAccount();
 
   MailServices.accounts.setSpecialFolders();
 
   var smtpServer = getBasicSmtpServer();
   var identity = getSmtpIdentity(kSender, smtpServer);
 
-  sentFolder = localAccountUtils.incomingServer
-                                .rootMsgFolder.createLocalSubfolder("Sent");
+  sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
 
   do_check_eq(identity.doFcc, true);
 
   var msgSend = Cc["@mozilla.org/messengercompose/send;1"]
                   .createInstance(Ci.nsIMsgSend);
 
   // Handle the server in a try/catch/finally loop so that we always will stop
   // the server if something fails.
--- a/mailnews/compose/test/unit/test_sendMessageLater.js
+++ b/mailnews/compose/test/unit/test_sendMessageLater.js
@@ -189,18 +189,17 @@ function run_test() {
 
   var smtpServer = getBasicSmtpServer();
   identity = getSmtpIdentity(kSender, smtpServer);
 
   account.addIdentity(identity);
   account.defaultIdentity = identity;
   account.incomingServer = incomingServer;
 
-  sentFolder = localAccountUtils.incomingServer
-                                .rootMsgFolder.createLocalSubfolder("Sent");
+  sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
 
   do_check_eq(identity.doFcc, true);
 
   // Now prepare to actually "send" the message later, i.e. dump it in the
   // unsent messages folder.
 
   var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
                      .createInstance(Ci.nsIMsgCompFields);
--- a/mailnews/compose/test/unit/test_sendMessageLater2.js
+++ b/mailnews/compose/test/unit/test_sendMessageLater2.js
@@ -232,17 +232,17 @@ function run_test() {
 
   var smtpServer = getBasicSmtpServer();
   identity = getSmtpIdentity(kSender, smtpServer);
 
   account.addIdentity(identity);
   account.defaultIdentity = identity;
   account.incomingServer = incomingServer;
 
-  localAccountUtils.incomingServer.rootMsgFolder.createLocalSubfolder("Sent");
+  localAccountUtils.rootFolder.createLocalSubfolder("Sent");
 
   gSentFolder = msgSendLater.getUnsentMessagesFolder(identity);
 
   // Don't copy messages to sent folder for this test
   identity.doFcc = false;
 
   // Create and add a listener
   var messageListener = new msll();
--- a/mailnews/compose/test/unit/test_sendMessageLater3.js
+++ b/mailnews/compose/test/unit/test_sendMessageLater3.js
@@ -136,18 +136,17 @@ function run_test() {
 
   var smtpServer = getBasicSmtpServer();
   identity = getSmtpIdentity(kSender, smtpServer);
 
   account.addIdentity(identity);
   account.defaultIdentity = identity;
   account.incomingServer = incomingServer;
 
-  sentFolder = localAccountUtils.incomingServer
-                                .rootMsgFolder.createLocalSubfolder("Sent");
+  sentFolder = localAccountUtils.rootFolder.createLocalSubfolder("Sent");
 
   identity.doFcc = false;
 
   // Now prepare to actually "send" the message later, i.e. dump it in the
   // unsent messages folder.
 
   var compFields = Cc["@mozilla.org/messengercompose/composefields;1"]
                      .createInstance(Ci.nsIMsgCompFields);
--- a/mailnews/compose/test/unit/test_temporaryFilesRemoved.js
+++ b/mailnews/compose/test/unit/test_temporaryFilesRemoved.js
@@ -90,18 +90,17 @@ function run_test() {
 
   params.composeFields = fields;
   params.format = Ci.nsIMsgCompFormat.HTML;
 
   gMsgCompose.initialize(params, null, null);
 
   let identity = getSmtpIdentity(null, getBasicSmtpServer());
 
-  let rootFolder = localAccountUtils.incomingServer.rootMsgFolder;
-  let draftFolder = rootFolder.createLocalSubfolder("Drafts");
+  let draftFolder = localAccountUtils.rootFolder.createLocalSubfolder("Drafts");
 
   let progress = Cc["@mozilla.org/messenger/progress;1"]
                    .createInstance(Ci.nsIMsgProgress);
   progress.registerListener(progressListener);
 
   do_test_pending();
 
   gMsgCompose.SendMsg(Ci.nsIMsgSend.nsMsgSaveAsDraft, identity, "", null,
--- a/mailnews/db/msgdb/test/unit/head_maildb.js
+++ b/mailnews/db/msgdb/test/unit/head_maildb.js
@@ -1,15 +1,13 @@
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://testing-common/mailnews/mailDirService.js");
 Components.utils.import("resource://testing-common/mailnews/mailTestUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var CC = Components.Constructor;
 
 var gProfileDir = ProfileDir.initialize(do_get_profile());
-
-// Import the main scripts that mailnews tests need to set up and tear down
-load("../../../../resources/localAccountUtils.js");
--- a/mailnews/extensions/bayesian-spam-filter/test/unit/head_bayes.js
+++ b/mailnews/extensions/bayesian-spam-filter/test/unit/head_bayes.js
@@ -1,24 +1,22 @@
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://testing-common/mailnews/mailDirService.js");
 Components.utils.import("resource://testing-common/mailnews/mailTestUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var CC = Components.Constructor;
 
 var gProfileDir = ProfileDir.initialize(do_get_profile());
 
-// Import the main scripts that mailnews tests need to set up and tear down
-load("../../../../resources/localAccountUtils.js");
-
 Components.utils.import("resource://gre/modules/Services.jsm");
 
 function getSpec(aFileName)
 {
   var file = do_get_file("resources/" + aFileName);
   var uri = Services.io.newFileURI(file).QueryInterface(Ci.nsIURL);
   uri.query = "type=application/x-message-display";
   return uri.spec;
--- a/mailnews/extensions/mdn/test/unit/head_mdn.js
+++ b/mailnews/extensions/mdn/test/unit/head_mdn.js
@@ -1,14 +1,12 @@
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://testing-common/mailnews/mailDirService.js");
 Components.utils.import("resource://testing-common/mailnews/mailTestUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var CC = Components.Constructor;
 
 var gProfileDir = ProfileDir.initialize(do_get_profile());
-
-// Import the main scripts that mailnews tests need to set up and tear down
-load("../../../../resources/localAccountUtils.js");
--- a/mailnews/imap/test/unit/head_server.js
+++ b/mailnews/imap/test/unit/head_server.js
@@ -3,32 +3,30 @@
 if (typeof gDEPTH == "undefined")
   var gDEPTH = "../../../../";
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://testing-common/mailnews/mailDirService.js");
 Components.utils.import("resource://testing-common/mailnews/mailTestUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var CC = Components.Constructor;
 
 var gProfileDir = ProfileDir.initialize(do_get_profile());
 
 // Import fakeserver
 Components.utils.import("resource://testing-common/mailnews/maild.js");
 Components.utils.import("resource://testing-common/mailnews/imapd.js");
 Components.utils.import("resource://testing-common/mailnews/auth.js");
 
-// And mailnews scripts
-load(gDEPTH + "mailnews/resources/localAccountUtils.js");
-
 const IMAP_PORT = 1024 + 143;
 
 function makeServer(daemon, infoString, otherProps) {
   if (infoString in configurations)
     return makeServer(daemon, configurations[infoString].join(","), otherProps);
 
   function createHandler(d) {
     var handler = new IMAP_RFC3501_handler(d);
--- a/mailnews/imap/test/unit/test_copyThenMove.js
+++ b/mailnews/imap/test/unit/test_copyThenMove.js
@@ -109,20 +109,18 @@ function setup() {
   // fetching messages is invoked after copying the messages.
   // (i.e. The fetching process will be invoked after OnStopCopy)
   // It will cause crash with an assertion
   // (ASSERTION: tried to add duplicate listener: 'index == -1') on teardown.
   Services.prefs.setBoolPref("mail.server.default.autosync_offline_stores", false);
 
   setupIMAPPump();
 
-  gEmptyLocal1 = localAccountUtils.incomingServer.rootFolder
-                                  .createLocalSubfolder("empty 1");
-  gEmptyLocal2 = localAccountUtils.incomingServer
-                                  .rootFolder.createLocalSubfolder("empty 2");
+  gEmptyLocal1 = localAccountUtils.rootFolder.createLocalSubfolder("empty 1");
+  gEmptyLocal2 = localAccountUtils.rootFolder.createLocalSubfolder("empty 2");
 
   // these hacks are required because we've created the inbox before
   // running initial folder discovery, and adding the folder bails
   // out before we set it as verified online, so we bail out, and
   // then remove the INBOX folder since it's not verified.
   gIMAPInbox.hierarchyDelimiter = '/';
   gIMAPInbox.verifiedAsOnlineFolder = true;
 }
--- a/mailnews/imap/test/unit/test_imapFilterActions.js
+++ b/mailnews/imap/test/unit/test_imapFilterActions.js
@@ -350,18 +350,17 @@ function run_test()
   Services.prefs.setIntPref("mail.server.default.max_cached_connections", 1);
   // We aren't interested in downloading messages automatically
   Services.prefs.setBoolPref("mail.server.default.download_on_biff", false);
   Services.prefs.setBoolPref("mail.biff.play_sound", false);
   Services.prefs.setBoolPref("mail.biff.show_alert", false);
   Services.prefs.setBoolPref("mail.biff.show_tray_icon", false);
   Services.prefs.setBoolPref("mail.biff.animate_dock_icon", false);
 
-  gSubfolder = localAccountUtils.incomingServer
-                                .rootFolder.createLocalSubfolder("Subfolder");
+  gSubfolder = localAccountUtils.rootFolder.createLocalSubfolder("Subfolder");
   gIMAPIncomingServer.performExpand(null);
 
   gRootFolder = gIMAPIncomingServer.rootFolder;
   gIMAPInbox = gRootFolder.getChildNamed("INBOX");
   gIMAPMailbox = gIMAPDaemon.getMailbox("INBOX");
   dump("gIMAPInbox uri = " + gIMAPInbox.URI + "\n");
   let msgImapFolder = gIMAPInbox.QueryInterface(Ci.nsIMsgImapMailFolder);
   // these hacks are required because we've created the inbox before
--- a/mailnews/imap/test/unit/test_imapFolderCopy.js
+++ b/mailnews/imap/test/unit/test_imapFolderCopy.js
@@ -95,24 +95,20 @@ var tests = [
     yield false;
   },
   teardown
 ];
 
 function setup() {
   setupIMAPPump();
 
-  gEmptyLocal1 = localAccountUtils.incomingServer
-                                  .rootFolder.createLocalSubfolder("empty 1");
-  gEmptyLocal2 = localAccountUtils.incomingServer
-                                  .rootFolder.createLocalSubfolder("empty 2");
-  gEmptyLocal3 = localAccountUtils.incomingServer
-                                  .rootFolder.createLocalSubfolder("empty 3");
-  gNotEmptyLocal4 = localAccountUtils.incomingServer
-                                     .rootFolder.createLocalSubfolder("not empty 4");
+  gEmptyLocal1 = localAccountUtils.rootFolder.createLocalSubfolder("empty 1");
+  gEmptyLocal2 = localAccountUtils.rootFolder.createLocalSubfolder("empty 2");
+  gEmptyLocal3 = localAccountUtils.rootFolder.createLocalSubfolder("empty 3");
+  gNotEmptyLocal4 = localAccountUtils.rootFolder.createLocalSubfolder("not empty 4");
 
   let messageGenerator = new MessageGenerator();
   let message = messageGenerator.makeMessage();
   gNotEmptyLocal4.QueryInterface(Ci.nsIMsgLocalMailFolder);
   gNotEmptyLocal4.addMessage(message.toMboxString());
 
   // these hacks are required because we've created the inbox before
   // running initial folder discovery, and adding the folder bails
--- a/mailnews/local/test/unit/head_maillocal.js
+++ b/mailnews/local/test/unit/head_maillocal.js
@@ -1,26 +1,24 @@
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://testing-common/mailnews/mailDirService.js");
 Components.utils.import("resource://testing-common/mailnews/mailTestUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var CC = Components.Constructor;
 
 var gProfileDir = ProfileDir.initialize(do_get_profile());
 
 var gDEPTH = "../../../../";
 
-// Import the main scripts that mailnews tests need to set up and tear down
-load("../../../resources/localAccountUtils.js");
-
 // Import the pop3 server scripts
 Components.utils.import("resource://testing-common/mailnews/maild.js");
 Components.utils.import("resource://testing-common/mailnews/auth.js");
 Components.utils.import("resource://testing-common/mailnews/pop3d.js");
 
 Components.utils.import("resource:///modules/mailServices.js");
 
 const POP3_PORT = 1024+110;
--- a/mailnews/local/test/unit/test_pop3FilterActions.js
+++ b/mailnews/local/test/unit/test_pop3FilterActions.js
@@ -118,18 +118,17 @@ function folderCount(folder)
 
 function run_test()
 {
   // Make sure we're not quarantining messages
   Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
 
-  gMoveFolder = localAccountUtils.incomingServer
-                                 .rootFolder.createLocalSubfolder("MoveFolder");
+  gMoveFolder = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder");
 
   MailServices.mailSession.AddFolderListener(FolderListener,
                                              Ci.nsIFolderListener.event |
                                                Ci.nsIFolderListener.added |
                                                Ci.nsIFolderListener.removed);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
--- a/mailnews/local/test/unit/test_pop3MoveFilter.js
+++ b/mailnews/local/test/unit/test_pop3MoveFilter.js
@@ -110,18 +110,17 @@ function folderCount(folder)
 
 function run_test()
 {
   // Make sure we're not quarantining messages
   Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
 
-  gMoveFolder = localAccountUtils.incomingServer
-                                 .rootFolder.createLocalSubfolder("MoveFolder");
+  gMoveFolder = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder");
 
   MailServices.mailSession.AddFolderListener(FolderListener,
                                              Ci.nsIFolderListener.event |
                                                Ci.nsIFolderListener.added |
                                                Ci.nsIFolderListener.removed);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
--- a/mailnews/local/test/unit/test_pop3MoveFilter2.js
+++ b/mailnews/local/test/unit/test_pop3MoveFilter2.js
@@ -100,18 +100,17 @@ function folderCount(folder)
 
 function run_test()
 {
   // Make sure we're not quarantining messages
   Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
   if (!localAccountUtils.inboxFolder)
     localAccountUtils.loadLocalMailAccount();
 
-  gMoveFolder = localAccountUtils.incomingServer
-                                 .rootFolder.createLocalSubfolder("MoveFolder");
+  gMoveFolder = localAccountUtils.rootFolder.createLocalSubfolder("MoveFolder");
 
   MailServices.mailSession.AddFolderListener(FolderListener,
                                              Ci.nsIFolderListener.event |
                                                Ci.nsIFolderListener.added |
                                                Ci.nsIFolderListener.removed);
 
   // "Master" do_test_pending(), paired with a do_test_finished() at the end of
   // all the operations.
--- a/mailnews/mime/test/unit/test_mimeStreaming.js
+++ b/mailnews/mime/test/unit/test_mimeStreaming.js
@@ -1,17 +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/. */
 
 /**
  * This test iterates over the test files in gTestFiles, and streams
  * each as a message and makes sure the streaming doesn't assert or crash.
  */
-load("../../../resources/localAccountUtils.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 Components.utils.import("resource:///modules/IOUtils.js");
 
 var gTestFiles =[ 
   "../../../data/bug505221",
   "../../../data/bug513543",
 ];
 
 var gMsgEnumerator;
--- a/mailnews/news/test/unit/head_server_setup.js
+++ b/mailnews/news/test/unit/head_server_setup.js
@@ -1,29 +1,25 @@
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource:///modules/mailServices.js");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://testing-common/mailnews/mailDirService.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 var Cr = Components.results;
 var CC = Components.Constructor;
 
 var gProfileDir = ProfileDir.initialize(do_get_profile());
 
 // Import the servers
 Components.utils.import("resource://testing-common/mailnews/maild.js");
 Components.utils.import("resource://testing-common/mailnews/nntpd.js");
 
-// Generic mailnews resource scripts
-load("../../../resources/localAccountUtils.js");
-
-Components.utils.import("resource:///modules/mailServices.js");
-
 const kSimpleNewsArticle =
   "From: John Doe <john.doe@example.com>\n"+
   "Date: Sat, 24 Mar 1990 10:59:24 -0500\n"+
   "Newsgroups: test.subscribe.simple\n"+
   "Subject: H2G2 -- What does it mean?\n"+
   "Message-ID: <TSS1@nntp.invalid>\n"+
   "\n"+
   "What does the acronym H2G2 stand for? I've seen it before...\n";
--- a/mailnews/test/resources/IMAPpump.js
+++ b/mailnews/test/resources/IMAPpump.js
@@ -7,35 +7,33 @@
  *  of its use can be found in test_imapPump.js
  *
  * The code that forms the core of this file, in its original incarnation,
  *  was test_imapFolderCopy.js  There have been several iterations since
  *  then.
  */
 
 Components.utils.import("resource:///modules/mailServices.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 // Make sure we execute this file exactly once
 if (typeof gIMAPpump_js__ == "undefined") {
 var gIMAPpump_js__ = true;
 
 // We can be executed from multiple depths
 // Provide understandable error message
 if (typeof gDEPTH == "undefined")
   do_throw("gDEPTH must be defined when using IMAPpump.js");
 
 // add imap fake server methods if missing
 
 Components.utils.import("resource://testing-common/mailnews/maild.js");
 Components.utils.import("resource://testing-common/mailnews/auth.js");
 Components.utils.import("resource://testing-common/mailnews/imapd.js");
 
-// Add localAccountUtils for create_incoming_server
-load(gDEPTH + "mailnews/resources/localAccountUtils.js");
-
 // define globals
 var gIMAPDaemon;         // the imap fake server daemon
 var gIMAPServer;         // the imap fake server
 var gIMAPIncomingServer; // nsIMsgIncomingServer for the imap server
 var gIMAPInbox;          // nsIMsgFolder/nsIMsgImapMailFolder for imap inbox
 var gIMAPMailbox;        // imap fake server mailbox
 var gAppInfo;            // application info
 
--- a/mailnews/test/resources/POP3pump.js
+++ b/mailnews/test/resources/POP3pump.js
@@ -11,30 +11,28 @@
  *
  * adapted from test_pop3GetNewMail.js
  *
  * Original Author: Kent James <kent@caspia.com>
  *
  */
 
 Components.utils.import("resource:///modules/mailServices.js");
+Components.utils.import("resource://testing-common/mailnews/localAccountUtils.js");
 
 // We can be executed from multiple depths
 // Provide understandable error message
 if (typeof gDEPTH == "undefined")
   do_throw("gDEPTH must be defined when using IMAPpump.js");
 
 // Import the pop3 server scripts
 Components.utils.import("resource://testing-common/mailnews/maild.js");
 Components.utils.import("resource://testing-common/mailnews/auth.js");
 Components.utils.import("resource://testing-common/mailnews/pop3d.js");
 
-// Add localAccountUtils for create_incoming_server
-load(gDEPTH + "mailnews/resources/localAccountUtils.js");
-
 function POP3Pump()
 {
   // public attributes
   this.fakeServer = null;
   this.onDone = null;
   this.files = null;
 
   // local private variables
--- a/mailnews/test/resources/localAccountUtils.js
+++ b/mailnews/test/resources/localAccountUtils.js
@@ -1,16 +1,21 @@
 /* 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/. */
 
-// Make sure we execute this file exactly once
-var gLocalAccountUtils_js__;
-if (!gLocalAccountUtils_js__) {
-gLocalAccountUtils_js__ = true;
+const EXPORTED_SYMBOLS = ['localAccountUtils'];
+
+// MailServices
+Components.utils.import("resource:///modules/mailServices.js");
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cr = Components.results;
+var CC = Components.Constructor;
 
 // Local Mail Folders. Requires prior setup of profile directory
 
 var localAccountUtils = {
   inboxFolder: undefined,
   incomingServer: undefined,
   rootFolder: undefined,
   msgAccount: undefined,
@@ -109,10 +114,8 @@ var localAccountUtils = {
 
     if (aIncoming instanceof Ci.nsIMsgIncomingServer)
       aIncoming = MailServices.accounts.FindAccountForServer(aIncoming);
     aIncoming.addIdentity(identity);
     if (aSetAsDefault)
       aIncoming.defaultIdentity = identity;
   }
 };
-
-}; // gLocalAccountUtils_js__
\ No newline at end of file