Bug 1243760 - Replace nsPIDOMWindow with nsPIDOMWindowInner/Outer in C-C due to bug 1241764. r=mkmelin CLOSED TREE
authorPhilip Chee
Thu, 04 Feb 2016 11:39:46 +0100
changeset 18930 989a9aad4e24d78fa90fb219f7b2358d13dea06c
parent 18929 4f1b3e5af8efdae0712600fe10017f7355cd6eaa
child 18931 bb1364708cceef43055182c414b1c769dd2c631d
push id11608
push usermozilla@jorgk.com
push dateThu, 04 Feb 2016 10:41:29 +0000
treeherdercomm-central@989a9aad4e24 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1243760, 1241764
Bug 1243760 - Replace nsPIDOMWindow with nsPIDOMWindowInner/Outer in C-C due to bug 1241764. r=mkmelin CLOSED TREE
mail/components/migration/src/nsProfileMigrator.cpp
mailnews/addrbook/public/nsIAbManager.idl
mailnews/addrbook/src/nsAbContentHandler.cpp
mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
mailnews/addrbook/src/nsAbManager.cpp
mailnews/base/public/nsIMapiRegistry.idl
mailnews/base/public/nsIMessenger.idl
mailnews/base/public/nsIMsgPrintEngine.idl
mailnews/base/public/nsIMsgProgress.idl
mailnews/base/public/nsIMsgWindow.idl
mailnews/base/src/nsMessenger.cpp
mailnews/base/src/nsMessenger.h
mailnews/base/src/nsMessengerBootstrap.cpp
mailnews/base/src/nsMessengerContentHandler.cpp
mailnews/base/src/nsMessengerOSXIntegration.mm
mailnews/base/src/nsMessengerUnixIntegration.cpp
mailnews/base/src/nsMessengerWinIntegration.cpp
mailnews/base/src/nsMsgMailSession.cpp
mailnews/base/src/nsMsgPrintEngine.cpp
mailnews/base/src/nsMsgPrintEngine.h
mailnews/base/src/nsMsgProgress.cpp
mailnews/base/src/nsMsgWindow.cpp
mailnews/compose/public/nsIMsgCompose.idl
mailnews/compose/public/nsIMsgComposeService.idl
mailnews/compose/public/nsIMsgSend.idl
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgCompose.h
mailnews/compose/src/nsMsgComposeContentHandler.cpp
mailnews/compose/src/nsMsgComposeService.cpp
mailnews/compose/src/nsMsgComposeService.h
mailnews/compose/src/nsMsgSend.cpp
mailnews/compose/src/nsMsgSend.h
mailnews/local/src/nsPop3Sink.cpp
mailnews/mapi/mapihook/src/msgMapiHook.cpp
mailnews/news/src/nsNNTPNewsgroupList.cpp
mailnews/news/src/nsNntpService.cpp
--- a/mail/components/migration/src/nsProfileMigrator.cpp
+++ b/mail/components/migration/src/nsProfileMigrator.cpp
@@ -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/. */
 
 #include "nsIFile.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIProfileMigrator.h"
 #include "nsIPrefService.h"
 #include "nsIServiceManager.h"
 #include "nsIToolkitProfile.h"
 #include "nsIToolkitProfileService.h"
 #include "nsIWindowWatcher.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIMutableArray.h"
@@ -48,17 +48,17 @@ nsProfileMigrator::Migrate(nsIProfileSta
   nsCOMPtr<nsIWindowWatcher> ww (do_GetService(NS_WINDOWWATCHER_CONTRACTID));
   nsCOMPtr<nsIMutableArray> params (do_CreateInstance(NS_ARRAY_CONTRACTID));
   if (!ww || !params) return NS_ERROR_FAILURE;
 
   params->AppendElement(cstr, false);
   params->AppendElement(mailMigrator, false);
   params->AppendElement(aStartup, false);
 
-  nsCOMPtr<nsIDOMWindow> migrateWizard;
+  nsCOMPtr<mozIDOMWindowProxy> migrateWizard;
   return ww->OpenWindow(nullptr,
                         MIGRATION_WIZARD_FE_URL,
                         "_blank",
                         MIGRATION_WIZARD_FE_FEATURES,
                         params,
                         getter_AddRefs(migrateWizard));
 }
 
--- a/mailnews/addrbook/public/nsIAbManager.idl
+++ b/mailnews/addrbook/public/nsIAbManager.idl
@@ -1,32 +1,32 @@
 /* -*- Mode: IDL; 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/. */
 
 #include "nsISupports.idl"
 #include "nsIAbListener.idl"
 
-interface nsIDOMWindow;
+interface mozIDOMWindowProxy;
 interface nsIAbDirectory;
 interface nsIAbCard;
 interface nsIAbDirectoryProperties;
 interface nsIFile;
 interface nsISimpleEnumerator;
 interface nsIAbBooleanExpression;
 
 /**
  * nsIAbManager is an interface to the main address book mananger
  * via the contract id "@mozilla.org/abmanager;1"
  *
  * It contains the main functions to create and delete address books as well
  * as some helper functions.
  */
-[scriptable, uuid(4271daa0-de0b-48ed-9c2b-934dc895383d)]
+[scriptable, uuid(ea0d8b3d-a549-4874-82d8-3a82cee2a3f1)]
 interface nsIAbManager : nsISupports 
 {
   /**
    * Returns an enumerator containing all the top-level directories
    * (non-recursive)
    */
   readonly attribute nsISimpleEnumerator directories;
 
@@ -70,17 +70,17 @@ interface nsIAbManager : nsISupports
 
   /**
    * Exports an address book, it will provide a dialog to the user for the
    * location to save the file to and will then save the address book to media.
    *
    * @param  aParentWin Parent Window for the file save dialog to use.
    * @param  aDirectory The directory to export.
    */
-  void exportAddressBook(in nsIDOMWindow aParentWin, in nsIAbDirectory aDirectory);
+  void exportAddressBook(in mozIDOMWindowProxy aParentWin, in nsIAbDirectory aDirectory);
 
   /**
    * Adds a nsIAbListener to receive notifications of address book updates
    * according to the specified notifyFlags.
    *
    * @param  aListener      The listener that is to receive updates.
    * @param  aNotifyFlags   A bitwise-or of abListenerNotifyFlagValue items
    *                        specifying which notifications to receive. See
--- a/mailnews/addrbook/src/nsAbContentHandler.cpp
+++ b/mailnews/addrbook/src/nsAbContentHandler.cpp
@@ -7,17 +7,17 @@
 #include "nsAbBaseCID.h"
 #include "nsNetUtil.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsNullPrincipal.h"
 #include "nsISupportsPrimitives.h"
 #include "plstr.h"
 #include "nsPIDOMWindow.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsMsgUtils.h"
 #include "nsIMsgVCardService.h"
 #include "nsIAbCard.h"
 #include "nsIAbManager.h"
 #include "nsVCard.h"
 #include "nsIChannel.h"
 //
 // nsAbContentHandler
@@ -62,20 +62,19 @@ nsAbContentHandler::HandleContent(const 
             
             // XXX todo, explain why we is escaped twice
             MsgUnescapeString(nsDependentCString(startOfVCard + strlen("add?vcard=")), 
                                                  0, unescapedData);
 
             if (!aWindowContext)
                 return NS_ERROR_FAILURE;
 
-            nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(aWindowContext);
-            nsCOMPtr<nsPIDOMWindow> parentWindow = do_QueryInterface(domWindow);
-            if (!parentWindow)
-                return NS_ERROR_FAILURE;
+            nsCOMPtr<mozIDOMWindowProxy> domWindow = do_GetInterface(aWindowContext);
+            NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
+            nsCOMPtr<nsPIDOMWindowOuter> parentWindow = nsPIDOMWindowOuter::From(domWindow);
             parentWindow = parentWindow->GetOuterWindow();
             NS_ENSURE_ARG_POINTER(parentWindow);
 
             nsCOMPtr<nsIAbManager> ab =
               do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
             NS_ENSURE_SUCCESS(rv, rv);
 
             nsCOMPtr <nsIAbCard> cardFromVCard;
@@ -85,17 +84,17 @@ nsAbContentHandler::HandleContent(const 
 
             nsCOMPtr<nsISupportsInterfacePointer> ifptr =
                 do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
             NS_ENSURE_SUCCESS(rv, rv);
 
             ifptr->SetData(cardFromVCard);
             ifptr->SetDataIID(&NS_GET_IID(nsIAbCard));
 
-            nsCOMPtr<nsIDOMWindow> dialogWindow;
+            nsCOMPtr<nsPIDOMWindowOuter> dialogWindow;
 
             rv = parentWindow->OpenDialog(
                 NS_LITERAL_STRING("chrome://messenger/content/addressbook/abNewCardDialog.xul"),
                 EmptyString(),
                 NS_LITERAL_STRING("chrome,resizable=no,titlebar,modal,centerscreen"),
                 ifptr, getter_AddRefs(dialogWindow));
             NS_ENSURE_SUCCESS(rv, rv);
         }
@@ -161,23 +160,23 @@ nsAbContentHandler::OnStreamComplete(nsI
         do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsCOMPtr <nsIAbCard> cardFromVCard;
       rv = ab->EscapedVCardToAbCard(vCard.get(),
                                     getter_AddRefs(cardFromVCard));
       NS_ENSURE_SUCCESS(rv, rv);
 
-      nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(aContext);
-      nsCOMPtr<nsPIDOMWindow> parentWindow = do_QueryInterface(domWindow);
-      NS_ENSURE_TRUE(parentWindow, NS_ERROR_FAILURE);
+      nsCOMPtr<mozIDOMWindowProxy> domWindow = do_GetInterface(aContext);
+      NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
+      nsCOMPtr<nsPIDOMWindowOuter> parentWindow = nsPIDOMWindowOuter::From(domWindow);
       parentWindow = parentWindow->GetOuterWindow();
       NS_ENSURE_ARG_POINTER(parentWindow);
 
-      nsCOMPtr<nsIDOMWindow> dialogWindow;
+      nsCOMPtr<nsPIDOMWindowOuter> dialogWindow;
       rv = parentWindow->OpenDialog(
            NS_LITERAL_STRING("chrome://messenger/content/addressbook/abNewCardDialog.xul"),
            EmptyString(),
            NS_LITERAL_STRING("chrome,resizable=no,titlebar,modal,centerscreen"),
            cardFromVCard, getter_AddRefs(dialogWindow));
     }
   }
 
--- a/mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPListenerBase.cpp
@@ -1,17 +1,17 @@
 /* -*- 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/. */
 
 #include "nsAbLDAPListenerBase.h"
 #include "nsIWindowWatcher.h"
 #include "nsIWindowMediator.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIAuthPrompt.h"
 #include "nsIStringBundle.h"
 #include "nsILDAPMessage.h"
 #include "nsILDAPErrors.h"
 #include "nsILoginManager.h"
 #include "nsILoginInfo.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
@@ -156,19 +156,19 @@ NS_IMETHODIMP nsAbLDAPListenerBase::OnLD
                " couldn't get window mediator service.");
       InitFailed();
       return rv;
     }
 
     // get the addressbook window, as it will be used to parent the auth
     // prompter dialog
     //
-    nsCOMPtr<nsIDOMWindow> window;
+    nsCOMPtr<mozIDOMWindowProxy> window;
     rv = windowMediator->GetMostRecentWindow(nullptr,
-                                               getter_AddRefs(window));
+                                             getter_AddRefs(window));
     if (NS_FAILED(rv))
     {
       NS_ERROR("nsAbLDAPListenerBase::OnLDAPInit():"
                " error getting most recent window");
       InitFailed();
       return rv;
     }
 
--- a/mailnews/addrbook/src/nsAbManager.cpp
+++ b/mailnews/addrbook/src/nsAbManager.cpp
@@ -11,17 +11,17 @@
 #include "nsNetUtil.h"
 #include "nsMsgI18N.h"
 #include "nsIStringBundle.h"
 #include "nsMsgUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "plstr.h"
 #include "prmem.h"
 #include "nsIServiceManager.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIFilePicker.h"
 #include "plbase64.h"
 #include "nsIWindowWatcher.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsVCard.h"
 #include "nsVCardObj.h"
 #include "nsIAbLDAPAttributeMap.h"
 #include "nsICommandLine.h"
@@ -525,17 +525,17 @@ enum ADDRESSBOOK_EXPORT_FILE_TYPE
  CSV_EXPORT_TYPE      = 0,
  CSV_EXPORT_TYPE_UTF8 = 1,
  TAB_EXPORT_TYPE      = 2,
  TAB_EXPORT_TYPE_UTF8 = 3,
  VCF_EXPORT_TYPE      = 4,
  LDIF_EXPORT_TYPE     = 5,
 };
 
-NS_IMETHODIMP nsAbManager::ExportAddressBook(nsIDOMWindow *aParentWin, nsIAbDirectory *aDirectory)
+NS_IMETHODIMP nsAbManager::ExportAddressBook(mozIDOMWindowProxy *aParentWin, nsIAbDirectory *aDirectory)
 {
   NS_ENSURE_ARG_POINTER(aParentWin);
 
   nsresult rv;
   nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIStringBundleService> bundleService =
@@ -1379,19 +1379,22 @@ nsAbManager::Handle(nsICommandLine* aCmd
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!found)
     return NS_OK;
 
   nsCOMPtr<nsIWindowWatcher> wwatch (do_GetService(NS_WINDOWWATCHER_CONTRACTID));
   NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
 
-  nsCOMPtr<nsIDOMWindow> opened;
-  wwatch->OpenWindow(nullptr, "chrome://messenger/content/addressbook/addressbook.xul",
-                     "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", nullptr, getter_AddRefs(opened));
+  nsCOMPtr<mozIDOMWindowProxy> opened;
+  wwatch->OpenWindow(nullptr,
+                     "chrome://messenger/content/addressbook/addressbook.xul",
+                     "_blank",
+                     "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar",
+                     nullptr, getter_AddRefs(opened));
   aCmdLine->SetPreventDefault(true);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAbManager::GetHelpInfo(nsACString& aResult)
 {
   aResult.Assign(NS_LITERAL_CSTRING("  -addressbook       Open the address book at startup.\n"));
--- a/mailnews/base/public/nsIMapiRegistry.idl
+++ b/mailnews/base/public/nsIMapiRegistry.idl
@@ -1,24 +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/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMWindow;
+interface mozIDOMWindowProxy;
 
 /**
  * This interface provides support for registering Mozilla as the default
  * Mail Client. This interface can also be used to get/set the user preference
  * for the default Mail Client.
  * 
  */
 
-[scriptable, uuid(B0342CA7-CB85-4d13-AD18-BD431F2086EA)]
+[scriptable, uuid(47D707C3-4369-46A6-A053-5118E12579D6)]
 interface nsIMapiRegistry: nsISupports {
 
    /** This is set to TRUE if Mozilla is the default mail application
     */
    attribute boolean isDefaultMailClient;
 
    /* Set to TRUE if Mozilla is the default news application */
    attribute boolean isDefaultNewsClient;
@@ -29,17 +29,17 @@ interface nsIMapiRegistry: nsISupports {
    /** This is set TRUE only once per session.
     */
    readonly attribute boolean showDialog;
 
    /** This will bring the dialog asking the user if he/she wants to set
     * Mozilla as default Mail Client.
     * Call this only if Mozilla is not the default Mail client
     */
-   void showMailIntegrationDialog(in nsIDOMWindow parentWindow);
+   void showMailIntegrationDialog(in mozIDOMWindowProxy parentWindow);
 
    /* After being installed, when we first launch, make sure we add the correct
     OS registry entries to make us show up as regsitered mail and news client
     in the OS
    */
    
    void registerMailAndNewsClient();
 };
--- a/mailnews/base/public/nsIMessenger.idl
+++ b/mailnews/base/public/nsIMessenger.idl
@@ -5,42 +5,43 @@
 
 #include "nsISupports.idl"
 #include "nsrootidl.idl"
 #include "nsIMsgWindow.idl"
 #include "nsIMsgIdentity.idl"
 
 interface nsIMsgDBHdr;
 interface nsIDOMWindow;
+interface mozIDOMWindowProxy;
 interface nsITransactionManager;
 interface nsIMsgMessageService;
 interface nsIFile;
 interface nsIUrlListener;
 
-[scriptable, uuid(4e36968b-b476-4f3e-b170-c19fe3d48d0b)]
+[scriptable, uuid(01b967c8-b289-4e32-ad46-6eb7c89d4106)]
 interface nsIMessenger : nsISupports {
 
     const long eUnknown = 0;
     const long eDeleteMsg = 1;
     const long eMoveMsg = 2;
     const long eCopyMsg = 3;
     const long eMarkAllMsg = 4;
 
     void setDisplayCharset(in ACString aCharset);
 
     readonly attribute nsITransactionManager transactionManager;
 
-    void setWindow(in nsIDOMWindow ptr, in nsIMsgWindow msgWindow);
+    void setWindow(in mozIDOMWindowProxy ptr, in nsIMsgWindow msgWindow);
 
     void addMsgUrlToNavigateHistory(in ACString aURL);
     void openURL(in ACString aURL);
 
     /** load a custom message by url, e.g load a attachment as a email
       */
-    void loadURL(in nsIDOMWindow ptr, in ACString aURL); 
+    void loadURL(in mozIDOMWindowProxy ptr, in ACString aURL);
 
     void launchExternalURL(in ACString aURL);
 
     boolean canUndo();
     boolean canRedo();
     unsigned long getUndoTransactionType();
     unsigned long getRedoTransactionType();
     void undo(in nsIMsgWindow msgWindow);
--- a/mailnews/base/public/nsIMsgPrintEngine.idl
+++ b/mailnews/base/public/nsIMsgPrintEngine.idl
@@ -1,36 +1,36 @@
 /* -*- Mode: C++; tab-width: 4; 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/. */
 
 #include "nsrootidl.idl"
 #include "nsIMsgStatusFeedback.idl"
 
-interface nsIDOMWindow;
+interface mozIDOMWindowProxy;
 interface nsIPrintSettings;
 interface nsIObserver;
 
-[scriptable, uuid(e5f5e4a2-9d74-46b3-ade7-25e1a1ddf54e)]
+[scriptable, uuid(9bdd0812-dd48-4f04-87a9-74dcfc3abadc)]
 interface nsIMsgPrintEngine : nsISupports {
     /**
      * Print/PrintPreview Msg Type
      */
     const short MNAB_START                 = 0;
     const short MNAB_PRINT_MSG             = 0;
     const short MNAB_PRINTPREVIEW_MSG      = 1;
     const short MNAB_PRINT_AB_CARD         = 2;
     const short MNAB_PRINTPREVIEW_AB_CARD  = 3;
     const short MNAB_PRINT_ADDRBOOK        = 4;
     const short MNAB_PRINTPREVIEW_ADDRBOOK = 5;
     const short MNAB_END                   = 6;
 
-    void setWindow(in nsIDOMWindow ptr);
-    void setParentWindow(in nsIDOMWindow ptr);
+    void setWindow(in mozIDOMWindowProxy ptr);
+    void setParentWindow(in mozIDOMWindowProxy ptr);
     void showWindow(in boolean aShow);
     void setStatusFeedback(in nsIMsgStatusFeedback feedback);
     void setPrintURICount(in int32_t aCount);
     void addPrintURI(in wstring aURI);
     void startPrintOperation(in nsIPrintSettings aPS);
     void setStartupPPObserver(in nsIObserver startupPPObs);
     void setMsgType(in long aMsgType);
 
--- a/mailnews/base/public/nsIMsgProgress.idl
+++ b/mailnews/base/public/nsIMsgProgress.idl
@@ -2,28 +2,28 @@
 /* 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/. */
 #include "nsISupports.idl"
 #include "domstubs.idl"
 #include "nsIPrompt.idl"
 #include "nsIWebProgressListener.idl"
 
-interface nsIDOMWindow;
+interface mozIDOMWindowProxy;
 interface nsIMsgWindow;
 
-[scriptable, uuid(5aae7f1b-95f1-422e-86d5-2b1d599e2ccf)]
+[scriptable, uuid(6d6fe91d-7f9a-4552-9737-9f74b0e75538)]
 interface nsIMsgProgress: nsIWebProgressListener {
 
   /** 
    * Open the progress dialog, you can specify parameters through an xpcom object
    */
-  void openProgressDialog(in nsIDOMWindow parent, 
-                          in nsIMsgWindow aMsgWindow, 
-                          in string dialogURL, 
+  void openProgressDialog(in mozIDOMWindowProxy parent,
+                          in nsIMsgWindow aMsgWindow,
+                          in string dialogURL,
                           in boolean inDisplayModal,
                           in nsISupports parameters);
 
   /* Close the progress dialog */
   void closeProgressDialog(in boolean forceClose);
   
   /* Register a Web Progress Listener */
   void registerListener(in nsIWebProgressListener listener);
--- a/mailnews/base/public/nsIMsgWindow.idl
+++ b/mailnews/base/public/nsIMsgWindow.idl
@@ -4,30 +4,30 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsIMsgStatusFeedback;
 interface nsIMsgFolder;
 interface nsITransactionManager;
 interface nsIDocShell;
-interface nsIDOMWindow;
+interface mozIDOMWindowProxy;
 interface nsIMsgHeaderSink;
 interface nsIPrompt;
 interface nsIInterfaceRequestor;
 interface nsIAuthPrompt;
 
 [scriptable, uuid(7B8F4A65-CFC4-4b3f-BF5C-152AA8D5CD10)]
 interface nsIMsgWindowCommands : nsISupports {
   void selectFolder(in ACString folderUri);
   void selectMessage(in ACString messageUri);
   void clearMsgPane();
 };
 
-[scriptable, uuid(8ad06f07-2230-4917-968c-2269588dbf7d)]
+[scriptable, uuid(a846fe48-4022-4296-a1c4-1dcd7eaecfe5)]
 interface nsIMsgWindow : nsISupports {
   attribute nsIMsgStatusFeedback statusFeedback;
   attribute nsIMsgWindowCommands windowCommands;
   attribute nsIMsgHeaderSink msgHeaderSink;
   attribute nsITransactionManager transactionManager;
   attribute nsIMsgFolder openFolder;
   
   /**
@@ -69,17 +69,17 @@ interface nsIMsgWindow : nsISupports {
 
   /**
     Has a running url been stopped? If you care about checking
     this flag, you need to clear it before you start your operation since
     there's no convenient place to clear it.
   */
   attribute boolean stopped;
 
-  attribute nsIDOMWindow domWindow;
+  attribute mozIDOMWindowProxy domWindow;
 
   void StopUrls();
 
   /**
     when the msg window is being unloaded from the content window,
     we can use this notification to force a flush on anything the
     msg window hangs on too. For some reason xpconnect is still hanging
     onto the msg window even though all of our objects have let go of it
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -221,34 +221,34 @@ nsMessenger::nsMessenger()
 
 nsMessenger::~nsMessenger()
 {
 }
 
 
 NS_IMPL_ISUPPORTS(nsMessenger, nsIMessenger, nsISupportsWeakReference, nsIFolderListener)
 
-NS_IMETHODIMP nsMessenger::SetWindow(nsIDOMWindow *aWin, nsIMsgWindow *aMsgWindow)
+NS_IMETHODIMP nsMessenger::SetWindow(mozIDOMWindowProxy *aWin, nsIMsgWindow *aMsgWindow)
 {
   nsresult rv;
 
   nsCOMPtr<nsIMsgMailSession> mailSession =
     do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aWin)
   {
     mMsgWindow = aMsgWindow;
     mWindow = aWin;
 
     rv = mailSession->AddFolderListener(this, nsIFolderListener::removed);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    nsCOMPtr<nsPIDOMWindow> win( do_QueryInterface(aWin) );
-    NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
+    NS_ENSURE_TRUE(aWin, NS_ERROR_FAILURE);
+    nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(aWin);
 
     nsIDocShell *docShell = win->GetDocShell();
     nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
     NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsIDocShellTreeItem> rootDocShellAsItem;
     docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootDocShellAsItem));
 
@@ -465,17 +465,17 @@ NS_IMETHODIMP nsMessenger::LaunchExterna
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIExternalProtocolService> extProtService = do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
   return extProtService->LoadUrl(uri);
 }
 
 NS_IMETHODIMP
-nsMessenger::LoadURL(nsIDOMWindow *aWin, const nsACString& aURL)
+nsMessenger::LoadURL(mozIDOMWindowProxy *aWin, const nsACString& aURL)
 {
   nsresult rv;
 
   SetDisplayCharset(NS_LITERAL_CSTRING("UTF-8"));
 
   NS_ConvertASCIItoUTF16 uriString(aURL);
   // Cleanup the empty spaces that might be on each end.
   uriString.Trim(" ");
--- a/mailnews/base/src/nsMessenger.h
+++ b/mailnews/base/src/nsMessenger.h
@@ -10,17 +10,17 @@
 #include "nsIMessenger.h"
 #include "nsCOMPtr.h"
 #include "nsITransactionManager.h"
 #include "nsIFile.h"
 #include "nsIDocShell.h"
 #include "nsIStringBundle.h"
 #include "nsIFile.h"
 #include "nsWeakReference.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsTArray.h"
 #include "nsIFolderListener.h"
 
 class nsMessenger : public nsIMessenger, public nsSupportsWeakReference, public nsIFolderListener
 {
 
 public:
   nsMessenger();
@@ -72,19 +72,19 @@ private:
                          nsIFile **aSaveAsFile);
 
   nsresult GetSaveToDir(nsIFile **aSaveToDir);
 
   nsString mId;
   nsCOMPtr<nsITransactionManager> mTxnMgr;
 
   /* rhp - need this to drive message display */
-  nsCOMPtr<nsIDOMWindow>    mWindow;
-  nsCOMPtr<nsIMsgWindow>    mMsgWindow;
-  nsCOMPtr<nsIDocShell>     mDocShell;
+  nsCOMPtr<mozIDOMWindowProxy> mWindow;
+  nsCOMPtr<nsIMsgWindow>       mMsgWindow;
+  nsCOMPtr<nsIDocShell>        mDocShell;
 
   // String bundles...
   nsCOMPtr<nsIStringBundle>   mStringBundle;
 
   nsCString mCurrentDisplayCharset;
 
   nsCOMPtr<nsISupports>  mSearchContext;
   nsCString   mLastDisplayURI; // this used when the user attempts to force a charset reload of a message...we need to get the last displayed
--- a/mailnews/base/src/nsMessengerBootstrap.cpp
+++ b/mailnews/base/src/nsMessengerBootstrap.cpp
@@ -6,17 +6,17 @@
 #include "nsMessengerBootstrap.h"
 #include "nsCOMPtr.h"
 
 #include "nsIMutableArray.h"
 #include "nsIMsgFolder.h"
 #include "nsIWindowWatcher.h"
 #include "nsMsgUtils.h"
 #include "nsISupportsPrimitives.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 
 NS_IMPL_ISUPPORTS(nsMessengerBootstrap, nsIMessengerWindowService)
 
 nsMessengerBootstrap::nsMessengerBootstrap()
 {
 }
@@ -71,13 +71,13 @@ NS_IMETHODIMP nsMessengerBootstrap::Open
     }
   }
   
   nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // we need to use the "mailnews.reuse_thread_window2" pref
   // to determine if we should open a new window, or use an existing one.
-  nsCOMPtr<nsIDOMWindow> newWindow;
+  nsCOMPtr<mozIDOMWindowProxy> newWindow;
   return wwatch->OpenWindow(0, chromeUrl.get(), "_blank",
                             "chrome,all,dialog=no", argsArray,
                              getter_AddRefs(newWindow));
 }
--- a/mailnews/base/src/nsMessengerContentHandler.cpp
+++ b/mailnews/base/src/nsMessengerContentHandler.cpp
@@ -69,13 +69,13 @@ NS_IMETHODIMP nsMessengerContentHandler:
 nsresult nsMessengerContentHandler::OpenWindow(nsIURI* aURI)
 {
   NS_ENSURE_ARG_POINTER(aURI);
   
   nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");
   if (!wwatch)
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIDOMWindow> newWindow;
+  nsCOMPtr<mozIDOMWindowProxy> newWindow;
   return wwatch->OpenWindow(0, "chrome://messenger/content/messageWindow.xul",
                  "_blank", "all,chrome,dialog=no,status,toolbar", aURI,
                  getter_AddRefs(newWindow));
 }
--- a/mailnews/base/src/nsMessengerOSXIntegration.mm
+++ b/mailnews/base/src/nsMessengerOSXIntegration.mm
@@ -15,17 +15,17 @@
 #include "nsCOMPtr.h"
 #include "nsMsgBaseCID.h"
 #include "nsMsgFolderFlags.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIDirectoryService.h"
 #include "MailNewsTypes.h"
 #include "nsIWindowMediator.h"
 #include "nsIDOMChromeWindow.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIBaseWindow.h"
 #include "nsIWidget.h"
 #include "nsIObserverService.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIMessengerWindowService.h"
@@ -103,51 +103,52 @@ static void openMailWindow(const nsCStri
         nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
         if (NS_FAILED(rv))
           return;
 
         // SeaMonkey only supports message uris, whereas Thunderbird only
         // supports message headers. This should be simplified/removed when
         // bug 507593 is implemented.
 #ifdef MOZ_SUITE
-        nsCOMPtr<nsIDOMWindow> newWindow;
+        nsCOMPtr<mozIDOMWindowProxy> newWindow;
         wwatch->OpenWindow(0, "chrome://messenger/content/messageWindow.xul",
                            "_blank", "all,chrome,dialog=no,status,toolbar", msgUri,
                            getter_AddRefs(newWindow));
 #else
         nsCOMPtr<nsIMessenger> messenger(do_CreateInstance(NS_MESSENGER_CONTRACTID, &rv));
         if (NS_FAILED(rv))
           return;
 
         nsCOMPtr<nsIMsgDBHdr> msgHdr; 
         messenger->MsgHdrFromURI(aUri, getter_AddRefs(msgHdr));
         if (msgHdr)
         {
-          nsCOMPtr<nsIDOMWindow> newWindow;
+          nsCOMPtr<mozIDOMWindowProxy> newWindow;
           wwatch->OpenWindow(0, "chrome://messenger/content/messageWindow.xul",
                              "_blank", "all,chrome,dialog=no,status,toolbar", msgHdr,
                              getter_AddRefs(newWindow));
         }
 #endif
       }
       else
       {
         nsCOMPtr<nsIMsgWindowCommands> windowCommands;
         topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
         if (windowCommands)
           windowCommands->SelectFolder(aUri);
       }
     }
 
     FocusAppNative();
-    nsCOMPtr<nsIDOMWindow> domWindow;
+    nsCOMPtr<mozIDOMWindowProxy> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
-    nsCOMPtr<nsPIDOMWindow> privateWindow(do_QueryInterface(domWindow));
-    if (privateWindow)
+    if (domWindow) {
+      nsCOMPtr<nsPIDOMWindowOuter> privateWindow = nsPIDOMWindowOuter::From(domWindow);
       privateWindow->Focus();
+    }
   }
   else
   {
     // the user doesn't have a mail window open already so open one for them...
     nsCOMPtr<nsIMessengerWindowService> messengerWindowService =
       do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
     // if we want to preselect the first account with new mail,
     // here is where we would try to generate a uri to pass in
@@ -489,17 +490,17 @@ nsMessengerOSXIntegration::BounceDockIco
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!bounceDockIcon)
     return NS_OK;
 
   nsCOMPtr<nsIWindowMediator> mediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
   if (mediator)
   {
-    nsCOMPtr<nsIDOMWindow> domWindow;
+    nsCOMPtr<mozIDOMWindowProxy> domWindow;
     mediator->GetMostRecentWindow(MOZ_UTF16("mail:3pane"), getter_AddRefs(domWindow));
     if (domWindow)
     {
       nsCOMPtr<nsIDOMChromeWindow> chromeWindow(do_QueryInterface(domWindow));
       chromeWindow->GetAttention();
     }
   }
   return NS_OK;
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -14,17 +14,17 @@
 #include "nsCOMPtr.h"
 #include "nsMsgBaseCID.h"
 #include "nsMsgFolderFlags.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsIDirectoryService.h"
 #include "nsIWindowWatcher.h"
 #include "nsIWindowMediator.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIBaseWindow.h"
 #include "MailNewsTypes.h"
 #include "nsIMessengerWindowService.h"
 #include "prprf.h"
 #include "nsIWeakReference.h"
 #include "nsIStringBundle.h"
@@ -77,20 +77,22 @@ static void openMailWindow(const nsACStr
     if (!aFolderUri.IsEmpty())
     {
       nsCOMPtr<nsIMsgWindowCommands> windowCommands;
       topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
       if (windowCommands)
         windowCommands->SelectFolder(aFolderUri);
     }
 
-    nsCOMPtr<nsIDOMWindow> domWindow;
+    nsCOMPtr<mozIDOMWindowProxy> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
-    nsCOMPtr<nsPIDOMWindow> privateWindow(do_QueryInterface(domWindow));
-    privateWindow->Focus();
+    if (domWindow) {
+      nsCOMPtr<nsPIDOMWindowOuter> privateWindow = nsPIDOMWindowOuter::From(domWindow);
+      privateWindow->Focus();
+    }
   }
   else
   {
     // the user doesn't have a mail window open already so open one for them...
     nsCOMPtr<nsIMessengerWindowService> messengerWindowService =
       do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
     // if we want to preselect the first account with new mail,
     // here is where we would try to generate a uri to pass in
@@ -394,17 +396,17 @@ nsresult nsMessengerUnixIntegration::Sho
 
   // pass in the animation flag
   nsCOMPtr<nsISupportsPRBool> scriptableUserInitiated (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   scriptableUserInitiated->SetData(aUserInitiated);
   argsArray->AppendElement(scriptableUserInitiated, false);
 
   nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
-  nsCOMPtr<nsIDOMWindow> newWindow;
+  nsCOMPtr<mozIDOMWindowProxy> newWindow;
 
   mAlertInProgress = true;
   rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",
                           "chrome,dialog=yes,titlebar=no,popup=yes", argsArray,
                           getter_AddRefs(newWindow));
 
   if (NS_FAILED(rv))
     AlertFinished();
--- a/mailnews/base/src/nsMessengerWinIntegration.cpp
+++ b/mailnews/base/src/nsMessengerWinIntegration.cpp
@@ -17,17 +17,17 @@
 #include "nsCOMPtr.h"
 #include "nsMsgBaseCID.h"
 #include "nsMsgFolderFlags.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsIDirectoryService.h"
 #include "nsIWindowWatcher.h"
 #include "nsIWindowMediator.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIBaseWindow.h"
 #include "nsIWidget.h"
 #include "nsWidgetsCID.h"
 #include "MailNewsTypes.h"
 #include "nsIMessengerWindowService.h"
 #include "prprf.h"
@@ -91,63 +91,65 @@
 #define NS_ALERT_HORIZONTAL 1
 #define NS_ALERT_LEFT       2
 #define NS_ALERT_TOP        4
 #endif
 
 using namespace mozilla;
 
 // begin shameless copying from nsNativeAppSupportWin
-HWND hwndForDOMWindow( nsISupports *window )
+HWND hwndForDOMWindow( mozIDOMWindowProxy *window )
 {
-  nsCOMPtr<nsPIDOMWindow> win( do_QueryInterface(window) );
-  if ( !win )
-      return 0;
+  if ( !window ) {
+    return 0;
+  }
+  nsCOMPtr<nsPIDOMWindowOuter> pidomwindow = nsPIDOMWindowOuter::From(window);
 
   nsCOMPtr<nsIBaseWindow> ppBaseWindow =
-      do_QueryInterface( win->GetDocShell() );
-  if (!ppBaseWindow) return 0;
+    do_QueryInterface( pidomwindow->GetDocShell() );
+  if (!ppBaseWindow)
+    return 0;
 
   nsCOMPtr<nsIWidget> ppWidget;
   ppBaseWindow->GetMainWidget( getter_AddRefs( ppWidget ) );
 
   return (HWND)( ppWidget->GetNativeData( NS_NATIVE_WIDGET ) );
 }
 
-static void activateWindow( nsIDOMWindow *win )
+static void activateWindow( mozIDOMWindowProxy *win )
 {
   // Try to get native window handle.
   HWND hwnd = hwndForDOMWindow( win );
   if ( hwnd )
   {
     // Restore the window if it is minimized.
     if ( ::IsIconic( hwnd ) )
       ::ShowWindow( hwnd, SW_RESTORE );
     // Use the OS call, if possible.
     ::SetForegroundWindow( hwnd );
   } else {
     // Use internal method.
-    nsCOMPtr<nsPIDOMWindow> privateWindow(do_QueryInterface(win));
+    nsCOMPtr<nsPIDOMWindowOuter> privateWindow = nsPIDOMWindowOuter::From(win);
     privateWindow->Focus();
   }
 }
 // end shameless copying from nsNativeAppWinSupport.cpp
 
 static void openMailWindow(const nsACString& aFolderUri)
 {
   nsresult rv;
   nsCOMPtr<nsIMsgMailSession> mailSession ( do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv));
   if (NS_FAILED(rv))
     return;
 
   nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
   rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
   if (topMostMsgWindow)
   {
-    nsCOMPtr<nsIDOMWindow> domWindow;
+    nsCOMPtr<mozIDOMWindowProxy> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
     if (domWindow)
     {
       if (!aFolderUri.IsEmpty())
       {
         nsCOMPtr<nsIMsgWindowCommands> windowCommands;
         topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
         if (windowCommands)
@@ -572,17 +574,17 @@ nsresult nsMessengerWinIntegration::Show
     }
 #endif
     scriptableOrigin->SetData(origin);
 
     rv = argsArray->AppendElement(scriptableOrigin, false);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
-    nsCOMPtr<nsIDOMWindow> newWindow;
+    nsCOMPtr<mozIDOMWindowProxy> newWindow;
     rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",
                 "chrome,dialog=yes,titlebar=no,popup=yes", argsArray,
                  getter_AddRefs(newWindow));
 
     mAlertInProgress = true;
   }
 
   // if the user has turned off the mail alert, or  openWindow generated an error,
@@ -618,17 +620,17 @@ nsresult nsMessengerWinIntegration::Aler
 {
   nsresult rv;
   nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
   nsCOMPtr<nsIMsgWindow> topMostMsgWindow;
   rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(topMostMsgWindow));
   if (topMostMsgWindow)
   {
-    nsCOMPtr<nsIDOMWindow> domWindow;
+    nsCOMPtr<mozIDOMWindowProxy> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
     if (domWindow)
     {
       activateWindow(domWindow);
       return NS_OK;
     }
   }
   // make sure we don't insert the icon in the system tray since the user clicked on the alert.
--- a/mailnews/base/src/nsMsgMailSession.cpp
+++ b/mailnews/base/src/nsMsgMailSession.cpp
@@ -273,17 +273,17 @@ nsresult nsMsgMailSession::GetTopmostMsg
 #else
     rv = windowMediator->GetZOrderDOMWindowEnumerator(nullptr, true,
                                                       getter_AddRefs(windowEnum));
 #endif
 
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsISupports> windowSupports;
-    nsCOMPtr<nsPIDOMWindow> topMostWindow;
+    nsCOMPtr<nsPIDOMWindowOuter> topMostWindow;
     nsCOMPtr<nsIDOMDocument> domDocument;
     nsCOMPtr<nsIDOMElement> domElement;
     nsAutoString windowType;
     bool more;
 
     // loop to get the top most with attibute "mail:3pane" or "mail:messageWindow"
     windowEnum->HasMoreElements(&more);
     while (more)
@@ -655,17 +655,17 @@ NS_IMETHODIMP nsMsgShutdownService::Obse
     NS_ENSURE_TRUE(mMsgProgress, NS_ERROR_FAILURE);
     
     nsCOMPtr<nsIMsgMailSession> mailSession = do_GetService(NS_MSGMAILSESSION_CONTRACTID);
     NS_ENSURE_TRUE(mailSession, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsIMsgWindow> topMsgWindow;
     mailSession->GetTopmostMsgWindow(getter_AddRefs(topMsgWindow));
     
-    nsCOMPtr<nsIDOMWindow> internalDomWin;
+    nsCOMPtr<mozIDOMWindowProxy> internalDomWin;
     if (topMsgWindow)
       topMsgWindow->GetDomWindow(getter_AddRefs(internalDomWin));
     
     if (!internalDomWin)
     {
       // First see if there is a window open. 
       nsCOMPtr<nsIWindowMediator> winMed = do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
       winMed->GetMostRecentWindow(nullptr, getter_AddRefs(internalDomWin));
--- a/mailnews/base/src/nsMsgPrintEngine.cpp
+++ b/mailnews/base/src/nsMsgPrintEngine.cpp
@@ -11,16 +11,17 @@
 
 #include "nsIComponentManager.h"
 
 #include "nsISupports.h"
 
 #include "nsIURI.h"
 
 #include "nsPIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIContentViewer.h"
 #include "nsIMsgMessageService.h"
 #include "nsMsgUtils.h"
 #include "nsIWebProgress.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsMsgPrintEngine.h"
 #include "nsIDocumentLoader.h"
 #include "nsIPrefService.h"
@@ -87,17 +88,17 @@ nsMsgPrintEngine::OnStateChange(nsIWebPr
       {
         // Check to see if the document DOMWin that is finished loading is the same
         // one as the mail msg that we started to load.
         // We only want to print when the entire msg and all of its attachments
         // have finished loading.
         // The mail msg doc is the last one to receive the STATE_STOP notification
         nsCOMPtr<nsISupports> container;
         docLoader->GetContainer(getter_AddRefs(container));
-        nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(container));
+        nsCOMPtr<mozIDOMWindowProxy> domWindow(do_GetInterface(container));
         if (domWindow.get() != mMsgDOMWin.get()) {
           return NS_OK;
         }
       }
       nsCOMPtr<nsIWebProgressListener> wpl(do_QueryInterface(mPrintPromptService));
       if (wpl) {
         wpl->OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP|nsIWebProgressListener::STATE_IS_DOCUMENT, NS_OK);
         mPrintProgressListener = nullptr;
@@ -155,17 +156,19 @@ nsMsgPrintEngine::OnStateChange(nsIWebPr
           }
         } else {
           FireStartNextEvent();
           rv = NS_OK;
         }
       } 
       else 
       {
-        mWindow->Close();
+        if (mWindow) {
+          nsPIDOMWindowOuter::From(mWindow)->Close();
+        }
       }
     }
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
@@ -205,32 +208,34 @@ nsMsgPrintEngine::OnSecurityChange(nsIWe
                       nsIRequest *aRequest, 
                       uint32_t state)
 {
     NS_NOTREACHED("notification excluded in AddProgressListener(...)");
     return NS_OK;
 }
 
 NS_IMETHODIMP    
-nsMsgPrintEngine::SetWindow(nsIDOMWindow *aWin)
+nsMsgPrintEngine::SetWindow(mozIDOMWindowProxy *aWin)
 {
-	if (!aWin)
+  if (!aWin)
   {
     // It isn't an error to pass in null for aWin, in fact it means we are shutting
     // down and we should start cleaning things up...
-		return NS_OK;
+    return NS_OK;
   }
 
-  mWindow = do_QueryInterface(aWin);
+  mWindow = aWin;
+
   NS_ENSURE_TRUE(mWindow, NS_ERROR_FAILURE);
+  nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(mWindow);
 
-  mWindow->GetDocShell()->SetAppType(nsIDocShell::APP_TYPE_MAIL);
+  window->GetDocShell()->SetAppType(nsIDocShell::APP_TYPE_MAIL);
 
   nsCOMPtr<nsIDocShellTreeItem> docShellAsItem =
-    do_QueryInterface(mWindow->GetDocShell());
+    do_QueryInterface(window->GetDocShell());
   NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDocShellTreeItem> rootAsItem;
   docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootAsItem));
 
   nsCOMPtr<nsIDocShellTreeItem> childItem;
   rootAsItem->FindChildWithName(MOZ_UTF16("content"), true,
 				false, nullptr, nullptr,
@@ -239,33 +244,34 @@ nsMsgPrintEngine::SetWindow(nsIDOMWindow
   mDocShell = do_QueryInterface(childItem);
 
   if(mDocShell)
     SetupObserver();
 
   return NS_OK;
 }
 
-/* void setParentWindow (in nsIDOMWindow ptr); */
-NS_IMETHODIMP nsMsgPrintEngine::SetParentWindow(nsIDOMWindow *ptr)
+/* void setParentWindow (in mozIDOMWindowProxy ptr); */
+NS_IMETHODIMP nsMsgPrintEngine::SetParentWindow(mozIDOMWindowProxy *ptr)
 {
   mParentWindow = ptr;
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsMsgPrintEngine::ShowWindow(bool aShow)
 {
   nsresult rv;
 
   NS_ENSURE_TRUE(mWindow, NS_ERROR_NOT_INITIALIZED);
 
+  nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(mWindow);
   nsCOMPtr <nsIDocShellTreeItem> treeItem =
-    do_QueryInterface(mWindow->GetDocShell(), &rv);
+    do_QueryInterface(window->GetDocShell(), &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsCOMPtr <nsIDocShellTreeOwner> treeOwner;
   rv = treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
   NS_ENSURE_SUCCESS(rv,rv);
   
   if (treeOwner) {
     // disable (enable) the window
@@ -345,17 +351,17 @@ nsMsgPrintEngine::ShowProgressDialog(boo
   // If we don't get a service, that's ok, then just don't show progress
   if (showProgressDialog) {
     if (!mPrintPromptService) 
     {
       mPrintPromptService = do_GetService(kPrintingPromptService);
     }
     if (mPrintPromptService) 
     {
-      nsCOMPtr<nsIDOMWindow> domWin(do_QueryInterface(mParentWindow));
+      nsCOMPtr<mozIDOMWindowProxy> domWin(do_QueryInterface(mParentWindow));
       if (!domWin) 
       {
         domWin = mWindow;
       }
 
       rv = mPrintPromptService->ShowProgress(domWin, mWebBrowserPrint, mPrintSettings, this, aIsForPrinting,
                                             getter_AddRefs(mPrintProgressListener), 
                                             getter_AddRefs(mPrintProgressParams), 
@@ -395,17 +401,18 @@ nsMsgPrintEngine::StartNextPrintOperatio
     InitializeDisplayCharset();
 
   mCurrentlyPrintingURI++;
 
   // First, check if we are at the end of this stuff!
   if (mCurrentlyPrintingURI >= (int32_t)mURIArray.Length())
   {
     // This is the end...dum, dum, dum....my only friend...the end
-    mWindow->Close();
+    NS_ENSURE_TRUE(mWindow, NS_ERROR_FAILURE);
+    nsPIDOMWindowOuter::From(mWindow)->Close();
 
     // Tell the user we are done...
     nsString msg;
     GetString(MOZ_UTF16("PrintingComplete"), msg);
     SetStatusMessage(msg);
     return NS_OK;
   }
 
@@ -617,17 +624,19 @@ nsMsgPrintEngine::PrintMsgWindow()
           mPrintSettings->GetIsCancelled(&isPrintingCancelled);
         }
         if (!isPrintingCancelled) 
         {
           StartNextPrintOperation();
         } 
         else 
         {
-          mWindow->Close();
+          if (mWindow) {
+            nsPIDOMWindowOuter::From(mWindow)->Close();
+          }
         }
       }
       else
       {
         // Tell the user we started printing...
         nsString msg;
         GetString(NS_ConvertASCIItoUTF16(kMsgKeys[mMsgInx]).get(), msg);
         SetStatusMessage(msg);
--- a/mailnews/base/src/nsMsgPrintEngine.h
+++ b/mailnews/base/src/nsMsgPrintEngine.h
@@ -60,28 +60,28 @@ protected:
   nsresult    FireThatLoadOperation(const nsString& uri);
   void        InitializeDisplayCharset();
   void        SetupObserver();
   nsresult    SetStatusMessage(const nsString& aMsgString);
   void GetString(const char16_t *aStringName, nsString& aOutString);
   nsresult    ShowProgressDialog(bool aIsForPrinting, bool& aDoNotify);
 
   nsCOMPtr<nsIDocShell>       mDocShell;
-  nsCOMPtr<nsPIDOMWindow>     mWindow;
-  nsCOMPtr<nsIDOMWindow>      mParentWindow;
+  nsCOMPtr<mozIDOMWindowProxy> mWindow;
+  nsCOMPtr<mozIDOMWindowProxy> mParentWindow;
   int32_t                     mURICount;
   nsTArray<nsString>          mURIArray;
   int32_t                     mCurrentlyPrintingURI;
 
   nsCOMPtr<nsIContentViewer>  mContentViewer;
   nsCOMPtr<nsIStringBundle>   mStringBundle;    // String bundles...
   nsCOMPtr<nsIMsgStatusFeedback> mFeedback;     // Tell the user something why don't ya'
   nsCOMPtr<nsIWebBrowserPrint> mWebBrowserPrint;
   nsCOMPtr<nsIPrintSettings>   mPrintSettings;
-  nsCOMPtr<nsIDOMWindow>       mMsgDOMWin;
+  nsCOMPtr<mozIDOMWindowProxy> mMsgDOMWin;
   bool                         mIsDoingPrintPreview;
   nsCOMPtr<nsIObserver>        mStartupPPObs;
   int32_t                      mMsgInx;
 
   // Progress Dialog
   
   nsCOMPtr<nsIPrintingPromptService> mPrintPromptService;
   nsCOMPtr<nsIWebProgressListener> mPrintProgressListener;
--- a/mailnews/base/src/nsMsgProgress.cpp
+++ b/mailnews/base/src/nsMsgProgress.cpp
@@ -8,16 +8,17 @@
 #include "nsIBaseWindow.h"
 #include "nsXPCOM.h"
 #include "nsIMutableArray.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsError.h"
 #include "nsIWindowWatcher.h"
 #include "nsPIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
 
 NS_IMPL_ISUPPORTS(nsMsgProgress, nsIMsgStatusFeedback, nsIMsgProgress,
   nsIWebProgressListener, nsIProgressEventSink, nsISupportsWeakReference)
 
@@ -30,33 +31,33 @@ nsMsgProgress::nsMsgProgress()
   m_pendingStateValue = NS_OK;
 }
 
 nsMsgProgress::~nsMsgProgress()
 {
   (void)ReleaseListeners();
 }
 
-NS_IMETHODIMP nsMsgProgress::OpenProgressDialog(nsIDOMWindow *parentDOMWindow, 
-                                                nsIMsgWindow *aMsgWindow, 
-                                                const char *dialogURL, 
-                                                bool inDisplayModal, 
+NS_IMETHODIMP nsMsgProgress::OpenProgressDialog(mozIDOMWindowProxy *parentDOMWindow,
+                                                nsIMsgWindow *aMsgWindow,
+                                                const char *dialogURL,
+                                                bool inDisplayModal,
                                                 nsISupports *parameters)
 {
   nsresult rv;
 
   if (aMsgWindow)
   {
     SetMsgWindow(aMsgWindow);
     aMsgWindow->SetStatusFeedback(this);
   }
 
   NS_ENSURE_ARG_POINTER(dialogURL);
-  nsCOMPtr<nsPIDOMWindow> parent(do_QueryInterface(parentDOMWindow));
-  NS_ENSURE_ARG_POINTER(parent);
+  NS_ENSURE_ARG_POINTER(parentDOMWindow);
+  nsCOMPtr<nsPIDOMWindowOuter> parent = nsPIDOMWindowOuter::From(parentDOMWindow);
   parent = parent->GetOuterWindow();
   NS_ENSURE_ARG_POINTER(parent);
 
   // Set up window.arguments[0]...
   nsCOMPtr<nsIMutableArray> array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsISupportsInterfacePointer> ifptr =
@@ -65,17 +66,17 @@ NS_IMETHODIMP nsMsgProgress::OpenProgres
 
   ifptr->SetData(static_cast<nsIMsgProgress*>(this));
   ifptr->SetDataIID(&NS_GET_IID(nsIMsgProgress));
 
   array->AppendElement(ifptr, false);
   array->AppendElement(parameters, false);
 
   // Open the dialog.
-  nsCOMPtr<nsIDOMWindow> newWindow;
+  nsCOMPtr<nsPIDOMWindowOuter> newWindow;
 
   nsString chromeOptions(NS_LITERAL_STRING("chrome,dependent,centerscreen"));
   if (inDisplayModal)
     chromeOptions.AppendLiteral(",modal");
 
   return parent->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL),
                             NS_LITERAL_STRING("_blank"),
                             chromeOptions,
--- a/mailnews/base/src/nsMsgWindow.cpp
+++ b/mailnews/base/src/nsMsgWindow.cpp
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsMsgWindow.h"
 #include "nsIURILoader.h"
 #include "nsCURILoader.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDOMElement.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsTransactionManagerCID.h"
 #include "nsIComponentManager.h"
 #include "nsILoadGroup.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIWebProgress.h"
 #include "nsIWebProgressListener.h"
@@ -301,32 +301,32 @@ NS_IMETHODIMP nsMsgWindow::GetCharsetOve
 }
 
 NS_IMETHODIMP nsMsgWindow::SetCharsetOverride(bool aCharsetOverride)
 {
   mCharsetOverride = aCharsetOverride;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgWindow::GetDomWindow(nsIDOMWindow **aWindow)
+NS_IMETHODIMP nsMsgWindow::GetDomWindow(mozIDOMWindowProxy **aWindow)
 {
   NS_ENSURE_ARG_POINTER(aWindow);
   if (mDomWindow)
     CallQueryReferent(mDomWindow.get(), aWindow);
   else
     *aWindow = nullptr;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsMsgWindow::SetDomWindow(nsIDOMWindow * aWindow)
+NS_IMETHODIMP nsMsgWindow::SetDomWindow(mozIDOMWindowProxy * aWindow)
 {
   NS_ENSURE_ARG_POINTER(aWindow);
   mDomWindow = do_GetWeakReference(aWindow);
 
-  nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(aWindow));
+  nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(aWindow);
   nsIDocShell *docShell = nullptr;
   if (win)
     docShell = win->GetDocShell();
 
   nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
 
   if(docShellAsItem)
   {
--- a/mailnews/compose/public/nsIMsgCompose.idl
+++ b/mailnews/compose/public/nsIMsgCompose.idl
@@ -11,17 +11,17 @@
 %{C++
 #include "nsStringGlue.h"
 %}
 
 interface nsIMsgSend;
 interface nsIMsgIdentity;
 interface nsIMsgProgress;
 interface nsIDocShell;
-interface nsIDOMWindow;
+interface mozIDOMWindowProxy;
 interface nsIEditor;
 interface nsIMsgWindow;
 
 typedef long MSG_ComposeSaveType;
 
 [scriptable, uuid(6953e50a-7531-11d3-85fe-006008948010)]
 interface nsIMsgCompSaveType {
     const long File     = 0;
@@ -93,30 +93,30 @@ native nsString(nsString);
 
 /* recycling listener interface */
 [scriptable, uuid(0b28cc56-1dd2-11b2-bbe4-99e6a314f8ba)]
 interface nsIMsgComposeRecyclingListener : nsISupports {
   void onClose();
   void onReopen(in nsIMsgComposeParams params);
 };
 
-[scriptable, uuid(d06ca5af-66b5-4a08-961f-5b47e88cee98)]
+[scriptable, uuid(c6544b6b-06dd-43ac-89b5-949d7c81bb7b)]
 interface nsIMsgCompose : nsIMsgSendListener {
 
   /**
    * Initializes the msg compose object.
    *
    * @param aParams   An nsIMsgComposeParams object containing the initial
    *                  details for the compose.
    * @param aWindow   The optional window associated with this compose object.
    * @param aDocShell The optional docShell of the editor element that is used
    *                  for composing.
    */
   void initialize(in nsIMsgComposeParams aParams,
-                  [optional] in nsIDOMWindow aWindow,
+                  [optional] in mozIDOMWindowProxy aWindow,
                   [optional] in nsIDocShell aDocShell); 
 
   /* ... */
   void SetDocumentCharset(in string charset);
   
   /* ... */
   void RegisterStateListener(in nsIMsgComposeStateListener stateListener);
 
@@ -204,17 +204,17 @@ interface nsIMsgCompose : nsIMsgSendList
    * Clear the messageSend object to break any circular references
    */
    void clearMessageSend();
 
   /* ... */
   attribute nsIEditor editor;
 
 	/* ... */
-  readonly attribute nsIDOMWindow domWindow;
+  readonly attribute mozIDOMWindowProxy domWindow;
 
 	/* ... */
   readonly attribute nsIMsgCompFields compFields;
     
 	/* ... */
   readonly attribute boolean composeHTML;
 
 	/* ... */
@@ -236,17 +236,17 @@ interface nsIMsgCompose : nsIMsgSendList
 
   /**
    *  Init the editor THIS USED TO BE [noscript]
    *  Now, this is called after editor is created,
    *  which is triggered by loading startup url from JS.
    *  The completion of document loading is detected by observing 
    *  the "obs_documentCreated" command
    */
-  void initEditor(in nsIEditor editor, in nsIDOMWindow contentWindow);
+  void initEditor(in nsIEditor editor, in mozIDOMWindowProxy contentWindow);
 
   /* The following functions are for internal use, essentially for the listener */
 
   /* ... */
   [noscript] void setCiteReference(in nsString citeReference);
 
   /* Set the URI of the folder where the message has been saved */
   attribute string savedFolderURI;
--- a/mailnews/compose/public/nsIMsgComposeService.idl
+++ b/mailnews/compose/public/nsIMsgComposeService.idl
@@ -10,17 +10,17 @@
 
 interface nsIURI;
 interface nsIDocShell;
 interface nsIMsgWindow;
 interface nsIMsgIdentity;
 interface nsIMsgIncomingServer;
 interface nsIMsgDBHdr;
 
-[scriptable, uuid(8de65170-a452-11e0-8264-0800200c9a66)]
+[scriptable, uuid(041782bf-e523-444b-a268-d90868fd2b50)]
 interface nsIMsgComposeService : nsISupports {
 
   /* we need a msg window because when we forward inline we may need progress */
   void OpenComposeWindow(in string msgComposeWindowURL,
                          in nsIMsgDBHdr msgHdr,
                          in string originalMsgURI,
                          in MSG_ComposeType type, 
                          in MSG_ComposeFormat format,
@@ -51,35 +51,35 @@ interface nsIMsgComposeService : nsISupp
    *
    * @param aParams   An nsIMsgComposeParams object containing the initial
    *                  details for the compose.
    * @param aWindow   The optional window associated with this compose object.
    * @param aDocShell The optional docShell of the editor element that is used
    *                  for composing.
    */
   nsIMsgCompose initCompose(in nsIMsgComposeParams aParams,
-                            [optional] in nsIDOMWindow aWindow, 
+                            [optional] in mozIDOMWindowProxy aWindow,
                             [optional] in nsIDocShell aDocShell);
 
   /**
   * defaultIdentity
   *
   * @return the default identity, in case no identity has been setup yet, will return null
   */
   readonly attribute nsIMsgIdentity defaultIdentity;
 
   /* This function is use for debugging purpose only and may go away at anytime without warning */
   void TimeStamp(in string label, in boolean resetTime);  
   
   /* This attribute is use for debugging purposes for determining whether to PR_LOG or not */
   readonly attribute boolean logComposePerformance;
 
   [noscript] boolean determineComposeHTML(in nsIMsgIdentity aIdentity, in MSG_ComposeFormat aFormat);
-  [noscript] void cacheWindow(in nsIDOMWindow aWindow, in boolean aComposeHTML, in nsIMsgComposeRecyclingListener listener);
-  boolean isCachedWindow(in nsIDOMWindow aWindow);
+  [noscript] void cacheWindow(in mozIDOMWindowProxy aWindow, in boolean aComposeHTML, in nsIMsgComposeRecyclingListener listener);
+  boolean isCachedWindow(in mozIDOMWindowProxy aWindow);
 
   /** 
    * given a mailto url, parse the attributes and turn them into a nsIMsgComposeParams object
    * @return nsIMsgComposeParams which corresponds to the passed in mailto url
    */
   nsIMsgComposeParams getParamsForMailto(in nsIURI aURI); 
 
   /**
--- a/mailnews/compose/public/nsIMsgSend.idl
+++ b/mailnews/compose/public/nsIMsgSend.idl
@@ -30,16 +30,17 @@ interface nsIMsgHdr;
 interface nsIFile;
 interface nsIOutputStream;
 interface nsIMsgComposeSecure;
 interface nsIMsgStatusFeedback;
 interface nsIEditor;
 interface nsIArray;
 interface nsISupportsArray;
 interface nsIMsgAttachmentHandler;
+interface mozIDOMWindowProxy;
 
 typedef long nsMsgDeliverMode;
 
 [scriptable, uuid(c658cd1f-dc4a-43c0-911c-c6d3e569ca7e)]
 interface nsIMsgAttachmentData : nsISupports
 {
   /// The URL to attach.
   attribute nsIURI url;
@@ -147,17 +148,17 @@ interface nsIMsgEmbeddedImageData : nsIS
 class nsMsgAttachmentHandler;
 #include "nsAutoPtr.h"
 #include "nsTArray.h"
 %}
 
 [ptr] native nsMsgAttachedFile(nsMsgAttachedFile);
 [ptr] native nsMsgAttachmentHandlerArray(nsTArray<RefPtr<nsMsgAttachmentHandler>>);
 
-[scriptable, uuid(adcea7be-0585-4f43-ab97-f2436ea5e002)]
+[scriptable, uuid(747fdfa2-1754-4282-ab26-1e55fd8de13c)]
 interface nsIMsgSend : nsISupports
 {
   //
   // This is the primary interface for creating and sending RFC822 messages
   // in the new architecture. Currently, this method supports many arguments
   // that change the behavior of the operation. This will change in time to 
   // be separate calls that will be more singluar in nature.
   //
@@ -211,17 +212,17 @@ interface nsIMsgSend : nsISupports
                               in boolean aIsDigest,
                               in boolean aDontDeliver,
                               in nsMsgDeliverMode aMode,
                               in nsIMsgDBHdr aMsgToReplace,
                               in string aBodyType,
                               in ACString aBody,
                               in nsIArray aAttachments,
                               in nsIArray aPreloadedAttachments,
-                              in nsIDOMWindow aParentWindow,
+                              in mozIDOMWindowProxy aParentWindow,
                               in nsIMsgProgress aProgress,
                               in nsIMsgSendListener aListener,
                               in string aPassword,
                               in AUTF8String aOriginalMsgURI,
                               in MSG_ComposeType aType);
 
   /**
    * Creates a file containing an rfc822 message, using the passed information.
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -7,16 +7,17 @@
 #include "nsIDOMDocument.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMText.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsIDOMHTMLLinkElement.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsPIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsISelectionController.h"
 #include "nsMsgI18N.h"
 #include "nsMsgCompCID.h"
 #include "nsMsgQuote.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIDocumentEncoder.h"    // for editor output flags
 #include "nsMsgCompUtils.h"
@@ -884,32 +885,31 @@ nsMsgCompose::GetQuotingToFollow(bool* q
 {
   NS_ENSURE_ARG(quotingToFollow);
   *quotingToFollow = mQuotingToFollow;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMsgCompose::Initialize(nsIMsgComposeParams *aParams,
-                         nsIDOMWindow *aWindow,
+                         mozIDOMWindowProxy *aWindow,
                          nsIDocShell *aDocShell)
 {
   NS_ENSURE_ARG_POINTER(aParams);
   nsresult rv;
 
   aParams->GetIdentity(getter_AddRefs(m_identity));
 
   if (aWindow)
   {
     m_window = aWindow;
-    nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aWindow));
-    if (!window)
-      return NS_ERROR_FAILURE;
-
-    nsCOMPtr<nsIDocShellTreeItem>  treeItem =
+    nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow);
+    NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
+
+    nsCOMPtr<nsIDocShellTreeItem> treeItem =
       do_QueryInterface(window->GetDocShell());
     nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
     rv = treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
     if (NS_FAILED(rv)) return rv;
 
     m_baseWindow = do_QueryInterface(treeOwner);
 
     window->GetDocShell()->SetAppType(nsIDocShell::APP_TYPE_EDITOR);
@@ -1172,19 +1172,20 @@ nsMsgCompose::SendMsgToServer(MSG_Delive
 NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const char *accountKey, nsIMsgWindow *aMsgWindow, nsIMsgProgress *progress)
 {
 
   NS_ENSURE_TRUE(m_compFields, NS_ERROR_NOT_INITIALIZED);
   nsresult rv = NS_OK;
   nsCOMPtr<nsIPrompt> prompt;
 
   // i'm assuming the compose window is still up at this point...
-  nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(m_window));
-  if (window)
+  if (m_window) {
+    nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(m_window);
     window->GetPrompter(getter_AddRefs(prompt));
+  }
 
   // Set content type based on which type of compose window we had.
   nsString contentType = (m_composeHTML) ? NS_LITERAL_STRING("text/html"):
                                            NS_LITERAL_STRING("text/plain");
   nsString msgBody;
   if (m_editor)
   {
     // Reset message body previously stored in the compose fields
@@ -1560,28 +1561,28 @@ NS_IMETHODIMP nsMsgCompose::SetEditor(ns
   m_editor = aEditor;
   return NS_OK;
 }
 
 // This used to be called BEFORE editor was created
 //  (it did the loadUrl that triggered editor creation)
 // It is called from JS after editor creation
 //  (loadUrl is done in JS)
-NS_IMETHODIMP nsMsgCompose::InitEditor(nsIEditor* aEditor, nsIDOMWindow* aContentWindow)
+NS_IMETHODIMP nsMsgCompose::InitEditor(nsIEditor* aEditor, mozIDOMWindowProxy* aContentWindow)
 {
   NS_ENSURE_ARG_POINTER(aEditor);
   NS_ENSURE_ARG_POINTER(aContentWindow);
 
   m_editor = aEditor;
 
   // Set the charset
   const nsDependentCString msgCharSet(m_compFields->GetCharacterSet());
   m_editor->SetDocumentCharacterSet(msgCharSet);
 
-  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContentWindow);
+  nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aContentWindow);
 
   nsIDocShell *docShell = window->GetDocShell();
   NS_ENSURE_TRUE(docShell, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsIContentViewer> childCV;
   NS_ENSURE_SUCCESS(docShell->GetContentViewer(getter_AddRefs(childCV)), NS_ERROR_FAILURE);
   if (childCV)
   {
@@ -1644,17 +1645,17 @@ nsresult nsMsgCompose::SetBodyModified(b
     else
       m_editor->ResetModificationCount();
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsMsgCompose::GetDomWindow(nsIDOMWindow * *aDomWindow)
+nsMsgCompose::GetDomWindow(mozIDOMWindowProxy * *aDomWindow)
 {
   NS_IF_ADDREF(*aDomWindow = m_window);
   return NS_OK;
 }
 
 nsresult nsMsgCompose::GetCompFields(nsIMsgCompFields * *aCompFields)
 {
   *aCompFields = (nsIMsgCompFields*)m_compFields;
@@ -2713,20 +2714,21 @@ NS_IMETHODIMP QuotingOutputStreamListene
           compFields->SetTo(EmptyString());
       }
 
       if (!followUpTo.IsEmpty())
       {
         // Handle "followup-to: poster" magic keyword here
         if (followUpTo.EqualsLiteral("poster"))
         {
-          nsCOMPtr<nsIDOMWindow> domWindow;
+          nsCOMPtr<mozIDOMWindowProxy> domWindow;
           nsCOMPtr<nsIPrompt> prompt;
           compose->GetDomWindow(getter_AddRefs(domWindow));
-          nsCOMPtr<nsPIDOMWindow> composeWindow(do_QueryInterface(domWindow));
+          NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
+          nsCOMPtr<nsPIDOMWindowOuter> composeWindow = nsPIDOMWindowOuter::From(domWindow);
           if (composeWindow)
             composeWindow->GetPrompter(getter_AddRefs(prompt));
           nsMsgDisplayMessageByName(prompt, MOZ_UTF16("followupToSenderMessage"));
 
           if (!replyTo.IsEmpty())
           {
             compFields->SetTo(replyTo);
           }
@@ -3621,17 +3623,17 @@ nsresult nsMsgComposeSendListener::OnSto
       nsCOMPtr<nsIMsgCompFields> compFields;
       msgCompose->GetCompFields(getter_AddRefs(compFields));
 
       // only process the reply flags if we successfully sent the message
       msgCompose->ProcessReplyFlags();
 
       // See if there is a composer window
       bool hasDomWindow = true;
-      nsCOMPtr<nsIDOMWindow> domWindow;
+      nsCOMPtr<mozIDOMWindowProxy> domWindow;
       rv = msgCompose->GetDomWindow(getter_AddRefs(domWindow));
       if (NS_FAILED(rv) || !domWindow)
         hasDomWindow = false;
 
       // Close the window ONLY if we are not going to do a save operation
       nsAutoString fieldsFCC;
       if (NS_SUCCEEDED(compFields->GetFcc(fieldsFCC)))
       {
--- a/mailnews/compose/src/nsMsgCompose.h
+++ b/mailnews/compose/src/nsMsgCompose.h
@@ -16,45 +16,46 @@
 #include "nsIMsgCopyServiceListener.h"
 #include "nsIBaseWindow.h"
 #include "nsIAbDirectory.h"
 #include "nsIWebProgressListener.h"
 #include "nsIMimeConverter.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsIMsgFolder.h"
 #include "nsIDOMNode.h"
+#include "mozIDOMWindow.h"
 
 // Forward declares
 class QuotingOutputStreamListener;
 class nsMsgComposeSendListener;
 class nsIEditorMailSupport;
 class nsIRDFService;
 class nsIArray;
 struct nsMsgMailList;
 
 class nsMsgCompose : public nsIMsgCompose, public nsSupportsWeakReference
 {
  public: 
 
-	nsMsgCompose();
+  nsMsgCompose();
 
-	/* this macro defines QueryInterface, AddRef and Release for this class */
-	NS_DECL_THREADSAFE_ISUPPORTS
+  /* this macro defines QueryInterface, AddRef and Release for this class */
+  NS_DECL_THREADSAFE_ISUPPORTS
 
-	/*** nsIMsgCompose pure virtual functions */
-	NS_DECL_NSIMSGCOMPOSE
+  /*** nsIMsgCompose pure virtual functions */
+  NS_DECL_NSIMSGCOMPOSE
 
   /* nsIMsgSendListener interface */
   NS_DECL_NSIMSGSENDLISTENER
 
 protected:
-	virtual ~nsMsgCompose();
+  virtual ~nsMsgCompose();
 
  // Deal with quoting issues...
-	nsresult                      QuoteOriginalMessage(); // New template
+  nsresult                      QuoteOriginalMessage(); // New template
   nsresult                      SetQuotingToFollow(bool aVal);
   nsresult                      ConvertHTMLToText(nsIFile *aSigFile, nsString &aSigData);
   nsresult                      ConvertTextToHTML(nsIFile *aSigFile, nsString &aSigData);
   bool                          IsEmbeddedObjectSafe(const char * originalScheme,
                                                      const char * originalHost,
                                                      const char * originalPath,
                                                      nsIDOMNode * object);
   nsresult                      ResetUrisForEmbeddedObjects();
@@ -94,52 +95,52 @@ protected:
    * the relevant cards from the address books.
    */
   nsresult LookupAddressBook(RecipientsArray &recipientList);
   bool IsLastWindow();
  
        // Helper function. Parameters are not checked.
   bool                                      mConvertStructs;    // for TagConvertible
   
-	nsCOMPtr<nsIEditor>                       m_editor;
-	nsIDOMWindow                              *m_window;
+  nsCOMPtr<nsIEditor>                       m_editor;
+  mozIDOMWindowProxy                        *m_window;
   nsCOMPtr<nsIDocShell>                     mDocShell;
   nsCOMPtr<nsIBaseWindow>                   m_baseWindow;
-	nsMsgCompFields                           *m_compFields;
-	nsCOMPtr<nsIMsgIdentity>                  m_identity;
-	bool						                        m_composeHTML;
-	QuotingOutputStreamListener               *mQuoteStreamListener;
-	nsCOMPtr<nsIOutputStream>                 mBaseStream;
+  nsMsgCompFields                           *m_compFields;
+  nsCOMPtr<nsIMsgIdentity>                  m_identity;
+  bool                                      m_composeHTML;
+  QuotingOutputStreamListener               *mQuoteStreamListener;
+  nsCOMPtr<nsIOutputStream>                 mBaseStream;
 
   nsCOMPtr<nsIMsgComposeRecyclingListener>  mRecyclingListener;
   bool                                      mRecycledWindow;
-	nsCOMPtr<nsIMsgSend>                      mMsgSend;           // for composition back end
-	nsCOMPtr<nsIMsgProgress>                  mProgress;          // use by the back end to report progress to the front end
+  nsCOMPtr<nsIMsgSend>                      mMsgSend;           // for composition back end
+  nsCOMPtr<nsIMsgProgress>                  mProgress;          // use by the back end to report progress to the front end
 
   // Deal with quoting issues...
   nsString                                  mCiteReference;
-	nsCOMPtr<nsIMsgQuote>                     mQuote;
-	bool						                        mQuotingToFollow;   // Quoting indicator
-	MSG_ComposeType                           mType;		          // Message type
+  nsCOMPtr<nsIMsgQuote>                     mQuote;
+  bool                                      mQuotingToFollow;   // Quoting indicator
+  MSG_ComposeType                           mType;              // Message type
   bool                                      mCharsetOverride;
   bool                                      mDeleteDraft;
   nsMsgDispositionState                     mDraftDisposition;
   nsCOMPtr <nsIMsgDBHdr>                    mOrigMsgHdr;
 
   nsCString                                 mSmtpPassword;
   nsCString                                 mHtmlToQuote;
 
   nsTObserverArray<nsCOMPtr<nsIMsgComposeStateListener> > mStateListeners;
   nsTObserverArray<nsCOMPtr<nsIMsgSendListener> > mExternalSendListeners;
-    
+
   bool                                      mInsertingQuotedContent;
   MSG_DeliverMode                           mDeliverMode;  // nsIMsgCompDeliverMode long.
 
   friend class QuotingOutputStreamListener;
-	friend class nsMsgComposeSendListener;
+  friend class nsMsgComposeSendListener;
 };
 
 ////////////////////////////////////////////////////////////////////////////////////
 // THIS IS THE CLASS THAT IS THE STREAM Listener OF THE HTML OUPUT
 // FROM LIBMIME. THIS IS FOR QUOTING
 ////////////////////////////////////////////////////////////////////////////////////
 class QuotingOutputStreamListener : public nsIMsgQuotingOutputStreamListener
 {
@@ -164,32 +165,32 @@ public:
                                   bool delsp,
                                   bool formatted,
                                   bool disallowBreaks);
     NS_IMETHOD InsertToCompose(nsIEditor *aEditor, bool aHTMLEditor);
     NS_IMETHOD AppendToMsgBody(const nsCString &inStr);
 
 private:
     virtual ~QuotingOutputStreamListener();
-    nsWeakPtr                 mWeakComposeObj;
-    nsString       				    mMsgBody;
-    nsString       				    mCitePrefix;
-    nsString       				    mSignature;
-    bool						        mQuoteHeaders;
-    bool						        mHeadersOnly;
-    nsCOMPtr<nsIMimeHeaders>	mHeaders;
-    nsCOMPtr<nsIMsgIdentity>  mIdentity;
-    nsCOMPtr<nsIMsgDBHdr>     mOrigMsgHdr;
-    nsString                  mCiteReference;
-    nsCOMPtr<nsIMimeConverter> mMimeConverter;
+    nsWeakPtr                   mWeakComposeObj;
+    nsString                    mMsgBody;
+    nsString                    mCitePrefix;
+    nsString                    mSignature;
+    bool                        mQuoteHeaders;
+    bool                        mHeadersOnly;
+    nsCOMPtr<nsIMimeHeaders>    mHeaders;
+    nsCOMPtr<nsIMsgIdentity>    mIdentity;
+    nsCOMPtr<nsIMsgDBHdr>       mOrigMsgHdr;
+    nsString                    mCiteReference;
+    nsCOMPtr<nsIMimeConverter>  mMimeConverter;
     nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
-    int32_t                   mUnicodeBufferCharacterLength;
-    char16_t*                mUnicodeConversionBuffer;
-    bool                      mQuoteOriginal;
-    nsCString                 mHtmlToQuote;
+    int32_t                     mUnicodeBufferCharacterLength;
+    char16_t*                   mUnicodeConversionBuffer;
+    bool                        mQuoteOriginal;
+    nsCString                   mHtmlToQuote;
 };
 
 ////////////////////////////////////////////////////////////////////////////////////
 // This is the listener class for the send operation. We have to create this class 
 // to listen for message send completion and eventually notify the caller
 ////////////////////////////////////////////////////////////////////////////////////
 class nsMsgComposeSendListener : public nsIMsgComposeSendListener, public nsIMsgSendListener, public nsIMsgCopyServiceListener, public nsIWebProgressListener
 {
@@ -203,26 +204,26 @@ public:
   NS_DECL_NSIMSGCOMPOSESENDLISTENER
 
   // nsIMsgSendListener interface
   NS_DECL_NSIMSGSENDLISTENER
   
   // nsIMsgCopyServiceListener interface
   NS_DECL_NSIMSGCOPYSERVICELISTENER
   
-	// nsIWebProgressListener interface
-	NS_DECL_NSIWEBPROGRESSLISTENER
+  // nsIWebProgressListener interface
+  NS_DECL_NSIWEBPROGRESSLISTENER
 
   nsresult    RemoveCurrentDraftMessage(nsIMsgCompose *compObj, bool calledByCopy);
   nsresult    GetMsgFolder(nsIMsgCompose *compObj, nsIMsgFolder **msgFolder);
 
 private:
   virtual ~nsMsgComposeSendListener();
   nsWeakPtr               mWeakComposeObj;
-	MSG_DeliverMode         mDeliverMode;
+  MSG_DeliverMode         mDeliverMode;
 };
 
 /******************************************************************************
  * nsMsgMailList
  ******************************************************************************/
 struct nsMsgMailList
 {
   explicit nsMsgMailList(nsIAbDirectory* directory);
--- a/mailnews/compose/src/nsMsgComposeContentHandler.cpp
+++ b/mailnews/compose/src/nsMsgComposeContentHandler.cpp
@@ -8,17 +8,17 @@
 #include "nsMsgBaseCID.h"
 #include "nsMsgCompCID.h"
 #include "nsIChannel.h"
 #include "nsIURI.h"
 #include "plstr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsCOMPtr.h"
 #include "nsPIDOMWindow.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsNetUtil.h"
 #include "nsIMsgFolder.h"
 #include "nsIMsgIncomingServer.h"
@@ -41,20 +41,19 @@ nsMsgComposeContentHandler::~nsMsgCompos
 // Try to get an appropriate nsIMsgIdentity by going through the window, getting
 // the document's URI, then the corresponding nsIMsgDBHdr. Then find the server
 // associated with that header and get the first identity for it.
 nsresult nsMsgComposeContentHandler::GetBestIdentity(
   nsIInterfaceRequestor* aWindowContext, nsIMsgIdentity **aIdentity)
 {
   nsresult rv;
 
-  nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(aWindowContext);
-  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(domWindow);
-  if (!window)
-    return NS_ERROR_FAILURE;
+  nsCOMPtr<mozIDOMWindowProxy> domWindow = do_GetInterface(aWindowContext);
+  NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
+  nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(domWindow);
 
   nsAutoString documentURIString;
   window->GetDoc()->GetDocumentURI(documentURIString);
 
   nsCOMPtr<nsIURI> documentURI;
   rv = NS_NewURI(getter_AddRefs(documentURI), documentURIString);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -11,17 +11,17 @@
 #include "nsIMsgIdentity.h"
 #include "nsISmtpUrl.h"
 #include "nsIURI.h"
 #include "nsMsgI18N.h"
 #include "nsIMsgComposeParams.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIWindowWatcher.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIContentViewer.h"
 #include "nsIMsgWindow.h"
 #include "nsIDocShell.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIXULWindow.h"
@@ -248,17 +248,17 @@ nsMsgComposeService::OpenComposeWindowWi
       int32_t i;
       for (i = 0; i < mMaxRecycledWindows; i ++)
       {
         if (mCachedWindows[i].window && (mCachedWindows[i].htmlCompose == composeHTML) && mCachedWindows[i].listener)
         {
           /* We need to save the window pointer as OnReopen will call nsMsgComposeService::InitCompose which will
              clear the cache entry if everything goes well
           */
-          nsCOMPtr<nsIDOMWindow> domWindow(mCachedWindows[i].window);
+          nsCOMPtr<mozIDOMWindowProxy> domWindow(mCachedWindows[i].window);
           nsCOMPtr<nsIXULWindow> xulWindow(mCachedWindows[i].xulWindow);
           rv = ShowCachedComposeWindow(domWindow, xulWindow, true);
           if (NS_SUCCEEDED(rv))
           {
             mCachedWindows[i].listener->OnReopen(params);
             return NS_OK;
           }
         }
@@ -273,32 +273,32 @@ nsMsgComposeService::OpenComposeWindowWi
 
   nsCOMPtr<nsISupportsInterfacePointer> msgParamsWrapper =
     do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   msgParamsWrapper->SetData(params);
   msgParamsWrapper->SetDataIID(&NS_GET_IID(nsIMsgComposeParams));
 
-  nsCOMPtr<nsIDOMWindow> newWindow;
+  nsCOMPtr<mozIDOMWindowProxy> newWindow;
   rv = wwatch->OpenWindow(0, chrome && *chrome ? chrome : DEFAULT_CHROME,
                  "_blank", "all,chrome,dialog=no,status,toolbar", msgParamsWrapper,
                  getter_AddRefs(newWindow));
 
   return rv;
 }
 
-void nsMsgComposeService::CloseHiddenCachedWindow(nsIDOMWindow *domWindow)
+void nsMsgComposeService::CloseHiddenCachedWindow(mozIDOMWindowProxy *domWindow)
 {
   if (domWindow)
   {
     nsCOMPtr<nsIDocShell> docshell;
-    nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(domWindow));
-    if (window)
+    if (domWindow)
     {
+      nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(domWindow);
       nsCOMPtr<nsIDocShellTreeItem> treeItem =
         do_QueryInterface(window->GetDocShell());
 
       if (treeItem)
       {
         nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
         treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
         if (treeOwner)
@@ -415,20 +415,19 @@ nsMsgComposeService::GetOrigWindowSelect
   nsCOMPtr<nsIDocShellTreeItem> childAsItem;
   rv = rootDocShell->FindChildWithName(MOZ_UTF16("messagepane"),
                                        true, false, nullptr, nullptr, getter_AddRefs(childAsItem));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(childAsItem, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(childAsItem, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
-  nsCOMPtr<nsPIDOMWindow> privateWindow(do_QueryInterface(domWindow, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<mozIDOMWindow> domWindow(do_GetInterface(childAsItem));
+  NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
+  nsCOMPtr<nsPIDOMWindowInner> privateWindow = nsPIDOMWindowInner::From(domWindow);
   nsCOMPtr<nsISelection> sel = privateWindow->GetSelection();
   NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE);
 
   bool requireMultipleWords = true;
   nsAutoCString charsOnlyIf;
   prefs->GetBoolPref(PREF_MAILNEWS_REPLY_QUOTING_SELECTION_MULTI_WORD, &requireMultipleWords);
   prefs->GetCharPref(PREF_MAILNEWS_REPLY_QUOTING_SELECTION_ONLY_IF, getter_Copies(charsOnlyIf));
   if (sel && (requireMultipleWords || !charsOnlyIf.IsEmpty()))
@@ -706,17 +705,17 @@ NS_IMETHODIMP nsMsgComposeService::OpenC
   if (NS_SUCCEEDED(rv)) {
     pMsgComposeParams->SetIdentity(identity);
     rv = OpenComposeWindowWithParams(aMsgComposeWindowURL, pMsgComposeParams);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsMsgComposeService::InitCompose(nsIMsgComposeParams *aParams,
-                                               nsIDOMWindow *aWindow,
+                                               mozIDOMWindowProxy *aWindow,
                                                nsIDocShell *aDocShell,
                                                nsIMsgCompose **_retval)
 {
   // We need to remove the window from the cache.
   int32_t i;
   for (i = 0; i < mMaxRecycledWindows; i ++)
     if (mCachedWindows[i].window == aWindow)
     {
@@ -787,17 +786,17 @@ NS_IMETHODIMP nsMsgComposeService::TimeS
 ((double)totalTime/1000.0) + 0.005, ((double)deltaTime/1000.0) + 0.005, label));
 
   mPreviousTime = now;
 #endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgComposeService::IsCachedWindow(nsIDOMWindow *aCachedWindow, bool *aIsCachedWindow)
+nsMsgComposeService::IsCachedWindow(mozIDOMWindowProxy *aCachedWindow, bool *aIsCachedWindow)
 {
   NS_ENSURE_ARG_POINTER(aCachedWindow);
   NS_ENSURE_ARG_POINTER(aIsCachedWindow);
 
   int32_t i;
   for (i = 0; i < mMaxRecycledWindows; i ++)
     if (mCachedWindows[i].window.get() == aCachedWindow)
     {
@@ -805,24 +804,23 @@ nsMsgComposeService::IsCachedWindow(nsID
       return NS_OK;
     }
 
  *aIsCachedWindow = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgComposeService::CacheWindow(nsIDOMWindow *aWindow, bool aComposeHTML, nsIMsgComposeRecyclingListener * aListener)
+nsMsgComposeService::CacheWindow(mozIDOMWindowProxy *aWindow, bool aComposeHTML, nsIMsgComposeRecyclingListener * aListener)
 {
   NS_ENSURE_ARG_POINTER(aWindow);
   NS_ENSURE_ARG_POINTER(aListener);
 
   nsresult rv;
-  nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aWindow, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aWindow);
 
   nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(window->GetDocShell(), &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr <nsIDocShellTreeOwner> treeOwner;
   rv = treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
   NS_ENSURE_SUCCESS(rv,rv);
 
@@ -918,17 +916,17 @@ NS_IMETHODIMP nsMsgTemplateReplyHelper::
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgTemplateReplyHelper::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
 {
   NS_ENSURE_SUCCESS(aExitCode, aExitCode);
   nsresult rv;
-  nsCOMPtr<nsIDOMWindow> parentWindow;
+  nsCOMPtr<nsPIDOMWindowOuter> parentWindow;
   if (mMsgWindow)
   {
     nsCOMPtr<nsIDocShell> docShell;
     rv = mMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
     NS_ENSURE_SUCCESS(rv, rv);
     parentWindow = do_GetInterface(docShell);
     NS_ENSURE_TRUE(parentWindow, NS_ERROR_FAILURE);
   }
@@ -1247,17 +1245,17 @@ nsMsgComposeService::ForwardMessage(cons
   if (aForwardType == nsIMsgComposeService::kForwardInline)
     return RunMessageThroughMimeDraft(msgUri,
                                       nsMimeOutput::nsMimeMessageDraftOrTemplate,
                                       identity,
                                       msgUri.get(), aMsgHdr,
                                       true, forwardTo,
                                       false, aMsgWindow);
 
-  nsCOMPtr<nsIDOMWindow> parentWindow;
+  nsCOMPtr<mozIDOMWindowProxy> parentWindow;
   if (aMsgWindow)
   {
     nsCOMPtr<nsIDocShell> docShell;
     rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
     NS_ENSURE_SUCCESS(rv, rv);
     parentWindow = do_GetInterface(docShell);
     NS_ENSURE_TRUE(parentWindow, NS_ERROR_FAILURE);
   }
@@ -1287,27 +1285,26 @@ nsMsgComposeService::ForwardMessage(cons
   // nsMsgCompose::ProcessReplyFlags usually takes care of marking messages
   // as forwarded. ProcessReplyFlags is normally called from
   // nsMsgComposeSendListener::OnStopSending but for this case the msgCompose
   // object is not set so ProcessReplyFlags won't get called.
   // Therefore, let's just mark it here instead.
   return folder->AddMessageDispositionState(aMsgHdr, nsIMsgFolder::nsMsgDispositionState_Forwarded);
 }
 
-nsresult nsMsgComposeService::ShowCachedComposeWindow(nsIDOMWindow *aComposeWindow, nsIXULWindow *aXULWindow, bool aShow)
+nsresult nsMsgComposeService::ShowCachedComposeWindow(mozIDOMWindowProxy *aComposeWindow, nsIXULWindow *aXULWindow, bool aShow)
 {
   nsresult rv = NS_OK;
 
   nsCOMPtr<nsIObserverService> obs =
     mozilla::services::GetObserverService();
   NS_ENSURE_TRUE(obs, NS_ERROR_UNEXPECTED);
 
-  nsCOMPtr <nsPIDOMWindow> window = do_QueryInterface(aComposeWindow, &rv);
-
-  NS_ENSURE_SUCCESS(rv,rv);
+  NS_ENSURE_TRUE(aComposeWindow, NS_ERROR_FAILURE);
+  nsCOMPtr <nsPIDOMWindowOuter> window = nsPIDOMWindowOuter::From(aComposeWindow);
 
   nsIDocShell *docShell = window->GetDocShell();
 
   nsCOMPtr <nsIDocShellTreeItem> treeItem = do_QueryInterface(docShell, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsCOMPtr <nsIDocShellTreeOwner> treeOwner;
   rv = treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
@@ -1730,17 +1727,17 @@ nsMsgComposeService::Handle(nsICommandLi
 
     nsCOMPtr<nsIWindowWatcher> wwatch (do_GetService(NS_WINDOWWATCHER_CONTRACTID));
     NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsISupportsString> arg(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
     if (arg)
       arg->SetData(uristr);
 
-    nsCOMPtr<nsIDOMWindow> opened;
+    nsCOMPtr<mozIDOMWindowProxy> opened;
     wwatch->OpenWindow(nullptr, DEFAULT_CHROME, "_blank",
                        "chrome,dialog=no,all", arg, getter_AddRefs(opened));
 
     aCmdLine->SetPreventDefault(true);
   }
   return NS_OK;
 }
 
--- a/mailnews/compose/src/nsMsgComposeService.h
+++ b/mailnews/compose/src/nsMsgComposeService.h
@@ -2,44 +2,44 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #define MSGCOMP_TRACE_PERFORMANCE 1
 
 #include "nsIMsgComposeService.h"
 #include "nsCOMPtr.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIXULWindow.h"
 #include "nsIObserver.h"
 #include "nsWeakReference.h"
 #include "nsIMimeStreamConverter.h"
 #include "nsInterfaceHashtable.h"
 
 #include "nsICommandLineHandler.h"
 #define ICOMMANDLINEHANDLER nsICommandLineHandler
 
 class nsMsgCachedWindowInfo
 {
 public:
-  void Initialize(nsIDOMWindow *aWindow, nsIXULWindow *aXULWindow, nsIMsgComposeRecyclingListener *aListener, bool aHtmlCompose)
+  void Initialize(mozIDOMWindowProxy *aWindow, nsIXULWindow *aXULWindow, nsIMsgComposeRecyclingListener *aListener, bool aHtmlCompose)
   {
     window = aWindow;
     xulWindow = aXULWindow;
     listener = aListener;
     htmlCompose = aHtmlCompose;
   }
     
   void Clear()
   {
     window = nullptr;
     listener = nullptr;
   }
   
-  nsCOMPtr<nsIDOMWindow>                    window;
+  nsCOMPtr<mozIDOMWindowProxy>              window;
   nsCOMPtr<nsIXULWindow>                    xulWindow;
   nsCOMPtr<nsIMsgComposeRecyclingListener>  listener;
   bool                                      htmlCompose;
 };
 
 class nsMsgComposeService : 
   public nsIMsgComposeService,
   public nsIObserver,
@@ -61,17 +61,17 @@ public:
 
 private:
 	virtual ~nsMsgComposeService();
   bool mLogComposePerformance;
 
   int32_t mMaxRecycledWindows;
   nsMsgCachedWindowInfo *mCachedWindows;
   
-  void CloseHiddenCachedWindow(nsIDOMWindow *domWindow);
+  void CloseHiddenCachedWindow(mozIDOMWindowProxy *domWindow);
 
   nsresult LoadDraftOrTemplate(const nsACString& aMsgURI, nsMimeOutputType aOutType, 
                                nsIMsgIdentity * aIdentity, const char * aOriginalMsgURI, 
                                nsIMsgDBHdr * aOrigMsgHdr, bool aForwardInline,
                                bool overrideComposeFormat,
                                nsIMsgWindow *aMsgWindow);
 
   nsresult RunMessageThroughMimeDraft(const nsACString& aMsgURI,
@@ -79,17 +79,17 @@ private:
                                       nsIMsgIdentity * aIdentity,
                                       const char * aOriginalMsgURI,
                                       nsIMsgDBHdr * aOrigMsgHdr,
                                       bool aForwardInline,
                                       const nsAString &forwardTo,
                                       bool overrideComposeFormat,
                                       nsIMsgWindow *aMsgWindow);
 
-  nsresult ShowCachedComposeWindow(nsIDOMWindow *aComposeWindow, nsIXULWindow *aXULWindow, bool aShow);
+  nsresult ShowCachedComposeWindow(mozIDOMWindowProxy *aComposeWindow, nsIXULWindow *aXULWindow, bool aShow);
 
   // hash table mapping dom windows to nsIMsgCompose objects
   nsInterfaceHashtable<nsISupportsHashKey, nsIWeakReference> mOpenComposeWindows;
 
   // When doing a reply and the settings are enabled, get the HTML of the selected text
   // in the original message window so that it can be quoted instead of the entire message.
   nsresult GetOrigWindowSelection(MSG_ComposeType type, nsIMsgWindow *aMsgWindow, nsACString& aSelHTML);
 
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -75,16 +75,17 @@
 #include "nsIArray.h"
 #include "nsArrayUtils.h"
 #include "mozilla/Services.h"
 #include "mozilla/mailnews/MimeEncoder.h"
 #include "mozilla/mailnews/MimeHeaderParser.h"
 #include "nsIMutableArray.h"
 #include "nsIMsgFilterService.h"
 #include "nsIMsgProtocolInfo.h"
+#include "mozIDOMWindow.h"
 
 using namespace mozilla::mailnews;
 
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 
 #define PREF_MAIL_SEND_STRUCT "mail.send_struct"
 #define PREF_MAIL_STRICTLY_MIME "mail.strictly_mime"
 #define PREF_MAIL_MESSAGE_WARNING_SIZE "mailnews.message_warning_size"
@@ -3992,17 +3993,17 @@ nsMsgComposeAndSend::CreateAndSendMessag
               bool                              digest_p,
               bool                              dont_deliver_p,
               nsMsgDeliverMode                  mode,
               nsIMsgDBHdr                       *msgToReplace,
               const char                        *attachment1_type,
               const nsACString                  &attachment1_body,
               nsIArray *attachments,
               nsIArray *preloaded_attachments,
-              nsIDOMWindow                      *parentWindow,
+              mozIDOMWindowProxy                *parentWindow,
               nsIMsgProgress                    *progress,
               nsIMsgSendListener                *aListener,
               const char                        *password,
               const nsACString                  &aOriginalMsgURI,
               MSG_ComposeType                   aType
               )
 {
   nsresult      rv;
--- a/mailnews/compose/src/nsMsgSend.h
+++ b/mailnews/compose/src/nsMsgSend.h
@@ -279,17 +279,17 @@ public:
                                                  // created, instead of actually delivering message.
   nsMsgDeliverMode          m_deliver_mode;      // nsMsgDeliverNow, nsMsgQueueForLater, nsMsgSaveAsDraft,
                                                  // nsMsgSaveAsTemplate and nsMsgSendUnsent
   nsCOMPtr<nsIMsgDBHdr>     mMsgToReplace;       // If the mode is nsMsgSaveAsDraft, this is the message it will
                                                  // replace
   nsString mSavedToFolderName; // Name of folder we're saving to, used when
                                // displaying error on save.
   // These are needed for callbacks to the FE...
-  nsCOMPtr<nsPIDOMWindow>         mParentWindow;
+  nsCOMPtr<nsPIDOMWindowOuter>    mParentWindow;
   nsCOMPtr<nsIMsgProgress>        mSendProgress;
   nsCOMPtr<nsIMsgSendListener>    mListener;
   nsCOMPtr<nsIMsgStatusFeedback>  mStatusFeedback;
   nsCOMPtr<nsIRequest>      mRunningRequest;
   bool                      mSendMailAlso;
   nsCOMPtr<nsIFile>         mReturnFile;     // a holder for file spec's to be returned to caller
 
   // File where we stored our HTML so that we could make the plaintext form.
--- a/mailnews/local/src/nsPop3Sink.cpp
+++ b/mailnews/local/src/nsPop3Sink.cpp
@@ -24,17 +24,17 @@
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIPrompt.h"
 #include "nsIPromptService.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDocShell.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsEmbedCID.h"
 #include "nsMsgUtils.h"
 #include "nsMsgBaseCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIPop3Service.h"
 #include "nsMsgLocalCID.h"
 #include "mozilla/Services.h"
 
@@ -679,17 +679,17 @@ nsresult nsPop3Sink::HandleTempDownloadF
   nsString fromStr, subjectStr, confirmString;
 
   m_newMailParser->m_newMsgHdr->GetMime2DecodedSubject(subjectStr);
   m_newMailParser->m_newMsgHdr->GetMime2DecodedAuthor(fromStr);
   const char16_t *params[] = { fromStr.get(), subjectStr.get() };
   bundle->FormatStringFromName(
     MOZ_UTF16("pop3TmpDownloadError"),
     params, 2, getter_Copies(confirmString));
-  nsCOMPtr<nsIDOMWindow> parentWindow;
+  nsCOMPtr<mozIDOMWindowProxy> parentWindow;
   nsCOMPtr<nsIPromptService> promptService = do_GetService(NS_PROMPTSERVICE_CONTRACTID);
   nsCOMPtr<nsIDocShell> docShell;
   if (msgWindow)
   {
     (void) msgWindow->GetRootDocShell(getter_AddRefs(docShell));
     parentWindow = do_QueryInterface(docShell);
   }
   if (promptService && !confirmString.IsEmpty())
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -10,17 +10,17 @@
 #include <direct.h>
 #include "nsCOMPtr.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsISupports.h"
 #include "nsIPromptService.h"
 #include "nsIAppStartup.h"
 #include "nsIAppShellService.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsINativeAppSupport.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
 #include "nsIStringBundle.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsStringGlue.h"
 #include "nsUnicharUtils.h"
@@ -282,17 +282,17 @@ nsresult nsMapiHook::BlindSendMail (unsi
 {
   nsresult rv = NS_OK ;
 
   if (!IsBlindSendAllowed())
     return NS_ERROR_FAILURE;
 
   /** create nsIMsgComposeParams obj and other fields to populate it **/
 
-  nsCOMPtr<nsIDOMWindow>  hiddenWindow;
+  nsCOMPtr<mozIDOMWindowProxy> hiddenWindow;
   // get parent window
   nsCOMPtr<nsIAppShellService> appService = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv);
   if (NS_FAILED(rv)|| (!appService) ) return rv ;
 
   rv = appService->GetHiddenDOMWindow(getter_AddRefs(hiddenWindow));
   if ( NS_FAILED(rv) ) return rv ;
   // smtp password and Logged in used IdKey from MapiConfig (session obj)
   nsMAPIConfiguration * pMapiConfig = nsMAPIConfiguration::GetMAPIConfiguration() ;
--- a/mailnews/news/src/nsNNTPNewsgroupList.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupList.cpp
@@ -14,17 +14,17 @@
 #include "msgCore.h"    // precompiled header...
 #include "MailNewsTypes.h"
 #include "nsCOMPtr.h"
 #include "nsIDBFolderInfo.h"
 #include "nsINewsDatabase.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsCOMPtr.h"
 #include "nsPIDOMWindow.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsINntpIncomingServer.h"
 #include "nsMsgBaseCID.h"
 #include "nsIMsgFilter.h"
 #include "nsNNTPNewsgroupList.h"
 
@@ -221,29 +221,29 @@ openWindow(nsIMsgWindow *aMsgWindow, con
 {
   nsresult rv;
   NS_ENSURE_ARG_POINTER(aMsgWindow);
   nsCOMPtr<nsIDocShell> docShell;
   rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
   if (NS_FAILED(rv))
       return rv;
 
-  nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(docShell));
-  nsCOMPtr<nsPIDOMWindow> parentWindow(do_QueryInterface(domWindow));
-  NS_ENSURE_TRUE(parentWindow, NS_ERROR_FAILURE);
+  nsCOMPtr<mozIDOMWindowProxy> domWindow(do_GetInterface(docShell));
+  NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
+  nsCOMPtr<nsPIDOMWindowOuter> parentWindow = nsPIDOMWindowOuter::From(domWindow);
   parentWindow = parentWindow->GetOuterWindow();
   NS_ENSURE_ARG_POINTER(parentWindow);
 
   nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   ifptr->SetData(param);
   ifptr->SetDataIID(&NS_GET_IID(nsINewsDownloadDialogArgs));
 
-  nsCOMPtr<nsIDOMWindow> dialogWindow;
+  nsCOMPtr<nsPIDOMWindowOuter> dialogWindow;
   rv = parentWindow->OpenDialog(NS_ConvertASCIItoUTF16(chromeURL),
                                 NS_LITERAL_STRING("_blank"),
                                 NS_LITERAL_STRING("centerscreen,chrome,modal,titlebar"),
                                 ifptr, getter_AddRefs(dialogWindow));
 
   return rv;
 }
 
--- a/mailnews/news/src/nsNntpService.cpp
+++ b/mailnews/news/src/nsNntpService.cpp
@@ -25,17 +25,17 @@
 #include "nsIMsgAccountManager.h"
 #include "nsIMessengerMigrator.h"
 #include "nsINntpIncomingServer.h"
 #include "nsICategoryManager.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIMessengerWindowService.h"
 #include "nsIWindowMediator.h"
-#include "nsIDOMWindow.h"
+#include "mozIDOMWindow.h"
 #include "nsIMsgSearchSession.h"
 #include "nsMailDirServiceDefs.h"
 #include "nsIWebNavigation.h"
 #include "nsIIOService.h"
 #include "nsNetCID.h"
 #include "nsIPrompt.h"
 #include "nsNewsDownloader.h"
 #include "prprf.h"
@@ -1615,17 +1615,17 @@ nsNntpService::Handle(nsICommandLine* aC
   nsresult rv;
   bool found;
 
   rv = aCmdLine->HandleFlag(NS_LITERAL_STRING("news"), false, &found);
   if (NS_SUCCEEDED(rv) && found) {
     nsCOMPtr<nsIWindowWatcher> wwatch (do_GetService(NS_WINDOWWATCHER_CONTRACTID));
     NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
 
-    nsCOMPtr<nsIDOMWindow> opened;
+    nsCOMPtr<mozIDOMWindowProxy> opened;
     wwatch->OpenWindow(nullptr, "chrome://messenger/content/", "_blank",
                        "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar",
                        nullptr, getter_AddRefs(opened));
     aCmdLine->SetPreventDefault(true);
   }
 
   return NS_OK;
 }
@@ -1689,17 +1689,17 @@ nsNntpService::HandleContent(const char 
           nsCOMPtr<nsIWindowWatcher> wwatcher =
             do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
           NS_ENSURE_SUCCESS(rv, rv);
 
           nsCOMPtr<nsISupportsCString> arg =
             do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID);
           arg->SetData(folderURL);
 
-          nsCOMPtr<nsIDOMWindow> newWindow;
+          nsCOMPtr<mozIDOMWindowProxy> newWindow;
           rv = wwatcher->OpenWindow(nullptr, "chrome://messenger/content/",
             "_blank", "chome,all,dialog=no", arg, getter_AddRefs(newWindow));
           NS_ENSURE_SUCCESS(rv, rv);
         }
       }
       if (msgWindow)
       {
         nsCOMPtr<nsIMsgWindowCommands> windowCommands;