Bug 1498041 - Turn on ESLint in mail/base/content: enable no-undef rule; r=aceman
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 23 Nov 2018 10:55:17 +1300
changeset 33765 202a0c6da02dfed38143bbe9488ccc01faae6b92
parent 33764 854e46a4c5f226a20fb42f14a2c50af188038289
child 33766 9ec06d5d2638767467fec74475ac1ab0f7abda43
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersaceman
bugs1498041
Bug 1498041 - Turn on ESLint in mail/base/content: enable no-undef rule; r=aceman
mail/base/content/.eslintrc.js
mail/base/content/ABSearchDialog.js
mail/base/content/FilterListDialog.js
mail/base/content/SearchDialog.js
mail/base/content/aboutAddonsExtra.js
mail/base/content/aboutDialog-appUpdater.js
mail/base/content/aboutDialog.js
mail/base/content/commandglue.js
mail/base/content/contentAreaClick.js
mail/base/content/editContactPanel.js
mail/base/content/extensions.xml
mail/base/content/folderDisplay.js
mail/base/content/folderPane.js
mail/base/content/foldersummary.js
mail/base/content/glodaFacetBindings.xml
mail/base/content/glodaFacetTab.js
mail/base/content/glodaFacetView.js
mail/base/content/glodaFacetVis.js
mail/base/content/macMessengerMenu.js
mail/base/content/mail-compacttheme.js
mail/base/content/mail-offline.js
mail/base/content/mail3PaneWindowCommands.js
mail/base/content/mailCommands.js
mail/base/content/mailContextMenus.js
mail/base/content/mailCore.js
mail/base/content/mailTabs.js
mail/base/content/mailWidgets.xml
mail/base/content/mailWindow.js
mail/base/content/mailWindowOverlay.js
mail/base/content/messageDisplay.js
mail/base/content/messageWindow.js
mail/base/content/msgHdrView.js
mail/base/content/msgMail3PaneWindow.js
mail/base/content/msgViewNavigation.js
mail/base/content/multimessageview.js
mail/base/content/nsContextMenu.js
mail/base/content/nsDragAndDrop.js
mail/base/content/phishingDetector.js
mail/base/content/plugins.js
mail/base/content/quickFilterBar.js
mail/base/content/sanitizeDialog.js
mail/base/content/search.xml
mail/base/content/selectionsummaries.js
mail/base/content/specialTabs.js
mail/base/content/tabmail.xml
mail/base/content/threadPane.js
mail/base/content/threadPaneColumnPicker.xml
mail/base/content/toolbarIconColor.js
mail/base/content/utilityOverlay.js
deleted file mode 100644
--- a/mail/base/content/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-module.exports = {
-  "rules": {
-    "no-undef": "off",
-  },
-};
--- a/mail/base/content/ABSearchDialog.js
+++ b/mail/base/content/ABSearchDialog.js
@@ -1,13 +1,23 @@
 /* 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/. */
 
-ChromeUtils.import("resource:///modules/ABQueryUtils.jsm");
+/* import-globals-from ../../../../toolkit/content/globalOverlay.js */
+/* import-globals-from ../../../mailnews/addrbook/content/abResultsPane.js */
+/* import-globals-from ../../../mailnews/base/content/dateFormat.js */
+/* import-globals-from ../../../mailnews/base/search/content/searchTermOverlay.js */
+/* import-globals-from ../../components/addrbook/content/abCommon.js */
+/* import-globals-from commandglue.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from msgMail3PaneWindow.js */
+/* import-globals-from nsDragAndDrop.js */
+
+var { encodeABTermValue } = ChromeUtils.import("resource:///modules/ABQueryUtils.jsm", null);
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var searchSessionContractID = "@mozilla.org/messenger/searchSession;1";
 var gSearchSession;
 
 var nsMsgSearchScope = Ci.nsMsgSearchScope;
--- a/mail/base/content/FilterListDialog.js
+++ b/mail/base/content/FilterListDialog.js
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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/. */
 
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
+var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gFilterListMsgWindow = null;
 var gCurrentFilterList;
 var gServerMenu = null;
 var gFilterListbox = null;
 var gEditButton = null;
--- a/mail/base/content/SearchDialog.js
+++ b/mail/base/content/SearchDialog.js
@@ -1,25 +1,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from ../../../../toolkit/content/globalOverlay.js */
+/* import-globals-from ../../../mailnews/base/search/content/searchTermOverlay.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from mailWindowOverlay.js */
+/* import-globals-from messageDisplay.js */
+/* import-globals-from threadPane.js */
+
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gCurrentFolder;
 
 var gFolderDisplay;
 // Although we don't display messages, we have a message display object to
 //  simplify our code.  It's just always disabled.
 var gMessageDisplay;
 
-var nsIMsgWindow = Ci.nsIMsgWindow;
-
 var gFolderPicker;
 var gStatusFeedback;
 var gTimelineEnabled = false;
 var RDF;
 var gSearchBundle;
 
 // Datasource search listener -- made global as it has to be registered
 // and unregistered in different functions.
@@ -84,34 +90,34 @@ var nsSearchResultsController = {
     doCommand(command) {
         switch (command) {
         case "cmd_open":
             MsgOpenSelectedMessages();
             return true;
 
         case "cmd_delete":
         case "button_delete":
-            MsgDeleteSelectedMessages(nsMsgViewCommandType.deleteMsg);
+            MsgDeleteSelectedMessages(Ci.nsMsgViewCommandType.deleteMsg);
             return true;
         case "cmd_shiftDelete":
-            MsgDeleteSelectedMessages(nsMsgViewCommandType.deleteNoTrash);
+            MsgDeleteSelectedMessages(Ci.nsMsgViewCommandType.deleteNoTrash);
             return true;
 
         case "open_in_folder_button":
             OpenInFolder();
             return true;
 
         case "saveas_vf_button":
             saveAsVirtualFolder();
             return true;
 
         case "cmd_selectAll":
             // move the focus to the search results pane
             GetThreadTree().focus();
-            gFolderDisplay.doCommand(nsMsgViewCommandType.selectAll);
+            gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.selectAll);
             return true;
 
         default:
             return false;
         }
 
     },
 
@@ -256,17 +262,17 @@ function searchOnUnload() {
 }
 
 function initializeSearchWindowWidgets() {
     gFolderPicker = document.getElementById("searchableFolders");
     gSearchStopButton = document.getElementById("search-button");
     hideMatchAllItem();
 
     msgWindow = Cc["@mozilla.org/messenger/msgwindow;1"]
-                  .createInstance(nsIMsgWindow);
+                  .createInstance(Ci.nsIMsgWindow);
     msgWindow.domWindow = window;
     msgWindow.rootDocShell.appType = Ci.nsIDocShell.APP_TYPE_MAIL;
 
     gStatusFeedback = new nsMsgStatusFeedback();
     msgWindow.statusFeedback = gStatusFeedback;
 
     // functionality to enable/disable buttons using nsSearchResultsController
     // depending of whether items are selected in the search results thread pane.
@@ -485,21 +491,16 @@ function GetScopeForFolder(folder) {
         return nsMsgSearchScope.onlineManual;
         // fall through to default
     default:
       return nsMsgSearchScope.offlineMail;
   }
 
 }
 
-var nsMsgViewSortType = Ci.nsMsgViewSortType;
-var nsMsgViewSortOrder = Ci.nsMsgViewSortOrder;
-var nsMsgViewFlagsType = Ci.nsMsgViewFlagsType;
-var nsMsgViewCommandType = Ci.nsMsgViewCommandType;
-
 function goUpdateSearchItems(commandset) {
   for (var i = 0; i < commandset.childNodes.length; i++) {
     var commandID = commandset.childNodes[i].getAttribute("id");
     if (commandID) {
       goUpdateCommand(commandID);
     }
   }
 }
@@ -523,17 +524,17 @@ function MoveMessageInSearch(destFolder)
   // "File Here".
   let destUri = destFolder.getAttribute("id");
   if (destUri.length == 0)
     destUri = destFolder.getAttribute("file-uri");
 
   let destMsgFolder = MailUtils.getOrCreateFolder(destUri);
 
   gFolderDisplay.hintAboutToDeleteMessages();
-  gFolderDisplay.doCommandWithFolder(nsMsgViewCommandType.moveMessages,
+  gFolderDisplay.doCommandWithFolder(Ci.nsMsgViewCommandType.moveMessages,
                                      destMsgFolder);
 }
 
 function OpenInFolder() {
   MailUtils.displayMessageInFolderTab(gFolderDisplay.selectedMessage);
 }
 
 function saveAsVirtualFolder() {
--- a/mail/base/content/aboutAddonsExtra.js
+++ b/mail/base/content/aboutAddonsExtra.js
@@ -1,13 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* globals AddonManager, Services, gDetailView, gListView, gStrings */
+/* import-globals-from ../../../../toolkit/mozapps/extensions/content/extensions.js */
 
 const { ExtensionSupport } = ChromeUtils.import("resource:///modules/extensionSupport.jsm", null);
 
 gStrings.mailExt =
   Services.strings.createBundle("chrome://messenger/locale/extensionsOverlay.properties");
 
 (function() {
   window.isCorrectlySigned = function() { return true; };
--- a/mail/base/content/aboutDialog-appUpdater.js
+++ b/mail/base/content/aboutDialog-appUpdater.js
@@ -1,15 +1,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/. */
 
 // Note: this file is included in aboutDialog.xul and preferences/advanced.xul
 // if MOZ_UPDATER is defined.
 
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/DownloadUtils.jsm");
 
 const PREF_APP_UPDATE_CANCELATIONS_OSX = "app.update.cancelations.osx";
 const PREF_APP_UPDATE_ELEVATE_NEVER    = "app.update.elevate.never";
 
 var gAppUpdater;
 
--- a/mail/base/content/aboutDialog.js
+++ b/mail/base/content/aboutDialog.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+/* import-globals-from aboutDialog-appUpdater.js */
+
 "use strict";
 
 // Services = object with smart getters for common XPCOM services
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 function init(aEvent) {
   if (aEvent.target != document)
--- a/mail/base/content/commandglue.js
+++ b/mail/base/content/commandglue.js
@@ -1,18 +1,20 @@
 /* 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/. */
 
 /*
  * Command-specific code. This stuff should be called by the widgets
  */
 
+/* import-globals-from folderDisplay.js */
+/* import-globals-from folderPane.js */
+
 var { MailViewConstants } = ChromeUtils.import("resource:///modules/MailViewManager.jsm", null);
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function UpdateMailToolbar(caller) {
   // If we have a transient selection, we shouldn't update the toolbar. We'll
   // update it once we've restored the original selection.
   if ("gRightMouseButtonSavedSelection" in window &&
       window.gRightMouseButtonSavedSelection)
     return;
@@ -20,20 +22,20 @@ function UpdateMailToolbar(caller) {
   // dump("XXX update mail-toolbar " + caller + "\n");
   document.commandDispatcher.updateCommands("mail-toolbar");
 
   // hook for extra toolbar items
   Services.obs.notifyObservers(window, "mail:updateToolbarItems");
 }
 
 function isNewsURI(uri) {
-    if (!uri) {
-        return false;
-    }
-    return uri.startsWith("news:/") || uri.startsWith("news-message:/");
+  if (!uri) {
+      return false;
+  }
+  return uri.startsWith("news:/") || uri.startsWith("news-message:/");
 }
 
 function SwitchView(command) {
   // when switching thread views, we might be coming out of quick search
   // or a message view.
   // first set view picker to all
   if (gFolderDisplay.view.mailViewIndex != MailViewConstants.kViewItemAll)
     gFolderDisplay.view.setMailView(MailViewConstants.kViewItemAll);
@@ -178,102 +180,94 @@ function ConvertSortTypeToColumnID(sortK
   // Hack to turn this into an integer, if it was a string.
   // It would be a string if it came from XULStore.json.
   sortKey = sortKey - 0;
 
   switch (sortKey) {
     // In the case of None, we default to the date column
     // This appears to be the case in such instances as
     // Global search, so don't complain about it.
-    case nsMsgViewSortType.byNone:
-    case nsMsgViewSortType.byDate:
+    case Ci.nsMsgViewSortType.byNone:
+    case Ci.nsMsgViewSortType.byDate:
       columnID = "dateCol";
       break;
-    case nsMsgViewSortType.byReceived:
+    case Ci.nsMsgViewSortType.byReceived:
       columnID = "receivedCol";
       break;
-    case nsMsgViewSortType.byAuthor:
+    case Ci.nsMsgViewSortType.byAuthor:
       columnID = "senderCol";
       break;
-    case nsMsgViewSortType.byRecipient:
+    case Ci.nsMsgViewSortType.byRecipient:
       columnID = "recipientCol";
       break;
-    case nsMsgViewSortType.bySubject:
+    case Ci.nsMsgViewSortType.bySubject:
       columnID = "subjectCol";
       break;
-    case nsMsgViewSortType.byLocation:
+    case Ci.nsMsgViewSortType.byLocation:
       columnID = "locationCol";
       break;
-    case nsMsgViewSortType.byAccount:
+    case Ci.nsMsgViewSortType.byAccount:
       columnID = "accountCol";
       break;
-    case nsMsgViewSortType.byUnread:
+    case Ci.nsMsgViewSortType.byUnread:
       columnID = "unreadButtonColHeader";
       break;
-    case nsMsgViewSortType.byStatus:
+    case Ci.nsMsgViewSortType.byStatus:
       columnID = "statusCol";
       break;
-    case nsMsgViewSortType.byTags:
+    case Ci.nsMsgViewSortType.byTags:
       columnID = "tagsCol";
       break;
-    case nsMsgViewSortType.bySize:
+    case Ci.nsMsgViewSortType.bySize:
       columnID = "sizeCol";
       break;
-    case nsMsgViewSortType.byPriority:
+    case Ci.nsMsgViewSortType.byPriority:
       columnID = "priorityCol";
       break;
-    case nsMsgViewSortType.byFlagged:
+    case Ci.nsMsgViewSortType.byFlagged:
       columnID = "flaggedCol";
       break;
-    case nsMsgViewSortType.byThread:
+    case Ci.nsMsgViewSortType.byThread:
       columnID = "threadCol";
       break;
-    case nsMsgViewSortType.byId:
+    case Ci.nsMsgViewSortType.byId:
       columnID = "idCol";
       break;
-    case nsMsgViewSortType.byJunkStatus:
+    case Ci.nsMsgViewSortType.byJunkStatus:
       columnID = "junkStatusCol";
       break;
-    case nsMsgViewSortType.byAttachments:
+    case Ci.nsMsgViewSortType.byAttachments:
       columnID = "attachmentCol";
       break;
-    case nsMsgViewSortType.byCustom:
+    case Ci.nsMsgViewSortType.byCustom:
 
       // TODO: either change try() catch to if (property exists) or restore the getColumnHandler() check
       try { // getColumnHandler throws an error when the ID is not handled
         columnID = gDBView.curCustomColumn;
       } catch (err) { // error - means no handler
         dump("ConvertSortTypeToColumnID: custom sort key but no handler for column '" + columnID + "'\n");
         columnID = "dateCol";
       }
 
       break;
-    case nsMsgViewSortType.byCorrespondent:
+    case Ci.nsMsgViewSortType.byCorrespondent:
       columnID = "correspondentCol";
       break;
     default:
       dump("unsupported sort key: " + sortKey + "\n");
       columnID = "dateCol";
       break;
   }
   return columnID;
 }
 
-var nsMsgViewSortType = Ci.nsMsgViewSortType;
-var nsMsgViewSortOrder = Ci.nsMsgViewSortOrder;
-var nsMsgViewFlagsType = Ci.nsMsgViewFlagsType;
-var nsMsgViewCommandType = Ci.nsMsgViewCommandType;
-var nsMsgViewType = Ci.nsMsgViewType;
-var nsMsgNavigationType = Ci.nsMsgNavigationType;
-
 var gDBView = null;
 var gCurViewFlags;
 var gCurSortType;
 
-
 function ChangeMessagePaneVisibility(now_hidden) {
   // We also have to disable the Message/Attachments menuitem.
   // It will be enabled when loading a message with attachments
   // (see messageHeaderSink.handleAttachment).
   var node = document.getElementById("msgAttachmentMenu");
   if (node && now_hidden)
     node.setAttribute("disabled", "true");
 
--- a/mail/base/content/contentAreaClick.js
+++ b/mail/base/content/contentAreaClick.js
@@ -1,13 +1,17 @@
 /**
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from ../../../../toolkit/content/contentAreaUtils.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from phishingDetector.js */
+
   /**
    * Extract the href from the link click event.
    * We look for HTMLAnchorElement, HTMLAreaElement, HTMLLinkElement,
    * HTMLInputElement.form.action, and nested anchor tags.
    * If the clicked element was a HTMLInputElement or HTMLButtonElement
    * we return the form action.
    *
    * @return href for the url being clicked
--- a/mail/base/content/editContactPanel.js
+++ b/mail/base/content/editContactPanel.js
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 
 var editContactInlineUI = {
   _overlayLoaded: false,
   _overlayLoading: false,
   _cardDetails: null,
   _writeable: true,
   _blockedCommands: ["cmd_close"],
 
--- a/mail/base/content/extensions.xml
+++ b/mail/base/content/extensions.xml
@@ -1,9 +1,14 @@
 <?xml version="1.0"?>
+<!-- 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/. -->
+
+<!-- import-globals-from aboutAddonsExtra.js -->
 
 <!DOCTYPE bindings>
 
 <bindings id="thunderbird-addon-bindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
   <binding id="thunderbird-addon-generic"
--- a/mail/base/content/folderDisplay.js
+++ b/mail/base/content/folderDisplay.js
@@ -1,14 +1,18 @@
 /* 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/. */
 
+/* import-globals-from commandglue.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from ../../extensions/mailviews/content/msgViewPickerOverlay.js */
+
 ChromeUtils.import("resource:///modules/DBViewWrapper.jsm");
-ChromeUtils.import("resource:///modules/jsTreeSelection.js");
+var { JSTreeSelection } = ChromeUtils.import("resource:///modules/jsTreeSelection.js", null);
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gFolderDisplay = null;
 var gMessageDisplay = null;
 
 /**
  * Maintains a list of listeners for all FolderDisplayWidget instances in this
@@ -352,20 +356,20 @@ FolderDisplayWidget.prototype = {
    * Restore the last expandAll/collapseAll state, for both grouped and threaded
    * views. Not all views respect viewFlags, ie single folder non-virtual.
    */
   restoreThreadState() {
     if (!this._active || !this.tree || !this.view.dbView.viewFolder)
       return;
 
     if (this.view._threadExpandAll &&
-        !(this.view.dbView.viewFlags & nsMsgViewFlagsType.kExpandAll))
+        !(this.view.dbView.viewFlags & Ci.nsMsgViewFlagsType.kExpandAll))
       this.view.dbView.doCommand(Ci.nsMsgViewCommandType.expandAll);
     if (!this.view._threadExpandAll &&
-        this.view.dbView.viewFlags & nsMsgViewFlagsType.kExpandAll)
+        this.view.dbView.viewFlags & Ci.nsMsgViewFlagsType.kExpandAll)
       this.view.dbView.doCommand(Ci.nsMsgViewCommandType.collapseAll);
   },
   // @}
 
   /**
    * @name Columns
    * @protected Folder Display
    */
@@ -1126,17 +1130,17 @@ FolderDisplayWidget.prototype = {
     if (this.view.dbView.numSelected > 0) {
       this.ensureRowIsVisible(this.view.dbView.viewIndexForFirstSelectedMsg);
       return;
     }
 
     // - new messages
     // if configured to scroll to new messages, try that
     if (Services.prefs.getBoolPref("mailnews.scroll_to_new_message") &&
-        this.navigate(nsMsgNavigationType.firstNew, /* select */ false))
+        this.navigate(Ci.nsMsgNavigationType.firstNew, /* select */ false))
       return;
 
     // - last selected message
     // if configured to load the last selected message (this is currently more
     //  persistent than our saveSelection/restoreSelection stuff), and the view
     //  is backed by a single underlying folder (the only way having just a
     //  message key works out), try that
     if (Services.prefs.getBoolPref("mailnews.remember_selected_message") &&
@@ -1154,17 +1158,17 @@ FolderDisplayWidget.prototype = {
             this.view.dbView.viewIndexForFirstSelectedMsg);
           return;
         }
       }
     }
 
     // - towards the newest messages, but don't select
     if (this.view.isSortedAscending && this.view.sortImpliesTemporalOrdering &&
-      this.navigate(nsMsgNavigationType.lastMessage, /* select */ false))
+      this.navigate(Ci.nsMsgNavigationType.lastMessage, /* select */ false))
       return;
 
     // - to the top, the coliseum
     this.ensureRowIsVisible(0);
   },
 
   /**
    * The DBViewWrapper tells us when someone (possibly the wrapper itself)
@@ -1859,17 +1863,17 @@ FolderDisplayWidget.prototype = {
     let treeSelection = this.treeSelection; // potentially magic getter
     let currentIndex = treeSelection ? treeSelection.currentIndex : 0;
 
     let viewIndex;
     // 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 &&
+        aNavType == Ci.nsMsgNavigationType.nextUnreadMessage &&
         currentIndex != -1 &&
         this.view.isCollapsedThreadAtIndex(currentIndex) &&
         !(this.view.dbView.getFlagsAt(currentIndex) &
           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
--- a/mail/base/content/folderPane.js
+++ b/mail/base/content/folderPane.js
@@ -2,17 +2,26 @@
  * 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/. */
 
 // Implements a tree of folders. It shows icons depending on folder type
 // and other fancy styling.
 // This is used in the main folder pane, but also some dialogs that need
 // to show a nice list of folders.
 
-ChromeUtils.import("resource:///modules/folderUtils.jsm");
+/* import-globals-from commandglue.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+
+var {
+  getFolderProperties,
+  allAccountsSorted,
+  getMostRecentFolders,
+  folderNameCompare,
+} = ChromeUtils.import("resource:///modules/folderUtils.jsm", null);
 var {
   fixIterator,
   toXPCOMArray,
 } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm", null);
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource:///modules/IOUtils.js");
 ChromeUtils.import("resource:///modules/FeedUtils.jsm");
--- a/mail/base/content/foldersummary.js
+++ b/mail/base/content/foldersummary.js
@@ -1,15 +1,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/. */
 
 /* globals MozXULElement */
-/* global gFolderTreeView */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from ../../../mailnews/base/content/newmailalert.js */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 
 /**
  * MozFolderSummary displays a listing of NEW mails for the folder in question.
  * For each mail the subject, sender and a message preview can be included.
--- a/mail/base/content/glodaFacetBindings.xml
+++ b/mail/base/content/glodaFacetBindings.xml
@@ -1,14 +1,15 @@
 <?xml version="1.0"?>
-
 <!-- 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/. -->
 
+<!-- import-globals-from glodaFacetView.js -->
+
 <bindings id="glodaFacetBindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:html="http://www.w3.org/1999/xhtml"
           xmlns:xbl="http://www.mozilla.org/xbl"
           xmlns:svg="http://www.w3.org/2000/svg">
 
 <!-- ===== Constraints ===== -->
@@ -1370,26 +1371,16 @@
           msgNode.setAttribute("class", "message");
           messagesNode.appendChild(msgNode);
         }
       } catch (e) {
         logException(e);
       }
       ]]></body>
     </method>
-    <method name="ensureNodeVisible">
-      <parameter name="messageIndex"/>
-      <body><![CDATA[
-        let messagesNode = document.getAnonymousElementByAttribute(
-                             this, "anonid", "messages");
-        let message = messagesNode.childNodes[messageIndex];
-        window.scrollTo(0, $(message).position().top + $(window).scrollTop());
-      ]]></body>
-    </method>
-
     <method name="updateSortLabels">
       <body><![CDATA[
       try {
         let sortBy = FacetContext.sortBy;
         let sortRelevanceNode = document.getAnonymousElementByAttribute(
                           this, "anonid", "sort-relevance");
         let sortDateNode = document.getAnonymousElementByAttribute(
                           this, "anonid", "sort-date");
@@ -1468,16 +1459,19 @@
           subject.textContent = message.subject;
         let authorNode = anonElem("author");
         authorNode.setAttribute("title", message.from.value);
         authorNode.textContent = message.from.contact.name;
         let toNode = anonElem("to");
         toNode.textContent = glodaFacetStrings.get("glodaFacetView.result.message.toLabel");
 
         // anonElem("author").textContent = ;
+        let {
+          makeFriendlyDateAgo,
+        } = ChromeUtils.import("resource:///modules/templateUtils.js", null);
         anonElem("date").textContent = makeFriendlyDateAgo(message.date);
 
         // - Recipients
       try {
         let recipientsNode = anonElem("recipients");
         if (message.recipients) {
           let recipientCount = 0;
           const MAX_RECIPIENTS = 3;
--- a/mail/base/content/glodaFacetTab.js
+++ b/mail/base/content/glodaFacetTab.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource:///modules/StringBundle.js");
 
-ChromeUtils.import("resource:///modules/gloda/facet.js");
+var { FacetDriver } = ChromeUtils.import("resource:///modules/gloda/facet.js", null);
 // needed by search.xml to use us
-ChromeUtils.import("resource:///modules/gloda/msg_search.js");
+var { GlodaMsgSearcher } = ChromeUtils.import("resource:///modules/gloda/msg_search.js", null);
 
 var glodaFacetTabType = {
   name: "glodaFacet",
   perTabPanel: "vbox",
   lastTabId: 0,
   strings:
     new StringBundle("chrome://messenger/locale/glodaFacetView.properties"),
   modes: {
--- a/mail/base/content/glodaFacetView.js
+++ b/mail/base/content/glodaFacetView.js
@@ -7,25 +7,30 @@
  *  Model View Controller (paradigm), we are the view and the XBL widgets are
  *  the the view and controller.
  *
  * Because much of the work related to faceting is not UI-specific, we try and
  *  push as much of it into mailnews/db/gloda/facet.js.  In some cases we may
  *  get it wrong and it may eventually want to migrate.
  */
 
-ChromeUtils.import("resource:///modules/gloda/log4moz.js");
+var { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js", null);
 ChromeUtils.import("resource:///modules/StringBundle.js");
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
-ChromeUtils.import("resource:///modules/errUtils.js");
-ChromeUtils.import("resource:///modules/templateUtils.js");
+var {
+  logObject,
+  logException,
+} = ChromeUtils.import("resource:///modules/errUtils.js", null);
 
-ChromeUtils.import("resource:///modules/gloda/public.js");
-ChromeUtils.import("resource:///modules/gloda/facet.js");
+var { Gloda } = ChromeUtils.import("resource:///modules/gloda/public.js", null);
+var {
+  FacetDriver,
+  FacetUtils,
+} = ChromeUtils.import("resource:///modules/gloda/facet.js", null);
 
 var glodaFacetStrings =
   new StringBundle("chrome://messenger/locale/glodaFacetView.properties");
 
 /**
  * Represents the active constraints on a singular facet.  Singular facets can
  *  only have an inclusive set or an exclusive set, but not both.  Non-singular
  *  facets can have both.  Because they are different worlds, non-singular gets
--- a/mail/base/content/glodaFacetVis.js
+++ b/mail/base/content/glodaFacetVis.js
@@ -3,16 +3,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Facet visualizations that would be awkward in XBL.  Allegedly because the
  *  interaciton idiom of a protovis-based visualization is entirely different
  *  from XBL, but also a lot because of the lack of good syntax highlighting.
  */
 
+/* import-globals-from glodaFacetView.js */
+/* import-globals-from protovis-r2.6-modded.js */
+
 /**
  * A date facet visualization abstraction.
  */
 function DateFacetVis(aBinding, aCanvasNode) {
   this.binding = aBinding;
   this.canvasNode = aCanvasNode;
 
   this.faceter = aBinding.faceter;
--- a/mail/base/content/macMessengerMenu.js
+++ b/mail/base/content/macMessengerMenu.js
@@ -1,13 +1,15 @@
 /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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/. */
 
+/* import-globals-from mailCore.js */
+
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 // Load and add the menu item to the OS X Dock icon menu.
 addEventListener("load", function() {
   let dockMenuElement = document.getElementById("menu_mac_dockmenu");
   let nativeMenu = Cc["@mozilla.org/widget/standalonenativemenu;1"]
                     .createInstance(Ci.nsIStandaloneNativeMenu);
--- a/mail/base/content/mail-compacttheme.js
+++ b/mail/base/content/mail-compacttheme.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+/* import-globals-from mailWindow.js */
+
 /**
  * Enables compacttheme.css when needed.
  */
 var CompactTheme = {
   get styleSheet() {
     // Change getter into a read/write property.
     delete this.styleSheet;
     for (let styleSheet of document.styleSheets) {
--- a/mail/base/content/mail-offline.js
+++ b/mail/base/content/mail-offline.js
@@ -1,13 +1,15 @@
 /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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/. */
 
+/* import-globals-from mailWindow.js */
+
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var MailOfflineMgr = {
   offlineManager: null,
   offlineBundle: null,
 
   init() {
     Services.obs.addObserver(this, "network:offline-status-changed");
--- a/mail/base/content/mail3PaneWindowCommands.js
+++ b/mail/base/content/mail3PaneWindowCommands.js
@@ -2,16 +2,23 @@
  * 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/. */
 
 /**
  * Functionality for the main application window (aka the 3pane) usually
  * consisting of folder pane, thread pane and message pane.
  */
 
+/* import-globals-from ../../components/im/content/chat-messenger.js */
+/* import-globals-from commandglue.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from msgViewNavigation.js */
+/* import-globals-from threadPane.js */
+
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 
 // Controller object for folder pane
 var FolderPaneController = {
   supportsCommand(command) {
@@ -258,42 +265,42 @@ var DefaultController = {
 
   isCommandEnabled(command) {
     switch (command) {
       case "cmd_delete":
         UpdateDeleteCommand();
         // fall through
       case "button_delete":
         UpdateDeleteToolbarButton();
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.deleteMsg);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.deleteMsg);
       case "cmd_shiftDelete":
       case "button_shiftDelete":
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.deleteNoTrash);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.deleteNoTrash);
       case "cmd_cancel":
         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(Ci.nsMsgFolderFlags.Virtual);
           }
           return CanDeleteFolder(folder);
         }
         return false;
       case "button_junk":
         UpdateJunkToolbarButton();
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.junk);
       case "cmd_killThread":
       case "cmd_killSubthread":
         return gFolderDisplay.selectedCount > 0;
       case "cmd_watchThread":
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.toggleThreadWatched);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.toggleThreadWatched);
       case "cmd_createFilterFromPopup":
       case "cmd_createFilterFromMenu":
         return gFolderDisplay.selectedCount == 1 &&
                gFolderDisplay.selectedMessage.folder &&
                gFolderDisplay.selectedMessage.folder.server.canHaveFilters;
       case "cmd_openConversation":
       case "button_showconversation":
         return gFolderDisplay.selectedCount == 1 &&
@@ -330,17 +337,17 @@ var DefaultController = {
         if (command == "cmd_applyFiltersToSelection") {
           var whichText = "valueMessage";
           if (numSelected > 1)
             whichText = "valueSelection";
           goSetMenuValue(command, whichText);
           goSetAccessKey(command, whichText + "AccessKey");
         }
         if (numSelected > 0) {
-          if (!gFolderDisplay.getCommandStatus(nsMsgViewCommandType.cmdRequiringMsgBody))
+          if (!gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.cmdRequiringMsgBody))
             return false;
 
           // Check if we have a collapsed thread selected and are summarizing it.
           // If so, selectedIndices.length won't match numSelected. Also check
           // that we're not displaying a message, which handles the case
           // where we failed to summarize the selection and fell back to
           // displaying a message.
           if (gFolderDisplay.selectedIndices.length != numSelected &&
@@ -352,48 +359,48 @@ var DefaultController = {
             return IsReplyEnabled();
           if (command == "cmd_replylist" || command == "button_replylist")
             return IsReplyListEnabled();
           return true;
         }
         return false;
       case "cmd_printpreview":
         if (gFolderDisplay.selectedCount == 1)
-          return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.cmdRequiringMsgBody);
+          return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.cmdRequiringMsgBody);
         return false;
       case "cmd_newMessage":
         return CanComposeMessages();
       case "cmd_printSetup":
       case "cmd_viewAllHeader":
       case "cmd_viewNormalHeader":
         return true;
       case "cmd_markAsFlagged":
       case "button_file":
         return gFolderDisplay.selectedCount > 0;
       case "cmd_archive":
       case "button_archive":
         return gFolderDisplay.canArchiveSelectedMessages;
       case "cmd_markAsJunk":
       case "cmd_markAsNotJunk":
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.junk);
       case "cmd_recalculateJunkScore":
         // We're going to take a conservative position here, because we really
         // don't want people running junk controls on folders that are not
         // enabled for junk. The junk type picks up possible dummy message headers,
         // while the runJunkControls will prevent running on XF virtual folders.
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk) &&
-               gFolderDisplay.getCommandStatus(nsMsgViewCommandType.runJunkControls);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.junk) &&
+               gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.runJunkControls);
       case "cmd_displayMsgFilters":
         return MailServices.accounts.accounts.length > 0;
       case "cmd_applyFilters":
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.applyFilters);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.applyFilters);
       case "cmd_runJunkControls":
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.runJunkControls);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.runJunkControls);
       case "cmd_deleteJunk":
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.deleteJunk);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.deleteJunk);
       case "button_mark":
       case "cmd_tag":
       case "cmd_addTag":
       case "cmd_manageTags":
       case "cmd_removeTags":
       case "cmd_tag1":
       case "cmd_tag2":
       case "cmd_tag3":
@@ -420,17 +427,17 @@ var DefaultController = {
       case "button_previous":
       case "cmd_previousUnreadMsg":
         return IsViewNavigationItemEnabled();
       case "button_goForward":
       case "button_goBack":
       case "cmd_goForward":
       case "cmd_goBack":
         if (gDBView)
-          return gDBView.navigateStatus((command == "cmd_goBack" || command == "button_goBack") ? nsMsgNavigationType.back : nsMsgNavigationType.forward);
+          return gDBView.navigateStatus((command == "cmd_goBack" || command == "button_goBack") ? Ci.nsMsgNavigationType.back : Ci.nsMsgNavigationType.forward);
         return false;
       case "cmd_goStartPage":
         return document.getElementById("tabmail").selectedTab.mode.name == "folder" &&
                !IsMessagePaneCollapsed();
       case "cmd_undoCloseTab":
         return (document.getElementById("tabmail").recentlyClosedTabs.length > 0);
       case "cmd_markAllRead":
         return IsFolderSelected() && gDBView && gDBView.msgFolder &&
@@ -648,92 +655,92 @@ var DefaultController = {
          // this ensures that we clear the biff indicator from the system tray when the user deletes the new message
         MarkSelectedMessagesRead(true);
         // If this is a right-click triggered delete, then do not hint about
         //  the deletion.  Note: The code that swaps the selection back in will
         //  take care of ensuring that this deletion does not make the saved
         //  selection incorrect.
         if (!gRightMouseButtonSavedSelection)
           gFolderDisplay.hintAboutToDeleteMessages();
-        gFolderDisplay.doCommand(nsMsgViewCommandType.deleteMsg);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.deleteMsg);
         UpdateDeleteToolbarButton();
         break;
       case "cmd_cancel":
         let message = gFolderDisplay.selectedMessage;
         message.folder.QueryInterface(Ci.nsIMsgNewsFolder)
                       .cancelMessage(message, msgWindow);
         break;
       case "button_shiftDelete":
       case "cmd_shiftDelete":
         MarkSelectedMessagesRead(true);
         gFolderDisplay.hintAboutToDeleteMessages();
-        gFolderDisplay.doCommand(nsMsgViewCommandType.deleteNoTrash);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.deleteNoTrash);
         UpdateDeleteToolbarButton();
         break;
       case "cmd_deleteFolder":
         gFolderTreeController.deleteFolder();
         break;
       case "cmd_killThread":
         if (!gFolderDisplay.selectedMessageIsNews) {
           if (!gFolderDisplay.selectedMessageThreadIgnored) {
             ShowIgnoredMessageNotification(gFolderDisplay.selectedMessages, false);
           } else {
             document.getElementById("msg-footer-notification-box")
                     .removeTransientNotifications();
           }
         }
         // kill thread kills the thread and then does a next unread
-        GoNextMessage(nsMsgNavigationType.toggleThreadKilled, true);
+        GoNextMessage(Ci.nsMsgNavigationType.toggleThreadKilled, true);
         break;
       case "cmd_killSubthread":
         if (!gFolderDisplay.selectedMessageIsNews) {
           if (!gFolderDisplay.selectedMessageSubthreadIgnored) {
             ShowIgnoredMessageNotification(gFolderDisplay.selectedMessages, true);
           } else {
             document.getElementById("msg-footer-notification-box")
                     .removeTransientNotifications();
           }
         }
-        GoNextMessage(nsMsgNavigationType.toggleSubthreadKilled, true);
+        GoNextMessage(Ci.nsMsgNavigationType.toggleSubthreadKilled, true);
         break;
       case "cmd_watchThread":
-        gFolderDisplay.doCommand(nsMsgViewCommandType.toggleThreadWatched);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.toggleThreadWatched);
         break;
       case "button_next":
       case "cmd_nextUnreadMsg":
-        GoNextMessage(nsMsgNavigationType.nextUnreadMessage, true);
+        GoNextMessage(Ci.nsMsgNavigationType.nextUnreadMessage, true);
         break;
       case "cmd_nextUnreadThread":
-        GoNextMessage(nsMsgNavigationType.nextUnreadThread, true);
+        GoNextMessage(Ci.nsMsgNavigationType.nextUnreadThread, true);
         break;
       case "button_nextMsg":
       case "cmd_nextMsg":
-        GoNextMessage(nsMsgNavigationType.nextMessage, false);
+        GoNextMessage(Ci.nsMsgNavigationType.nextMessage, false);
         break;
       case "cmd_nextFlaggedMsg":
-        GoNextMessage(nsMsgNavigationType.nextFlagged, true);
+        GoNextMessage(Ci.nsMsgNavigationType.nextFlagged, true);
         break;
       case "button_previousMsg":
       case "cmd_previousMsg":
-        GoNextMessage(nsMsgNavigationType.previousMessage, false);
+        GoNextMessage(Ci.nsMsgNavigationType.previousMessage, false);
         break;
       case "button_previous":
       case "cmd_previousUnreadMsg":
-        GoNextMessage(nsMsgNavigationType.previousUnreadMessage, true);
+        GoNextMessage(Ci.nsMsgNavigationType.previousUnreadMessage, true);
         break;
       case "cmd_previousFlaggedMsg":
-        GoNextMessage(nsMsgNavigationType.previousFlagged, true);
+        GoNextMessage(Ci.nsMsgNavigationType.previousFlagged, true);
         break;
       case "button_goForward":
       case "cmd_goForward":
-        GoNextMessage(nsMsgNavigationType.forward, true);
+        GoNextMessage(Ci.nsMsgNavigationType.forward, true);
         break;
       case "button_goBack":
       case "cmd_goBack":
-        GoNextMessage(nsMsgNavigationType.back, true);
+        GoNextMessage(Ci.nsMsgNavigationType.back, true);
         break;
       case "cmd_goStartPage":
         HideMessageHeaderPane();
         loadStartPage(true);
         break;
       case "cmd_undoCloseTab":
         document.getElementById("tabmail").undoCloseTab();
         break;
@@ -760,22 +767,22 @@ var DefaultController = {
         break;
       case "cmd_undo":
         messenger.undo(msgWindow);
         break;
       case "cmd_redo":
         messenger.redo(msgWindow);
         break;
       case "cmd_expandAllThreads":
-        gFolderDisplay.doCommand(nsMsgViewCommandType.expandAll);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.expandAll);
         gFolderDisplay.ensureSelectionIsVisible();
         break;
       case "cmd_collapseAllThreads":
         gFolderDisplay.selectSelectedThreadRoots();
-        gFolderDisplay.doCommand(nsMsgViewCommandType.collapseAll);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.collapseAll);
         gFolderDisplay.ensureSelectionIsVisible();
         break;
       case "cmd_renameFolder":
         gFolderTreeController.renameFolder();
         return;
       case "cmd_sendUnsentMsgs":
         // if offline, prompt for sendUnsentMessages
         if (MailOfflineMgr.isOnline())
@@ -872,20 +879,20 @@ var DefaultController = {
       case "cmd_markAsRead":
         MsgMarkMsgAsRead(true);
         return;
       case "cmd_markAsUnread":
         MsgMarkMsgAsRead(false);
         return;
       case "cmd_markThreadAsRead":
         ClearPendingReadTimer();
-        gFolderDisplay.doCommand(nsMsgViewCommandType.markThreadRead);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.markThreadRead);
         return;
       case "cmd_markAllRead":
-        gFolderDisplay.doCommand(nsMsgViewCommandType.markAllRead);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.markAllRead);
         return;
       case "button_junk":
         MsgJunk();
         return;
       case "cmd_stop":
         msgWindow.StopUrls();
         return;
       case "cmd_markAsFlagged":
@@ -928,20 +935,20 @@ var DefaultController = {
         return;
       case "cmd_compactFolder":
         gFolderTreeController.compactAllFoldersForAccount();
         return;
       case "button_compact":
         gFolderTreeController.compactFolders();
         return;
       case "cmd_downloadFlagged":
-          gFolderDisplay.doCommand(nsMsgViewCommandType.downloadFlaggedForOffline);
+          gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.downloadFlaggedForOffline);
           break;
       case "cmd_downloadSelected":
-          gFolderDisplay.doCommand(nsMsgViewCommandType.downloadSelectedForOffline);
+          gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.downloadSelectedForOffline);
           break;
       case "cmd_synchronizeOffline":
           MsgSynchronizeOffline();
           break;
       case "cmd_settingsOffline":
           MailOfflineMgr.openOfflineAccountSettings();
           break;
       case "cmd_moveToFolderAgain":
@@ -956,23 +963,23 @@ var DefaultController = {
         // XXX If the message pane is selected but the tab focused, this ends
         // closing the message tab. See bug 502834.
         if (aTab.mode.name == "message")
           break;
 
         // move the focus so the user can delete the newly selected messages, not the folder
         SetFocusThreadPane();
         // if in threaded mode, the view will expand all before selecting all
-        gFolderDisplay.doCommand(nsMsgViewCommandType.selectAll);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.selectAll);
         break;
       case "cmd_selectThread":
-          gFolderDisplay.doCommand(nsMsgViewCommandType.selectThread);
+          gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.selectThread);
           break;
       case "cmd_selectFlagged":
-        gFolderDisplay.doCommand(nsMsgViewCommandType.selectFlagged);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.selectFlagged);
         break;
       case "cmd_fullZoomReduce":
         ZoomManager.reduce();
         break;
       case "cmd_fullZoomEnlarge":
         ZoomManager.enlarge();
         break;
       case "cmd_fullZoomReset":
--- a/mail/base/content/mailCommands.js
+++ b/mail/base/content/mailCommands.js
@@ -1,13 +1,17 @@
 /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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/. */
 
+/* import-globals-from commandglue.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 
 /**
  * Get the identity that most likely is the best one to use, given the hint.
  * @param identities    nsIArray<nsIMsgIdentity> of identities
  * @param optionalHint  string containing comma separated mailboxes
  * @param useDefault    If true, use the default identity of the default
@@ -447,21 +451,29 @@ function SaveAsTemplate(uri) {
         return;
     }
     messenger.saveAs(uri, false, identity, null);
   }
 }
 
 function MarkSelectedMessagesRead(markRead) {
   ClearPendingReadTimer();
-  gDBView.doCommand(markRead ? nsMsgViewCommandType.markMessagesRead : nsMsgViewCommandType.markMessagesUnread);
+  gDBView.doCommand(
+    markRead ?
+    Ci.nsMsgViewCommandType.markMessagesRead :
+    Ci.nsMsgViewCommandType.markMessagesUnread
+  );
 }
 
 function MarkSelectedMessagesFlagged(markFlagged) {
-  gDBView.doCommand(markFlagged ? nsMsgViewCommandType.flagMessages : nsMsgViewCommandType.unflagMessages);
+  gDBView.doCommand(
+    markFlagged ?
+    Ci.nsMsgViewCommandType.flagMessages :
+    Ci.nsMsgViewCommandType.unflagMessages
+  );
 }
 
 function ViewPageSource(messages) {
   var numMessages = messages.length;
 
   if (numMessages == 0) {
     dump("MsgViewPageSource(): No messages selected.\n");
     return false;
--- a/mail/base/content/mailContextMenus.js
+++ b/mail/base/content/mailContextMenus.js
@@ -1,12 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from commandglue.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from nsContextMenu.js */
+
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 var mailtolength = 7;
 
 /**
  * Function to change the highlighted row back to the row that is currently
--- a/mail/base/content/mailCore.js
+++ b/mail/base/content/mailCore.js
@@ -7,16 +7,21 @@
  * Core mail routines used by all of the major mail windows (address book,
  * 3-pane, compose and stand alone message window).
  * Routines to support custom toolbars in mail windows, opening up a new window
  * of a particular type all live here.
  * Before adding to this file, ask yourself, is this a JS routine that is going
  * to be used by all of the main mail windows?
  */
 
+/* import-globals-from ../../../common/src/customizeToolbar.js */
+/* import-globals-from ../../extensions/mailviews/content/msgViewPickerOverlay.js */
+/* import-globals-from commandglue.js */
+/* import-globals-from mailWindow.js */
+
 ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/CharsetMenu.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "gViewSourceUtils", function() {
--- a/mail/base/content/mailTabs.js
+++ b/mail/base/content/mailTabs.js
@@ -1,16 +1,25 @@
 /* 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/. */
 
+/* import-globals-from commandglue.js */
+/* import-globals-from mail3PaneWindowCommands.js */
+/* import-globals-from mailContextMenus.js */
+/* import-globals-from mailWindowOverlay.js */
+/* import-globals-from messageDisplay.js */
+/* import-globals-from msgMail3PaneWindow.js */
+
 ChromeUtils.import("resource:///modules/MsgHdrSyntheticView.jsm");
-ChromeUtils.import("resource:///modules/errUtils.js");
+var { logException } = ChromeUtils.import("resource:///modules/errUtils.js", null);
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { getSpecialFolderString } = ChromeUtils.import("resource:///modules/folderUtils.jsm", null);
+var { MsgHdrToMimeMessage } = ChromeUtils.import("resource:///modules/gloda/mimemsg.js", null);
 
 /**
  * Displays message "folder"s, mail "message"s, and "glodaList" results.  The
  *  commonality is that they all use the "mailContent" panel's folder tree,
  *  thread tree, and message pane objects.  This happens for historical reasons,
  *  likely involving the fact that prior to the introduction of this
  *  abstraction, everything was always stored in global objects.  For the 3.0
  *  release cycle we considered avoiding this 'multiplexed' style of operation
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -1,13 +1,17 @@
 <?xml version="1.0"?>
 <!-- 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/. -->
 
+<!-- globals fillInTags // mailWidgets.xml -->
+<!-- import-globals-from ../../../mailnews/base/content/dateFormat.js -->
+<!-- import-globals-from mailWindow.js -->
+<!-- import-globals-from SearchDialog.js -->
 
 <!DOCTYPE bindings [
 <!ENTITY % msgHdrViewOverlayDTD SYSTEM "chrome://messenger/locale/msgHdrViewOverlay.dtd" >
 %msgHdrViewOverlayDTD;
 <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
 %messengerDTD;
 ]>
 
@@ -1930,17 +1934,17 @@
                   index = 0;
                   break;
                 case event.DOM_VK_END:
                   index = box.view.rowCount - 1;
                   break;
                 default:
                   if (event.charCode > 0 && !event.ctrlKey && !event.metaKey) {
                     event.preventDefault();
-                    index = tree.keyNavigate(event);
+                    index = this.tree.keyNavigate(event);
                     if (index >= 0)
                       break;
                   }
                   return;
               }
               box.view.selection.select(index);
               if (this.parentNode.hasAttribute("open"))
                 box.ensureRowIsVisible(index);
--- a/mail/base/content/mailWindow.js
+++ b/mail/base/content/mailWindow.js
@@ -1,20 +1,31 @@
 /**
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from ../../../../toolkit/content/contentAreaUtils.js */
+/* import-globals-from ../../../../toolkit/content/globalOverlay.js */
+/* import-globals-from ../../../../toolkit/content/viewZoomOverlay.js */
+/* import-globals-from commandglue.js */
+/* import-globals-from mail-offline.js */
+/* import-globals-from mailCore.js */
+/* import-globals-from mailWindowOverlay.js */
+/* import-globals-from msgHdrView.js */
+/* import-globals-from msgMail3PaneWindow.js */
+/* import-globals-from utilityOverlay.js */
+
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource:///modules/appIdleManager.js");
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource:///modules/gloda/log4moz.js");
-ChromeUtils.import("resource:///modules/gloda/public.js");
+var { Log4Moz } = ChromeUtils.import("resource:///modules/gloda/log4moz.js", null);
+var { Gloda } = ChromeUtils.import("resource:///modules/gloda/public.js", null);
 
 // This file stores variables common to mail windows
 var messenger;
 var statusFeedback;
 var msgWindow;
 
 var accountManager;
 
@@ -658,17 +669,17 @@ nsBrowserAccess.prototype = {
     if (!win)
       throw new Error("Couldn't get a suitable window for openURI");
 
     let loadInBackground =
       Services.prefs.getBoolPref("browser.tabs.loadDivertedInBackground");
 
     let tabmail = win.document.getElementById("tabmail");
     let clickHandler = null;
-    let browser = tabmail.getBrowserForDocument(content);
+    let browser = tabmail.getBrowserForDocument(window.content);
     if (browser)
       clickHandler = browser.clickHandler;
 
     let newTab = tabmail.openTab("contentTab", {contentPage: "about:blank",
                                                 background: loadInBackground,
                                                 clickHandler});
 
     newWindow = newTab.browser.docShell.domWindow;
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -1,21 +1,33 @@
 /* -*- indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+/* import-globals-from ../../../mailnews/base/content/junkCommands.js */
+/* import-globals-from ../../../mailnews/extensions/newsblog/content/newsblogOverlay.js */
+/* import-globals-from commandglue.js */
+/* import-globals-from contentAreaClick.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mail3PaneWindowCommands.js */
+/* import-globals-from mailCommands.js */
+/* import-globals-from mailContextMenus.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from phishingDetector.js */
+
 ChromeUtils.import("resource:///modules/FeedUtils.jsm");
-ChromeUtils.import("resource:///modules/gloda/dbview.js");
+var { GlodaSyntheticView } = ChromeUtils.import("resource:///modules/gloda/dbview.js", null);
 ChromeUtils.import("resource:///modules/MailConsts.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 
 ChromeUtils.defineModuleGetter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm");
 ChromeUtils.defineModuleGetter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
 ChromeUtils.defineModuleGetter(this, "ExtensionParent", "resource://gre/modules/ExtensionParent.jsm");
 ChromeUtils.defineModuleGetter(this, "ExtensionSupport", "resource:///modules/extensionSupport.jsm");
 Object.defineProperty(this, "HUDService", {
   get() {
     let { devtools } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", null);
@@ -304,37 +316,37 @@ function setSortByMenuItemCheckState(id,
 
 /**
  * Called when showing the menu_viewSortPopup menupopup, so it should always
  * be up-to-date.
  */
 function InitViewSortByMenu() {
   var sortType = gFolderDisplay.view.primarySortType;
 
-  setSortByMenuItemCheckState("sortByDateMenuitem", (sortType == nsMsgViewSortType.byDate));
-  setSortByMenuItemCheckState("sortByReceivedMenuitem", (sortType == nsMsgViewSortType.byReceived));
-  setSortByMenuItemCheckState("sortByFlagMenuitem", (sortType == nsMsgViewSortType.byFlagged));
-  setSortByMenuItemCheckState("sortByOrderReceivedMenuitem", (sortType == nsMsgViewSortType.byId));
-  setSortByMenuItemCheckState("sortByPriorityMenuitem", (sortType == nsMsgViewSortType.byPriority));
-  setSortByMenuItemCheckState("sortBySizeMenuitem", (sortType == nsMsgViewSortType.bySize));
-  setSortByMenuItemCheckState("sortByStatusMenuitem", (sortType == nsMsgViewSortType.byStatus));
-  setSortByMenuItemCheckState("sortBySubjectMenuitem", (sortType == nsMsgViewSortType.bySubject));
-  setSortByMenuItemCheckState("sortByUnreadMenuitem", (sortType == nsMsgViewSortType.byUnread));
-  setSortByMenuItemCheckState("sortByTagsMenuitem", (sortType == nsMsgViewSortType.byTags));
-  setSortByMenuItemCheckState("sortByJunkStatusMenuitem", (sortType == nsMsgViewSortType.byJunkStatus));
-  setSortByMenuItemCheckState("sortByFromMenuitem", (sortType == nsMsgViewSortType.byAuthor));
-  setSortByMenuItemCheckState("sortByRecipientMenuitem", (sortType == nsMsgViewSortType.byRecipient));
-  setSortByMenuItemCheckState("sortByAttachmentsMenuitem", (sortType == nsMsgViewSortType.byAttachments));
-  setSortByMenuItemCheckState("sortByCorrespondentMenuitem", (sortType == nsMsgViewSortType.byCorrespondent));
+  setSortByMenuItemCheckState("sortByDateMenuitem", (sortType == Ci.nsMsgViewSortType.byDate));
+  setSortByMenuItemCheckState("sortByReceivedMenuitem", (sortType == Ci.nsMsgViewSortType.byReceived));
+  setSortByMenuItemCheckState("sortByFlagMenuitem", (sortType == Ci.nsMsgViewSortType.byFlagged));
+  setSortByMenuItemCheckState("sortByOrderReceivedMenuitem", (sortType == Ci.nsMsgViewSortType.byId));
+  setSortByMenuItemCheckState("sortByPriorityMenuitem", (sortType == Ci.nsMsgViewSortType.byPriority));
+  setSortByMenuItemCheckState("sortBySizeMenuitem", (sortType == Ci.nsMsgViewSortType.bySize));
+  setSortByMenuItemCheckState("sortByStatusMenuitem", (sortType == Ci.nsMsgViewSortType.byStatus));
+  setSortByMenuItemCheckState("sortBySubjectMenuitem", (sortType == Ci.nsMsgViewSortType.bySubject));
+  setSortByMenuItemCheckState("sortByUnreadMenuitem", (sortType == Ci.nsMsgViewSortType.byUnread));
+  setSortByMenuItemCheckState("sortByTagsMenuitem", (sortType == Ci.nsMsgViewSortType.byTags));
+  setSortByMenuItemCheckState("sortByJunkStatusMenuitem", (sortType == Ci.nsMsgViewSortType.byJunkStatus));
+  setSortByMenuItemCheckState("sortByFromMenuitem", (sortType == Ci.nsMsgViewSortType.byAuthor));
+  setSortByMenuItemCheckState("sortByRecipientMenuitem", (sortType == Ci.nsMsgViewSortType.byRecipient));
+  setSortByMenuItemCheckState("sortByAttachmentsMenuitem", (sortType == Ci.nsMsgViewSortType.byAttachments));
+  setSortByMenuItemCheckState("sortByCorrespondentMenuitem", (sortType == Ci.nsMsgViewSortType.byCorrespondent));
 
   var sortOrder = gFolderDisplay.view.primarySortOrder;
   var sortTypeSupportsGrouping = isSortTypeValidForGrouping(sortType);
 
-  setSortByMenuItemCheckState("sortAscending", (sortOrder == nsMsgViewSortOrder.ascending));
-  setSortByMenuItemCheckState("sortDescending", (sortOrder == nsMsgViewSortOrder.descending));
+  setSortByMenuItemCheckState("sortAscending", (sortOrder == Ci.nsMsgViewSortOrder.ascending));
+  setSortByMenuItemCheckState("sortDescending", (sortOrder == Ci.nsMsgViewSortOrder.descending));
 
   var grouped = gFolderDisplay.view.showGroupedBySort;
   var threaded = gFolderDisplay.view.showThreaded;
   var sortThreadedMenuItem = document.getElementById("sortThreaded");
   var sortUnthreadedMenuItem = document.getElementById("sortUnthreaded");
 
   sortThreadedMenuItem.setAttribute("checked", threaded);
   sortUnthreadedMenuItem.setAttribute("checked", !threaded && !grouped);
@@ -343,66 +355,66 @@ function InitViewSortByMenu() {
 
   groupBySortOrderMenuItem.setAttribute("disabled", !sortTypeSupportsGrouping);
   groupBySortOrderMenuItem.setAttribute("checked", grouped);
 }
 
 function InitAppViewSortByMenu() {
   let sortType = gFolderDisplay.view.primarySortType;
 
-  setSortByMenuItemCheckState("appmenu_sortByDateMenuitem", (sortType == nsMsgViewSortType.byDate));
-  setSortByMenuItemCheckState("appmenu_sortByReceivedMenuitem", (sortType == nsMsgViewSortType.byReceived));
-  setSortByMenuItemCheckState("appmenu_sortByFlagMenuitem", (sortType == nsMsgViewSortType.byFlagged));
-  setSortByMenuItemCheckState("appmenu_sortByOrderReceivedMenuitem", (sortType == nsMsgViewSortType.byId));
-  setSortByMenuItemCheckState("appmenu_sortByPriorityMenuitem", (sortType == nsMsgViewSortType.byPriority));
-  setSortByMenuItemCheckState("appmenu_sortBySizeMenuitem", (sortType == nsMsgViewSortType.bySize));
-  setSortByMenuItemCheckState("appmenu_sortByStatusMenuitem", (sortType == nsMsgViewSortType.byStatus));
-  setSortByMenuItemCheckState("appmenu_sortBySubjectMenuitem", (sortType == nsMsgViewSortType.bySubject));
-  setSortByMenuItemCheckState("appmenu_sortByUnreadMenuitem", (sortType == nsMsgViewSortType.byUnread));
-  setSortByMenuItemCheckState("appmenu_sortByTagsMenuitem", (sortType == nsMsgViewSortType.byTags));
-  setSortByMenuItemCheckState("appmenu_sortByJunkStatusMenuitem", (sortType == nsMsgViewSortType.byJunkStatus));
-  setSortByMenuItemCheckState("appmenu_sortByFromMenuitem", (sortType == nsMsgViewSortType.byAuthor));
-  setSortByMenuItemCheckState("appmenu_sortByRecipientMenuitem", (sortType == nsMsgViewSortType.byRecipient));
-  setSortByMenuItemCheckState("appmenu_sortByAttachmentsMenuitem", (sortType == nsMsgViewSortType.byAttachments));
+  setSortByMenuItemCheckState("appmenu_sortByDateMenuitem", (sortType == Ci.nsMsgViewSortType.byDate));
+  setSortByMenuItemCheckState("appmenu_sortByReceivedMenuitem", (sortType == Ci.nsMsgViewSortType.byReceived));
+  setSortByMenuItemCheckState("appmenu_sortByFlagMenuitem", (sortType == Ci.nsMsgViewSortType.byFlagged));
+  setSortByMenuItemCheckState("appmenu_sortByOrderReceivedMenuitem", (sortType == Ci.nsMsgViewSortType.byId));
+  setSortByMenuItemCheckState("appmenu_sortByPriorityMenuitem", (sortType == Ci.nsMsgViewSortType.byPriority));
+  setSortByMenuItemCheckState("appmenu_sortBySizeMenuitem", (sortType == Ci.nsMsgViewSortType.bySize));
+  setSortByMenuItemCheckState("appmenu_sortByStatusMenuitem", (sortType == Ci.nsMsgViewSortType.byStatus));
+  setSortByMenuItemCheckState("appmenu_sortBySubjectMenuitem", (sortType == Ci.nsMsgViewSortType.bySubject));
+  setSortByMenuItemCheckState("appmenu_sortByUnreadMenuitem", (sortType == Ci.nsMsgViewSortType.byUnread));
+  setSortByMenuItemCheckState("appmenu_sortByTagsMenuitem", (sortType == Ci.nsMsgViewSortType.byTags));
+  setSortByMenuItemCheckState("appmenu_sortByJunkStatusMenuitem", (sortType == Ci.nsMsgViewSortType.byJunkStatus));
+  setSortByMenuItemCheckState("appmenu_sortByFromMenuitem", (sortType == Ci.nsMsgViewSortType.byAuthor));
+  setSortByMenuItemCheckState("appmenu_sortByRecipientMenuitem", (sortType == Ci.nsMsgViewSortType.byRecipient));
+  setSortByMenuItemCheckState("appmenu_sortByAttachmentsMenuitem", (sortType == Ci.nsMsgViewSortType.byAttachments));
 
   let sortOrder = gFolderDisplay.view.primarySortOrder;
   let sortTypeSupportsGrouping = isSortTypeValidForGrouping(sortType);
 
-  setSortByMenuItemCheckState("appmenu_sortAscending", (sortOrder == nsMsgViewSortOrder.ascending));
-  setSortByMenuItemCheckState("appmenu_sortDescending", (sortOrder == nsMsgViewSortOrder.descending));
+  setSortByMenuItemCheckState("appmenu_sortAscending", (sortOrder == Ci.nsMsgViewSortOrder.ascending));
+  setSortByMenuItemCheckState("appmenu_sortDescending", (sortOrder == Ci.nsMsgViewSortOrder.descending));
 
   let grouped = gFolderDisplay.view.showGroupedBySort;
   let threaded = gFolderDisplay.view.showThreaded;
   let sortThreadedMenuItem = document.getElementById("appmenu_sortThreaded");
   let sortUnthreadedMenuItem = document.getElementById("appmenu_sortUnthreaded");
 
   sortThreadedMenuItem.setAttribute("checked", threaded);
   sortUnthreadedMenuItem.setAttribute("checked", !threaded && !grouped);
 
   let groupBySortOrderMenuItem = document.getElementById("appmenu_groupBySort");
 
   groupBySortOrderMenuItem.setAttribute("disabled", !sortTypeSupportsGrouping);
   groupBySortOrderMenuItem.setAttribute("checked", grouped);
 }
 
 function isSortTypeValidForGrouping(sortType) {
-  return Boolean(sortType == nsMsgViewSortType.byAccount ||
-                 sortType == nsMsgViewSortType.byAttachments ||
-                 sortType == nsMsgViewSortType.byAuthor ||
-                 sortType == nsMsgViewSortType.byCorrespondent ||
-                 sortType == nsMsgViewSortType.byDate ||
-                 sortType == nsMsgViewSortType.byFlagged ||
-                 sortType == nsMsgViewSortType.byLocation ||
-                 sortType == nsMsgViewSortType.byPriority ||
-                 sortType == nsMsgViewSortType.byReceived ||
-                 sortType == nsMsgViewSortType.byRecipient ||
-                 sortType == nsMsgViewSortType.byStatus ||
-                 sortType == nsMsgViewSortType.bySubject ||
-                 sortType == nsMsgViewSortType.byTags ||
-                 sortType == nsMsgViewSortType.byCustom);
+  return Boolean(sortType == Ci.nsMsgViewSortType.byAccount ||
+                 sortType == Ci.nsMsgViewSortType.byAttachments ||
+                 sortType == Ci.nsMsgViewSortType.byAuthor ||
+                 sortType == Ci.nsMsgViewSortType.byCorrespondent ||
+                 sortType == Ci.nsMsgViewSortType.byDate ||
+                 sortType == Ci.nsMsgViewSortType.byFlagged ||
+                 sortType == Ci.nsMsgViewSortType.byLocation ||
+                 sortType == Ci.nsMsgViewSortType.byPriority ||
+                 sortType == Ci.nsMsgViewSortType.byReceived ||
+                 sortType == Ci.nsMsgViewSortType.byRecipient ||
+                 sortType == Ci.nsMsgViewSortType.byStatus ||
+                 sortType == Ci.nsMsgViewSortType.bySubject ||
+                 sortType == Ci.nsMsgViewSortType.byTags ||
+                 sortType == Ci.nsMsgViewSortType.byCustom);
 }
 
 function InitViewMessagesMenu() {
   document.getElementById("viewAllMessagesMenuItem").setAttribute("checked",
     !gFolderDisplay.view.showUnreadOnly &&
     !gFolderDisplay.view.specialView);
 
   document.getElementById("viewUnreadMessagesMenuItem").setAttribute("checked",
@@ -1467,46 +1479,46 @@ function MsgGetNextNMessages() {
 function MsgDeleteMessage(reallyDelete, fromToolbar) {
   // If from the toolbar, return right away if this is a news message
   // only allow cancel from the menu:  "Edit | Cancel / Delete Message".
   if (fromToolbar && gFolderDisplay.view.isNewsFolder)
     return;
 
   gFolderDisplay.hintAboutToDeleteMessages();
   if (reallyDelete)
-    gDBView.doCommand(nsMsgViewCommandType.deleteNoTrash);
+    gDBView.doCommand(Ci.nsMsgViewCommandType.deleteNoTrash);
   else
-    gDBView.doCommand(nsMsgViewCommandType.deleteMsg);
+    gDBView.doCommand(Ci.nsMsgViewCommandType.deleteMsg);
 }
 
 /**
  * Copies the selected messages to the destination folder
  * @param aDestFolder  the destination folder
  */
 function MsgCopyMessage(aDestFolder) {
   if (gMessageDisplay.isDummy) {
     let file = window.arguments[0].QueryInterface(Ci.nsIFileURL).file;
     MailServices.copy.CopyFileMessage(file, aDestFolder, null, false,
                                       Ci.nsMsgMessageFlags.Read,
                                       "", null, msgWindow);
   } else {
-    gDBView.doCommandWithFolder(nsMsgViewCommandType.copyMessages, aDestFolder);
+    gDBView.doCommandWithFolder(Ci.nsMsgViewCommandType.copyMessages, aDestFolder);
   }
 
   Services.prefs.setCharPref("mail.last_msg_movecopy_target_uri", aDestFolder.URI);
   Services.prefs.setBoolPref("mail.last_msg_movecopy_was_move", false);
 }
 
 /**
  * Moves the selected messages to the destination folder
  * @param aDestFolder  the destination folder
  */
 function MsgMoveMessage(aDestFolder) {
   gFolderDisplay.hintAboutToDeleteMessages();
-  gDBView.doCommandWithFolder(nsMsgViewCommandType.moveMessages, aDestFolder);
+  gDBView.doCommandWithFolder(Ci.nsMsgViewCommandType.moveMessages, aDestFolder);
   Services.prefs.setCharPref("mail.last_msg_movecopy_target_uri", aDestFolder.URI);
   Services.prefs.setBoolPref("mail.last_msg_movecopy_was_move", true);
 }
 
 /**
  * Calls the ComposeMessage function with the desired type, and proper default
  * based on the event that fired it.
  *
@@ -2185,17 +2197,17 @@ function UpdateJunkButton() {
   // The junk message should slave off the selected message, as the preview pane
   //  may not be visible
   let hdr = gFolderDisplay.selectedMessage;
   // But only the message display knows if we are dealing with a dummy.
   if (!hdr || gMessageDisplay.isDummy) // .eml file
     return;
   let junkScore = hdr.getStringProperty("junkscore");
   let hideJunk = (junkScore == Ci.nsIJunkMailPlugin.IS_SPAM_SCORE);
-  if (!gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk))
+  if (!gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.junk))
     hideJunk = true;
   if (document.getElementById("hdrJunkButton")) {
     document.getElementById("hdrJunkButton").disabled = hideJunk;
   }
 }
 
 /**
  * Checks if the selected messages can be marked as read or unread
--- a/mail/base/content/messageDisplay.js
+++ b/mail/base/content/messageDisplay.js
@@ -1,12 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from mailWindow.js */
+/* import-globals-from selectionsummaries.js */
+
 /**
  * Base abstraction for message display along the line of FolderDisplayWidget,
  *  but for message display.  This really only exists to keep
  *  FolderDisplayWidget manageable and free from taking on responsibility for
  *  the (different) horrors of message display.  The reality of the situation
  *  is that FolderDisplayWidget still has a lot to do with message display,
  *  and so we are just where helper logic gets to live, but the FDW still
  *  may deal with some things internally.
--- a/mail/base/content/messageWindow.js
+++ b/mail/base/content/messageWindow.js
@@ -1,16 +1,34 @@
 /**
  * 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 is where functions related to the standalone message window are kept */
 
-ChromeUtils.import("resource:///modules/jsTreeSelection.js");
+/* import-globals-from ../../../../toolkit/components/printing/content/printUtils.js */
+/* import-globals-from ../../../../toolkit/content/viewZoomOverlay.js */
+/* import-globals-from ../../../mailnews/base/content/junkCommands.js */
+/* import-globals-from ../../../mailnews/base/prefs/content/accountUtils.js */
+/* import-globals-from commandglue.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mail-offline.js */
+/* import-globals-from mailCommands.js */
+/* import-globals-from mailCore.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from mailWindowOverlay.js */
+/* import-globals-from messageDisplay.js */
+/* import-globals-from msgHdrView.js */
+/* import-globals-from msgViewNavigation.js */
+/* import-globals-from nsDragAndDrop.js */
+/* import-globals-from phishingDetector.js */
+/* import-globals-from toolbarIconColor.js */
+
+var { JSTreeSelection } = ChromeUtils.import("resource:///modules/jsTreeSelection.js", null);
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource:///modules/MsgHdrSyntheticView.jsm");
 
 // from MailNewsTypes.h
 var nsMsgKey_None = 0xFFFFFFFF;
@@ -909,29 +927,29 @@ var MessageWindowController = {
         loadedFolder = gFolderDisplay.displayedFolder;
         if (!(loadedFolder && loadedFolder.server.canHaveFilters))
           return false;
       case "cmd_delete":
         UpdateDeleteCommand();
         // fall through
       case "button_delete":
         UpdateDeleteToolbarButton();
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.deleteMsg);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.deleteMsg);
       case "cmd_shiftDelete":
       case "button_shiftDelete":
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.deleteNoTrash);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.deleteNoTrash);
       case "button_junk":
         UpdateJunkToolbarButton();
         // fall through
       case "cmd_markAsJunk":
       case "cmd_markAsNotJunk":
-        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk);
+        return gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.junk);
       case "cmd_recalculateJunkScore":
         return gFolderDisplay.selectedMessage &&
-               gFolderDisplay.getCommandStatus(nsMsgViewCommandType.runJunkControls);
+               gFolderDisplay.getCommandStatus(Ci.nsMsgViewCommandType.runJunkControls);
       case "cmd_archive":
       case "button_archive":
         return gFolderDisplay.canArchiveSelectedMessages;
       case "cmd_reply":
       case "button_reply":
       case "cmd_replyall":
       case "button_replyall":
         return gFolderDisplay.selectedMessage && IsReplyEnabled();
@@ -1023,17 +1041,17 @@ var MessageWindowController = {
       case "cmd_fullZoomToggle":
         return true;
       case "button_goForward":
       case "button_goBack":
       case "cmd_goForward":
       case "cmd_goBack":
         return gFolderDisplay.navigateStatus(
           (command == "cmd_goBack" || command == "button_goBack") ?
-            nsMsgNavigationType.back : nsMsgNavigationType.forward);
+            Ci.nsMsgNavigationType.back : Ci.nsMsgNavigationType.forward);
       case "cmd_search":
         loadedFolder = gFolderDisplay.displayedFolder;
         if (!loadedFolder)
           return false;
         return loadedFolder.server.canSearchMessages;
       case "cmd_undo":
       case "cmd_redo":
         return SetupUndoRedoCommand(command);
@@ -1133,22 +1151,22 @@ var MessageWindowController = {
         break;
       case "cmd_createFilterFromPopup":
         break;// This does nothing because the createfilter is invoked from the popupnode oncommand.
       case "cmd_createFilterFromMenu":
         MsgCreateFilter();
         break;
       case "button_delete":
       case "cmd_delete":
-        gFolderDisplay.doCommand(nsMsgViewCommandType.deleteMsg);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.deleteMsg);
         UpdateDeleteToolbarButton();
         break;
       case "button_shiftDelete":
       case "cmd_shiftDelete":
-        gFolderDisplay.doCommand(nsMsgViewCommandType.deleteNoTrash);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.deleteNoTrash);
         UpdateDeleteToolbarButton();
         break;
       case "button_junk":
         MsgJunk();
         break;
       case "cmd_printSetup":
         PrintUtils.showPageSetup();
         break;
@@ -1212,17 +1230,17 @@ var MessageWindowController = {
       case "cmd_markAsRead":
         MsgMarkMsgAsRead(true);
         return;
       case "cmd_markAsUnread":
         MsgMarkMsgAsRead(false);
         return;
       case "cmd_markThreadAsRead":
         ClearPendingReadTimer();
-        gFolderDisplay.doCommand(nsMsgViewCommandType.markThreadRead);
+        gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.markThreadRead);
         return;
       case "cmd_markAllRead":
         MsgMarkAllRead();  // Won't run since always disabled.
         return;
       case "cmd_markReadByDate":
         MsgMarkReadByDate();
         return;
       case "cmd_viewAllHeader":
@@ -1240,58 +1258,58 @@ var MessageWindowController = {
       case "cmd_markAsNotJunk":
         JunkSelectedMessages(false);
         return;
       case "cmd_recalculateJunkScore":
         analyzeMessagesForJunk();
         return;
       case "cmd_downloadFlagged":
         gFolderDisplay.doCommand(
-          nsMsgViewCommandType.downloadFlaggedForOffline);
+          Ci.nsMsgViewCommandType.downloadFlaggedForOffline);
         return;
       case "cmd_downloadSelected":
         gFolderDisplay.doCommand(
-          nsMsgViewCommandType.downloadSelectedForOffline);
+          Ci.nsMsgViewCommandType.downloadSelectedForOffline);
         return;
       case "cmd_synchronizeOffline":
         MsgSynchronizeOffline();
         return;
       case "cmd_settingsOffline":
         MailOfflineMgr.openOfflineAccountSettings();
         return;
       case "button_next":
       case "cmd_nextUnreadMsg":
-        performNavigation(nsMsgNavigationType.nextUnreadMessage);
+        performNavigation(Ci.nsMsgNavigationType.nextUnreadMessage);
         break;
       case "cmd_nextUnreadThread":
-        performNavigation(nsMsgNavigationType.nextUnreadThread);
+        performNavigation(Ci.nsMsgNavigationType.nextUnreadThread);
         break;
       case "button_nextMsg":
       case "cmd_nextMsg":
-        performNavigation(nsMsgNavigationType.nextMessage);
+        performNavigation(Ci.nsMsgNavigationType.nextMessage);
         break;
       case "cmd_nextFlaggedMsg":
-        performNavigation(nsMsgNavigationType.nextFlagged);
+        performNavigation(Ci.nsMsgNavigationType.nextFlagged);
         break;
       case "button_previousMsg":
       case "cmd_previousMsg":
-        performNavigation(nsMsgNavigationType.previousMessage);
+        performNavigation(Ci.nsMsgNavigationType.previousMessage);
         break;
       case "button_previous":
       case "cmd_previousUnreadMsg":
-        performNavigation(nsMsgNavigationType.previousUnreadMessage);
+        performNavigation(Ci.nsMsgNavigationType.previousUnreadMessage);
         break;
       case "cmd_previousFlaggedMsg":
-        performNavigation(nsMsgNavigationType.previousFlagged);
+        performNavigation(Ci.nsMsgNavigationType.previousFlagged);
         break;
       case "cmd_goForward":
-        performNavigation(nsMsgNavigationType.forward);
+        performNavigation(Ci.nsMsgNavigationType.forward);
         break;
       case "cmd_goBack":
-        performNavigation(nsMsgNavigationType.back);
+        performNavigation(Ci.nsMsgNavigationType.back);
         break;
       case "cmd_applyFiltersToSelection":
         MsgApplyFiltersToSelection();
         break;
       case "cmd_fullZoomReduce":
         ZoomManager.reduce();
         break;
       case "cmd_fullZoomEnlarge":
--- a/mail/base/content/msgHdrView.js
+++ b/mail/base/content/msgHdrView.js
@@ -2,21 +2,27 @@
  * 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/. */
 
 /**
  * Functions related to displaying the headers for a selected message in the
  * message pane.
  */
 
+/* import-globals-from editContactPanel.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from messageDisplay.js */
+/* import-globals-from nsDragAndDrop.js */
+
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource:///modules/DisplayNameUtils.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource:///modules/gloda/utils.js");
+var { GlodaUtils } = ChromeUtils.import("resource:///modules/gloda/utils.js", null);
 var {
   Status: statusUtils,
 } = ChromeUtils.import("resource:///modules/imStatusUtils.jsm", null);
 
 // Warning: It's critical that the code in here for displaying the message
 // headers for a selected message remain as fast as possible. In particular,
 // right now, we only introduce one reflow per message. i.e. if you click on
 // a message in the thread pane, we batch up all the changes for displaying
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -1,16 +1,34 @@
 /**
  * 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/. */
 
+/* import-globals-from ../../../../toolkit/modules/PageMenu.jsm */
+/* import-globals-from ../../../mailnews/base/prefs/content/accountUtils.js */
+/* import-globals-from ../../../mailnews/base/util/mailnewsMigrator.js */
+/* import-globals-from ../../components/newmailaccount/content/accountProvisionerTab.js */
+/* import-globals-from ../../components/preferences/preferencesTab.js */
+/* import-globals-from commandglue.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from folderPane.js */
+/* import-globals-from glodaFacetTab.js */
+/* import-globals-from mail-compacttheme.js */
+/* import-globals-from mailTabs.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from plugins.js */
+/* import-globals-from quickFilterBar.js */
+/* import-globals-from searchBar.js */
+/* import-globals-from searchBar.js */
+/* import-globals-from specialTabs.js */
+/* import-globals-from toolbarIconColor.js */
+
 ChromeUtils.import("resource:///modules/activity/activityModules.jsm");
 var { logException } = ChromeUtils.import("resource:///modules/errUtils.js", null);
-ChromeUtils.import("resource:///modules/folderUtils.jsm");
 ChromeUtils.import("resource:///modules/IOUtils.js");
 var { JSTreeSelection } = ChromeUtils.import("resource:///modules/jsTreeSelection.js", null);
 ChromeUtils.import("resource:///modules/MailConsts.jsm");
 ChromeUtils.import("resource:///modules/MailInstrumentation.jsm");
 ChromeUtils.import("resource:///modules/mailnewsMigrator.js");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
 ChromeUtils.import("resource:///modules/msgDBCacheManager.js");
 ChromeUtils.import("resource:///modules/SessionStoreManager.jsm");
@@ -895,17 +913,19 @@ function loadStartFolder(initialUri) {
             if (gFolderTreeView._rowMap.length)
               gFolderTreeView.selectFolder(gFolderTreeView._rowMap[0]._folder);
           }
         }
     } catch (ex) {
       // this is the case where we're trying to auto-subscribe to a folder.
       if (initialUri && !startFolder.parent) {
         // hack to force display of thread pane.
-        ShowingThreadPane();
+        if (IsMessagePaneCollapsed) {
+          MsgToggleMessagePane();
+        }
         messenger.loadURL(window, initialUri);
         return;
       }
 
       Cu.reportError(ex);
     }
 
     MsgGetMessagesForAllServers(defaultServer);
@@ -1447,17 +1467,17 @@ function ThreadPaneOnDrop(aEvent) {
 
 var LightWeightThemeWebInstaller = {
   handleEvent(event) {
     switch (event.type) {
       case "InstallBrowserTheme":
       case "PreviewBrowserTheme":
       case "ResetBrowserThemePreview":
         // ignore requests from background tabs
-        if (event.target.ownerGlobal.top != content)
+        if (event.target.ownerGlobal.top != window.content)
           return;
     }
     switch (event.type) {
       case "InstallBrowserTheme":
         this._installRequest(event);
         break;
       case "PreviewBrowserTheme":
         this._preview(event);
--- a/mail/base/content/msgViewNavigation.js
+++ b/mail/base/content/msgViewNavigation.js
@@ -1,16 +1,21 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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 file contains the js functions necessary to implement view navigation within the 3 pane. */
 
-ChromeUtils.import("resource:///modules/folderUtils.jsm");
+/* import-globals-from commandglue.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from messageDisplay.js */
+
+var { allAccountsSorted } = ChromeUtils.import("resource:///modules/folderUtils.jsm", null);
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function GetSubFoldersInFolderPaneOrder(folder) {
   var subFolders = folder.subFolders;
   var msgFolders = [];
 
   // get all the subfolders
   while (subFolders.hasMoreElements()) {
@@ -119,24 +124,24 @@ function GetRootFoldersInFolderPaneOrder
   for (let account of accounts)
     serversMsgFolders.push(account.incomingServer.rootMsgFolder);
 
   return serversMsgFolders;
 }
 
 function CrossFolderNavigation(type) {
   // do cross folder navigation for next unread message/thread and message history
-  if (type != nsMsgNavigationType.nextUnreadMessage &&
-      type != nsMsgNavigationType.nextUnreadThread &&
-      type != nsMsgNavigationType.forward &&
-      type != nsMsgNavigationType.back)
+  if (type != Ci.nsMsgNavigationType.nextUnreadMessage &&
+      type != Ci.nsMsgNavigationType.nextUnreadThread &&
+      type != Ci.nsMsgNavigationType.forward &&
+      type != Ci.nsMsgNavigationType.back)
     return;
 
-  if (type == nsMsgNavigationType.nextUnreadMessage ||
-      type == nsMsgNavigationType.nextUnreadThread) {
+  if (type == Ci.nsMsgNavigationType.nextUnreadMessage ||
+      type == Ci.nsMsgNavigationType.nextUnreadThread) {
     var nextMode = Services.prefs.getIntPref("mailnews.nav_crosses_folders");
     // 0: "next" goes to the next folder, without prompting
     // 1: "next" goes to the next folder, and prompts (the default)
     // 2: "next" does nothing when there are no unread messages
 
     // not crossing folders, don't find next
     if (nextMode == 2)
       return;
@@ -154,24 +159,22 @@ function CrossFolderNavigation(type) {
       }
       gFolderDisplay.pushNavigation(type, true);
       SelectFolder(folder.URI);
     }
   } else {
     // if no message is loaded, relPos should be 0, to
     // go back to the previously loaded message
     var relPos = 0;
-    if (type == nsMsgNavigationType.forward) {
+    if (type == Ci.nsMsgNavigationType.forward) {
       relPos = 1;
     } else if (gMessageDisplay.displayedMessage) {
       relPos = -1;
     }
     var folderUri = messenger.getFolderUriAtNavigatePos(relPos);
-    var msgHdr = messenger.msgHdrFromURI(messenger.getMsgUriAtNavigatePos(relPos));
-    gStartMsgKey = msgHdr.messageKey;
     var curPos = messenger.navigatePos;
     curPos += relPos;
     messenger.navigatePos = curPos;
     SelectFolder(folderUri);
   }
 }
 
 function GoNextMessage(type, startFromBeginning) {
--- a/mail/base/content/multimessageview.js
+++ b/mail/base/content/multimessageview.js
@@ -1,19 +1,24 @@
 /* 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/. */
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource:///modules/gloda/gloda.js");
-ChromeUtils.import("resource:///modules/gloda/connotent.js");
-ChromeUtils.import("resource:///modules/gloda/mimemsg.js");
+var { Gloda } = ChromeUtils.import("resource:///modules/gloda/gloda.js", null);
+var {
+  mimeMsgToContentSnippetAndMeta,
+} = ChromeUtils.import("resource:///modules/gloda/connotent.js", null);
+var { MsgHdrToMimeMessage } = ChromeUtils.import("resource:///modules/gloda/mimemsg.js", null);
 ChromeUtils.import("resource:///modules/DisplayNameUtils.jsm");
 ChromeUtils.import("resource:///modules/MailServices.jsm");
-ChromeUtils.import("resource:///modules/templateUtils.js");
+var {
+  PluralStringFormatter,
+  makeFriendlyDateAgo,
+} = ChromeUtils.import("resource:///modules/templateUtils.js", null);
 
 var gMessenger = Cc["@mozilla.org/messenger;1"]
                    .createInstance(Ci.nsIMessenger);
 
 // Set up our string formatter for localizing strings.
 XPCOMUtils.defineLazyGetter(this, "formatString", function() {
   let formatter = new PluralStringFormatter(
     "chrome://messenger/locale/multimessageview.properties"
--- a/mail/base/content/nsContextMenu.js
+++ b/mail/base/content/nsContextMenu.js
@@ -1,13 +1,18 @@
 /**
  * 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/. */
 
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailTabs.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from messageDisplay.js */
+
 ChromeUtils.import("resource://gre/modules/InlineSpellChecker.jsm");
 ChromeUtils.import("resource://gre/modules/PlacesUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "PageMenuParent", function() {
@@ -826,17 +831,17 @@ nsContextMenu.prototype = {
     if (!text || (text.trim() == "")) {
       text = this.link.getAttribute("title");
       if (!text || (text.trim() == "")) {
         text = this.link.getAttribute("alt");
         if (!text || (text.trim() == "")) {
           if (this.link.href) {
             text = this.link.href;
           } else {
-            text = getAttributeNS("http://www.w3.org/1999/xlink", "href");
+            text = this.link.getAttributeNS("http://www.w3.org/1999/xlink", "href");
             if (text && !(text.trim() == "")) {
               text = this.makeURLAbsolute(this.link.baseURI, text);
             }
           }
         }
       }
     }
 
--- a/mail/base/content/nsDragAndDrop.js
+++ b/mail/base/content/nsDragAndDrop.js
@@ -8,16 +8,18 @@
 // Do not use this file for new code.
 //
 // Toolkit dropped nsDragAndDrop.js in bug 1162050.
 // Mapped to content/global/nsDragAndDrop.js until we can remove this usage.
 //
 // For documentation about what to use instead, see:
 //   http://developer.mozilla.org/En/DragDrop/Drag_and_Drop
 
+ChromeUtils.defineModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
+
 /**
  *  nsTransferable - a wrapper for nsITransferable that simplifies
  *                   javascript clipboard and drag&drop. for use in
  *                   these situations you should use the nsClipboard
  *                   and nsDragAndDrop wrappers for more convenience
  **/
 
 var nsTransferable = {
--- a/mail/base/content/phishingDetector.js
+++ b/mail/base/content/phishingDetector.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
-// Dependencies:
-// gatherTextUnder from utilityOverlay.js
+/* import-globals-from mailWindowOverlay.js */
+/* import-globals-from utilityOverlay.js */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var kPhishingNotSuspicious = 0;
 var kPhishingWithIPAddress = 1;
 var kPhishingWithMismatchedHosts = 2;
 
 
--- a/mail/base/content/plugins.js
+++ b/mail/base/content/plugins.js
@@ -1,12 +1,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 file is scheduled to be demolished to make way for a new hyperspace bypass.
+// See bug 1508942.
+/* eslint-disable */
+
 "use strict";
 
 /* A note to the curious: a large portion of this code was copied over from
  * mozilla/browser/base/content/browser.js
  */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
--- a/mail/base/content/quickFilterBar.js
+++ b/mail/base/content/quickFilterBar.js
@@ -1,14 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
-ChromeUtils.import("resource:///modules/errUtils.js");
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+
+var {
+  logException,
+  errorWithDebug,
+} = ChromeUtils.import("resource:///modules/errUtils.js", null);
 var {
   MessageTextFilter,
   QuickFilterManager,
   QuickFilterSearchListener,
   QuickFilterState,
 } = ChromeUtils.import("resource:///modules/QuickFilterManager.jsm", null);
 ChromeUtils.import("resource:///modules/SearchSpec.jsm");
 
--- a/mail/base/content/sanitizeDialog.js
+++ b/mail/base/content/sanitizeDialog.js
@@ -1,13 +1,15 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+/* import-globals-from sanitize.js */
+
 var gSanitizePromptDialog = {
 
   get bundleBrowser() {
     if (!this._bundleBrowser)
       this._bundleBrowser = document.getElementById("bundleBrowser");
     return this._bundleBrowser;
   },
 
--- a/mail/base/content/search.xml
+++ b/mail/base/content/search.xml
@@ -1,14 +1,16 @@
 <?xml version="1.0"?>
-
 <!-- 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/. -->
 
+<!-- import-globals-from mailWindow.js -->
+<!-- import-globals-from nsDragAndDrop.js -->
+
 <!DOCTYPE bindings [
 <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd">
 %messengerDTD;
 ]>
 
 <bindings id="SearchBindings"
    xmlns="http://www.mozilla.org/xbl"
    xmlns:html="http://www.w3.org/1999/xhtml"
@@ -46,17 +48,16 @@
         this.clearSearch();
         event.preventDefault();
         event.stopPropagation();
       ]]></handler>
     </handlers>
 
     <implementation implements="nsIObserver">
       <constructor><![CDATA[
-        ChromeUtils.import("resource:///modules/errUtils.js");
         ChromeUtils.import("resource://gre/modules/Services.jsm");
         ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
         try {
           this.setAttribute(
             "placeholder",
             this.getAttribute("emptytextbase")
                 .replace("#1", this.getAttribute(
@@ -75,16 +76,17 @@
           this.glodaEnabled =
             Services.prefs.getBoolPref("mailnews.database.global.indexer.enabled");
           this.collapsed = !this.glodaEnabled;
 
           // make sure we set our emptytext here from the get-go
         if (this.hasAttribute("placeholder"))
           this.placeholder = this.getAttribute("placeholder");
         } catch (e) {
+          let { logException } = ChromeUtils.import("resource:///modules/errUtils.js", null);
           logException(e, true);
         }
       ]]></constructor>
 
       <destructor>
         <![CDATA[
           ChromeUtils.import("resource://gre/modules/Services.jsm");
 
@@ -142,16 +144,17 @@
             if (aXferData.data) {
               this.inputSearch.focus();
               this.inputSearch.value = aXferData.data;
               // XXX for some reason the input field is _cleared_ even though
               // the search works.
               this.inputSearch.doSearch();
             }
           } catch (e) {
+            let { logException } = ChromeUtils.import("resource:///modules/errUtils.js", null);
             logException(e);
           }
         },
 
         getSupportedFlavours() {
           var flavourSet = new FlavourSet();
           flavourSet.appendFlavour("text/unicode");
           return flavourSet;
@@ -194,16 +197,17 @@
               }
               theQuery.orderBy("-date");
               document.getElementById("tabmail").openTab("glodaFacet", {
                 query: theQuery,
               });
             }
           }
         } catch (e) {
+          let { logException } = ChromeUtils.import("resource:///modules/errUtils.js", null);
           logException(e);
         }
         ]]></body>
       </method>
 
       <method name="doSearch">
         <body><![CDATA[
           ChromeUtils.import("resource://gre/modules/Services.jsm");
@@ -224,23 +228,25 @@
                 // this tab and starting over
                 tabmail.closeTab();
               }
               this.value = ""; // clear our value, to avoid persistence
               let args = {
                 searcher: new GlodaMsgSearcher(null, searchString),
               };
               if (Services.prefs.getBoolPref("mail.chat.enabled")) {
-                if (!("GlodaIMSearcher" in window))
-                  ChromeUtils.import("resource:///modules/search_im.jsm");
+                let {
+                  GlodaIMSearcher,
+                } = ChromeUtils.import("resource:///modules/search_im.jsm", null);
                 args.IMSearcher = new GlodaIMSearcher(null, searchString);
               }
               tabmail.openTab("glodaFacet", args);
             }
           } catch (e) {
+            let { logException } = ChromeUtils.import("resource:///modules/errUtils.js", null);
             logException(e);
           }
         ]]>
         </body>
       </method>
       <method name="clearSearch">
         <body><![CDATA[
           this.value = "";
--- a/mail/base/content/selectionsummaries.js
+++ b/mail/base/content/selectionsummaries.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+/* import-globals-from commandglue.js */
+
 /**
  * Summarize a set of selected messages.  This can either be a single thread or
  * multiple threads.
  *
  * @param aMessageDisplay The MessageDisplayWidget object responsible for
  *                         showing messages.
  */
 function summarizeSelection(aMessageDisplay) {
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -1,12 +1,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/. */
 
+/* import-globals-from ../../../../toolkit/components/printing/content/printUtils.js */
+/* import-globals-from mailWindow.js */
+/* import-globals-from plugins.js */
+
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 ChromeUtils.import("resource:///modules/StringBundle.js");
 ChromeUtils.import("resource://gre/modules/BrowserUtils.jsm");
 ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 ChromeUtils.import("resource://gre/modules/ExtensionParent.jsm");
 
--- a/mail/base/content/tabmail.xml
+++ b/mail/base/content/tabmail.xml
@@ -1,13 +1,16 @@
 <?xml version="1.0"?>
 <!-- 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/. -->
 
+<!-- import-globals-from commandglue.js -->
+<!-- import-globals-from mailWindow.js -->
+
 <!DOCTYPE bindings [
 <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
 %messengerDTD;
 <!ENTITY % tabMailDTD SYSTEM "chrome://messenger/locale/tabmail.dtd" >
  %tabMailDTD;
 ]>
 
 <bindings id="tabmailBindings"
@@ -2331,17 +2334,17 @@
 
         dt.mozCursor = "default";
 
         // Create Drag Image
         let panel = document.getElementById("tabpanelcontainer");
 
         let thumbnail = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
         thumbnail.width = Math.ceil(screen.availWidth / 5.75);
-        thumbnail.height = Math.round(width * 0.5625);
+        thumbnail.height = Math.round(thumbnail.width * 0.5625);
 
         let snippetWidth = panel.boxObject.width * .6;
         let scale = thumbnail.width / snippetWidth;
 
         let ctx = thumbnail.getContext("2d");
 
         ctx.scale(scale, scale);
 
--- a/mail/base/content/threadPane.js
+++ b/mail/base/content/threadPane.js
@@ -1,13 +1,17 @@
 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * 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/. */
 
+/* import-globals-from commandglue.js */
+/* import-globals-from folderDisplay.js */
+/* import-globals-from mailWindow.js */
+
 var gLastMessageUriToLoad = null;
 var gThreadPaneCommandUpdater = null;
 
 function ThreadPaneOnClick(event) {
   // We only care about button 0 (left click) events.
   if (event.button != 0) {
     event.stopPropagation();
     return;
@@ -112,18 +116,18 @@ function HandleColumnClick(columnID) {
   }
 
   if (!simpleColumns && viewWrapper.showThreaded) {
     viewWrapper.showUnthreaded = true;
     MsgSortThreadPane(sortType);
     return;
   }
 
-  if (viewWrapper.primarySortType == nsMsgViewSortType[sortType] &&
-      (viewWrapper.primarySortType != nsMsgViewSortType.byCustom ||
+  if (viewWrapper.primarySortType == Ci.nsMsgViewSortType[sortType] &&
+      (viewWrapper.primarySortType != Ci.nsMsgViewSortType.byCustom ||
        curCustomColumn == columnID)) {
     MsgReverseSortThreadPane();
   } else {
     MsgSortThreadPane(sortType);
   }
 }
 
 function ThreadPaneDoubleClick() {
@@ -159,23 +163,23 @@ function ThreadPaneKeyDown(event) {
 }
 
 function MsgSortByThread() {
   gFolderDisplay.view.showThreaded = true;
   MsgSortThreadPane("byDate");
 }
 
 function MsgSortThreadPane(sortName) {
-  let sortType = nsMsgViewSortType[sortName];
+  let sortType = Ci.nsMsgViewSortType[sortName];
   let grouped = gFolderDisplay.view.showGroupedBySort;
   gFolderDisplay.view._threadExpandAll =
-    Boolean(gFolderDisplay.view._viewFlags & nsMsgViewFlagsType.kExpandAll);
+    Boolean(gFolderDisplay.view._viewFlags & Ci.nsMsgViewFlagsType.kExpandAll);
 
   if (!grouped) {
-    gFolderDisplay.view.sort(sortType, nsMsgViewSortOrder.ascending);
+    gFolderDisplay.view.sort(sortType, Ci.nsMsgViewSortOrder.ascending);
     // Respect user's last expandAll/collapseAll choice, post sort direction change.
     gFolderDisplay.restoreThreadState();
     return;
   }
 
   // legacy behavior dictates we un-group-by-sort if we were.  this probably
   //  deserves a UX call...
 
@@ -184,43 +188,43 @@ function MsgSortThreadPane(sortName) {
   // For virtual folders, which are rebuilt in the backend in a grouped
   // change, create a new view upfront rather than applying viewFlags. There
   // are oddities just applying viewFlags, for example changing out of a
   // custom column grouped xfvf view with the threads collapsed works (doesn't)
   // differently than other variations.
   // So, first set the desired sortType and sortOrder, then set viewFlags in
   // batch mode, then apply it all (open a new view) with endViewUpdate().
   gFolderDisplay.view.beginViewUpdate();
-  gFolderDisplay.view._sort = [[sortType, nsMsgViewSortOrder.ascending]];
+  gFolderDisplay.view._sort = [[sortType, Ci.nsMsgViewSortOrder.ascending]];
   gFolderDisplay.view.showGroupedBySort = false;
   gFolderDisplay.view.endViewUpdate();
 
   // Virtual folders don't persist viewFlags well in the back end,
   // due to a virtual folder being either 'real' or synthetic, so make
   // sure it's done here.
   if (gFolderDisplay.view.isVirtual)
     gFolderDisplay.view.dbView.viewFlags = gFolderDisplay.view.viewFlags;
 }
 
 function MsgReverseSortThreadPane() {
   let grouped = gFolderDisplay.view.showGroupedBySort;
   gFolderDisplay.view._threadExpandAll =
-    Boolean(gFolderDisplay.view._viewFlags & nsMsgViewFlagsType.kExpandAll);
+    Boolean(gFolderDisplay.view._viewFlags & Ci.nsMsgViewFlagsType.kExpandAll);
 
   // Grouped By view is special for column click sort direction changes.
   if (grouped) {
     if (gDBView.selection.count)
       gFolderDisplay._saveSelection();
 
     if (gFolderDisplay.view.isSingleFolder) {
       if (gFolderDisplay.view.isVirtual)
         gFolderDisplay.view.showGroupedBySort = false;
       else
        // Must ensure rows are collapsed and kExpandAll is unset.
-       gFolderDisplay.doCommand(nsMsgViewCommandType.collapseAll);
+       gFolderDisplay.doCommand(Ci.nsMsgViewCommandType.collapseAll);
     }
   }
 
   if (gFolderDisplay.view.isSortedAscending)
     gFolderDisplay.view.sortDescending();
   else
     gFolderDisplay.view.sortAscending();
 
@@ -309,17 +313,17 @@ function UpdateSortIndicators(sortType, 
 
   // If threading, set the sort direction on the thread column which causes it
   //  to be able to 'light up' or otherwise indicate threading is active.
   if (viewWrapper.showThreaded)
     threadCol.setAttribute("sortDirection", "ascending");
 
   if (sortedColumn)
     sortedColumn.setAttribute("sortDirection",
-                              sortOrder == nsMsgViewSortOrder.ascending ?
+                              sortOrder == Ci.nsMsgViewSortOrder.ascending ?
                                 "ascending" : "descending");
 }
 
 function IsSpecialFolderSelected(flags, checkAncestors) {
   let folder = GetThreadPaneFolder();
   return folder && folder.isSpecialFolder(flags, checkAncestors);
 }
 
--- a/mail/base/content/threadPaneColumnPicker.xml
+++ b/mail/base/content/threadPaneColumnPicker.xml
@@ -1,14 +1,16 @@
 <?xml version="1.0"?>
-
 <!-- 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/. -->
 
+<!-- import-globals-from folderDisplay.js -->
+<!-- import-globals-from mailWindow.js -->
+
 <!DOCTYPE window [
 <!ENTITY % messengerDTD SYSTEM "chrome://messenger/locale/messenger.dtd" >
 %messengerDTD;
 ]>
 
 <bindings id="threadPaneColumnPickerBindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
--- a/mail/base/content/toolbarIconColor.js
+++ b/mail/base/content/toolbarIconColor.js
@@ -1,13 +1,15 @@
 /**
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+/* import-globals-from mailWindow.js */
+
 var ToolbarIconColor = {
   init() {
     this._initialized = true;
 
     window.addEventListener("activate", this);
     window.addEventListener("deactivate", this);
     Services.obs.addObserver(this, "lightweight-theme-styling-update");
 
--- a/mail/base/content/utilityOverlay.js
+++ b/mail/base/content/utilityOverlay.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+/* import-globals-from mailWindow.js */
+
 ChromeUtils.import("resource://gre/modules/PlacesUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gShowBiDi = false;
 
 function getBrowserURL() {
   return AppConstants.BROWSER_CHROME_URL;
 }