Bug 1503734 - Remove needless constants for nsMsgFolderFlags. r=jorgk DONTBUILD
authoraceman <acelists@atlas.sk>
Wed, 31 Oct 2018 16:38:00 +0100
changeset 33639 86c5e6686ff369415311612453b2b6c966683e72
parent 33638 29028feb0c71338166c9d4fc24cbad6312334f4c
child 33640 87943872543e306a510525a2a02502564ff49f18
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersjorgk
bugs1503734
Bug 1503734 - Remove needless constants for nsMsgFolderFlags. r=jorgk DONTBUILD
mail/base/content/folderDisplay.js
mail/base/content/folderPane.js
mail/base/content/mail3PaneWindowCommands.js
mail/base/content/mailContextMenus.js
mail/base/content/mailWindowOverlay.js
mail/base/content/msgMail3PaneWindow.js
mail/base/content/msgViewNavigation.js
mail/base/content/phishingDetector.js
mail/base/content/threadPane.js
mail/components/activity/modules/moveCopy.jsm
mail/test/mozmill/folder-pane/test-display-message-with-folder-modes.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-tree-modes/test-unread-folders.js
mailnews/base/content/folderProps.js
mailnews/base/content/msgSelectOfflineFolders.js
mailnews/base/util/folderUtils.jsm
mailnews/db/gloda/modules/index_msg.js
mailnews/db/msgdb/test/unit/test_filter_enumerator.js
mailnews/imap/test/unit/test_imapContentLength.js
mailnews/imap/test/unit/test_listSubscribed.js
mailnews/imap/test/unit/test_lsub.js
mailnews/imap/test/unit/test_nsIMsgFolderListenerIMAP.js
mailnews/local/test/unit/test_nsIMsgLocalMailFolder.js
--- a/mail/base/content/folderDisplay.js
+++ b/mail/base/content/folderDisplay.js
@@ -5,19 +5,16 @@
 ChromeUtils.import("resource:///modules/DBViewWrapper.jsm");
 ChromeUtils.import("resource:///modules/jsTreeSelection.js");
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gFolderDisplay = null;
 var gMessageDisplay = null;
 
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-var nsMsgMessageFlags = Ci.nsMsgMessageFlags;
-
 /**
  * Maintains a list of listeners for all FolderDisplayWidget instances in this
  *  window.  The assumption is that because of our multiplexed tab
  *  implementation all consumers are effectively going to care about all such
  *  tabs.
  *
  * We are not just a global list so that we can add brains about efficiently
  *  building lists, provide try-wrapper convenience, etc.
@@ -542,18 +539,16 @@ FolderDisplayWidget.prototype = {
     this._persistColumnStates(this.getColumnStates());
   },
 
   /**
    * Either inherit the column state of another folder or use heuristics to
    *  figure out the best column state for the current folder.
    */
   _getDefaultColumnsForCurrentFolder: function(aDoNotInherit) {
-    const InboxFlag = Ci.nsMsgFolderFlags.Inbox;
-
     // If the view is synthetic, try asking it for its default columns. If it
     // fails, just return nothing, since most synthetic views don't care about
     // columns anyway.
     if (this.view.isSynthetic) {
       if ("getDefaultSetting" in this.view._syntheticView)
         return this.view._syntheticView.getDefaultSetting("columns");
       return {};
     }
@@ -570,24 +565,24 @@ FolderDisplayWidget.prototype = {
     //    (Although we could try and see if they have opened any other news
     //    folders in the same account.  But it's not all that important to us.)
     // - It's an inbox!
     let doNotInherit = aDoNotInherit ||
       this.view.isOutgoingFolder ||
       this.view.isVirtual ||
       this.view.isMultiFolder ||
       this.view.isNewsFolder ||
-      this.displayedFolder.flags & InboxFlag;
+      this.displayedFolder.getFlag(Ci.nsMsgFolderFlags.Inbox);
 
     // Try and grab the inbox for this account's settings.  we may not be able
     //  to, in which case we just won't inherit.  (It ends up the same since the
     //  inbox is obviously not customized in this case.)
     if (!doNotInherit) {
       let inboxFolder =
-        this.displayedFolder.rootFolder.getFolderWithFlags(InboxFlag);
+        this.displayedFolder.rootFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Inbox);
       if (inboxFolder) {
         let state = this._depersistColumnStatesFromDbFolderInfo(
                       inboxFolder.msgDatabase.dBFolderInfo);
         // inbox message databases don't get closed as a matter of policy.
 
         if (state)
           return state;
       }
@@ -1900,17 +1895,17 @@ FolderDisplayWidget.prototype = {
     // if we're doing next unread, and a collapsed thread is selected, and
     // the top level message is unread, just set the result manually to
     // the top level message, without using viewNavigate.
     if (summarizeSelection &&
         aNavType == nsMsgNavigationType.nextUnreadMessage &&
         currentIndex != -1 &&
         this.view.isCollapsedThreadAtIndex(currentIndex) &&
         !(this.view.dbView.getFlagsAt(currentIndex) &
-          nsMsgMessageFlags.Read)) {
+          Ci.nsMsgMessageFlags.Read)) {
       viewIndex = currentIndex;
     }
     else {
       // always 'wrap' because the start index is relative to the selection.
       // (keep in mind that many forms of navigation do not care about the
       //  starting position or 'wrap' at all; for example, firstNew just finds
       //  the first new message.)
       // allegedly this does tree-expansion for us.
@@ -1996,27 +1991,27 @@ FolderDisplayWidget.prototype = {
   },
 
   /**
    * @return true if there is a selected message and it's an IMAP message.
    */
   get selectedMessageIsImap() {
     let message = this.selectedMessage;
     return Boolean(message && message.folder &&
-                   message.folder.flags & nsMsgFolderFlags.ImapBox);
+                   message.folder.flags & Ci.nsMsgFolderFlags.ImapBox);
   },
 
   /**
    * @return true if there is a selected message and it's a news message.  It
    *  would be great if messages knew this about themselves, but they don't.
    */
   get selectedMessageIsNews() {
     let message = this.selectedMessage;
     return Boolean(message && message.folder &&
-                   (message.folder.flags & nsMsgFolderFlags.Newsgroup));
+                   (message.folder.flags & Ci.nsMsgFolderFlags.Newsgroup));
   },
 
   /**
    * @return true if there is a selected message and it's an external message,
    *  meaning it is loaded from an .eml file on disk or is an rfc822 attachment
    *  on a message.
    */
   get selectedMessageIsExternal() {
@@ -2043,17 +2038,17 @@ FolderDisplayWidget.prototype = {
 
   /**
    * @return true if there is a selected message and the message is the base
    *              message for an ignored subthread.
    */
   get selectedMessageSubthreadIgnored() {
     let message = this.selectedMessage;
     return Boolean(message && message.folder &&
-                   (message.flags & nsMsgMessageFlags.Ignored));
+                   (message.flags & Ci.nsMsgMessageFlags.Ignored));
   },
 
   /**
    * @return true if there is a selected message and the message belongs to a
    *              watched thread.
    */
   get selectedMessageThreadWatched() {
     let message = this.selectedMessage;
--- a/mail/base/content/folderPane.js
+++ b/mail/base/content/folderPane.js
@@ -15,18 +15,16 @@ ChromeUtils.import("resource:///modules/
 ChromeUtils.import("resource:///modules/FeedUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 if (typeof FeedMessageHandler != "object")
   Services.scriptloader.loadSubScript("chrome://messenger-newsblog/content/newsblogOverlay.js");
 
 var kDefaultMode = "all";
 
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-
 /**
  * This file contains the controls and functions for the folder pane.
  * The following definitions will be useful to know:
  *
  * gFolderTreeView - the controller for the folder tree.
  * ftvItem  - folder tree view item, representing a row in the tree
  * mode - folder view type, e.g., all folders, favorite folders, MRU...
  */
@@ -719,17 +717,17 @@ var gFolderTreeView = {
         // Don't copy within same server.
         if ((folder.server == targetFolder.server) &&
              (dt.dropEffect == 'copy'))
           return false;
         // Don't allow immediate child to be dropped onto its parent.
         if (targetFolder == folder.parent)
           return false;
         // Don't allow dragging of virtual folders across accounts.
-        if ((folder.flags & nsMsgFolderFlags.Virtual) &&
+        if ((folder.getFlag(Ci.nsMsgFolderFlags.Virtual)) &&
             folder.server != targetFolder.server)
           return false;
         // Don't allow parent to be dropped on its ancestors.
         if (folder.isAncestorOf(targetFolder))
           return false;
         // If there is a folder that can't be renamed, don't allow it to be
         // dropped if it is not to "Local Folders" or is to the same account.
         if (!folder.canRename && (targetFolder.server.type != "none" ||
@@ -1160,17 +1158,17 @@ var gFolderTreeView = {
     let folders = [];
     for (let acct of accounts) {
       let foldersWithFlag = acct.incomingServer.rootFolder.getFoldersWithFlags(aFolderFlag);
       if (foldersWithFlag.length > 0) {
         for (let folderWithFlag of fixIterator(foldersWithFlag,
                                                Ci.nsIMsgFolder)) {
           folders.push(folderWithFlag);
           // Add sub-folders of Sent and Archive to the result.
-          if (deep && (aFolderFlag & (nsMsgFolderFlags.SentMail | nsMsgFolderFlags.Archive)))
+          if (deep && (aFolderFlag & (Ci.nsMsgFolderFlags.SentMail | Ci.nsMsgFolderFlags.Archive)))
             this.addSubFolders(folderWithFlag, folders);
         }
       }
     }
     return folders;
   },
 
   /**
@@ -1198,17 +1196,17 @@ var gFolderTreeView = {
   _addSmartFoldersForFlag: function ftv_addSFForFlag(map, accounts, smartRootFolder,
                                                      flag, folderName, position)
   {
     // If there's only one subFolder, just put it at the root.
     let subFolders = gFolderTreeView._allSmartFolders(accounts, flag, folderName, false);
     if (flag && subFolders.length == 1) {
       let folderItem = new ftvItem(subFolders[0]);
       folderItem._level = 0;
-      if (flag & nsMsgFolderFlags.Inbox)
+      if (flag & Ci.nsMsgFolderFlags.Inbox)
         folderItem.__defineGetter__("children", () => []);
       if (position == undefined)
         map.push(folderItem);
       else
         map[position] = folderItem;
       // No smart folder was added
       return null;
     }
@@ -1247,17 +1245,17 @@ var gFolderTreeView = {
 
     let prevChild = null;
     // Each child is a level one below the smartFolder
     for (let child of smartFolderItem._children) {
       child._level = smartFolderItem._level + 1;
       child._parent = smartFolderItem;
       // don't show sub-folders of the inbox, but I think Archives/Sent, etc
       // should have the sub-folders.
-      if (flag & nsMsgFolderFlags.Inbox)
+      if (flag & Ci.nsMsgFolderFlags.Inbox)
         child.__defineGetter__("children", () => []);
       // If we have consecutive children with the same server, then both
       // should display as folder - server.
       if (prevChild && (child._folder.server == prevChild._folder.server)) {
         child.addServerName = true;
         prevChild.addServerName = true;
         prevChild.useServerNameOnly = false;
       }
@@ -1276,17 +1274,17 @@ var gFolderTreeView = {
                                                searchFolderURIs, folderFlag)
   {
     let newFolder;
     try {
       if (parentFolder instanceof(Ci.nsIMsgLocalMailFolder))
         newFolder = parentFolder.createLocalSubfolder(newName);
       else
         newFolder = parentFolder.addSubfolder(newName);
-      newFolder.setFlag(nsMsgFolderFlags.Virtual);
+      newFolder.setFlag(Ci.nsMsgFolderFlags.Virtual);
       // provide a way to make the top level folder just a container, not
       // a search folder
       let type = this._modes["smart"].getSmartFolderTypeByName(newName);
       if (type[3]) { // isSearch
         let vfdb = newFolder.msgDatabase;
         let dbFolderInfo = vfdb.dBFolderInfo;
         // set the view string as a property of the db folder info
         // set the original folder name as well.
@@ -1645,17 +1643,17 @@ var gFolderTreeView = {
 
       generateMap: function ftv_favorite_generateMap(ftv) {
         let accounts = gFolderTreeView._sortedAccounts();
         // Force each root folder to do its local subfolder discovery.
         MailUtils.discoverFolders();
 
         let favRootFolders = [];
         let filterFavorite = function filterFavorite(aFolder) {
-          return aFolder.getFolderWithFlags(nsMsgFolderFlags.Favorite) != null;
+          return aFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Favorite) != null;
         }
         for (let acct of accounts) {
           let rootFolder = acct.incomingServer.rootFolder;
           // Add rootFolders of accounts that contain at least one Favorite folder.
           if (filterFavorite(rootFolder))
             favRootFolders.push(new ftvItem(rootFolder, filterFavorite));
         }
 
@@ -1679,17 +1677,17 @@ var gFolderTreeView = {
      * and the unread folders are shown in a compact list with no hierarchy.
      */
     favorite_compact: {
       __proto__: IFolderTreeMode,
 
       generateMap: function(ftv) {
         let faves = [];
         for (let folder of ftv._enumerateFolders) {
-          if (folder.getFlag(nsMsgFolderFlags.Favorite))
+          if (folder.getFlag(Ci.nsMsgFolderFlags.Favorite))
             faves.push(new ftvItem(folder));
         }
 
         // We want to display the account name alongside folders that have
         // duplicated folder names.
         let uniqueNames = new Set(); // set of folder names seen at least once
         let dupeNames = new Set(); // set of folders seen at least twice
         for (let item of faves) {
@@ -1800,24 +1798,24 @@ var gFolderTreeView = {
 
       /**
        * A list of [flag, name, isDeep, isSearch] for smart folders. isDeep ==
        * false means that subfolders are displayed as subfolders of the account,
        * not of the smart folder. This list is expected to be constant through a
        * session.
        */
       _flagNameList: [
-        [nsMsgFolderFlags.Inbox, "Inbox", false, true],
-        [nsMsgFolderFlags.Drafts, "Drafts", false, true],
-        [nsMsgFolderFlags.SentMail, "Sent", true, true],
-        [nsMsgFolderFlags.Trash, "Trash", true, true],
-        [nsMsgFolderFlags.Templates, "Templates", false, true],
-        [nsMsgFolderFlags.Archive, "Archives", true, true],
-        [nsMsgFolderFlags.Junk, "Junk", false, true],
-        [nsMsgFolderFlags.Queue, "Outbox", true, true]
+        [Ci.nsMsgFolderFlags.Inbox, "Inbox", false, true],
+        [Ci.nsMsgFolderFlags.Drafts, "Drafts", false, true],
+        [Ci.nsMsgFolderFlags.SentMail, "Sent", true, true],
+        [Ci.nsMsgFolderFlags.Trash, "Trash", true, true],
+        [Ci.nsMsgFolderFlags.Templates, "Templates", false, true],
+        [Ci.nsMsgFolderFlags.Archive, "Archives", true, true],
+        [Ci.nsMsgFolderFlags.Junk, "Junk", false, true],
+        [Ci.nsMsgFolderFlags.Queue, "Outbox", true, true]
       ],
 
       /**
        * support for addons to add special folder types, this must be called
        * prior to onload.
        *
        * @param aFolderName  name of the folder
        * @param isDeep  include subfolders
@@ -2094,17 +2092,17 @@ var gFolderTreeView = {
     let parent = null;
     let parentIndex = -1;
     let newChild;
     let newChildIndex = 0;
     if (!smartFolder || this.getIndexOfFolder(smartFolder) == null) {
       newChild = new ftv_SmartItem(aItem);
       newChild._level = 0;
       while (newChildIndex < this.rowCount) {
-        if (this._rowMap[newChildIndex]._folder.flags & aFlag) {
+        if (this._rowMap[newChildIndex]._folder.getFlag(aFlag)) {
           // This type of folder seems to already exist, so replace the row
           // with a smartFolder.
           this._addSmartFoldersForFlag(this._rowMap, this._sortedAccounts(),
                                        aSmartRoot, aFlag, aName, newChildIndex);
           return;
         }
         if (this._rowMap[newChildIndex]._folder.isServer)
           break;
@@ -2118,17 +2116,17 @@ var gFolderTreeView = {
 
       newChild = new ftv_SmartItem(aItem);
       parent.children.push(newChild);
       newChild._level = parent._level + 1;
       newChild._parent = parent;
       sortFolderItems(parent._children);
       newChild.useServerNameOnly = true;
     }
-    if (aItem.flags & nsMsgFolderFlags.Inbox)
+    if (aItem.getFlag(Ci.nsMsgFolderFlags.Inbox))
       newChild.__defineGetter__("children", () => []);
     if (parent)
       this._addChildToView(parent, parentIndex, newChild);
     else {
       this._rowMap.splice(newChildIndex, 0, newChild);
       this._tree.rowCountChanged(newChildIndex, 1);
     }
   },
@@ -2183,17 +2181,17 @@ var gFolderTreeView = {
     // Otherwise, just invalidate the parent row. Note that this code doesn't
     // get called for the smart folder case.
     if (!parent.open) {
       // Special case adding a special folder when the parent is collapsed.
       // Expand the parent so the user can see the special child.
       // Expanding the parent is sufficient to add the folder to the view,
       // because either we knew about it, or we will have added a child item
       // for it above.
-      if (newChild._folder.flags & nsMsgFolderFlags.SpecialUse) {
+      if (newChild._folder.getFlag(Ci.nsMsgFolderFlags.SpecialUse)) {
         this._toggleRow(parentIndex, false);
         return;
       }
     }
     this._addChildToView(parent, parentIndex, newChild);
   },
 
   OnItemRemoved: function ftl_remove(aRDFParentItem, aItem) {
@@ -2401,17 +2399,17 @@ ftvItem.prototype = {
   },
 
   getProperties: function (aColumn) {
     if (aColumn && aColumn.id != "folderNameCol")
       return "";
 
     // From folderUtils.jsm
     let properties = getFolderProperties(this._folder, this.open);
-    if (this._folder.getFlag(nsMsgFolderFlags.Virtual)) {
+    if (this._folder.getFlag(Ci.nsMsgFolderFlags.Virtual)) {
       properties += " specialFolder-Smart";
       // a second possibility for customized smart folders
       properties += " specialFolder-" + this._folder.name.replace(/\s+/g, "");
     }
     // if there is a smartFolder name property, add it
     let smartFolderName = getSmartFolderName(this._folder);
     if (smartFolderName) {
       properties += " specialFolder-" + smartFolderName.replace(/\s+/g, "");
@@ -2515,17 +2513,17 @@ var gFolderTreeController = {
     let folder = aFolder || gFolderTreeView.getSelectedFolders()[0];
 
     // If this is actually a server, send it off to that controller
     if (folder.isServer) {
       MsgAccountManager(null, folder.server);
       return;
     }
 
-    if (folder.flags & nsMsgFolderFlags.Virtual) {
+    if (folder.getFlag(Ci.nsMsgFolderFlags.Virtual)) {
       this.editVirtualFolder(folder);
       return;
     }
     let title = gFolderTreeView.messengerBundle
                                .getString("folderProperties");
 
     //xxx useless param
     function editFolderCallback(aNewName, aOldName, aUri) {
@@ -2614,28 +2612,28 @@ var gFolderTreeController = {
    *
    * @param aFolder (optional) the folder to delete, if not the selected one
    */
   deleteFolder: function ftc_delete(aFolder) {
     let folders = aFolder ? [aFolder] : gFolderTreeView.getSelectedFolders();
     let folder = folders[0];
 
     // For newsgroups, "delete" means "unsubscribe".
-    if (folder.server.type == "nntp" && !folder.getFlag(nsMsgFolderFlags.Virtual)) {
+    if (folder.server.type == "nntp" && !folder.getFlag(Ci.nsMsgFolderFlags.Virtual)) {
       MsgUnsubscribe(folders);
       return;
     }
 
-    var canDelete = (folder.isSpecialFolder(nsMsgFolderFlags.Junk, false)) ?
+    var canDelete = (folder.isSpecialFolder(Ci.nsMsgFolderFlags.Junk, false)) ?
       CanRenameDeleteJunkMail(folder.URI) : folder.deletable;
 
     if (!canDelete)
       throw new Error("Can't delete folder: " + folder.name);
 
-    if (folder.flags & nsMsgFolderFlags.Virtual) {
+    if (folder.getFlag(Ci.nsMsgFolderFlags.Virtual)) {
       let confirmation = gFolderTreeView.messengerBundle
                                         .getString("confirmSavedSearchDeleteMessage");
       let title = gFolderTreeView.messengerBundle
                                  .getString("confirmSavedSearchTitle");
       if (Services.prompt
             .confirmEx(window, title, confirmation,
                        Services.prompt.STD_YES_NO_BUTTONS + Services.prompt.BUTTON_POS_1_DEFAULT,
                        "", "", "", "", {}) != 0) /* the yes button is in position 0 */
@@ -2664,17 +2662,17 @@ var gFolderTreeController = {
       return;
 
       // Check if this is a top-level smart folder. If so, we're going
       // to empty all the trash folders.
       if (folder.server.hostName == "smart mailboxes" &&
           folder.parent.isServer) {
         let subFolders = gFolderTreeView
                            ._allFoldersWithFlag(gFolderTreeView._sortedAccounts(),
-                            nsMsgFolderFlags.Trash, false);
+                            Ci.nsMsgFolderFlags.Trash, false);
         for (let trash of subFolders)
           trash.emptyTrash(msgWindow, null);
       }
       else {
         folder.emptyTrash(msgWindow, null);
       }
   },
 
@@ -2682,17 +2680,17 @@ var gFolderTreeController = {
    * Deletes everything (folders and messages) in the selected folder.
    * The folder is only emptied if it has the proper Junk flag.
    *
    * @param aFolder (optional)  the folder to empty
    */
   emptyJunk: function ftc_emptyJunk(aFolder) {
     let folder = aFolder || gFolderTreeView.getSelectedFolders()[0];
 
-    if (!folder || !folder.getFlag(nsMsgFolderFlags.Junk))
+    if (!folder || !folder.getFlag(Ci.nsMsgFolderFlags.Junk))
       return;
 
     if (!this._checkConfirmationPrompt("emptyJunk", folder))
       return;
 
     // Delete any subfolders this folder might have
     let iter = folder.subFolders;
     while (iter.hasMoreElements())
@@ -2851,17 +2849,17 @@ ftv_SmartItem.prototype = {
     // We're caching our child list to save perf.
     if (!this._children) {
       this._children = [];
       let iter = fixIterator(this._folder.subFolders, Ci.nsIMsgFolder);
       for (let folder of iter) {
         if (!smartMode.isSmartFolder(folder)) {
           this._children.push(new ftv_SmartItem(folder));
         }
-        else if (folder.flags & nsMsgFolderFlags.Inbox) {
+        else if (folder.getFlag(Ci.nsMsgFolderFlags.Inbox)) {
           let subIter = fixIterator(folder.subFolders, Ci.nsIMsgFolder);
           for (let subfolder of subIter) {
             if (!smartMode.isSmartFolder(subfolder))
               this._children.push(new ftv_SmartItem(subfolder));
           }
         }
       }
       sortFolderItems(this._children);
--- a/mail/base/content/mail3PaneWindowCommands.js
+++ b/mail/base/content/mail3PaneWindowCommands.js
@@ -92,17 +92,17 @@ var FolderPaneController =
   }
 };
 
 function UpdateDeleteLabelsFromFolderCommand(folder, command)
 {
   if (command != "cmd_delete")
     return;
 
-  if (folder.getFlag(nsMsgFolderFlags.Virtual)) {
+  if (folder.getFlag(Ci.nsMsgFolderFlags.Virtual)) {
     goSetMenuValue(command, "valueFolder");
   }
   else if (folder.server.type == "nntp") {
     goSetMenuValue(command, "valueNewsgroup");
     goSetAccessKey(command, "valueNewsgroupAccessKey");
   }
   else {
     goSetMenuValue(command, "valueFolder");
@@ -287,17 +287,17 @@ var DefaultController =
         return gFolderDisplay.selectedCount == 1 &&
                gFolderDisplay.selectedMessageIsNews;
       case "cmd_deleteFolder":
         var folders = gFolderTreeView.getSelectedFolders();
         if (folders.length == 1) {
           let folder = folders[0];
           if (folder.server.type == "nntp") {
             // Just disable the command for news unless it is a Saved search folder.
-            return folder.getFlag(nsMsgFolderFlags.Virtual);
+            return folder.getFlag(Ci.nsMsgFolderFlags.Virtual);
           }
           return CanDeleteFolder(folder);
         }
         return false;
       case "button_junk":
         UpdateJunkToolbarButton();
         return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk);
       case "cmd_killThread":
@@ -526,17 +526,17 @@ var DefaultController =
         return folder && folder.server.canEmptyTrashOnExit ?
                          IsMailFolderSelected() : false;
       }
       case "button_compact":
       {
         let folders = gFolderTreeView.getSelectedFolders();
         let canCompact = function canCompact(folder) {
           return !folder.isServer &&
-            !(folder.flags & Ci.nsMsgFolderFlags.Virtual) &&
+            !(folder.getFlag(Ci.nsMsgFolderFlags.Virtual)) &&
             (folder.server.type != "imap" || folder.server.canCompactFoldersOnServer) &&
             folder.isCommandEnabled("button_compact");
         }
         return folders && folders.every(canCompact);
       }
       case "cmd_compactFolder":
       {
         let folders = gFolderTreeView.getSelectedFolders();
@@ -1251,17 +1251,17 @@ function IsPropertiesEnabled(command)
   var folders = GetSelectedMsgFolders();
   if (!folders.length)
     return false;
   var folder = folders[0];
 
   // when servers are selected it should be "Edit | Properties..."
   if (folder.isServer)
     goSetMenuValue(command, "valueGeneric");
-  else if (folder.getFlag(nsMsgFolderFlags.Virtual))
+  else if (folder.getFlag(Ci.nsMsgFolderFlags.Virtual))
     goSetMenuValue(command, "valueFolder");
   else
     goSetMenuValue(command, isNewsURI(folder.URI) ? "valueNewsgroup" : "valueFolder");
 
    return (folders.length == 1);
 }
 
 function IsViewNavigationItemEnabled()
--- a/mail/base/content/mailContextMenus.js
+++ b/mail/base/content/mailContextMenus.js
@@ -293,19 +293,18 @@ function CheckForMessageIdInFolder(folde
     messageHeader = messageDatabase.getMsgHdrForMessageID(messageId);
   }
   catch (ex)
   {
     Cu.reportError("Failed to find message-id in folder; " +
                    "messageId=" + messageId);
   }
 
-  const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
   if (!MailServices.mailSession.IsFolderOpenInWindow(folder) &&
-      !(folder.flags & (nsMsgFolderFlags.Trash | nsMsgFolderFlags.Inbox)))
+      !(folder.flags & (Ci.nsMsgFolderFlags.Trash | Ci.nsMsgFolderFlags.Inbox)))
   {
     folder.msgDatabase = null;
   }
 
   return messageHeader;
 }
 
 function folderPaneOnPopupHiding()
@@ -339,18 +338,17 @@ function fillFolderPaneContextMenu(aEven
   var bundle = document.getElementById("bundle_messenger");
   var folders = gFolderTreeView.getSelectedFolders();
   if (!folders.length)
     return false;
 
   var numSelected = folders.length;
 
   function checkIsVirtualFolder(folder) {
-    const kVirtualFlag = Ci.nsMsgFolderFlags.Virtual;
-    return folder.flags & kVirtualFlag;
+    return folder.getFlag(Ci.nsMsgFolderFlags.Virtual);
   }
   var haveAnyVirtualFolders = folders.some(checkIsVirtualFolder);
 
   function checkIsServer(folder) {
     return folder.isServer;
   }
   var selectedServers = folders.filter(checkIsServer);
 
@@ -360,44 +358,44 @@ function fillFolderPaneContextMenu(aEven
                                           getSpecialFolderString(folders[0]);
 
   function checkCanSubscribeToFolder(folder) {
     if (checkIsVirtualFolder(folder))
       return false;
 
     // All feed account folders, besides Trash, are subscribable.
     if (folder.server.type == "rss" &&
-        !(folder.flags & nsMsgFolderFlags.Trash))
+        !(folder.getFlag(Ci.nsMsgFolderFlags.Trash)))
       return true;
 
     // We only want the subscribe item on the account nodes.
     if (!folder.isServer)
       return false;
 
     return folder.server.type == "nntp" ||
            folder.server.type == "imap";
   }
   var haveOnlySubscribableFolders = folders.every(checkCanSubscribeToFolder);
 
   function checkIsNewsgroup(folder) {
     return !folder.isServer && folder.server.type == "nntp" &&
-           !folder.getFlag(nsMsgFolderFlags.Virtual);
+           !folder.getFlag(Ci.nsMsgFolderFlags.Virtual);
   }
   var haveOnlyNewsgroups = folders.every(checkIsNewsgroup);
 
   function checkIsMailFolder(folder) {
     return !folder.isServer && folder.server.type != "nntp";
   }
   var haveOnlyMailFolders = folders.every(checkIsMailFolder);
 
   function checkCanGetMessages(folder) {
-    const kTrashFlag = Ci.nsMsgFolderFlags.Trash;
     return (folder.isServer && (folder.server.type != "none")) ||
            checkIsNewsgroup(folder) ||
-           ((folder.server.type == "rss") && !folder.isSpecialFolder(kTrashFlag, true) &&
+           ((folder.server.type == "rss") &&
+            !folder.isSpecialFolder(Ci.nsMsgFolderFlags.Trash, true) &&
              !checkIsVirtualFolder(folder));
   }
   var selectedFoldersThatCanGetMessages = folders.filter(checkCanGetMessages);
 
   // --- Set up folder properties / account settings menu item.
   if (numSelected != 1) {
     ShowMenuItem("folderPaneContext-settings", false);
     ShowMenuItem("folderPaneContext-properties", false);
@@ -487,53 +485,51 @@ function fillFolderPaneContextMenu(aEven
                    !folders[0].isServer && folders[0].isCommandEnabled("cmd_renameFolder"));
   }
   else {
     ShowMenuItem("folderPaneContext-rename", false);
   }
 
   // --- Set up the delete folder menu item.
   function checkCanDeleteFolder(folder) {
-    if (folder.isSpecialFolder(nsMsgFolderFlags.Junk, false))
+    if (folder.isSpecialFolder(Ci.nsMsgFolderFlags.Junk, false))
       return CanRenameDeleteJunkMail(folder.URI);
     return folder.deletable;
   }
   var haveOnlyDeletableFolders = folders.every(checkCanDeleteFolder);
   ShowMenuItem("folderPaneContext-remove", haveOnlyDeletableFolders && numSelected == 1);
 
   function checkIsDeleteEnabled(folder) {
     return folder.isCommandEnabled("cmd_delete");
   }
   var haveOnlyDeleteEnabledFolders = folders.every(checkIsDeleteEnabled);
   EnableMenuItem("folderPaneContext-remove", haveOnlyDeleteEnabledFolders);
 
   // --- Set up the compact folder menu item.
   function checkCanCompactFolder(folder) {
-    const kVirtualFlag = Ci.nsMsgFolderFlags.Virtual;
-    return folder.canCompact && !(folder.flags & kVirtualFlag) &&
+    return folder.canCompact && !(folder.getFlag(Ci.nsMsgFolderFlags.Virtual)) &&
            folder.isCommandEnabled("cmd_compactFolder");
   }
   var haveOnlyCompactableFolders = folders.every(checkCanCompactFolder);
   ShowMenuItem("folderPaneContext-compact", haveOnlyCompactableFolders);
 
   function checkIsCompactEnabled(folder) {
     return folder.isCommandEnabled("cmd_compactFolder");
   }
   var haveOnlyCompactEnabledFolders = folders.every(checkIsCompactEnabled);
   EnableMenuItem("folderPaneContext-compact", haveOnlyCompactEnabledFolders);
 
   // --- Set up favorite folder menu item.
   ShowMenuItem("folderPaneContext-favoriteFolder",
                numSelected == 1 && !folders[0].isServer);
   if (numSelected == 1 && !folders[0].isServer)
   {
-    const kFavoriteFlag = Ci.nsMsgFolderFlags.Favorite;
      // Adjust the checked state on the menu item.
     document.getElementById("folderPaneContext-favoriteFolder")
-            .setAttribute("checked", folders[0].getFlag(kFavoriteFlag));
+            .setAttribute("checked", folders[0].getFlag(Ci.nsMsgFolderFlags.Favorite));
   }
 
   // --- Set up the empty trash menu item.
   ShowMenuItem("folderPaneContext-emptyTrash",
                numSelected == 1 && specialFolder == "Trash");
 
   // --- Set up the empty junk menu item.
   ShowMenuItem("folderPaneContext-emptyJunk",
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -70,20 +70,19 @@ function menu_new_init()
 
   let folder = gFolderDisplay.displayedFolder;
   if (!folder)
     return;
 
   if (Services.prefs.prefIsLocked("mail.disable_new_account_addition"))
     document.getElementById("newAccountMenuItem").setAttribute("disabled", "true");
 
-  const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-  var isInbox = folder.isSpecialFolder(nsMsgFolderFlags.Inbox);
+  var isInbox = folder.isSpecialFolder(Ci.nsMsgFolderFlags.Inbox);
   var showNew = (folder.canCreateSubfolders ||
-                 (isInbox && !(folder.flags & nsMsgFolderFlags.Virtual))) &&
+                 (isInbox && !(folder.getFlag(Ci.nsMsgFolderFlags.Virtual)))) &&
                 (document.getElementById("cmd_newFolder").getAttribute("disabled") != "true");
   ShowMenuItem("menu_newFolder", showNew);
   ShowMenuItem("menu_newVirtualFolder", showNew);
 
   EnableMenuItem("menu_newFolder", folder.server.type != "imap" || MailOfflineMgr.isOnline());
   if (showNew)
   {
     var bundle = document.getElementById("bundle_messenger");
@@ -131,19 +130,19 @@ function InitEditMessagesMenu()
   goSetAccessKey('cmd_delete', 'valueDefaultAccessKey');
   document.commandDispatcher.updateCommands('create-menu-edit');
 
   // initialize the favorite Folder checkbox in the edit menu
   let favoriteFolderMenu = document.getElementById('menu_favoriteFolder');
   if (!favoriteFolderMenu.hasAttribute("disabled")) {
     let folders = gFolderTreeView.getSelectedFolders();
     if (folders.length == 1 && !folders[0].isServer) {
-      const kFavoriteFlag = Ci.nsMsgFolderFlags.Favorite;
       // Adjust the checked state on the menu item.
-      favoriteFolderMenu.setAttribute("checked", folders[0].getFlag(kFavoriteFlag));
+      favoriteFolderMenu.setAttribute("checked",
+        folders[0].getFlag(Ci.nsMsgFolderFlags.Favorite));
       favoriteFolderMenu.hidden = false;
     } else {
       favoriteFolderMenu.hidden = true;
     }
   }
 }
 
 function InitAppFolderViewsMenu()
@@ -152,19 +151,19 @@ function InitAppFolderViewsMenu()
   goSetAccessKey('cmd_delete', 'valueDefaultAccessKey');
   document.commandDispatcher.updateCommands('create-menu-edit');
 
   // initialize the favorite Folder checkbox in the appmenu menu
   let favoriteAppFolderMenu = document.getElementById('appmenu_favoriteFolder');
   if (!favoriteAppFolderMenu.hasAttribute("disabled")) {
     let folders = gFolderTreeView.getSelectedFolders();
     if (folders.length == 1 && !folders[0].isServer) {
-      const kFavoriteFlag = Ci.nsMsgFolderFlags.Favorite;
       // Adjust the checked state on the menu item.
-      favoriteAppFolderMenu.setAttribute("checked", folders[0].getFlag(kFavoriteFlag));
+      favoriteAppFolderMenu.setAttribute("checked",
+        folders[0].getFlag(Ci.nsMsgFolderFlags.Favorite));
       favoriteAppFolderMenu.hidden = false;
     } else {
       favoriteAppFolderMenu.hidden = true;
     }
   }
 }
 
 function InitGoMessagesMenu()
@@ -1425,18 +1424,17 @@ function GetFirstSelectedMsgFolder()
 }
 
 function GetInboxFolder(server)
 {
   try {
     var rootMsgFolder = server.rootMsgFolder;
 
     // Now find the Inbox.
-    const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-    return rootMsgFolder.getFolderWithFlags(nsMsgFolderFlags.Inbox);
+    return rootMsgFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Inbox);
   }
   catch (ex) {
     dump(ex + "\n");
   }
   return null;
 }
 
 function GetMessagesForInboxOnServer(server)
@@ -2840,18 +2838,17 @@ function SendUnsentMessages()
   }
 }
 
 function CoalesceGetMsgsForPop3ServersByDestFolder(currentServer,
                                                    pop3DownloadServersArray,
                                                    localFoldersToDownloadTo)
 {
   var outNumFolders = new Object();
-  const kInboxFlag = Ci.nsMsgFolderFlags.Inbox;
-  var inboxFolder = currentServer.rootMsgFolder.getFolderWithFlags(kInboxFlag);
+  var inboxFolder = currentServer.rootMsgFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Inbox);
   // coalesce the servers that download into the same folder...
   var index = localFoldersToDownloadTo.indexOf(inboxFolder);
   if (index == -1)
   {
     if (inboxFolder)
     {
       inboxFolder.biffState =  Ci.nsIMsgFolder.nsMsgBiffState_NoMail;
       inboxFolder.clearNewMessages();
@@ -2998,20 +2995,19 @@ function HandleJunkStatusChanged(folder)
       // unsanitized. Otherwise we wouldn't see the reloaded version anyway.
       // 1) When marking as non-junk from the Junk folder, the msg would move
       //    back to the Inbox -> no reload needed
       //    When marking as non-junk from a folder other than the Junk folder,
       //    the message isn't moved back to Inbox -> reload needed
       //    (see nsMsgDBView::DetermineActionsForJunkChange)
       // 2) When marking as junk, the msg will move or delete, if manualMark is set.
       // 3) Marking as junk in the junk folder just changes the junk status.
-      const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-      if ((!isJunk && !folder.isSpecialFolder(nsMsgFolderFlags.Junk)) ||
+      if ((!isJunk && !folder.isSpecialFolder(Ci.nsMsgFolderFlags.Junk)) ||
           (isJunk && !folder.server.spamSettings.manualMark) ||
-          (isJunk && folder.isSpecialFolder(nsMsgFolderFlags.Junk)))
+          (isJunk && folder.isSpecialFolder(Ci.nsMsgFolderFlags.Junk)))
         ReloadMessage();
     }
   }
 }
 
 /**
  * Object to handle message related notifications that are showing in a
  * notificationbox above the message content.
@@ -3204,18 +3200,17 @@ var gMessageNotificationBar =
       null, this.msgNotificationBar.PRIORITY_INFO_MEDIUM, buttons);
   },
 
   setDraftEditMessage: function() {
    let msgHdr = gFolderDisplay.selectedMessage;
    if (!msgHdr || !msgHdr.folder)
      return;
 
-   const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-   if (msgHdr.folder.isSpecialFolder(nsMsgFolderFlags.Drafts, true))
+   if (msgHdr.folder.isSpecialFolder(Ci.nsMsgFolderFlags.Drafts, true))
    {
     let draftMsgNote = this.stringBundle.getString("draftMessageMsg");
 
     let buttons = [{
       label: this.stringBundle.getString("draftMessageButton"),
       accessKey: this.stringBundle.getString("draftMessageButtonKey"),
       popup: null,
       callback: function(aNotification, aButton) {
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -910,19 +910,17 @@ function loadStartFolder(initialUri)
 
             // Get the user pref to see if the login at startup is enabled for default account
             isLoginAtStartUpEnabled = defaultServer.loginAtStartUp;
 
             // Get Inbox only if login at startup is enabled.
             if (isLoginAtStartUpEnabled)
             {
                 //now find Inbox
-                var outNumFolders = new Object();
-                const kInboxFlag = Ci.nsMsgFolderFlags.Inbox;
-                var inboxFolder = rootMsgFolder.getFolderWithFlags(kInboxFlag);
+                var inboxFolder = rootMsgFolder.getFolderWithFlags(Ci.nsMsgFolderFlags.Inbox);
                 if (!inboxFolder) return;
 
                 startFolder = inboxFolder;
             }
         }
 
         // it is possible we were given an initial uri and we need to subscribe or try to add
         // the folder. i.e. the user just clicked on a news folder they aren't subscribed to from a browser
--- a/mail/base/content/msgViewNavigation.js
+++ b/mail/base/content/msgViewNavigation.js
@@ -38,20 +38,19 @@ function FindNextChildFolder(aParent, aA
     var subFolders = GetSubFoldersInFolderPaneOrder(aParent);
     var i = 0;
     var folder = null;
 
     // Skip folders until after the specified child
     while (folder != aAfter)
       folder = subFolders[i++];
 
-    const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-    let ignoreFlags = nsMsgFolderFlags.Trash | nsMsgFolderFlags.SentMail |
-                      nsMsgFolderFlags.Drafts | nsMsgFolderFlags.Queue |
-                      nsMsgFolderFlags.Templates | nsMsgFolderFlags.Junk;
+    let ignoreFlags = Ci.nsMsgFolderFlags.Trash | Ci.nsMsgFolderFlags.SentMail |
+                      Ci.nsMsgFolderFlags.Drafts | Ci.nsMsgFolderFlags.Queue |
+                      Ci.nsMsgFolderFlags.Templates | Ci.nsMsgFolderFlags.Junk;
     while (i < subFolders.length) {
       folder = subFolders[i++];
       // If there is unread mail in the trash, sent, drafts, unsent messages
       // templates or junk special folder,
       // we ignore it when doing cross folder "next" navigation.
       if (!folder.isSpecialFolder(ignoreFlags, true)) {
         if (folder.getNumUnread(false) > 0)
           return folder;
--- a/mail/base/content/phishingDetector.js
+++ b/mail/base/content/phishingDetector.js
@@ -55,19 +55,18 @@ var gPhishingDetector = {
       // we are opening an .eml file.
       var folder = aUrl.folder;
 
       // Ignore nntp and RSS messages.
       if (folder.server.type == 'nntp' || folder.server.type == 'rss')
         return;
 
       // Also ignore messages in Sent/Drafts/Templates/Outbox.
-      const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-      let outgoingFlags = nsMsgFolderFlags.SentMail | nsMsgFolderFlags.Drafts |
-                          nsMsgFolderFlags.Templates | nsMsgFolderFlags.Queue;
+      let outgoingFlags = Ci.nsMsgFolderFlags.SentMail | Ci.nsMsgFolderFlags.Drafts |
+                          Ci.nsMsgFolderFlags.Templates | Ci.nsMsgFolderFlags.Queue;
       if (folder.isSpecialFolder(outgoingFlags, true))
         return;
 
     } catch (ex) {
         if (ex.result != Cr.NS_ERROR_FAILURE)
           throw ex;
     }
 
--- a/mail/base/content/threadPane.js
+++ b/mail/base/content/threadPane.js
@@ -131,21 +131,20 @@ function HandleColumnClick(columnID)
   }
   else {
     MsgSortThreadPane(sortType);
   }
 }
 
 function ThreadPaneDoubleClick()
 {
-  const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-  if (IsSpecialFolderSelected(nsMsgFolderFlags.Drafts, true)) {
+  if (IsSpecialFolderSelected(Ci.nsMsgFolderFlags.Drafts, true)) {
     MsgComposeDraftMessage();
   }
-  else if(IsSpecialFolderSelected(nsMsgFolderFlags.Templates, true)) {
+  else if (IsSpecialFolderSelected(Ci.nsMsgFolderFlags.Templates, true)) {
     ComposeMessage(Ci.nsIMsgCompType.Template,
                    Ci.nsIMsgCompFormat.Default,
                    gFolderDisplay.displayedFolder,
                    gFolderDisplay.selectedMessageUris);
   }
   else {
     MsgOpenSelectedMessages();
   }
--- a/mail/components/activity/modules/moveCopy.jsm
+++ b/mail/components/activity/modules/moveCopy.jsm
@@ -2,17 +2,16 @@
 /* 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.EXPORTED_SYMBOLS = ["moveCopyModule"];
 
 var nsActEvent = Components.Constructor("@mozilla.org/activity-event;1",
                                           "nsIActivityEvent", "init");
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 const { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js", null);
 
 // This module provides a link between the move/copy code and the activity
 // manager.
@@ -179,17 +178,17 @@ var moveCopyModule =
       MailServices.accounts.FindServer(server.username, server.hostName, server.type);
     } catch (ex) { return; }
 
     let displayText;
     let statusText = server.prettyName;
 
     // Display a different message depending on whether we emptied the trash
     // or actually deleted a folder
-    if (aFolder.isSpecialFolder(nsMsgFolderFlags.Trash, false))
+    if (aFolder.isSpecialFolder(Ci.nsMsgFolderFlags.Trash, false))
       displayText = this.getString("emptiedTrash");
     else
       displayText = this.getString("deletedFolder").replace("#1", aFolder.prettyName);
 
     // create an activity event
     let event = new nsActEvent(displayText,
                                server,
                                statusText,
@@ -244,17 +243,17 @@ var moveCopyModule =
     this.log.info("in folderRenamed, aOrigFolder = " + aOrigFolder.prettyName +
                   ", aNewFolder = " + aNewFolder.prettyName);
 
     let displayText;
     let statusText = aNewFolder.server.prettyName;
 
     // Display a different message depending on whether we moved the folder
     // to the trash or actually renamed the folder.
-    if (aNewFolder.isSpecialFolder(nsMsgFolderFlags.Trash, true)) {
+    if (aNewFolder.isSpecialFolder(Ci.nsMsgFolderFlags.Trash, true)) {
       displayText = this.getString("movedFolderToTrash");
       displayText = displayText.replace("#1", aOrigFolder.prettyName);
     } else {
       displayText = this.getString("renamedFolder");
       displayText = displayText.replace("#1", aOrigFolder.prettyName);
       displayText = displayText.replace("#2", aNewFolder.prettyName);
     }
 
--- a/mail/test/mozmill/folder-pane/test-display-message-with-folder-modes.js
+++ b/mail/test/mozmill/folder-pane/test-display-message-with-folder-modes.js
@@ -80,20 +80,20 @@ function test_display_message_with_folde
 }
 
 /**
  * Test that displaying a message _does not_ cause a switch to the default
  * folder mode if the folder is present in the current folder mode.
  */
 function test_display_message_with_folder_present_in_current_folder_mode() {
   // Mark the folder as a favorite
-  folder.flags |= Ci.nsMsgFolderFlags.Favorite;
+  folder.setFlag(Ci.nsMsgFolderFlags.Favorite);
   // Also mark the dummy folder as a favorite, in preparation for
   // test_display_message_in_smart_folder_mode_works
-  dummyFolder.flags |= Ci.nsMsgFolderFlags.Favorite;
+  dummyFolder.setFlag(Ci.nsMsgFolderFlags.Favorite);
 
   // Make sure the folder doesn't appear in the favorite folder mode just
   // because it was selected last before switching
   be_in_folder(inboxFolder);
 
   // Switch to favorite folders. Check that the folder is now in the view, as is
   // the dummy folder
   mc.folderTreeView.mode = "favorite";
@@ -107,18 +107,18 @@ function test_display_message_with_folde
   // Try displaying a message
   display_message_in_folder_tab(msgHdr);
 
   assert_folder_mode("favorite");
   assert_folder_selected_and_displayed(folder);
   assert_selected_and_displayed(msgHdr);
 
   // Now unset the flags so that we don't affect later tests.
-  folder.flags &= ~Ci.nsMsgFolderFlags.Favorite;
-  dummyFolder.flags &= ~Ci.nsMsgFolderFlags.Favorite;
+  folder.clearFlag(Ci.nsMsgFolderFlags.Favorite);
+  dummyFolder.clearFlag(Ci.nsMsgFolderFlags.Favorite);
 }
 
 /**
  * Test that displaying a message in smart folders mode causes the parent in the
  * view to expand.
  */
 function test_display_message_in_smart_folder_mode_works() {
   // Clear the message selection, otherwise msgHdr will still be displayed and
--- a/mail/test/mozmill/folder-tree-modes/test-mode-switching.js
+++ b/mail/test/mozmill/folder-tree-modes/test-mode-switching.js
@@ -40,17 +40,17 @@ function setupModule(module) {
   // Create one folder with unread messages and one favorite folder.
   inboxFolder.createSubfolder("UnreadFolder", null);
   unreadFolder = inboxFolder.getChildNamed("UnreadFolder");
 
   inboxFolder.createSubfolder("FavoriteFolder", null);
   favoriteFolder = inboxFolder.getChildNamed("FavoriteFolder");
 
   make_new_sets_in_folder(unreadFolder, [{count: 1}]);
-  favoriteFolder.flags |= Ci.nsMsgFolderFlags.Favorite;
+  favoriteFolder.setFlag(Ci.nsMsgFolderFlags.Favorite);
 
   toggle_menu = mc.e("menu_compactFolderView");
   toggle_appmenu = mc.e("appmenu_compactFolderView");
 
   modeList_menu = mc.e("menu_FolderViewsPopup");
   modeList_appmenu = mc.e("appmenu_FolderViewsPopup");
 
   view_menu = mc.eid("menu_View");
--- a/mail/test/mozmill/folder-tree-modes/test-smart-folders.js
+++ b/mail/test/mozmill/folder-tree-modes/test-smart-folders.js
@@ -19,30 +19,28 @@ var rootFolder;
 var inboxSubfolder;
 var trashFolder;
 var trashSubfolder;
 
 var smartInboxFolder;
 
 var inboxSet;
 
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-
 function setupModule(module) {
   let fdh = collector.getModule("folder-display-helpers");
   fdh.installInto(module);
 
   rootFolder = inboxFolder.server.rootFolder;
 
   // Create a folder as a subfolder of the inbox
   inboxFolder.createSubfolder("SmartFoldersA", null);
   inboxSubfolder = inboxFolder.getChildNamed("SmartFoldersA");
 
   trashFolder = inboxFolder.server.rootFolder.getFolderWithFlags(
-    nsMsgFolderFlags.Trash);
+    Ci.nsMsgFolderFlags.Trash);
   trashFolder.createSubfolder("SmartFoldersB", null);
   trashSubfolder = trashFolder.getChildNamed("SmartFoldersB");
 
   // The message itself doesn't really matter, as long as there's at least one
   // in the folder.
   [inboxSet] = make_new_sets_in_folder(inboxFolder, [{count: 1}]);
   make_new_sets_in_folder(inboxSubfolder, [{count: 1}]);
 }
@@ -173,17 +171,17 @@ function test_folder_flag_changes() {
   rootFolder = inboxFolder.server.rootFolder;
   let archiveFolder = rootFolder.getChildNamed("Archives");
   assert_folder_and_children_in_scope(archiveFolder, archiveScope);
   archiveFolder = pop3Server.rootFolder.getChildNamed("Archives");
   assert_folder_and_children_in_scope(archiveFolder, archiveScope);
 
   // Remove the archive flag, and make sure the archive folder and
   // its children are no longer in the search scope.
-  archiveFolder.clearFlag(nsMsgFolderFlags.Archive);
+  archiveFolder.clearFlag(Ci.nsMsgFolderFlags.Archive);
 
   // Refresh the archive scope because clearing the flag should have
   // changed it.
   archiveScope = "|" + smartArchiveFolder.msgDatabase.dBFolderInfo
                  .getCharProperty("searchFolderUri") + "|";
 
   // figure out what we expect the archiveScope to now be.
   rootFolder = inboxFolder.server.rootFolder;
--- a/mail/test/mozmill/folder-tree-modes/test-unread-folders.js
+++ b/mail/test/mozmill/folder-tree-modes/test-unread-folders.js
@@ -16,30 +16,28 @@ var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers"];
 
 var rootFolder;
 var inboxSubfolder;
 var trashFolder;
 var trashSubfolder;
 var inboxSet;
 
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-
 function setupModule(module) {
   let fdh = collector.getModule("folder-display-helpers");
   fdh.installInto(module);
 
   rootFolder = inboxFolder.server.rootFolder;
 
   // Create a folder as a subfolder of the inbox
   inboxFolder.createSubfolder("UnreadFoldersA", null);
   inboxSubfolder = inboxFolder.getChildNamed("UnreadFoldersA");
 
   trashFolder = inboxFolder.server.rootFolder.getFolderWithFlags(
-    nsMsgFolderFlags.Trash);
+    Ci.nsMsgFolderFlags.Trash);
   trashFolder.createSubfolder("UnreadFoldersB", null);
   trashSubfolder = trashFolder.getChildNamed("UnreadFoldersB");
 
   // The message itself doesn't really matter, as long as there's at least one
   // in the folder.
   [ inboxSet ] = make_new_sets_in_folder(inboxFolder, [{count: 1}]);
   make_new_sets_in_folder(inboxSubfolder, [{count: 1}]);
 }
--- a/mailnews/base/content/folderProps.js
+++ b/mailnews/base/content/folderProps.js
@@ -99,17 +99,16 @@ function doEnabling()
   var nameTextbox = document.getElementById("name");
   document.documentElement.getButton("accept").disabled = !nameTextbox.value;
 }
 
 function folderPropsOKButton()
 {
   if (gMsgFolder)
   {
-    const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
     // set charset attributes
     var folderCharsetList = document.getElementById("folderCharsetList");
 
     // Log to the Error Console the charset value for the folder
     // if it is unknown to us. Value will be preserved by the menu-item.
     if (folderCharsetList.selectedIndex == -1)
     {
       Cu.reportError("Unknown folder encoding; folder=" +
@@ -117,24 +116,24 @@ function folderPropsOKButton()
     }
 
     gMsgFolder.charset = folderCharsetList.getAttribute("value");
     gMsgFolder.charsetOverride = document.getElementById("folderCharsetOverride")
                                          .checked;
 
     if(document.getElementById("offline.selectForOfflineFolder").checked ||
       document.getElementById("offline.selectForOfflineNewsgroup").checked)
-      gMsgFolder.setFlag(nsMsgFolderFlags.Offline);
+      gMsgFolder.setFlag(Ci.nsMsgFolderFlags.Offline);
     else
-      gMsgFolder.clearFlag(nsMsgFolderFlags.Offline);
+      gMsgFolder.clearFlag(Ci.nsMsgFolderFlags.Offline);
 
     if(document.getElementById("folderCheckForNewMessages").checked)
-      gMsgFolder.setFlag(nsMsgFolderFlags.CheckNew);
+      gMsgFolder.setFlag(Ci.nsMsgFolderFlags.CheckNew);
     else
-      gMsgFolder.clearFlag(nsMsgFolderFlags.CheckNew);
+      gMsgFolder.clearFlag(Ci.nsMsgFolderFlags.CheckNew);
 
     let glodaCheckbox = document.getElementById("folderIncludeInGlobalSearch");
     if (!glodaCheckbox.hidden) {
       if(glodaCheckbox.checked) {
         // We pass true here so that folders such as trash and junk can still
         // have a priority set.
         Gloda.resetFolderIndexingPriority(gMsgFolder, true);
       } else {
@@ -189,17 +188,16 @@ function folderPropsOnLoad()
     // when the dialog is accepted.
     var nameTextbox = document.getElementById("name");
     nameTextbox.value = window.arguments[0].name;
 
 //  name.setSelectionRange(0,-1);
 //  name.focusTextField();
   }
 
-  const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
   const serverType = window.arguments[0].serverType;
 
   // Do this first, because of gloda we may want to override some of the hidden
   // statuses.
   hideShowControls(serverType);
 
   if (gMsgFolder) {
     // We really need a functioning database, so we'll detect problems
@@ -216,17 +214,17 @@ function folderPropsOnLoad()
     // Decode the displayed mailbox:// URL as it's useful primarily for debugging,
     // whereas imap and news urls are sent around.
     locationTextbox.value = (serverType == "imap" || serverType == "nntp") ?
         gMsgFolder.folderURL : decodeURI(gMsgFolder.folderURL);
 
     if (gMsgFolder.canRename)
       document.getElementById("name").removeAttribute("readonly");
 
-    if (gMsgFolder.flags & nsMsgFolderFlags.Offline) {
+    if (gMsgFolder.getFlag(Ci.nsMsgFolderFlags.Offline)) {
 
       if(serverType == "imap" || serverType == "pop3")
         document.getElementById("offline.selectForOfflineFolder").checked = true;
 
       if(serverType == "nntp")
         document.getElementById("offline.selectForOfflineNewsgroup").checked = true;
     }
     else {
@@ -240,24 +238,25 @@ function folderPropsOnLoad()
     // select the menu item
     var folderCharsetList = document.getElementById("folderCharsetList");
     folderCharsetList.value = gMsgFolder.charset;
 
     // set override checkbox
     document.getElementById("folderCharsetOverride").checked = gMsgFolder.charsetOverride;
 
     // set check for new mail checkbox
-    document.getElementById("folderCheckForNewMessages").checked = gMsgFolder.flags & nsMsgFolderFlags.CheckNew;
+    document.getElementById("folderCheckForNewMessages").checked =
+      gMsgFolder.getFlag(Ci.nsMsgFolderFlags.CheckNew);
 
     // if gloda indexing is off, hide the related checkbox
     var glodaCheckbox = document.getElementById("folderIncludeInGlobalSearch");
     var glodaEnabled = Services.prefs
       .getBoolPref("mailnews.database.global.indexer.enabled");
-    if (!glodaEnabled || (gMsgFolder.flags & (nsMsgFolderFlags.Queue |
-                                              nsMsgFolderFlags.Newsgroup))) {
+    if (!glodaEnabled || (gMsgFolder.flags & (Ci.nsMsgFolderFlags.Queue |
+                                              Ci.nsMsgFolderFlags.Newsgroup))) {
       glodaCheckbox.hidden = true;
     } else {
       // otherwise, the user can choose whether this file gets indexed
       let glodaFolder = Gloda.getFolderForFolder(gMsgFolder);
       glodaCheckbox.checked =
         glodaFolder.indexingPriority != glodaFolder.kIndexingNeverPriority;
     }
   }
@@ -333,24 +332,23 @@ function hideShowControls(serverType)
           privilegesButton.setAttribute("hidden", "true");
       }
     }
   }
   catch (ex) {}
 
   if (gMsgFolder)
   {
-    const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
     // Hide "check for new mail" checkbox if this is an Inbox.
-    if (gMsgFolder.flags & nsMsgFolderFlags.Inbox)
+    if (gMsgFolder.getFlag(Ci.nsMsgFolderFlags.Inbox))
       document.getElementById("folderCheckForNewMessages").hidden = true;
     // Retention policy doesn't apply to Drafts/Templates/Outbox.
-    if (gMsgFolder.isSpecialFolder(nsMsgFolderFlags.Drafts |
-                                   nsMsgFolderFlags.Templates |
-                                   nsMsgFolderFlags.Queue, true))
+    if (gMsgFolder.isSpecialFolder(Ci.nsMsgFolderFlags.Drafts |
+                                   Ci.nsMsgFolderFlags.Templates |
+                                   Ci.nsMsgFolderFlags.Queue, true))
       document.getElementById("Retention").hidden = true;
   }
 }
 
 function onOfflineFolderDownload()
 {
   // we need to create a progress window and pass that in as the second parameter here.
   gMsgFolder.downloadAllForOffline(null, window.arguments[0].msgWindow);
--- a/mailnews/base/content/msgSelectOfflineFolders.js
+++ b/mailnews/base/content/msgSelectOfflineFolders.js
@@ -12,17 +12,17 @@ var gSelectOffline = {
       if (!aColumn || aColumn.id != "syncCol")
         return oldProps.call(this, aColumn);
 
       let properties = "syncCol";
 
       if (this._folder.isServer)
         return " isServer-true";
 
-      if (this._folder.getFlag(nsMsgFolderFlags.Offline))
+      if (this._folder.getFlag(Ci.nsMsgFolderFlags.Offline))
         properties += " synchronize-true";
 
       return properties;
     }
 
     let modeOffline = {
       __proto__: IFolderTreeMode,
 
@@ -82,26 +82,26 @@ var gSelectOffline = {
   _toggle: function(aRow) {
     let folder = gFolderTreeView._rowMap[aRow]._folder;
 
     if (folder.isServer)
       return;
 
     // Save our current state for rollback, if necessary.
     if (!this._rollbackMap.has(folder))
-      this._rollbackMap.set(folder, folder.getFlag(nsMsgFolderFlags.Offline));
+      this._rollbackMap.set(folder, folder.getFlag(Ci.nsMsgFolderFlags.Offline));
 
-    folder.toggleFlag(nsMsgFolderFlags.Offline);
+    folder.toggleFlag(Ci.nsMsgFolderFlags.Offline);
     gFolderTreeView._tree.invalidateRow(aRow);
   },
 
   onAccept: function() {
     gFolderTreeView.unload();
   },
 
   onCancel: function() {
     gFolderTreeView.unload();
     for (let [folder, value] of this._rollbackMap) {
-      if (value != folder.getFlag(nsMsgFolderFlags.Offline))
-        folder.toggleFlag(nsMsgFolderFlags.Offline);
+      if (value != folder.getFlag(Ci.nsMsgFolderFlags.Offline))
+        folder.toggleFlag(Ci.nsMsgFolderFlags.Offline);
     }
   }
 };
--- a/mailnews/base/util/folderUtils.jsm
+++ b/mailnews/base/util/folderUtils.jsm
@@ -13,35 +13,34 @@ ChromeUtils.import("resource:///modules/
 ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 
 /**
  * Returns a string representation of a folder's "special" type.
  *
  * @param aFolder  the nsIMsgFolder whose special type should be returned
  */
 function getSpecialFolderString(aFolder) {
-  const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
   let flags = aFolder.flags;
-  if (flags & nsMsgFolderFlags.Inbox)
+  if (flags & Ci.nsMsgFolderFlags.Inbox)
     return "Inbox";
-  if (flags & nsMsgFolderFlags.Trash)
+  if (flags & Ci.nsMsgFolderFlags.Trash)
     return "Trash";
-  if (flags & nsMsgFolderFlags.Queue)
+  if (flags & Ci.nsMsgFolderFlags.Queue)
     return "Outbox";
-  if (flags & nsMsgFolderFlags.SentMail)
+  if (flags & Ci.nsMsgFolderFlags.SentMail)
     return "Sent";
-  if (flags & nsMsgFolderFlags.Drafts)
+  if (flags & Ci.nsMsgFolderFlags.Drafts)
     return "Drafts";
-  if (flags & nsMsgFolderFlags.Templates)
+  if (flags & Ci.nsMsgFolderFlags.Templates)
     return "Templates";
-  if (flags & nsMsgFolderFlags.Junk)
+  if (flags & Ci.nsMsgFolderFlags.Junk)
     return "Junk";
-  if (flags & nsMsgFolderFlags.Archive)
+  if (flags & Ci.nsMsgFolderFlags.Archive)
     return "Archive";
-  if (flags & nsMsgFolderFlags.Virtual)
+  if (flags & Ci.nsMsgFolderFlags.Virtual)
     return "Virtual";
   return "none";
 }
 
 /**
  * This function is meant to be used with trees. It returns the property list
  * for all of the common properties that css styling is based off of.
  *
--- a/mailnews/db/gloda/modules/index_msg.js
+++ b/mailnews/db/gloda/modules/index_msg.js
@@ -65,33 +65,24 @@ var GLODA_BAD_MESSAGE_ID = 2;
  */
 var GLODA_OLD_BAD_MESSAGE_ID = 1;
 var GLODA_FIRST_VALID_MESSAGE_ID = 32;
 
 var JUNK_SCORE_PROPERTY = "junkscore";
 var JUNK_SPAM_SCORE_STR = Ci.nsIJunkMailPlugin.IS_SPAM_SCORE.toString();
 var JUNK_HAM_SCORE_STR = Ci.nsIJunkMailPlugin.IS_HAM_SCORE.toString();
 
-var nsIArray = Ci.nsIArray;
-var nsIMsgFolder = Ci.nsIMsgFolder;
-var nsIMsgLocalMailFolder = Ci.nsIMsgLocalMailFolder;
-var nsIMsgImapMailFolder = Ci.nsIMsgImapMailFolder;
-var nsIMsgDBHdr = Ci.nsIMsgDBHdr;
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-var nsMsgMessageFlags = Ci.nsMsgMessageFlags;
-var nsMsgProcessingFlags = Ci.nsMsgProcessingFlags;
-
 /**
  * The processing flags that tell us that a message header has not yet been
  *  reported to us via msgsClassified.  If it has one of these flags, it is
  *  still being processed.
  */
 var NOT_YET_REPORTED_PROCESSING_FLAGS =
-  nsMsgProcessingFlags.NotReportedClassified |
-  nsMsgProcessingFlags.ClassifyJunk;
+  Ci.nsMsgProcessingFlags.NotReportedClassified |
+  Ci.nsMsgProcessingFlags.ClassifyJunk;
 
 // for list comprehension fun
 function* range(begin, end) {
   for (let i = begin; i < end; ++i) {
     yield i;
   }
 }
 
@@ -598,17 +589,17 @@ var GlodaMsgIndexer = {
 
     if (this._indexingFolder)
       this._log.debug("Entering folder: " + this._indexingFolder.URI);
 
     try {
       // The msf may need to be created or otherwise updated for local folders.
       // This may require yielding until such time as the msf has been created.
       try {
-        if (this._indexingFolder instanceof nsIMsgLocalMailFolder) {
+        if (this._indexingFolder instanceof Ci.nsIMsgLocalMailFolder) {
           this._indexingDatabase =
             this._indexingFolder.getDatabaseWithReparse(null,
                                                         null);
         }
         // we need do nothing special for IMAP, news, or other
       }
       // getDatabaseWithReparse can return either NS_ERROR_NOT_INITIALIZED or
       //  NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE if the net result is that it
@@ -715,17 +706,17 @@ var GlodaMsgIndexer = {
       // If the folder !isLocal we add the terms:
       //  - if the folder is offline -- && (Status Is nsMsgMessageFlags.Offline)
       //  - && (Status Isnt nsMsgMessageFlags.Expunged)
 
       let searchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                             .createInstance(Ci.nsIMsgSearchSession);
       let searchTerms = Cc["@mozilla.org/array;1"]
                          .createInstance(Ci.nsIMutableArray);
-      let isLocal = this._indexingFolder instanceof nsIMsgLocalMailFolder;
+      let isLocal = this._indexingFolder instanceof Ci.nsIMsgLocalMailFolder;
 
       searchSession.addScopeTerm(Ci.nsMsgSearchScope.offlineMail,
                                  this._indexingFolder);
       let nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
       let nsMsgSearchOp = Ci.nsMsgSearchOp;
 
       // first term: (GLODA_MESSAGE_ID_PROPERTY Is 0
       let searchTerm = searchSession.createTerm();
@@ -777,37 +768,37 @@ var GlodaMsgIndexer = {
       value.str = JUNK_SPAM_SCORE_STR;
       searchTerm.value = value;
       searchTerm.hdrProperty = JUNK_SCORE_PROPERTY;
       searchTerms.appendElement(searchTerm);
 
       if (!isLocal)
       {
         // If the folder is offline, then the message should be too
-        if (this._indexingFolder.flags & Ci.nsMsgFolderFlags.Offline) {
+        if (this._indexingFolder.getFlag(Ci.nsMsgFolderFlags.Offline)) {
           // third term: && Status Is nsMsgMessageFlags.Offline
           searchTerm = searchSession.createTerm();
           searchTerm.booleanAnd = true;
           searchTerm.attrib = nsMsgSearchAttrib.MsgStatus;
           searchTerm.op = nsMsgSearchOp.Is;
           value = searchTerm.value;
           value.attrib = searchTerm.attrib;
-          value.status = nsMsgMessageFlags.Offline;
+          value.status = Ci.nsMsgMessageFlags.Offline;
           searchTerm.value = value;
           searchTerms.appendElement(searchTerm);
         }
 
         // fourth term: && Status Isnt nsMsgMessageFlags.Expunged
         searchTerm = searchSession.createTerm();
         searchTerm.booleanAnd = true;
         searchTerm.attrib = nsMsgSearchAttrib.MsgStatus;
         searchTerm.op = nsMsgSearchOp.Isnt;
         value = searchTerm.value;
         value.attrib = searchTerm.attrib;
-        value.status = nsMsgMessageFlags.Expunged;
+        value.status = Ci.nsMsgMessageFlags.Expunged;
         searchTerm.value = value;
         searchTerms.appendElement(searchTerm);
       }
 
       this._indexingEnumerator =
         this._indexingDatabase.getFilterEnumerator(searchTerms, true);
     }
     else if (aEnumKind == this.kEnumIndexedMsgs) {
@@ -1347,17 +1338,17 @@ var GlodaMsgIndexer = {
     //  everyone in one go in a filthy context because if we have to terminate
     //  indexing before we quit, we don't want to have to re-index messages next
     //  time.  (This could even lead to never completing indexing in a
     //  pathological situation.)
     let glodaFolder = GlodaDatastore._mapFolder(this._indexingFolder);
     if (glodaFolder.dirtyStatus == glodaFolder.kFolderFilthy) {
       this._indexerGetEnumerator(this.kEnumIndexedMsgs, true);
       let count = 0;
-      for (let msgHdr of fixIterator(this._indexingEnumerator, nsIMsgDBHdr)) {
+      for (let msgHdr of fixIterator(this._indexingEnumerator, Ci.nsIMsgDBHdr)) {
         // we still need to avoid locking up the UI, pause periodically...
         if (++count % HEADER_CHECK_SYNC_BLOCK_SIZE == 0)
           yield this.kWorkSync;
 
         if (count % HEADER_CHECK_GC_BLOCK_SIZE == 0)
           GlodaUtils.considerHeaderBasedGC(HEADER_CHECK_GC_BLOCK_SIZE);
 
         let glodaMessageId = msgHdr.getUint32Property(
@@ -1405,17 +1396,17 @@ var GlodaMsgIndexer = {
     aJob.goal = numMessagesToIndex;
 
     if (numMessagesToIndex > 0) {
       // We used up the iterator, get a new one.
       this._indexerGetEnumerator(enumeratorType);
 
       // Pass 2: index the messages.
       let count = 0;
-      for (let msgHdr of fixIterator(this._indexingEnumerator, nsIMsgDBHdr)) {
+      for (let msgHdr of fixIterator(this._indexingEnumerator, Ci.nsIMsgDBHdr)) {
         // per above, we want to periodically release control while doing all
         // this header traversal/investigation.
         if (++count % HEADER_CHECK_SYNC_BLOCK_SIZE == 0)
           yield this.kWorkSync;
 
         if (count % HEADER_CHECK_GC_BLOCK_SIZE == 0)
           GlodaUtils.considerHeaderBasedGC(HEADER_CHECK_GC_BLOCK_SIZE);
 
@@ -2038,17 +2029,17 @@ var GlodaMsgIndexer = {
    *     after the first notification, we would likely just mistakenly treat
    *     the msgsClassified notification as something dirtying, so it would
    *     still work out...)
    */
   _reindexChangedMessages: function gloda_indexer_reindexChangedMessage(
                                       aMsgHdrs, aDirtyingEvent) {
     let glodaIdsNeedingDeletion = null;
     let messageKeyChangedIds = null, messageKeyChangedNewKeys = null;
-    for (let msgHdr of fixIterator(aMsgHdrs, nsIMsgDBHdr)) {
+    for (let msgHdr of fixIterator(aMsgHdrs, Ci.nsIMsgDBHdr)) {
       // -- Index this folder?
       let msgFolder = msgHdr.folder;
       if (!this.shouldIndexFolder(msgFolder)) {
         continue;
       }
       // -- Ignore messages in filthy folders!
       // A filthy folder can only be processed by an indexing sweep, and at
       //  that point the message will get indexed.
@@ -2081,20 +2072,20 @@ var GlodaMsgIndexer = {
           if (!keyChangedInfo.isDirty)
             continue;
         }
       }
 
       // -- Index this message?
       // We index local messages, IMAP messages that are offline, and IMAP
       // messages that aren't offline but whose folders aren't offline either
-      let isFolderLocal = msgFolder instanceof nsIMsgLocalMailFolder;
+      let isFolderLocal = msgFolder instanceof Ci.nsIMsgLocalMailFolder;
       if (!isFolderLocal) {
-        if (!(msgHdr.flags & nsMsgMessageFlags.Offline) &&
-            (msgFolder.flags & nsMsgFolderFlags.Offline)) {
+        if (!(msgHdr.flags & Ci.nsMsgMessageFlags.Offline) &&
+            (msgFolder.getFlag(Ci.nsMsgFolderFlags.Offline))) {
           continue;
         }
       }
       // Ignore messages whose processing flags indicate it has not yet been
       //  classified.  In the IMAP case if the Offline flag is going to get set
       //  we are going to see it before the msgsClassified event so this is
       //  very important.
       if (msgFolder.getProcessingFlags(msgHdr.messageKey) &
@@ -2226,17 +2217,17 @@ var GlodaMsgIndexer = {
      *  back, the fact that deletion is thus deferred can be handy, as we can
      *  reuse the existing gloda message.
      */
     msgsDeleted: function gloda_indexer_msgsDeleted(aMsgHdrs) {
       this.indexer._log.debug("msgsDeleted notification");
       let glodaMessageIds = [];
 
       for (let iMsgHdr = 0; iMsgHdr < aMsgHdrs.length; iMsgHdr++) {
-        let msgHdr = aMsgHdrs.queryElementAt(iMsgHdr, nsIMsgDBHdr);
+        let msgHdr = aMsgHdrs.queryElementAt(iMsgHdr, Ci.nsIMsgDBHdr);
         let [glodaId, glodaDirty] = PendingCommitTracker.getGlodaState(msgHdr);
         if (glodaId >= GLODA_FIRST_VALID_MESSAGE_ID &&
             glodaDirty != GlodaMsgIndexer.kMessageFilthy)
           glodaMessageIds.push(glodaId);
       }
 
       if (glodaMessageIds.length) {
         GlodaMsgIndexer._datastore.markMessagesDeletedByIDs(glodaMessageIds);
@@ -2305,23 +2296,23 @@ var GlodaMsgIndexer = {
           }
 
           // -- Avoid propagation of filthy gloda-id's.
           // If the source folder is filthy or should not be indexed (and so
           //  any gloda-id's found in there are gibberish), our only job is to
           //  strip the gloda-id's off of all the destination headers because
           //  none of the gloda-id's are valid (and so we certainly don't want
           //  to try and use them as a basis for updating message keys.)
-          let srcMsgFolder = aSrcMsgHdrs.queryElementAt(0, nsIMsgDBHdr).folder;
+          let srcMsgFolder = aSrcMsgHdrs.queryElementAt(0, Ci.nsIMsgDBHdr).folder;
           if (!this.indexer.shouldIndexFolder(srcMsgFolder) ||
               (GlodaDatastore._mapFolder(srcMsgFolder).dirtyStatus ==
                  GlodaFolder.prototype.kFolderFilthy)) {
             // Local case, just modify the destination headers directly.
             if (aDestMsgHdrs) {
-              for (let destMsgHdr of fixIterator(aDestMsgHdrs, nsIMsgDBHdr)) {
+              for (let destMsgHdr of fixIterator(aDestMsgHdrs, Ci.nsIMsgDBHdr)) {
                 // zero it out if it exists
                 // (no need to deal with pending commit issues here; a filthy
                 //  folder by definition has nothing indexed in it.)
                 let glodaId = destMsgHdr.getUint32Property(
                                 GLODA_MESSAGE_ID_PROPERTY);
                 if (glodaId)
                   destMsgHdr.setUint32Property(GLODA_MESSAGE_ID_PROPERTY,
                                                0);
@@ -2343,17 +2334,17 @@ var GlodaMsgIndexer = {
                 destDb = aDestFolder.msgDatabase;
               } catch (ex) {
                 this.indexer._log.warn("Destination database for " +
                                        aDestFolder.prettyName +
                                        " not ready on IMAP move." +
                                        " Gloda corruption possible.");
                 return;
               }
-              for (let srcMsgHdr of fixIterator(aSrcMsgHdrs, nsIMsgDBHdr)) {
+              for (let srcMsgHdr of fixIterator(aSrcMsgHdrs, Ci.nsIMsgDBHdr)) {
                 // zero it out if it exists
                 // (no need to deal with pending commit issues here; a filthy
                 //  folder by definition has nothing indexed in it.)
                 let glodaId = srcMsgHdr.getUint32Property(
                                 GLODA_MESSAGE_ID_PROPERTY);
                 if (glodaId)
                   destDb.setUint32AttributeOnPendingHdr(
                     srcMsgHdr, GLODA_MESSAGE_ID_PROPERTY, 0);
@@ -2367,24 +2358,24 @@ var GlodaMsgIndexer = {
 
 
           // --- Have destination headers (local case):
           if (aDestMsgHdrs) {
             // -- Update message keys for valid gloda-id's.
             // (Which means ignore filthy gloda-id's.)
             let glodaIds = [];
             let newMessageKeys = [];
-            aSrcMsgHdrs.QueryInterface(nsIArray);
-            aDestMsgHdrs.QueryInterface(nsIArray);
+            aSrcMsgHdrs.QueryInterface(Ci.nsIArray);
+            aDestMsgHdrs.QueryInterface(Ci.nsIArray);
             // Track whether we see any messages that are not gloda indexed so
             //  we know if we have to mark the destination folder dirty.
             let sawNonGlodaMessage = false;
             for (let iMsg = 0; iMsg < aSrcMsgHdrs.length; iMsg++) {
-              let srcMsgHdr = aSrcMsgHdrs.queryElementAt(iMsg, nsIMsgDBHdr);
-              let destMsgHdr = aDestMsgHdrs.queryElementAt(iMsg, nsIMsgDBHdr);
+              let srcMsgHdr = aSrcMsgHdrs.queryElementAt(iMsg, Ci.nsIMsgDBHdr);
+              let destMsgHdr = aDestMsgHdrs.queryElementAt(iMsg, Ci.nsIMsgDBHdr);
 
               let [glodaId, dirtyStatus] =
                 PendingCommitTracker.getGlodaState(srcMsgHdr);
               if (glodaId >= GLODA_FIRST_VALID_MESSAGE_ID &&
                   dirtyStatus != GlodaMsgIndexer.kMessageFilthy) {
                 // we may need to update the pending commit map (it checks)
                 PendingCommitTracker.noteMove(srcMsgHdr, destMsgHdr);
                 // but we always need to update our database
@@ -2413,19 +2404,19 @@ var GlodaMsgIndexer = {
           // --- No dest headers (IMAP case):
           // Update any valid gloda indexed messages into their new folder to
           //  make the indexer's life easier when it sees the messages in their
           //  new folder.
           else {
             let glodaIds = [];
 
             let srcFolderIsLocal =
-              (srcMsgFolder instanceof nsIMsgLocalMailFolder);
+              (srcMsgFolder instanceof Ci.nsIMsgLocalMailFolder);
             for (let iMsgHdr = 0; iMsgHdr < aSrcMsgHdrs.length; iMsgHdr++) {
-              let msgHdr = aSrcMsgHdrs.queryElementAt(iMsgHdr, nsIMsgDBHdr);
+              let msgHdr = aSrcMsgHdrs.queryElementAt(iMsgHdr, Ci.nsIMsgDBHdr);
 
               let [glodaId, dirtyStatus] =
                 PendingCommitTracker.getGlodaState(msgHdr);
               if (glodaId >= GLODA_FIRST_VALID_MESSAGE_ID &&
                   dirtyStatus != GlodaMsgIndexer.kMessageFilthy) {
                 // we may need to update the pending commit map (it checks)
                 PendingCommitTracker.noteBlindMove(msgHdr);
                 // but we always need to update our database
@@ -2458,17 +2449,17 @@ var GlodaMsgIndexer = {
             //  message added events will cause that to happen.
           }
         }
         // ---- Copy case
         else {
           // -- Do not propagate gloda-id's for copies
           // (Only applies if we have the destination header, which means local)
           if (aDestMsgHdrs) {
-            for (let destMsgHdr of fixIterator(aDestMsgHdrs, nsIMsgDBHdr)) {
+            for (let destMsgHdr of fixIterator(aDestMsgHdrs, Ci.nsIMsgDBHdr)) {
               let glodaId = destMsgHdr.getUint32Property(
                 GLODA_MESSAGE_ID_PROPERTY);
               if (glodaId)
                 destMsgHdr.setUint32Property(GLODA_MESSAGE_ID_PROPERTY, 0);
             }
           }
 
           // mark the folder as dirty; we'll get to it later.
@@ -2678,17 +2669,17 @@ var GlodaMsgIndexer = {
      * - JunkStatusChanged: We mark the messages that have had their junk
      *    state change to be reindexed.
      */
     itemEvent: function gloda_indexer_itemEvent(aItem, aEvent, aData, aString) {
       // Compact and Reindex are close enough that we can reuse the same code
       //  with one minor difference.
       if (aEvent == "FolderCompactStart" ||
           aEvent == "FolderReindexTriggered") {
-        let aMsgFolder = aItem.QueryInterface(nsIMsgFolder);
+        let aMsgFolder = aItem.QueryInterface(Ci.nsIMsgFolder);
         // ignore folders we ignore...
         if (!GlodaMsgIndexer.shouldIndexFolder(aMsgFolder))
           return;
 
         let glodaFolder = GlodaDatastore._mapFolder(aMsgFolder);
         if (aEvent == "FolderCompactStart")
           glodaFolder.compacting = true;
 
@@ -2708,17 +2699,17 @@ var GlodaMsgIndexer = {
         //  about the folder.  We will pick up the pieces in the compaction
         //  pass.
         PendingCommitTracker.noteFolderDatabaseGettingBlownAway(aMsgFolder);
 
         // (We do not need to mark the folder dirty because if we were indexing
         //  it, it already must have been marked dirty.)
       }
       else if (aEvent == "FolderCompactFinish") {
-        let aMsgFolder = aItem.QueryInterface(nsIMsgFolder);
+        let aMsgFolder = aItem.QueryInterface(Ci.nsIMsgFolder);
         // ignore folders we ignore...
         if (!GlodaMsgIndexer.shouldIndexFolder(aMsgFolder))
           return;
 
         let glodaFolder = GlodaDatastore._mapFolder(aMsgFolder);
         glodaFolder.compacting = false;
         glodaFolder._setCompactedState(true);
 
@@ -2795,20 +2786,20 @@ var GlodaMsgIndexer = {
      * Notice when user activity adds/removes tags or changes a message's
      *  status.
      */
     OnItemPropertyFlagChanged: function gloda_indexer_OnItemPropertyFlagChanged(
                                 aMsgHdr, aProperty, aOldValue, aNewValue) {
       if (aProperty == "Keywords" ||
           // We could care less about the new flag changing.
           (aProperty == "Status" &&
-           (aOldValue ^ aNewValue) != nsMsgMessageFlags.New &&
+           (aOldValue ^ aNewValue) != Ci.nsMsgMessageFlags.New &&
            // We do care about IMAP deletion, but msgsDeleted tells us that, so
            //  ignore IMAPDeleted too...
-           (aOldValue ^ aNewValue) != nsMsgMessageFlags.IMAPDeleted) ||
+           (aOldValue ^ aNewValue) != Ci.nsMsgMessageFlags.IMAPDeleted) ||
           aProperty == "Flagged") {
         GlodaMsgIndexer._reindexChangedMessages([aMsgHdr], true);
       }
     },
 
     /**
      * Get folder loaded notifications for folders that had to do some
      *  (asynchronous) processing before they could be opened.
@@ -2946,18 +2937,18 @@ var GlodaMsgIndexer = {
     let logDebug = this._log.level <= Log4Moz.Level.Debug;
     if (logDebug)
       this._log.debug("*** Indexing message: " + aMsgHdr.messageKey + " : " +
                       aMsgHdr.subject);
 
     // If the message is offline, then get the message body as well
     let isMsgOffline = false;
     let aMimeMsg;
-    if ((aMsgHdr.flags & nsMsgMessageFlags.Offline) ||
-        (aMsgHdr.folder instanceof nsIMsgLocalMailFolder)) {
+    if ((aMsgHdr.flags & Ci.nsMsgMessageFlags.Offline) ||
+        (aMsgHdr.folder instanceof Ci.nsIMsgLocalMailFolder)) {
       isMsgOffline = true;
       this._MsgHdrToMimeMessageFunc(aMsgHdr, aCallbackHandle.callbackThis,
           aCallbackHandle.callback, false, {saneBodySize: true});
       aMimeMsg = (yield this.kWorkAsync)[1];
     }
     else {
       if (logDebug)
         this._log.debug("  * Message is not offline -- only headers indexed");
--- a/mailnews/db/msgdb/test/unit/test_filter_enumerator.js
+++ b/mailnews/db/msgdb/test/unit/test_filter_enumerator.js
@@ -1,19 +1,14 @@
 load("../../../../resources/messageGenerator.js");
 
 var gMessages = [];
-var nsMsgSearchScope  = Ci.nsMsgSearchScope;
-var nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;
-var nsMsgSearchOp     = Ci.nsMsgSearchOp;
-var nsMsgMessageFlags = Ci.nsMsgMessageFlags;
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
 
-var kSetCount = 13;
-var kNumExpectedMatches = 10;
+const kSetCount = 13;
+const kNumExpectedMatches = 10;
 
 function setupGlobals()
 {
   localAccountUtils.loadLocalMailAccount();
   // Create a message generator
   let messageGenerator = new MessageGenerator();
   let localInbox = localAccountUtils.inboxFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
 
@@ -47,43 +42,43 @@ function run_test() {
   let searchTerm = searchSession.createTerm();
 
   // Create the following search term:
   // (folderFlag & Mail && folderFlag != ImapBox) &&
   //    msg property.gloda-id isEmpty
 
   searchTerm.beginsGrouping = true;
   searchTerm.booleanAnd = true;
-  searchTerm.attrib = nsMsgSearchAttrib.FolderFlag;
-  searchTerm.op = nsMsgSearchOp.Is;
+  searchTerm.attrib = Ci.nsMsgSearchAttrib.FolderFlag;
+  searchTerm.op = Ci.nsMsgSearchOp.Is;
   let value = searchTerm.value;
-  value.status = nsMsgFolderFlags.Mail;
-  value.attrib = nsMsgSearchAttrib.FolderFlag;
+  value.status = Ci.nsMsgFolderFlags.Mail;
+  value.attrib = Ci.nsMsgSearchAttrib.FolderFlag;
   searchTerm.value = value;
   searchTerms.appendElement(searchTerm);
 
   searchTerm = searchSession.createTerm();
   searchTerm.booleanAnd = true;
-  searchTerm.attrib = nsMsgSearchAttrib.FolderFlag;
-  searchTerm.op = nsMsgSearchOp.Isnt;
+  searchTerm.attrib = Ci.nsMsgSearchAttrib.FolderFlag;
+  searchTerm.op = Ci.nsMsgSearchOp.Isnt;
   value = searchTerm.value;
-  value.status = nsMsgFolderFlags.ImapBox;
-  value.attrib = nsMsgSearchAttrib.FolderFlag;
+  value.status = Ci.nsMsgFolderFlags.ImapBox;
+  value.attrib = Ci.nsMsgSearchAttrib.FolderFlag;
   searchTerm.value = value;
   searchTerm.endsGrouping = true;
   searchTerms.appendElement(searchTerm);
 
   searchTerm = searchSession.createTerm();
   searchTerm.booleanAnd = true;
-  searchTerm.attrib = nsMsgSearchAttrib.HdrProperty;
+  searchTerm.attrib = Ci.nsMsgSearchAttrib.HdrProperty;
   searchTerm.hdrProperty = "gloda-id";
-  searchTerm.op = nsMsgSearchOp.IsEmpty;
+  searchTerm.op = Ci.nsMsgSearchOp.IsEmpty;
   value = searchTerm.value;
   value.str = "gloda-id";
-  value.attrib = nsMsgSearchAttrib.HdrProperty;
+  value.attrib = Ci.nsMsgSearchAttrib.HdrProperty;
   searchTerm.value = value;
   searchTerms.appendElement(searchTerm);
 
   let filterEnumerator = inboxDB.getFilterEnumerator(searchTerms);
   let numMatches = {};
   let keepGoing = inboxDB.nextMatchingHdrs(filterEnumerator, 100, 100, null, numMatches);
   Assert.equal(kNumExpectedMatches, numMatches.value);
   Assert.ok(!keepGoing);
--- a/mailnews/imap/test/unit/test_imapContentLength.js
+++ b/mailnews/imap/test/unit/test_imapContentLength.js
@@ -45,17 +45,17 @@ var msgFolderListener = {
 };
 
 function setup() {
   setupIMAPPump();
 
   // Set up nsIMsgFolderListener to get the header when it's received
   MailServices.mfn.addListener(msgFolderListener, MailServices.mfn.msgAdded);
 
-  IMAPPump.inbox.flags &= ~Ci.nsMsgFolderFlags.Offline;
+  IMAPPump.inbox.clearFlag(Ci.nsMsgFolderFlags.Offline);
 }
 
 function verifyContentLength() {
   let messageUri = IMAPPump.inbox.getUriForMsg(gMsgHdr);
   // Convert this to a URI that necko can run
   let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
   let neckoURL = {};
   let messageService = messenger.messageServiceFromURI(messageUri);
--- a/mailnews/imap/test/unit/test_listSubscribed.js
+++ b/mailnews/imap/test/unit/test_listSubscribed.js
@@ -17,17 +17,16 @@ load("../../../resources/logHelper.js");
 load("../../../resources/asyncTestUtils.js");
 load("../../../resources/alertTestUtils.js");
 
 // IMAP pump
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 // Globals
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
 
 // Zimbra is one of the servers that supports LIST-EXTENDED
 // it also has a bug that causes a server crash in certain setups
 setupIMAPPump("Zimbra");
 
 // Definition of tests
 var tests = [
   setupMailboxes,
@@ -52,34 +51,34 @@ function* setupMailboxes()
 
 // tests that LIST (SUBSCRIBED) returns the proper response
 function* testListSubscribed()
 {
   // check that we have \Noselect and \Noinferiors flags - these would not have
   // been returned if we had used LSUB instead of LIST(SUBSCRIBED)
   let rootFolder = IMAPPump.incomingServer.rootFolder;
   let folder1 = rootFolder.getChildNamed("folder1");
-  Assert.ok(folder1.getFlag(nsMsgFolderFlags.ImapNoselect));
-  Assert.ok(!folder1.getFlag(nsMsgFolderFlags.ImapNoinferiors));
+  Assert.ok(folder1.getFlag(Ci.nsMsgFolderFlags.ImapNoselect));
+  Assert.ok(!folder1.getFlag(Ci.nsMsgFolderFlags.ImapNoinferiors));
 
   // make sure the above test was not a fluke
   let folder11 = folder1.getChildNamed("folder11");
-  Assert.ok(!folder11.getFlag(nsMsgFolderFlags.ImapNoselect));
-  Assert.ok(folder11.getFlag(nsMsgFolderFlags.ImapNoinferiors));
+  Assert.ok(!folder11.getFlag(Ci.nsMsgFolderFlags.ImapNoselect));
+  Assert.ok(folder11.getFlag(Ci.nsMsgFolderFlags.ImapNoinferiors));
 
   // test that \NonExistent implies \Noselect
   let folder2 = rootFolder.getChildNamed("folder2");
-  Assert.ok(folder1.getFlag(nsMsgFolderFlags.ImapNoselect));
+  Assert.ok(folder1.getFlag(Ci.nsMsgFolderFlags.ImapNoselect));
 
   // should not get a folder3 since it is not subscribed
   let folder3;
   try {
     folder3 = rootFolder.getChildNamed("folder3");
   } catch (ex) {}
-  //do_check_false(folder1.getFlag(nsMsgFolderFlags.Subscribed));
+  //do_check_false(folder1.getFlag(Ci.nsMsgFolderFlags.Subscribed));
   Assert.equal(null, folder3);
 
   yield true;
 }
 
 function* testZimbraServerVersions() {
   // older versions of Zimbra can crash if we send LIST (SUBSCRIBED) so we want
   // to make sure that we are checking for versions
@@ -100,17 +99,18 @@ function* testZimbraServerVersions() {
     IMAPPump.incomingServer.closeCachedConnections();
     IMAPPump.incomingServer.performExpand(null);
     // select inbox is just to wait on performExpand since performExpand does not have listener
     IMAPPump.inbox.updateFolderWithListener(null, asyncUrlListener);
     yield false;
     // if we send LSUB instead of LIST(SUBSCRIBED), then we should not have \NoSelect flag
     let rootFolder = IMAPPump.incomingServer.rootFolder;
     let folder1 = rootFolder.getChildNamed("folder1");
-    Assert.equal(folder1.getFlag(nsMsgFolderFlags.ImapNoselect), testValues[i].expectedResult);
+    Assert.equal(folder1.getFlag(Ci.nsMsgFolderFlags.ImapNoselect),
+                 testValues[i].expectedResult);
   }
 }
 
 // Cleanup at end
 function endTest()
 {
   teardownIMAPPump();
 }
--- a/mailnews/imap/test/unit/test_lsub.js
+++ b/mailnews/imap/test/unit/test_lsub.js
@@ -40,40 +40,38 @@ function* setupMailboxes()
   // select the inbox to force folder discovery, etc.
   IMAPPump.inbox.updateFolderWithListener(null, asyncUrlListener);
   yield false;
 }
 
 // tests that LSUB returns the proper response
 function* testLsub()
 {
-  let nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-
   // check that we have \Noselect and \Noinferiors flags - these would not have
   // been returned if we had used LSUB instead of LIST(SUBSCRIBED)
   let rootFolder = IMAPPump.incomingServer.rootFolder;
   let folder1 = rootFolder.getChildNamed("folder1");
-  Assert.ok(folder1.getFlag(nsMsgFolderFlags.ImapNoselect));
-  Assert.ok(!folder1.getFlag(nsMsgFolderFlags.ImapNoinferiors));
+  Assert.ok(folder1.getFlag(Ci.nsMsgFolderFlags.ImapNoselect));
+  Assert.ok(!folder1.getFlag(Ci.nsMsgFolderFlags.ImapNoinferiors));
 
   // make sure the above test was not a fluke
   let folder11 = folder1.getChildNamed("folder11");
-  Assert.ok(!folder11.getFlag(nsMsgFolderFlags.ImapNoselect));
-  Assert.ok(folder11.getFlag(nsMsgFolderFlags.ImapNoinferiors));
+  Assert.ok(!folder11.getFlag(Ci.nsMsgFolderFlags.ImapNoselect));
+  Assert.ok(folder11.getFlag(Ci.nsMsgFolderFlags.ImapNoinferiors));
 
   // test that \NonExistent implies \Noselect
   let folder2 = rootFolder.getChildNamed("folder2");
-  Assert.ok(folder1.getFlag(nsMsgFolderFlags.ImapNoselect));
+  Assert.ok(folder1.getFlag(Ci.nsMsgFolderFlags.ImapNoselect));
 
   // should not get a folder3 since it is not subscribed
   let folder3;
   try {
     folder3 = rootFolder.getChildNamed("folder3");
   } catch (ex) {}
-  //do_check_false(folder1.getFlag(nsMsgFolderFlags.Subscribed));
+  //do_check_false(folder1.getFlag(Ci.nsMsgFolderFlags.Subscribed));
   Assert.equal(null, folder3);
 
   yield true;
 }
 
 // Cleanup at end
 function endTest()
 {
--- a/mailnews/imap/test/unit/test_nsIMsgFolderListenerIMAP.js
+++ b/mailnews/imap/test/unit/test_nsIMsgFolderListenerIMAP.js
@@ -157,17 +157,17 @@ var gTestArray =
   function testAddFolder2() { addFolder(gRootFolder, "folder3", "gIMAPFolder3") },
 
   // Adding messages to folders
   function testCopyFileMessage1()
   {
     // Make sure the offline flag is not set for any of the folders
     [gIMAPInbox, gIMAPFolder2, gIMAPFolder3].forEach(function (folder)
     {
-      folder.flags &= ~Ci.nsMsgFolderFlags.Offline;
+      folder.clearFlag(Ci.nsMsgFolderFlags.Offline);
     });
     copyFileMessage(gMsgFile1, gMsgId1, gIMAPInbox)
   },
   function testCopyFileMessage2() { copyFileMessage(gMsgFile2, gMsgId2, gIMAPInbox) },
 
   // Add message straight to the server, so that we get a message added
   // notification on the next folder update
   function testNewMessageArrival1() {
--- a/mailnews/local/test/unit/test_nsIMsgLocalMailFolder.js
+++ b/mailnews/local/test/unit/test_nsIMsgLocalMailFolder.js
@@ -126,40 +126,38 @@ function subtest_folder_operations(root)
   // Test - isAncestorOf
 
   Assert.ok(folder.isAncestorOf(folder2));
   Assert.ok(root.isAncestorOf(folder2));
   Assert.ok(!folder.isAncestorOf(root));
 
   // Test - FoldersWithFlag
 
-  const nsMsgFolderFlags = Ci.nsMsgFolderFlags;
+  folder.setFlag(Ci.nsMsgFolderFlags.CheckNew);
+  Assert.ok(folder.getFlag(Ci.nsMsgFolderFlags.CheckNew));
+  Assert.ok(!folder.getFlag(Ci.nsMsgFolderFlags.Offline));
 
-  folder.setFlag(nsMsgFolderFlags.CheckNew);
-  Assert.ok(folder.getFlag(nsMsgFolderFlags.CheckNew));
-  Assert.ok(!folder.getFlag(nsMsgFolderFlags.Offline));
-
-  folder.setFlag(nsMsgFolderFlags.Offline);
-  Assert.ok(folder.getFlag(nsMsgFolderFlags.CheckNew));
-  Assert.ok(folder.getFlag(nsMsgFolderFlags.Offline));
+  folder.setFlag(Ci.nsMsgFolderFlags.Offline);
+  Assert.ok(folder.getFlag(Ci.nsMsgFolderFlags.CheckNew));
+  Assert.ok(folder.getFlag(Ci.nsMsgFolderFlags.Offline));
 
-  folder.toggleFlag(nsMsgFolderFlags.CheckNew);
-  Assert.ok(!folder.getFlag(nsMsgFolderFlags.CheckNew));
-  Assert.ok(folder.getFlag(nsMsgFolderFlags.Offline));
+  folder.toggleFlag(Ci.nsMsgFolderFlags.CheckNew);
+  Assert.ok(!folder.getFlag(Ci.nsMsgFolderFlags.CheckNew));
+  Assert.ok(folder.getFlag(Ci.nsMsgFolderFlags.Offline));
 
-  folder.clearFlag(nsMsgFolderFlags.Offline);
-  Assert.ok(!folder.getFlag(nsMsgFolderFlags.CheckNew));
-  Assert.ok(!folder.getFlag(nsMsgFolderFlags.Offline));
+  folder.clearFlag(Ci.nsMsgFolderFlags.Offline);
+  Assert.ok(!folder.getFlag(Ci.nsMsgFolderFlags.CheckNew));
+  Assert.ok(!folder.getFlag(Ci.nsMsgFolderFlags.Offline));
 
-  folder.setFlag(nsMsgFolderFlags.Favorite);
-  folder2.setFlag(nsMsgFolderFlags.Favorite);
-  folder.setFlag(nsMsgFolderFlags.CheckNew);
-  folder2.setFlag(nsMsgFolderFlags.Offline);
+  folder.setFlag(Ci.nsMsgFolderFlags.Favorite);
+  folder2.setFlag(Ci.nsMsgFolderFlags.Favorite);
+  folder.setFlag(Ci.nsMsgFolderFlags.CheckNew);
+  folder2.setFlag(Ci.nsMsgFolderFlags.Offline);
 
-  Assert.equal(root.getFolderWithFlags(nsMsgFolderFlags.CheckNew),
+  Assert.equal(root.getFolderWithFlags(Ci.nsMsgFolderFlags.CheckNew),
                folder);
 
   // Test - Move folders around
 
   var folder3 = root.createLocalSubfolder("folder3");
   var folder3Local = folder3.QueryInterface(Ci.nsIMsgLocalMailFolder);
   var folder1Local = folder.QueryInterface(Ci.nsIMsgLocalMailFolder);