Bug 1414974 - Part 2: Switch many consumers to nsGlobalWindow{Inner,Outer}, r=smaug
authorNika Layzell <nika@thelayzells.com>
Fri, 03 Nov 2017 18:25:38 -0400
changeset 444269 ff6e961b87dc1163c5efe35da2e334c6723a14e1
parent 444268 e71c83eb16f68be36a10ebe1be36a282e0bbe458
child 444270 5b48b5a65a462aa7f0f83d5c2acac2061d493509
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1414974
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1414974 - Part 2: Switch many consumers to nsGlobalWindow{Inner,Outer}, r=smaug This is a large patch which tries to switch many of the external consumers of nsGlobalWindow to instead use the new Inner or Outer variants. MozReview-Commit-ID: 99648Lm46T5
accessible/generic/RootAccessible.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
dom/animation/AnimationUtils.cpp
dom/base/BarProps.cpp
dom/base/BarProps.h
dom/base/Location.cpp
dom/base/Navigator.cpp
dom/base/PostMessageEvent.cpp
dom/base/PostMessageEvent.h
dom/base/ScreenOrientation.cpp
dom/base/Timeout.h
dom/base/TimeoutManager.cpp
dom/base/TimeoutManager.h
dom/base/WebSocket.cpp
dom/base/WindowNamedPropertiesHandler.cpp
dom/base/WindowOrientationObserver.cpp
dom/base/WindowOrientationObserver.h
dom/base/nsCCUncollectableMarker.cpp
dom/base/nsContentUtils.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMMutationObserver.h
dom/base/nsDOMWindowUtils.cpp
dom/base/nsDOMWindowUtils.h
dom/base/nsDocument.cpp
dom/base/nsFrameLoader.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsINode.cpp
dom/base/nsJSEnvironment.cpp
dom/base/nsJSTimeoutHandler.cpp
dom/base/nsJSUtils.cpp
dom/base/nsWindowMemoryReporter.cpp
dom/base/nsWindowRoot.cpp
dom/bindings/BindingUtils.cpp
dom/bindings/CallbackObject.cpp
dom/bindings/nsScriptError.cpp
dom/canvas/CanvasRenderingContext2D.h
dom/console/Console.cpp
dom/events/DOMEventTargetHelper.cpp
dom/events/Event.cpp
dom/events/EventStateManager.cpp
dom/events/MouseEvent.cpp
dom/events/TouchEvent.cpp
dom/events/XULCommandEvent.cpp
dom/flyweb/FlyWebPublishedServer.cpp
dom/flyweb/FlyWebService.cpp
dom/gamepad/GamepadManager.cpp
dom/gamepad/GamepadManager.h
dom/geolocation/nsGeolocation.cpp
dom/html/HTMLBodyElement.cpp
dom/html/HTMLFrameSetElement.cpp
dom/html/TextTrackManager.cpp
dom/html/nsGenericHTMLElement.cpp
dom/html/nsHTMLDocument.cpp
dom/indexedDB/IDBFactory.cpp
dom/ipc/TabChild.cpp
dom/media/MediaManager.cpp
dom/media/TextTrack.cpp
dom/media/TextTrackList.cpp
dom/media/webrtc/MediaEngineTabVideoSource.cpp
dom/plugins/base/nsNPAPIPlugin.cpp
dom/presentation/PresentationRequest.cpp
dom/promise/Promise.cpp
dom/script/ScriptSettings.cpp
dom/script/ScriptSettings.h
dom/vr/VREventObserver.cpp
dom/vr/VREventObserver.h
dom/workers/ServiceWorkerClient.cpp
dom/workers/ServiceWorkerManager.cpp
dom/workers/ServiceWorkerWindowClient.cpp
dom/workers/WorkerRunnable.cpp
gfx/vr/ipc/VRManagerChild.cpp
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCJSContext.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/xpcpublic.h
js/xpconnect/wrappers/AccessCheck.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
layout/base/nsDocumentViewer.cpp
layout/style/CSS.cpp
layout/xul/nsXULPopupManager.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
media/webrtc/signaling/test/signaling_unittests.cpp
netwerk/ipc/NeckoChild.cpp
toolkit/components/perfmonitoring/nsPerformanceStats.cpp
toolkit/components/windowwatcher/nsWindowWatcher.cpp
toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
toolkit/xre/nsNativeAppSupportWin.cpp
xpfe/appshell/nsWindowMediator.cpp
--- a/accessible/generic/RootAccessible.cpp
+++ b/accessible/generic/RootAccessible.cpp
@@ -480,17 +480,18 @@ RootAccessible::Shutdown()
 
 Relation
 RootAccessible::RelationByType(RelationType aType)
 {
   if (!mDocumentNode || aType != RelationType::EMBEDS)
     return DocAccessibleWrap::RelationByType(aType);
 
   if (nsPIDOMWindowOuter* rootWindow = mDocumentNode->GetWindow()) {
-    nsCOMPtr<nsPIDOMWindowOuter> contentWindow = nsGlobalWindow::Cast(rootWindow)->GetContent();
+    nsCOMPtr<nsPIDOMWindowOuter> contentWindow =
+      nsGlobalWindowOuter::Cast(rootWindow)->GetContent();
     if (contentWindow) {
       nsCOMPtr<nsIDocument> contentDocumentNode = contentWindow->GetDoc();
       if (contentDocumentNode) {
         DocAccessible* contentDocument =
           GetAccService()->GetDocAccessible(contentDocumentNode);
         if (contentDocument)
           return Relation(contentDocument);
       }
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -3269,17 +3269,17 @@ nsDocShell::GetCustomUserAgent(nsAString
   aCustomUserAgent = mCustomUserAgent;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetCustomUserAgent(const nsAString& aCustomUserAgent)
 {
   mCustomUserAgent = aCustomUserAgent;
-  RefPtr<nsGlobalWindow> win = mScriptGlobal ?
+  RefPtr<nsGlobalWindowInner> win = mScriptGlobal ?
     mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
   if (win) {
     Navigator* navigator = win->Navigator();
     if (navigator) {
       navigator->ClearUserAgentCache();
     }
   }
 
@@ -3774,17 +3774,17 @@ nsDocShell::CanAccessItem(nsIDocShellTre
 
   return CanAccessItem(openerItem, aAccessingItem, false);
 }
 
 static bool
 ItemIsActive(nsIDocShellTreeItem* aItem)
 {
   if (nsCOMPtr<nsPIDOMWindowOuter> window = aItem->GetWindow()) {
-    auto* win = nsGlobalWindow::Cast(window);
+    auto* win = nsGlobalWindowOuter::Cast(window);
     MOZ_ASSERT(win->IsOuterWindow());
     if (!win->GetClosedOuter()) {
       return true;
     }
   }
 
   return false;
 }
@@ -10614,18 +10614,18 @@ nsDocShell::InternalLoad(nsIURI* aURI,
       UpdateGlobalHistoryTitle(aURI);
 
       SetDocCurrentStateObj(mOSHE);
 
       // Inform the favicon service that the favicon for oldURI also
       // applies to aURI.
       CopyFavicon(currentURI, aURI, doc->NodePrincipal(), UsePrivateBrowsing());
 
-      RefPtr<nsGlobalWindow> scriptGlobal = mScriptGlobal;
-      RefPtr<nsGlobalWindow> win = scriptGlobal ?
+      RefPtr<nsGlobalWindowOuter> scriptGlobal = mScriptGlobal;
+      RefPtr<nsGlobalWindowInner> win = scriptGlobal ?
         scriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
 
       // ScrollToAnchor doesn't necessarily cause us to scroll the window;
       // the function decides whether a scroll is appropriate based on the
       // arguments it receives.  But even if we don't end up scrolling,
       // ScrollToAnchor performs other important tasks, such as informing
       // the presShell that we have a new hash.  See bug 680257.
       rv = ScrollToAnchor(curURIHasRef, newURIHasRef, newHash, aLoadType);
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -72,17 +72,18 @@ namespace dom {
 class EventTarget;
 class PendingGlobalHistoryEntry;
 typedef uint32_t ScreenOrientationInternal;
 } // namespace dom
 } // namespace mozilla
 
 class nsDocShell;
 class nsDOMNavigationTiming;
-class nsGlobalWindow;
+class nsGlobalWindowOuter;
+class nsGlobalWindowInner;
 class nsIController;
 class nsIScrollableFrame;
 class OnLinkClickEvent;
 class nsDSURIContentListener;
 class nsDocShellEditorData;
 class nsIClipboardDragDropHookList;
 class nsICommandManager;
 class nsIContentViewer;
@@ -913,17 +914,17 @@ protected:
   RefPtr<nsDSURIContentListener> mContentListener;
   nsCOMPtr<nsIContentViewer> mContentViewer;
   nsCOMPtr<nsIWidget> mParentWidget;
 
   // mCurrentURI should be marked immutable on set if possible.
   nsCOMPtr<nsIURI> mCurrentURI;
   nsCOMPtr<nsIURI> mReferrerURI;
   uint32_t mReferrerPolicy;
-  RefPtr<nsGlobalWindow> mScriptGlobal;
+  RefPtr<nsGlobalWindowOuter> mScriptGlobal;
   nsCOMPtr<nsISHistory> mSessionHistory;
   nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
   nsCOMPtr<nsIWebBrowserFind> mFind;
   nsCOMPtr<nsICommandManager> mCommandManager;
   // Reference to the SHEntry for this docshell until the page is destroyed.
   // Somebody give me better name
   nsCOMPtr<nsISHEntry> mOSHE;
   // Reference to the SHEntry for this docshell until the page is loaded
--- a/dom/animation/AnimationUtils.cpp
+++ b/dom/animation/AnimationUtils.cpp
@@ -37,17 +37,17 @@ AnimationUtils::LogAsyncAnimationFailure
   }
   aMessage.Append('\n');
   printf_stderr("%s", aMessage.get());
 }
 
 /* static */ nsIDocument*
 AnimationUtils::GetCurrentRealmDocument(JSContext* aCx)
 {
-  nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx);
+  nsGlobalWindowInner* win = xpc::CurrentWindowOrNull(aCx);
   if (!win) {
     return nullptr;
   }
   return win->GetDoc();
 }
 
 /* static */ bool
 AnimationUtils::IsOffscreenThrottlingEnabled()
--- a/dom/base/BarProps.cpp
+++ b/dom/base/BarProps.cpp
@@ -13,17 +13,17 @@
 #include "nsIWebBrowserChrome.h"
 
 namespace mozilla {
 namespace dom {
 
 //
 //  Basic (virtual) BarProp class implementation
 //
-BarProp::BarProp(nsGlobalWindow* aWindow)
+BarProp::BarProp(nsGlobalWindowInner* aWindow)
   : mDOMWindow(aWindow)
 {
   MOZ_ASSERT(aWindow->IsInnerWindow());
 }
 
 BarProp::~BarProp()
 {
 }
@@ -101,17 +101,17 @@ BarProp::GetBrowserChrome()
 
   return mDOMWindow->GetWebBrowserChrome();
 }
 
 //
 // MenubarProp class implementation
 //
 
-MenubarProp::MenubarProp(nsGlobalWindow *aWindow)
+MenubarProp::MenubarProp(nsGlobalWindowInner *aWindow)
   : BarProp(aWindow)
 {
 }
 
 MenubarProp::~MenubarProp()
 {
 }
 
@@ -127,17 +127,17 @@ MenubarProp::SetVisible(bool aVisible, C
   BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_MENUBAR,
                             aCallerType, aRv);
 }
 
 //
 // ToolbarProp class implementation
 //
 
-ToolbarProp::ToolbarProp(nsGlobalWindow *aWindow)
+ToolbarProp::ToolbarProp(nsGlobalWindowInner *aWindow)
   : BarProp(aWindow)
 {
 }
 
 ToolbarProp::~ToolbarProp()
 {
 }
 
@@ -153,17 +153,17 @@ ToolbarProp::SetVisible(bool aVisible, C
   BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_TOOLBAR,
                             aCallerType, aRv);
 }
 
 //
 // LocationbarProp class implementation
 //
 
-LocationbarProp::LocationbarProp(nsGlobalWindow *aWindow)
+LocationbarProp::LocationbarProp(nsGlobalWindowInner *aWindow)
   : BarProp(aWindow)
 {
 }
 
 LocationbarProp::~LocationbarProp()
 {
 }
 
@@ -181,17 +181,17 @@ LocationbarProp::SetVisible(bool aVisibl
   BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_LOCATIONBAR,
                             aCallerType, aRv);
 }
 
 //
 // PersonalbarProp class implementation
 //
 
-PersonalbarProp::PersonalbarProp(nsGlobalWindow *aWindow)
+PersonalbarProp::PersonalbarProp(nsGlobalWindowInner *aWindow)
   : BarProp(aWindow)
 {
 }
 
 PersonalbarProp::~PersonalbarProp()
 {
 }
 
@@ -210,17 +210,17 @@ PersonalbarProp::SetVisible(bool aVisibl
                             nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
                             aCallerType, aRv);
 }
 
 //
 // StatusbarProp class implementation
 //
 
-StatusbarProp::StatusbarProp(nsGlobalWindow *aWindow)
+StatusbarProp::StatusbarProp(nsGlobalWindowInner *aWindow)
   : BarProp(aWindow)
 {
 }
 
 StatusbarProp::~StatusbarProp()
 {
 }
 
@@ -238,17 +238,17 @@ StatusbarProp::SetVisible(bool aVisible,
                                    nsIWebBrowserChrome::CHROME_STATUSBAR,
                                    aCallerType, aRv);
 }
 
 //
 // ScrollbarsProp class implementation
 //
 
-ScrollbarsProp::ScrollbarsProp(nsGlobalWindow *aWindow)
+ScrollbarsProp::ScrollbarsProp(nsGlobalWindowInner *aWindow)
 : BarProp(aWindow)
 {
 }
 
 ScrollbarsProp::~ScrollbarsProp()
 {
 }
 
--- a/dom/base/BarProps.h
+++ b/dom/base/BarProps.h
@@ -14,31 +14,31 @@
 #define mozilla_dom_BarProps_h
 
 #include "mozilla/Attributes.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
 #include "nsPIDOMWindow.h"
 #include "mozilla/dom/BindingDeclarations.h"
 
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 class nsIWebBrowserChrome;
 
 namespace mozilla {
 
 class ErrorResult;
 
 namespace dom {
 
 // Script "BarProp" object
 class BarProp : public nsISupports,
                 public nsWrapperCache
 {
 public:
-  explicit BarProp(nsGlobalWindow *aWindow);
+  explicit BarProp(nsGlobalWindowInner *aWindow);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BarProp)
 
   nsPIDOMWindowInner* GetParentObject() const;
 
   virtual JSObject*
   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
@@ -51,84 +51,84 @@ protected:
   virtual ~BarProp();
 
   bool GetVisibleByFlag(uint32_t aChromeFlag, ErrorResult& aRv);
   void SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag,
                         CallerType aCallerType, ErrorResult &aRv);
 
   already_AddRefed<nsIWebBrowserChrome> GetBrowserChrome();
 
-  RefPtr<nsGlobalWindow> mDOMWindow;
+  RefPtr<nsGlobalWindowInner> mDOMWindow;
 };
 
 // Script "menubar" object
 class MenubarProp final : public BarProp
 {
 public:
-  explicit MenubarProp(nsGlobalWindow *aWindow);
+  explicit MenubarProp(nsGlobalWindowInner *aWindow);
   virtual ~MenubarProp();
 
   virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
   virtual void SetVisible(bool aVisible, CallerType aCallerType,
                           ErrorResult& aRv) override;
 };
 
 // Script "toolbar" object
 class ToolbarProp final : public BarProp
 {
 public:
-  explicit ToolbarProp(nsGlobalWindow *aWindow);
+  explicit ToolbarProp(nsGlobalWindowInner *aWindow);
   virtual ~ToolbarProp();
 
   virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
   virtual void SetVisible(bool aVisible, CallerType aCallerType,
                           ErrorResult& aRv) override;
 };
 
 // Script "locationbar" object
 class LocationbarProp final : public BarProp
 {
 public:
-  explicit LocationbarProp(nsGlobalWindow *aWindow);
+  explicit LocationbarProp(nsGlobalWindowInner *aWindow);
   virtual ~LocationbarProp();
 
   virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
   virtual void SetVisible(bool aVisible, CallerType aCallerType,
                           ErrorResult& aRv) override;
 };
 
 // Script "personalbar" object
 class PersonalbarProp final : public BarProp
 {
 public:
-  explicit PersonalbarProp(nsGlobalWindow *aWindow);
+  explicit PersonalbarProp(nsGlobalWindowInner *aWindow);
   virtual ~PersonalbarProp();
 
   virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
   virtual void SetVisible(bool aVisible, CallerType aCallerType,
                           ErrorResult& aRv) override;
 };
 
 // Script "statusbar" object
 class StatusbarProp final : public BarProp
 {
 public:
-  explicit StatusbarProp(nsGlobalWindow *aWindow);
+  explicit StatusbarProp(nsGlobalWindowInner *aWindow);
   virtual ~StatusbarProp();
 
   virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
   virtual void SetVisible(bool aVisible, CallerType aCallerType,
                           ErrorResult& aRv) override;
 };
 
 // Script "scrollbars" object
 class ScrollbarsProp final : public BarProp
 {
 public:
-  explicit ScrollbarsProp(nsGlobalWindow *aWindow);
+  explicit ScrollbarsProp(nsGlobalWindowInner *aWindow);
   virtual ~ScrollbarsProp();
 
   virtual bool GetVisible(CallerType aCallerType, ErrorResult& aRv) override;
   virtual void SetVisible(bool aVisible, CallerType aCallerType,
                           ErrorResult& aRv) override;
 };
 
 } // namespace dom
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -510,33 +510,32 @@ Location::SetHrefWithBase(const nsAStrin
      * so that the new url will be appended to Session History.
      * This solution is tricky. Hopefully it isn't going to bite
      * anywhere else. This is part of solution for bug # 39938, 72197
      */
     bool inScriptTag = false;
     nsIScriptContext* scriptContext = nullptr;
     nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(GetEntryGlobal());
     if (win) {
-      scriptContext = nsGlobalWindow::Cast(win)->GetContextInternal();
+      scriptContext = nsGlobalWindowInner::Cast(win)->GetContextInternal();
     }
 
     if (scriptContext) {
       if (scriptContext->GetProcessingScriptTag()) {
         // Now check to make sure that the script is running in our window,
         // since we only want to replace if the location is set by a
         // <script> tag in the same window.  See bug 178729.
         nsCOMPtr<nsIScriptGlobalObject> ourGlobal =
           docShell ? docShell->GetScriptGlobalObject() : nullptr;
         inScriptTag = (ourGlobal == scriptContext->GetGlobalObject());
       }
     }
 
     return SetURI(newUri, aReplace || inScriptTag);
-  }
-
+  } 
   return result;
 }
 
 void
 Location::GetOrigin(nsAString& aOrigin,
                     nsIPrincipal& aSubjectPrincipal,
                     ErrorResult& aRv)
 {
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1441,17 +1441,17 @@ void
 Navigator::GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads,
                        ErrorResult& aRv)
 {
   if (!mWindow) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
   NS_ENSURE_TRUE_VOID(mWindow->GetDocShell());
-  nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
   win->SetHasGamepadEventListener(true);
   win->GetGamepads(aGamepads);
 }
 
 GamepadServiceTest*
 Navigator::RequestGamepadServiceTest()
 {
   if (!mGamepadServiceTest) {
@@ -1463,17 +1463,17 @@ Navigator::RequestGamepadServiceTest()
 already_AddRefed<Promise>
 Navigator::GetVRDisplays(ErrorResult& aRv)
 {
   if (!mWindow || !mWindow->GetDocShell()) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
-  nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
   win->NotifyVREventListenerAdded();
 
   nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
   RefPtr<Promise> p = Promise::Create(go, aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
@@ -1500,33 +1500,33 @@ Navigator::GetActiveVRDisplays(nsTArray<
    * as that would cause enumeration and activation of other VR hardware.
    * Activating VR hardware is intrusive to the end user, as it may
    * involve physically powering on devices that the user did not
    * intend to use.
    */
   if (!mWindow || !mWindow->GetDocShell()) {
     return;
   }
-  nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
   nsTArray<RefPtr<VRDisplay>> displays;
   if (win->UpdateVRDisplays(displays)) {
     for (auto display : displays) {
       if (display->IsPresenting()) {
         aDisplays.AppendElement(display);
       }
     }
   }
 }
 
 void
 Navigator::NotifyVRDisplaysUpdated()
 {
   // Synchronize the VR devices and resolve the promises in
   // mVRGetDisplaysPromises
-  nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
 
   nsTArray<RefPtr<VRDisplay>> vrDisplays;
   if (win->UpdateVRDisplays(vrDisplays)) {
     for (auto p : mVRGetDisplaysPromises) {
       p->MaybeResolve(vrDisplays);
     }
   } else {
     for (auto p : mVRGetDisplaysPromises) {
@@ -1541,43 +1541,43 @@ Navigator::NotifyActiveVRDisplaysChanged
 {
   NavigatorBinding::ClearCachedActiveVRDisplaysValue(this);
 }
 
 VRServiceTest*
 Navigator::RequestVRServiceTest()
 {
   // Ensure that the Mock VR devices are not released prematurely
-  nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
   win->NotifyVREventListenerAdded();
 
   if (!mVRServiceTest) {
     mVRServiceTest = VRServiceTest::CreateTestService(mWindow);
   }
   return mVRServiceTest;
 }
 
 bool
 Navigator::IsWebVRContentDetected() const
 {
-  nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
   return win->IsVRContentDetected();
 }
 
 bool
 Navigator::IsWebVRContentPresenting() const
 {
-  nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
   return win->IsVRContentPresenting();
 }
 
 void
 Navigator::RequestVRPresentation(VRDisplay& aDisplay)
 {
-  nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(mWindow);
   win->DispatchVRDisplayActivate(aDisplay.DisplayId(), VRDisplayEventReason::Requested);
 }
 
 //*****************************************************************************
 //    Navigator::nsIMozNavigatorNetwork
 //*****************************************************************************
 
 NS_IMETHODIMP
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -24,19 +24,19 @@
 #include "nsIPrincipal.h"
 #include "nsIScriptError.h"
 #include "nsPresContext.h"
 #include "nsQueryObject.h"
 
 namespace mozilla {
 namespace dom {
 
-PostMessageEvent::PostMessageEvent(nsGlobalWindow* aSource,
+PostMessageEvent::PostMessageEvent(nsGlobalWindowOuter* aSource,
                                    const nsAString& aCallerOrigin,
-                                   nsGlobalWindow* aTargetWindow,
+                                   nsGlobalWindowOuter* aTargetWindow,
                                    nsIPrincipal* aProvidedPrincipal,
                                    nsIDocument* aSourceDocument,
                                    bool aTrustedCaller)
   : Runnable("dom::PostMessageEvent")
   , StructuredCloneHolder(CloningSupported,
                           TransferringSupported,
                           StructuredCloneScope::SameProcessSameThread)
   , mSource(aSource)
@@ -71,17 +71,17 @@ PostMessageEvent::Run()
   // Use a stack variable so mSourceDocument is not held onto after this method
   // finishes, regardless of the method outcome.
   nsCOMPtr<nsIDocument> sourceDocument;
   sourceDocument.swap(mSourceDocument);
 
   // If we bailed before this point we're going to leak mMessage, but
   // that's probably better than crashing.
 
-  RefPtr<nsGlobalWindow> targetWindow;
+  RefPtr<nsGlobalWindowInner> targetWindow;
   if (mTargetWindow->IsClosedOrClosing() ||
       !(targetWindow = mTargetWindow->GetCurrentInnerWindowInternal()) ||
       targetWindow->IsClosedOrClosing())
     return NS_OK;
 
   MOZ_ASSERT(targetWindow->IsInnerWindow(),
              "we ordered an inner window!");
   JSAutoCompartment ac(cx, targetWindow->GetWrapper());
@@ -171,17 +171,17 @@ PostMessageEvent::Run()
                           messageData, mCallerOrigin,
                           EmptyString(), source, ports);
 
   Dispatch(targetWindow, event);
   return NS_OK;
 }
 
 void
-PostMessageEvent::DispatchError(JSContext* aCx, nsGlobalWindow* aTargetWindow,
+PostMessageEvent::DispatchError(JSContext* aCx, nsGlobalWindowInner* aTargetWindow,
                                 mozilla::dom::EventTarget* aEventTarget)
 {
   RootedDictionary<MessageEventInit> init(aCx);
   init.mBubbles = false;
   init.mCancelable = false;
   init.mOrigin = mCallerOrigin;
 
   if (mSource) {
@@ -190,17 +190,17 @@ PostMessageEvent::DispatchError(JSContex
 
   RefPtr<Event> event =
     MessageEvent::Constructor(aEventTarget, NS_LITERAL_STRING("messageerror"),
                               init);
   Dispatch(aTargetWindow, event);
 }
 
 void
-PostMessageEvent::Dispatch(nsGlobalWindow* aTargetWindow, Event* aEvent)
+PostMessageEvent::Dispatch(nsGlobalWindowInner* aTargetWindow, Event* aEvent)
 {
   // We can't simply call dispatchEvent on the window because doing so ends
   // up flipping the trusted bit on the event, and we don't want that to
   // happen because then untrusted content can call postMessage on a chrome
   // window if it can get a reference to it.
 
   nsIPresShell *shell = aTargetWindow->GetExtantDoc()->GetShell();
   RefPtr<nsPresContext> presContext;
--- a/dom/base/PostMessageEvent.h
+++ b/dom/base/PostMessageEvent.h
@@ -8,53 +8,54 @@
 #define mozilla_dom_PostMessageEvent_h
 
 #include "mozilla/dom/StructuredCloneHolder.h"
 #include "nsCOMPtr.h"
 #include "mozilla/RefPtr.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 
-class nsGlobalWindow;
+class nsGlobalWindowOuter;
+class nsGlobalWindowInner;
 class nsIDocument;
 class nsIPrincipal;
 
 namespace mozilla {
 namespace dom {
 
 /**
  * Class used to represent events generated by calls to Window.postMessage,
  * which asynchronously creates and dispatches events.
  */
 class PostMessageEvent final : public Runnable
                              , public StructuredCloneHolder
 {
 public:
   NS_DECL_NSIRUNNABLE
 
-  PostMessageEvent(nsGlobalWindow* aSource,
+  PostMessageEvent(nsGlobalWindowOuter* aSource,
                    const nsAString& aCallerOrigin,
-                   nsGlobalWindow* aTargetWindow,
+                   nsGlobalWindowOuter* aTargetWindow,
                    nsIPrincipal* aProvidedPrincipal,
                    nsIDocument* aSourceDocument,
                    bool aTrustedCaller);
 
 private:
   ~PostMessageEvent();
 
   void
-  Dispatch(nsGlobalWindow* aTargetWindow, Event* aEvent);
+  Dispatch(nsGlobalWindowInner* aTargetWindow, Event* aEvent);
 
   void
-  DispatchError(JSContext* aCx, nsGlobalWindow* aTargetWindow,
+  DispatchError(JSContext* aCx, nsGlobalWindowInner* aTargetWindow,
                 mozilla::dom::EventTarget* aEventTarget);
 
-  RefPtr<nsGlobalWindow> mSource;
+  RefPtr<nsGlobalWindowOuter> mSource;
   nsString mCallerOrigin;
-  RefPtr<nsGlobalWindow> mTargetWindow;
+  RefPtr<nsGlobalWindowOuter> mTargetWindow;
   nsCOMPtr<nsIPrincipal> mProvidedPrincipal;
   nsCOMPtr<nsIDocument> mSourceDocument;
   bool mTrustedCaller;
 };
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/base/ScreenOrientation.cpp
+++ b/dom/base/ScreenOrientation.cpp
@@ -608,17 +608,17 @@ ScreenOrientation::VisibleEventListener:
   nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetCurrentTarget();
   MOZ_ASSERT(target);
 
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
   if (!doc || doc->Hidden()) {
     return NS_OK;
   }
 
-  auto* win = nsGlobalWindow::Cast(doc->GetInnerWindow());
+  auto* win = nsGlobalWindowInner::Cast(doc->GetInnerWindow());
   if (!win) {
     return NS_OK;
   }
 
   ErrorResult rv;
   nsScreen* screen = win->GetScreen(rv);
   if (NS_WARN_IF(rv.Failed())) {
     return rv.StealNSResult();
--- a/dom/base/Timeout.h
+++ b/dom/base/Timeout.h
@@ -64,17 +64,17 @@ private:
 
 public:
   // Public member variables in this section.  Please don't add to this list
   // or mix methods with these.  The interleaving public/private sections
   // is necessary as we migrate members to private while still trying to
   // keep decent binary packing.
 
   // Window for which this timeout fires
-  RefPtr<nsGlobalWindow> mWindow;
+  RefPtr<nsGlobalWindowInner> mWindow;
 
   // The language-specific information about the callback.
   nsCOMPtr<nsITimeoutHandler> mScriptHandler;
 
   // Interval
   TimeDuration mInterval;
 
   // Returned as value of setTimeout()
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -390,17 +390,17 @@ uint32_t gMaxConsecutiveCallbacksMillise
 
 // Only propagate the open window click permission if the setTimeout() is equal
 // to or less than this value.
 #define DEFAULT_DISABLE_OPEN_CLICK_DELAY 0
 int32_t gDisableOpenClickDelay;
 
 } // anonymous namespace
 
-TimeoutManager::TimeoutManager(nsGlobalWindow& aWindow)
+TimeoutManager::TimeoutManager(nsGlobalWindowInner& aWindow)
   : mWindow(aWindow),
     mExecutor(new TimeoutExecutor(this)),
     mNormalTimeouts(*this),
     mTrackingTimeouts(*this),
     mTimeoutIdCounter(1),
     mNextFiringId(InvalidFiringId + 1),
     mRunningTimeout(nullptr),
     mIdleCallbackTimeoutCounter(1),
@@ -1189,17 +1189,17 @@ TimeoutManager::IsTimeoutTracking(uint32
 }
 
 namespace {
 
 class ThrottleTimeoutsCallback final : public nsITimerCallback
                                      , public nsINamed
 {
 public:
-  explicit ThrottleTimeoutsCallback(nsGlobalWindow* aWindow)
+  explicit ThrottleTimeoutsCallback(nsGlobalWindowInner* aWindow)
     : mWindow(aWindow)
   {
     MOZ_DIAGNOSTIC_ASSERT(aWindow->IsInnerWindow());
   }
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSITIMERCALLBACK
 
@@ -1210,17 +1210,17 @@ public:
   }
 
 private:
   ~ThrottleTimeoutsCallback() {}
 
 private:
   // The strong reference here keeps the Window and hence the TimeoutManager
   // object itself alive.
-  RefPtr<nsGlobalWindow> mWindow;
+  RefPtr<nsGlobalWindowInner> mWindow;
 };
 
 NS_IMPL_ISUPPORTS(ThrottleTimeoutsCallback, nsITimerCallback, nsINamed)
 
 NS_IMETHODIMP
 ThrottleTimeoutsCallback::Notify(nsITimer* aTimer)
 {
   mWindow->AsInner()->TimeoutManager().StartThrottlingTimeouts();
--- a/dom/base/TimeoutManager.h
+++ b/dom/base/TimeoutManager.h
@@ -7,29 +7,29 @@
 #ifndef mozilla_dom_TimeoutManager_h__
 #define mozilla_dom_TimeoutManager_h__
 
 #include "mozilla/dom/Timeout.h"
 #include "nsTArray.h"
 
 class nsIEventTarget;
 class nsITimeoutHandler;
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 
 namespace mozilla {
 namespace dom {
 
 class OrderedTimeoutIterator;
 class TimeoutExecutor;
 
 // This class manages the timeouts in a Window's setTimeout/setInterval pool.
 class TimeoutManager final
 {
 public:
-  explicit TimeoutManager(nsGlobalWindow& aWindow);
+  explicit TimeoutManager(nsGlobalWindowInner& aWindow);
   ~TimeoutManager();
   TimeoutManager(const TimeoutManager& rhs) = delete;
   void operator=(const TimeoutManager& rhs) = delete;
 
   bool IsRunningTimeout() const;
 
   static uint32_t GetNestingLevel() { return sNestingLevel; }
   static void SetNestingLevel(uint32_t aLevel) { sNestingLevel = aLevel; }
@@ -210,19 +210,19 @@ private:
 
     // mTimeoutList is generally sorted by mWhen, but new values are always
     // inserted after any Timeouts with a valid FiringId.
     TimeoutList               mTimeoutList;
   };
 
   friend class OrderedTimeoutIterator;
 
-  // Each nsGlobalWindow object has a TimeoutManager member.  This reference
+  // Each nsGlobalWindowInner object has a TimeoutManager member.  This reference
   // points to that holder object.
-  nsGlobalWindow&             mWindow;
+  nsGlobalWindowInner&             mWindow;
   // The executor is specific to the nsGlobalWindow/TimeoutManager, but it
   // can live past the destruction of the window if its scheduled.  Therefore
   // it must be a separate ref-counted object.
   RefPtr<TimeoutExecutor>     mExecutor;
   // The list of timeouts coming from non-tracking scripts.
   Timeouts                    mNormalTimeouts;
   // The list of timeouts coming from scripts on the tracking protection list.
   Timeouts                    mTrackingTimeouts;
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -1692,17 +1692,17 @@ WebSocketImpl::Init(JSContext* aCx,
         if (NS_WARN_IF(!currentInnerWindow)) {
           return NS_ERROR_DOM_SECURITY_ERR;
         }
 
         // We are at the top. Let's see if we have an opener window.
         if (innerWindow == currentInnerWindow) {
           ErrorResult error;
           parentWindow =
-            nsGlobalWindow::Cast(innerWindow)->GetOpenerWindow(error);
+            nsGlobalWindowInner::Cast(innerWindow)->GetOpenerWindow(error);
           if (NS_WARN_IF(error.Failed())) {
             error.SuppressException();
             return NS_ERROR_DOM_SECURITY_ERR;
           }
 
           if (!parentWindow) {
             break;
           }
--- a/dom/base/WindowNamedPropertiesHandler.cpp
+++ b/dom/base/WindowNamedPropertiesHandler.cpp
@@ -101,17 +101,17 @@ WindowNamedPropertiesHandler::getOwnProp
   }
 
   if(str.IsEmpty()) {
     return true;
   }
 
   // Grab the DOM window.
   JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, aProxy));
-  nsGlobalWindow* win = xpc::WindowOrNull(global);
+  nsGlobalWindowInner* win = xpc::WindowOrNull(global);
   if (win->Length() > 0) {
     nsCOMPtr<nsPIDOMWindowOuter> childWin = win->GetChildWindow(str);
     if (childWin && ShouldExposeChildWindow(str, childWin)) {
       // We found a subframe of the right name. Shadowing via |var foo| in
       // global scope is still allowed, since |var| only looks up |own|
       // properties. But unqualified shadowing will fail, per-spec.
       JS::Rooted<JS::Value> v(aCx);
       if (!WrapObject(aCx, childWin, &v)) {
@@ -173,20 +173,20 @@ WindowNamedPropertiesHandler::ownPropNam
                                            JS::AutoIdVector& aProps) const
 {
   if (!(flags & JSITER_HIDDEN)) {
     // None of our named properties are enumerable.
     return true;
   }
 
   // Grab the DOM window.
-  nsGlobalWindow* win = xpc::WindowOrNull(JS_GetGlobalForObject(aCx, aProxy));
+  nsGlobalWindowInner* win = xpc::WindowOrNull(JS_GetGlobalForObject(aCx, aProxy));
   nsTArray<nsString> names;
   // The names live on the outer window, which might be null
-  nsGlobalWindow* outer = win->GetOuterWindowInternal();
+  nsGlobalWindowOuter* outer = win->GetOuterWindowInternal();
   if (outer) {
     nsDOMWindowList* childWindows = outer->GetWindowList();
     if (childWindows) {
       uint32_t length = childWindows->GetLength();
       for (uint32_t i = 0; i < length; ++i) {
         nsCOMPtr<nsIDocShellTreeItem> item =
           childWindows->GetDocShellTreeItemAt(i);
         // This is a bit silly, since we could presumably just do
--- a/dom/base/WindowOrientationObserver.cpp
+++ b/dom/base/WindowOrientationObserver.cpp
@@ -7,23 +7,23 @@
 #include "WindowOrientationObserver.h"
 
 #include "nsGlobalWindow.h"
 #include "mozilla/Hal.h"
 
 using namespace mozilla::dom;
 
 /**
- * This class is used by nsGlobalWindow to implement window.orientation
+ * This class is used by nsGlobalWindowInner to implement window.orientation
  * and window.onorientationchange. This class is defined in its own file
  * because Hal.h pulls in windows.h and can't be included from
  * nsGlobalWindow.cpp
  */
 WindowOrientationObserver::WindowOrientationObserver(
-  nsGlobalWindow* aGlobalWindow)
+  nsGlobalWindowInner* aGlobalWindow)
   : mWindow(aGlobalWindow)
 {
   MOZ_ASSERT(aGlobalWindow && aGlobalWindow->IsInnerWindow());
   hal::RegisterScreenConfigurationObserver(this);
 
   hal::ScreenConfiguration config;
   hal::GetCurrentScreenConfiguration(&config);
   mAngle = config.angle();
--- a/dom/base/WindowOrientationObserver.h
+++ b/dom/base/WindowOrientationObserver.h
@@ -4,32 +4,32 @@
  * 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/. */
 
 #ifndef mozilla_dom_WindowOrientationObserver_h
 #define mozilla_dom_WindowOrientationObserver_h
 
 #include "mozilla/HalScreenConfiguration.h"
 
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 
 namespace mozilla {
 namespace dom {
 
 class WindowOrientationObserver final :
   public mozilla::hal::ScreenConfigurationObserver
 {
 public:
-  explicit WindowOrientationObserver(nsGlobalWindow* aGlobalWindow);
+  explicit WindowOrientationObserver(nsGlobalWindowInner* aGlobalWindow);
   ~WindowOrientationObserver();
   void Notify(const mozilla::hal::ScreenConfiguration& aConfiguration) override;
   static int16_t OrientationAngle();
 
 private:
   // Weak pointer, instance is owned by mWindow.
-  nsGlobalWindow* MOZ_NON_OWNING_REF mWindow;
+  nsGlobalWindowInner* MOZ_NON_OWNING_REF mWindow;
   uint16_t mAngle;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_WindowOrientationObserver_h
--- a/dom/base/nsCCUncollectableMarker.cpp
+++ b/dom/base/nsCCUncollectableMarker.cpp
@@ -207,17 +207,17 @@ MarkContentViewer(nsIContentViewer* aVie
         elm->MarkForCC();
       }
       nsCOMPtr<EventTarget> win = do_QueryInterface(doc->GetInnerWindow());
       if (win) {
         elm = win->GetExistingListenerManager();
         if (elm) {
           elm->MarkForCC();
         }
-        static_cast<nsGlobalWindow*>(win.get())->AsInner()->
+        static_cast<nsGlobalWindowInner*>(win.get())->AsInner()->
           TimeoutManager().UnmarkGrayTimers();
       }
     } else if (aPrepareForCC) {
       // Unfortunately we need to still mark user data just before running CC so
       // that it has the right generation.
       doc->PropertyTable(DOM_USER_DATA)->
         EnumerateAll(MarkUserData, &nsCCUncollectableMarker::sGeneration);
     }
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4734,17 +4734,18 @@ nsContentUtils::MatchElementId(nsIConten
 nsIDocument*
 nsContentUtils::GetSubdocumentWithOuterWindowId(nsIDocument *aDocument,
                                                 uint64_t aOuterWindowId)
 {
   if (!aDocument || !aOuterWindowId) {
     return nullptr;
   }
 
-  RefPtr<nsGlobalWindow> window = nsGlobalWindow::GetOuterWindowWithId(aOuterWindowId);
+  RefPtr<nsGlobalWindowOuter> window =
+    nsGlobalWindow::GetOuterWindowWithId(aOuterWindowId);
   if (!window) {
     return nullptr;
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> outerWindow = window->AsOuter();
   nsCOMPtr<nsIDocument> foundDoc = outerWindow->GetDoc();
   if (nsContentUtils::ContentIsCrossDocDescendantOf(foundDoc, aDocument)) {
     // Note that ContentIsCrossDocDescendantOf will return true if
@@ -9886,17 +9887,17 @@ nsContentUtils::SerializeNodeToMarkup(ns
 
 bool
 nsContentUtils::IsSpecificAboutPage(JSObject* aGlobal, const char* aUri)
 {
   // aUri must start with about: or this isn't the right function to be using.
   MOZ_ASSERT(strncmp(aUri, "about:", 6) == 0);
 
   // Make sure the global is a window
-  nsGlobalWindow* win = xpc::WindowGlobalOrNull(aGlobal);
+  nsGlobalWindowInner* win = xpc::WindowGlobalOrNull(aGlobal);
   if (!win) {
     return false;
   }
 
   nsCOMPtr<nsIPrincipal> principal = win->GetPrincipal();
   NS_ENSURE_TRUE(principal, false);
   nsCOMPtr<nsIURI> uri;
   principal->GetURI(getter_AddRefs(uri));
@@ -10728,17 +10729,18 @@ nsContentUtils::GetEventTargetByLoadInfo
     // There's no document yet, but this might be a top-level load where we can
     // find a TabGroup.
     uint64_t outerWindowId;
     if (NS_FAILED(aLoadInfo->GetOuterWindowID(&outerWindowId))) {
       // No window. This might be an add-on XHR, a service worker request, or
       // something else.
       return nullptr;
     }
-    RefPtr<nsGlobalWindow> window = nsGlobalWindow::GetOuterWindowWithId(outerWindowId);
+    RefPtr<nsGlobalWindowOuter> window =
+      nsGlobalWindow::GetOuterWindowWithId(outerWindowId);
     if (!window) {
       return nullptr;
     }
 
     target = window->TabGroup()->EventTargetFor(aCategory);
   }
 
   return target.forget();
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -221,17 +221,17 @@ FindObjectClass(JSContext* cx, JSObject*
     js::GetObjectProto(cx, obj, &proto);
   } while (proto);
 
   sObjectClass = js::GetObjectJSClass(obj);
 }
 
 // Helper to handle torn-down inner windows.
 static inline nsresult
-SetParentToWindow(nsGlobalWindow *win, JSObject **parent)
+SetParentToWindow(nsGlobalWindowInner *win, JSObject **parent)
 {
   MOZ_ASSERT(win);
   MOZ_ASSERT(win->IsInnerWindow());
   *parent = win->FastGetGlobalJSObject();
 
   if (MOZ_UNLIKELY(!*parent)) {
     // The inner window has been torn down. The scope is dying, so don't create
     // any new wrappers.
@@ -1072,17 +1072,17 @@ nsresult
 nsDOMConstructor::PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj)
 {
   nsCOMPtr<nsPIDOMWindowInner> owner(do_QueryReferent(mWeakOwner));
   if (!owner) {
     // Can't do anything.
     return NS_OK;
   }
 
-  nsGlobalWindow *win = nsGlobalWindow::Cast(owner);
+  nsGlobalWindowInner *win = nsGlobalWindowInner::Cast(owner);
   return SetParentToWindow(win, parentObj);
 }
 
 nsresult
 nsDOMConstructor::Construct(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
                             JS::Handle<JSObject*> obj, const JS::CallArgs &args,
                             bool *_retval)
 {
--- a/dom/base/nsDOMMutationObserver.h
+++ b/dom/base/nsDOMMutationObserver.h
@@ -621,17 +621,17 @@ protected:
   void ScheduleForRun();
   void RescheduleForRun();
 
   nsDOMMutationRecord* CurrentRecord(nsAtom* aType);
   bool HasCurrentRecord(const nsAString& aType);
 
   bool Suppressed()
   {
-    return mOwner && nsGlobalWindow::Cast(mOwner)->IsInSyncOperation();
+    return mOwner && nsGlobalWindowInner::Cast(mOwner)->IsInSyncOperation();
   }
 
   static void HandleMutationsInternal(mozilla::AutoSlowOperation& aAso);
 
   static void AddCurrentlyHandlingObserver(nsDOMMutationObserver* aObserver,
                                            uint32_t aMutationLevel);
 
   nsCOMPtr<nsPIDOMWindowInner>                       mOwner;
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -203,17 +203,17 @@ NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY(nsIDOMWindowUtils)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(nsDOMWindowUtils)
 NS_IMPL_RELEASE(nsDOMWindowUtils)
 
-nsDOMWindowUtils::nsDOMWindowUtils(nsGlobalWindow *aWindow)
+nsDOMWindowUtils::nsDOMWindowUtils(nsGlobalWindowOuter *aWindow)
 {
   nsCOMPtr<nsISupports> supports = do_QueryObject(aWindow);
   mWindow = do_GetWeakReference(supports);
   NS_ASSERTION(aWindow->IsOuterWindow(), "How did that happen?");
 }
 
 nsDOMWindowUtils::~nsDOMWindowUtils()
 {
@@ -2352,17 +2352,17 @@ nsDOMWindowUtils::LeaveModalState()
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::IsInModalState(bool *retval)
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   NS_ENSURE_STATE(window);
 
-  *retval = nsGlobalWindow::Cast(window)->IsInModalState();
+  *retval = nsGlobalWindowOuter::Cast(window)->IsInModalState();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::SetDesktopModeViewport(bool aDesktopMode)
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   NS_ENSURE_STATE(window);
@@ -2384,18 +2384,18 @@ nsDOMWindowUtils::GetOuterWindowID(uint6
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetCurrentInnerWindowID(uint64_t *aWindowID)
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   NS_ENSURE_TRUE(window, NS_ERROR_NOT_AVAILABLE);
 
   NS_ASSERTION(window->IsOuterWindow(), "How did that happen?");
-  nsGlobalWindow* inner =
-    nsGlobalWindow::Cast(window)->GetCurrentInnerWindowInternal();
+  nsGlobalWindowInner* inner =
+    nsGlobalWindowOuter::Cast(window)->GetCurrentInnerWindowInternal();
   if (!inner) {
     return NS_ERROR_NOT_AVAILABLE;
   }
   *aWindowID = inner->WindowID();
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -3263,37 +3263,37 @@ nsDOMWindowUtils::NumberOfAssignedPainte
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::EnableDialogs()
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
-  nsGlobalWindow::Cast(window)->EnableDialogs();
+  nsGlobalWindowOuter::Cast(window)->EnableDialogs();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::DisableDialogs()
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
-  nsGlobalWindow::Cast(window)->DisableDialogs();
+  nsGlobalWindowOuter::Cast(window)->DisableDialogs();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::AreDialogsEnabled(bool* aResult)
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
-  *aResult = nsGlobalWindow::Cast(window)->AreDialogsEnabled();
+  *aResult = nsGlobalWindowOuter::Cast(window)->AreDialogsEnabled();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetFileId(JS::Handle<JS::Value> aFile, JSContext* aCx,
                             int64_t* _retval)
 {
   if (aFile.isPrimitive()) {
@@ -3791,17 +3791,17 @@ nsDOMWindowUtils::GetMillisSinceLastUser
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::AllowScriptsToClose()
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   NS_ENSURE_STATE(window);
-  nsGlobalWindow::Cast(window)->AllowScriptsToClose();
+  nsGlobalWindowOuter::Cast(window)->AllowScriptsToClose();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetIsParentWindowMainWidgetVisible(bool* aIsVisible)
 {
   // this should reflect the "is parent window visible" logic in
   // nsWindowWatcher::OpenWindowInternal()
--- a/dom/base/nsDOMWindowUtils.h
+++ b/dom/base/nsDOMWindowUtils.h
@@ -8,17 +8,17 @@
 #define nsDOMWindowUtils_h_
 
 #include "nsWeakReference.h"
 
 #include "nsIDOMWindowUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/BasicEvents.h"
 
-class nsGlobalWindow;
+class nsGlobalWindowOuter;
 class nsIPresShell;
 class nsIWidget;
 class nsPresContext;
 class nsIDocument;
 class nsView;
 struct nsPoint;
 
 namespace mozilla {
@@ -57,17 +57,17 @@ private:
 };
 
 class nsDOMWindowUtils final : public nsIDOMWindowUtils,
                                public nsSupportsWeakReference
 {
   typedef mozilla::widget::TextEventDispatcher
     TextEventDispatcher;
 public:
-  explicit nsDOMWindowUtils(nsGlobalWindow *aWindow);
+  explicit nsDOMWindowUtils(nsGlobalWindowOuter *aWindow);
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMWINDOWUTILS
 
 protected:
   ~nsDOMWindowUtils();
 
   nsWeakPtr mWindow;
 
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2485,17 +2485,17 @@ nsDocument::ResetToURI(nsIURI *aURI, nsI
       if (NS_SUCCEEDED(rv)) {
         SetPrincipal(principal);
       }
     }
   }
 
   // Refresh the principal on the compartment.
   if (nsPIDOMWindowInner* win = GetInnerWindow()) {
-    nsGlobalWindow::Cast(win)->RefreshCompartmentPrincipal();
+    nsGlobalWindowInner::Cast(win)->RefreshCompartmentPrincipal();
   }
 }
 
 already_AddRefed<nsIPrincipal>
 nsDocument::MaybeDowngradePrincipal(nsIPrincipal* aPrincipal)
 {
   if (!aPrincipal) {
     return nullptr;
@@ -7196,17 +7196,17 @@ already_AddRefed<Location>
 nsIDocument::GetLocation() const
 {
   nsCOMPtr<nsPIDOMWindowInner> w = do_QueryInterface(mScriptGlobalObject);
 
   if (!w) {
     return nullptr;
   }
 
-  nsGlobalWindow* window = nsGlobalWindow::Cast(w);
+  nsGlobalWindowInner* window = nsGlobalWindowInner::Cast(w);
   RefPtr<Location> loc = window->GetLocation();
   return loc.forget();
 }
 
 Element*
 nsIDocument::GetHtmlElement() const
 {
   Element* rootElement = GetRootElement();
@@ -8465,17 +8465,17 @@ nsDocument::GetEventTargetParent(EventCh
 
   aVisitor.mCanHandle = true;
    // FIXME! This is a hack to make middle mouse paste working also in Editor.
    // Bug 329119
   aVisitor.mForceContentDispatch = true;
 
   // Load events must not propagate to |window| object, see bug 335251.
   if (aVisitor.mEvent->mMessage != eLoad) {
-    nsGlobalWindow* window = nsGlobalWindow::Cast(GetWindow());
+    nsGlobalWindowOuter* window = nsGlobalWindowOuter::Cast(GetWindow());
     aVisitor.mParentTarget =
       window ? window->GetTargetForEventTargetChain() : nullptr;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
@@ -9153,17 +9153,17 @@ nsDocument::CanSavePresentation(nsIReque
       if (!canCache) {
         return false;
       }
     }
   }
 
 
   if (win) {
-    auto* globalWindow = nsGlobalWindow::Cast(win);
+    auto* globalWindow = nsGlobalWindowInner::Cast(win);
 #ifdef MOZ_WEBSPEECH
     if (globalWindow->HasActiveSpeechSynthesis()) {
       return false;
     }
 #endif
     if (globalWindow->HasUsedVR()) {
       return false;
     }
@@ -14317,17 +14317,17 @@ nsIDocument::GetSelection(ErrorResult& a
     return nullptr;
   }
 
   NS_ASSERTION(window->IsInnerWindow(), "Should have inner window here!");
   if (!window->IsCurrentInnerWindow()) {
     return nullptr;
   }
 
-  return nsGlobalWindow::Cast(window)->GetSelection(aRv);
+  return nsGlobalWindowInner::Cast(window)->GetSelection(aRv);
 }
 
 void
 nsDocument::RecordNavigationTiming(ReadyState aReadyState)
 {
   if (!XRE_IsContentProcess()) {
     return;
   }
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1597,17 +1597,17 @@ nsFrameLoader::SwapWithOtherRemoteLoader
   }
 
   aOther->mRemoteBrowser->SetBrowserDOMWindow(browserDOMWindow);
   mRemoteBrowser->SetBrowserDOMWindow(otherBrowserDOMWindow);
 
 #ifdef XP_WIN
   // Native plugin windows used by this remote content need to be reparented.
   if (nsPIDOMWindowOuter* newWin = ourDoc->GetWindow()) {
-    RefPtr<nsIWidget> newParent = nsGlobalWindow::Cast(newWin)->GetMainWidget();
+    RefPtr<nsIWidget> newParent = nsGlobalWindowOuter::Cast(newWin)->GetMainWidget();
     const ManagedContainer<mozilla::plugins::PPluginWidgetParent>& plugins =
       aOther->mRemoteBrowser->ManagedPPluginWidgetParent();
     for (auto iter = plugins.ConstIter(); !iter.Done(); iter.Next()) {
       static_cast<mozilla::plugins::PluginWidgetParent*>(iter.Get()->GetKey())->SetParent(newParent);
     }
   }
 #endif // XP_WIN
 
@@ -3835,17 +3835,17 @@ nsFrameLoader::Print(uint64_t aOuterWind
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     bool success = mRemoteBrowser->SendPrint(aOuterWindowID, printData);
     return success ? NS_OK : NS_ERROR_FAILURE;
   }
 
-  nsGlobalWindow* outerWindow =
+  nsGlobalWindowOuter* outerWindow =
     nsGlobalWindow::GetOuterWindowWithId(aOuterWindowID);
   if (NS_WARN_IF(!outerWindow)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint =
     do_GetInterface(outerWindow->AsOuter());
   if (NS_WARN_IF(!webBrowserPrint)) {
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1011,17 +1011,17 @@ nsPIDOMWindow<T>::nsPIDOMWindow(nsPIDOMW
   mMarkedCCGeneration(0), mServiceWorkersTestingEnabled(false),
   mLargeAllocStatus(LargeAllocStatus::NONE),
   mHasTriedToCacheTopInnerWindow(false),
   mNumOfIndexedDBDatabases(0),
   mNumOfOpenWebSockets(0)
 {
   if (aOuterWindow) {
     mTimeoutManager =
-      MakeUnique<mozilla::dom::TimeoutManager>(*nsGlobalWindow::Cast(AsInner()));
+      MakeUnique<mozilla::dom::TimeoutManager>(*nsGlobalWindowInner::Cast(AsInner()));
   }
 }
 
 template<class T>
 nsPIDOMWindow<T>::~nsPIDOMWindow() {}
 
 /* static */
 nsPIDOMWindowOuter*
@@ -5018,74 +5018,74 @@ nsGlobalWindow::GetPrompter(nsIPrompt** 
 }
 
 BarProp*
 nsGlobalWindow::GetMenubar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mMenubar) {
-    mMenubar = new MenubarProp(this);
+    mMenubar = new MenubarProp(AssertInner());
   }
 
   return mMenubar;
 }
 
 BarProp*
 nsGlobalWindow::GetToolbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mToolbar) {
-    mToolbar = new ToolbarProp(this);
+    mToolbar = new ToolbarProp(AssertInner());
   }
 
   return mToolbar;
 }
 
 BarProp*
 nsGlobalWindow::GetLocationbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mLocationbar) {
-    mLocationbar = new LocationbarProp(this);
+    mLocationbar = new LocationbarProp(AssertInner());
   }
   return mLocationbar;
 }
 
 BarProp*
 nsGlobalWindow::GetPersonalbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mPersonalbar) {
-    mPersonalbar = new PersonalbarProp(this);
+    mPersonalbar = new PersonalbarProp(AssertInner());
   }
   return mPersonalbar;
 }
 
 BarProp*
 nsGlobalWindow::GetStatusbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mStatusbar) {
-    mStatusbar = new StatusbarProp(this);
+    mStatusbar = new StatusbarProp(AssertInner());
   }
   return mStatusbar;
 }
 
 BarProp*
 nsGlobalWindow::GetScrollbars(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mScrollbars) {
-    mScrollbars = new ScrollbarsProp(this);
+    mScrollbars = new ScrollbarsProp(AssertInner());
   }
 
   return mScrollbars;
 }
 
 bool
 nsGlobalWindow::GetClosedOuter()
 {
@@ -9240,17 +9240,17 @@ nsGlobalWindow::PostMessageMozOuter(JSCo
 
   // Create and asynchronously dispatch a runnable which will handle actual DOM
   // event creation and dispatch.
   RefPtr<PostMessageEvent> event =
     new PostMessageEvent(nsContentUtils::IsCallerChrome() || !callerInnerWin
                          ? nullptr
                          : callerInnerWin->GetOuterWindowInternal(),
                          origin,
-                         this,
+                         AssertOuter(),
                          providedPrincipal,
                          callerInnerWin
                          ? callerInnerWin->GetDoc()
                          : nullptr,
                          nsContentUtils::IsCallerChrome());
 
   JS::Rooted<JS::Value> message(aCx, aMessage);
   JS::Rooted<JS::Value> transfer(aCx, aTransfer);
@@ -10688,41 +10688,41 @@ void nsGlobalWindow::MaybeUpdateTouchSta
 void
 nsGlobalWindow::EnableGamepadUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasGamepad) {
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     if (gamepadManager) {
-      gamepadManager->AddListener(this);
+      gamepadManager->AddListener(AssertInner());
     }
   }
 }
 
 void
 nsGlobalWindow::DisableGamepadUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasGamepad) {
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     if (gamepadManager) {
-      gamepadManager->RemoveListener(this);
+      gamepadManager->RemoveListener(AssertInner());
     }
   }
 }
 
 void
 nsGlobalWindow::EnableVRUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasVREvents && !mVREventObserver) {
-    mVREventObserver = new VREventObserver(this);
+    mVREventObserver = new VREventObserver(AssertInner());
   }
 }
 
 void
 nsGlobalWindow::DisableVRUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
   if (mVREventObserver) {
@@ -11439,17 +11439,17 @@ nsGlobalWindow::GetInterface(const nsIID
       if (viewer) {
         nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint(do_QueryInterface(viewer));
         webBrowserPrint.forget(aSink);
       }
     }
   }
 #endif
   else if (aIID.Equals(NS_GET_IID(nsIDOMWindowUtils))) {
-    nsGlobalWindow* outer = GetOuterWindowInternal();
+    nsGlobalWindowOuter* outer = GetOuterWindowInternal();
     NS_ENSURE_TRUE(outer, NS_ERROR_NOT_INITIALIZED);
 
     if (!mWindowUtils) {
       mWindowUtils = new nsDOMWindowUtils(outer);
     }
 
     *aSink = mWindowUtils;
     NS_ADDREF(((nsISupports *) *aSink));
@@ -13115,17 +13115,17 @@ nsGlobalWindow::SetTimeoutOrInterval(JSC
   }
 
   if (inner != this) {
     return inner->SetTimeoutOrInterval(aCx, aFunction, aTimeout, aArguments,
                                        aIsInterval, aError);
   }
 
   nsCOMPtr<nsIScriptTimeoutHandler> handler =
-    NS_CreateJSTimeoutHandler(aCx, this, aFunction, aArguments, aError);
+    NS_CreateJSTimeoutHandler(aCx, AssertInner(), aFunction, aArguments, aError);
   if (!handler) {
     return 0;
   }
 
   int32_t result;
   aError = mTimeoutManager->SetTimeout(handler, aTimeout, aIsInterval,
                                       Timeout::Reason::eTimeoutOrInterval,
                                       &result);
@@ -13143,17 +13143,17 @@ nsGlobalWindow::SetTimeoutOrInterval(JSC
   }
 
   if (inner != this) {
     return inner->SetTimeoutOrInterval(aCx, aHandler, aTimeout, aIsInterval,
                                        aError);
   }
 
   nsCOMPtr<nsIScriptTimeoutHandler> handler =
-    NS_CreateJSTimeoutHandler(aCx, this, aHandler, aError);
+    NS_CreateJSTimeoutHandler(aCx, AssertInner(), aHandler, aError);
   if (!handler) {
     return 0;
   }
 
   int32_t result;
   aError = mTimeoutManager->SetTimeout(handler, aTimeout, aIsInterval,
                                       Timeout::Reason::eTimeoutOrInterval,
                                       &result);
@@ -13536,17 +13536,17 @@ nsGlobalWindow::DisableDeviceSensor(uint
 #if defined(MOZ_WIDGET_ANDROID)
 void
 nsGlobalWindow::EnableOrientationChangeListener()
 {
   MOZ_ASSERT(IsInnerWindow());
   if (!nsContentUtils::ShouldResistFingerprinting(mDocShell) &&
       !mOrientationChangeObserver) {
     mOrientationChangeObserver =
-      MakeUnique<WindowOrientationObserver>(this);
+      MakeUnique<WindowOrientationObserver>(AssertInner());
   }
 }
 
 void
 nsGlobalWindow::DisableOrientationChangeListener()
 {
   MOZ_ASSERT(IsInnerWindow());
 
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -149,23 +149,23 @@ class Worklet;
 namespace cache {
 class CacheStorage;
 } // namespace cache
 class IDBFactory;
 } // namespace dom
 } // namespace mozilla
 
 extern already_AddRefed<nsIScriptTimeoutHandler>
-NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow,
+NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindowInner *aWindow,
                           mozilla::dom::Function& aFunction,
                           const mozilla::dom::Sequence<JS::Value>& aArguments,
                           mozilla::ErrorResult& aError);
 
 extern already_AddRefed<nsIScriptTimeoutHandler>
-NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow,
+NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindowInner *aWindow,
                           const nsAString& aExpression,
                           mozilla::ErrorResult& aError);
 
 extern const js::Class OuterWindowProxyClass;
 
 struct IdleObserverHolder
 {
   nsCOMPtr<nsIIdleObserver> mIdleObserver;
@@ -303,16 +303,19 @@ public:
   static const nsGlobalWindow* Cast(const nsPIDOMWindowOuter* aPIWin) {
     return static_cast<const nsGlobalWindow*>(
                         reinterpret_cast<const nsPIDOMWindow<nsISupports>*>(aPIWin));
   }
   static nsGlobalWindow* Cast(mozIDOMWindowProxy* aWin) {
     return Cast(nsPIDOMWindowOuter::From(aWin));
   }
 
+  nsGlobalWindowInner* AssertInner();
+  nsGlobalWindowOuter* AssertOuter();
+
   // public methods
   nsPIDOMWindowOuter* GetPrivateParent();
 
   // callback for close event
   void ReallyCloseWindow();
 
   // nsISupports
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@@ -2185,16 +2188,30 @@ nsGlobalWindow::IsPopupSpamWindow()
 }
 
 inline bool
 nsGlobalWindow::IsFrame()
 {
   return GetParentInternal() != nullptr;
 }
 
+inline nsGlobalWindowInner*
+nsGlobalWindow::AssertInner()
+{
+  MOZ_RELEASE_ASSERT(IsInnerWindow());
+  return static_cast<nsGlobalWindowInner*>(this);
+}
+
+inline nsGlobalWindowOuter*
+nsGlobalWindow::AssertOuter()
+{
+  MOZ_RELEASE_ASSERT(IsOuterWindow());
+  return static_cast<nsGlobalWindowOuter*>(this);
+}
+
 /* factory function */
 inline already_AddRefed<nsGlobalWindowOuter>
 NS_NewScriptGlobalObject(bool aIsChrome)
 {
   RefPtr<nsGlobalWindow> global;
 
   if (aIsChrome) {
     global = nsGlobalWindow::CreateChrome(nullptr);
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1381,17 +1381,17 @@ nsINode::GetContextForEventHandlers(nsre
 {
   return nsContentUtils::GetContextForEventHandlers(this, aRv);
 }
 
 nsPIDOMWindowOuter*
 nsINode::GetOwnerGlobalForBindings()
 {
   bool dummy;
-  auto* window = static_cast<nsGlobalWindow*>(OwnerDoc()->GetScriptHandlingObject(dummy));
+  auto* window = static_cast<nsGlobalWindowInner*>(OwnerDoc()->GetScriptHandlingObject(dummy));
   return window ? nsPIDOMWindowOuter::GetFromCurrentInner(window->AsInner()) : nullptr;
 }
 
 nsIGlobalObject*
 nsINode::GetOwnerGlobal() const
 {
   bool dummy;
   return OwnerDoc()->GetScriptHandlingObject(dummy);
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -406,17 +406,17 @@ NS_HandleScriptError(nsIScriptGlobalObje
 
     static int32_t errorDepth; // Recursion prevention
     ++errorDepth;
 
     if (errorDepth < 2) {
       // Dispatch() must be synchronous for the recursion block
       // (errorDepth) to work.
       RefPtr<ErrorEvent> event =
-        ErrorEvent::Constructor(nsGlobalWindow::Cast(win),
+        ErrorEvent::Constructor(nsGlobalWindowInner::Cast(win),
                                 NS_LITERAL_STRING("error"),
                                 aErrorEventInit);
       event->SetTrusted(true);
 
       EventDispatcher::DispatchDOMEvent(win, nullptr, event, presContext,
                                         aStatus);
       called = true;
     }
@@ -467,17 +467,17 @@ public:
         init.mError = mError;
       } else {
         NS_WARNING("Not same origin error!");
         init.mMessage = xoriginMsg;
         init.mLineno = 0;
       }
 
       RefPtr<ErrorEvent> event =
-        ErrorEvent::Constructor(nsGlobalWindow::Cast(win),
+        ErrorEvent::Constructor(nsGlobalWindowInner::Cast(win),
                                 NS_LITERAL_STRING("error"), init);
       event->SetTrusted(true);
 
       EventDispatcher::DispatchDOMEvent(win, nullptr, event, presContext,
                                         &status);
     }
 
     if (status != nsEventStatus_eConsumeNoDefault) {
@@ -509,17 +509,17 @@ DispatchScriptErrorEvent(nsPIDOMWindowIn
 {
   nsContentUtils::AddScriptRunner(new ScriptErrorEvent(win, rootingCx, xpcReport, exception));
 }
 
 } /* namespace xpc */
 
 #ifdef DEBUG
 // A couple of useful functions to call when you're debugging.
-nsGlobalWindow *
+nsGlobalWindowInner *
 JSObject2Win(JSObject *obj)
 {
   return xpc::WindowOrNull(obj);
 }
 
 void
 PrintWinURI(nsGlobalWindow *win)
 {
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -30,21 +30,21 @@ class nsJSScriptTimeoutHandler final : p
 {
 public:
   // nsISupports
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsJSScriptTimeoutHandler)
 
   nsJSScriptTimeoutHandler();
   // This will call SwapElements on aArguments with an empty array.
-  nsJSScriptTimeoutHandler(JSContext* aCx, nsGlobalWindow* aWindow,
+  nsJSScriptTimeoutHandler(JSContext* aCx, nsGlobalWindowInner* aWindow,
                            Function& aFunction,
                            nsTArray<JS::Heap<JS::Value>>&& aArguments,
                            ErrorResult& aError);
-  nsJSScriptTimeoutHandler(JSContext* aCx, nsGlobalWindow* aWindow,
+  nsJSScriptTimeoutHandler(JSContext* aCx, nsGlobalWindowInner* aWindow,
                            const nsAString& aExpression, bool* aAllowEval,
                            ErrorResult& aError);
   nsJSScriptTimeoutHandler(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
                            Function& aFunction,
                            nsTArray<JS::Heap<JS::Value>>&& aArguments);
   nsJSScriptTimeoutHandler(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
                            const nsAString& aExpression);
 
@@ -160,17 +160,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsITimeoutHandler)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsJSScriptTimeoutHandler)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsJSScriptTimeoutHandler)
 
 static bool
-CheckCSPForEval(JSContext* aCx, nsGlobalWindow* aWindow, ErrorResult& aError)
+CheckCSPForEval(JSContext* aCx, nsGlobalWindowInner* aWindow, ErrorResult& aError)
 {
   // if CSP is enabled, and setTimeout/setInterval was called with a string,
   // disable the registration and log an error
   nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
   if (!doc) {
     // if there's no document, we don't have to do anything.
     return true;
   }
@@ -214,17 +214,17 @@ CheckCSPForEval(JSContext* aCx, nsGlobal
 
 nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler()
   : mLineNo(0)
   , mColumn(0)
 {
 }
 
 nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
-                                                   nsGlobalWindow *aWindow,
+                                                   nsGlobalWindowInner *aWindow,
                                                    Function& aFunction,
                                                    nsTArray<JS::Heap<JS::Value>>&& aArguments,
                                                    ErrorResult& aError)
   : mLineNo(0)
   , mColumn(0)
   , mFunction(&aFunction)
 {
   if (!aWindow->GetContextInternal() || !aWindow->FastGetGlobalJSObject()) {
@@ -233,17 +233,17 @@ nsJSScriptTimeoutHandler::nsJSScriptTime
     aError.Throw(NS_ERROR_NOT_INITIALIZED);
     return;
   }
 
   Init(aCx, Move(aArguments));
 }
 
 nsJSScriptTimeoutHandler::nsJSScriptTimeoutHandler(JSContext* aCx,
-                                                   nsGlobalWindow *aWindow,
+                                                   nsGlobalWindowInner *aWindow,
                                                    const nsAString& aExpression,
                                                    bool* aAllowEval,
                                                    ErrorResult& aError)
   : mLineNo(0)
   , mColumn(0)
   , mExpr(aExpression)
 {
   if (!aWindow->GetContextInternal() || !aWindow->FastGetGlobalJSObject()) {
@@ -323,34 +323,34 @@ nsJSScriptTimeoutHandler::ReleaseJSObjec
 const nsAString&
 nsJSScriptTimeoutHandler::GetHandlerText()
 {
   NS_ASSERTION(!mFunction, "No expression, so no handler text!");
   return mExpr;
 }
 
 already_AddRefed<nsIScriptTimeoutHandler>
-NS_CreateJSTimeoutHandler(JSContext *aCx, nsGlobalWindow *aWindow,
+NS_CreateJSTimeoutHandler(JSContext *aCx, nsGlobalWindowInner *aWindow,
                           Function& aFunction,
                           const Sequence<JS::Value>& aArguments,
                           ErrorResult& aError)
 {
   nsTArray<JS::Heap<JS::Value>> args;
   if (!args.AppendElements(aArguments, fallible)) {
     aError.Throw(NS_ERROR_OUT_OF_MEMORY);
     return nullptr;
   }
 
   RefPtr<nsJSScriptTimeoutHandler> handler =
     new nsJSScriptTimeoutHandler(aCx, aWindow, aFunction, Move(args), aError);
   return aError.Failed() ? nullptr : handler.forget();
 }
 
 already_AddRefed<nsIScriptTimeoutHandler>
-NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindow *aWindow,
+NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindowInner *aWindow,
                           const nsAString& aExpression, ErrorResult& aError)
 {
   bool allowEval = false;
   RefPtr<nsJSScriptTimeoutHandler> handler =
     new nsJSScriptTimeoutHandler(aCx, aWindow, aExpression, &allowEval, aError);
   if (aError.Failed() || !allowEval) {
     return nullptr;
   }
--- a/dom/base/nsJSUtils.cpp
+++ b/dom/base/nsJSUtils.cpp
@@ -78,17 +78,17 @@ nsJSUtils::GetStaticScriptContext(JSObje
 }
 
 uint64_t
 nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(JSContext *aContext)
 {
   if (!aContext)
     return 0;
 
-  nsGlobalWindow* win = xpc::CurrentWindowOrNull(aContext);
+  nsGlobalWindowInner* win = xpc::CurrentWindowOrNull(aContext);
   return win ? win->WindowID() : 0;
 }
 
 nsresult
 nsJSUtils::CompileFunction(AutoJSAPI& jsapi,
                            JS::AutoObjectVector& aScopeChain,
                            JS::CompileOptions& aOptions,
                            const nsACString& aName,
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -85,17 +85,17 @@ AddNonJSSizeOfWindowAndItsDescendents(ns
       NS_ENSURE_SUCCESS(rv, rv);
   }
   return NS_OK;
 }
 
 static nsresult
 NonJSSizeOfTab(nsPIDOMWindowOuter* aWindow, size_t* aDomSize, size_t* aStyleSize, size_t* aOtherSize)
 {
-  nsGlobalWindow* window = nsGlobalWindow::Cast(aWindow);
+  nsGlobalWindowOuter* window = nsGlobalWindowOuter::Cast(aWindow);
 
   nsTabSizes sizes;
   nsresult rv = AddNonJSSizeOfWindowAndItsDescendents(window, &sizes);
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aDomSize   = sizes.mDom;
   *aStyleSize = sizes.mStyle;
   *aOtherSize = sizes.mOther;
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -290,17 +290,17 @@ nsWindowRoot::GetControllerForCommand(co
                                            getter_AddRefs(controller));
       if (controller) {
         controller.forget(_retval);
         return NS_OK;
       }
     }
 
     // XXXndeakin P3 is this casting safe?
-    nsGlobalWindow *win = nsGlobalWindow::Cast(focusedWindow);
+    nsGlobalWindowOuter *win = nsGlobalWindowOuter::Cast(focusedWindow);
     focusedWindow = win->GetPrivateParent();
   }
 
   return NS_OK;
 }
 
 void
 nsWindowRoot::GetEnabledDisabledCommandsForControllers(nsIControllers* aControllers,
@@ -362,17 +362,17 @@ nsWindowRoot::GetEnabledDisabledCommands
                                        getter_AddRefs(focusedWindow));
   while (focusedWindow) {
     focusedWindow->GetControllers(getter_AddRefs(controllers));
     if (controllers) {
       GetEnabledDisabledCommandsForControllers(controllers, commandsHandled,
                                                aEnabledCommands, aDisabledCommands);
     }
 
-    nsGlobalWindow* win = nsGlobalWindow::Cast(focusedWindow);
+    nsGlobalWindowOuter* win = nsGlobalWindowOuter::Cast(focusedWindow);
     focusedWindow = win->GetPrivateParent();
   }
 }
 
 nsIDOMNode*
 nsWindowRoot::GetPopupNode()
 {
   nsCOMPtr<nsIDOMNode> popupNode = do_QueryReferent(mPopupNode);
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -2855,17 +2855,17 @@ HandlePrerenderingViolation(nsPIDOMWindo
 bool
 EnforceNotInPrerendering(JSContext* aCx, JSObject* aObj)
 {
   JS::Rooted<JSObject*> thisObj(aCx, js::CheckedUnwrap(aObj));
   if (!thisObj) {
     // Without a this object, we cannot check the safety.
     return true;
   }
-  nsGlobalWindow* window = xpc::WindowGlobalOrNull(thisObj);
+  nsGlobalWindowInner* window = xpc::WindowGlobalOrNull(thisObj);
   if (!window) {
     // Without a window, we cannot check the safety.
     return true;
   }
 
   if (window->GetIsPrerendered()) {
     HandlePrerenderingViolation(window->AsInner());
     // When the bindings layer sees a false return value, it returns false form
@@ -3529,17 +3529,17 @@ CustomElementReactionsStack*
 GetCustomElementReactionsStack(JS::Handle<JSObject*> aObj)
 {
   // This might not be the right object, if there are wrappers. Unwrap if we can.
   JSObject* obj = js::CheckedUnwrap(aObj);
   if (!obj) {
     return nullptr;
   }
 
-  nsGlobalWindow* window = xpc::WindowGlobalOrNull(obj);
+  nsGlobalWindowInner* window = xpc::WindowGlobalOrNull(obj);
   if (!window) {
     return nullptr;
   }
 
   DocGroup* docGroup = window->AsInner()->GetDocGroup();
   if (!docGroup) {
     return nullptr;
   }
@@ -3727,17 +3727,17 @@ AssertReflectorHasGivenProto(JSContext* 
              "How are we supposed to change the proto now?");
 }
 } // namespace binding_detail
 #endif // DEBUG
 
 void
 SetDocumentAndPageUseCounter(JSObject* aObject, UseCounter aUseCounter)
 {
-  nsGlobalWindow* win = xpc::WindowGlobalOrNull(js::UncheckedUnwrap(aObject));
+  nsGlobalWindowInner* win = xpc::WindowGlobalOrNull(js::UncheckedUnwrap(aObject));
   if (win && win->GetDocument()) {
     win->GetDocument()->SetDocumentAndPageUseCounter(aUseCounter);
   }
 }
 
 namespace {
 
 // This runnable is used to write a deprecation message from a worker to the
--- a/dom/bindings/CallbackObject.cpp
+++ b/dom/bindings/CallbackObject.cpp
@@ -177,17 +177,17 @@ CallbackObject::CallSetup::CallSetup(Cal
           NS_LITERAL_CSTRING("Refusing to execute function from global in which "
                              "script is disabled."));
         return;
       }
     }
 
     // Now get the global for this callback. Note that for the case of
     // JS-implemented WebIDL we never have a window here.
-    nsGlobalWindow* win = mIsMainThread && !aIsJSImplementedWebIDL
+    nsGlobalWindowInner* win = mIsMainThread && !aIsJSImplementedWebIDL
                             ? xpc::WindowGlobalOrNull(realCallback)
                             : nullptr;
     if (win) {
       MOZ_ASSERT(win->IsInnerWindow());
       // We don't want to run script in windows that have been navigated away
       // from.
       if (!win->AsInner()->HasActiveDocument()) {
         aRv.ThrowDOMException(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
--- a/dom/bindings/nsScriptError.cpp
+++ b/dom/bindings/nsScriptError.cpp
@@ -56,17 +56,17 @@ nsScriptErrorBase::AddNote(nsIScriptErro
 
 void
 nsScriptErrorBase::InitializeOnMainThread()
 {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(!mInitializedOnMainThread);
 
     if (mInnerWindowID) {
-        nsGlobalWindow* window =
+        nsGlobalWindowInner* window =
           nsGlobalWindow::GetInnerWindowWithId(mInnerWindowID);
         if (window) {
             nsPIDOMWindowOuter* outer = window->GetOuterWindow();
             if (outer)
                 mOuterWindowID = outer->WindowID();
 
             nsIDocShell* docShell = window->GetDocShell();
             nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -26,17 +26,17 @@
 #include "imgIEncoder.h"
 #include "nsLayoutUtils.h"
 #include "mozilla/EnumeratedArray.h"
 #include "FilterSupport.h"
 #include "SVGObserverUtils.h"
 #include "Layers.h"
 #include "nsBidi.h"
 
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 class nsXULElement;
 
 namespace mozilla {
 namespace gl {
 class SourceSurface;
 } // namespace gl
 
 namespace dom {
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -370,17 +370,17 @@ protected:
   void
   RunWithWindow(nsPIDOMWindowInner* aWindow)
   {
     AssertIsOnMainThread();
 
     AutoJSAPI jsapi;
     MOZ_ASSERT(aWindow);
 
-    RefPtr<nsGlobalWindow> win = nsGlobalWindow::Cast(aWindow);
+    RefPtr<nsGlobalWindowInner> win = nsGlobalWindowInner::Cast(aWindow);
     if (NS_WARN_IF(!jsapi.Init(win))) {
       return;
     }
 
     MOZ_ASSERT(aWindow->IsInnerWindow());
     nsPIDOMWindowOuter* outerWindow = aWindow->GetOuterWindow();
     if (NS_WARN_IF(!outerWindow)) {
       return;
@@ -1291,17 +1291,17 @@ Console::MethodInternal(JSContext* aCx, 
 
   DOMHighResTimeStamp monotonicTimer;
 
   // Monotonic timer for 'time' and 'timeEnd'
   if (aMethodName == MethodTime ||
       aMethodName == MethodTimeEnd ||
       aMethodName == MethodTimeStamp) {
     if (mWindow) {
-      nsGlobalWindow *win = nsGlobalWindow::Cast(mWindow);
+      nsGlobalWindowInner *win = nsGlobalWindowInner::Cast(mWindow);
       MOZ_ASSERT(win);
 
       RefPtr<Performance> performance = win->GetPerformance();
       if (!performance) {
         return;
       }
 
       monotonicTimer = performance->Now();
@@ -2453,17 +2453,17 @@ Console::GetConsoleInternal(const Global
   // Window
   if (NS_IsMainThread()) {
     nsCOMPtr<nsPIDOMWindowInner> innerWindow =
       do_QueryInterface(aGlobal.GetAsSupports());
     if (NS_WARN_IF(!innerWindow)) {
       return nullptr;
     }
 
-    nsGlobalWindow* window = nsGlobalWindow::Cast(innerWindow);
+    nsGlobalWindowInner* window = nsGlobalWindowInner::Cast(innerWindow);
     return window->GetConsole(aRv);
   }
 
   // Workers
   MOZ_ASSERT(!NS_IsMainThread());
 
   JSContext* cx = aGlobal.Context();
   WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
--- a/dom/events/DOMEventTargetHelper.cpp
+++ b/dom/events/DOMEventTargetHelper.cpp
@@ -85,17 +85,17 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMEvent
 NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(DOMEventTargetHelper,
                                                    LastRelease())
 
 NS_IMPL_DOMTARGET_DEFAULTS(DOMEventTargetHelper)
 
 DOMEventTargetHelper::~DOMEventTargetHelper()
 {
   if (nsPIDOMWindowInner* owner = GetOwner()) {
-    nsGlobalWindow::Cast(owner)->RemoveEventTargetObject(this);
+    nsGlobalWindowInner::Cast(owner)->RemoveEventTargetObject(this);
   }
   if (mListenerManager) {
     mListenerManager->Disconnect();
   }
   ReleaseWrapper(this);
 }
 
 void
@@ -106,53 +106,53 @@ DOMEventTargetHelper::BindToOwner(nsPIDO
 }
 
 void
 DOMEventTargetHelper::BindToOwner(nsIGlobalObject* aOwner)
 {
   nsCOMPtr<nsIGlobalObject> parentObject = do_QueryReferent(mParentObject);
   if (parentObject) {
     if (mOwnerWindow) {
-      nsGlobalWindow::Cast(mOwnerWindow)->RemoveEventTargetObject(this);
+      nsGlobalWindowInner::Cast(mOwnerWindow)->RemoveEventTargetObject(this);
       mOwnerWindow = nullptr;
     }
     mParentObject = nullptr;
     mHasOrHasHadOwnerWindow = false;
   }
   if (aOwner) {
     mParentObject = do_GetWeakReference(aOwner);
     MOZ_ASSERT(mParentObject, "All nsIGlobalObjects must support nsISupportsWeakReference");
     // Let's cache the result of this QI for fast access and off main thread usage
     mOwnerWindow = nsCOMPtr<nsPIDOMWindowInner>(do_QueryInterface(aOwner)).get();
     if (mOwnerWindow) {
       mHasOrHasHadOwnerWindow = true;
-      nsGlobalWindow::Cast(mOwnerWindow)->AddEventTargetObject(this);
+      nsGlobalWindowInner::Cast(mOwnerWindow)->AddEventTargetObject(this);
     }
   }
 }
 
 void
 DOMEventTargetHelper::BindToOwner(DOMEventTargetHelper* aOther)
 {
   if (mOwnerWindow) {
-    nsGlobalWindow::Cast(mOwnerWindow)->RemoveEventTargetObject(this);
+    nsGlobalWindowInner::Cast(mOwnerWindow)->RemoveEventTargetObject(this);
     mOwnerWindow = nullptr;
     mParentObject = nullptr;
     mHasOrHasHadOwnerWindow = false;
   }
   if (aOther) {
     mHasOrHasHadOwnerWindow = aOther->HasOrHasHadOwner();
     if (aOther->GetParentObject()) {
       mParentObject = do_GetWeakReference(aOther->GetParentObject());
       MOZ_ASSERT(mParentObject, "All nsIGlobalObjects must support nsISupportsWeakReference");
       // Let's cache the result of this QI for fast access and off main thread usage
       mOwnerWindow = nsCOMPtr<nsPIDOMWindowInner>(do_QueryInterface(aOther->GetParentObject())).get();
       if (mOwnerWindow) {
         mHasOrHasHadOwnerWindow = true;
-        nsGlobalWindow::Cast(mOwnerWindow)->AddEventTargetObject(this);
+        nsGlobalWindowInner::Cast(mOwnerWindow)->AddEventTargetObject(this);
       }
     }
   }
 }
 
 void
 DOMEventTargetHelper::DisconnectFromOwner()
 {
@@ -336,17 +336,17 @@ DOMEventTargetHelper::GetExistingListene
 nsIScriptContext*
 DOMEventTargetHelper::GetContextForEventHandlers(nsresult* aRv)
 {
   *aRv = CheckInnerWindowCorrectness();
   if (NS_FAILED(*aRv)) {
     return nullptr;
   }
   nsPIDOMWindowInner* owner = GetOwner();
-  return owner ? nsGlobalWindow::Cast(owner)->GetContextInternal()
+  return owner ? nsGlobalWindowInner::Cast(owner)->GetContextInternal()
                : nullptr;
 }
 
 nsresult
 DOMEventTargetHelper::WantsUntrusted(bool* aRetVal)
 {
   nsresult rv = CheckInnerWindowCorrectness();
   NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -47,17 +47,17 @@ Event::Event(EventTarget* aOwner,
              nsPresContext* aPresContext,
              WidgetEvent* aEvent)
 {
   ConstructorInit(aOwner, aPresContext, aEvent);
 }
 
 Event::Event(nsPIDOMWindowInner* aParent)
 {
-  ConstructorInit(nsGlobalWindow::Cast(aParent), nullptr, nullptr);
+  ConstructorInit(nsGlobalWindowInner::Cast(aParent), nullptr, nullptr);
 }
 
 void
 Event::ConstructorInit(EventTarget* aOwner,
                        nsPresContext* aPresContext,
                        WidgetEvent* aEvent)
 {
   SetOwner(aOwner);
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -2079,17 +2079,18 @@ EventStateManager::GetContentViewer(nsIC
 
     nsCOMPtr<mozIDOMWindowProxy> activeWindow;
     fm->GetActiveWindow(getter_AddRefs(activeWindow));
     if (rootWindow != activeWindow) return NS_OK;
   } else {
     if (!tabChild->ParentIsActive()) return NS_OK;
   }
 
-  nsCOMPtr<nsPIDOMWindowOuter> contentWindow = nsGlobalWindow::Cast(rootWindow)->GetContent();
+  nsCOMPtr<nsPIDOMWindowOuter> contentWindow =
+    nsGlobalWindowOuter::Cast(rootWindow)->GetContent();
   if (!contentWindow) return NS_ERROR_FAILURE;
 
   nsIDocument *doc = contentWindow->GetDoc();
   if (!doc) return NS_ERROR_FAILURE;
 
   nsCOMPtr<nsISupports> container = doc->GetContainer();
   if (!container) return NS_ERROR_FAILURE;
 
--- a/dom/events/MouseEvent.cpp
+++ b/dom/events/MouseEvent.cpp
@@ -111,17 +111,17 @@ MouseEvent::InitMouseEvent(const nsAStri
                            bool aCtrlKey,
                            bool aAltKey,
                            bool aShiftKey,
                            bool aMetaKey,
                            uint16_t aButton,
                            nsIDOMEventTarget* aRelatedTarget)
 {
   MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
-                             nsGlobalWindow::Cast(aView), aDetail,
+                             nsGlobalWindowInner::Cast(aView), aDetail,
                              aScreenX, aScreenY,
                              aClientX, aClientY,
                              aCtrlKey, aAltKey, aShiftKey,
                              aMetaKey, aButton,
                              static_cast<EventTarget *>(aRelatedTarget));
 
   return NS_OK;
 }
--- a/dom/events/TouchEvent.cpp
+++ b/dom/events/TouchEvent.cpp
@@ -166,17 +166,17 @@ TouchEvent::ChangedTouches()
 }
 
 // static
 bool
 TouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
 {
   nsIDocShell* docShell = nullptr;
   if (aGlobal) {
-    nsGlobalWindow* win = xpc::WindowOrNull(aGlobal);
+    nsGlobalWindowInner* win = xpc::WindowOrNull(aGlobal);
     if (win) {
       docShell = win->GetDocShell();
     }
   }
   return PrefEnabled(docShell);
 }
 
 // static
--- a/dom/events/XULCommandEvent.cpp
+++ b/dom/events/XULCommandEvent.cpp
@@ -125,17 +125,17 @@ XULCommandEvent::InitCommandEvent(const 
                                   bool aAltKey,
                                   bool aShiftKey,
                                   bool aMetaKey,
                                   nsIDOMEvent* aSourceEvent,
                                   uint16_t aInputSource)
 {
   NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
 
-  auto* view = nsGlobalWindow::Cast(nsPIDOMWindowInner::From(aView));
+  auto* view = nsGlobalWindowInner::Cast(nsPIDOMWindowInner::From(aView));
   UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, view, aDetail);
 
   mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
                                              aShiftKey, aMetaKey);
   mSourceEvent = aSourceEvent;
   mInputSource = aInputSource;
 
   return NS_OK;
--- a/dom/flyweb/FlyWebPublishedServer.cpp
+++ b/dom/flyweb/FlyWebPublishedServer.cpp
@@ -135,17 +135,17 @@ FlyWebPublishedServer::OnWebSocketAccept
                               aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
   MOZ_ASSERT(provider);
 
   nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetOwner());
   AutoJSContext cx;
-  GlobalObject global(cx, nsGlobalWindow::Cast(window)->FastGetGlobalJSObject());
+  GlobalObject global(cx, nsGlobalWindowInner::Cast(window)->FastGetGlobalJSObject());
 
   nsAutoCString extensions, negotiatedExtensions;
   aConnectRequest->Headers()->
     GetFirst(NS_LITERAL_CSTRING("Sec-WebSocket-Extensions"), extensions, aRv);
   mozilla::net::ProcessServerWebSocketExtensions(extensions,
                                                  negotiatedExtensions);
 
   nsCString url;
--- a/dom/flyweb/FlyWebService.cpp
+++ b/dom/flyweb/FlyWebService.cpp
@@ -63,17 +63,17 @@ public:
   {
     return mWindowID;
   }
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
-    nsGlobalWindow* globalWindow = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
+    nsGlobalWindowInner* globalWindow = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
     if (!globalWindow) {
       return Cancel();
     }
     mWindow = globalWindow->AsInner();
     if (NS_WARN_IF(!mWindow)) {
       return Cancel();
     }
 
--- a/dom/gamepad/GamepadManager.cpp
+++ b/dom/gamepad/GamepadManager.cpp
@@ -41,18 +41,18 @@ namespace mozilla {
 namespace dom {
 
 namespace {
 
 const char* kGamepadEnabledPref = "dom.gamepad.enabled";
 const char* kGamepadEventsEnabledPref =
   "dom.gamepad.non_standard_events.enabled";
 
-const nsTArray<RefPtr<nsGlobalWindow>>::index_type NoIndex =
-  nsTArray<RefPtr<nsGlobalWindow>>::NoIndex;
+const nsTArray<RefPtr<nsGlobalWindowInner>>::index_type NoIndex =
+  nsTArray<RefPtr<nsGlobalWindowInner>>::NoIndex;
 
 bool sShutdown = false;
 
 StaticRefPtr<GamepadManager> gGamepadManagerSingleton;
 const uint32_t VR_GAMEPAD_IDX_OFFSET = 0x01 << 16;
 
 } // namespace
 
@@ -127,17 +127,17 @@ GamepadManager::BeginShutdown()
   for (uint32_t i = 0; i < mListeners.Length(); i++) {
     mListeners[i]->SetHasGamepadEventListener(false);
   }
   mListeners.Clear();
   sShutdown = true;
 }
 
 void
-GamepadManager::AddListener(nsGlobalWindow* aWindow)
+GamepadManager::AddListener(nsGlobalWindowInner* aWindow)
 {
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aWindow->IsInnerWindow());
   MOZ_ASSERT(NS_IsMainThread());
 
   // IPDL child has not been created
   if (mChannelChildren.IsEmpty()) {
     PBackgroundChild* actor = BackgroundChild::GetOrCreateForCurrentThread();
@@ -173,17 +173,17 @@ GamepadManager::AddListener(nsGlobalWind
   if (mListeners.IndexOf(aWindow) != NoIndex) {
     return; // already exists
   }
 
   mListeners.AppendElement(aWindow);
 }
 
 void
-GamepadManager::RemoveListener(nsGlobalWindow* aWindow)
+GamepadManager::RemoveListener(nsGlobalWindowInner* aWindow)
 {
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aWindow->IsInnerWindow());
 
   if (mShuttingDown) {
     // Doesn't matter at this point. It's possible we're being called
     // as a result of our own destructor here, so just bail out.
     return;
@@ -344,17 +344,17 @@ GamepadManager::NewConnectionEvent(uint3
 
   RefPtr<Gamepad> gamepad = GetGamepad(aIndex);
   if (!gamepad) {
     return;
   }
 
   // Hold on to listeners in a separate array because firing events
   // can mutate the mListeners array.
-  nsTArray<RefPtr<nsGlobalWindow>> listeners(mListeners);
+  nsTArray<RefPtr<nsGlobalWindowInner>> listeners(mListeners);
 
   if (aConnected) {
     for (uint32_t i = 0; i < listeners.Length(); i++) {
 
       MOZ_ASSERT(listeners[i]->IsInnerWindow());
 
       // Only send events to non-background windows
       if (!listeners[i]->AsInner()->IsCurrentInnerWindow() ||
@@ -463,36 +463,36 @@ GamepadManager::GetService()
 
 // static
 bool
 GamepadManager::IsAPIEnabled() {
   return Preferences::GetBool(kGamepadEnabledPref, false);
 }
 
 bool
-GamepadManager::MaybeWindowHasSeenGamepad(nsGlobalWindow* aWindow, uint32_t aIndex)
+GamepadManager::MaybeWindowHasSeenGamepad(nsGlobalWindowInner* aWindow, uint32_t aIndex)
 {
   if (!WindowHasSeenGamepad(aWindow, aIndex)) {
     // This window hasn't seen this gamepad before, so
     // send a connection event first.
     SetWindowHasSeenGamepad(aWindow, aIndex);
     return true;
   }
   return false;
 }
 
 bool
-GamepadManager::WindowHasSeenGamepad(nsGlobalWindow* aWindow, uint32_t aIndex) const
+GamepadManager::WindowHasSeenGamepad(nsGlobalWindowInner* aWindow, uint32_t aIndex) const
 {
   RefPtr<Gamepad> gamepad = aWindow->GetGamepad(aIndex);
   return gamepad != nullptr;
 }
 
 void
-GamepadManager::SetWindowHasSeenGamepad(nsGlobalWindow* aWindow,
+GamepadManager::SetWindowHasSeenGamepad(nsGlobalWindowInner* aWindow,
                                         uint32_t aIndex,
                                         bool aHasSeen)
 {
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aWindow->IsInnerWindow());
 
   if (mListeners.IndexOf(aWindow) == NoIndex) {
     // This window isn't even listening for gamepad events.
@@ -541,17 +541,17 @@ GamepadManager::Update(const GamepadChan
   }
 
   if (!SetGamepadByEvent(aEvent)) {
     return;
   }
 
   // Hold on to listeners in a separate array because firing events
   // can mutate the mListeners array.
-  nsTArray<RefPtr<nsGlobalWindow>> listeners(mListeners);
+  nsTArray<RefPtr<nsGlobalWindowInner>> listeners(mListeners);
 
   for (uint32_t i = 0; i < listeners.Length(); i++) {
     MOZ_ASSERT(listeners[i]->IsInnerWindow());
 
     // Only send events to non-background windows
     if (!listeners[i]->AsInner()->IsCurrentInnerWindow() ||
         listeners[i]->GetOuterWindow()->IsBackground()) {
       continue;
@@ -559,17 +559,17 @@ GamepadManager::Update(const GamepadChan
 
     SetGamepadByEvent(aEvent, listeners[i]);
     MaybeConvertToNonstandardGamepadEvent(aEvent, listeners[i]);
   }
 }
 
 void
 GamepadManager::MaybeConvertToNonstandardGamepadEvent(const GamepadChangeEvent& aEvent,
-                                                      nsGlobalWindow* aWindow)
+                                                      nsGlobalWindowInner* aWindow)
 {
   MOZ_ASSERT(aWindow);
 
   if (!mNonstandardEventsEnabled) {
     return;
   }
 
   const uint32_t index = GetGamepadIndexWithServiceType(aEvent.index(),
@@ -593,17 +593,17 @@ GamepadManager::MaybeConvertToNonstandar
       }
       default:
         break;
     }
   }
 }
 
 bool
-GamepadManager::SetGamepadByEvent(const GamepadChangeEvent& aEvent, nsGlobalWindow *aWindow)
+GamepadManager::SetGamepadByEvent(const GamepadChangeEvent& aEvent, nsGlobalWindowInner *aWindow)
 {
   bool ret = false;
   bool firstTime = false;
   const uint32_t index = GetGamepadIndexWithServiceType(aEvent.index(),
                                                         aEvent.service_type());
   if (aWindow) {
     firstTime = MaybeWindowHasSeenGamepad(aWindow, index);
   }
--- a/dom/gamepad/GamepadManager.h
+++ b/dom/gamepad/GamepadManager.h
@@ -7,17 +7,17 @@
 #ifndef mozilla_dom_GamepadManager_h_
 #define mozilla_dom_GamepadManager_h_
 
 #include "nsIObserver.h"
 // Needed for GamepadMappingType
 #include "mozilla/dom/GamepadBinding.h"
 #include "mozilla/dom/GamepadServiceType.h"
 
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 
 namespace mozilla {
 namespace gfx {
 class VRManagerChild;
 } // namespace gfx
 namespace dom {
 
 class EventTarget;
@@ -37,19 +37,19 @@ class GamepadManager final : public nsIO
   static already_AddRefed<GamepadManager> GetService();
   // Return true if the API is preffed on.
   static bool IsAPIEnabled();
 
   void BeginShutdown();
   void StopMonitoring();
 
   // Indicate that |aWindow| wants to receive gamepad events.
-  void AddListener(nsGlobalWindow* aWindow);
+  void AddListener(nsGlobalWindowInner* aWindow);
   // Indicate that |aWindow| should no longer receive gamepad events.
-  void RemoveListener(nsGlobalWindow* aWindow);
+  void RemoveListener(nsGlobalWindowInner* aWindow);
 
   // Add a gamepad to the list of known gamepads.
   void AddGamepad(uint32_t aIndex, const nsAString& aID, GamepadMappingType aMapping,
                   GamepadHand aHand, GamepadServiceType aServiceType, uint32_t aDisplayID,
                   uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aNumHaptics);
 
   // Remove the gamepad at |aIndex| from the list of known gamepads.
   void RemoveGamepad(uint32_t aIndex, GamepadServiceType aServiceType);
@@ -111,38 +111,39 @@ class GamepadManager final : public nsIO
   // don't need to refcount it here.
   nsTArray<GamepadEventChannelChild *> mChannelChildren;
 
  private:
 
   nsresult Init();
 
   void MaybeConvertToNonstandardGamepadEvent(const GamepadChangeEvent& aEvent,
-                                             nsGlobalWindow* aWindow);
+                                             nsGlobalWindowInner* aWindow);
 
-  bool SetGamepadByEvent(const GamepadChangeEvent& aEvent, nsGlobalWindow* aWindow = nullptr);
+  bool SetGamepadByEvent(const GamepadChangeEvent& aEvent,
+                         nsGlobalWindowInner* aWindow = nullptr);
 
-  bool MaybeWindowHasSeenGamepad(nsGlobalWindow* aWindow, uint32_t aIndex);
+  bool MaybeWindowHasSeenGamepad(nsGlobalWindowInner* aWindow, uint32_t aIndex);
   // Returns true if we have already sent data from this gamepad
   // to this window. This should only return true if the user
   // explicitly interacted with a gamepad while this window
   // was focused, by pressing buttons or similar actions.
-  bool WindowHasSeenGamepad(nsGlobalWindow* aWindow, uint32_t aIndex) const;
+  bool WindowHasSeenGamepad(nsGlobalWindowInner* aWindow, uint32_t aIndex) const;
   // Indicate that a window has received data from a gamepad.
-  void SetWindowHasSeenGamepad(nsGlobalWindow* aWindow, uint32_t aIndex,
+  void SetWindowHasSeenGamepad(nsGlobalWindowInner* aWindow, uint32_t aIndex,
                                bool aHasSeen = true);
   // Our gamepad index has VR_GAMEPAD_IDX_OFFSET while GamepadChannelType
   // is from VRManager.
   uint32_t GetGamepadIndexWithServiceType(uint32_t aIndex, GamepadServiceType aServiceType);
 
   // Gamepads connected to the system. Copies of these are handed out
   // to each window.
   nsRefPtrHashtable<nsUint32HashKey, Gamepad> mGamepads;
   // Inner windows that are listening for gamepad events.
   // has been sent to that window.
-  nsTArray<RefPtr<nsGlobalWindow>> mListeners;
+  nsTArray<RefPtr<nsGlobalWindowInner>> mListeners;
   uint32_t mPromiseID;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_GamepadManager_h_
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -1190,17 +1190,17 @@ Geolocation::ShouldBlockInsecureRequests
     return false;
   }
 
   nsCOMPtr<nsIDocument> doc = win->GetDoc();
   if (!doc) {
     return false;
   }
 
-  if (!nsGlobalWindow::Cast(win)->IsSecureContextIfOpenerIgnored()) {
+  if (!nsGlobalWindowInner::Cast(win)->IsSecureContextIfOpenerIgnored()) {
     nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
                                     NS_LITERAL_CSTRING("DOM"), doc,
                                     nsContentUtils::eDOM_PROPERTIES,
                                     "GeolocationInsecureRequestIsForbidden");
     return true;
   }
 
   return false;
--- a/dom/html/HTMLBodyElement.cpp
+++ b/dom/html/HTMLBodyElement.cpp
@@ -343,30 +343,30 @@ HTMLBodyElement::AfterSetAttr(int32_t aN
 // nsGenericHTMLElement::GetOnError returns
 // already_AddRefed<EventHandlerNonNull> while other getters return
 // EventHandlerNonNull*, so allow passing in the type to use here.
 #define WINDOW_EVENT_HELPER(name_, type_)                                      \
   type_*                                                                       \
   HTMLBodyElement::GetOn##name_()                                              \
   {                                                                            \
     if (nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow()) {              \
-      nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win);                   \
+      nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win);         \
       return globalWin->GetOn##name_();                                        \
     }                                                                          \
     return nullptr;                                                            \
   }                                                                            \
   void                                                                         \
   HTMLBodyElement::SetOn##name_(type_* handler)                                \
   {                                                                            \
     nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow();                    \
     if (!win) {                                                                \
       return;                                                                  \
     }                                                                          \
                                                                                \
-    nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win);                     \
+    nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win);           \
     return globalWin->SetOn##name_(handler);                                   \
   }
 #define WINDOW_EVENT(name_, id_, type_, struct_)                               \
   WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                         \
   WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
 #include "mozilla/EventNameList.h" // IWYU pragma: keep
 #undef BEFOREUNLOAD_EVENT
--- a/dom/html/HTMLFrameSetElement.cpp
+++ b/dom/html/HTMLFrameSetElement.cpp
@@ -314,30 +314,30 @@ HTMLFrameSetElement::IsEventAttributeNam
 // nsGenericHTMLElement::GetOnError returns
 // already_AddRefed<EventHandlerNonNull> while other getters return
 // EventHandlerNonNull*, so allow passing in the type to use here.
 #define WINDOW_EVENT_HELPER(name_, type_)                                      \
   type_*                                                                       \
   HTMLFrameSetElement::GetOn##name_()                                          \
   {                                                                            \
     if (nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow()) {              \
-      nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win);                   \
+      nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win);         \
       return globalWin->GetOn##name_();                                        \
     }                                                                          \
     return nullptr;                                                            \
   }                                                                            \
   void                                                                         \
   HTMLFrameSetElement::SetOn##name_(type_* handler)                            \
   {                                                                            \
     nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow();                    \
     if (!win) {                                                                \
       return;                                                                  \
     }                                                                          \
                                                                                \
-    nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win);                     \
+    nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win);           \
     return globalWin->SetOn##name_(handler);                                   \
   }
 #define WINDOW_EVENT(name_, id_, type_, struct_)                               \
   WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                         \
   WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
 #include "mozilla/EventNameList.h" // IWYU pragma: keep
 #undef BEFOREUNLOAD_EVENT
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -633,17 +633,17 @@ private:
 void
 TextTrackManager::DispatchUpdateCueDisplay()
 {
   if (!mUpdateCueDisplayDispatched && !IsShutdown() &&
       (mMediaElement->GetHasUserInteraction() || mMediaElement->IsCurrentlyPlaying())) {
     WEBVTT_LOG("DispatchUpdateCueDisplay");
     nsPIDOMWindowInner* win = mMediaElement->OwnerDoc()->GetInnerWindow();
     if (win) {
-      nsGlobalWindow::Cast(win)->Dispatch(
+      nsGlobalWindowInner::Cast(win)->Dispatch(
         TaskCategory::Other,
         NewRunnableMethod("dom::TextTrackManager::UpdateCueDisplay",
                           this,
                           &TextTrackManager::UpdateCueDisplay));
       mUpdateCueDisplayDispatched = true;
     }
   }
 }
@@ -655,17 +655,17 @@ TextTrackManager::DispatchTimeMarchesOn(
   // enqueue the current playback position and whether only that changed
   // through its usual monotonic increase during normal playback; current
   // executing call upon completion will check queue for further 'work'.
   if (!mTimeMarchesOnDispatched && !IsShutdown() &&
       (mMediaElement->GetHasUserInteraction() || mMediaElement->IsCurrentlyPlaying())) {
     WEBVTT_LOG("DispatchTimeMarchesOn");
     nsPIDOMWindowInner* win = mMediaElement->OwnerDoc()->GetInnerWindow();
     if (win) {
-      nsGlobalWindow::Cast(win)->Dispatch(
+      nsGlobalWindowInner::Cast(win)->Dispatch(
         TaskCategory::Other,
         NewRunnableMethod("dom::TextTrackManager::TimeMarchesOn",
                           this,
                           &TextTrackManager::TimeMarchesOn));
       mTimeMarchesOnDispatched = true;
     }
   }
 }
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -842,47 +842,47 @@ nsGenericHTMLElement::GetEventListenerMa
 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by nsINode */
 #define FORWARDED_EVENT(name_, id_, type_, struct_)                           \
 EventHandlerNonNull*                                                          \
 nsGenericHTMLElement::GetOn##name_()                                          \
 {                                                                             \
   if (IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset)) {            \
     /* XXXbz note to self: add tests for this! */                             \
     if (nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow()) {             \
-      nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win);                  \
+      nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win);        \
       return globalWin->GetOn##name_();                                       \
     }                                                                         \
     return nullptr;                                                           \
   }                                                                           \
                                                                               \
   return nsINode::GetOn##name_();                                             \
 }                                                                             \
 void                                                                          \
 nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler)              \
 {                                                                             \
   if (IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset)) {            \
     nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow();                   \
     if (!win) {                                                               \
       return;                                                                 \
     }                                                                         \
                                                                               \
-    nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win);                    \
+    nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win);          \
     return globalWin->SetOn##name_(handler);                                  \
   }                                                                           \
                                                                               \
   return nsINode::SetOn##name_(handler);                                      \
 }
 #define ERROR_EVENT(name_, id_, type_, struct_)                               \
 already_AddRefed<EventHandlerNonNull>                                         \
 nsGenericHTMLElement::GetOn##name_()                                          \
 {                                                                             \
   if (IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset)) {            \
     /* XXXbz note to self: add tests for this! */                             \
     if (nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow()) {             \
-      nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win);                  \
+      nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win);        \
       OnErrorEventHandlerNonNull* errorHandler = globalWin->GetOn##name_();   \
       if (errorHandler) {                                                     \
         RefPtr<EventHandlerNonNull> handler =                                 \
           new EventHandlerNonNull(errorHandler);                              \
         return handler.forget();                                              \
       }                                                                       \
     }                                                                         \
     return nullptr;                                                           \
@@ -895,17 +895,17 @@ void                                    
 nsGenericHTMLElement::SetOn##name_(EventHandlerNonNull* handler)              \
 {                                                                             \
   if (IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset)) {            \
     nsPIDOMWindowInner* win = OwnerDoc()->GetInnerWindow();                   \
     if (!win) {                                                               \
       return;                                                                 \
     }                                                                         \
                                                                               \
-    nsGlobalWindow* globalWin = nsGlobalWindow::Cast(win);                    \
+    nsGlobalWindowInner* globalWin = nsGlobalWindowInner::Cast(win);          \
     RefPtr<OnErrorEventHandlerNonNull> errorHandler;                          \
     if (handler) {                                                            \
       errorHandler = new OnErrorEventHandlerNonNull(handler);                 \
     }                                                                         \
     return globalWin->SetOn##name_(errorHandler);                             \
   }                                                                           \
                                                                               \
   return nsINode::SetOn##name_(handler);                                      \
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -1473,17 +1473,17 @@ nsHTMLDocument::Open(JSContext* /* unuse
     return nullptr;
   }
   nsCOMPtr<nsPIDOMWindowOuter> outer =
     nsPIDOMWindowOuter::GetFromCurrentInner(window);
   if (!outer) {
     rv.Throw(NS_ERROR_NOT_INITIALIZED);
     return nullptr;
   }
-  RefPtr<nsGlobalWindow> win = nsGlobalWindow::Cast(outer);
+  RefPtr<nsGlobalWindowOuter> win = nsGlobalWindowOuter::Cast(outer);
   nsCOMPtr<nsPIDOMWindowOuter> newWindow;
   // XXXbz We ignore aReplace for now.
   rv = win->OpenJS(aURL, aName, aFeatures, getter_AddRefs(newWindow));
   return newWindow.forget();
 }
 
 already_AddRefed<nsIDocument>
 nsHTMLDocument::Open(JSContext* cx,
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -138,17 +138,17 @@ IDBFactory::CreateForWindow(nsPIDOMWindo
   nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
   nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
 
   RefPtr<IDBFactory> factory = new IDBFactory();
   factory->mPrincipalInfo = Move(principalInfo);
   factory->mWindow = aWindow;
   factory->mTabChild = TabChild::GetFrom(aWindow);
   factory->mEventTarget =
-    nsGlobalWindow::Cast(aWindow)->EventTargetFor(TaskCategory::Other);
+    nsGlobalWindowInner::Cast(aWindow)->EventTargetFor(TaskCategory::Other);
   factory->mInnerWindowID = aWindow->WindowID();
   factory->mPrivateBrowsingMode =
     loadContext && loadContext->UsePrivateBrowsing();
 
   factory.forget(aFactory);
   return NS_OK;
 }
 
@@ -736,17 +736,17 @@ IDBFactory::OpenInternal(JSContext* aCx,
       threadLocal->mIndexedDBThreadLocal = newIDBThreadLocal.forget();
     }
   }
 
   RefPtr<IDBOpenDBRequest> request;
 
   if (mWindow) {
     JS::Rooted<JSObject*> scriptOwner(aCx,
-                                      nsGlobalWindow::Cast(mWindow.get())->FastGetGlobalJSObject());
+                                      nsGlobalWindowInner::Cast(mWindow.get())->FastGetGlobalJSObject());
     MOZ_ASSERT(scriptOwner);
 
     request = IDBOpenDBRequest::CreateForWindow(aCx, this, mWindow, scriptOwner);
   } else {
     JS::Rooted<JSObject*> scriptOwner(aCx, mOwningObject);
 
     request = IDBOpenDBRequest::CreateForJS(aCx, this, scriptOwner);
     if (!request) {
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -2550,17 +2550,17 @@ TabChild::RecvSetUseGlobalHistory(const 
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 TabChild::RecvPrint(const uint64_t& aOuterWindowID, const PrintData& aPrintData)
 {
 #ifdef NS_PRINTING
-  nsGlobalWindow* outerWindow =
+  nsGlobalWindowOuter* outerWindow =
     nsGlobalWindow::GetOuterWindowWithId(aOuterWindowID);
   if (NS_WARN_IF(!outerWindow)) {
     return IPC_OK();
   }
 
   nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint =
     do_GetInterface(outerWindow->AsOuter());
   if (NS_WARN_IF(!webBrowserPrint)) {
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1036,17 +1036,17 @@ public:
     // DOMMediaStream::NotifyMediaStreamGraphShutdown is called.
     RefPtr<DOMMediaStream> mStream;
   };
 
   NS_IMETHOD
   Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
-    nsGlobalWindow* globalWindow = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
+    nsGlobalWindowInner* globalWindow = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
     nsPIDOMWindowInner* window = globalWindow ? globalWindow->AsInner() : nullptr;
 
     // We're on main-thread, and the windowlist can only
     // be invalidated from the main-thread (see OnNavigation)
     GetUserMediaWindowListener* listener =
       mManager->GetWindowListener(mWindowID);
     if (!listener || !window || !window->GetExtantDoc()) {
       // This window is no longer live.  mListener has already been removed
@@ -2147,17 +2147,17 @@ static bool IsFullyActive(nsPIDOMWindowI
     nsPIDOMWindowOuter* context = aWindow->GetOuterWindow();
     if (!context) {
       return false;
     }
     if (context->IsTopLevelWindow()) {
       return true;
     }
     nsCOMPtr<Element> frameElement =
-      nsGlobalWindow::Cast(context)->GetRealFrameElementOuter();
+      nsGlobalWindowOuter::Cast(context)->GetRealFrameElementOuter();
     if (!frameElement) {
       return false;
     }
     aWindow = frameElement->OwnerDoc()->GetInnerWindow();
   }
 }
 
 enum class GetUserMediaSecurityState {
@@ -2263,17 +2263,17 @@ MediaManager::GetUserMedia(nsPIDOMWindow
     Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_SECURE_ORIGIN,
                           (uint32_t) GetUserMediaSecurityState::Localhost);
   } else {
     Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_SECURE_ORIGIN,
                           (uint32_t) GetUserMediaSecurityState::Other);
   }
 
   nsCOMPtr<nsIPrincipal> principal =
-    nsGlobalWindow::Cast(aWindow)->GetPrincipal();
+    nsGlobalWindowInner::Cast(aWindow)->GetPrincipal();
   if (NS_WARN_IF(!principal)) {
     return NS_ERROR_FAILURE;
   }
 
   // This principal needs to be sent to different threads and so via IPC.
   // For this reason it's better to convert it to PrincipalInfo right now.
   ipc::PrincipalInfo principalInfo;
   rv = PrincipalToPrincipalInfo(principal, &principalInfo);
@@ -2713,17 +2713,17 @@ MediaManager::EnumerateDevicesImpl(uint6
   uint32_t id = mOutstandingPledges.Append(*pledge);
 
   // To get a device list anonymized for a particular origin, we must:
   // 1. Get an origin-key (for either regular or private browsing)
   // 2. Get the raw devices list
   // 3. Anonymize the raw list with the origin-key.
 
   nsCOMPtr<nsIPrincipal> principal =
-    nsGlobalWindow::Cast(window)->GetPrincipal();
+    nsGlobalWindowInner::Cast(window)->GetPrincipal();
   MOZ_ASSERT(principal);
 
   ipc::PrincipalInfo principalInfo;
   nsresult rv = PrincipalToPrincipalInfo(principal, &principalInfo);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     RefPtr<PledgeSourceSet> p = new PledgeSourceSet();
     RefPtr<MediaStreamError> error =
       new MediaStreamError(window, NS_LITERAL_STRING("NotAllowedError"));
@@ -4189,15 +4189,15 @@ GetUserMediaNotificationEvent::Run()
     msg = NS_LITERAL_STRING("starting");
     stream->OnTracksAvailable(mOnTracksAvailableCallback->release());
     break;
   case STOPPING:
     msg = NS_LITERAL_STRING("shutdown");
     break;
   }
 
-  RefPtr<nsGlobalWindow> window = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
+  RefPtr<nsGlobalWindowInner> window = nsGlobalWindow::GetInnerWindowWithId(mWindowID);
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
   return MediaManager::NotifyRecordingStatusChange(window->AsInner(), msg);
 }
 
 } // namespace mozilla
--- a/dom/media/TextTrack.cpp
+++ b/dom/media/TextTrack.cpp
@@ -331,17 +331,17 @@ TextTrack::GetLanguage(nsAString& aLangu
 void
 TextTrack::DispatchAsyncTrustedEvent(const nsString& aEventName)
 {
   nsPIDOMWindowInner* win = GetOwner();
   if (!win) {
     return;
   }
   RefPtr<TextTrack> self = this;
-  nsGlobalWindow::Cast(win)->Dispatch(
+  nsGlobalWindowInner::Cast(win)->Dispatch(
     TaskCategory::Other,
     NS_NewRunnableFunction(
       "dom::TextTrack::DispatchAsyncTrustedEvent",
       [self, aEventName]() { self->DispatchTrustedEvent(aEventName); }));
 }
 
 bool
 TextTrack::IsLoaded()
--- a/dom/media/TextTrackList.cpp
+++ b/dom/media/TextTrackList.cpp
@@ -188,17 +188,17 @@ TextTrackList::CreateAndDispatchChangeEv
 
     mPendingTextTrackChange = true;
     RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
 
     event->InitEvent(NS_LITERAL_STRING("change"), false, false);
     event->SetTrusted(true);
 
     nsCOMPtr<nsIRunnable> eventRunner = new ChangeEventRunner(this, event);
-    nsGlobalWindow::Cast(win)->Dispatch(TaskCategory::Other, eventRunner.forget());
+    nsGlobalWindowInner::Cast(win)->Dispatch(TaskCategory::Other, eventRunner.forget());
   }
 }
 
 void
 TextTrackList::CreateAndDispatchTrackEventRunner(TextTrack* aTrack,
                                                  const nsAString& aEventName)
 {
   DebugOnly<nsresult> rv;
--- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp
@@ -84,17 +84,17 @@ MediaEngineTabVideoSource::Notify(nsITim
   Draw();
   return NS_OK;
 }
 
 nsresult
 MediaEngineTabVideoSource::InitRunnable::Run()
 {
   if (mVideoSource->mWindowId != -1) {
-    nsGlobalWindow* globalWindow =
+    nsGlobalWindowOuter* globalWindow =
       nsGlobalWindow::GetOuterWindowWithId(mVideoSource->mWindowId);
     if (!globalWindow) {
       // We can't access the window, just send a blacked out screen.
       mVideoSource->mWindow = nullptr;
       mVideoSource->mBlackedoutWindow = true;
     } else {
       nsCOMPtr<nsPIDOMWindowOuter> window = globalWindow->AsOuter();
       if (window) {
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -695,17 +695,17 @@ NPObject*
   // The window want to return here is the outer window, *not* the inner (since
   // we don't know what the plugin will do with it).
   nsIDocument* doc = GetDocumentFromNPP(npp);
   NS_ENSURE_TRUE(doc, nullptr);
   nsCOMPtr<nsPIDOMWindowOuter> outer = doc->GetWindow();
   NS_ENSURE_TRUE(outer, nullptr);
 
   JS::Rooted<JSObject*> global(dom::RootingCx(),
-                               nsGlobalWindow::Cast(outer)->GetGlobalJSObject());
+                               nsGlobalWindowOuter::Cast(outer)->GetGlobalJSObject());
   return nsJSObjWrapper::GetNewOrUsed(npp, global);
 }
 
 NPObject*
 _getpluginelement(NPP npp)
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_getpluginelement called from the wrong thread\n"));
@@ -971,17 +971,17 @@ bool
   if (!npp)
     return false;
 
   NPPAutoPusher nppPusher(npp);
 
   nsIDocument *doc = GetDocumentFromNPP(npp);
   NS_ENSURE_TRUE(doc, false);
 
-  nsGlobalWindow* win = nsGlobalWindow::Cast(doc->GetInnerWindow());
+  nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(doc->GetInnerWindow());
   if (NS_WARN_IF(!win || !win->FastGetGlobalJSObject())) {
     return false;
   }
 
   nsAutoMicroTask mt;
   dom::AutoEntryScript aes(win, "NPAPI NPN_evaluate");
   JSContext* cx = aes.cx();
 
--- a/dom/presentation/PresentationRequest.cpp
+++ b/dom/presentation/PresentationRequest.cpp
@@ -183,17 +183,17 @@ PresentationRequest::StartWithDevice(con
     return promise.forget();
   }
 
   if (doc->GetSandboxFlags() & SANDBOXED_PRESENTATION) {
     promise->MaybeReject(NS_ERROR_DOM_SECURITY_ERR);
     return promise.forget();
   }
 
-  RefPtr<Navigator> navigator = nsGlobalWindow::Cast(GetOwner())->Navigator();
+  RefPtr<Navigator> navigator = nsGlobalWindowInner::Cast(GetOwner())->Navigator();
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
 
   RefPtr<Presentation> presentation = navigator->GetPresentation(aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
@@ -483,17 +483,17 @@ void
 PresentationRequest::NotifyPromiseSettled()
 {
   PRES_DEBUG("%s\n", __func__);
 
   if (!GetOwner()) {
     return;
   }
 
-  RefPtr<Navigator> navigator = nsGlobalWindow::Cast(GetOwner())->Navigator();
+  RefPtr<Navigator> navigator = nsGlobalWindowInner::Cast(GetOwner())->Navigator();
   if (!navigator) {
     return;
   }
 
   ErrorResult rv;
   RefPtr<Presentation> presentation = navigator->GetPresentation(rv);
 
   if (presentation) {
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -492,17 +492,19 @@ Promise::ReportRejectedPromise(JSContext
     JS_ClearPendingException(aCx);
     return;
   }
 
   RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
   bool isMainThread = MOZ_LIKELY(NS_IsMainThread());
   bool isChrome = isMainThread ? nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(aPromise))
                                : GetCurrentThreadWorkerPrivate()->IsChromeWorker();
-  nsGlobalWindow* win = isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr;
+  nsGlobalWindowInner* win = isMainThread
+    ? xpc::WindowGlobalOrNull(aPromise)
+    : nullptr;
   xpcReport->Init(report.report(), report.toStringResult().c_str(), isChrome,
                   win ? win->AsInner()->WindowID() : 0);
 
   // Now post an event to do the real reporting async
   NS_DispatchToMainThread(new AsyncErrorReporter(xpcReport));
 }
 
 bool
--- a/dom/script/ScriptSettings.cpp
+++ b/dom/script/ScriptSettings.cpp
@@ -500,33 +500,33 @@ bool
 AutoJSAPI::Init(JSObject* aObject)
 {
   return Init(xpc::NativeGlobal(aObject));
 }
 
 bool
 AutoJSAPI::Init(nsPIDOMWindowInner* aWindow, JSContext* aCx)
 {
-  return Init(nsGlobalWindow::Cast(aWindow), aCx);
+  return Init(nsGlobalWindowInner::Cast(aWindow), aCx);
 }
 
 bool
 AutoJSAPI::Init(nsPIDOMWindowInner* aWindow)
 {
-  return Init(nsGlobalWindow::Cast(aWindow));
+  return Init(nsGlobalWindowInner::Cast(aWindow));
 }
 
 bool
-AutoJSAPI::Init(nsGlobalWindow* aWindow, JSContext* aCx)
+AutoJSAPI::Init(nsGlobalWindowInner* aWindow, JSContext* aCx)
 {
   return Init(static_cast<nsIGlobalObject*>(aWindow), aCx);
 }
 
 bool
-AutoJSAPI::Init(nsGlobalWindow* aWindow)
+AutoJSAPI::Init(nsGlobalWindowInner* aWindow)
 {
   return Init(static_cast<nsIGlobalObject*>(aWindow));
 }
 
 // Even with autoJSAPIOwnsErrorReporting, the JS engine still sends warning
 // reports to the JSErrorReporter as soon as they are generated. These go
 // directly to the console, so we can handle them easily here.
 //
@@ -547,17 +547,17 @@ WarningOnlyErrorReporter(JSContext* aCx,
     workers::WorkerPrivate* worker = workers::GetWorkerPrivateFromContext(aCx);
     MOZ_ASSERT(worker);
 
     worker->ReportError(aCx, JS::ConstUTF8CharsZ(), aRep);
     return;
   }
 
   RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
-  nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx);
+  nsGlobalWindowInner* win = xpc::CurrentWindowOrNull(aCx);
   if (!win) {
     // We run addons in a separate privileged compartment, but if we're in an
     // addon compartment we should log warnings to the console of the associated
     // DOM Window.
     win = xpc::AddonWindowOrNull(JS::CurrentGlobalOrNull(aCx));
   }
   xpcReport->Init(aRep, nullptr, nsContentUtils::IsSystemCaller(aCx),
                   win ? win->AsInner()->WindowID() : 0);
@@ -587,17 +587,17 @@ AutoJSAPI::ReportException()
   JSAutoCompartment ac(cx(), errorGlobal);
   JS::Rooted<JS::Value> exn(cx());
   js::ErrorReport jsReport(cx());
   if (StealException(&exn) &&
       jsReport.init(cx(), exn, js::ErrorReport::WithSideEffects)) {
     if (mIsMainThread) {
       RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
 
-      RefPtr<nsGlobalWindow> win = xpc::WindowGlobalOrNull(errorGlobal);
+      RefPtr<nsGlobalWindowInner> win = xpc::WindowGlobalOrNull(errorGlobal);
       if (!win) {
         // We run addons in a separate privileged compartment, but they still
         // expect to trigger the onerror handler of their associated DOM Window.
         win = xpc::AddonWindowOrNull(errorGlobal);
       }
       nsPIDOMWindowInner* inner = win ? win->AsInner() : nullptr;
       bool isChrome = nsContentUtils::IsSystemPrincipal(
         nsContentUtils::ObjectPrincipal(errorGlobal));
--- a/dom/script/ScriptSettings.h
+++ b/dom/script/ScriptSettings.h
@@ -14,17 +14,17 @@
 #include "nsIPrincipal.h"
 
 #include "mozilla/Maybe.h"
 
 #include "jsapi.h"
 #include "js/Debug.h"
 
 class nsPIDOMWindowInner;
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 class nsIScriptContext;
 class nsIDocument;
 class nsIDocShell;
 
 namespace mozilla {
 namespace dom {
 
 /*
@@ -241,18 +241,18 @@ public:
   // show up in the corresponding web console.
   MOZ_MUST_USE bool Init(nsIGlobalObject* aGlobalObject, JSContext* aCx);
 
   // Convenience functions to take an nsPIDOMWindow* or nsGlobalWindow*,
   // when it is more easily available than an nsIGlobalObject.
   MOZ_MUST_USE bool Init(nsPIDOMWindowInner* aWindow);
   MOZ_MUST_USE bool Init(nsPIDOMWindowInner* aWindow, JSContext* aCx);
 
-  MOZ_MUST_USE bool Init(nsGlobalWindow* aWindow);
-  MOZ_MUST_USE bool Init(nsGlobalWindow* aWindow, JSContext* aCx);
+  MOZ_MUST_USE bool Init(nsGlobalWindowInner* aWindow);
+  MOZ_MUST_USE bool Init(nsGlobalWindowInner* aWindow, JSContext* aCx);
 
   JSContext* cx() const {
     MOZ_ASSERT(mCx, "Must call Init before using an AutoJSAPI");
     MOZ_ASSERT(IsStackTop());
     return mCx;
   }
 
 #ifdef DEBUG
--- a/dom/vr/VREventObserver.cpp
+++ b/dom/vr/VREventObserver.cpp
@@ -17,17 +17,17 @@ namespace dom {
 
 using namespace gfx;
 
 /**
  * This class is used by nsGlobalWindow to implement window.onvrdisplayactivate,
  * window.onvrdisplaydeactivate, window.onvrdisplayconnected,
  * window.onvrdisplaydisconnected, and window.onvrdisplaypresentchange.
  */
-VREventObserver::VREventObserver(nsGlobalWindow* aGlobalWindow)
+VREventObserver::VREventObserver(nsGlobalWindowInner* aGlobalWindow)
   : mWindow(aGlobalWindow)
   , mIs2DView(true)
   , mHasReset(false)
 {
   MOZ_ASSERT(aGlobalWindow && aGlobalWindow->IsInnerWindow());
 
   UpdateSpentTimeIn2DTelemetry(false);
   VRManagerChild* vmc = VRManagerChild::Get();
--- a/dom/vr/VREventObserver.h
+++ b/dom/vr/VREventObserver.h
@@ -5,42 +5,42 @@
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_VREventObserver_h
 #define mozilla_dom_VREventObserver_h
 
 #include "mozilla/dom/VRDisplayEventBinding.h"
 #include "nsISupportsImpl.h" // for NS_INLINE_DECL_REFCOUNTING
 
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 
 namespace mozilla {
 namespace dom {
 
 class VREventObserver final
 {
 public:
   NS_INLINE_DECL_REFCOUNTING(VREventObserver)
-  explicit VREventObserver(nsGlobalWindow* aGlobalWindow);
+  explicit VREventObserver(nsGlobalWindowInner* aGlobalWindow);
 
   void NotifyVRDisplayMounted(uint32_t aDisplayID);
   void NotifyVRDisplayUnmounted(uint32_t aDisplayID);
   void NotifyVRDisplayNavigation(uint32_t aDisplayID);
   void NotifyVRDisplayRequested(uint32_t aDisplayID);
   void NotifyVRDisplayConnect(uint32_t aDisplayID);
   void NotifyVRDisplayDisconnect(uint32_t aDisplayID);
   void NotifyVRDisplayPresentChange(uint32_t aDisplayID);
 
   void DisconnectFromOwner();
   void UpdateSpentTimeIn2DTelemetry(bool aUpdate);
 
 private:
   ~VREventObserver();
 
-  RefPtr<nsGlobalWindow> mWindow;
+  RefPtr<nsGlobalWindowInner> mWindow;
   // For WebVR telemetry for tracking users who view content
   // in the 2D view.
   TimeStamp mSpendTimeIn2DView;
   bool mIs2DView;
   bool mHasReset;
 };
 
 } // namespace dom
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -38,17 +38,18 @@ ServiceWorkerClientInfo::ServiceWorkerCl
   , mFrameType(FrameType::None)
 {
   MOZ_ASSERT(aDoc);
   nsresult rv = aDoc->GetOrCreateId(mClientId);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to get the UUID of the document.");
   }
 
-  RefPtr<nsGlobalWindow> innerWindow = nsGlobalWindow::Cast(aDoc->GetInnerWindow());
+  RefPtr<nsGlobalWindowInner> innerWindow =
+    nsGlobalWindowInner::Cast(aDoc->GetInnerWindow());
   if (innerWindow) {
     // XXXcatalinb: The inner window can be null if the document is navigating
     // and was detached.
     mWindowId = innerWindow->WindowID();
   }
 
   nsCOMPtr<nsIURI> originalURI = aDoc->GetOriginalURI();
   if (originalURI) {
@@ -64,17 +65,18 @@ ServiceWorkerClientInfo::ServiceWorkerCl
   mFocused = aDoc->HasFocus(result);
   if (result.Failed()) {
     NS_WARNING("Failed to get focus information.");
   }
 
   MOZ_ASSERT_IF(mLastFocusTime.IsNull(), !mFocused);
   MOZ_ASSERT_IF(mFocused, !mLastFocusTime.IsNull());
 
-  RefPtr<nsGlobalWindow> outerWindow = nsGlobalWindow::Cast(aDoc->GetWindow());
+  RefPtr<nsGlobalWindowOuter> outerWindow =
+    nsGlobalWindowOuter::Cast(aDoc->GetWindow());
   if (!outerWindow) {
     MOZ_ASSERT(mFrameType == FrameType::None);
   } else if (!outerWindow->IsTopLevelWindow()) {
     mFrameType = FrameType::Nested;
   } else if (outerWindow->HadOriginalOpener()) {
     mFrameType = FrameType::Auxiliary;
   } else {
     mFrameType = FrameType::Top_level;
@@ -145,17 +147,17 @@ public:
     , mSourceScope(aSourceScope)
     , mWindowId(aWindowId)
   {}
 
   NS_IMETHOD
   Run() override
   {
     AssertIsOnMainThread();
-    nsGlobalWindow* window = nsGlobalWindow::GetInnerWindowWithId(mWindowId);
+    nsGlobalWindowInner* window = nsGlobalWindow::GetInnerWindowWithId(mWindowId);
     if (!window) {
       return NS_ERROR_FAILURE;
     }
 
     dom::Navigator* navigator = window->Navigator();
     if (!navigator) {
       return NS_ERROR_FAILURE;
     }
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -3088,17 +3088,17 @@ FireControllerChangeOnDocument(nsIDocume
   MOZ_ASSERT(aDocument);
 
   nsCOMPtr<nsPIDOMWindowInner> w = aDocument->GetInnerWindow();
   if (!w) {
     NS_WARNING("Failed to dispatch controllerchange event");
     return;
   }
 
-  auto* window = nsGlobalWindow::Cast(w.get());
+  auto* window = nsGlobalWindowInner::Cast(w.get());
   dom::Navigator* navigator = window->Navigator();
   if (!navigator) {
     return;
   }
 
   RefPtr<ServiceWorkerContainer> container = navigator->ServiceWorker();
   ErrorResult result;
   container->ControllerChanged(result);
--- a/dom/workers/ServiceWorkerWindowClient.cpp
+++ b/dom/workers/ServiceWorkerWindowClient.cpp
@@ -117,17 +117,17 @@ public:
   {
     MOZ_ASSERT(mPromiseProxy);
   }
 
   NS_IMETHOD
   Run() override
   {
     AssertIsOnMainThread();
-    nsGlobalWindow* window = nsGlobalWindow::GetInnerWindowWithId(mWindowId);
+    nsGlobalWindowInner* window = nsGlobalWindow::GetInnerWindowWithId(mWindowId);
     UniquePtr<ServiceWorkerClientInfo> clientInfo;
 
     if (window) {
       nsCOMPtr<nsIDocument> doc = window->GetDocument();
       if (doc) {
         nsContentUtils::DispatchFocusChromeEvent(window->GetOuterWindow());
         clientInfo.reset(new ServiceWorkerClientInfo(doc));
       }
@@ -378,17 +378,17 @@ public:
     nsCOMPtr<nsIURI> baseUrl;
     nsCOMPtr<nsIURI> url;
     nsresult rv = ParseUrl(getter_AddRefs(baseUrl), getter_AddRefs(url));
 
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return RejectPromise(NS_ERROR_TYPE_ERR);
     }
 
-    nsGlobalWindow* window;
+    nsGlobalWindowInner* window;
     rv = Navigate(url, principal, &window);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return RejectPromise(rv);
     }
 
     nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
     nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell);
     if (NS_WARN_IF(!webProgress)) {
@@ -466,21 +466,21 @@ private:
 
     baseUrl.forget(aBaseUrl);
     url.forget(aUrl);
 
     return NS_OK;
   }
 
   nsresult
-  Navigate(nsIURI* aUrl, nsIPrincipal* aPrincipal, nsGlobalWindow** aWindow)
+  Navigate(nsIURI* aUrl, nsIPrincipal* aPrincipal, nsGlobalWindowInner** aWindow)
   {
     MOZ_ASSERT(aWindow);
 
-    nsGlobalWindow* window = nsGlobalWindow::GetInnerWindowWithId(mWindowId);
+    nsGlobalWindowInner* window = nsGlobalWindow::GetInnerWindowWithId(mWindowId);
     if (NS_WARN_IF(!window)) {
       return NS_ERROR_TYPE_ERR;
     }
 
     nsCOMPtr<nsIDocument> doc = window->GetDocument();
     if (NS_WARN_IF(!doc)) {
       return NS_ERROR_TYPE_ERR;
     }
--- a/dom/workers/WorkerRunnable.cpp
+++ b/dom/workers/WorkerRunnable.cpp
@@ -298,17 +298,17 @@ WorkerRunnable::Run()
     // We may still not have a globalObject here: in the case of
     // CompileScriptRunnable, we don't actually create the global object until
     // we have the script data, which happens in a syncloop under
     // CompileScriptRunnable::WorkerRun, so we can't assert that it got created
     // in the PreRun call above.
   } else {
     kungFuDeathGrip = mWorkerPrivate;
     if (isMainThread) {
-      globalObject = nsGlobalWindow::Cast(mWorkerPrivate->GetWindow());
+      globalObject = nsGlobalWindowInner::Cast(mWorkerPrivate->GetWindow());
     } else {
       globalObject = mWorkerPrivate->GetParent()->GlobalScope();
     }
   }
 
   // We might run script as part of WorkerRun, so we need an AutoEntryScript.
   // This is part of the HTML spec for workers at:
   // http://www.whatwg.org/specs/web-apps/current-work/#run-a-worker
--- a/gfx/vr/ipc/VRManagerChild.cpp
+++ b/gfx/vr/ipc/VRManagerChild.cpp
@@ -239,17 +239,17 @@ VRManagerChild::RecvUpdateDisplayInfo(ns
   UpdateDisplayInfo(aDisplayUpdates);
   for (auto& windowId : mNavigatorCallbacks) {
     /** We must call NotifyVRDisplaysUpdated for every
      * window's Navigator in mNavigatorCallbacks to ensure that
      * the promise returned by Navigator.GetVRDevices
      * can resolve.  This must happen even if no changes
      * to VRDisplays have been detected here.
      */
-    nsGlobalWindow* window = nsGlobalWindow::GetInnerWindowWithId(windowId);
+    nsGlobalWindowInner* window = nsGlobalWindow::GetInnerWindowWithId(windowId);
     if (!window) {
       continue;
     }
     dom::Navigator* nav = window->Navigator();
     if (!nav) {
       continue;
     }
     nav->NotifyVRDisplaysUpdated();
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -2113,17 +2113,17 @@ NS_IMETHODIMP
 nsXPCComponents_Utils::ReportError(HandleValue error, JSContext* cx)
 {
     // This function shall never fail! Silently eat any failure conditions.
 
     nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
     if (!console)
         return NS_OK;
 
-    nsGlobalWindow* globalWin = CurrentWindowOrNull(cx);
+    nsGlobalWindowInner* globalWin = CurrentWindowOrNull(cx);
     nsPIDOMWindowInner* win = globalWin ? globalWin->AsInner() : nullptr;
     const uint64_t innerWindowID = win ? win->WindowID() : 0;
 
     RootedObject errorObj(cx, error.isObject() ? &error.toObject() : nullptr);
     JSErrorReport* err = errorObj ? JS_ErrorFromException(cx, errorObj) : nullptr;
 
     nsCOMPtr<nsIScriptError> scripterr;
 
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -663,17 +663,17 @@ XPCJSContext::InterruptCallback(JSContex
 
     //
     // This has gone on long enough! Time to take action. ;-)
     //
 
     // Get the DOM window associated with the running script. If the script is
     // running in a non-DOM scope, we have to just let it keep running.
     RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
-    RefPtr<nsGlobalWindow> win = WindowOrNull(global);
+    RefPtr<nsGlobalWindowInner> win = WindowOrNull(global);
     if (!win && IsSandbox(global)) {
         // If this is a sandbox associated with a DOMWindow via a
         // sandboxPrototype, use that DOMWindow. This supports GreaseMonkey
         // and JetPack content scripts.
         JS::Rooted<JSObject*> proto(cx);
         if (!JS_GetPrototype(cx, global, &proto))
             return false;
         if (proto && IsSandboxPrototypeProxy(proto) &&
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -526,37 +526,37 @@ PrivilegedJunkScope()
 }
 
 JSObject*
 CompilationScope()
 {
     return XPCJSRuntime::Get()->CompilationScope();
 }
 
-nsGlobalWindow*
+nsGlobalWindowInner*
 WindowOrNull(JSObject* aObj)
 {
     MOZ_ASSERT(aObj);
     MOZ_ASSERT(!js::IsWrapper(aObj));
 
     nsGlobalWindow* win = nullptr;
     UNWRAP_NON_WRAPPER_OBJECT(Window, aObj, win);
-    return win;
+    return static_cast<nsGlobalWindowInner*>(win);
 }
 
-nsGlobalWindow*
+nsGlobalWindowInner*
 WindowGlobalOrNull(JSObject* aObj)
 {
     MOZ_ASSERT(aObj);
     JSObject* glob = js::GetGlobalForObjectCrossCompartment(aObj);
 
     return WindowOrNull(glob);
 }
 
-nsGlobalWindow*
+nsGlobalWindowInner*
 AddonWindowOrNull(JSObject* aObj)
 {
     if (!IsInAddonScope(aObj))
         return nullptr;
 
     JSObject* global = js::GetGlobalForObjectCrossCompartment(aObj);
     JSObject* proto = js::GetPrototypeNoProxy(global);
 
@@ -566,17 +566,17 @@ AddonWindowOrNull(JSObject* aObj)
     MOZ_RELEASE_ASSERT(js::IsCrossCompartmentWrapper(proto) ||
                        xpc::IsSandboxPrototypeProxy(proto));
     JSObject* mainGlobal = js::UncheckedUnwrap(proto, /* stopAtWindowProxy = */ false);
     MOZ_RELEASE_ASSERT(JS_IsGlobalObject(mainGlobal));
 
     return WindowOrNull(mainGlobal);
 }
 
-nsGlobalWindow*
+nsGlobalWindowInner*
 CurrentWindowOrNull(JSContext* cx)
 {
     JSObject* glob = JS::CurrentGlobalOrNull(cx);
     return glob ? WindowOrNull(glob) : nullptr;
 }
 
 // Nukes all wrappers into or out of the given compartment, and prevents new
 // wrappers from being created. Additionally marks the compartment as
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -22,17 +22,17 @@
 #include "nsTArray.h"
 #include "mozilla/dom/JSSlots.h"
 #include "mozilla/fallible.h"
 #include "nsMathUtils.h"
 #include "nsStringBuffer.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/Preferences.h"
 
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 class nsIPrincipal;
 class nsScriptNameSpaceManager;
 class nsIHandleReportCallback;
 
 namespace mozilla {
 namespace dom {
 class Exception;
 }
@@ -478,39 +478,39 @@ CompilationScope();
  */
 nsIGlobalObject*
 NativeGlobal(JSObject* aObj);
 
 /**
  * If |aObj| is a window, returns the associated nsGlobalWindow.
  * Otherwise, returns null.
  */
-nsGlobalWindow*
+nsGlobalWindowInner*
 WindowOrNull(JSObject* aObj);
 
 /**
  * If |aObj| has a window for a global, returns the associated nsGlobalWindow.
  * Otherwise, returns null.
  */
-nsGlobalWindow*
+nsGlobalWindowInner*
 WindowGlobalOrNull(JSObject* aObj);
 
 /**
  * If |aObj| is in an addon scope and that addon scope is associated with a
  * live DOM Window, returns the associated nsGlobalWindow. Otherwise, returns
  * null.
  */
-nsGlobalWindow*
+nsGlobalWindowInner*
 AddonWindowOrNull(JSObject* aObj);
 
 /**
  * If |cx| is in a compartment whose global is a window, returns the associated
  * nsGlobalWindow. Otherwise, returns null.
  */
-nsGlobalWindow*
+nsGlobalWindowInner*
 CurrentWindowOrNull(JSContext* cx);
 
 void
 SimulateActivityCallback(bool aActive);
 
 // This function may be used off-main-thread, in which case it is benignly
 // racey.
 bool
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -124,17 +124,17 @@ IsPermitted(CrossOriginObjectType type, 
 }
 
 static bool
 IsFrameId(JSContext* cx, JSObject* obj, jsid idArg)
 {
     MOZ_ASSERT(!js::IsWrapper(obj));
     RootedId id(cx, idArg);
 
-    nsGlobalWindow* win = WindowOrNull(obj);
+    nsGlobalWindowInner* win = WindowOrNull(obj);
     if (!win) {
         return false;
     }
 
     nsCOMPtr<nsIDOMWindowCollection> col = win->GetFrames();
     if (!col) {
         return false;
     }
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -275,17 +275,17 @@ ReportWrapperDenial(JSContext* cx, Handl
     // Grab the pieces.
     nsCOMPtr<nsIConsoleService> consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
     NS_ENSURE_TRUE(consoleService, true);
     nsCOMPtr<nsIScriptError> errorObject = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
     NS_ENSURE_TRUE(errorObject, true);
 
     // Compute the current window id if any.
     uint64_t windowId = 0;
-    nsGlobalWindow* win = WindowGlobalOrNull(CurrentGlobalOrNull(cx));
+    nsGlobalWindowInner* win = WindowGlobalOrNull(CurrentGlobalOrNull(cx));
     if (win)
       windowId = win->WindowID();
 
 
     Maybe<nsPrintfCString> errorMessage;
     if (type == WrapperDenialForXray) {
         errorMessage.emplace("XrayWrapper denied access to property %s (reason: %s). "
                              "See https://developer.mozilla.org/en-US/docs/Xray_vision "
@@ -1429,17 +1429,17 @@ namespace XrayUtils {
 bool
 IsXPCWNHolderClass(const JSClass* clasp)
 {
   return clasp == &XPCWrappedNativeXrayTraits::HolderClass;
 }
 
 } // namespace XrayUtils
 
-static nsGlobalWindow*
+static nsGlobalWindowInner*
 AsWindow(JSContext* cx, JSObject* wrapper)
 {
   // We want to use our target object here, since we don't want to be
   // doing a security check while unwrapping.
   JSObject* target = XrayTraits::getTargetObject(wrapper);
   return WindowOrNull(target);
 }
 
@@ -1758,23 +1758,23 @@ DOMXrayTraits::resolveOwnProperty(JSCont
     // Call the common code.
     bool ok = XrayTraits::resolveOwnProperty(cx, wrapper, target, holder, id, desc);
     if (!ok || desc.object())
         return ok;
 
     // Check for indexed access on a window.
     uint32_t index = GetArrayIndexFromId(cx, id);
     if (IsArrayIndex(index)) {
-        nsGlobalWindow* win = AsWindow(cx, wrapper);
+        nsGlobalWindowInner* win = AsWindow(cx, wrapper);
         // Note: As() unwraps outer windows to get to the inner window.
         if (win) {
             nsCOMPtr<nsPIDOMWindowOuter> subframe = win->IndexedGetter(index);
             if (subframe) {
                 subframe->EnsureInnerWindow();
-                nsGlobalWindow* global = nsGlobalWindow::Cast(subframe);
+                nsGlobalWindowOuter* global = nsGlobalWindowOuter::Cast(subframe);
                 JSObject* obj = global->FastGetGlobalJSObject();
                 if (MOZ_UNLIKELY(!obj)) {
                     // It's gone?
                     return xpc::Throw(cx, NS_ERROR_FAILURE);
                 }
                 ExposeObjectToActiveJS(obj);
                 desc.value().setObject(*obj);
                 FillPropertyDescriptor(desc, wrapper, true);
@@ -1830,17 +1830,17 @@ DOMXrayTraits::defineProperty(JSContext*
     return XrayDefineProperty(cx, wrapper, obj, id, desc, result, defined);
 }
 
 bool
 DOMXrayTraits::enumerateNames(JSContext* cx, HandleObject wrapper, unsigned flags,
                               AutoIdVector& props)
 {
     // Put the indexed properties for a window first.
-    nsGlobalWindow* win = AsWindow(cx, wrapper);
+    nsGlobalWindowInner* win = AsWindow(cx, wrapper);
     if (win) {
         uint32_t length = win->Length();
         if (!props.reserve(props.length() + length)) {
             return false;
         }
         JS::RootedId indexId(cx);
         for (uint32_t i = 0; i < length; ++i) {
             if (!JS_IndexToId(cx, i, &indexId)) {
@@ -2126,26 +2126,26 @@ XrayWrapper<Base, Traits>::getPropertyDe
     // We need to handle named access on the Window somewhere other than
     // Traits::resolveOwnProperty, because per spec it happens on the Global
     // Scope Polluter and thus the resulting properties are non-|own|. However,
     // we're set up (above) to cache (on the holder) anything that comes out of
     // resolveNativeProperty, which we don't want for something dynamic like
     // named access. So we just handle it separately here.  Note that this is
     // only relevant for CrossOriginXrayWrapper, which calls
     // getPropertyDescriptor from getOwnPropertyDescriptor.
-    nsGlobalWindow* win = nullptr;
+    nsGlobalWindowInner* win = nullptr;
     if (!desc.object() &&
         JSID_IS_STRING(id) &&
         (win = AsWindow(cx, wrapper)))
     {
         nsAutoJSString name;
         if (!name.init(cx, JSID_TO_STRING(id)))
             return false;
         if (nsCOMPtr<nsPIDOMWindowOuter> childDOMWin = win->GetChildWindow(name)) {
-            auto* cwin = nsGlobalWindow::Cast(childDOMWin);
+            auto* cwin = nsGlobalWindowOuter::Cast(childDOMWin);
             JSObject* childObj = cwin->FastGetGlobalJSObject();
             if (MOZ_UNLIKELY(!childObj))
                 return xpc::Throw(cx, NS_ERROR_FAILURE);
             ExposeObjectToActiveJS(childObj);
             FillPropertyDescriptor(desc, wrapper, ObjectValue(*childObj),
                                    /* readOnly = */ true);
             return JS_WrapPropertyDescriptor(cx, desc);
         }
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1217,17 +1217,17 @@ nsDocumentViewer::PermitUnloadInternal(b
 
   bool dialogsAreEnabled = false;
   {
     // Never permit popups from the beforeunload handler, no matter
     // how we get here.
     nsAutoPopupStatePusher popupStatePusher(openAbused, true);
 
     // Never permit dialogs from the beforeunload handler
-    nsGlobalWindow* globalWindow = nsGlobalWindow::Cast(window);
+    nsGlobalWindowOuter* globalWindow = nsGlobalWindowOuter::Cast(window);
     dialogsAreEnabled = globalWindow->AreDialogsEnabled();
     nsGlobalWindow::TemporarilyDisableDialogs disableDialogs(globalWindow);
 
     nsIDocument::PageUnloadingEventTimeStamp timestamp(mDocument);
 
     mInPermitUnload = true;
     EventDispatcher::DispatchDOMEvent(window, nullptr, event, mPresContext,
                                       nullptr);
--- a/layout/style/CSS.cpp
+++ b/layout/style/CSS.cpp
@@ -27,17 +27,17 @@ struct SupportsParsingInfo
   nsIPrincipal* mPrincipal;
   StyleBackendType mStyleBackendType;
 };
 
 static nsresult
 GetParsingInfo(const GlobalObject& aGlobal,
                SupportsParsingInfo& aInfo)
 {
-  nsGlobalWindow* win = xpc::WindowOrNull(aGlobal.Get());
+  nsGlobalWindowInner* win = xpc::WindowOrNull(aGlobal.Get());
   if (!win) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIDocument> doc = win->GetDoc();
   if (!doc) {
     return NS_ERROR_FAILURE;
   }
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -1814,17 +1814,17 @@ nsXULPopupManager::MayShowPopup(nsMenuPo
   nsCOMPtr<nsIWidget> mainWidget;
   baseWin->GetMainWidget(getter_AddRefs(mainWidget));
   if (mainWidget && mainWidget->SizeMode() == nsSizeMode_Minimized) {
     return false;
   }
 
 #ifdef XP_MACOSX
   if (rootWin) {
-    auto globalWin = nsGlobalWindow::Cast(rootWin.get());
+    auto globalWin = nsGlobalWindowOuter::Cast(rootWin.get());
     if (globalWin->IsInModalState()) {
       return false;
     }
   }
 #endif
 
   // cannot open a popup that is a submenu of a menupopup that isn't open.
   nsMenuFrame* menuFrame = do_QueryFrame(aPopup->GetParent());
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -574,17 +574,17 @@ PeerConnectionConfiguration::AddIceServe
       }
     }
   }
   return NS_OK;
 }
 
 nsresult
 PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
-                               nsGlobalWindow* aWindow,
+                               nsGlobalWindowInner* aWindow,
                                const PeerConnectionConfiguration& aConfiguration,
                                nsISupports* aThread)
 {
   nsresult res;
 
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aThread);
   if (!mThread) {
@@ -739,17 +739,17 @@ PeerConnectionImpl::Initialize(PeerConne
   PeerConnectionConfiguration converted;
   nsresult res = converted.Init(aConfiguration);
   if (NS_FAILED(res)) {
     CSFLogError(LOGTAG, "%s: Invalid RTCConfiguration", __FUNCTION__);
     rv.Throw(res);
     return;
   }
 
-  res = Initialize(aObserver, &aWindow, converted, aThread);
+  res = Initialize(aObserver, aWindow.AssertInner(), converted, aThread);
   if (NS_FAILED(res)) {
     rv.Throw(res);
     return;
   }
 
   if (!aConfiguration.mPeerIdentity.IsEmpty()) {
     mPeerIdentity = new PeerIdentity(aConfiguration.mPeerIdentity);
     mPrivacyRequested = true;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -320,17 +320,17 @@ public:
     PC_AUTO_ENTER_API_CALL_NO_CHECK();
     return mWindow;
   }
 
   // Initialize PeerConnection from a PeerConnectionConfiguration object
   // (used directly by unit-tests, and indirectly by the JS entry point)
   // This is necessary because RTCConfiguration can't be used by unit-tests
   nsresult Initialize(PeerConnectionObserver& aObserver,
-                      nsGlobalWindow* aWindow,
+                      nsGlobalWindowInner* aWindow,
                       const PeerConnectionConfiguration& aConfiguration,
                       nsISupports* aThread);
 
   // Initialize PeerConnection from an RTCConfiguration object (JS entrypoint)
   void Initialize(PeerConnectionObserver& aObserver,
                   nsGlobalWindow& aWindow,
                   const RTCConfiguration& aConfiguration,
                   nsISupports* aThread,
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -685,17 +685,17 @@ class PCDispatchWrapper : public nsSuppo
     return pc_;
   }
 
   const RefPtr<PeerConnectionMedia>& media() const {
     return pc_->media();
   }
 
   NS_IMETHODIMP Initialize(TestObserver* aObserver,
-                           nsGlobalWindow* aWindow,
+                           nsGlobalWindowInner* aWindow,
                            const PeerConnectionConfiguration& aConfiguration,
                            nsIThread* aThread) {
     nsresult rv;
 
     observer_ = aObserver;
 
     if (NS_IsMainThread()) {
       rv = pc_->Initialize(*aObserver, aWindow, aConfiguration, aThread);
--- a/netwerk/ipc/NeckoChild.cpp
+++ b/netwerk/ipc/NeckoChild.cpp
@@ -201,17 +201,17 @@ NeckoChild::DeallocPWebSocketChild(PWebS
   p->ReleaseIPDLReference();
   return true;
 }
 
 PWebSocketEventListenerChild*
 NeckoChild::AllocPWebSocketEventListenerChild(const uint64_t& aInnerWindowID)
 {
   nsCOMPtr<nsIEventTarget> target;
-  if (nsGlobalWindow* win = nsGlobalWindow::GetInnerWindowWithId(aInnerWindowID)) {
+  if (nsGlobalWindowInner* win = nsGlobalWindow::GetInnerWindowWithId(aInnerWindowID)) {
     target = win->EventTargetFor(TaskCategory::Other);
   }
 
   RefPtr<WebSocketEventListenerChild> c =
     new WebSocketEventListenerChild(aInnerWindowID, target);
 
   if (target) {
     gNeckoChild->SetEventTargetForActor(c, target);
--- a/toolkit/components/perfmonitoring/nsPerformanceStats.cpp
+++ b/toolkit/components/perfmonitoring/nsPerformanceStats.cpp
@@ -60,17 +60,17 @@ namespace {
 /**
  * Get the private window for the current compartment.
  *
  * @return null if the code is not executed in a window or in
  * case of error, a nsPIDOMWindow otherwise.
  */
 already_AddRefed<nsPIDOMWindowOuter>
 GetPrivateWindow(JSContext* cx) {
-  nsGlobalWindow* win = xpc::CurrentWindowOrNull(cx);
+  nsGlobalWindowInner* win = xpc::CurrentWindowOrNull(cx);
   if (!win) {
     return nullptr;
   }
 
   nsPIDOMWindowOuter* outer = win->AsInner()->GetOuterWindow();
   if (!outer) {
     return nullptr;
   }
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -1111,17 +1111,17 @@ nsWindowWatcher::OpenWindowInternal(mozI
 
     // The principal of the initial about:blank document gets set up in
     // nsWindowWatcher::AddWindow. Make sure to call it. In the common case
     // this call already happened when the window was created, but
     // SetInitialPrincipalToSubject is safe to call multiple times.
     if (newWindow) {
       newWindow->SetInitialPrincipalToSubject();
       if (aIsPopupSpam) {
-        nsGlobalWindow* globalWin = nsGlobalWindow::Cast(newWindow);
+        nsGlobalWindowOuter* globalWin = nsGlobalWindowOuter::Cast(newWindow);
         MOZ_ASSERT(!globalWin->IsPopupSpamWindow(),
                    "Who marked it as popup spam already???");
         if (!globalWin->IsPopupSpamWindow()) { // Make sure we don't mess up our
                                                // counter even if the above
                                                // assert fails.
           globalWin->SetIsPopupSpamWindow(true);
         }
       }
--- a/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
+++ b/toolkit/mozapps/extensions/AddonManagerWebAPI.cpp
@@ -86,17 +86,17 @@ AddonManagerWebAPI::IsValidSite(nsIURI* 
   }
 
   return IsValidHost(host);
 }
 
 bool
 AddonManagerWebAPI::IsAPIEnabled(JSContext* cx, JSObject* obj)
 {
-  nsGlobalWindow* global = xpc::WindowGlobalOrNull(obj);
+  nsGlobalWindowInner* global = xpc::WindowGlobalOrNull(obj);
   if (!global) {
     return false;
   }
 
   nsCOMPtr<nsPIDOMWindowInner> win = global->AsInner();
   if (!win) {
     return false;
   }
--- a/toolkit/xre/nsNativeAppSupportWin.cpp
+++ b/toolkit/xre/nsNativeAppSupportWin.cpp
@@ -958,17 +958,18 @@ nsNativeAppSupportWin::HandleDDENotifica
                                              getter_AddRefs( navWin ) );
                         nsCOMPtr<nsPIDOMWindowOuter> piNavWin = do_QueryInterface(navWin);
                         if ( !piNavWin ) {
                             // There is not a window open
                             break;
                         }
 
                         // Get content window.
-                        nsCOMPtr<nsPIDOMWindowOuter> internalContent = nsGlobalWindow::Cast(piNavWin)->GetContent();
+                        nsCOMPtr<nsPIDOMWindowOuter> internalContent =
+                            nsGlobalWindowOuter::Cast(piNavWin)->GetContent();
                         if ( !internalContent ) {
                             break;
                         }
                         // Get location.
                         RefPtr<dom::Location> location = internalContent->GetLocation();
                         if ( !location ) {
                             break;
                         }
--- a/xpfe/appshell/nsWindowMediator.cpp
+++ b/xpfe/appshell/nsWindowMediator.cpp
@@ -347,27 +347,27 @@ nsWindowMediator::MostRecentWindowInfo(c
 
   return foundInfo;
 }
 
 NS_IMETHODIMP
 nsWindowMediator::GetOuterWindowWithId(uint64_t aWindowID,
                                        mozIDOMWindowProxy** aWindow)
 {
-  RefPtr<nsGlobalWindow> window = nsGlobalWindow::GetOuterWindowWithId(aWindowID);
+  RefPtr<nsGlobalWindowOuter> window = nsGlobalWindow::GetOuterWindowWithId(aWindowID);
   nsCOMPtr<nsPIDOMWindowOuter> outer = window ? window->AsOuter() : nullptr;
   outer.forget(aWindow);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindowMediator::GetCurrentInnerWindowWithId(uint64_t aWindowID,
                                               mozIDOMWindow** aWindow)
 {
-  RefPtr<nsGlobalWindow> window = nsGlobalWindow::GetInnerWindowWithId(aWindowID);
+  RefPtr<nsGlobalWindowInner> window = nsGlobalWindow::GetInnerWindowWithId(aWindowID);
 
   // not found
   if (!window)
     return NS_OK;
 
   nsCOMPtr<nsPIDOMWindowInner> inner = window->AsInner();
   nsCOMPtr<nsPIDOMWindowOuter> outer = inner->GetOuterWindow();
   NS_ENSURE_TRUE(outer, NS_ERROR_UNEXPECTED);