Bug 1416384 - Part 2c: Get nsGlobalWindowInner.cpp building, r=smaug
authorNika Layzell <nika@thelayzells.com>
Wed, 15 Nov 2017 11:33:39 -0500
changeset 392028 71a0e504ebd0dd6349a8f16b28f8fac057aa5792
parent 392027 028e876d02bfabc06e5945d00ee3740fb5af823b
child 392029 d1fc9865c5574cecc72270dde1822c9344bc137e
push id32909
push usercbrindusan@mozilla.com
push dateWed, 15 Nov 2017 22:25:14 +0000
treeherdermozilla-central@f41930a869a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1416384
milestone59.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 1416384 - Part 2c: Get nsGlobalWindowInner.cpp building, r=smaug MozReview-Commit-ID: CmKx5jtvtrT
dom/base/Element.h
dom/base/moz.build
dom/base/nsDOMClassInfo.h
dom/base/nsGlobalWindow.h
dom/base/nsGlobalWindowInner.cpp
dom/base/nsPIDOMWindow.h
dom/bindings/BindingUtils.h
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -50,17 +50,18 @@ class nsIDOMMozNamedAttrMap;
 class nsIMozBrowserFrame;
 class nsIURI;
 class nsIScrollableFrame;
 class nsAttrValueOrString;
 class nsContentList;
 class nsDOMTokenList;
 struct nsRect;
 class nsFocusManager;
-class nsGlobalWindow;
+class nsGlobalWindowInner;
+class nsGlobalWindowOuter;
 class nsICSSDeclaration;
 class nsISMILAttr;
 class nsDocument;
 class nsDOMStringMap;
 
 namespace mozilla {
 class DeclarationBlock;
 class TextEditor;
@@ -608,17 +609,18 @@ protected:
 
   already_AddRefed<ShadowRoot> AttachShadowInternal(bool aClosed,
                                                     ErrorResult& aError);
 
 private:
   // Need to allow the ESM, nsGlobalWindow, and the focus manager to
   // set our state
   friend class mozilla::EventStateManager;
-  friend class ::nsGlobalWindow;
+  friend class ::nsGlobalWindowInner;
+  friend class ::nsGlobalWindowOuter;
   friend class ::nsFocusManager;
 
   // Allow CusomtElementRegistry to call AddStates.
   friend class CustomElementRegistry;
 
   // Also need to allow Link to call UpdateLinkState.
   friend class Link;
 
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -385,16 +385,17 @@ SOURCES += [
     # Because of OS X headers.
     'nsContentUtils.cpp',
     # this file doesn't like windows.h
     'nsDOMWindowUtils.cpp',
     # Conflicts with windows.h's definition of SendMessage.
     'nsFrameMessageManager.cpp',
     # This file has a #error "Never include windows.h in this file!"
     # 'nsGlobalWindow.cpp',
+    'nsGlobalWindowInner.cpp',
     # Conflicts with windows.h's definition of LoadImage.
     'nsImageLoadingContent.cpp',
     # Because of OS X headers.
     'nsObjectLoadingContent.cpp',
     # nsPluginArray.cpp includes npapi.h indirectly, and that includes a lot of system headers
     'nsPluginArray.cpp',
 ]
 
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -15,18 +15,18 @@
 #include "js/Id.h"
 #include "nsIXPConnect.h"
 
 #ifdef XP_WIN
 #undef GetClassName
 #endif
 
 struct nsGlobalNameStruct;
-class nsGlobalWindow;
 class nsGlobalWindowInner;
+class nsGlobalWindowOuter;
 
 struct nsDOMClassInfoData;
 
 typedef nsIClassInfo* (*nsDOMClassInfoConstructorFnc)
   (nsDOMClassInfoData* aData);
 
 typedef nsresult (*nsDOMConstructorFunc)(nsISupports** aNewObject);
 
@@ -140,17 +140,18 @@ public:
 // moving to be nsGlobalWindow member methods.  See bug 1062418.
 class nsWindowSH
 {
 protected:
   static nsresult GlobalResolve(nsGlobalWindowInner *aWin, JSContext *cx,
                                 JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
                                 JS::MutableHandle<JS::PropertyDescriptor> desc);
 
-  friend class nsGlobalWindow;
+  friend class nsGlobalWindowInner;
+  friend class nsGlobalWindowOuter;
 public:
   static bool NameStructEnabled(JSContext* aCx, nsGlobalWindowInner *aWin,
                                 const nsAString& aName,
                                 const nsGlobalNameStruct& aNameStruct);
 };
 
 
 // Event handler 'this' translator class, this is called by XPConnect
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -2,16 +2,34 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsGlobalWindow_h___
 #define nsGlobalWindow_h___
 
+// XXX(nika): Figure out where to put this?
+#define DEFAULT_HOME_PAGE "www.mozilla.org"
+#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
+
+// Amount of time allowed between alert/prompt/confirm before enabling
+// the stop dialog checkbox.
+#define DEFAULT_SUCCESSIVE_DIALOG_TIME_LIMIT 3 // 3 sec
+
+// Maximum number of successive dialogs before we prompt users to disable
+// dialogs for this window.
+#define MAX_SUCCESSIVE_DIALOG_COUNT 5
+
+// Idle fuzz time upper limit
+#define MAX_IDLE_FUZZ_TIME_MS 90000
+
+// Min idle notification time in seconds.
+#define MIN_IDLE_NOTIFICATION_TIME_S 1
+
 // NOTE: This is so that I can rewrite the includes in a separate patch.
 // Specificially I don't think I want to change this until I've moved everything
 // to mozilla/dom/Window.h and mozilla/dom/WindowProxy.h.
 
 #include "nsGlobalWindowInner.h"
 #include "nsGlobalWindowOuter.h"
 
 #endif /* nsGlobalWindow_h___ */
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -284,17 +284,16 @@ using mozilla::BasePrincipal;
 using mozilla::OriginAttributes;
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
 using mozilla::dom::cache::CacheStorage;
 
 static LazyLogModule gDOMLeakPRLog("DOMLeak");
 
 nsGlobalWindowInner::InnerWindowByIdTable *nsGlobalWindowInner::sInnerWindowsById = nullptr;
-nsGlobalWindowOuter::OuterWindowByIdTable *nsGlobalWindowOuter::sOuterWindowsById = nullptr;
 
 static int32_t              gRefCnt                           = 0;
 static int32_t              gOpenPopupSpamCount               = 0;
 static PopupControlState    gPopupControlState                = openAbused;
 static bool                 gMouseDown                        = false;
 static bool                 gDragServiceDisabled              = false;
 static FILE                *gDumpFile                         = nullptr;
 static uint32_t             gSerialCounter                    = 0;
@@ -489,17 +488,17 @@ public:
   {
     return mWindow ? mWindow->EventTargetFor(TaskCategory::Other) : nullptr;
   }
 
 private:
   ~nsGlobalWindowObserver() = default;
 
   // This reference is non-owning and safe because it's cleared by
-  // nsGlobalWindow::CleanUp().
+  // nsGlobalWindowInner::CleanUp().
   nsGlobalWindowInner* MOZ_NON_OWNING_REF mWindow;
 };
 
 NS_IMPL_ISUPPORTS(nsGlobalWindowObserver, nsIObserver, nsIInterfaceRequestor)
 
 static already_AddRefed<nsIVariant>
 CreateVoidVariant()
 {
@@ -771,79 +770,79 @@ IdleRequestExecutorTimeoutHandler::Call(
 {
   if (!mExecutor->IsCancelled()) {
     mExecutor->ScheduleDispatch();
   }
   return NS_OK;
 }
 
 void
-nsGlobalWindow::ScheduleIdleRequestDispatch()
+nsGlobalWindowInner::ScheduleIdleRequestDispatch()
 {
   AssertIsOnMainThread();
 
   if (!mIdleRequestExecutor) {
     mIdleRequestExecutor = new IdleRequestExecutor(AssertInner());
   }
 
   mIdleRequestExecutor->MaybeDispatch();
 }
 
 void
-nsGlobalWindow::SuspendIdleRequests()
+nsGlobalWindowInner::SuspendIdleRequests()
 {
   if (mIdleRequestExecutor) {
     mIdleRequestExecutor->Cancel();
     mIdleRequestExecutor = nullptr;
   }
 }
 
 void
-nsGlobalWindow::ResumeIdleRequests()
+nsGlobalWindowInner::ResumeIdleRequests()
 {
   MOZ_ASSERT(!mIdleRequestExecutor);
 
   ScheduleIdleRequestDispatch();
 }
 
 void
-nsGlobalWindow::InsertIdleCallback(IdleRequest* aRequest)
+nsGlobalWindowInner::InsertIdleCallback(IdleRequest* aRequest)
 {
   AssertIsOnMainThread();
   mIdleRequestCallbacks.insertBack(aRequest);
   aRequest->AddRef();
 }
 
 void
-nsGlobalWindow::RemoveIdleCallback(mozilla::dom::IdleRequest* aRequest)
+nsGlobalWindowInner::RemoveIdleCallback(mozilla::dom::IdleRequest* aRequest)
 {
   AssertIsOnMainThread();
 
   if (aRequest->HasTimeout()) {
     mTimeoutManager->ClearTimeout(aRequest->GetTimeoutHandle(),
                                   Timeout::Reason::eIdleCallbackTimeout);
   }
 
   aRequest->removeFrom(mIdleRequestCallbacks);
   aRequest->Release();
 }
 
 nsresult
-nsGlobalWindow::RunIdleRequest(IdleRequest* aRequest,
+nsGlobalWindowInner::RunIdleRequest(IdleRequest* aRequest,
                                DOMHighResTimeStamp aDeadline,
                                bool aDidTimeout)
 {
   AssertIsOnMainThread();
   RefPtr<IdleRequest> request(aRequest);
   RemoveIdleCallback(request);
   return request->IdleRun(AsInner(), aDeadline, aDidTimeout);
 }
 
 nsresult
-nsGlobalWindow::ExecuteIdleRequest(TimeStamp aDeadline)
+nsGlobalWindowInner::ExecuteIdleRequest(TimeStamp aDeadline)
 {
   AssertIsOnMainThread();
   RefPtr<IdleRequest> request = mIdleRequestCallbacks.getFirst();
 
   if (!request) {
     // There are no more idle requests, so stop scheduling idle
     // request callbacks.
     return NS_OK;
@@ -909,17 +908,17 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(IdleR
 
 NS_IMPL_ADDREF_INHERITED(IdleRequestTimeoutHandler, TimeoutHandler)
 NS_IMPL_RELEASE_INHERITED(IdleRequestTimeoutHandler, TimeoutHandler)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IdleRequestTimeoutHandler)
 NS_INTERFACE_MAP_END_INHERITING(TimeoutHandler)
 
 uint32_t
-nsGlobalWindow::RequestIdleCallback(JSContext* aCx,
+nsGlobalWindowInner::RequestIdleCallback(JSContext* aCx,
                                     IdleRequestCallback& aCallback,
                                     const IdleRequestOptions& aOptions,
                                     ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
   AssertIsOnMainThread();
 
   uint32_t handle = mIdleRequestCallbackCounter++;
@@ -948,44 +947,44 @@ nsGlobalWindow::RequestIdleCallback(JSCo
   if (!IsSuspended()) {
     ScheduleIdleRequestDispatch();
   }
 
   return handle;
 }
 
 void
-nsGlobalWindow::CancelIdleCallback(uint32_t aHandle)
+nsGlobalWindowInner::CancelIdleCallback(uint32_t aHandle)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   for (IdleRequest* r : mIdleRequestCallbacks) {
     if (r->Handle() == aHandle) {
       RemoveIdleCallback(r);
       break;
     }
   }
 }
 
 void
-nsGlobalWindow::DisableIdleCallbackRequests()
+nsGlobalWindowInner::DisableIdleCallbackRequests()
 {
   if (mIdleRequestExecutor) {
     mIdleRequestExecutor->Cancel();
     mIdleRequestExecutor = nullptr;
   }
 
   while (!mIdleRequestCallbacks.isEmpty()) {
     RefPtr<IdleRequest> request = mIdleRequestCallbacks.getFirst();
     RemoveIdleCallback(request);
   }
 }
 
 bool
-nsGlobalWindow::IsBackgroundInternal() const
+nsGlobalWindowInner::IsBackgroundInternal() const
 {
   return !mOuterWindow || mOuterWindow->IsBackground();
 }
 namespace mozilla {
 namespace dom {
 extern uint64_t
 NextWindowID();
 } // namespace dom
@@ -1522,21 +1521,21 @@ NewOuterWindowProxy(JSContext *cx, JS::H
                                    isChrome ? &nsChromeOuterWindowProxy::singleton
                                             : &nsOuterWindowProxy::singleton,
                                    options);
   MOZ_ASSERT_IF(obj, js::IsWindowProxy(obj));
   return obj;
 }
 
 //*****************************************************************************
-//***    nsGlobalWindow: Object Management
+//***    nsGlobalWindowInner: Object Management
 //*****************************************************************************
 
-nsGlobalWindow::nsGlobalWindow(nsGlobalWindowOuter *aOuterWindow)
-  : nsPIDOMWindow<nsISupports>(aOuterWindow ? aOuterWindow->AsOuter() : nullptr),
+nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter *aOuterWindow)
+  : nsPIDOMWindow<nsISupports>(aOuterWindow->AsOuter()),
     mIdleFuzzFactor(0),
     mIdleCallbackIndex(-1),
     mCurrentlyIdle(false),
     mAddActiveEventFuzzTime(true),
     mFullScreen(false),
     mFullscreenMode(false),
     mIsClosed(false),
     mInClose(false),
@@ -1668,44 +1667,53 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
                   getpid(),
                   gSerialCounter,
                   static_cast<void*>(ToCanonicalSupports(aOuterWindow)));
   }
 #endif
 
   MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
           ("DOMWINDOW %p created outer=%p", this, aOuterWindow));
+
+  // Add ourselves to the inner windows list.
+  MOZ_ASSERT(sInnerWindowsById, "Inner Windows hash table must be created!");
+  MOZ_ASSERT(!sInnerWindowsById->Get(mWindowID),
+             "This window shouldn't be in the hash table yet!");
+  // We seem to see crashes in release builds because of null |sInnerWindowsById|.
+  if (sInnerWindowsById) {
+    sInnerWindowsById->Put(mWindowID, AssertInner());
+  }
 }
 
 #ifdef DEBUG
 
 /* static */
 void
-nsGlobalWindow::AssertIsOnMainThread()
+nsGlobalWindowInner::AssertIsOnMainThread()
 {
   MOZ_ASSERT(NS_IsMainThread());
 }
 
 #endif // DEBUG
 
 /* static */
 void
-nsGlobalWindow::Init()
+nsGlobalWindowInner::Init()
 {
   AssertIsOnMainThread();
 
   NS_ASSERTION(gDOMLeakPRLog, "gDOMLeakPRLog should have been initialized!");
 
   nsGlobalWindowOuter::sOuterWindowsById =
     new nsGlobalWindowOuter::OuterWindowByIdTable();
   nsGlobalWindowInner::sInnerWindowsById =
     new nsGlobalWindowInner::InnerWindowByIdTable();
 }
 
-nsGlobalWindow::~nsGlobalWindow()
+nsGlobalWindowInner::~nsGlobalWindowInner()
 {
   AssertIsOnMainThread();
 
   if (IsChromeWindow()) {
     MOZ_ASSERT(mCleanMessageManager,
               "chrome windows may always disconnect the msg manager");
 
     DisconnectAndClearGroupMessageManagers();
@@ -1824,102 +1832,102 @@ nsGlobalWindow::~nsGlobalWindow()
   nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
   if (ac)
     ac->RemoveWindowAsListener(this);
 
   nsLayoutStatics::Release();
 }
 
 void
-nsGlobalWindow::AddEventTargetObject(DOMEventTargetHelper* aObject)
+nsGlobalWindowInner::AddEventTargetObject(DOMEventTargetHelper* aObject)
 {
   MOZ_ASSERT(IsInnerWindow());
   mEventTargetObjects.PutEntry(aObject);
 }
 
 void
-nsGlobalWindow::RemoveEventTargetObject(DOMEventTargetHelper* aObject)
+nsGlobalWindowInner::RemoveEventTargetObject(DOMEventTargetHelper* aObject)
 {
   MOZ_ASSERT(IsInnerWindow());
   mEventTargetObjects.RemoveEntry(aObject);
 }
 
 void
-nsGlobalWindow::DisconnectEventTargetObjects()
+nsGlobalWindowInner::DisconnectEventTargetObjects()
 {
   for (auto iter = mEventTargetObjects.ConstIter(); !iter.Done();
        iter.Next()) {
     RefPtr<DOMEventTargetHelper> target = iter.Get()->GetKey();
     target->DisconnectFromOwner();
   }
   mEventTargetObjects.Clear();
 }
 
 // static
 void
-nsGlobalWindow::ShutDown()
+nsGlobalWindowInner::ShutDown()
 {
   AssertIsOnMainThread();
 
   if (gDumpFile && gDumpFile != stdout) {
     fclose(gDumpFile);
   }
   gDumpFile = nullptr;
 
   delete nsGlobalWindowInner::sInnerWindowsById;
   nsGlobalWindowInner::sInnerWindowsById = nullptr;
   delete nsGlobalWindowOuter::sOuterWindowsById;
   nsGlobalWindowOuter::sOuterWindowsById = nullptr;
 }
 
 // static
 void
-nsGlobalWindow::CleanupCachedXBLHandlers()
+nsGlobalWindowInner::CleanupCachedXBLHandlers()
 {
   if (mCachedXBLPrototypeHandlers &&
       mCachedXBLPrototypeHandlers->Count() > 0) {
     mCachedXBLPrototypeHandlers->Clear();
   }
 }
 
 void
-nsGlobalWindow::MaybeForgiveSpamCount()
+nsGlobalWindowInner::MaybeForgiveSpamCount()
 {
   if (IsOuterWindow() &&
       IsPopupSpamWindow()) {
     SetIsPopupSpamWindow(false);
   }
 }
 
 void
-nsGlobalWindow::SetIsPopupSpamWindow(bool aIsPopupSpam)
+nsGlobalWindowInner::SetIsPopupSpamWindow(bool aIsPopupSpam)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   mIsPopupSpam = aIsPopupSpam;
   if (aIsPopupSpam) {
     ++gOpenPopupSpamCount;
   } else {
     --gOpenPopupSpamCount;
     NS_ASSERTION(gOpenPopupSpamCount >= 0,
                  "Unbalanced decrement of gOpenPopupSpamCount");
   }
 }
 
 void
-nsGlobalWindow::DropOuterWindowDocs()
+nsGlobalWindowInner::DropOuterWindowDocs()
 {
   MOZ_ASSERT(IsOuterWindow());
   MOZ_ASSERT_IF(mDoc, !mDoc->EventHandlingSuppressed());
   mDoc = nullptr;
   mSuspendedDoc = nullptr;
 }
 
 void
-nsGlobalWindow::CleanUp()
+nsGlobalWindowInner::CleanUp()
 {
   // Guarantee idempotence.
   if (mCleanedUp)
     return;
   mCleanedUp = true;
 
   StartDying();
 
@@ -2038,17 +2046,17 @@ nsGlobalWindow::CleanUp()
   }
 
   mServiceWorkerRegistrationTable.Clear();
 
   mIntlUtils = nullptr;
 }
 
 void
-nsGlobalWindow::ClearControllers()
+nsGlobalWindowInner::ClearControllers()
 {
   if (mControllers) {
     uint32_t count;
     mControllers->GetControllerCount(&count);
 
     while (count--) {
       nsCOMPtr<nsIController> controller;
       mControllers->GetControllerAt(count, getter_AddRefs(controller));
@@ -2058,17 +2066,17 @@ nsGlobalWindow::ClearControllers()
         context->SetCommandContext(nullptr);
     }
 
     mControllers = nullptr;
   }
 }
 
 void
-nsGlobalWindow::FreeInnerObjects()
+nsGlobalWindowInner::FreeInnerObjects()
 {
   NS_ASSERTION(IsInnerWindow(), "Don't free inner objects on an outer window");
 
   // Make sure that this is called before we null out the document and
   // other members that the window destroyed observers could
   // re-create.
   NotifyDOMWindowDestroyed(AssertInner());
   if (auto* reporter = nsWindowMemoryReporter::Get()) {
@@ -2160,23 +2168,23 @@ nsGlobalWindow::FreeInnerObjects()
   if (mTabChild) {
     while (mBeforeUnloadListenerCount-- > 0) {
       mTabChild->BeforeUnloadRemoved();
     }
   }
 }
 
 //*****************************************************************************
-// nsGlobalWindow::nsISupports
+// nsGlobalWindowInner::nsISupports
 //*****************************************************************************
 
-// QueryInterface implementation for nsGlobalWindow
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
+// QueryInterface implementation for nsGlobalWindowInner
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindowInner)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  // Make sure this matches the cast in nsGlobalWindow::FromWrapper()
+  // Make sure this matches the cast in nsGlobalWindowInner::FromWrapper()
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventTarget)
   NS_INTERFACE_MAP_ENTRY(nsIDOMWindow)
   NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
   NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject)
   NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
   NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
   NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
   if (aIID.Equals(NS_GET_IID(nsPIDOMWindowInner))) {
@@ -2194,20 +2202,20 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   if (aIID.Equals(NS_GET_IID(nsIDOMChromeWindow)) && IsChromeWindow()) {
     foundInterface = static_cast<nsIDOMChromeWindow*>(this);
   } else
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
 NS_INTERFACE_MAP_END
 
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGlobalWindow)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGlobalWindow)
-
-NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsGlobalWindow)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGlobalWindowInner)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGlobalWindowInner)
+
+NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsGlobalWindowInner)
   if (tmp->IsBlackForCC(false)) {
     if (nsCCUncollectableMarker::InGeneration(tmp->mCanSkipCCGeneration)) {
       return true;
     }
     tmp->mCanSkipCCGeneration = nsCCUncollectableMarker::sGeneration;
     if (tmp->mCachedXBLPrototypeHandlers) {
       for (auto iter = tmp->mCachedXBLPrototypeHandlers->Iter();
            !iter.Done();
@@ -2220,47 +2228,47 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(
     }
     if (tmp->mTimeoutManager) {
       tmp->mTimeoutManager->UnmarkGrayTimers();
     }
     return true;
   }
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
 
-NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsGlobalWindow)
+NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsGlobalWindowInner)
   return tmp->IsBlackForCC(true);
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
 
-NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsGlobalWindow)
+NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsGlobalWindowInner)
   return tmp->IsBlackForCC(false);
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
 
 inline void
 ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
                             IdleObserverHolder& aField,
                             const char* aName,
                             unsigned aFlags)
 {
   CycleCollectionNoteChild(aCallback, aField.mIdleObserver.get(), aName, aFlags);
 }
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalWindow)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalWindowInner)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowInner)
   if (MOZ_UNLIKELY(cb.WantDebugInfo())) {
     char name[512];
     nsAutoCString uri;
     if (tmp->mDoc && tmp->mDoc->GetDocumentURI()) {
       uri = tmp->mDoc->GetDocumentURI()->GetSpecOrDefault();
     }
-    SprintfLiteral(name, "nsGlobalWindow # %" PRIu64 " %s %s", tmp->mWindowID,
+    SprintfLiteral(name, "nsGlobalWindowInner # %" PRIu64 " %s %s", tmp->mWindowID,
                    tmp->IsInnerWindow() ? "inner" : "outer", uri.get());
     cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   } else {
-    NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGlobalWindow, tmp->mRefCnt.get())
+    NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGlobalWindowInner, tmp->mRefCnt.get())
   }
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext)
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mArguments)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReturnValue)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNavigator)
@@ -2338,17 +2346,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   tmp->TraverseHostObjectURIs(cb);
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeFields.mBrowserDOMWindow)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeFields.mMessageManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeFields.mGroupMessageManagers)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeFields.mOpenerForInitialContentBrowser)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner)
   tmp->CleanupCachedXBLHandlers();
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mArguments)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mReturnValue)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mNavigator)
@@ -2438,52 +2446,52 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeFields.mOpenerForInitialContentBrowser)
   }
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 #ifdef DEBUG
 void
-nsGlobalWindow::RiskyUnlink()
+nsGlobalWindowInner::RiskyUnlink()
 {
   NS_CYCLE_COLLECTION_INNERNAME.Unlink(this);
 }
 #endif
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsGlobalWindow)
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsGlobalWindowInner)
   if (tmp->mCachedXBLPrototypeHandlers) {
     for (auto iter = tmp->mCachedXBLPrototypeHandlers->Iter();
          !iter.Done();
          iter.Next()) {
       aCallbacks.Trace(&iter.Data(), "Cached XBL prototype handler", aClosure);
     }
   }
   NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 bool
-nsGlobalWindow::IsBlackForCC(bool aTracingNeeded)
+nsGlobalWindowInner::IsBlackForCC(bool aTracingNeeded)
 {
   if (!nsCCUncollectableMarker::sGeneration) {
     return false;
   }
 
   return (nsCCUncollectableMarker::InGeneration(GetMarkedCCGeneration()) ||
           HasKnownLiveWrapper()) &&
          (!aTracingNeeded ||
           HasNothingToTrace(static_cast<nsIDOMEventTarget*>(this)));
 }
 
 //*****************************************************************************
-// nsGlobalWindow::nsIScriptGlobalObject
+// nsGlobalWindowInner::nsIScriptGlobalObject
 //*****************************************************************************
 
 nsresult
-nsGlobalWindow::EnsureScriptEnvironment()
+nsGlobalWindowInner::EnsureScriptEnvironment()
 {
   nsGlobalWindowOuter* outer = GetOuterWindowInternal();
   if (!outer) {
     NS_WARNING("No outer window available!");
     return NS_ERROR_FAILURE;
   }
 
   if (outer->GetWrapperPreserveColor()) {
@@ -2506,39 +2514,39 @@ nsGlobalWindow::EnsureScriptEnvironment(
   nsresult rv = context->InitContext();
   NS_ENSURE_SUCCESS(rv, rv);
 
   outer->mContext = context;
   return NS_OK;
 }
 
 nsIScriptContext *
-nsGlobalWindow::GetScriptContext()
+nsGlobalWindowInner::GetScriptContext()
 {
   nsGlobalWindowOuter* outer = GetOuterWindowInternal();
   if (!outer) {
     return nullptr;
   }
   return outer->mContext;
 }
 
 JSObject *
-nsGlobalWindow::GetGlobalJSObject()
+nsGlobalWindowInner::GetGlobalJSObject()
 {
   return FastGetGlobalJSObject();
 }
 
 void
-nsGlobalWindow::TraceGlobalJSObject(JSTracer* aTrc)
+nsGlobalWindowInner::TraceGlobalJSObject(JSTracer* aTrc)
 {
   TraceWrapper(aTrc, "active window global");
 }
 
 bool
-nsGlobalWindow::WouldReuseInnerWindow(nsIDocument* aNewDocument)
+nsGlobalWindowInner::WouldReuseInnerWindow(nsIDocument* aNewDocument)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // We reuse the inner window when:
   // a. We are currently at our original document.
   // b. At least one of the following conditions are true:
   // -- The new document is the same as the old document. This means that we're
   //    getting called from document.open().
@@ -2574,17 +2582,17 @@ nsGlobalWindow::WouldReuseInnerWindow(ns
     // The origin is the same.
     return true;
   }
 
   return false;
 }
 
 void
-nsGlobalWindow::SetInitialPrincipalToSubject()
+nsGlobalWindowInner::SetInitialPrincipalToSubject()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // First, grab the subject principal.
   nsCOMPtr<nsIPrincipal> newWindowPrincipal = nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller();
 
   // We should never create windows with an expanded principal.
   // If we have a system principal, make sure we're not using it for a content
@@ -2649,30 +2657,30 @@ void
 PopPopupControlState(PopupControlState aState)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   gPopupControlState = aState;
 }
 
 PopupControlState
-nsGlobalWindow::PushPopupControlState(PopupControlState aState,
+nsGlobalWindowInner::PushPopupControlState(PopupControlState aState,
                                       bool aForce) const
 {
   return ::PushPopupControlState(aState, aForce);
 }
 
 void
-nsGlobalWindow::PopPopupControlState(PopupControlState aState) const
+nsGlobalWindowInner::PopPopupControlState(PopupControlState aState) const
 {
   ::PopPopupControlState(aState);
 }
 
 PopupControlState
-nsGlobalWindow::GetPopupControlState() const
+nsGlobalWindowInner::GetPopupControlState() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   return gPopupControlState;
 }
 
 #define WINDOWSTATEHOLDER_IID \
 {0x0b917c3e, 0xbd50, 0x4683, {0xaf, 0xc9, 0xc7, 0x81, 0x07, 0xae, 0x33, 0x26}}
 
@@ -2779,97 +2787,19 @@ InitializeLegacyNetscapeObject(JSContext
   /* Define PrivilegeManager object with the necessary "static" methods. */
   obj = JS_DefineObject(aCx, obj, "PrivilegeManager", nullptr);
   NS_ENSURE_TRUE(obj, false);
 
   return JS_DefineFunctions(aCx, obj, EnablePrivilegeSpec);
 }
 
 bool
-nsGlobalWindow::ComputeIsSecureContext(nsIDocument* aDocument, SecureContextFlags aFlags)
-{
-  MOZ_ASSERT(IsOuterWindow());
-
-  nsCOMPtr<nsIPrincipal> principal = aDocument->NodePrincipal();
-  if (nsContentUtils::IsSystemPrincipal(principal)) {
-    return true;
-  }
-
-  // Implement https://w3c.github.io/webappsec-secure-contexts/#settings-object
-  // With some modifications to allow for aFlags.
-
-  bool hadNonSecureContextCreator = false;
-
-  nsPIDOMWindowOuter* parentOuterWin = GetScriptableParent();
-  MOZ_ASSERT(parentOuterWin, "How can we get here? No docShell somehow?");
-  if (nsGlobalWindowOuter::Cast(parentOuterWin) != this) {
-    // There may be a small chance that parentOuterWin has navigated in
-    // the time that it took us to start loading this sub-document.  If that
-    // were the case then parentOuterWin->GetCurrentInnerWindow() wouldn't
-    // return the window for the document that is embedding us.  For this
-    // reason we only use the GetScriptableParent call above to check that we
-    // have a same-type parent, but actually get the inner window via the
-    // document that we know is embedding us.
-    nsIDocument* creatorDoc = aDocument->GetParentDocument();
-    if (!creatorDoc) {
-      return false; // we must be tearing down
-    }
-    nsGlobalWindowInner* parentWin =
-      nsGlobalWindowInner::Cast(creatorDoc->GetInnerWindow());
-    if (!parentWin) {
-      return false; // we must be tearing down
-    }
-    MOZ_ASSERT(parentWin ==
-               nsGlobalWindowInner::Cast(parentOuterWin->GetCurrentInnerWindow()),
-               "Creator window mismatch while setting Secure Context state");
-    if (aFlags != SecureContextFlags::eIgnoreOpener) {
-      hadNonSecureContextCreator = !parentWin->IsSecureContext();
-    } else {
-      hadNonSecureContextCreator = !parentWin->IsSecureContextIfOpenerIgnored();
-    }
-  } else if (mHadOriginalOpener) {
-    if (aFlags != SecureContextFlags::eIgnoreOpener) {
-      hadNonSecureContextCreator = !mOriginalOpenerWasSecureContext;
-    }
-  }
-
-  if (hadNonSecureContextCreator) {
-    return false;
-  }
-
-  if (nsContentUtils::HttpsStateIsModern(aDocument)) {
-    return true;
-  }
-
-  if (principal->GetIsNullPrincipal()) {
-    nsCOMPtr<nsIURI> uri = aDocument->GetOriginalURI();
-    // IsOriginPotentiallyTrustworthy doesn't care about origin attributes so
-    // it doesn't actually matter what we use here, but reusing the document
-    // principal's attributes is convenient.
-    const OriginAttributes& attrs = principal->OriginAttributesRef();
-    // CreateCodebasePrincipal correctly gets a useful principal for blob: and
-    // other URI_INHERITS_SECURITY_CONTEXT URIs.
-    principal = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
-    if (NS_WARN_IF(!principal)) {
-      return false;
-    }
-  }
-
-  nsCOMPtr<nsIContentSecurityManager> csm =
-    do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID);
-  NS_WARNING_ASSERTION(csm, "csm is null");
-  if (csm) {
-    bool isTrustworthyOrigin = false;
-    csm->IsOriginPotentiallyTrustworthy(principal, &isTrustworthyOrigin);
-    if (isTrustworthyOrigin) {
-      return true;
-    }
-  }
-
-  return false;
+nsGlobalWindowInner::ComputeIsSecureContext(nsIDocument* aDocument, SecureContextFlags aFlags)
+{
+  MOZ_CRASH("Outer Window Only - notbuilding");
 }
 
 static JS::CompartmentCreationOptions&
 SelectZoneGroup(nsGlobalWindowInner* aNewInner,
                 JS::CompartmentCreationOptions& aOptions)
 {
   JS::CompartmentCreationOptions options;
 
@@ -2959,17 +2889,17 @@ CreateNativeGlobalForInner(JSContext* aC
   if (!InitializeLegacyNetscapeObject(aCx, aGlobal)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 nsresult
-nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
+nsGlobalWindowInner::SetNewDocument(nsIDocument* aDocument,
                                nsISupports* aState,
                                bool aForceReuseInnerWindow)
 {
   NS_PRECONDITION(mDocumentPrincipal == nullptr,
                   "mDocumentPrincipal prematurely set!");
   MOZ_ASSERT(aDocument);
 
   if (IsInnerWindow()) {
@@ -3034,17 +2964,17 @@ nsGlobalWindow::SetNewDocument(nsIDocume
     }
   }
 
   /* No mDocShell means we're already been partially closed down.  When that
      happens, setting status isn't a big requirement, so don't. (Doesn't happen
      under normal circumstances, but bug 49615 describes a case.) */
 
   nsContentUtils::AddScriptRunner(NewRunnableMethod(
-    "nsGlobalWindow::ClearStatus", this, &nsGlobalWindow::ClearStatus));
+    "nsGlobalWindowInner::ClearStatus", this, &nsGlobalWindowInner::ClearStatus));
 
   // Sometimes, WouldReuseInnerWindow() returns true even if there's no inner
   // window (see bug 776497). Be safe.
   bool reUseInnerWindow = (aForceReuseInnerWindow || wouldReuseInnerWindow) &&
                           GetCurrentInnerWindowInternal();
 
   nsresult rv = NS_OK;
 
@@ -3238,18 +3168,18 @@ nsGlobalWindow::SetNewDocument(nsIDocume
     // Set scriptability based on the state of the docshell.
     bool allow = GetDocShell()->GetCanExecuteScripts();
     xpc::Scriptability::Get(GetWrapperPreserveColor()).SetDocShellAllowsScript(allow);
 
     if (!aState) {
       // Get the "window" property once so it will be cached on our inner.  We
       // have to do this here, not in binding code, because this has to happen
       // after we've created the outer window proxy and stashed it in the outer
-      // nsGlobalWindow, so GetWrapperPreserveColor() on that outer
-      // nsGlobalWindow doesn't return null and nsGlobalWindow::OuterObject
+      // nsGlobalWindowInner, so GetWrapperPreserveColor() on that outer
+      // nsGlobalWindowInner doesn't return null and nsGlobalWindowInner::OuterObject
       // works correctly.
       JS::Rooted<JS::Value> unused(cx);
       if (!JS_GetProperty(cx, newInnerGlobal, "window", &unused)) {
         NS_ERROR("can't create the 'window' property");
         return NS_ERROR_FAILURE;
       }
 
       // And same thing for the "self" property.
@@ -3339,49 +3269,49 @@ nsGlobalWindow::SetNewDocument(nsIDocume
   }
 
   kungFuDeathGrip->DidInitializeContext();
 
   // We wait to fire the debugger hook until the window is all set up and hooked
   // up with the outer. See bug 969156.
   if (createdInnerWindow) {
     nsContentUtils::AddScriptRunner(
-      NewRunnableMethod("nsGlobalWindow::FireOnNewGlobalObject",
+      NewRunnableMethod("nsGlobalWindowInner::FireOnNewGlobalObject",
                         newInnerWindow,
-                        &nsGlobalWindow::FireOnNewGlobalObject));
+                        &nsGlobalWindowInner::FireOnNewGlobalObject));
   }
 
   if (newInnerWindow && !newInnerWindow->mHasNotifiedGlobalCreated && mDoc) {
     // We should probably notify. However if this is the, arguably bad,
     // situation when we're creating a temporary non-chrome-about-blank
     // document in a chrome docshell, don't notify just yet. Instead wait
     // until we have a real chrome doc.
     if (!mDocShell ||
         mDocShell->ItemType() != nsIDocShellTreeItem::typeChrome ||
         nsContentUtils::IsSystemPrincipal(mDoc->NodePrincipal())) {
       newInnerWindow->mHasNotifiedGlobalCreated = true;
       nsContentUtils::AddScriptRunner(
-        NewRunnableMethod("nsGlobalWindow::DispatchDOMWindowCreated",
+        NewRunnableMethod("nsGlobalWindowInner::DispatchDOMWindowCreated",
                           this,
-                          &nsGlobalWindow::DispatchDOMWindowCreated));
+                          &nsGlobalWindowInner::DispatchDOMWindowCreated));
     }
   }
 
   PreloadLocalStorage();
 
   // If we have a recorded interesting Large-Allocation header status, report it
   // to the newly attached document.
   ReportLargeAllocStatus();
   mLargeAllocStatus = LargeAllocStatus::NONE;
 
   return NS_OK;
 }
 
 void
-nsGlobalWindow::PreloadLocalStorage()
+nsGlobalWindowInner::PreloadLocalStorage()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!Preferences::GetBool(kStorageEnabled)) {
     return;
   }
 
   if (IsChromeWindow()) {
@@ -3408,17 +3338,17 @@ nsGlobalWindow::PreloadLocalStorage()
     rv = storageManager->PrecacheStorage(principal, getter_AddRefs(storage));
     if (NS_SUCCEEDED(rv)) {
       mLocalStorage = static_cast<Storage*>(storage.get());
     }
   }
 }
 
 void
-nsGlobalWindow::DispatchDOMWindowCreated()
+nsGlobalWindowInner::DispatchDOMWindowCreated()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mDoc) {
     return;
   }
 
   // Fire DOMWindowCreated at chrome event listeners
@@ -3441,23 +3371,23 @@ nsGlobalWindow::DispatchDOMWindowCreated
                       nsContentUtils::IsSystemPrincipal(principal) ?
                         "chrome-document-global-created" :
                         "content-document-global-created",
                       origin.get());
   }
 }
 
 void
-nsGlobalWindow::ClearStatus()
+nsGlobalWindowInner::ClearStatus()
 {
   SetStatusOuter(EmptyString());
 }
 
 void
-nsGlobalWindow::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument)
+nsGlobalWindowInner::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument)
 {
   NS_PRECONDITION(IsInnerWindow(), "Must only be called on inner windows");
   MOZ_ASSERT(aDocument);
 
   if (MOZ_LOG_TEST(gDOMLeakPRLog, LogLevel::Debug)) {
     nsIURI *uri = aDocument->GetDocumentURI();
     MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
             ("DOMWINDOW %p SetNewDocument %s",
@@ -3477,69 +3407,23 @@ nsGlobalWindow::InnerSetNewDocument(JSCo
   Telemetry::Accumulate(Telemetry::INNERWINDOWS_WITH_MUTATION_LISTENERS,
                         mMutationBits ? 1 : 0);
 
   // Clear our mutation bitfield.
   mMutationBits = 0;
 }
 
 void
-nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
-{
-  NS_ASSERTION(IsOuterWindow(), "Uh, SetDocShell() called on inner window!");
-  MOZ_ASSERT(aDocShell);
-
-  if (aDocShell == mDocShell) {
-    return;
-  }
-
-  mDocShell = aDocShell; // Weak Reference
-
-  nsCOMPtr<nsPIDOMWindowOuter> parentWindow = GetScriptableParentOrNull();
-  MOZ_RELEASE_ASSERT(!parentWindow || !mTabGroup ||
-                     mTabGroup == nsGlobalWindowOuter::Cast(parentWindow)->mTabGroup);
-
-  mTopLevelOuterContentWindow =
-    !mIsChrome && GetScriptableTopInternal() == this;
-
-  NS_ASSERTION(!mNavigator, "Non-null mNavigator in outer window!");
-
-  if (mFrames) {
-    mFrames->SetDocShell(aDocShell);
-  }
-
-  // Get our enclosing chrome shell and retrieve its global window impl, so
-  // that we can do some forwarding to the chrome document.
-  nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
-  mDocShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
-  mChromeEventHandler = do_QueryInterface(chromeEventHandler);
-  if (!mChromeEventHandler) {
-    // We have no chrome event handler. If we have a parent,
-    // get our chrome event handler from the parent. If
-    // we don't have a parent, then we need to make a new
-    // window root object that will function as a chrome event
-    // handler and receive all events that occur anywhere inside
-    // our window.
-    nsCOMPtr<nsPIDOMWindowOuter> parentWindow = GetParent();
-    if (parentWindow.get() != AsOuter()) {
-      mChromeEventHandler = parentWindow->GetChromeEventHandler();
-    }
-    else {
-      mChromeEventHandler = NS_NewWindowRoot(AsOuter());
-      mIsRootOuterWindow = true;
-    }
-  }
-
-  bool docShellActive;
-  mDocShell->GetIsActive(&docShellActive);
-  SetIsBackgroundInternal(!docShellActive);
-}
-
-void
-nsGlobalWindow::DetachFromDocShell()
+nsGlobalWindowInner::SetDocShell(nsIDocShell* aDocShell)
+{
+  MOZ_CRASH("Outer Window Only");
+}
+
+void
+nsGlobalWindowInner::DetachFromDocShell()
 {
   NS_ASSERTION(IsOuterWindow(), "Uh, DetachFromDocShell() called on inner window!");
 
   // DetachFromDocShell means the window is being torn down. Drop our
   // reference to the script context, allowing it to be deleted
   // later. Meanwhile, keep our weak reference to the script object
   // so that it can be retrieved later (until it is finalized by the JS GC).
 
@@ -3599,17 +3483,17 @@ nsGlobalWindow::DetachFromDocShell()
     mFrames->SetDocShell(nullptr);
   }
 
   MaybeForgiveSpamCount();
   CleanUp();
 }
 
 void
-nsGlobalWindow::SetOpenerWindow(nsPIDOMWindowOuter* aOpener,
+nsGlobalWindowInner::SetOpenerWindow(nsPIDOMWindowOuter* aOpener,
                                 bool aOriginalOpener)
 {
   FORWARD_TO_OUTER_VOID(SetOpenerWindow, (aOpener, aOriginalOpener));
 
   nsWeakPtr opener = do_GetWeakReference(aOpener);
   if (opener == mOpener) {
     return;
   }
@@ -3660,17 +3544,17 @@ TryGetTabChildGlobalAsEventTarget(nsISup
     return nullptr;
   }
 
   nsCOMPtr<EventTarget> target = frameLoader->GetTabChildGlobalAsEventTarget();
   return target.forget();
 }
 
 void
-nsGlobalWindow::UpdateParentTarget()
+nsGlobalWindowInner::UpdateParentTarget()
 {
   // Try to get our frame element's tab child global (its in-process message
   // manager).  If that fails, fall back to the chrome event handler's tab
   // child global, and if it doesn't have one, just use the chrome event
   // handler itself.
 
   nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal();
   nsCOMPtr<EventTarget> eventTarget =
@@ -3691,35 +3575,35 @@ nsGlobalWindow::UpdateParentTarget()
   if (!eventTarget) {
     eventTarget = mChromeEventHandler;
   }
 
   mParentTarget = eventTarget;
 }
 
 EventTarget*
-nsGlobalWindow::GetTargetForDOMEvent()
+nsGlobalWindowInner::GetTargetForDOMEvent()
 {
   return GetOuterWindowInternal();
 }
 
 EventTarget*
-nsGlobalWindow::GetTargetForEventTargetChain()
+nsGlobalWindowInner::GetTargetForEventTargetChain()
 {
   return IsInnerWindow() ? this : GetCurrentInnerWindowInternal();
 }
 
 nsresult
-nsGlobalWindow::WillHandleEvent(EventChainPostVisitor& aVisitor)
+nsGlobalWindowInner::WillHandleEvent(EventChainPostVisitor& aVisitor)
 {
   return NS_OK;
 }
 
 nsresult
-nsGlobalWindow::GetEventTargetParent(EventChainPreVisitor& aVisitor)
+nsGlobalWindowInner::GetEventTargetParent(EventChainPreVisitor& aVisitor)
 {
   NS_PRECONDITION(IsInnerWindow(),
                   "GetEventTargetParent is used on outer window!?");
   EventMessage msg = aVisitor.mEvent->mMessage;
 
   aVisitor.mCanHandle = true;
   aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119
   if (msg == eResize && aVisitor.mEvent->IsTrusted()) {
@@ -3754,17 +3638,17 @@ nsGlobalWindow::GetEventTargetParent(Eve
        aVisitor.mEvent->HasDragEventMessage())) {
     mAddActiveEventFuzzTime = false;
   }
 
   return NS_OK;
 }
 
 bool
-nsGlobalWindow::ShouldPromptToBlockDialogs()
+nsGlobalWindowInner::ShouldPromptToBlockDialogs()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsGlobalWindowOuter *topWindowOuter = GetScriptableTopInternal();
   if (!topWindowOuter) {
     NS_ASSERTION(!mDocShell, "ShouldPromptToBlockDialogs() called without a top window?");
     return true;
   }
@@ -3773,17 +3657,17 @@ nsGlobalWindow::ShouldPromptToBlockDialo
   if (!topWindow) {
     return true;
   }
 
   return topWindow->DialogsAreBeingAbused();
 }
 
 bool
-nsGlobalWindow::AreDialogsEnabled()
+nsGlobalWindowInner::AreDialogsEnabled()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsGlobalWindowOuter *topWindowOuter = GetScriptableTopInternal();
   if (!topWindowOuter) {
     NS_ERROR("AreDialogsEnabled() called without a top window?");
     return false;
   }
@@ -3815,17 +3699,17 @@ nsGlobalWindow::AreDialogsEnabled()
   if (!mDoc || (mDoc->GetSandboxFlags() & SANDBOXED_MODALS)) {
     return false;
   }
 
   return topWindow->mAreDialogsEnabled;
 }
 
 bool
-nsGlobalWindow::DialogsAreBeingAbused()
+nsGlobalWindowInner::DialogsAreBeingAbused()
 {
   MOZ_ASSERT(IsInnerWindow());
   NS_ASSERTION(GetScriptableTopInternal() &&
                GetScriptableTopInternal()->GetCurrentInnerWindowInternal() == this,
                "DialogsAreBeingAbused called with invalid window");
 
   if (mLastDialogQuitTime.IsNull() ||
       nsContentUtils::IsCallerChrome()) {
@@ -3844,17 +3728,17 @@ nsGlobalWindow::DialogsAreBeingAbused()
 
   // Reset the abuse counter
   mDialogAbuseCount = 0;
 
   return false;
 }
 
 bool
-nsGlobalWindow::ConfirmDialogIfNeeded()
+nsGlobalWindowInner::ConfirmDialogIfNeeded()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   NS_ENSURE_TRUE(mDocShell, false);
   nsCOMPtr<nsIPromptService> promptSvc =
     do_GetService("@mozilla.org/embedcomp/prompt-service;1");
 
   if (!promptSvc) {
@@ -3877,49 +3761,49 @@ nsGlobalWindow::ConfirmDialogIfNeeded()
     DisableDialogs();
     return false;
   }
 
   return true;
 }
 
 void
-nsGlobalWindow::DisableDialogs()
+nsGlobalWindowInner::DisableDialogs()
 {
   nsGlobalWindowOuter *topWindowOuter = GetScriptableTopInternal();
   if (!topWindowOuter) {
     NS_ERROR("DisableDialogs() called without a top window?");
     return;
   }
 
   nsGlobalWindowInner* topWindow = topWindowOuter->GetCurrentInnerWindowInternal();
   // TODO: Warn if no top window?
   if (topWindow) {
     topWindow->mAreDialogsEnabled = false;
   }
 }
 
 void
-nsGlobalWindow::EnableDialogs()
+nsGlobalWindowInner::EnableDialogs()
 {
   nsGlobalWindowOuter *topWindowOuter = GetScriptableTopInternal();
   if (!topWindowOuter) {
     NS_ERROR("EnableDialogs() called without a top window?");
     return;
   }
 
   // TODO: Warn if no top window?
   nsGlobalWindowInner* topWindow = topWindowOuter->GetCurrentInnerWindowInternal();
   if (topWindow) {
     topWindow->mAreDialogsEnabled = true;
   }
 }
 
 nsresult
-nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
+nsGlobalWindowInner::PostHandleEvent(EventChainPostVisitor& aVisitor)
 {
   NS_PRECONDITION(IsInnerWindow(), "PostHandleEvent is used on outer window!?");
 
   // Return early if there is nothing to do.
   switch (aVisitor.mEvent->mMessage) {
     case eResize:
     case eUnload:
     case eLoad:
@@ -4006,26 +3890,26 @@ nsGlobalWindow::PostHandleEvent(EventCha
                                 VRDisplayEventReason::Navigation);
     }
   }
 
   return NS_OK;
 }
 
 void
-nsGlobalWindow::PoisonOuterWindowProxy(JSObject *aObject)
+nsGlobalWindowInner::PoisonOuterWindowProxy(JSObject *aObject)
 {
   MOZ_ASSERT(IsOuterWindow());
   if (aObject == GetWrapperMaybeDead()) {
     PoisonWrapper();
   }
 }
 
 nsresult
-nsGlobalWindow::SetArguments(nsIArray *aArguments)
+nsGlobalWindowInner::SetArguments(nsIArray *aArguments)
 {
   MOZ_ASSERT(IsOuterWindow());
   nsresult rv;
 
   // Historically, we've used the same machinery to handle openDialog arguments
   // (exposed via window.arguments) and showModalDialog arguments (exposed via
   // window.dialogArguments), even though the former is XUL-only and uses an XPCOM
   // array while the latter is web-exposed and uses an arbitrary JS value.
@@ -4042,33 +3926,33 @@ nsGlobalWindow::SetArguments(nsIArray *a
   mArguments = aArguments;
   rv = currentInner->DefineArgumentsProperty(aArguments);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 nsresult
-nsGlobalWindow::DefineArgumentsProperty(nsIArray *aArguments)
+nsGlobalWindowInner::DefineArgumentsProperty(nsIArray *aArguments)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   nsIScriptContext *ctx = GetOuterWindowInternal()->mContext;
   NS_ENSURE_TRUE(aArguments && ctx, NS_ERROR_NOT_INITIALIZED);
 
   JS::Rooted<JSObject*> obj(RootingCx(), GetWrapperPreserveColor());
   return ctx->SetProperty(obj, "arguments", aArguments);
 }
 
 //*****************************************************************************
-// nsGlobalWindow::nsIScriptObjectPrincipal
+// nsGlobalWindowInner::nsIScriptObjectPrincipal
 //*****************************************************************************
 
 nsIPrincipal*
-nsGlobalWindow::GetPrincipal()
+nsGlobalWindowInner::GetPrincipal()
 {
   if (mDoc) {
     // If we have a document, get the principal from the document
     return mDoc->NodePrincipal();
   }
 
   if (mDocumentPrincipal) {
     return mDocumentPrincipal;
@@ -4086,17 +3970,17 @@ nsGlobalWindow::GetPrincipal()
   if (objPrincipal) {
     return objPrincipal->GetPrincipal();
   }
 
   return nullptr;
 }
 
 //*****************************************************************************
-// nsGlobalWindow::nsIDOMWindow
+// nsGlobalWindowInner::nsIDOMWindow
 //*****************************************************************************
 
 template <class T>
 nsIURI*
 nsPIDOMWindow<T>::GetDocumentURI() const
 {
   return mDoc ? mDoc->GetDocumentURI() : mDocumentURI.get();
 }
@@ -4208,88 +4092,88 @@ nsPIDOMWindowInner::UnmuteAudioContexts(
   for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
     if (!mAudioContexts[i]->IsOffline()) {
       mAudioContexts[i]->Unmute();
     }
   }
 }
 
 nsGlobalWindowInner*
-nsGlobalWindow::Window()
+nsGlobalWindowInner::Window()
 {
   return AssertInner();
 }
 
 nsGlobalWindowInner*
-nsGlobalWindow::Self()
+nsGlobalWindowInner::Self()
 {
   return AssertInner();
 }
 
 Navigator*
-nsGlobalWindow::Navigator()
+nsGlobalWindowInner::Navigator()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mNavigator) {
     mNavigator = new mozilla::dom::Navigator(AsInner());
   }
 
   return mNavigator;
 }
 
 nsIDOMNavigator*
-nsGlobalWindow::GetNavigator()
+nsGlobalWindowInner::GetNavigator()
 {
   FORWARD_TO_INNER(GetNavigator, (), nullptr);
 
   return Navigator();
 }
 
 nsScreen*
-nsGlobalWindow::GetScreen(ErrorResult& aError)
+nsGlobalWindowInner::GetScreen(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mScreen) {
     mScreen = nsScreen::Create(AsInner());
     if (!mScreen) {
       aError.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
   }
 
   return mScreen;
 }
 
 nsIDOMScreen*
-nsGlobalWindow::GetScreen()
+nsGlobalWindowInner::GetScreen()
 {
   FORWARD_TO_INNER(GetScreen, (), nullptr);
 
   ErrorResult dummy;
   nsIDOMScreen* screen = GetScreen(dummy);
   dummy.SuppressException();
   return screen;
 }
 
 nsHistory*
-nsGlobalWindow::GetHistory(ErrorResult& aError)
+nsGlobalWindowInner::GetHistory(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mHistory) {
     mHistory = new nsHistory(AsInner());
   }
 
   return mHistory;
 }
 
 CustomElementRegistry*
-nsGlobalWindow::CustomElements()
+nsGlobalWindowInner::CustomElements()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mCustomElements) {
     mCustomElements = new CustomElementRegistry(AsInner());
   }
 
   return mCustomElements;
@@ -4299,17 +4183,17 @@ Performance*
 nsPIDOMWindowInner::GetPerformance()
 {
   MOZ_ASSERT(IsInnerWindow());
   CreatePerformanceObjectIfNeeded();
   return mPerformance;
 }
 
 Performance*
-nsGlobalWindow::GetPerformance()
+nsGlobalWindowInner::GetPerformance()
 {
   return AsInner()->GetPerformance();
 }
 
 void
 nsPIDOMWindowInner::CreatePerformanceObjectIfNeeded()
 {
   MOZ_ASSERT(IsInnerWindow());
@@ -4368,17 +4252,17 @@ nsPIDOMWindowInner::Thaw()
 
 void
 nsPIDOMWindowInner::SyncStateFromParentWindow()
 {
   nsGlobalWindowInner::Cast(this)->SyncStateFromParentWindow();
 }
 
 void
-nsGlobalWindow::UpdateTopInnerWindow()
+nsGlobalWindowInner::UpdateTopInnerWindow()
 {
   if (!IsInnerWindow() || AsInner()->IsTopInnerWindow() || !mTopInnerWindow) {
     return;
   }
 
   mTopInnerWindow->UpdateWebSocketCount(-(int32_t)mNumOfOpenWebSockets);
 }
 
@@ -4723,43 +4607,43 @@ nsPIDOMWindowInner::SetAudioCapture(bool
 
   return NS_OK;
 }
 
 // nsISpeechSynthesisGetter
 
 #ifdef MOZ_WEBSPEECH
 SpeechSynthesis*
-nsGlobalWindow::GetSpeechSynthesis(ErrorResult& aError)
+nsGlobalWindowInner::GetSpeechSynthesis(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mSpeechSynthesis) {
     mSpeechSynthesis = new SpeechSynthesis(AsInner());
   }
 
   return mSpeechSynthesis;
 }
 
 bool
-nsGlobalWindow::HasActiveSpeechSynthesis()
+nsGlobalWindowInner::HasActiveSpeechSynthesis()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mSpeechSynthesis) {
     return !mSpeechSynthesis->HasEmptyQueue();
   }
 
   return false;
 }
 
 #endif
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetParentOuter()
+nsGlobalWindowInner::GetParentOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return nullptr;
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> parent;
@@ -4768,56 +4652,55 @@ nsGlobalWindow::GetParentOuter()
   } else {
     parent = GetParent();
   }
 
   return parent.forget();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetParent(ErrorResult& aError)
+nsGlobalWindowInner::GetParent(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetParentOuter, (), aError, nullptr);
 }
 
 /**
  * GetScriptableParent is called when script reads window.parent.
  *
  * In contrast to GetRealParent, GetScriptableParent respects <iframe
  * mozbrowser> boundaries, so if |this| is contained by an <iframe
  * mozbrowser>, we will return |this| as its own parent.
  */
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetScriptableParent()
+nsGlobalWindowInner::GetScriptableParent()
 {
   FORWARD_TO_OUTER(GetScriptableParent, (), nullptr);
 
   nsCOMPtr<nsPIDOMWindowOuter> parent = GetParentOuter();
   return parent.get();
 }
 
 /**
  * Behavies identically to GetScriptableParent extept that it returns null
  * if GetScriptableParent would return this window.
  */
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetScriptableParentOrNull()
+nsGlobalWindowInner::GetScriptableParentOrNull()
 {
   FORWARD_TO_OUTER(GetScriptableParentOrNull, (), nullptr);
 
-  nsPIDOMWindowOuter* parent = GetScriptableParent();
-  return (nsGlobalWindowOuter::Cast(parent) == this) ? nullptr : parent;
+  MOZ_CRASH("Should be in outer by now");
 }
 
 /**
  * nsPIDOMWindow::GetParent (when called from C++) is just a wrapper around
  * GetRealParent.
  */
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetParent()
+nsGlobalWindowInner::GetParent()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return nullptr;
   }
 
   nsCOMPtr<nsIDocShell> parent;
@@ -4870,35 +4753,35 @@ GetTopImpl(nsGlobalWindowOuter* aWin, ns
 /**
  * GetScriptableTop is called when script reads window.top.
  *
  * In contrast to GetRealTop, GetScriptableTop respects <iframe mozbrowser>
  * boundaries.  If we encounter a window owned by an <iframe mozbrowser> while
  * walking up the window hierarchy, we'll stop and return that window.
  */
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetScriptableTop()
+nsGlobalWindowInner::GetScriptableTop()
 {
   FORWARD_TO_OUTER(GetScriptableTop, (), nullptr);
   nsCOMPtr<nsPIDOMWindowOuter> window;
   GetTopImpl(AssertOuter(), getter_AddRefs(window), /* aScriptable = */ true);
   return window.get();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetTop()
+nsGlobalWindowInner::GetTop()
 {
   MOZ_ASSERT(IsOuterWindow());
   nsCOMPtr<nsPIDOMWindowOuter> window;
   GetTopImpl(AssertOuter(), getter_AddRefs(window), /* aScriptable = */ false);
   return window.forget();
 }
 
 void
-nsGlobalWindow::GetContentOuter(JSContext* aCx,
+nsGlobalWindowInner::GetContentOuter(JSContext* aCx,
                                 JS::MutableHandle<JSObject*> aRetval,
                                 CallerType aCallerType,
                                 ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsPIDOMWindowOuter> content =
     GetContentInternal(aError, aCallerType);
@@ -4916,27 +4799,27 @@ nsGlobalWindow::GetContentOuter(JSContex
     aRetval.set(&val.toObject());
     return;
   }
 
   aRetval.set(nullptr);
 }
 
 void
-nsGlobalWindow::GetContent(JSContext* aCx,
+nsGlobalWindowInner::GetContent(JSContext* aCx,
                            JS::MutableHandle<JSObject*> aRetval,
                            CallerType aCallerType,
                            ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetContentOuter,
                             (aCx, aRetval, aCallerType, aError), aError, );
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetContentInternal(ErrorResult& aError, CallerType aCallerType)
+nsGlobalWindowInner::GetContentInternal(ErrorResult& aError, CallerType aCallerType)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // First check for a named frame named "content"
   nsCOMPtr<nsPIDOMWindowOuter> domWindow =
     GetChildWindow(NS_LITERAL_STRING("content"));
   if (domWindow) {
     return domWindow.forget();
@@ -4983,34 +4866,34 @@ nsGlobalWindow::GetContentInternal(Error
     return nullptr;
   }
 
   domWindow = primaryContent->GetWindow();
   return domWindow.forget();
 }
 
 MozSelfSupport*
-nsGlobalWindow::GetMozSelfSupport(ErrorResult& aError)
+nsGlobalWindowInner::GetMozSelfSupport(ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mMozSelfSupport) {
     return mMozSelfSupport;
   }
 
   // We're called from JS and want to use out existing JSContext (and,
   // importantly, its compartment!) here.
   AutoJSContext cx;
   GlobalObject global(cx, FastGetGlobalJSObject());
   mMozSelfSupport = MozSelfSupport::Constructor(global, cx, aError);
   return mMozSelfSupport;
 }
 
 nsresult
-nsGlobalWindow::GetPrompter(nsIPrompt** aPrompt)
+nsGlobalWindowInner::GetPrompter(nsIPrompt** aPrompt)
 {
   if (IsInnerWindow()) {
     nsGlobalWindowOuter* outer = GetOuterWindowInternal();
     if (!outer) {
       NS_WARNING("No outer window available!");
       return NS_ERROR_NOT_INITIALIZED;
     }
     return outer->GetPrompter(aPrompt);
@@ -5022,148 +4905,148 @@ nsGlobalWindow::GetPrompter(nsIPrompt** 
   nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
   NS_ENSURE_TRUE(prompter, NS_ERROR_NO_INTERFACE);
 
   prompter.forget(aPrompt);
   return NS_OK;
 }
 
 BarProp*
-nsGlobalWindow::GetMenubar(ErrorResult& aError)
+nsGlobalWindowInner::GetMenubar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mMenubar) {
     mMenubar = new MenubarProp(AssertInner());
   }
 
   return mMenubar;
 }
 
 BarProp*
-nsGlobalWindow::GetToolbar(ErrorResult& aError)
+nsGlobalWindowInner::GetToolbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mToolbar) {
     mToolbar = new ToolbarProp(AssertInner());
   }
 
   return mToolbar;
 }
 
 BarProp*
-nsGlobalWindow::GetLocationbar(ErrorResult& aError)
+nsGlobalWindowInner::GetLocationbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mLocationbar) {
     mLocationbar = new LocationbarProp(AssertInner());
   }
   return mLocationbar;
 }
 
 BarProp*
-nsGlobalWindow::GetPersonalbar(ErrorResult& aError)
+nsGlobalWindowInner::GetPersonalbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mPersonalbar) {
     mPersonalbar = new PersonalbarProp(AssertInner());
   }
   return mPersonalbar;
 }
 
 BarProp*
-nsGlobalWindow::GetStatusbar(ErrorResult& aError)
+nsGlobalWindowInner::GetStatusbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mStatusbar) {
     mStatusbar = new StatusbarProp(AssertInner());
   }
   return mStatusbar;
 }
 
 BarProp*
-nsGlobalWindow::GetScrollbars(ErrorResult& aError)
+nsGlobalWindowInner::GetScrollbars(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mScrollbars) {
     mScrollbars = new ScrollbarsProp(AssertInner());
   }
 
   return mScrollbars;
 }
 
 bool
-nsGlobalWindow::GetClosedOuter()
+nsGlobalWindowInner::GetClosedOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   // If someone called close(), or if we don't have a docshell, we're closed.
   return mIsClosed || !mDocShell;
 }
 
 bool
-nsGlobalWindow::GetClosed(ErrorResult& aError)
+nsGlobalWindowInner::GetClosed(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetClosedOuter, (), aError, false);
 }
 
 bool
-nsGlobalWindow::Closed()
+nsGlobalWindowInner::Closed()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   return GetClosedOuter();
 }
 
 nsDOMWindowList*
-nsGlobalWindow::GetWindowList()
+nsGlobalWindowInner::GetWindowList()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mFrames && mDocShell) {
     mFrames = new nsDOMWindowList(mDocShell);
   }
 
   return mFrames;
 }
 
 already_AddRefed<nsIDOMWindowCollection>
-nsGlobalWindow::GetFrames()
+nsGlobalWindowInner::GetFrames()
 {
   FORWARD_TO_OUTER(GetFrames, (), nullptr);
 
   nsCOMPtr<nsIDOMWindowCollection> frames = GetWindowList();
   return frames.forget();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::IndexedGetterOuter(uint32_t aIndex)
+nsGlobalWindowInner::IndexedGetterOuter(uint32_t aIndex)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsDOMWindowList* windows = GetWindowList();
   NS_ENSURE_TRUE(windows, nullptr);
 
   return windows->IndexedGetter(aIndex);
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::IndexedGetter(uint32_t aIndex)
+nsGlobalWindowInner::IndexedGetter(uint32_t aIndex)
 {
   FORWARD_TO_OUTER(IndexedGetterOuter, (aIndex), nullptr);
   MOZ_CRASH();
 }
 
 bool
-nsGlobalWindow::DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
+nsGlobalWindowInner::DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
                           JS::Handle<jsid> aId,
                           JS::MutableHandle<JS::PropertyDescriptor> aDesc)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   // Note: Keep this in sync with MayResolve.
 
   // Note: The infallibleInit call in GlobalResolve depends on this check.
@@ -5185,17 +5068,17 @@ nsGlobalWindow::DoResolve(JSContext* aCx
     return Throw(aCx, rv);
   }
 
   return true;
 }
 
 /* static */
 bool
-nsGlobalWindow::MayResolve(jsid aId)
+nsGlobalWindowInner::MayResolve(jsid aId)
 {
   // Note: This function does not fail and may not have any side-effects.
   // Note: Keep this in sync with DoResolve.
   if (!JSID_IS_STRING(aId)) {
     return false;
   }
 
   if (aId == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_COMPONENTS)) {
@@ -5221,17 +5104,17 @@ nsGlobalWindow::MayResolve(jsid aId)
 
   nsAutoString name;
   AssignJSFlatString(name, JSID_TO_FLAT_STRING(aId));
 
   return nameSpaceManager->LookupName(name);
 }
 
 void
-nsGlobalWindow::GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
+nsGlobalWindowInner::GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
                                     bool aEnumerableOnly, ErrorResult& aRv)
 {
   if (aEnumerableOnly) {
     // The names we would return from here get defined on the window via one of
     // two codepaths.  The ones coming from the WebIDLGlobalNameHash will end up
     // in the DefineConstructor function in BindingUtils, which always defines
     // things as non-enumerable.  The ones coming from the script namespace
     // manager get defined by nsDOMClassInfo::PostCreatePrototype calling
@@ -5283,33 +5166,33 @@ nsGlobalWindow::GetOwnPropertyNames(JSCo
           return;
         }
       }
     }
   }
 }
 
 /* static */ bool
-nsGlobalWindow::IsPrivilegedChromeWindow(JSContext* aCx, JSObject* aObj)
+nsGlobalWindowInner::IsPrivilegedChromeWindow(JSContext* aCx, JSObject* aObj)
 {
   // For now, have to deal with XPConnect objects here.
   return xpc::WindowOrNull(aObj)->IsChromeWindow() &&
          nsContentUtils::ObjectPrincipal(aObj) == nsContentUtils::GetSystemPrincipal();
 }
 
 /* static */ bool
-nsGlobalWindow::IsRequestIdleCallbackEnabled(JSContext* aCx, JSObject* aObj)
+nsGlobalWindowInner::IsRequestIdleCallbackEnabled(JSContext* aCx, JSObject* aObj)
 {
   // The requestIdleCallback should always be enabled for system code.
   return nsContentUtils::RequestIdleCallbackEnabled() ||
          nsContentUtils::IsSystemCaller(aCx);
 }
 
 nsIDOMOfflineResourceList*
-nsGlobalWindow::GetApplicationCache(ErrorResult& aError)
+nsGlobalWindowInner::GetApplicationCache(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mApplicationCache) {
     nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetDocShell()));
     if (!webNav || !mDoc) {
       aError.Throw(NS_ERROR_FAILURE);
       return nullptr;
@@ -5332,58 +5215,58 @@ nsGlobalWindow::GetApplicationCache(Erro
 
     mApplicationCache = applicationCache;
   }
 
   return mApplicationCache;
 }
 
 already_AddRefed<nsIDOMOfflineResourceList>
-nsGlobalWindow::GetApplicationCache()
+nsGlobalWindowInner::GetApplicationCache()
 {
   FORWARD_TO_INNER(GetApplicationCache, (), nullptr);
 
   ErrorResult dummy;
   nsCOMPtr<nsIDOMOfflineResourceList> applicationCache =
     GetApplicationCache(dummy);
   dummy.SuppressException();
   return applicationCache.forget();
 }
 
 Crypto*
-nsGlobalWindow::GetCrypto(ErrorResult& aError)
+nsGlobalWindowInner::GetCrypto(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mCrypto) {
     mCrypto = new Crypto();
     mCrypto->Init(this);
   }
   return mCrypto;
 }
 
 mozilla::dom::U2F*
-nsGlobalWindow::GetU2f(ErrorResult& aError)
+nsGlobalWindowInner::GetU2f(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mU2F) {
     RefPtr<U2F> u2f = new U2F(AsInner());
     u2f->Init(aError);
     if (NS_WARN_IF(aError.Failed())) {
       return nullptr;
     }
 
     mU2F = u2f;
   }
   return mU2F;
 }
 
 nsIControllers*
-nsGlobalWindow::GetControllersOuter(ErrorResult& aError)
+nsGlobalWindowInner::GetControllersOuter(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mControllers) {
     nsresult rv;
     mControllers = do_CreateInstance(kXULControllersCID, &rv);
     if (NS_FAILED(rv)) {
       aError.Throw(rv);
@@ -5407,35 +5290,35 @@ nsGlobalWindow::GetControllersOuter(Erro
 
     controllerContext->SetCommandContext(static_cast<nsIDOMWindow*>(this));
   }
 
   return mControllers;
 }
 
 nsIControllers*
-nsGlobalWindow::GetControllers(ErrorResult& aError)
+nsGlobalWindowInner::GetControllers(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetControllersOuter, (aError), aError, nullptr);
 }
 
 nsresult
-nsGlobalWindow::GetControllers(nsIControllers** aResult)
+nsGlobalWindowInner::GetControllers(nsIControllers** aResult)
 {
   FORWARD_TO_INNER(GetControllers, (aResult), NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   nsCOMPtr<nsIControllers> controllers = GetControllers(rv);
   controllers.forget(aResult);
 
   return rv.StealNSResult();
 }
 
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetSanitizedOpener(nsPIDOMWindowOuter* aOpener)
+nsGlobalWindowInner::GetSanitizedOpener(nsPIDOMWindowOuter* aOpener)
 {
   if (!aOpener) {
     return nullptr;
   }
 
   nsGlobalWindowOuter* win = nsGlobalWindowOuter::Cast(aOpener);
 
   // First, ensure that we're not handing back a chrome window to content:
@@ -5460,17 +5343,17 @@ nsGlobalWindow::GetSanitizedOpener(nsPID
       }
     }
   }
 
   return nullptr;
 }
 
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetOpenerWindowOuter()
+nsGlobalWindowInner::GetOpenerWindowOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsPIDOMWindowOuter> opener = do_QueryReferent(mOpener);
 
   if (!opener) {
     return nullptr;
   }
@@ -5484,47 +5367,47 @@ nsGlobalWindow::GetOpenerWindowOuter()
     }
     return opener;
   }
 
   return GetSanitizedOpener(opener);
 }
 
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetOpenerWindow(ErrorResult& aError)
+nsGlobalWindowInner::GetOpenerWindow(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetOpenerWindowOuter, (), aError, nullptr);
 }
 
 void
-nsGlobalWindow::GetOpener(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
+nsGlobalWindowInner::GetOpener(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
                           ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   nsCOMPtr<nsPIDOMWindowOuter> opener = GetOpenerWindow(aError);
   if (aError.Failed() || !opener) {
     aRetval.setNull();
     return;
   }
 
   aError = nsContentUtils::WrapNative(aCx, opener, aRetval);
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetOpener()
+nsGlobalWindowInner::GetOpener()
 {
   FORWARD_TO_OUTER(GetOpener, (), nullptr);
 
   nsCOMPtr<nsPIDOMWindowOuter> opener = GetOpenerWindowOuter();
   return opener.forget();
 }
 
 void
-nsGlobalWindow::SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener,
+nsGlobalWindowInner::SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener,
                           ErrorResult& aError)
 {
   // Check if we were called from a privileged chrome script.  If not, and if
   // aOpener is not null, just define aOpener on our inner window's JS object,
   // wrapped into the current compartment so that for Xrays we define on the
   // Xray expando object, but don't set it on the outer window, so that it'll
   // get reset on navigation.  This is just like replaceable properties, but
   // we're not quite readonly.
@@ -5566,31 +5449,31 @@ nsGlobalWindow::SetOpener(JSContext* aCx
     }
     outer = win->GetOuterWindow();
   }
 
   SetOpenerWindow(outer, false);
 }
 
 void
-nsGlobalWindow::GetStatusOuter(nsAString& aStatus)
+nsGlobalWindowInner::GetStatusOuter(nsAString& aStatus)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   aStatus = mStatus;
 }
 
 void
-nsGlobalWindow::GetStatus(nsAString& aStatus, ErrorResult& aError)
+nsGlobalWindowInner::GetStatus(nsAString& aStatus, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetStatusOuter, (aStatus), aError, );
 }
 
 void
-nsGlobalWindow::SetStatusOuter(const nsAString& aStatus)
+nsGlobalWindowInner::SetStatusOuter(const nsAString& aStatus)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   mStatus = aStatus;
 
   /*
    * If caller is not chrome and dom.disable_window_status_change is true,
    * prevent propagating window.status to the UI by exiting early
@@ -5603,116 +5486,116 @@ nsGlobalWindow::SetStatusOuter(const nsA
   nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetWebBrowserChrome();
   if (browserChrome) {
     browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT,
                              PromiseFlatString(aStatus).get());
   }
 }
 
 void
-nsGlobalWindow::SetStatus(const nsAString& aStatus, ErrorResult& aError)
+nsGlobalWindowInner::SetStatus(const nsAString& aStatus, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetStatusOuter, (aStatus), aError, );
 }
 
 void
-nsGlobalWindow::GetNameOuter(nsAString& aName)
+nsGlobalWindowInner::GetNameOuter(nsAString& aName)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (mDocShell) {
     mDocShell->GetName(aName);
   }
 }
 
 void
-nsGlobalWindow::GetName(nsAString& aName, ErrorResult& aError)
+nsGlobalWindowInner::GetName(nsAString& aName, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetNameOuter, (aName), aError, );
 }
 
 void
-nsGlobalWindow::SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError)
+nsGlobalWindowInner::SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (mDocShell) {
     aError = mDocShell->SetName(aName);
   }
 }
 
 void
-nsGlobalWindow::SetName(const nsAString& aName, mozilla::ErrorResult& aError)
+nsGlobalWindowInner::SetName(const nsAString& aName, mozilla::ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetNameOuter, (aName, aError), aError, );
 }
 
 // Helper functions used by many methods below.
 int32_t
-nsGlobalWindow::DevToCSSIntPixels(int32_t px)
+nsGlobalWindowInner::DevToCSSIntPixels(int32_t px)
 {
   if (!mDocShell)
     return px; // assume 1:1
 
   RefPtr<nsPresContext> presContext;
   mDocShell->GetPresContext(getter_AddRefs(presContext));
   if (!presContext)
     return px;
 
   return presContext->DevPixelsToIntCSSPixels(px);
 }
 
 int32_t
-nsGlobalWindow::CSSToDevIntPixels(int32_t px)
+nsGlobalWindowInner::CSSToDevIntPixels(int32_t px)
 {
   if (!mDocShell)
     return px; // assume 1:1
 
   RefPtr<nsPresContext> presContext;
   mDocShell->GetPresContext(getter_AddRefs(presContext));
   if (!presContext)
     return px;
 
   return presContext->CSSPixelsToDevPixels(px);
 }
 
 nsIntSize
-nsGlobalWindow::DevToCSSIntPixels(nsIntSize px)
+nsGlobalWindowInner::DevToCSSIntPixels(nsIntSize px)
 {
   if (!mDocShell)
     return px; // assume 1:1
 
   RefPtr<nsPresContext> presContext;
   mDocShell->GetPresContext(getter_AddRefs(presContext));
   if (!presContext)
     return px;
 
   return nsIntSize(
       presContext->DevPixelsToIntCSSPixels(px.width),
       presContext->DevPixelsToIntCSSPixels(px.height));
 }
 
 nsIntSize
-nsGlobalWindow::CSSToDevIntPixels(nsIntSize px)
+nsGlobalWindowInner::CSSToDevIntPixels(nsIntSize px)
 {
   if (!mDocShell)
     return px; // assume 1:1
 
   RefPtr<nsPresContext> presContext;
   mDocShell->GetPresContext(getter_AddRefs(presContext));
   if (!presContext)
     return px;
 
   return nsIntSize(
     presContext->CSSPixelsToDevPixels(px.width),
     presContext->CSSPixelsToDevPixels(px.height));
 }
 
 nsresult
-nsGlobalWindow::GetInnerSize(CSSIntSize& aSize)
+nsGlobalWindowInner::GetInnerSize(CSSIntSize& aSize)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   EnsureSizeAndPositionUpToDate();
 
   NS_ENSURE_STATE(mDocShell);
 
   RefPtr<nsPresContext> presContext;
@@ -5741,59 +5624,59 @@ nsGlobalWindow::GetInnerSize(CSSIntSize&
 
     aSize = CSSIntRect::FromAppUnitsRounded(
       presContext->GetVisibleArea().Size());
   }
   return NS_OK;
 }
 
 int32_t
-nsGlobalWindow::GetInnerWidthOuter(ErrorResult& aError)
+nsGlobalWindowInner::GetInnerWidthOuter(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   CSSIntSize size;
   aError = GetInnerSize(size);
   return size.width;
 }
 
 int32_t
-nsGlobalWindow::GetInnerWidth(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetInnerWidth(CallerType aCallerType, ErrorResult& aError)
 {
   // We ignore aCallerType; we only have that argument because some other things
   // called by GetReplaceableWindowCoord need it.  If this ever changes, fix
-  //   nsresult nsGlobalWindow::GetInnerWidth(int32_t* aInnerWidth)
+  //   nsresult nsGlobalWindowInner::GetInnerWidth(int32_t* aInnerWidth)
   // to actually take a useful CallerType and pass it in here.
   FORWARD_TO_OUTER_OR_THROW(GetInnerWidthOuter, (aError), aError, 0);
 }
 
 void
-nsGlobalWindow::GetInnerWidth(JSContext* aCx,
+nsGlobalWindowInner::GetInnerWidth(JSContext* aCx,
                               JS::MutableHandle<JS::Value> aValue,
                               CallerType aCallerType,
                               ErrorResult& aError)
 {
-  GetReplaceableWindowCoord(aCx, &nsGlobalWindow::GetInnerWidth, aValue,
+  GetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::GetInnerWidth, aValue,
                             aCallerType, aError);
 }
 
 nsresult
-nsGlobalWindow::GetInnerWidth(int32_t* aInnerWidth)
+nsGlobalWindowInner::GetInnerWidth(int32_t* aInnerWidth)
 {
   FORWARD_TO_INNER(GetInnerWidth, (aInnerWidth), NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   // Callee doesn't care about the caller type, but play it safe.
   *aInnerWidth = GetInnerWidth(CallerType::NonSystem, rv);
 
   return rv.StealNSResult();
 }
 
 void
-nsGlobalWindow::SetInnerWidthOuter(int32_t aInnerWidth,
+nsGlobalWindowInner::SetInnerWidthOuter(int32_t aInnerWidth,
                                    CallerType aCallerType,
                                    ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     aError.Throw(NS_ERROR_UNEXPECTED);
     return;
@@ -5821,76 +5704,76 @@ nsGlobalWindow::SetInnerWidthOuter(int32
   int32_t unused  = 0;
 
   nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
   docShellAsWin->GetSize(&unused, &height);
   aError = SetDocShellWidthAndHeight(CSSToDevIntPixels(aInnerWidth), height);
 }
 
 void
-nsGlobalWindow::SetInnerWidth(int32_t aInnerWidth, CallerType aCallerType,
+nsGlobalWindowInner::SetInnerWidth(int32_t aInnerWidth, CallerType aCallerType,
                               ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetInnerWidthOuter,
                             (aInnerWidth, aCallerType, aError), aError, );
 }
 
 void
-nsGlobalWindow::SetInnerWidth(JSContext* aCx, JS::Handle<JS::Value> aValue,
+nsGlobalWindowInner::SetInnerWidth(JSContext* aCx, JS::Handle<JS::Value> aValue,
                               CallerType aCallerType,
                               ErrorResult& aError)
 {
-  SetReplaceableWindowCoord(aCx, &nsGlobalWindow::SetInnerWidth,
+  SetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::SetInnerWidth,
                             aValue, "innerWidth", aCallerType, aError);
 }
 
 int32_t
-nsGlobalWindow::GetInnerHeightOuter(ErrorResult& aError)
+nsGlobalWindowInner::GetInnerHeightOuter(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   CSSIntSize size;
   aError = GetInnerSize(size);
   return size.height;
 }
 
 int32_t
-nsGlobalWindow::GetInnerHeight(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetInnerHeight(CallerType aCallerType, ErrorResult& aError)
 {
   // We ignore aCallerType; we only have that argument because some other things
   // called by GetReplaceableWindowCoord need it.  If this ever changes, fix
-  //   nsresult nsGlobalWindow::GetInnerHeight(int32_t* aInnerWidth)
+  //   nsresult nsGlobalWindowInner::GetInnerHeight(int32_t* aInnerWidth)
   // to actually take a useful CallerType and pass it in here.
   FORWARD_TO_OUTER_OR_THROW(GetInnerHeightOuter, (aError), aError, 0);
 }
 
 void
-nsGlobalWindow::GetInnerHeight(JSContext* aCx,
+nsGlobalWindowInner::GetInnerHeight(JSContext* aCx,
                               JS::MutableHandle<JS::Value> aValue,
                               CallerType aCallerType,
                               ErrorResult& aError)
 {
-  GetReplaceableWindowCoord(aCx, &nsGlobalWindow::GetInnerHeight, aValue,
+  GetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::GetInnerHeight, aValue,
                             aCallerType, aError);
 }
 
 nsresult
-nsGlobalWindow::GetInnerHeight(int32_t* aInnerHeight)
+nsGlobalWindowInner::GetInnerHeight(int32_t* aInnerHeight)
 {
   FORWARD_TO_INNER(GetInnerHeight, (aInnerHeight), NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   // Callee doesn't care about the caller type, but play it safe.
   *aInnerHeight = GetInnerHeight(CallerType::NonSystem, rv);
 
   return rv.StealNSResult();
 }
 
 void
-nsGlobalWindow::SetInnerHeightOuter(int32_t aInnerHeight,
+nsGlobalWindowInner::SetInnerHeightOuter(int32_t aInnerHeight,
                                     CallerType aCallerType,
                                     ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     aError.Throw(NS_ERROR_UNEXPECTED);
     return;
@@ -5917,34 +5800,34 @@ nsGlobalWindow::SetInnerHeightOuter(int3
 
   nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
   docShellAsWin->GetSize(&width, &height);
   CheckSecurityWidthAndHeight(nullptr, &aInnerHeight, aCallerType);
   aError = SetDocShellWidthAndHeight(width, CSSToDevIntPixels(aInnerHeight));
 }
 
 void
-nsGlobalWindow::SetInnerHeight(int32_t aInnerHeight,
+nsGlobalWindowInner::SetInnerHeight(int32_t aInnerHeight,
                                CallerType aCallerType,
                                ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetInnerHeightOuter,
                             (aInnerHeight, aCallerType, aError), aError, );
 }
 
 void
-nsGlobalWindow::SetInnerHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
+nsGlobalWindowInner::SetInnerHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
                                CallerType aCallerType, ErrorResult& aError)
 {
-  SetReplaceableWindowCoord(aCx, &nsGlobalWindow::SetInnerHeight,
+  SetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::SetInnerHeight,
                             aValue, "innerHeight", aCallerType, aError);
 }
 
 nsIntSize
-nsGlobalWindow::GetOuterSize(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetOuterSize(CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (nsContentUtils::ResistFingerprinting(aCallerType)) {
     CSSIntSize size;
     aError = GetInnerSize(size);
     return nsIntSize(size.width, size.height);
   }
@@ -5960,65 +5843,65 @@ nsGlobalWindow::GetOuterSize(CallerType 
   if (aError.Failed()) {
     return nsIntSize();
   }
 
   return DevToCSSIntPixels(sizeDevPixels);
 }
 
 int32_t
-nsGlobalWindow::GetOuterWidthOuter(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetOuterWidthOuter(CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   return GetOuterSize(aCallerType, aError).width;
 }
 
 int32_t
-nsGlobalWindow::GetOuterWidth(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetOuterWidth(CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetOuterWidthOuter, (aCallerType, aError),
                             aError, 0);
 }
 
 void
-nsGlobalWindow::GetOuterWidth(JSContext* aCx,
+nsGlobalWindowInner::GetOuterWidth(JSContext* aCx,
                               JS::MutableHandle<JS::Value> aValue,
                               CallerType aCallerType,
                               ErrorResult& aError)
 {
-  GetReplaceableWindowCoord(aCx, &nsGlobalWindow::GetOuterWidth, aValue,
+  GetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::GetOuterWidth, aValue,
                             aCallerType, aError);
 }
 
 int32_t
-nsGlobalWindow::GetOuterHeightOuter(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetOuterHeightOuter(CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   return GetOuterSize(aCallerType, aError).height;
 }
 
 int32_t
-nsGlobalWindow::GetOuterHeight(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetOuterHeight(CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetOuterHeightOuter, (aCallerType, aError),
                             aError, 0);
 }
 
 void
-nsGlobalWindow::GetOuterHeight(JSContext* aCx,
+nsGlobalWindowInner::GetOuterHeight(JSContext* aCx,
                                JS::MutableHandle<JS::Value> aValue,
                                CallerType aCallerType,
                                ErrorResult& aError)
 {
-  GetReplaceableWindowCoord(aCx, &nsGlobalWindow::GetOuterHeight, aValue,
+  GetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::GetOuterHeight, aValue,
                             aCallerType, aError);
 }
 
 void
-nsGlobalWindow::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
+nsGlobalWindowInner::SetOuterSize(int32_t aLengthCSSPixels, bool aIsWidth,
                              CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
   if (!treeOwnerAsWin) {
     aError.Throw(NS_ERROR_FAILURE);
     return;
@@ -6041,73 +5924,73 @@ nsGlobalWindow::SetOuterSize(int32_t aLe
     height = lengthDevPixels;
   }
   aError = treeOwnerAsWin->SetSize(width, height, true);
 
   CheckForDPIChange();
 }
 
 void
-nsGlobalWindow::SetOuterWidthOuter(int32_t aOuterWidth,
+nsGlobalWindowInner::SetOuterWidthOuter(int32_t aOuterWidth,
                                    CallerType aCallerType,
                                    ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   SetOuterSize(aOuterWidth, true, aCallerType, aError);
 }
 
 void
-nsGlobalWindow::SetOuterWidth(int32_t aOuterWidth,
+nsGlobalWindowInner::SetOuterWidth(int32_t aOuterWidth,
                               CallerType aCallerType,
                               ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetOuterWidthOuter,
                             (aOuterWidth, aCallerType, aError), aError, );
 }
 
 void
-nsGlobalWindow::SetOuterWidth(JSContext* aCx, JS::Handle<JS::Value> aValue,
+nsGlobalWindowInner::SetOuterWidth(JSContext* aCx, JS::Handle<JS::Value> aValue,
                               CallerType aCallerType,
                               ErrorResult& aError)
 {
-  SetReplaceableWindowCoord(aCx, &nsGlobalWindow::SetOuterWidth,
+  SetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::SetOuterWidth,
                             aValue, "outerWidth", aCallerType, aError);
 }
 
 void
-nsGlobalWindow::SetOuterHeightOuter(int32_t aOuterHeight,
+nsGlobalWindowInner::SetOuterHeightOuter(int32_t aOuterHeight,
                                     CallerType aCallerType,
                                     ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   SetOuterSize(aOuterHeight, false, aCallerType, aError);
 }
 
 void
-nsGlobalWindow::SetOuterHeight(int32_t aOuterHeight,
+nsGlobalWindowInner::SetOuterHeight(int32_t aOuterHeight,
                                CallerType aCallerType,
                                ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetOuterHeightOuter,
                             (aOuterHeight, aCallerType, aError), aError, );
 }
 
 void
-nsGlobalWindow::SetOuterHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
+nsGlobalWindowInner::SetOuterHeight(JSContext* aCx, JS::Handle<JS::Value> aValue,
                                CallerType aCallerType,
                                ErrorResult& aError)
 {
-  SetReplaceableWindowCoord(aCx, &nsGlobalWindow::SetOuterHeight,
+  SetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::SetOuterHeight,
                             aValue, "outerHeight", aCallerType, aError);
 }
 
 CSSIntPoint
-nsGlobalWindow::GetScreenXY(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetScreenXY(CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // When resisting fingerprinting, always return (0,0)
   if (nsContentUtils::ResistFingerprinting(aCallerType)) {
     return CSSIntPoint(0, 0);
   }
 
@@ -6145,41 +6028,41 @@ nsGlobalWindow::GetScreenXY(CallerType a
     presContext->CSSToDevPixelScale();
   cssPt.x += screenRectDesk.x;
   cssPt.y += screenRectDesk.y;
 
   return CSSIntPoint(NSToIntRound(cssPt.x), NSToIntRound(cssPt.y));
 }
 
 int32_t
-nsGlobalWindow::GetScreenXOuter(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetScreenXOuter(CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   return GetScreenXY(aCallerType, aError).x;
 }
 
 int32_t
-nsGlobalWindow::GetScreenX(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetScreenX(CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetScreenXOuter, (aCallerType, aError), aError, 0);
 }
 
 void
-nsGlobalWindow::GetScreenX(JSContext* aCx,
+nsGlobalWindowInner::GetScreenX(JSContext* aCx,
                            JS::MutableHandle<JS::Value> aValue,
                            CallerType aCallerType,
                            ErrorResult& aError)
 {
-  GetReplaceableWindowCoord(aCx, &nsGlobalWindow::GetScreenX, aValue,
+  GetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::GetScreenX, aValue,
                             aCallerType, aError);
 }
 
 nsRect
-nsGlobalWindow::GetInnerScreenRect()
+nsGlobalWindowInner::GetInnerScreenRect()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return nsRect();
   }
 
   EnsureSizeAndPositionUpToDate();
@@ -6196,57 +6079,57 @@ nsGlobalWindow::GetInnerScreenRect()
   if (!rootFrame) {
     return nsRect();
   }
 
   return rootFrame->GetScreenRectInAppUnits();
 }
 
 float
-nsGlobalWindow::GetMozInnerScreenXOuter(CallerType aCallerType)
+nsGlobalWindowInner::GetMozInnerScreenXOuter(CallerType aCallerType)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   // When resisting fingerprinting, always return 0.
   if (nsContentUtils::ResistFingerprinting(aCallerType)) {
     return 0.0;
   }
 
   nsRect r = GetInnerScreenRect();
   return nsPresContext::AppUnitsToFloatCSSPixels(r.x);
 }
 
 float
-nsGlobalWindow::GetMozInnerScreenX(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetMozInnerScreenX(CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetMozInnerScreenXOuter, (aCallerType), aError, 0);
 }
 
 float
-nsGlobalWindow::GetMozInnerScreenYOuter(CallerType aCallerType)
+nsGlobalWindowInner::GetMozInnerScreenYOuter(CallerType aCallerType)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   // Return 0 to prevent fingerprinting.
   if (nsContentUtils::ResistFingerprinting(aCallerType)) {
     return 0.0;
   }
 
   nsRect r = GetInnerScreenRect();
   return nsPresContext::AppUnitsToFloatCSSPixels(r.y);
 }
 
 float
-nsGlobalWindow::GetMozInnerScreenY(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetMozInnerScreenY(CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetMozInnerScreenYOuter, (aCallerType), aError, 0);
 }
 
 double
-nsGlobalWindow::GetDevicePixelRatioOuter(CallerType aCallerType)
+nsGlobalWindowInner::GetDevicePixelRatioOuter(CallerType aCallerType)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return 1.0;
   }
 
   RefPtr<nsPresContext> presContext;
@@ -6265,48 +6148,48 @@ nsGlobalWindow::GetDevicePixelRatioOuter
     return overrideDPPX;
   }
 
   return double(nsPresContext::AppUnitsPerCSSPixel()) /
          double(presContext->AppUnitsPerDevPixel());
 }
 
 double
-nsGlobalWindow::GetDevicePixelRatio(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetDevicePixelRatio(CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetDevicePixelRatioOuter, (aCallerType), aError, 0.0);
 }
 
 float
 nsPIDOMWindowOuter::GetDevicePixelRatio(CallerType aCallerType)
 {
   return nsGlobalWindowOuter::Cast(this)->GetDevicePixelRatioOuter(aCallerType);
 }
 
 uint64_t
-nsGlobalWindow::GetMozPaintCountOuter()
+nsGlobalWindowInner::GetMozPaintCountOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return 0;
   }
 
   nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
   return presShell ? presShell->GetPaintCount() : 0;
 }
 
 uint64_t
-nsGlobalWindow::GetMozPaintCount(ErrorResult& aError)
+nsGlobalWindowInner::GetMozPaintCount(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetMozPaintCountOuter, (), aError, 0);
 }
 
 int32_t
-nsGlobalWindow::RequestAnimationFrame(FrameRequestCallback& aCallback,
+nsGlobalWindowInner::RequestAnimationFrame(FrameRequestCallback& aCallback,
                                       ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mDoc) {
     return 0;
   }
 
@@ -6315,54 +6198,54 @@ nsGlobalWindow::RequestAnimationFrame(Fr
   }
 
   int32_t handle;
   aError = mDoc->ScheduleFrameRequestCallback(aCallback, &handle);
   return handle;
 }
 
 void
-nsGlobalWindow::CancelAnimationFrame(int32_t aHandle, ErrorResult& aError)
+nsGlobalWindowInner::CancelAnimationFrame(int32_t aHandle, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mDoc) {
     return;
   }
 
   mDoc->CancelFrameRequestCallback(aHandle);
 }
 
 already_AddRefed<MediaQueryList>
-nsGlobalWindow::MatchMediaOuter(const nsAString& aMediaQueryList,
+nsGlobalWindowInner::MatchMediaOuter(const nsAString& aMediaQueryList,
                                 CallerType aCallerType)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDoc) {
     return nullptr;
   }
 
   return mDoc->MatchMedia(aMediaQueryList, aCallerType);
 }
 
 already_AddRefed<MediaQueryList>
-nsGlobalWindow::MatchMedia(const nsAString& aMediaQueryList,
+nsGlobalWindowInner::MatchMedia(const nsAString& aMediaQueryList,
                            CallerType aCallerType,
                            ErrorResult& aError)
 {
   // FIXME: This whole forward-to-outer and then get a pres
   // shell/context off the docshell dance is sort of silly; it'd make
   // more sense to forward to the inner, but it's what everyone else
   // (GetSelection, GetScrollXY, etc.) does around here.
   FORWARD_TO_OUTER_OR_THROW(MatchMediaOuter, (aMediaQueryList, aCallerType), aError, nullptr);
 }
 
 void
-nsGlobalWindow::SetScreenXOuter(int32_t aScreenX,
+nsGlobalWindowInner::SetScreenXOuter(int32_t aScreenX,
                                 CallerType aCallerType,
                                 ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
   if (!treeOwnerAsWin) {
     aError.Throw(NS_ERROR_FAILURE);
@@ -6379,57 +6262,57 @@ nsGlobalWindow::SetScreenXOuter(int32_t 
   x = CSSToDevIntPixels(aScreenX);
 
   aError = treeOwnerAsWin->SetPosition(x, y);
 
   CheckForDPIChange();
 }
 
 void
-nsGlobalWindow::SetScreenX(int32_t aScreenX,
+nsGlobalWindowInner::SetScreenX(int32_t aScreenX,
                            CallerType aCallerType,
                            ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetScreenXOuter,
                             (aScreenX, aCallerType, aError), aError, );
 }
 
 void
-nsGlobalWindow::SetScreenX(JSContext* aCx, JS::Handle<JS::Value> aValue,
+nsGlobalWindowInner::SetScreenX(JSContext* aCx, JS::Handle<JS::Value> aValue,
                            CallerType aCallerType, ErrorResult& aError)
 {
-  SetReplaceableWindowCoord(aCx, &nsGlobalWindow::SetScreenX,
+  SetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::SetScreenX,
                             aValue, "screenX", aCallerType, aError);
 }
 
 int32_t
-nsGlobalWindow::GetScreenYOuter(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetScreenYOuter(CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   return GetScreenXY(aCallerType, aError).y;
 }
 
 int32_t
-nsGlobalWindow::GetScreenY(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::GetScreenY(CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetScreenYOuter, (aCallerType, aError), aError, 0);
 }
 
 void
-nsGlobalWindow::GetScreenY(JSContext* aCx,
+nsGlobalWindowInner::GetScreenY(JSContext* aCx,
                            JS::MutableHandle<JS::Value> aValue,
                            CallerType aCallerType, ErrorResult& aError)
 {
-  GetReplaceableWindowCoord(aCx, &nsGlobalWindow::GetScreenY, aValue,
+  GetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::GetScreenY, aValue,
                             aCallerType, aError);
 }
 
 void
-nsGlobalWindow::SetScreenYOuter(int32_t aScreenY,
+nsGlobalWindowInner::SetScreenYOuter(int32_t aScreenY,
                                 CallerType aCallerType,
                                 ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
   if (!treeOwnerAsWin) {
     aError.Throw(NS_ERROR_FAILURE);
@@ -6446,37 +6329,37 @@ nsGlobalWindow::SetScreenYOuter(int32_t 
   y = CSSToDevIntPixels(aScreenY);
 
   aError = treeOwnerAsWin->SetPosition(x, y);
 
   CheckForDPIChange();
 }
 
 void
-nsGlobalWindow::SetScreenY(int32_t aScreenY,
+nsGlobalWindowInner::SetScreenY(int32_t aScreenY,
                            CallerType aCallerType,
                            ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetScreenYOuter,
                             (aScreenY, aCallerType, aError), aError, );
 }
 
 void
-nsGlobalWindow::SetScreenY(JSContext* aCx, JS::Handle<JS::Value> aValue,
+nsGlobalWindowInner::SetScreenY(JSContext* aCx, JS::Handle<JS::Value> aValue,
                            CallerType aCallerType,
                            ErrorResult& aError)
 {
-  SetReplaceableWindowCoord(aCx, &nsGlobalWindow::SetScreenY,
+  SetReplaceableWindowCoord(aCx, &nsGlobalWindowInner::SetScreenY,
                             aValue, "screenY", aCallerType, aError);
 }
 
 // NOTE: Arguments to this function should have values scaled to
 // CSS pixels, not device pixels.
 void
-nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight,
+nsGlobalWindowInner::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight,
                                             CallerType aCallerType)
 {
   MOZ_ASSERT(IsOuterWindow());
 
 #ifdef MOZ_XUL
   if (aCallerType != CallerType::System) {
     // if attempting to resize the window, hide any open popups
     nsContentUtils::HidePopupsInDocument(mDoc);
@@ -6496,17 +6379,17 @@ nsGlobalWindow::CheckSecurityWidthAndHei
         *aHeight = 100;
       }
     }
   }
 }
 
 // NOTE: Arguments to this function should have values in device pixels
 nsresult
-nsGlobalWindow::SetDocShellWidthAndHeight(int32_t aInnerWidth, int32_t aInnerHeight)
+nsGlobalWindowInner::SetDocShellWidthAndHeight(int32_t aInnerWidth, int32_t aInnerHeight)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
   mDocShell->GetTreeOwner(getter_AddRefs(treeOwner));
   NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
@@ -6514,34 +6397,34 @@ nsGlobalWindow::SetDocShellWidthAndHeigh
   NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(mDocShell, aInnerWidth, aInnerHeight),
                     NS_ERROR_FAILURE);
 
   return NS_OK;
 }
 
 // NOTE: Arguments to this function should have values in app units
 void
-nsGlobalWindow::SetCSSViewportWidthAndHeight(nscoord aInnerWidth, nscoord aInnerHeight)
+nsGlobalWindowInner::SetCSSViewportWidthAndHeight(nscoord aInnerWidth, nscoord aInnerHeight)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   RefPtr<nsPresContext> presContext;
   mDocShell->GetPresContext(getter_AddRefs(presContext));
 
   nsRect shellArea = presContext->GetVisibleArea();
   shellArea.SetHeight(aInnerHeight);
   shellArea.SetWidth(aInnerWidth);
 
   presContext->SetVisibleArea(shellArea);
 }
 
 // NOTE: Arguments to this function should have values scaled to
 // CSS pixels, not device pixels.
 void
-nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop,
+nsGlobalWindowInner::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop,
                                         CallerType aCallerType)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // This one is harder. We have to get the screen size and window dimensions.
 
   // Check security state for use in determing window dimensions
 
@@ -6608,58 +6491,58 @@ nsGlobalWindow::CheckSecurityLeftAndTop(
         *aLeft = 0;
       if (aTop)
         *aTop = 0;
     }
   }
 }
 
 int32_t
-nsGlobalWindow::GetScrollBoundaryOuter(Side aSide)
+nsGlobalWindowInner::GetScrollBoundaryOuter(Side aSide)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   FlushPendingNotifications(FlushType::Layout);
   if (nsIScrollableFrame *sf = GetScrollFrame()) {
     return nsPresContext::
       AppUnitsToIntCSSPixels(sf->GetScrollRange().Edge(aSide));
   }
   return 0;
 }
 
 int32_t
-nsGlobalWindow::GetScrollMinX(ErrorResult& aError)
+nsGlobalWindowInner::GetScrollMinX(ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   FORWARD_TO_OUTER_OR_THROW(GetScrollBoundaryOuter, (eSideLeft), aError, 0);
 }
 
 int32_t
-nsGlobalWindow::GetScrollMinY(ErrorResult& aError)
+nsGlobalWindowInner::GetScrollMinY(ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   FORWARD_TO_OUTER_OR_THROW(GetScrollBoundaryOuter, (eSideTop), aError, 0);
 }
 
 int32_t
-nsGlobalWindow::GetScrollMaxX(ErrorResult& aError)
+nsGlobalWindowInner::GetScrollMaxX(ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   FORWARD_TO_OUTER_OR_THROW(GetScrollBoundaryOuter, (eSideRight), aError, 0);
 }
 
 int32_t
-nsGlobalWindow::GetScrollMaxY(ErrorResult& aError)
+nsGlobalWindowInner::GetScrollMaxY(ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   FORWARD_TO_OUTER_OR_THROW(GetScrollBoundaryOuter, (eSideBottom), aError, 0);
 }
 
 CSSPoint
-nsGlobalWindow::GetScrollXY(bool aDoFlush)
+nsGlobalWindowInner::GetScrollXY(bool aDoFlush)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (aDoFlush) {
     FlushPendingNotifications(FlushType::Layout);
   } else {
     EnsureSizeAndPositionUpToDate();
   }
@@ -6676,93 +6559,93 @@ nsGlobalWindow::GetScrollXY(bool aDoFlus
     // may get shorter and hence our scroll position may decrease.
     return GetScrollXY(true);
   }
 
   return CSSPoint::FromAppUnits(scrollPos);
 }
 
 double
-nsGlobalWindow::GetScrollXOuter()
+nsGlobalWindowInner::GetScrollXOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   return GetScrollXY(false).x;
 }
 
 double
-nsGlobalWindow::GetScrollX(ErrorResult& aError)
+nsGlobalWindowInner::GetScrollX(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetScrollXOuter, (), aError, 0);
 }
 
 double
-nsGlobalWindow::GetScrollYOuter()
+nsGlobalWindowInner::GetScrollYOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   return GetScrollXY(false).y;
 }
 
 double
-nsGlobalWindow::GetScrollY(ErrorResult& aError)
+nsGlobalWindowInner::GetScrollY(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetScrollYOuter, (), aError, 0);
 }
 
 uint32_t
-nsGlobalWindow::Length()
+nsGlobalWindowInner::Length()
 {
   FORWARD_TO_OUTER(Length, (), 0);
 
   nsDOMWindowList* windows = GetWindowList();
 
   return windows ? windows->GetLength() : 0;
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetTopOuter()
+nsGlobalWindowInner::GetTopOuter()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsPIDOMWindowOuter> top = GetScriptableTop();
   return top.forget();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetTop(mozilla::ErrorResult& aError)
+nsGlobalWindowInner::GetTop(mozilla::ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetTopOuter, (), aError, nullptr);
 }
 
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetChildWindow(const nsAString& aName)
+nsGlobalWindowInner::GetChildWindow(const nsAString& aName)
 {
   nsCOMPtr<nsIDocShell> docShell(GetDocShell());
   NS_ENSURE_TRUE(docShell, nullptr);
 
   nsCOMPtr<nsIDocShellTreeItem> child;
   docShell->FindChildWithName(aName, false, true, nullptr, nullptr,
                               getter_AddRefs(child));
 
   return child ? child->GetWindow() : nullptr;
 }
 
 bool
-nsGlobalWindow::DispatchCustomEvent(const nsAString& aEventName)
+nsGlobalWindowInner::DispatchCustomEvent(const nsAString& aEventName)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   bool defaultActionEnabled = true;
   nsContentUtils::DispatchTrustedEvent(mDoc, ToSupports(this), aEventName,
                                        true, true, &defaultActionEnabled);
 
   return defaultActionEnabled;
 }
 
 bool
-nsGlobalWindow::DispatchResizeEvent(const CSSIntSize& aSize)
+nsGlobalWindowInner::DispatchResizeEvent(const CSSIntSize& aSize)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   ErrorResult res;
   RefPtr<Event> domEvent =
     mDoc->CreateEvent(NS_LITERAL_STRING("CustomEvent"), CallerType::System,
                       res);
   if (res.Failed()) {
@@ -6803,17 +6686,17 @@ nsGlobalWindow::DispatchResizeEvent(cons
 
   bool defaultActionEnabled = true;
   target->DispatchEvent(domEvent, &defaultActionEnabled);
 
   return defaultActionEnabled;
 }
 
 void
-nsGlobalWindow::RefreshCompartmentPrincipal()
+nsGlobalWindowInner::RefreshCompartmentPrincipal()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   JS_SetCompartmentPrincipals(js::GetObjectCompartment(GetWrapperPreserveColor()),
                               nsJSPrincipals::get(mDoc->NodePrincipal()));
 }
 
 static already_AddRefed<nsIDocShellTreeItem>
@@ -6821,17 +6704,17 @@ GetCallerDocShellTreeItem()
 {
   nsCOMPtr<nsIWebNavigation> callerWebNav = do_GetInterface(GetEntryGlobal());
   nsCOMPtr<nsIDocShellTreeItem> callerItem = do_QueryInterface(callerWebNav);
 
   return callerItem.forget();
 }
 
 bool
-nsGlobalWindow::WindowExists(const nsAString& aName,
+nsGlobalWindowInner::WindowExists(const nsAString& aName,
                              bool aForceNoOpener,
                              bool aLookForCallerOnJSStack)
 {
   NS_PRECONDITION(IsOuterWindow(), "Must be outer window");
   NS_PRECONDITION(mDocShell, "Must have docshell");
 
   if (aForceNoOpener) {
     return aName.LowerCaseEqualsLiteral("_self") ||
@@ -6851,59 +6734,59 @@ nsGlobalWindow::WindowExists(const nsASt
   nsCOMPtr<nsIDocShellTreeItem> namedItem;
   mDocShell->FindItemWithName(aName, nullptr, caller,
                               /* aSkipTabGroup = */ false,
                               getter_AddRefs(namedItem));
   return namedItem != nullptr;
 }
 
 already_AddRefed<nsIWidget>
-nsGlobalWindow::GetMainWidget()
+nsGlobalWindowInner::GetMainWidget()
 {
   FORWARD_TO_OUTER(GetMainWidget, (), nullptr);
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
 
   nsCOMPtr<nsIWidget> widget;
 
   if (treeOwnerAsWin) {
     treeOwnerAsWin->GetMainWidget(getter_AddRefs(widget));
   }
 
   return widget.forget();
 }
 
 nsIWidget*
-nsGlobalWindow::GetNearestWidget() const
+nsGlobalWindowInner::GetNearestWidget() const
 {
   nsIDocShell* docShell = GetDocShell();
   NS_ENSURE_TRUE(docShell, nullptr);
   nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
   NS_ENSURE_TRUE(presShell, nullptr);
   nsIFrame* rootFrame = presShell->GetRootFrame();
   NS_ENSURE_TRUE(rootFrame, nullptr);
   return rootFrame->GetView()->GetNearestWidget(nullptr);
 }
 
 void
-nsGlobalWindow::SetFullScreenOuter(bool aFullScreen, mozilla::ErrorResult& aError)
+nsGlobalWindowInner::SetFullScreenOuter(bool aFullScreen, mozilla::ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   aError = SetFullscreenInternal(FullscreenReason::ForFullscreenMode, aFullScreen);
 }
 
 void
-nsGlobalWindow::SetFullScreen(bool aFullScreen, mozilla::ErrorResult& aError)
+nsGlobalWindowInner::SetFullScreen(bool aFullScreen, mozilla::ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetFullScreenOuter, (aFullScreen, aError), aError, /* void */);
 }
 
 nsresult
-nsGlobalWindow::SetFullScreen(bool aFullScreen)
+nsGlobalWindowInner::SetFullScreen(bool aFullScreen)
 {
   FORWARD_TO_OUTER(SetFullScreen, (aFullScreen), NS_ERROR_NOT_INITIALIZED);
 
   return SetFullscreenInternal(FullscreenReason::ForFullscreenMode, aFullScreen);
 }
 
 static void
 FinishDOMFullscreenChange(nsIDocument* aDoc, bool aInDOMFullscreen)
@@ -7177,17 +7060,17 @@ MakeWidgetFullscreen(nsGlobalWindowOuter
   nsCOMPtr<nsIRunnable> task =
     new FullscreenTransitionTask(duration, aWindow, aFullscreen,
                                  widget, nullptr, transitionData);
   task->Run();
   return true;
 }
 
 nsresult
-nsGlobalWindow::SetFullscreenInternal(FullscreenReason aReason,
+nsGlobalWindowInner::SetFullscreenInternal(FullscreenReason aReason,
                                       bool aFullScreen)
 {
   MOZ_ASSERT(IsOuterWindow());
   MOZ_ASSERT(nsContentUtils::IsSafeToRunScript(),
              "Requires safe to run script as it "
              "may call FinishDOMFullscreenChange");
 
   NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
@@ -7259,68 +7142,47 @@ nsGlobalWindow::SetFullscreenInternal(Fu
   mFullScreen = aFullScreen;
 
   // Sometimes we don't want the top-level widget to actually go fullscreen,
   // for example in the B2G desktop client, we don't want the emulated screen
   // dimensions to appear to increase when entering fullscreen mode; we just
   // want the content to fill the entire client area of the emulator window.
   if (!Preferences::GetBool("full-screen-api.ignore-widgets", false)) {
     if (MakeWidgetFullscreen(AssertOuter(), aReason, aFullScreen)) {
-      // The rest of code for switching fullscreen is in nsGlobalWindow::
+      // The rest of code for switching fullscreen is in nsGlobalWindowInner::
       // FinishFullscreenChange() which will be called after sizemodechange
       // event is dispatched.
       return NS_OK;
     }
   }
 
   FinishFullscreenChange(aFullScreen);
   return NS_OK;
 }
 
 bool
-nsGlobalWindow::SetWidgetFullscreen(FullscreenReason aReason, bool aIsFullscreen,
+nsGlobalWindowInner::SetWidgetFullscreen(FullscreenReason aReason, bool aIsFullscreen,
                                     nsIWidget* aWidget, nsIScreen* aScreen)
 {
-  MOZ_ASSERT(IsOuterWindow());
-  MOZ_ASSERT(this == GetTopInternal(), "Only topmost window should call this");
-  MOZ_ASSERT(!AsOuter()->GetFrameElementInternal(), "Content window should not call this");
-  MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
-
-  if (!NS_WARN_IF(!IsChromeWindow())) {
-    if (!NS_WARN_IF(mChromeFields.mFullscreenPresShell)) {
-      if (nsIPresShell* shell = mDocShell->GetPresShell()) {
-        if (nsRefreshDriver* rd = shell->GetRefreshDriver()) {
-          mChromeFields.mFullscreenPresShell = do_GetWeakReference(shell);
-          MOZ_ASSERT(mChromeFields.mFullscreenPresShell);
-          rd->SetIsResizeSuppressed();
-          rd->Freeze();
-        }
-      }
-    }
-  }
-  nsresult rv = aReason == FullscreenReason::ForFullscreenMode ?
-    // If we enter fullscreen for fullscreen mode, we want
-    // the native system behavior.
-    aWidget->MakeFullScreenWithNativeTransition(aIsFullscreen, aScreen) :
-    aWidget->MakeFullScreen(aIsFullscreen, aScreen);
-  return NS_SUCCEEDED(rv);
-}
+  MOZ_CRASH("Only callable on the outer window");
+}
+
 
 /* virtual */ void
-nsGlobalWindow::FullscreenWillChange(bool aIsFullscreen)
+nsGlobalWindowInner::FullscreenWillChange(bool aIsFullscreen)
 {
   if (aIsFullscreen) {
     DispatchCustomEvent(NS_LITERAL_STRING("willenterfullscreen"));
   } else {
     DispatchCustomEvent(NS_LITERAL_STRING("willexitfullscreen"));
   }
 }
 
 /* virtual */ void
-nsGlobalWindow::FinishFullscreenChange(bool aIsFullscreen)
+nsGlobalWindowInner::FinishFullscreenChange(bool aIsFullscreen)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (aIsFullscreen != mFullScreen) {
     NS_WARNING("Failed to toggle fullscreen state of the widget");
     // We failed to make the widget enter fullscreen.
     // Stop further changes and restore the state.
     if (!aIsFullscreen) {
@@ -7373,17 +7235,17 @@ nsGlobalWindow::FinishFullscreenChange(b
     ErrorResult rv;
     mWakeLock->Unlock(rv);
     mWakeLock = nullptr;
     rv.SuppressException();
   }
 }
 
 bool
-nsGlobalWindow::FullScreen() const
+nsGlobalWindowInner::FullScreen() const
 {
   MOZ_ASSERT(IsOuterWindow());
 
   NS_ENSURE_TRUE(mDocShell, mFullScreen);
 
   // Get the fullscreen value of the root window, to always have the value
   // accurate, even when called from content.
   nsCOMPtr<nsIDocShellTreeItem> rootItem;
@@ -7403,41 +7265,41 @@ nsGlobalWindow::FullScreen() const
 
   nsCOMPtr<nsPIDOMWindowOuter> window = rootItem->GetWindow();
   NS_ENSURE_TRUE(window, mFullScreen);
 
   return nsGlobalWindowOuter::Cast(window)->FullScreen();
 }
 
 bool
-nsGlobalWindow::GetFullScreenOuter()
+nsGlobalWindowInner::GetFullScreenOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   return FullScreen();
 }
 
 bool
-nsGlobalWindow::GetFullScreen(ErrorResult& aError)
+nsGlobalWindowInner::GetFullScreen(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetFullScreenOuter, (), aError, false);
 }
 
 bool
-nsGlobalWindow::GetFullScreen()
+nsGlobalWindowInner::GetFullScreen()
 {
   FORWARD_TO_INNER(GetFullScreen, (), false);
 
   ErrorResult dummy;
   bool fullscreen = GetFullScreen(dummy);
   dummy.SuppressException();
   return fullscreen;
 }
 
 void
-nsGlobalWindow::Dump(const nsAString& aStr)
+nsGlobalWindowInner::Dump(const nsAString& aStr)
 {
   if (!nsContentUtils::DOMWindowDumpEnabled()) {
     return;
   }
 
   char *cstr = ToNewUTF8String(aStr);
 
 #if defined(XP_MACOSX)
@@ -7461,17 +7323,17 @@ nsGlobalWindow::Dump(const nsAString& aS
     FILE *fp = gDumpFile ? gDumpFile : stdout;
     fputs(cstr, fp);
     fflush(fp);
     free(cstr);
   }
 }
 
 void
-nsGlobalWindow::EnsureReflowFlushAndPaint()
+nsGlobalWindowInner::EnsureReflowFlushAndPaint()
 {
   MOZ_ASSERT(IsOuterWindow());
   NS_ASSERTION(mDocShell, "EnsureReflowFlushAndPaint() called with no "
                "docshell!");
 
   if (!mDocShell)
     return;
 
@@ -7486,17 +7348,17 @@ nsGlobalWindow::EnsureReflowFlushAndPain
   }
 
   // Unsuppress painting.
   presShell->UnsuppressPainting();
 }
 
 // static
 void
-nsGlobalWindow::MakeScriptDialogTitle(nsAString& aOutTitle,
+nsGlobalWindowInner::MakeScriptDialogTitle(nsAString& aOutTitle,
                                       nsIPrincipal* aSubjectPrincipal)
 {
   MOZ_ASSERT(aSubjectPrincipal);
 
   aOutTitle.Truncate();
 
   // Try to get a host from the running principal -- this will do the
   // right thing for javascript: and data: documents.
@@ -7546,17 +7408,17 @@ nsGlobalWindow::MakeScriptDialogTitle(ns
   // Just in case
   if (aOutTitle.IsEmpty()) {
     NS_WARNING("could not get ScriptDlgGenericHeading string from string bundle");
     aOutTitle.AssignLiteral("[Script]");
   }
 }
 
 bool
-nsGlobalWindow::CanMoveResizeWindows(CallerType aCallerType)
+nsGlobalWindowInner::CanMoveResizeWindows(CallerType aCallerType)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // When called from chrome, we can avoid the following checks.
   if (aCallerType != CallerType::System) {
     // Don't allow scripts to move or resize windows that were not opened by a
     // script.
     if (!mHadOriginalOpener) {
@@ -7602,22 +7464,22 @@ nsGlobalWindow::CanMoveResizeWindows(Cal
       gDragServiceDisabled = true;
       ds->Suppress();
     }
   }
   return true;
 }
 
 bool
-nsGlobalWindow::AlertOrConfirm(bool aAlert,
+nsGlobalWindowInner::AlertOrConfirm(bool aAlert,
                                const nsAString& aMessage,
                                nsIPrincipal& aSubjectPrincipal,
                                ErrorResult& aError)
 {
-  // XXX This method is very similar to nsGlobalWindow::Prompt, make
+  // XXX This method is very similar to nsGlobalWindowInner::Prompt, make
   // sure any modifications here don't need to happen over there!
   MOZ_ASSERT(IsOuterWindow());
 
   if (!AreDialogsEnabled()) {
     // Just silently return.  In the case of alert(), the return value is
     // ignored.  In the case of confirm(), returning false is the same thing as
     // would happen if the user cancels.
     return false;
@@ -7681,77 +7543,77 @@ nsGlobalWindow::AlertOrConfirm(bool aAle
                prompt->Alert(title.get(), final.get()) :
                prompt->Confirm(title.get(), final.get(), &result);
   }
 
   return result;
 }
 
 void
-nsGlobalWindow::Alert(nsIPrincipal& aSubjectPrincipal,
+nsGlobalWindowInner::Alert(nsIPrincipal& aSubjectPrincipal,
                       ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   Alert(EmptyString(), aSubjectPrincipal, aError);
 }
 
 void
-nsGlobalWindow::AlertOuter(const nsAString& aMessage,
+nsGlobalWindowInner::AlertOuter(const nsAString& aMessage,
                            nsIPrincipal& aSubjectPrincipal,
                            ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   AlertOrConfirm(/* aAlert = */ true, aMessage, aSubjectPrincipal, aError);
 }
 
 void
-nsGlobalWindow::Alert(const nsAString& aMessage,
+nsGlobalWindowInner::Alert(const nsAString& aMessage,
                       nsIPrincipal& aSubjectPrincipal,
                       ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(AlertOuter, (aMessage, aSubjectPrincipal, aError),
                             aError, );
 }
 
 bool
-nsGlobalWindow::ConfirmOuter(const nsAString& aMessage,
+nsGlobalWindowInner::ConfirmOuter(const nsAString& aMessage,
                              nsIPrincipal& aSubjectPrincipal,
                              ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   return AlertOrConfirm(/* aAlert = */ false, aMessage, aSubjectPrincipal,
                         aError);
 }
 
 bool
-nsGlobalWindow::Confirm(const nsAString& aMessage,
+nsGlobalWindowInner::Confirm(const nsAString& aMessage,
                         nsIPrincipal& aSubjectPrincipal,
                         ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(ConfirmOuter, (aMessage, aSubjectPrincipal, aError),
                             aError, false);
 }
 
 already_AddRefed<Promise>
-nsGlobalWindow::Fetch(const RequestOrUSVString& aInput,
+nsGlobalWindowInner::Fetch(const RequestOrUSVString& aInput,
                       const RequestInit& aInit,
                       CallerType aCallerType, ErrorResult& aRv)
 {
   return FetchRequest(this, aInput, aInit, aCallerType, aRv);
 }
 
 void
-nsGlobalWindow::PromptOuter(const nsAString& aMessage,
+nsGlobalWindowInner::PromptOuter(const nsAString& aMessage,
                             const nsAString& aInitial,
                             nsAString& aReturn,
                             nsIPrincipal& aSubjectPrincipal,
                             ErrorResult& aError)
 {
-  // XXX This method is very similar to nsGlobalWindow::AlertOrConfirm, make
+  // XXX This method is very similar to nsGlobalWindowInner::AlertOrConfirm, make
   // sure any modifications here don't need to happen over there!
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   SetDOMStringToNull(aReturn);
 
   if (!AreDialogsEnabled()) {
     // Return null, as if the user just canceled the prompt.
     return;
@@ -7824,29 +7686,29 @@ nsGlobalWindow::PromptOuter(const nsAStr
   outValue.Adopt(inoutValue);
 
   if (ok && inoutValue) {
     aReturn.Assign(outValue);
   }
 }
 
 void
-nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
+nsGlobalWindowInner::Prompt(const nsAString& aMessage, const nsAString& aInitial,
                        nsAString& aReturn,
                        nsIPrincipal& aSubjectPrincipal,
                        ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(PromptOuter,
                             (aMessage, aInitial, aReturn, aSubjectPrincipal,
                              aError),
                             aError, );
 }
 
 void
-nsGlobalWindow::FocusOuter(ErrorResult& aError)
+nsGlobalWindowInner::FocusOuter(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   if (!fm) {
     return;
   }
 
@@ -7944,34 +7806,34 @@ nsGlobalWindow::FocusOuter(ErrorResult& 
     // if there is no parent, this must be a toplevel window, so raise the
     // window if canFocus is true. If this is a child process, the raise
     // window request will get forwarded to the parent by the puppet widget.
     aError = fm->SetActiveWindow(AsOuter());
   }
 }
 
 void
-nsGlobalWindow::Focus(ErrorResult& aError)
+nsGlobalWindowInner::Focus(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(FocusOuter, (aError), aError, );
 }
 
 nsresult
-nsGlobalWindow::Focus()
+nsGlobalWindowInner::Focus()
 {
   FORWARD_TO_INNER(Focus, (), NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   Focus(rv);
 
   return rv.StealNSResult();
 }
 
 void
-nsGlobalWindow::BlurOuter()
+nsGlobalWindowInner::BlurOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   // If dom.disable_window_flip == true, then content should not be allowed
   // to call this function (this would allow popunders, bug 369306)
   if (!CanSetProperty("dom.disable_window_flip")) {
     return;
   }
@@ -7994,63 +7856,63 @@ nsGlobalWindow::BlurOuter()
       if (content == mDoc->GetRootElement()) {
         fm->ClearFocus(AsOuter());
       }
     }
   }
 }
 
 void
-nsGlobalWindow::Blur(ErrorResult& aError)
+nsGlobalWindowInner::Blur(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(BlurOuter, (), aError, );
 }
 
 void
-nsGlobalWindow::BackOuter(ErrorResult& aError)
+nsGlobalWindowInner::BackOuter(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
   if (!webNav) {
     aError.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   aError = webNav->GoBack();
 }
 
 void
-nsGlobalWindow::Back(ErrorResult& aError)
+nsGlobalWindowInner::Back(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(BackOuter, (aError), aError, );
 }
 
 void
-nsGlobalWindow::ForwardOuter(ErrorResult& aError)
+nsGlobalWindowInner::ForwardOuter(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
   if (!webNav) {
     aError.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   aError = webNav->GoForward();
 }
 
 void
-nsGlobalWindow::Forward(ErrorResult& aError)
+nsGlobalWindowInner::Forward(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(ForwardOuter, (aError), aError, );
 }
 
 void
-nsGlobalWindow::HomeOuter(nsIPrincipal& aSubjectPrincipal, ErrorResult& aError)
+nsGlobalWindowInner::HomeOuter(nsIPrincipal& aSubjectPrincipal, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return;
   }
 
   nsAutoString homeURL;
@@ -8093,53 +7955,53 @@ nsGlobalWindow::HomeOuter(nsIPrincipal& 
                            nsIWebNavigation::LOAD_FLAGS_NONE,
                            nullptr,
                            nullptr,
                            nullptr,
                            &aSubjectPrincipal);
 }
 
 void
-nsGlobalWindow::Home(nsIPrincipal& aSubjectPrincipal, ErrorResult& aError)
+nsGlobalWindowInner::Home(nsIPrincipal& aSubjectPrincipal, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(HomeOuter, (aSubjectPrincipal, aError), aError, );
 }
 
 void
-nsGlobalWindow::StopOuter(ErrorResult& aError)
+nsGlobalWindowInner::StopOuter(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
   if (webNav) {
     aError = webNav->Stop(nsIWebNavigation::STOP_ALL);
   }
 }
 
 void
-nsGlobalWindow::Stop(ErrorResult& aError)
+nsGlobalWindowInner::Stop(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(StopOuter, (aError), aError, );
 }
 
 /* static */
 bool
-nsGlobalWindow::IsWindowPrintEnabled(JSContext*, JSObject*)
+nsGlobalWindowInner::IsWindowPrintEnabled(JSContext*, JSObject*)
 {
   static bool called = false;
   static bool printDisabled = false;
   if (!called) {
     called = true;
     Preferences::AddBoolVarCache(&printDisabled, "dom.disable_window_print");
   }
   return !printDisabled;
 }
 
 void
-nsGlobalWindow::PrintOuter(ErrorResult& aError)
+nsGlobalWindowInner::PrintOuter(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
 #ifdef NS_PRINTING
   if (!AreDialogsEnabled()) {
     // We probably want to keep throwing here; silently doing nothing is a bit
     // weird given the typical use cases of print().
     aError.Throw(NS_ERROR_NOT_AVAILABLE);
@@ -8216,23 +8078,23 @@ nsGlobalWindow::PrintOuter(ErrorResult& 
       webBrowserPrint->GetGlobalPrintSettings(getter_AddRefs(printSettings));
       webBrowserPrint->Print(printSettings, nullptr);
     }
   }
 #endif //NS_PRINTING
 }
 
 void
-nsGlobalWindow::Print(ErrorResult& aError)
+nsGlobalWindowInner::Print(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(PrintOuter, (aError), aError, );
 }
 
 void
-nsGlobalWindow::MoveToOuter(int32_t aXPos, int32_t aYPos,
+nsGlobalWindowInner::MoveToOuter(int32_t aXPos, int32_t aYPos,
                             CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent window.moveTo() by exiting early
    */
 
@@ -8281,25 +8143,25 @@ nsGlobalWindow::MoveToOuter(int32_t aXPo
     LayoutDevicePoint devPos = cssPos * CSSToLayoutDeviceScale(1.0);
     aError = treeOwnerAsWin->SetPosition(devPos.x, devPos.y);
   }
 
   CheckForDPIChange();
 }
 
 void
-nsGlobalWindow::MoveTo(int32_t aXPos, int32_t aYPos,
+nsGlobalWindowInner::MoveTo(int32_t aXPos, int32_t aYPos,
                        CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(MoveToOuter,
                             (aXPos, aYPos, aCallerType, aError), aError, );
 }
 
 void
-nsGlobalWindow::MoveByOuter(int32_t aXDif, int32_t aYDif,
+nsGlobalWindowInner::MoveByOuter(int32_t aXDif, int32_t aYDif,
                             CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   /*
    * If caller is not chrome and the user has not explicitly exempted the site,
    * prevent window.moveBy() by exiting early
    */
@@ -8335,36 +8197,36 @@ nsGlobalWindow::MoveByOuter(int32_t aXDi
   nsIntSize newDevPos(CSSToDevIntPixels(cssPos));
 
   aError = treeOwnerAsWin->SetPosition(newDevPos.width, newDevPos.height);
 
   CheckForDPIChange();
 }
 
 void
-nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif,
+nsGlobalWindowInner::MoveBy(int32_t aXDif, int32_t aYDif,
                        CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(MoveByOuter,
                             (aXDif, aYDif, aCallerType, aError), aError, );
 }
 
 nsresult
-nsGlobalWindow::MoveBy(int32_t aXDif, int32_t aYDif)
+nsGlobalWindowInner::MoveBy(int32_t aXDif, int32_t aYDif)
 {
   FORWARD_TO_OUTER(MoveBy, (aXDif, aYDif), NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   MoveByOuter(aXDif, aYDif, CallerType::System, rv);
 
   return rv.StealNSResult();
 }
 
 void
-nsGlobalWindow::ResizeToOuter(int32_t aWidth, int32_t aHeight,
+nsGlobalWindowInner::ResizeToOuter(int32_t aWidth, int32_t aHeight,
                               CallerType aCallerType,
                               ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   /*
    * If caller is a browser-element then dispatch a resize event to
    * the embedder.
@@ -8399,25 +8261,25 @@ nsGlobalWindow::ResizeToOuter(int32_t aW
   nsIntSize devSz(CSSToDevIntPixels(cssSize));
 
   aError = treeOwnerAsWin->SetSize(devSz.width, devSz.height, true);
 
   CheckForDPIChange();
 }
 
 void
-nsGlobalWindow::ResizeTo(int32_t aWidth, int32_t aHeight,
+nsGlobalWindowInner::ResizeTo(int32_t aWidth, int32_t aHeight,
                          CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(ResizeToOuter,
                             (aWidth, aHeight, aCallerType, aError), aError, );
 }
 
 void
-nsGlobalWindow::ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
+nsGlobalWindowInner::ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
                               CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   /*
    * If caller is a browser-element then dispatch a resize event to
    * parent.
    */
@@ -8472,26 +8334,26 @@ nsGlobalWindow::ResizeByOuter(int32_t aW
   nsIntSize newDevSize(CSSToDevIntPixels(cssSize));
 
   aError = treeOwnerAsWin->SetSize(newDevSize.width, newDevSize.height, true);
 
   CheckForDPIChange();
 }
 
 void
-nsGlobalWindow::ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
+nsGlobalWindowInner::ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
                          CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(ResizeByOuter,
                             (aWidthDif, aHeightDif, aCallerType, aError),
                             aError, );
 }
 
 void
-nsGlobalWindow::SizeToContentOuter(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::SizeToContentOuter(CallerType aCallerType, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return;
   }
 
   /*
@@ -8531,54 +8393,54 @@ nsGlobalWindow::SizeToContentOuter(Calle
 
   nsIntSize newDevSize(CSSToDevIntPixels(cssSize));
 
   aError = treeOwner->SizeShellTo(mDocShell, newDevSize.width,
                                   newDevSize.height);
 }
 
 void
-nsGlobalWindow::SizeToContent(CallerType aCallerType, ErrorResult& aError)
+nsGlobalWindowInner::SizeToContent(CallerType aCallerType, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SizeToContentOuter, (aCallerType, aError),
                             aError, );
 }
 
 already_AddRefed<nsPIWindowRoot>
-nsGlobalWindow::GetTopWindowRoot()
+nsGlobalWindowInner::GetTopWindowRoot()
 {
   nsPIDOMWindowOuter* piWin = GetPrivateRoot();
   if (!piWin) {
     return nullptr;
   }
 
   nsCOMPtr<nsPIWindowRoot> window = do_QueryInterface(piWin->GetChromeEventHandler());
   return window.forget();
 }
 
 void
-nsGlobalWindow::Scroll(double aXScroll, double aYScroll)
+nsGlobalWindowInner::Scroll(double aXScroll, double aYScroll)
 {
   // Convert -Inf, Inf, and NaN to 0; otherwise, convert by C-style cast.
   auto scrollPos = CSSIntPoint::Truncate(mozilla::ToZeroIfNonfinite(aXScroll),
                                          mozilla::ToZeroIfNonfinite(aYScroll));
   ScrollTo(scrollPos, ScrollOptions());
 }
 
 void
-nsGlobalWindow::ScrollTo(double aXScroll, double aYScroll)
+nsGlobalWindowInner::ScrollTo(double aXScroll, double aYScroll)
 {
   // Convert -Inf, Inf, and NaN to 0; otherwise, convert by C-style cast.
   auto scrollPos = CSSIntPoint::Truncate(mozilla::ToZeroIfNonfinite(aXScroll),
                                          mozilla::ToZeroIfNonfinite(aYScroll));
   ScrollTo(scrollPos, ScrollOptions());
 }
 
 void
-nsGlobalWindow::ScrollTo(const ScrollToOptions& aOptions)
+nsGlobalWindowInner::ScrollTo(const ScrollToOptions& aOptions)
 {
   // When scrolling to a non-zero offset, we need to determine whether that
   // position is within our scrollable range, so we need updated layout
   // information which requires a layout flush, otherwise all we need is to
   // flush frames to be able to access our scrollable frame here.
   FlushType flushType = ((aOptions.mLeft.WasPassed() &&
                           aOptions.mLeft.Value() > 0) ||
                          (aOptions.mTop.WasPassed() &&
@@ -8597,23 +8459,23 @@ nsGlobalWindow::ScrollTo(const ScrollToO
       scrollPos.y = mozilla::ToZeroIfNonfinite(aOptions.mTop.Value());
     }
 
     ScrollTo(scrollPos, aOptions);
   }
 }
 
 void
-nsGlobalWindow::Scroll(const ScrollToOptions& aOptions)
+nsGlobalWindowInner::Scroll(const ScrollToOptions& aOptions)
 {
   ScrollTo(aOptions);
 }
 
 void
-nsGlobalWindow::ScrollTo(const CSSIntPoint& aScroll,
+nsGlobalWindowInner::ScrollTo(const CSSIntPoint& aScroll,
                          const ScrollOptions& aOptions)
 {
   // When scrolling to a non-zero offset, we need to determine whether that
   // position is within our scrollable range, so we need updated layout
   // information which requires a layout flush, otherwise all we need is to
   // flush frames to be able to access our scrollable frame here.
   FlushType flushType = (aScroll.x || aScroll.y) ?
                           FlushType::Layout :
@@ -8642,34 +8504,34 @@ nsGlobalWindow::ScrollTo(const CSSIntPoi
 
     sf->ScrollToCSSPixels(scroll, smoothScroll
                             ? nsIScrollableFrame::SMOOTH_MSD
                             : nsIScrollableFrame::INSTANT);
   }
 }
 
 void
-nsGlobalWindow::ScrollBy(double aXScrollDif, double aYScrollDif)
+nsGlobalWindowInner::ScrollBy(double aXScrollDif, double aYScrollDif)
 {
   FlushPendingNotifications(FlushType::Layout);
   nsIScrollableFrame *sf = GetScrollFrame();
 
   if (sf) {
     // Convert -Inf, Inf, and NaN to 0; otherwise, convert by C-style cast.
     auto scrollDif = CSSIntPoint::Truncate(mozilla::ToZeroIfNonfinite(aXScrollDif),
                                            mozilla::ToZeroIfNonfinite(aYScrollDif));
     // It seems like it would make more sense for ScrollBy to use
     // SMOOTH mode, but tests seem to depend on the synchronous behaviour.
     // Perhaps Web content does too.
     ScrollTo(sf->GetScrollPositionCSSPixels() + scrollDif, ScrollOptions());
   }
 }
 
 void
-nsGlobalWindow::ScrollBy(const ScrollToOptions& aOptions)
+nsGlobalWindowInner::ScrollBy(const ScrollToOptions& aOptions)
 {
   FlushPendingNotifications(FlushType::Layout);
   nsIScrollableFrame *sf = GetScrollFrame();
 
   if (sf) {
     CSSIntPoint scrollPos = sf->GetScrollPositionCSSPixels();
     if (aOptions.mLeft.WasPassed()) {
       scrollPos.x += mozilla::ToZeroIfNonfinite(aOptions.mLeft.Value());
@@ -8678,17 +8540,17 @@ nsGlobalWindow::ScrollBy(const ScrollToO
       scrollPos.y += mozilla::ToZeroIfNonfinite(aOptions.mTop.Value());
     }
 
     ScrollTo(scrollPos, aOptions);
   }
 }
 
 void
-nsGlobalWindow::ScrollByLines(int32_t numLines,
+nsGlobalWindowInner::ScrollByLines(int32_t numLines,
                               const ScrollOptions& aOptions)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   FlushPendingNotifications(FlushType::Layout);
   nsIScrollableFrame *sf = GetScrollFrame();
   if (sf) {
     // It seems like it would make more sense for ScrollByLines to use
@@ -8699,17 +8561,17 @@ nsGlobalWindow::ScrollByLines(int32_t nu
     sf->ScrollBy(nsIntPoint(0, numLines), nsIScrollableFrame::LINES,
                  smoothScroll
                    ? nsIScrollableFrame::SMOOTH_MSD
                    : nsIScrollableFrame::INSTANT);
   }
 }
 
 void
-nsGlobalWindow::ScrollByPages(int32_t numPages,
+nsGlobalWindowInner::ScrollByPages(int32_t numPages,
                               const ScrollOptions& aOptions)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   FlushPendingNotifications(FlushType::Layout);
   nsIScrollableFrame *sf = GetScrollFrame();
   if (sf) {
     // It seems like it would make more sense for ScrollByPages to use
@@ -8720,63 +8582,63 @@ nsGlobalWindow::ScrollByPages(int32_t nu
     sf->ScrollBy(nsIntPoint(0, numPages), nsIScrollableFrame::PAGES,
                  smoothScroll
                    ? nsIScrollableFrame::SMOOTH_MSD
                    : nsIScrollableFrame::INSTANT);
   }
 }
 
 void
-nsGlobalWindow::MozScrollSnap()
+nsGlobalWindowInner::MozScrollSnap()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   FlushPendingNotifications(FlushType::Layout);
   nsIScrollableFrame *sf = GetScrollFrame();
   if (sf) {
     sf->ScrollSnap();
   }
 }
 
 void
-nsGlobalWindow::ClearTimeout(int32_t aHandle)
+nsGlobalWindowInner::ClearTimeout(int32_t aHandle)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (aHandle > 0) {
     mTimeoutManager->ClearTimeout(aHandle, Timeout::Reason::eTimeoutOrInterval);
   }
 }
 
 void
-nsGlobalWindow::ClearInterval(int32_t aHandle)
+nsGlobalWindowInner::ClearInterval(int32_t aHandle)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (aHandle > 0) {
     mTimeoutManager->ClearTimeout(aHandle, Timeout::Reason::eTimeoutOrInterval);
   }
 }
 
 void
-nsGlobalWindow::SetResizable(bool aResizable) const
+nsGlobalWindowInner::SetResizable(bool aResizable) const
 {
   // nop
 }
 
 void
-nsGlobalWindow::CaptureEvents()
+nsGlobalWindowInner::CaptureEvents()
 {
   if (mDoc) {
     mDoc->WarnOnceAbout(nsIDocument::eUseOfCaptureEvents);
   }
 }
 
 void
-nsGlobalWindow::ReleaseEvents()
+nsGlobalWindowInner::ReleaseEvents()
 {
   if (mDoc) {
     mDoc->WarnOnceAbout(nsIDocument::eUseOfReleaseEvents);
   }
 }
 
 static
 bool IsPopupBlocked(nsIDocument* aDoc)
@@ -8793,17 +8655,17 @@ bool IsPopupBlocked(nsIDocument* aDoc)
   }
 
   uint32_t permission = nsIPopupWindowManager::ALLOW_POPUP;
   pm->TestPermission(aDoc->NodePrincipal(), &permission);
   return permission == nsIPopupWindowManager::DENY_POPUP;
 }
 
 void
-nsGlobalWindow::FirePopupBlockedEvent(nsIDocument* aDoc,
+nsGlobalWindowInner::FirePopupBlockedEvent(nsIDocument* aDoc,
                                       nsIURI* aPopupURI,
                                       const nsAString& aPopupWindowName,
                                       const nsAString& aPopupWindowFeatures)
 {
   MOZ_ASSERT(IsOuterWindow(), "All callers seem to assume we're an outer window?");
   MOZ_ASSERT(aDoc);
 
   // Fire a "DOMPopupBlocked" event so that the UI can hear about
@@ -8826,30 +8688,30 @@ nsGlobalWindow::FirePopupBlockedEvent(ns
   event->SetTrusted(true);
 
   bool defaultActionEnabled;
   aDoc->DispatchEvent(event, &defaultActionEnabled);
 }
 
 // static
 bool
-nsGlobalWindow::CanSetProperty(const char *aPrefName)
+nsGlobalWindowInner::CanSetProperty(const char *aPrefName)
 {
   // Chrome can set any property.
   if (nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
     return true;
   }
 
   // If the pref is set to true, we can not set the property
   // and vice versa.
   return !Preferences::GetBool(aPrefName, true);
 }
 
 bool
-nsGlobalWindow::PopupWhitelisted()
+nsGlobalWindowInner::PopupWhitelisted()
 {
   if (!IsPopupBlocked(mDoc))
     return true;
 
   nsCOMPtr<nsPIDOMWindowOuter> parent = GetParent();
   if (parent == AsOuter())
   {
     return false;
@@ -8860,17 +8722,17 @@ nsGlobalWindow::PopupWhitelisted()
 
 /*
  * Examine the current document state to see if we're in a way that is
  * typically abused by web designers. The window.open code uses this
  * routine to determine whether to allow the new window.
  * Returns a value from the PopupControlState enum.
  */
 PopupControlState
-nsGlobalWindow::RevisePopupAbuseLevel(PopupControlState aControl)
+nsGlobalWindowInner::RevisePopupAbuseLevel(PopupControlState aControl)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   NS_ASSERTION(mDocShell, "Must have docshell");
 
   if (mDocShell->ItemType() != nsIDocShellTreeItem::typeContent) {
     return openAllowed;
   }
@@ -8902,17 +8764,17 @@ nsGlobalWindow::RevisePopupAbuseLevel(Po
       abuse = openOverridden;
   }
 
   return abuse;
 }
 
 /* If a window open is blocked, fire the appropriate DOM events. */
 void
-nsGlobalWindow::FireAbuseEvents(const nsAString &aPopupURL,
+nsGlobalWindowInner::FireAbuseEvents(const nsAString &aPopupURL,
                                 const nsAString &aPopupWindowName,
                                 const nsAString &aPopupWindowFeatures)
 {
   MOZ_ASSERT(IsOuterWindow());
   // fetch the URI of the window requesting the opened window
 
   nsCOMPtr<nsPIDOMWindowOuter> window = GetTop();
   if (!window) {
@@ -8940,36 +8802,36 @@ nsGlobalWindow::FireAbuseEvents(const ns
                 getter_AddRefs(popupURI));
 
   // fire an event chock full of informative URIs
   FirePopupBlockedEvent(topDoc, popupURI, aPopupWindowName,
                         aPopupWindowFeatures);
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::OpenOuter(const nsAString& aUrl, const nsAString& aName,
+nsGlobalWindowInner::OpenOuter(const nsAString& aUrl, const nsAString& aName,
                           const nsAString& aOptions, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   nsCOMPtr<nsPIDOMWindowOuter> window;
   aError = OpenJS(aUrl, aName, aOptions, getter_AddRefs(window));
   return window.forget();
 }
 
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::Open(const nsAString& aUrl, const nsAString& aName,
+nsGlobalWindowInner::Open(const nsAString& aUrl, const nsAString& aName,
                      const nsAString& aOptions, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(OpenOuter, (aUrl, aName, aOptions, aError), aError,
                             nullptr);
 }
 
 nsresult
-nsGlobalWindow::Open(const nsAString& aUrl, const nsAString& aName,
+nsGlobalWindowInner::Open(const nsAString& aUrl, const nsAString& aName,
                      const nsAString& aOptions, nsIDocShellLoadInfo* aLoadInfo,
                      bool aForceNoOpener, nsPIDOMWindowOuter **_retval)
 {
   FORWARD_TO_OUTER(Open, (aUrl, aName, aOptions, aLoadInfo, aForceNoOpener,
                           _retval),
                    NS_ERROR_NOT_INITIALIZED);
   return OpenInternal(aUrl, aName, aOptions,
                       false,          // aDialog
@@ -8979,17 +8841,17 @@ nsGlobalWindow::Open(const nsAString& aU
                       true,           // aNavigate
                       nullptr, nullptr,  // No args
                       aLoadInfo,
                       aForceNoOpener,
                       _retval);
 }
 
 nsresult
-nsGlobalWindow::OpenJS(const nsAString& aUrl, const nsAString& aName,
+nsGlobalWindowInner::OpenJS(const nsAString& aUrl, const nsAString& aName,
                        const nsAString& aOptions, nsPIDOMWindowOuter **_retval)
 {
   MOZ_ASSERT(IsOuterWindow());
   return OpenInternal(aUrl, aName, aOptions,
                       false,          // aDialog
                       false,          // aContentModal
                       false,          // aCalledNoScript
                       true,           // aDoJSFixups
@@ -8998,17 +8860,17 @@ nsGlobalWindow::OpenJS(const nsAString& 
                       nullptr,        // aLoadInfo
                       false,          // aForceNoOpener
                       _retval);
 }
 
 // like Open, but attaches to the new window any extra parameters past
 // [features] as a JS property named "arguments"
 nsresult
-nsGlobalWindow::OpenDialog(const nsAString& aUrl, const nsAString& aName,
+nsGlobalWindowInner::OpenDialog(const nsAString& aUrl, const nsAString& aName,
                            const nsAString& aOptions,
                            nsISupports* aExtraArgument,
                            nsPIDOMWindowOuter** _retval)
 {
   MOZ_ASSERT(IsOuterWindow());
   return OpenInternal(aUrl, aName, aOptions,
                       true,                    // aDialog
                       false,                   // aContentModal
@@ -9018,17 +8880,17 @@ nsGlobalWindow::OpenDialog(const nsAStri
                       nullptr, aExtraArgument, // Arguments
                       nullptr,                 // aLoadInfo
                       false,                   // aForceNoOpener
                       _retval);
 }
 
 // Like Open, but passes aNavigate=false.
 /* virtual */ nsresult
-nsGlobalWindow::OpenNoNavigate(const nsAString& aUrl,
+nsGlobalWindowInner::OpenNoNavigate(const nsAString& aUrl,
                                const nsAString& aName,
                                const nsAString& aOptions,
                                nsPIDOMWindowOuter **_retval)
 {
   MOZ_ASSERT(IsOuterWindow());
   return OpenInternal(aUrl, aName, aOptions,
                       false,          // aDialog
                       false,          // aContentModal
@@ -9038,17 +8900,17 @@ nsGlobalWindow::OpenNoNavigate(const nsA
                       nullptr, nullptr,  // No args
                       nullptr,        // aLoadInfo
                       false,          // aForceNoOpener
                       _retval);
 
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::OpenDialogOuter(JSContext* aCx, const nsAString& aUrl,
+nsGlobalWindowInner::OpenDialogOuter(JSContext* aCx, const nsAString& aUrl,
                                 const nsAString& aName, const nsAString& aOptions,
                                 const Sequence<JS::Value>& aExtraArgument,
                                 ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIJSArgArray> argvArray;
   aError = NS_CreateJSArgv(aCx, aExtraArgument.Length(),
@@ -9068,42 +8930,42 @@ nsGlobalWindow::OpenDialogOuter(JSContex
                         argvArray, nullptr,  // Arguments
                         nullptr,          // aLoadInfo
                         false,            // aForceNoOpener
                         getter_AddRefs(dialog));
   return dialog.forget();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::OpenDialog(JSContext* aCx, const nsAString& aUrl,
+nsGlobalWindowInner::OpenDialog(JSContext* aCx, const nsAString& aUrl,
                            const nsAString& aName, const nsAString& aOptions,
                            const Sequence<JS::Value>& aExtraArgument,
                            ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(OpenDialogOuter,
                             (aCx, aUrl, aName, aOptions, aExtraArgument, aError),
                             aError, nullptr);
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetFramesOuter()
+nsGlobalWindowInner::GetFramesOuter()
 {
   RefPtr<nsPIDOMWindowOuter> frames(AsOuter());
   FlushPendingNotifications(FlushType::ContentAndNotify);
   return frames.forget();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
-nsGlobalWindow::GetFrames(ErrorResult& aError)
+nsGlobalWindowInner::GetFrames(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetFramesOuter, (), aError, nullptr);
 }
 
 nsGlobalWindowInner*
-nsGlobalWindow::CallerInnerWindow()
+nsGlobalWindowInner::CallerInnerWindow()
 {
   JSContext *cx = nsContentUtils::GetCurrentJSContext();
   NS_ENSURE_TRUE(cx, nullptr);
   nsIGlobalObject* global = GetIncumbentGlobal();
   NS_ENSURE_TRUE(global, nullptr);
   JS::Rooted<JSObject*> scope(cx, global->GetGlobalJSObject());
   NS_ENSURE_TRUE(scope, nullptr);
 
@@ -9128,17 +8990,17 @@ nsGlobalWindow::CallerInnerWindow()
 
   // The calling window must be holding a reference, so we can return a weak
   // pointer.
   nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(global);
   return nsGlobalWindowInner::Cast(win);
 }
 
 void
-nsGlobalWindow::PostMessageMozOuter(JSContext* aCx, JS::Handle<JS::Value> aMessage,
+nsGlobalWindowInner::PostMessageMozOuter(JSContext* aCx, JS::Handle<JS::Value> aMessage,
                                     const nsAString& aTargetOrigin,
                                     JS::Handle<JS::Value> aTransfer,
                                     nsIPrincipal& aSubjectPrincipal,
                                     ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   //
@@ -9280,30 +9142,30 @@ nsGlobalWindow::PostMessageMozOuter(JSCo
   if (NS_WARN_IF(aError.Failed())) {
     return;
   }
 
   aError = Dispatch(TaskCategory::Other, event.forget());
 }
 
 void
-nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
+nsGlobalWindowInner::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
                                const nsAString& aTargetOrigin,
                                JS::Handle<JS::Value> aTransfer,
                                nsIPrincipal& aSubjectPrincipal,
                                ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(PostMessageMozOuter,
                             (aCx, aMessage, aTargetOrigin, aTransfer,
                              aSubjectPrincipal, aError),
                             aError, );
 }
 
 void
-nsGlobalWindow::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
+nsGlobalWindowInner::PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
                                const nsAString& aTargetOrigin,
                                const Sequence<JSObject*>& aTransfer,
                                nsIPrincipal& aSubjectPrincipal,
                                ErrorResult& aRv)
 {
   JS::Rooted<JS::Value> transferArray(aCx, JS::UndefinedValue());
 
   aRv = nsContentUtils::CreateJSValueFromSequenceOfObject(aCx, aTransfer,
@@ -9347,17 +9209,17 @@ public:
       mWindow->ReallyCloseWindow();
     }
     return NS_OK;
   }
 
 };
 
 bool
-nsGlobalWindow::CanClose()
+nsGlobalWindowInner::CanClose()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (mIsChrome) {
     nsCOMPtr<nsIBrowserDOMWindow> bwin;
     GetBrowserDOMWindow(getter_AddRefs(bwin));
 
     bool canClose = true;
@@ -9387,17 +9249,17 @@ nsGlobalWindow::CanClose()
     if (NS_SUCCEEDED(rv) && !canClose)
       return false;
   }
 
   return true;
 }
 
 void
-nsGlobalWindow::CloseOuter(bool aTrustedCaller)
+nsGlobalWindowInner::CloseOuter(bool aTrustedCaller)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell || IsInModalState() ||
       (IsFrame() && !mDocShell->GetIsMozBrowser())) {
     // window.close() is called on a frame in a frameset, on a window
     // that's already closed, or on a window for which there's
     // currently a modal dialog open. Ignore such calls.
@@ -9462,31 +9324,31 @@ nsGlobalWindow::CloseOuter(bool aTrusted
     mInClose = wasInClose;
     return;
   }
 
   FinalClose();
 }
 
 void
-nsGlobalWindow::Close(ErrorResult& aError)
+nsGlobalWindowInner::Close(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(CloseOuter, (nsContentUtils::IsCallerChrome()), aError, );
 }
 
 nsresult
-nsGlobalWindow::Close()
+nsGlobalWindowInner::Close()
 {
   FORWARD_TO_OUTER(Close, (), NS_ERROR_UNEXPECTED);
   CloseOuter(/* aTrustedCaller = */ true);
   return NS_OK;
 }
 
 void
-nsGlobalWindow::ForceClose()
+nsGlobalWindowInner::ForceClose()
 {
   MOZ_ASSERT(IsOuterWindow());
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
 
   if (IsFrame() || !mDocShell) {
     // This may be a frame in a frameset, or a window that's already closed.
     // Ignore such calls.
     return;
@@ -9501,17 +9363,17 @@ nsGlobalWindow::ForceClose()
   mInClose = true;
 
   DispatchCustomEvent(NS_LITERAL_STRING("DOMWindowClose"));
 
   FinalClose();
 }
 
 void
-nsGlobalWindow::FinalClose()
+nsGlobalWindowInner::FinalClose()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // Flag that we were closed.
   mIsClosed = true;
 
   // If we get here from CloseOuter then it means that the parent process is
   // going to close our window for us. It's just important to set mIsClosed.
@@ -9539,17 +9401,17 @@ nsGlobalWindow::FinalClose()
     ReallyCloseWindow();
   } else {
     mHavePendingClose = true;
   }
 }
 
 
 void
-nsGlobalWindow::ReallyCloseWindow()
+nsGlobalWindowInner::ReallyCloseWindow()
 {
   FORWARD_TO_OUTER_VOID(ReallyCloseWindow, ());
 
   // Make sure we never reenter this method.
   mHavePendingClose = true;
 
   nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
 
@@ -9592,17 +9454,17 @@ nsGlobalWindow::ReallyCloseWindow()
       }
     }
 
     CleanUp();
   }
 }
 
 void
-nsGlobalWindow::EnterModalState()
+nsGlobalWindowInner::EnterModalState()
 {
   MOZ_ASSERT(IsOuterWindow(), "Modal state is maintained on outer windows");
 
   // GetScriptableTop, not GetTop, so that EnterModalState works properly with
   // <iframe mozbrowser>.
   nsGlobalWindowOuter* topWin = GetScriptableTopInternal();
 
   if (!topWin) {
@@ -9660,17 +9522,17 @@ nsGlobalWindow::EnterModalState()
     if (inner) {
       topWin->GetCurrentInnerWindowInternal()->Suspend();
     }
   }
   topWin->mModalStateDepth++;
 }
 
 void
-nsGlobalWindow::LeaveModalState()
+nsGlobalWindowInner::LeaveModalState()
 {
   MOZ_ASSERT(IsOuterWindow(), "Modal state is maintained on outer windows");
 
   nsGlobalWindowOuter* topWin = GetScriptableTopInternal();
 
   if (!topWin) {
     NS_ERROR("Uh, LeaveModalState() called w/o a reachable top window?");
     return;
@@ -9706,32 +9568,32 @@ nsGlobalWindow::LeaveModalState()
     event->SetTrusted(true);
     event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
     bool dummy;
     topWin->DispatchEvent(event, &dummy);
   }
 }
 
 bool
-nsGlobalWindow::IsInModalState()
+nsGlobalWindowInner::IsInModalState()
 {
   nsGlobalWindowOuter *topWin = GetScriptableTopInternal();
 
   if (!topWin) {
     // IsInModalState() getting called w/o a reachable top window is a bit
     // iffy, but valid enough not to make noise about it.  See bug 404828
     return false;
   }
 
   return topWin->mModalStateDepth != 0;
 }
 
 // static
 void
-nsGlobalWindow::NotifyDOMWindowDestroyed(nsGlobalWindowInner* aWindow) {
+nsGlobalWindowInner::NotifyDOMWindowDestroyed(nsGlobalWindowInner* aWindow) {
   nsCOMPtr<nsIObserverService> observerService =
     services::GetObserverService();
   if (observerService) {
     observerService->
       NotifyObservers(ToSupports(aWindow),
                       DOM_WINDOW_DESTROYED_TOPIC, nullptr);
   }
 }
@@ -9870,82 +9732,82 @@ private:
   uint64_t mID;
   Phase mPhase;
   nsCString mTopic;
   nsWeakPtr mWindow;
   bool mIsInnerWindow;
 };
 
 void
-nsGlobalWindow::NotifyWindowIDDestroyed(const char* aTopic)
+nsGlobalWindowInner::NotifyWindowIDDestroyed(const char* aTopic)
 {
   nsCOMPtr<nsIRunnable> runnable;
   if (IsInnerWindow()) {
     runnable = new WindowDestroyedEvent(AssertInner(), mWindowID, aTopic);
   } else {
     runnable = new WindowDestroyedEvent(AssertOuter(), mWindowID, aTopic);
   }
   nsresult rv = Dispatch(TaskCategory::Other, runnable.forget());
   if (NS_SUCCEEDED(rv)) {
     mNotifiedIDDestroyed = true;
   }
 }
 
 // static
 void
-nsGlobalWindow::NotifyDOMWindowFrozen(nsGlobalWindowInner* aWindow) {
+nsGlobalWindowInner::NotifyDOMWindowFrozen(nsGlobalWindowInner* aWindow) {
   if (aWindow) {
     nsCOMPtr<nsIObserverService> observerService =
       services::GetObserverService();
     if (observerService) {
       observerService->
         NotifyObservers(ToSupports(aWindow),
                         DOM_WINDOW_FROZEN_TOPIC, nullptr);
     }
   }
 }
 
 // static
 void
-nsGlobalWindow::NotifyDOMWindowThawed(nsGlobalWindowInner* aWindow) {
+nsGlobalWindowInner::NotifyDOMWindowThawed(nsGlobalWindowInner* aWindow) {
   if (aWindow) {
     nsCOMPtr<nsIObserverService> observerService =
       services::GetObserverService();
     if (observerService) {
       observerService->
         NotifyObservers(ToSupports(aWindow),
                         DOM_WINDOW_THAWED_TOPIC, nullptr);
     }
   }
 }
 
 JSObject*
-nsGlobalWindow::GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey)
+nsGlobalWindowInner::GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey)
 {
   JS::Rooted<JSObject*> handler(RootingCx());
   if (mCachedXBLPrototypeHandlers) {
     mCachedXBLPrototypeHandlers->Get(aKey, handler.address());
   }
   return handler;
 }
 
 void
-nsGlobalWindow::CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
+nsGlobalWindowInner::CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
                                          JS::Handle<JSObject*> aHandler)
 {
   if (!mCachedXBLPrototypeHandlers) {
     mCachedXBLPrototypeHandlers = MakeUnique<XBLPrototypeHandlerTable>();
     PreserveWrapper(ToSupports(this));
   }
 
   mCachedXBLPrototypeHandlers->Put(aKey, aHandler);
 }
 
 Element*
-nsGlobalWindow::GetFrameElementOuter(nsIPrincipal& aSubjectPrincipal)
+nsGlobalWindowInner::GetFrameElementOuter(nsIPrincipal& aSubjectPrincipal)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell || mDocShell->GetIsMozBrowser()) {
     return nullptr;
   }
 
   // Per HTML5, the frameElement getter returns null in cross-origin situations.
@@ -9957,25 +9819,25 @@ nsGlobalWindow::GetFrameElementOuter(nsI
   if (!aSubjectPrincipal.SubsumesConsideringDomain(element->NodePrincipal())) {
     return nullptr;
   }
 
   return element;
 }
 
 Element*
-nsGlobalWindow::GetFrameElement(nsIPrincipal& aSubjectPrincipal,
+nsGlobalWindowInner::GetFrameElement(nsIPrincipal& aSubjectPrincipal,
                                 ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetFrameElementOuter, (aSubjectPrincipal), aError,
                             nullptr);
 }
 
 Element*
-nsGlobalWindow::GetRealFrameElementOuter()
+nsGlobalWindowInner::GetRealFrameElementOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return nullptr;
   }
 
   nsCOMPtr<nsIDocShell> parent;
@@ -9986,39 +9848,39 @@ nsGlobalWindow::GetRealFrameElementOuter
     // element to content code.
     return nullptr;
   }
 
   return mFrameElement;
 }
 
 Element*
-nsGlobalWindow::GetRealFrameElement(ErrorResult& aError)
+nsGlobalWindowInner::GetRealFrameElement(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetRealFrameElementOuter, (), aError, nullptr);
 }
 
 /**
  * nsIGlobalWindow::GetFrameElement (when called from C++) is just a wrapper
  * around GetRealFrameElement.
  */
 already_AddRefed<nsIDOMElement>
-nsGlobalWindow::GetFrameElement()
+nsGlobalWindowInner::GetFrameElement()
 {
   FORWARD_TO_INNER(GetFrameElement, (), nullptr);
 
   ErrorResult dummy;
   nsCOMPtr<nsIDOMElement> frameElement =
     do_QueryInterface(GetRealFrameElement(dummy));
   dummy.SuppressException();
   return frameElement.forget();
 }
 
 /* static */ bool
-nsGlobalWindow::TokenizeDialogOptions(nsAString& aToken,
+nsGlobalWindowInner::TokenizeDialogOptions(nsAString& aToken,
                                       nsAString::const_iterator& aIter,
                                       nsAString::const_iterator aEnd)
 {
   while (aIter != aEnd && nsCRT::IsAsciiSpace(*aIter)) {
     ++aIter;
   }
 
   if (aIter == aEnd) {
@@ -10046,17 +9908,17 @@ nsGlobalWindow::TokenizeDialogOptions(ns
 }
 
 // Helper for converting window.showModalDialog() options (list of ';'
 // separated name (:|=) value pairs) to a format that's parsable by
 // our normal window opening code.
 
 /* static */
 void
-nsGlobalWindow::ConvertDialogOptions(const nsAString& aOptions,
+nsGlobalWindowInner::ConvertDialogOptions(const nsAString& aOptions,
                                      nsAString& aResult)
 {
   nsAString::const_iterator end;
   aOptions.EndReading(end);
 
   nsAString::const_iterator iter;
   aOptions.BeginReading(iter);
 
@@ -10183,17 +10045,17 @@ public:
     return mDispatcher->UpdateCommands(mAction);
   }
 
   nsCOMPtr<nsIDOMXULCommandDispatcher> mDispatcher;
   nsString                             mAction;
 };
 
 nsresult
-nsGlobalWindow::UpdateCommands(const nsAString& anAction, nsISelection* aSel, int16_t aReason)
+nsGlobalWindowInner::UpdateCommands(const nsAString& anAction, nsISelection* aSel, int16_t aReason)
 {
   // If this is a child process, redirect to the parent process.
   if (nsIDocShell* docShell = GetDocShell()) {
     if (nsCOMPtr<nsITabChild> child = docShell->GetTabChild()) {
       nsCOMPtr<nsPIWindowRoot> root = GetTopWindowRoot();
       if (root) {
         nsContentUtils::AddScriptRunner(
           new ChildCommandDispatcher(root, child, anAction));
@@ -10220,17 +10082,17 @@ nsGlobalWindow::UpdateCommands(const nsA
                                                             anAction));
     }
   }
 
   return NS_OK;
 }
 
 Selection*
-nsGlobalWindow::GetSelectionOuter()
+nsGlobalWindowInner::GetSelectionOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return nullptr;
   }
 
   nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
@@ -10238,30 +10100,30 @@ nsGlobalWindow::GetSelectionOuter()
     return nullptr;
   }
   nsISelection* domSelection =
     presShell->GetCurrentSelection(SelectionType::eNormal);
   return domSelection ? domSelection->AsSelection() : nullptr;
 }
 
 Selection*
-nsGlobalWindow::GetSelection(ErrorResult& aError)
+nsGlobalWindowInner::GetSelection(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetSelectionOuter, (), aError, nullptr);
 }
 
 already_AddRefed<nsISelection>
-nsGlobalWindow::GetSelection()
+nsGlobalWindowInner::GetSelection()
 {
   nsCOMPtr<nsISelection> selection = GetSelectionOuter();
   return selection.forget();
 }
 
 bool
-nsGlobalWindow::FindOuter(const nsAString& aString, bool aCaseSensitive,
+nsGlobalWindowInner::FindOuter(const nsAString& aString, bool aCaseSensitive,
                           bool aBackwards, bool aWrapAround, bool aWholeWord,
                           bool aSearchInFrames, bool aShowDialog,
                           ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   Unused << aShowDialog;
 
@@ -10303,79 +10165,79 @@ nsGlobalWindow::FindOuter(const nsAStrin
 
   // Launch the search with the passed in search string
   bool didFind = false;
   aError = finder->FindNext(&didFind);
   return didFind;
 }
 
 bool
-nsGlobalWindow::Find(const nsAString& aString, bool aCaseSensitive,
+nsGlobalWindowInner::Find(const nsAString& aString, bool aCaseSensitive,
                      bool aBackwards, bool aWrapAround, bool aWholeWord,
                      bool aSearchInFrames, bool aShowDialog,
                      ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(FindOuter,
                             (aString, aCaseSensitive, aBackwards, aWrapAround,
                              aWholeWord, aSearchInFrames, aShowDialog, aError),
                             aError, false);
 }
 
 void
-nsGlobalWindow::GetOrigin(nsAString& aOrigin)
+nsGlobalWindowInner::GetOrigin(nsAString& aOrigin)
 {
   MOZ_DIAGNOSTIC_ASSERT(IsInnerWindow());
   nsContentUtils::GetUTFOrigin(GetPrincipal(), aOrigin);
 }
 
 void
-nsGlobalWindow::Atob(const nsAString& aAsciiBase64String,
+nsGlobalWindowInner::Atob(const nsAString& aAsciiBase64String,
                      nsAString& aBinaryData, ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   aError = nsContentUtils::Atob(aAsciiBase64String, aBinaryData);
 }
 
 void
-nsGlobalWindow::Btoa(const nsAString& aBinaryData,
+nsGlobalWindowInner::Btoa(const nsAString& aBinaryData,
                      nsAString& aAsciiBase64String, ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   aError = nsContentUtils::Btoa(aBinaryData, aAsciiBase64String);
 }
 
 //*****************************************************************************
-// nsGlobalWindow::nsIDOMEventTarget
+// nsGlobalWindowInner::nsIDOMEventTarget
 //*****************************************************************************
 
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetOwnerGlobalForBindings()
+nsGlobalWindowInner::GetOwnerGlobalForBindings()
 {
   if (IsOuterWindow()) {
     return AsOuter();
   }
 
   return nsPIDOMWindowOuter::GetFromCurrentInner(AsInner());
 }
 
 NS_IMETHODIMP
-nsGlobalWindow::RemoveEventListener(const nsAString& aType,
+nsGlobalWindowInner::RemoveEventListener(const nsAString& aType,
                                     nsIDOMEventListener* aListener,
                                     bool aUseCapture)
 {
   if (RefPtr<EventListenerManager> elm = GetExistingListenerManager()) {
     elm->RemoveEventListener(aType, aListener, aUseCapture);
   }
   return NS_OK;
 }
 
-NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsGlobalWindow)
+NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsGlobalWindowInner)
 
 NS_IMETHODIMP
-nsGlobalWindow::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
+nsGlobalWindowInner::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
 {
   FORWARD_TO_INNER(DispatchEvent, (aEvent, aRetVal), NS_OK);
 
   if (!AsInner()->IsCurrentInnerWindow()) {
     NS_WARNING("DispatchEvent called on non-current inner window, dropping. "
                "Please check the window in the caller instead.");
     return NS_ERROR_FAILURE;
   }
@@ -10396,17 +10258,17 @@ nsGlobalWindow::DispatchEvent(nsIDOMEven
   nsresult rv = EventDispatcher::DispatchDOMEvent(AsInner(), nullptr, aEvent,
                                                   presContext, &status);
 
   *aRetVal = (status != nsEventStatus_eConsumeNoDefault);
   return rv;
 }
 
 NS_IMETHODIMP
-nsGlobalWindow::AddEventListener(const nsAString& aType,
+nsGlobalWindowInner::AddEventListener(const nsAString& aType,
                                  nsIDOMEventListener *aListener,
                                  bool aUseCapture, bool aWantsUntrusted,
                                  uint8_t aOptionalArgc)
 {
   NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1,
                "Won't check if this is chrome, you want to set "
                "aWantsUntrusted to false or make the aWantsUntrusted "
                "explicit by making optional_argc non-zero.");
@@ -10418,17 +10280,17 @@ nsGlobalWindow::AddEventListener(const n
 
   EventListenerManager* manager = GetOrCreateListenerManager();
   NS_ENSURE_STATE(manager);
   manager->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted);
   return NS_OK;
 }
 
 void
-nsGlobalWindow::AddEventListener(const nsAString& aType,
+nsGlobalWindowInner::AddEventListener(const nsAString& aType,
                                  EventListener* aListener,
                                  const AddEventListenerOptionsOrBoolean& aOptions,
                                  const Nullable<bool>& aWantsUntrusted,
                                  ErrorResult& aRv)
 {
   if (IsOuterWindow() && mInnerWindow &&
       !nsContentUtils::CanCallerAccess(mInnerWindow)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
@@ -10447,17 +10309,17 @@ nsGlobalWindow::AddEventListener(const n
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 
   manager->AddEventListener(aType, aListener, aOptions, wantsUntrusted);
 }
 
 NS_IMETHODIMP
-nsGlobalWindow::AddSystemEventListener(const nsAString& aType,
+nsGlobalWindowInner::AddSystemEventListener(const nsAString& aType,
                                        nsIDOMEventListener *aListener,
                                        bool aUseCapture,
                                        bool aWantsUntrusted,
                                        uint8_t aOptionalArgc)
 {
   NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1,
                "Won't check if this is chrome, you want to set "
                "aWantsUntrusted to false or make the aWantsUntrusted "
@@ -10474,56 +10336,56 @@ nsGlobalWindow::AddSystemEventListener(c
     aWantsUntrusted = true;
   }
 
   return NS_AddSystemEventListener(this, aType, aListener, aUseCapture,
                                    aWantsUntrusted);
 }
 
 EventListenerManager*
-nsGlobalWindow::GetOrCreateListenerManager()
+nsGlobalWindowInner::GetOrCreateListenerManager()
 {
   FORWARD_TO_INNER_CREATE(GetOrCreateListenerManager, (), nullptr);
 
   if (!mListenerManager) {
     mListenerManager =
       new EventListenerManager(static_cast<EventTarget*>(this));
   }
 
   return mListenerManager;
 }
 
 EventListenerManager*
-nsGlobalWindow::GetExistingListenerManager() const
+nsGlobalWindowInner::GetExistingListenerManager() const
 {
   FORWARD_TO_INNER(GetExistingListenerManager, (), nullptr);
 
   return mListenerManager;
 }
 
 nsIScriptContext*
-nsGlobalWindow::GetContextForEventHandlers(nsresult* aRv)
+nsGlobalWindowInner::GetContextForEventHandlers(nsresult* aRv)
 {
   *aRv = NS_ERROR_UNEXPECTED;
   NS_ENSURE_TRUE(!IsInnerWindow() || AsInner()->IsCurrentInnerWindow(), nullptr);
 
   nsIScriptContext* scx;
   if ((scx = GetContext())) {
     *aRv = NS_OK;
     return scx;
   }
   return nullptr;
 }
 
 //*****************************************************************************
-// nsGlobalWindow::nsPIDOMWindow
+// nsGlobalWindowInner::nsPIDOMWindow
 //*****************************************************************************
 
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetPrivateParent()
+nsGlobalWindowInner::GetPrivateParent()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsPIDOMWindowOuter> parent = GetParent();
 
   if (AsOuter() == parent) {
     nsCOMPtr<nsIContent> chromeElement(do_QueryInterface(mChromeEventHandler));
     if (!chromeElement)
@@ -10535,17 +10397,17 @@ nsGlobalWindow::GetPrivateParent()
 
     return doc->GetWindow();
   }
 
   return parent;
 }
 
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetPrivateRoot()
+nsGlobalWindowInner::GetPrivateRoot()
 {
   if (IsInnerWindow()) {
     nsGlobalWindowOuter* outer = GetOuterWindowInternal();
     if (!outer) {
       NS_WARNING("No outer window available!");
       return nullptr;
     }
     return outer->GetPrivateRoot();
@@ -10563,32 +10425,32 @@ nsGlobalWindow::GetPrivateRoot()
       }
     }
   }
 
   return top;
 }
 
 Location*
-nsGlobalWindow::GetLocation()
+nsGlobalWindowInner::GetLocation()
 {
   // This method can be called on the outer window as well.
   FORWARD_TO_INNER(GetLocation, (), nullptr);
 
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mLocation) {
     mLocation = new dom::Location(AsInner(), GetDocShell());
   }
 
   return mLocation;
 }
 
 void
-nsGlobalWindow::ActivateOrDeactivate(bool aActivate)
+nsGlobalWindowInner::ActivateOrDeactivate(bool aActivate)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   if (!mDoc) {
     return;
   }
 
   // Set / unset mIsActive on the top level window, which is used for the
@@ -10634,43 +10496,43 @@ static bool
 NotifyDocumentTree(nsIDocument* aDocument, void* aData)
 {
   aDocument->EnumerateSubDocuments(NotifyDocumentTree, nullptr);
   aDocument->DocumentStatesChanged(NS_DOCUMENT_STATE_WINDOW_INACTIVE);
   return true;
 }
 
 void
-nsGlobalWindow::SetActive(bool aActive)
+nsGlobalWindowInner::SetActive(bool aActive)
 {
   nsPIDOMWindow::SetActive(aActive);
   if (mDoc) {
     NotifyDocumentTree(mDoc, nullptr);
   }
 }
 
 bool
-nsGlobalWindow::IsTopLevelWindowActive()
+nsGlobalWindowInner::IsTopLevelWindowActive()
 {
    nsCOMPtr<nsIDocShellTreeItem> treeItem(GetDocShell());
    if (!treeItem) {
      return false;
    }
 
    nsCOMPtr<nsIDocShellTreeItem> rootItem;
    treeItem->GetRootTreeItem(getter_AddRefs(rootItem));
    if (!rootItem) {
      return false;
    }
 
    nsCOMPtr<nsPIDOMWindowOuter> domWindow = rootItem->GetWindow();
    return domWindow && domWindow->IsActive();
 }
 
-void nsGlobalWindow::SetIsBackground(bool aIsBackground)
+void nsGlobalWindowInner::SetIsBackground(bool aIsBackground)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   bool changed = aIsBackground != AsOuter()->IsBackground();
   SetIsBackgroundInternal(aIsBackground);
 
   nsGlobalWindowInner* inner = GetCurrentInnerWindowInternal();
 
@@ -10696,96 +10558,96 @@ void nsGlobalWindow::SetIsBackground(boo
     // When switching to be as a top tab, restart the telemetry.
     // false is for only resetting the timestamp.
     inner->ResetVRTelemetry(false);
     inner->SyncGamepadState();
   }
 }
 
 void
-nsGlobalWindow::SetIsBackgroundInternal(bool aIsBackground)
+nsGlobalWindowInner::SetIsBackgroundInternal(bool aIsBackground)
 {
   if (mIsBackground != aIsBackground) {
     TabGroup()->WindowChangedBackgroundStatus(aIsBackground);
   }
   mIsBackground = aIsBackground;
 }
 
-void nsGlobalWindow::MaybeUpdateTouchState()
+void nsGlobalWindowInner::MaybeUpdateTouchState()
 {
   FORWARD_TO_INNER_VOID(MaybeUpdateTouchState, ());
 
   if (mMayHaveTouchEventListener) {
     nsCOMPtr<nsIObserverService> observerService =
       services::GetObserverService();
 
     if (observerService) {
       observerService->NotifyObservers(static_cast<nsIDOMWindow*>(this),
                                        DOM_TOUCH_LISTENER_ADDED,
                                        nullptr);
     }
   }
 }
 
 void
-nsGlobalWindow::EnableGamepadUpdates()
+nsGlobalWindowInner::EnableGamepadUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasGamepad) {
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     if (gamepadManager) {
       gamepadManager->AddListener(AssertInner());
     }
   }
 }
 
 void
-nsGlobalWindow::DisableGamepadUpdates()
+nsGlobalWindowInner::DisableGamepadUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasGamepad) {
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     if (gamepadManager) {
       gamepadManager->RemoveListener(AssertInner());
     }
   }
 }
 
 void
-nsGlobalWindow::EnableVRUpdates()
+nsGlobalWindowInner::EnableVRUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasVREvents && !mVREventObserver) {
     mVREventObserver = new VREventObserver(AssertInner());
   }
 }
 
 void
-nsGlobalWindow::DisableVRUpdates()
+nsGlobalWindowInner::DisableVRUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
   if (mVREventObserver) {
     mVREventObserver->DisconnectFromOwner();
     mVREventObserver = nullptr;
   }
 }
 
 void
-nsGlobalWindow::ResetVRTelemetry(bool aUpdate)
+nsGlobalWindowInner::ResetVRTelemetry(bool aUpdate)
 {
   if (mVREventObserver) {
     mVREventObserver->UpdateSpentTimeIn2DTelemetry(aUpdate);
   }
 }
 
 void
-nsGlobalWindow::SetChromeEventHandler(EventTarget* aChromeEventHandler)
+nsGlobalWindowInner::SetChromeEventHandler(EventTarget* aChromeEventHandler)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   SetChromeEventHandlerInternal(aChromeEventHandler);
   // update the chrome event handler on all our inner windows
   RefPtr<nsGlobalWindowInner> inner;
   for (PRCList* node = PR_LIST_HEAD(this);
        node != this;
@@ -10811,17 +10673,17 @@ static bool ShouldShowFocusRingIfFocused
   if (!aNode) {
     return true;
   }
   return !IsLink(aNode) &&
          !aNode->IsAnyOfHTMLElements(nsGkAtoms::video, nsGkAtoms::audio);
 }
 
 void
-nsGlobalWindow::SetFocusedNode(nsIContent* aNode,
+nsGlobalWindowInner::SetFocusedNode(nsIContent* aNode,
                                uint32_t aFocusMethod,
                                bool aNeedsFocus)
 {
   FORWARD_TO_INNER_VOID(SetFocusedNode, (aNode, aFocusMethod, aNeedsFocus));
 
   if (aNode && aNode->GetComposedDoc() != mDoc) {
     NS_WARNING("Trying to set focus to a node from a wrong document");
     return;
@@ -10858,38 +10720,38 @@ nsGlobalWindow::SetFocusedNode(nsIConten
     }
   }
 
   if (aNeedsFocus)
     mNeedsFocus = aNeedsFocus;
 }
 
 uint32_t
-nsGlobalWindow::GetFocusMethod()
+nsGlobalWindowInner::GetFocusMethod()
 {
   FORWARD_TO_INNER(GetFocusMethod, (), 0);
 
   return mFocusMethod;
 }
 
 bool
-nsGlobalWindow::ShouldShowFocusRing()
+nsGlobalWindowInner::ShouldShowFocusRing()
 {
   FORWARD_TO_INNER(ShouldShowFocusRing, (), false);
 
   if (mShowFocusRingForContent || mFocusByKeyOccurred) {
     return true;
   }
 
   nsCOMPtr<nsPIWindowRoot> root = GetTopWindowRoot();
   return root ? root->ShowFocusRings() : false;
 }
 
 void
-nsGlobalWindow::SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
+nsGlobalWindowInner::SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
                                       UIStateChangeType aShowFocusRings)
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsPIDOMWindowOuter* piWin = GetPrivateRoot();
   if (!piWin) {
     return;
   }
@@ -10924,17 +10786,17 @@ nsGlobalWindow::SetKeyboardIndicators(UI
       mFocusedNode->AsElement()->AddStates(NS_EVENT_STATE_FOCUSRING);
     } else {
       mFocusedNode->AsElement()->RemoveStates(NS_EVENT_STATE_FOCUSRING);
     }
   }
 }
 
 bool
-nsGlobalWindow::TakeFocus(bool aFocus, uint32_t aFocusMethod)
+nsGlobalWindowInner::TakeFocus(bool aFocus, uint32_t aFocusMethod)
 {
   FORWARD_TO_INNER(TakeFocus, (aFocus, aFocusMethod), false);
 
   if (mCleanedUp) {
     return false;
   }
 
   if (aFocus)
@@ -10955,31 +10817,31 @@ nsGlobalWindow::TakeFocus(bool aFocus, u
     return true;
   }
 
   mNeedsFocus = false;
   return false;
 }
 
 void
-nsGlobalWindow::SetReadyForFocus()
+nsGlobalWindowInner::SetReadyForFocus()
 {
   FORWARD_TO_INNER_VOID(SetReadyForFocus, ());
 
   bool oldNeedsFocus = mNeedsFocus;
   mNeedsFocus = false;
 
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   if (fm) {
     fm->WindowShown(GetOuterWindow(), oldNeedsFocus);
   }
 }
 
 void
-nsGlobalWindow::PageHidden()
+nsGlobalWindowInner::PageHidden()
 {
   FORWARD_TO_INNER_VOID(PageHidden, ());
 
   // the window is being hidden, so tell the focus manager that the frame is
   // no longer valid. Use the persisted field to determine if the document
   // is being destroyed.
 
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
@@ -11013,17 +10875,17 @@ public:
 
 private:
   nsString mOldURL;
   nsString mNewURL;
   RefPtr<nsGlobalWindowInner> mWindow;
 };
 
 nsresult
-nsGlobalWindow::DispatchAsyncHashchange(nsIURI *aOldURI, nsIURI *aNewURI)
+nsGlobalWindowInner::DispatchAsyncHashchange(nsIURI *aOldURI, nsIURI *aNewURI)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   // Make sure that aOldURI and aNewURI are identical up to the '#', and that
   // their hashes are different.
   bool equal = false;
   NS_ENSURE_STATE(NS_SUCCEEDED(aOldURI->EqualsExceptRef(aNewURI, &equal)) && equal);
   nsAutoCString oldHash, newHash;
@@ -11044,17 +10906,17 @@ nsGlobalWindow::DispatchAsyncHashchange(
   NS_ConvertUTF8toUTF16 newWideSpec(newSpec);
 
   nsCOMPtr<nsIRunnable> callback =
     new HashchangeCallback(oldWideSpec, newWideSpec, AssertInner());
   return Dispatch(TaskCategory::Other, callback.forget());
 }
 
 nsresult
-nsGlobalWindow::FireHashchange(const nsAString &aOldURL,
+nsGlobalWindowInner::FireHashchange(const nsAString &aOldURL,
                                const nsAString &aNewURL)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   // Don't do anything if the window is frozen.
   if (IsFrozen()) {
     return NS_OK;
   }
@@ -11080,17 +10942,17 @@ nsGlobalWindow::FireHashchange(const nsA
 
   event->SetTrusted(true);
 
   bool dummy;
   return DispatchEvent(event, &dummy);
 }
 
 nsresult
-nsGlobalWindow::DispatchSyncPopState()
+nsGlobalWindowInner::DispatchSyncPopState()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
   NS_ASSERTION(nsContentUtils::IsSafeToRunScript(),
                "Must be safe to run script here.");
 
   nsresult rv = NS_OK;
 
   // Bail if the window is frozen.
@@ -11154,17 +11016,17 @@ static nsCanvasFrame* FindCanvasFrame(ns
     }
 
     return nullptr;
 }
 
 //-------------------------------------------------------
 // Tells the HTMLFrame/CanvasFrame that is now has focus
 void
-nsGlobalWindow::UpdateCanvasFocus(bool aFocusChanged, nsIContent* aNewContent)
+nsGlobalWindowInner::UpdateCanvasFocus(bool aFocusChanged, nsIContent* aNewContent)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   // this is called from the inner window so use GetDocShell
   nsIDocShell* docShell = GetDocShell();
   if (!docShell)
     return;
 
@@ -11198,34 +11060,34 @@ nsGlobalWindow::UpdateCanvasFocus(bool a
           if (canvasFrame) {
               canvasFrame->SetHasFocus(false);
           }
       }
   }
 }
 
 already_AddRefed<nsICSSDeclaration>
-nsGlobalWindow::GetComputedStyle(Element& aElt, const nsAString& aPseudoElt,
+nsGlobalWindowInner::GetComputedStyle(Element& aElt, const nsAString& aPseudoElt,
                                  ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   return GetComputedStyleHelper(aElt, aPseudoElt, false, aError);
 }
 
 already_AddRefed<nsICSSDeclaration>
-nsGlobalWindow::GetDefaultComputedStyle(Element& aElt,
+nsGlobalWindowInner::GetDefaultComputedStyle(Element& aElt,
                                         const nsAString& aPseudoElt,
                                         ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   return GetComputedStyleHelper(aElt, aPseudoElt, true, aError);
 }
 
 nsresult
-nsGlobalWindow::GetComputedStyleHelper(nsIDOMElement* aElt,
+nsGlobalWindowInner::GetComputedStyleHelper(nsIDOMElement* aElt,
                                        const nsAString& aPseudoElt,
                                        bool aDefaultStylesOnly,
                                        nsIDOMCSSStyleDeclaration** aReturn)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   NS_ENSURE_ARG_POINTER(aReturn);
   *aReturn = nullptr;
@@ -11239,17 +11101,17 @@ nsGlobalWindow::GetComputedStyleHelper(n
   nsCOMPtr<nsIDOMCSSStyleDeclaration> declaration =
     GetComputedStyleHelper(*element, aPseudoElt, aDefaultStylesOnly, rv);
   declaration.forget(aReturn);
 
   return rv.StealNSResult();
 }
 
 already_AddRefed<nsICSSDeclaration>
-nsGlobalWindow::GetComputedStyleHelperOuter(Element& aElt,
+nsGlobalWindowInner::GetComputedStyleHelperOuter(Element& aElt,
                                             const nsAString& aPseudoElt,
                                             bool aDefaultStylesOnly)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return nullptr;
   }
@@ -11281,41 +11143,41 @@ nsGlobalWindow::GetComputedStyleHelperOu
     NS_NewComputedDOMStyle(&aElt, aPseudoElt, presShell,
                            aDefaultStylesOnly ? nsComputedDOMStyle::eDefaultOnly :
                                                 nsComputedDOMStyle::eAll);
 
   return compStyle.forget();
 }
 
 already_AddRefed<nsICSSDeclaration>
-nsGlobalWindow::GetComputedStyleHelper(Element& aElt,
+nsGlobalWindowInner::GetComputedStyleHelper(Element& aElt,
                                        const nsAString& aPseudoElt,
                                        bool aDefaultStylesOnly,
                                        ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetComputedStyleHelperOuter,
                             (aElt, aPseudoElt, aDefaultStylesOnly),
                             aError, nullptr);
 }
 
 Storage*
-nsGlobalWindow::GetSessionStorage(ErrorResult& aError)
+nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   nsIPrincipal *principal = GetPrincipal();
   nsIDocShell* docShell = GetDocShell();
 
   if (!principal || !docShell || !Preferences::GetBool(kStorageEnabled)) {
     return nullptr;
   }
 
   if (mSessionStorage) {
     MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
-            ("nsGlobalWindow %p has %p sessionStorage", this, mSessionStorage.get()));
+            ("nsGlobalWindowInner %p has %p sessionStorage", this, mSessionStorage.get()));
     bool canAccess = principal->Subsumes(mSessionStorage->Principal());
     NS_ASSERTION(canAccess,
                  "This window owned sessionStorage "
                  "that could not be accessed!");
     if (!canAccess) {
       mSessionStorage = nullptr;
     }
   }
@@ -11356,32 +11218,32 @@ nsGlobalWindow::GetSessionStorage(ErrorR
     if (aError.Failed()) {
       return nullptr;
     }
 
     mSessionStorage = static_cast<Storage*>(storage.get());
     MOZ_ASSERT(mSessionStorage);
 
     MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
-            ("nsGlobalWindow %p tried to get a new sessionStorage %p", this, mSessionStorage.get()));
+            ("nsGlobalWindowInner %p tried to get a new sessionStorage %p", this, mSessionStorage.get()));
 
     if (!mSessionStorage) {
       aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
       return nullptr;
     }
   }
 
   MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
-          ("nsGlobalWindow %p returns %p sessionStorage", this, mSessionStorage.get()));
+          ("nsGlobalWindowInner %p returns %p sessionStorage", this, mSessionStorage.get()));
 
   return mSessionStorage;
 }
 
 Storage*
-nsGlobalWindow::GetLocalStorage(ErrorResult& aError)
+nsGlobalWindowInner::GetLocalStorage(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!Preferences::GetBool(kStorageEnabled)) {
     return nullptr;
   }
 
   if (!mLocalStorage) {
@@ -11423,34 +11285,34 @@ nsGlobalWindow::GetLocalStorage(ErrorRes
     mLocalStorage = static_cast<Storage*>(storage.get());
     MOZ_ASSERT(mLocalStorage);
   }
 
   return mLocalStorage;
 }
 
 IDBFactory*
-nsGlobalWindow::GetIndexedDB(ErrorResult& aError)
+nsGlobalWindowInner::GetIndexedDB(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
   if (!mIndexedDB) {
     // This may keep mIndexedDB null without setting an error.
     aError = IDBFactory::CreateForWindow(AsInner(),
                                          getter_AddRefs(mIndexedDB));
   }
 
   return mIndexedDB;
 }
 
 //*****************************************************************************
-// nsGlobalWindow::nsIInterfaceRequestor
+// nsGlobalWindowInner::nsIInterfaceRequestor
 //*****************************************************************************
 
 NS_IMETHODIMP
-nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink)
+nsGlobalWindowInner::GetInterface(const nsIID & aIID, void **aSink)
 {
   NS_ENSURE_ARG_POINTER(aSink);
   *aSink = nullptr;
 
   if (aIID.Equals(NS_GET_IID(nsIDocCharset))) {
     nsGlobalWindowOuter* outer = GetOuterWindowInternal();
     NS_ENSURE_TRUE(outer, NS_ERROR_NOT_INITIALIZED);
 
@@ -11508,26 +11370,26 @@ nsGlobalWindow::GetInterface(const nsIID
   else {
     return QueryInterface(aIID, aSink);
   }
 
   return *aSink ? NS_OK : NS_ERROR_NO_INTERFACE;
 }
 
 void
-nsGlobalWindow::GetInterface(JSContext* aCx, nsIJSID* aIID,
+nsGlobalWindowInner::GetInterface(JSContext* aCx, nsIJSID* aIID,
                              JS::MutableHandle<JS::Value> aRetval,
                              ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
   dom::GetInterface(aCx, this, aIID, aRetval, aError);
 }
 
 already_AddRefed<CacheStorage>
-nsGlobalWindow::GetCaches(ErrorResult& aRv)
+nsGlobalWindowInner::GetCaches(ErrorResult& aRv)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (!mCacheStorage) {
     bool forceTrustedOrigin =
       GetOuterWindow()->GetServiceWorkersTestingEnabled();
 
     nsContentUtils::StorageAccess access =
@@ -11562,17 +11424,17 @@ nsPIDOMWindowInner::GetServiceWorkerRegi
 
 void
 nsPIDOMWindowInner::InvalidateServiceWorkerRegistration(const nsAString& aScope)
 {
   mServiceWorkerRegistrationTable.Remove(aScope);
 }
 
 void
-nsGlobalWindow::FireOfflineStatusEventIfChanged()
+nsGlobalWindowInner::FireOfflineStatusEventIfChanged()
 {
   if (!AsInner()->IsCurrentInnerWindow())
     return;
 
   // Don't fire an event if the status hasn't changed
   if (mWasOffline == NS_IsOffline()) {
     return;
   }
@@ -11630,34 +11492,34 @@ private:
   uint32_t mTimeInS;
   RefPtr<nsGlobalWindowInner> mIdleWindow;
 
   // If false then call on active
   bool mCallOnidle;
 };
 
 void
-nsGlobalWindow::NotifyIdleObserver(IdleObserverHolder* aIdleObserverHolder,
+nsGlobalWindowInner::NotifyIdleObserver(IdleObserverHolder* aIdleObserverHolder,
                                    bool aCallOnidle)
 {
   MOZ_ASSERT(IsInnerWindow());
   MOZ_ASSERT(aIdleObserverHolder);
   aIdleObserverHolder->mPrevNotificationIdle = aCallOnidle;
 
   nsCOMPtr<nsIRunnable> caller =
     new NotifyIdleObserverRunnable(aIdleObserverHolder->mIdleObserver,
                                    aIdleObserverHolder->mTimeInS,
                                    aCallOnidle, AssertInner());
   if (NS_FAILED(Dispatch(TaskCategory::Other, caller.forget()))) {
     NS_WARNING("Failed to dispatch thread for idle observer notification.");
   }
 }
 
 bool
-nsGlobalWindow::ContainsIdleObserver(nsIIdleObserver* aIdleObserver, uint32_t aTimeInS)
+nsGlobalWindowInner::ContainsIdleObserver(nsIIdleObserver* aIdleObserver, uint32_t aTimeInS)
 {
   MOZ_ASSERT(aIdleObserver, "Idle observer not instantiated.");
   bool found = false;
   nsTObserverArray<IdleObserverHolder>::ForwardIterator iter(mIdleObservers);
   while (iter.HasMore()) {
     IdleObserverHolder& idleObserver = iter.GetNext();
     if (idleObserver.mIdleObserver == aIdleObserver &&
         idleObserver.mTimeInS == aTimeInS) {
@@ -11682,31 +11544,31 @@ IdleObserverTimerCallback(nsITimer* aTim
 {
   RefPtr<nsGlobalWindowInner> idleWindow =
     static_cast<nsGlobalWindowInner*>(aClosure);
   MOZ_ASSERT(idleWindow, "Idle window has not been instantiated.");
   idleWindow->HandleIdleObserverCallback();
 }
 
 void
-nsGlobalWindow::HandleIdleObserverCallback()
+nsGlobalWindowInner::HandleIdleObserverCallback()
 {
   MOZ_ASSERT(IsInnerWindow(), "Must be an inner window!");
   MOZ_ASSERT(static_cast<uint32_t>(mIdleCallbackIndex) < mIdleObservers.Length(),
                                   "Idle callback index exceeds array bounds!");
   IdleObserverHolder& idleObserver = mIdleObservers.ElementAt(mIdleCallbackIndex);
   NotifyIdleObserver(&idleObserver, true);
   mIdleCallbackIndex++;
   if (NS_FAILED(ScheduleNextIdleObserverCallback())) {
     NS_WARNING("Failed to set next idle observer callback.");
   }
 }
 
 nsresult
-nsGlobalWindow::ScheduleNextIdleObserverCallback()
+nsGlobalWindowInner::ScheduleNextIdleObserverCallback()
 {
   MOZ_ASSERT(IsInnerWindow(), "Must be an inner window!");
   MOZ_ASSERT(mIdleService, "No idle service!");
 
   if (mIdleCallbackIndex < 0 ||
       static_cast<uint32_t>(mIdleCallbackIndex) >= mIdleObservers.Length()) {
     return NS_OK;
   }
@@ -11724,24 +11586,24 @@ nsGlobalWindow::ScheduleNextIdleObserver
   }
 
   mIdleTimer->Cancel();
   rv = mIdleTimer->InitWithNamedFuncCallback(
     IdleObserverTimerCallback,
     AssertInner(),
     callbackTimeMS,
     nsITimer::TYPE_ONE_SHOT,
-    "nsGlobalWindow::ScheduleNextIdleObserverCallback");
+    "nsGlobalWindowInner::ScheduleNextIdleObserverCallback");
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 uint32_t
-nsGlobalWindow::GetFuzzTimeMS()
+nsGlobalWindowInner::GetFuzzTimeMS()
 {
   MOZ_ASSERT(IsInnerWindow(), "Must be an inner window!");
 
   if (gIdleObserversAPIFuzzTimeDisabled) {
     return 0;
   }
 
   uint32_t randNum = MAX_IDLE_FUZZ_TIME_MS;
@@ -11754,40 +11616,40 @@ nsGlobalWindow::GetFuzzTimeMS()
   if (randNum > MAX_IDLE_FUZZ_TIME_MS) {
     randNum %= MAX_IDLE_FUZZ_TIME_MS;
   }
 
   return randNum;
 }
 
 nsresult
-nsGlobalWindow::ScheduleActiveTimerCallback()
+nsGlobalWindowInner::ScheduleActiveTimerCallback()
 {
   MOZ_ASSERT(IsInnerWindow(), "Must be an inner window!");
 
   if (!mAddActiveEventFuzzTime) {
     return HandleIdleActiveEvent();
   }
 
   MOZ_ASSERT(mIdleTimer);
   mIdleTimer->Cancel();
 
   uint32_t fuzzFactorInMS = GetFuzzTimeMS();
   nsresult rv = mIdleTimer->InitWithNamedFuncCallback(
     IdleActiveTimerCallback,
     AssertInner(),
     fuzzFactorInMS,
     nsITimer::TYPE_ONE_SHOT,
-    "nsGlobalWindow::ScheduleActiveTimerCallback");
+    "nsGlobalWindowInner::ScheduleActiveTimerCallback");
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
 nsresult
-nsGlobalWindow::HandleIdleActiveEvent()
+nsGlobalWindowInner::HandleIdleActiveEvent()
 {
   MOZ_ASSERT(IsInnerWindow(), "Must be an inner window!");
 
   if (mCurrentlyIdle) {
     mIdleCallbackIndex = 0;
     mIdleFuzzFactor = GetFuzzTimeMS();
     nsresult rv = ScheduleNextIdleObserverCallback();
     NS_ENSURE_SUCCESS(rv, rv);
@@ -11803,18 +11665,18 @@ nsGlobalWindow::HandleIdleActiveEvent()
     if (idleObserver.mPrevNotificationIdle) {
       NotifyIdleObserver(&idleObserver, false);
     }
   }
 
   return NS_OK;
 }
 
-nsGlobalWindow::SlowScriptResponse
-nsGlobalWindow::ShowSlowScriptDialog(const nsString& aAddonId)
+nsGlobalWindowInner::SlowScriptResponse
+nsGlobalWindowInner::ShowSlowScriptDialog(const nsString& aAddonId)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   nsresult rv;
   AutoJSContext cx;
 
   if (Preferences::GetBool("dom.always_stop_slow_scripts")) {
     return KillSlowScript;
@@ -12039,17 +11901,17 @@ nsGlobalWindow::ShowSlowScriptDialog(con
   JS_ClearPendingException(cx);
 
   if (checkboxValue && isAddonScript)
     return KillScriptGlobal;
   return KillSlowScript;
 }
 
 uint32_t
-nsGlobalWindow::FindInsertionIndex(IdleObserverHolder* aIdleObserver)
+nsGlobalWindowInner::FindInsertionIndex(IdleObserverHolder* aIdleObserver)
 {
   MOZ_ASSERT(IsInnerWindow());
   MOZ_ASSERT(aIdleObserver, "Idle observer not instantiated.");
 
   uint32_t i = 0;
   nsTObserverArray<IdleObserverHolder>::ForwardIterator iter(mIdleObservers);
   while (iter.HasMore()) {
     IdleObserverHolder& idleObserver = iter.GetNext();
@@ -12059,17 +11921,17 @@ nsGlobalWindow::FindInsertionIndex(IdleO
     i++;
     MOZ_ASSERT(i <= mIdleObservers.Length(), "Array index out of bounds error.");
   }
 
   return i;
 }
 
 nsresult
-nsGlobalWindow::RegisterIdleObserver(nsIIdleObserver* aIdleObserver)
+nsGlobalWindowInner::RegisterIdleObserver(nsIIdleObserver* aIdleObserver)
 {
   MOZ_ASSERT(IsInnerWindow(), "Must be an inner window!");
 
   nsresult rv;
   if (mIdleObservers.IsEmpty()) {
     mIdleService = do_GetService("@mozilla.org/widget/idleservice;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -12130,17 +11992,17 @@ nsGlobalWindow::RegisterIdleObserver(nsI
     mIdleTimer->Cancel();
     rv = ScheduleNextIdleObserverCallback();
     NS_ENSURE_SUCCESS(rv, rv);
   }
   return NS_OK;
 }
 
 nsresult
-nsGlobalWindow::FindIndexOfElementToRemove(nsIIdleObserver* aIdleObserver,
+nsGlobalWindowInner::FindIndexOfElementToRemove(nsIIdleObserver* aIdleObserver,
                                            int32_t* aRemoveElementIndex)
 {
   MOZ_ASSERT(IsInnerWindow(), "Must be an inner window!");
   MOZ_ASSERT(aIdleObserver, "Idle observer not instantiated.");
 
   *aRemoveElementIndex = 0;
   if (mIdleObservers.IsEmpty()) {
     return NS_ERROR_FAILURE;
@@ -12160,17 +12022,17 @@ nsGlobalWindow::FindIndexOfElementToRemo
     }
     (*aRemoveElementIndex)++;
   }
   return static_cast<uint32_t>(*aRemoveElementIndex) >= mIdleObservers.Length() ?
     NS_ERROR_FAILURE : NS_OK;
 }
 
 nsresult
-nsGlobalWindow::UnregisterIdleObserver(nsIIdleObserver* aIdleObserver)
+nsGlobalWindowInner::UnregisterIdleObserver(nsIIdleObserver* aIdleObserver)
 {
   MOZ_ASSERT(IsInnerWindow(), "Must be an inner window!");
 
   int32_t removeElementIndex;
   nsresult rv = FindIndexOfElementToRemove(aIdleObserver, &removeElementIndex);
   if (NS_FAILED(rv)) {
     NS_WARNING("Idle observer not found in list of idle observers. No idle observer removed.");
     return NS_OK;
@@ -12216,17 +12078,17 @@ nsGlobalWindow::UnregisterIdleObserver(n
   }
   rv = ScheduleNextIdleObserverCallback();
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 nsresult
-nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
+nsGlobalWindowInner::Observe(nsISupports* aSubject, const char* aTopic,
                         const char16_t* aData)
 {
   if (!nsCRT::strcmp(aTopic, NS_IOSERVICE_OFFLINE_STATUS_TOPIC)) {
     if (!IsFrozen()) {
         // Fires an offline status event if the offline status has changed
         FireOfflineStatusEventIfChanged();
     }
     return NS_OK;
@@ -12302,22 +12164,22 @@ nsGlobalWindow::Observe(nsISupports* aSu
     RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
     event->InitEvent(NS_LITERAL_STRING("languagechange"), false, false);
     event->SetTrusted(true);
 
     bool dummy;
     return DispatchEvent(event, &dummy);
   }
 
-  NS_WARNING("unrecognized topic in nsGlobalWindow::Observe");
+  NS_WARNING("unrecognized topic in nsGlobalWindowInner::Observe");
   return NS_ERROR_FAILURE;
 }
 
 void
-nsGlobalWindow::ObserveStorageNotification(StorageEvent* aEvent,
+nsGlobalWindowInner::ObserveStorageNotification(StorageEvent* aEvent,
                                            const char16_t* aStorageType,
                                            bool aPrivateBrowsing)
 {
   MOZ_ASSERT(aEvent);
 
   // The private browsing check must be done here again because this window
   // could have changed its state before the notification check and now. This
   // happens in case this window did have a docShell at that time.
@@ -12359,17 +12221,17 @@ nsGlobalWindow::ObserveStorageNotificati
 
     if (!check) {
       // This storage event is not coming from our storage or is coming
       // from a different docshell, i.e. it is a clone, ignore this event.
       return;
     }
 
     MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
-            ("nsGlobalWindow %p with sessionStorage %p passing event from %p",
+            ("nsGlobalWindowInner %p with sessionStorage %p passing event from %p",
              this, mSessionStorage.get(), changingStorage.get()));
 
     fireMozStorageChanged = mSessionStorage == changingStorage;
     if (fireMozStorageChanged) {
       eventType.AssignLiteral("MozSessionStorageChanged");
     }
   }
 
@@ -12402,17 +12264,17 @@ nsGlobalWindow::ObserveStorageNotificati
     internalEvent->mFlags.mOnlyChromeDispatch = true;
   }
 
   bool defaultActionEnabled;
   DispatchEvent(clonedEvent, &defaultActionEnabled);
 }
 
 already_AddRefed<StorageEvent>
-nsGlobalWindow::CloneStorageEvent(const nsAString& aType,
+nsGlobalWindowInner::CloneStorageEvent(const nsAString& aType,
                                   const RefPtr<StorageEvent>& aEvent,
                                   ErrorResult& aRv)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   StorageEventInit dict;
 
   dict.mBubbles = aEvent->Bubbles();
@@ -12455,17 +12317,17 @@ nsGlobalWindow::CloneStorageEvent(const 
 
   dict.mStorageArea = storage;
 
   RefPtr<StorageEvent> event = StorageEvent::Constructor(this, aType, dict);
   return event.forget();
 }
 
 void
-nsGlobalWindow::Suspend()
+nsGlobalWindowInner::Suspend()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(IsInnerWindow());
 
   // We can only safely suspend windows that are the current inner window.  If
   // its not the current inner, then we are in one of two different cases.
   // Either we are in the bfcache or we are doomed window that is going away.
   // When a window becomes inactive we purposely avoid placing already suspended
@@ -12475,17 +12337,17 @@ nsGlobalWindow::Suspend()
   // invariant will be broken.  If the window is doomed there is no point in
   // suspending it since it will soon be gone.
   if (!AsInner()->IsCurrentInnerWindow()) {
     return;
   }
 
   // All children are also suspended.  This ensure mSuspendDepth is
   // set properly and the timers are properly canceled for each child.
-  CallOnChildren(&nsGlobalWindow::Suspend);
+  CallOnChildren(&nsGlobalWindowInner::Suspend);
 
   mSuspendDepth += 1;
   if (mSuspendDepth != 1) {
     return;
   }
 
   nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
   if (ac) {
@@ -12504,34 +12366,34 @@ nsGlobalWindow::Suspend()
   // Suspend all of the AudioContexts for this window
   for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
     ErrorResult dummy;
     RefPtr<Promise> d = mAudioContexts[i]->Suspend(dummy);
   }
 }
 
 void
-nsGlobalWindow::Resume()
+nsGlobalWindowInner::Resume()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(IsInnerWindow());
 
   // We can only safely resume a window if its the current inner window.  If
   // its not the current inner, then we are in one of two different cases.
   // Either we are in the bfcache or we are doomed window that is going away.
   // If a window is suspended when it becomes inactive we purposely do not
   // put it in the bfcache, so Resume should never be needed in that case.
   // If the window is doomed then there is no point in resuming it.
   if (!AsInner()->IsCurrentInnerWindow()) {
     return;
   }
 
   // Resume all children.  This restores timers recursively canceled
   // in Suspend() and ensures all children have the correct mSuspendDepth.
-  CallOnChildren(&nsGlobalWindow::Resume);
+  CallOnChildren(&nsGlobalWindowInner::Resume);
 
   MOZ_ASSERT(mSuspendDepth != 0);
   mSuspendDepth -= 1;
   if (mSuspendDepth != 0) {
     return;
   }
 
   // We should not be able to resume a frozen window.  It must be Thaw()'d first.
@@ -12557,46 +12419,46 @@ nsGlobalWindow::Resume()
 
   // Resume all of the workers for this window.  We must do this
   // after timeouts since workers may have queued events that can trigger
   // a setTimeout().
   mozilla::dom::workers::ResumeWorkersForWindow(AsInner());
 }
 
 bool
-nsGlobalWindow::IsSuspended() const
+nsGlobalWindowInner::IsSuspended() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   // No inner means we are effectively suspended
   if (IsOuterWindow()) {
     if (!mInnerWindow) {
       return true;
     }
     return mInnerWindow->IsSuspended();
   }
   return mSuspendDepth != 0;
 }
 
 void
-nsGlobalWindow::Freeze()
+nsGlobalWindowInner::Freeze()
 {
   MOZ_ASSERT(NS_IsMainThread());
   Suspend();
   FreezeInternal();
 }
 
 void
-nsGlobalWindow::FreezeInternal()
+nsGlobalWindowInner::FreezeInternal()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(IsInnerWindow());
   MOZ_DIAGNOSTIC_ASSERT(AsInner()->IsCurrentInnerWindow());
   MOZ_DIAGNOSTIC_ASSERT(IsSuspended());
 
-  CallOnChildren(&nsGlobalWindow::FreezeInternal);
+  CallOnChildren(&nsGlobalWindowInner::FreezeInternal);
 
   mFreezeDepth += 1;
   MOZ_ASSERT(mSuspendDepth >= mFreezeDepth);
   if (mFreezeDepth != 1) {
     return;
   }
 
   mozilla::dom::workers::FreezeWorkersForWindow(AsInner());
@@ -12604,32 +12466,32 @@ nsGlobalWindow::FreezeInternal()
   mTimeoutManager->Freeze();
 
   if (IsInnerWindow()) {
     NotifyDOMWindowFrozen(AssertInner());
   }
 }
 
 void
-nsGlobalWindow::Thaw()
+nsGlobalWindowInner::Thaw()
 {
   MOZ_ASSERT(NS_IsMainThread());
   ThawInternal();
   Resume();
 }
 
 void
-nsGlobalWindow::ThawInternal()
+nsGlobalWindowInner::ThawInternal()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(IsInnerWindow());
   MOZ_DIAGNOSTIC_ASSERT(AsInner()->IsCurrentInnerWindow());
   MOZ_DIAGNOSTIC_ASSERT(IsSuspended());
 
-  CallOnChildren(&nsGlobalWindow::ThawInternal);
+  CallOnChildren(&nsGlobalWindowInner::ThawInternal);
 
   MOZ_ASSERT(mFreezeDepth != 0);
   mFreezeDepth -= 1;
   MOZ_ASSERT(mSuspendDepth >= mFreezeDepth);
   if (mFreezeDepth != 0) {
     return;
   }
 
@@ -12638,33 +12500,33 @@ nsGlobalWindow::ThawInternal()
   mozilla::dom::workers::ThawWorkersForWindow(AsInner());
 
   if (IsInnerWindow()) {
     NotifyDOMWindowThawed(AssertInner());
   }
 }
 
 bool
-nsGlobalWindow::IsFrozen() const
+nsGlobalWindowInner::IsFrozen() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   // No inner means we are effectively frozen
   if (IsOuterWindow()) {
     if (!mInnerWindow) {
       return true;
     }
     return mInnerWindow->IsFrozen();
   }
   bool frozen = mFreezeDepth != 0;
   MOZ_ASSERT_IF(frozen, IsSuspended());
   return frozen;
 }
 
 void
-nsGlobalWindow::SyncStateFromParentWindow()
+nsGlobalWindowInner::SyncStateFromParentWindow()
 {
   // This method should only be called on an inner window that has been
   // assigned to an outer window already.
   MOZ_ASSERT(IsInnerWindow());
   MOZ_ASSERT(AsInner()->IsCurrentInnerWindow());
   nsPIDOMWindowOuter* outer = GetOuterWindow();
   MOZ_ASSERT(outer);
 
@@ -12700,17 +12562,17 @@ nsGlobalWindow::SyncStateFromParentWindo
   // suspend count after applying the Freeze() calls.
   for (uint32_t i = 0; i < (parentSuspendDepth - parentFreezeDepth); ++i) {
     Suspend();
   }
 }
 
 template<typename Method>
 void
-nsGlobalWindow::CallOnChildren(Method aMethod)
+nsGlobalWindowInner::CallOnChildren(Method aMethod)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(IsInnerWindow());
   MOZ_ASSERT(AsInner()->IsCurrentInnerWindow());
 
   nsCOMPtr<nsIDocShell> docShell = GetDocShell();
   if (!docShell) {
     return;
@@ -12739,17 +12601,17 @@ nsGlobalWindow::CallOnChildren(Method aM
       continue;
     }
 
     (inner->*aMethod)();
   }
 }
 
 nsresult
-nsGlobalWindow::FireDelayedDOMEvents()
+nsGlobalWindowInner::FireDelayedDOMEvents()
 {
   FORWARD_TO_INNER(FireDelayedDOMEvents, (), NS_ERROR_UNEXPECTED);
 
   if (mApplicationCache) {
     static_cast<nsDOMOfflineResourceList*>(mApplicationCache.get())->FirePendingEvents();
   }
 
   // Fires an offline status event if the offline status has changed
@@ -12781,21 +12643,21 @@ nsGlobalWindow::FireDelayedDOMEvents()
       }
     }
   }
 
   return NS_OK;
 }
 
 //*****************************************************************************
-// nsGlobalWindow: Window Control Functions
+// nsGlobalWindowInner: Window Control Functions
 //*****************************************************************************
 
 nsPIDOMWindowOuter*
-nsGlobalWindow::GetParentInternal()
+nsGlobalWindowInner::GetParentInternal()
 {
   if (IsInnerWindow()) {
     nsGlobalWindowOuter* outer = GetOuterWindowInternal();
     if (!outer) {
       // No outer window available!
       return nullptr;
     }
     return outer->GetParentInternal();
@@ -12806,17 +12668,17 @@ nsGlobalWindow::GetParentInternal()
   if (parent && parent != AsOuter()) {
     return parent;
   }
 
   return nullptr;
 }
 
 void
-nsGlobalWindow::UnblockScriptedClosing()
+nsGlobalWindowInner::UnblockScriptedClosing()
 {
   MOZ_ASSERT(IsOuterWindow());
   mBlockScriptedClosingFlag = false;
 }
 
 class AutoUnblockScriptClosing
 {
 private:
@@ -12825,25 +12687,25 @@ public:
   explicit AutoUnblockScriptClosing(nsGlobalWindowOuter* aWin)
     : mWin(aWin)
   {
     MOZ_ASSERT(mWin);
     MOZ_ASSERT(mWin->IsOuterWindow());
   }
   ~AutoUnblockScriptClosing()
   {
-    void (nsGlobalWindow::*run)() = &nsGlobalWindow::UnblockScriptedClosing;
+    void (nsGlobalWindowOuter::*run)() = &nsGlobalWindowOuter::UnblockScriptedClosing;
     nsCOMPtr<nsIRunnable> caller = NewRunnableMethod(
       "AutoUnblockScriptClosing::~AutoUnblockScriptClosing", mWin, run);
     mWin->Dispatch(TaskCategory::Other, caller.forget());
   }
 };
 
 nsresult
-nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
+nsGlobalWindowInner::OpenInternal(const nsAString& aUrl, const nsAString& aName,
                              const nsAString& aOptions, bool aDialog,
                              bool aContentModal, bool aCalledNoScript,
                              bool aDoJSFixups, bool aNavigate,
                              nsIArray *argv,
                              nsISupports *aExtraArgument,
                              nsIDocShellLoadInfo* aLoadInfo,
                              bool aForceNoOpener,
                              nsPIDOMWindowOuter **aReturn)
@@ -13038,21 +12900,21 @@ nsGlobalWindow::OpenInternal(const nsASt
       Unused << doc;
     }
   }
 
   return rv;
 }
 
 //*****************************************************************************
-// nsGlobalWindow: Timeout Functions
+// nsGlobalWindowInner: Timeout Functions
 //*****************************************************************************
 
 nsGlobalWindowInner*
-nsGlobalWindow::InnerForSetTimeoutOrInterval(ErrorResult& aError)
+nsGlobalWindowInner::InnerForSetTimeoutOrInterval(ErrorResult& aError)
 {
   nsGlobalWindowInner* currentInner;
   nsGlobalWindowInner* forwardTo;
   if (IsInnerWindow()) {
     nsGlobalWindowOuter* outer = GetOuterWindowInternal();
     currentInner = outer ? outer->GetCurrentInnerWindowInternal() : AssertInner();
 
     forwardTo = AssertInner();
@@ -13092,27 +12954,27 @@ nsGlobalWindow::InnerForSetTimeoutOrInte
 
   // If forwardTo is not the window with an active document then we want the
   // call to setTimeout/Interval to be a noop, so return null but don't set an
   // error.
   return forwardTo->AsInner()->HasActiveDocument() ? currentInner : nullptr;
 }
 
 int32_t
-nsGlobalWindow::SetTimeout(JSContext* aCx, Function& aFunction,
+nsGlobalWindowInner::SetTimeout(JSContext* aCx, Function& aFunction,
                            int32_t aTimeout,
                            const Sequence<JS::Value>& aArguments,
                            ErrorResult& aError)
 {
   return SetTimeoutOrInterval(aCx, aFunction, aTimeout, aArguments, false,
                               aError);
 }
 
 int32_t
-nsGlobalWindow::SetTimeout(JSContext* aCx, const nsAString& aHandler,
+nsGlobalWindowInner::SetTimeout(JSContext* aCx, const nsAString& aHandler,
                            int32_t aTimeout,
                            const Sequence<JS::Value>& /* unused */,
                            ErrorResult& aError)
 {
   return SetTimeoutOrInterval(aCx, aHandler, aTimeout, false, aError);
 }
 
 static bool
@@ -13125,40 +12987,40 @@ IsInterval(const Optional<int32_t>& aTim
 
   // If no interval was specified, treat this like a timeout, to avoid setting
   // an interval of 0 milliseconds.
   aResultTimeout = 0;
   return false;
 }
 
 int32_t
-nsGlobalWindow::SetInterval(JSContext* aCx, Function& aFunction,
+nsGlobalWindowInner::SetInterval(JSContext* aCx, Function& aFunction,
                             const Optional<int32_t>& aTimeout,
                             const Sequence<JS::Value>& aArguments,
                             ErrorResult& aError)
 {
   int32_t timeout;
   bool isInterval = IsInterval(aTimeout, timeout);
   return SetTimeoutOrInterval(aCx, aFunction, timeout, aArguments, isInterval,
                               aError);
 }
 
 int32_t
-nsGlobalWindow::SetInterval(JSContext* aCx, const nsAString& aHandler,
+nsGlobalWindowInner::SetInterval(JSContext* aCx, const nsAString& aHandler,
                             const Optional<int32_t>& aTimeout,
                             const Sequence<JS::Value>& /* unused */,
                             ErrorResult& aError)
 {
   int32_t timeout;
   bool isInterval = IsInterval(aTimeout, timeout);
   return SetTimeoutOrInterval(aCx, aHandler, timeout, isInterval, aError);
 }
 
 int32_t
-nsGlobalWindow::SetTimeoutOrInterval(JSContext *aCx, Function& aFunction,
+nsGlobalWindowInner::SetTimeoutOrInterval(JSContext *aCx, Function& aFunction,
                                      int32_t aTimeout,
                                      const Sequence<JS::Value>& aArguments,
                                      bool aIsInterval, ErrorResult& aError)
 {
   nsGlobalWindowInner* inner = InnerForSetTimeoutOrInterval(aError);
   if (!inner) {
     return -1;
   }
@@ -13177,17 +13039,17 @@ nsGlobalWindow::SetTimeoutOrInterval(JSC
   int32_t result;
   aError = mTimeoutManager->SetTimeout(handler, aTimeout, aIsInterval,
                                       Timeout::Reason::eTimeoutOrInterval,
                                       &result);
   return result;
 }
 
 int32_t
-nsGlobalWindow::SetTimeoutOrInterval(JSContext* aCx, const nsAString& aHandler,
+nsGlobalWindowInner::SetTimeoutOrInterval(JSContext* aCx, const nsAString& aHandler,
                                      int32_t aTimeout, bool aIsInterval,
                                      ErrorResult& aError)
 {
   nsGlobalWindowInner* inner = InnerForSetTimeoutOrInterval(aError);
   if (!inner) {
     return -1;
   }
 
@@ -13205,17 +13067,17 @@ nsGlobalWindow::SetTimeoutOrInterval(JSC
   int32_t result;
   aError = mTimeoutManager->SetTimeout(handler, aTimeout, aIsInterval,
                                       Timeout::Reason::eTimeoutOrInterval,
                                       &result);
   return result;
 }
 
 bool
-nsGlobalWindow::RunTimeoutHandler(Timeout* aTimeout,
+nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
                                   nsIScriptContext* aScx)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   // Hold on to the timeout in case mExpr or mFunObj releases its
   // doc.
   RefPtr<Timeout> timeout = aTimeout;
   Timeout* last_running_timeout = mTimeoutManager->BeginRunningTimeout(timeout);
@@ -13325,38 +13187,38 @@ nsGlobalWindow::RunTimeoutHandler(Timeou
 
   mTimeoutManager->EndRunningTimeout(last_running_timeout);
   timeout->mRunning = false;
 
   return timeout->mCleared;
 }
 
 //*****************************************************************************
-// nsGlobalWindow: Helper Functions
+// nsGlobalWindowInner: Helper Functions
 //*****************************************************************************
 
 already_AddRefed<nsIDocShellTreeOwner>
-nsGlobalWindow::GetTreeOwner()
+nsGlobalWindowInner::GetTreeOwner()
 {
   FORWARD_TO_OUTER(GetTreeOwner, (), nullptr);
 
   // If there's no docShellAsItem, this window must have been closed,
   // in that case there is no tree owner.
 
   if (!mDocShell) {
     return nullptr;
   }
 
   nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
   mDocShell->GetTreeOwner(getter_AddRefs(treeOwner));
   return treeOwner.forget();
 }
 
 already_AddRefed<nsIBaseWindow>
-nsGlobalWindow::GetTreeOwnerWindow()
+nsGlobalWindowInner::GetTreeOwnerWindow()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
 
   // If there's no mDocShell, this window must have been closed,
   // in that case there is no tree owner.
 
@@ -13364,42 +13226,42 @@ nsGlobalWindow::GetTreeOwnerWindow()
     mDocShell->GetTreeOwner(getter_AddRefs(treeOwner));
   }
 
   nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(treeOwner);
   return baseWindow.forget();
 }
 
 already_AddRefed<nsIWebBrowserChrome>
-nsGlobalWindow::GetWebBrowserChrome()
+nsGlobalWindowInner::GetWebBrowserChrome()
 {
   nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
 
   nsCOMPtr<nsIWebBrowserChrome> browserChrome = do_GetInterface(treeOwner);
   return browserChrome.forget();
 }
 
 nsIScrollableFrame *
-nsGlobalWindow::GetScrollFrame()
+nsGlobalWindowInner::GetScrollFrame()
 {
   FORWARD_TO_OUTER(GetScrollFrame, (), nullptr);
 
   if (!mDocShell) {
     return nullptr;
   }
 
   nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
   if (presShell) {
     return presShell->GetRootScrollFrameAsScrollable();
   }
   return nullptr;
 }
 
 nsresult
-nsGlobalWindow::SecurityCheckURL(const char *aURL)
+nsGlobalWindowInner::SecurityCheckURL(const char *aURL)
 {
   nsCOMPtr<nsPIDOMWindowInner> sourceWindow = do_QueryInterface(GetEntryGlobal());
   if (!sourceWindow) {
     sourceWindow = AsOuter()->GetCurrentInnerWindow();
   }
   AutoJSContext cx;
   nsGlobalWindowInner* sourceWin = nsGlobalWindowInner::Cast(sourceWindow);
   JSAutoCompartment ac(cx, sourceWin->GetGlobalJSObject());
@@ -13426,46 +13288,46 @@ nsGlobalWindow::SecurityCheckURL(const c
         CheckLoadURIFromScript(cx, uri))) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 bool
-nsGlobalWindow::IsPrivateBrowsing()
+nsGlobalWindowInner::IsPrivateBrowsing()
 {
   nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(GetDocShell());
   return loadContext && loadContext->UsePrivateBrowsing();
 }
 
 void
-nsGlobalWindow::FlushPendingNotifications(FlushType aType)
+nsGlobalWindowInner::FlushPendingNotifications(FlushType aType)
 {
   if (mDoc) {
     mDoc->FlushPendingNotifications(aType);
   }
 }
 
 void
-nsGlobalWindow::EnsureSizeAndPositionUpToDate()
+nsGlobalWindowInner::EnsureSizeAndPositionUpToDate()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   // If we're a subframe, make sure our size is up to date.  It's OK that this
   // crosses the content/chrome boundary, since chrome can have pending reflows
   // too.
   nsGlobalWindowOuter *parent = nsGlobalWindowOuter::Cast(GetPrivateParent());
   if (parent) {
     parent->FlushPendingNotifications(FlushType::Layout);
   }
 }
 
 already_AddRefed<nsISupports>
-nsGlobalWindow::SaveWindowState()
+nsGlobalWindowInner::SaveWindowState()
 {
   NS_PRECONDITION(IsOuterWindow(), "Can't save the inner window's state");
 
   if (!mContext || !GetWrapperPreserveColor()) {
     // The window may be getting torn down; don't bother saving state.
     return nullptr;
   }
 
@@ -13484,17 +13346,17 @@ nsGlobalWindow::SaveWindowState()
 #ifdef DEBUG_PAGE_CACHE
   printf("saving window state, state = %p\n", (void*)state);
 #endif
 
   return state.forget();
 }
 
 nsresult
-nsGlobalWindow::RestoreWindowState(nsISupports *aState)
+nsGlobalWindowInner::RestoreWindowState(nsISupports *aState)
 {
   NS_ASSERTION(IsOuterWindow(), "Cannot restore an inner window");
 
   if (!mContext || !GetWrapperPreserveColor()) {
     // The window may be getting torn down; don't bother restoring state.
     return NS_OK;
   }
 
@@ -13523,17 +13385,17 @@ nsGlobalWindow::RestoreWindowState(nsISu
   inner->Thaw();
 
   holder->DidRestoreWindow();
 
   return NS_OK;
 }
 
 void
-nsGlobalWindow::EnableDeviceSensor(uint32_t aType)
+nsGlobalWindowInner::EnableDeviceSensor(uint32_t aType)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   bool alreadyEnabled = false;
   for (uint32_t i = 0; i < mEnabledSensors.Length(); i++) {
     if (mEnabledSensors[i] == aType) {
       alreadyEnabled = true;
       break;
@@ -13548,17 +13410,17 @@ nsGlobalWindow::EnableDeviceSensor(uint3
 
   nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
   if (ac) {
     ac->AddWindowListener(aType, this);
   }
 }
 
 void
-nsGlobalWindow::DisableDeviceSensor(uint32_t aType)
+nsGlobalWindowInner::DisableDeviceSensor(uint32_t aType)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   int32_t doomedElement = -1;
   int32_t listenerCount = 0;
   for (uint32_t i = 0; i < mEnabledSensors.Length(); i++) {
     if (mEnabledSensors[i] == aType) {
       doomedElement = i;
@@ -13579,48 +13441,48 @@ nsGlobalWindow::DisableDeviceSensor(uint
   nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
   if (ac) {
     ac->RemoveWindowListener(aType, this);
   }
 }
 
 #if defined(MOZ_WIDGET_ANDROID)
 void
-nsGlobalWindow::EnableOrientationChangeListener()
+nsGlobalWindowInner::EnableOrientationChangeListener()
 {
   MOZ_ASSERT(IsInnerWindow());
   if (!nsContentUtils::ShouldResistFingerprinting(mDocShell) &&
       !mOrientationChangeObserver) {
     mOrientationChangeObserver =
       MakeUnique<WindowOrientationObserver>(AssertInner());
   }
 }
 
 void
-nsGlobalWindow::DisableOrientationChangeListener()
+nsGlobalWindowInner::DisableOrientationChangeListener()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   mOrientationChangeObserver = nullptr;
 }
 #endif
 
 void
-nsGlobalWindow::SetHasGamepadEventListener(bool aHasGamepad/* = true*/)
+nsGlobalWindowInner::SetHasGamepadEventListener(bool aHasGamepad/* = true*/)
 {
   MOZ_ASSERT(IsInnerWindow());
   mHasGamepad = aHasGamepad;
   if (aHasGamepad) {
     EnableGamepadUpdates();
   }
 }
 
 
 void
-nsGlobalWindow::EventListenerAdded(nsAtom* aType)
+nsGlobalWindowInner::EventListenerAdded(nsAtom* aType)
 {
   if (aType == nsGkAtoms::onvrdisplayactivate ||
       aType == nsGkAtoms::onvrdisplayconnect ||
       aType == nsGkAtoms::onvrdisplaydeactivate ||
       aType == nsGkAtoms::onvrdisplaydisconnect ||
       aType == nsGkAtoms::onvrdisplaypresentchange) {
     NotifyVREventListenerAdded();
   }
@@ -13642,81 +13504,81 @@ nsGlobalWindow::EventListenerAdded(nsAto
   if (aType == nsGkAtoms::onstorage) {
     ErrorResult rv;
     GetLocalStorage(rv);
     rv.SuppressException();
   }
 }
 
 void
-nsGlobalWindow::EventListenerRemoved(nsAtom* aType)
+nsGlobalWindowInner::EventListenerRemoved(nsAtom* aType)
 {
   if (aType == nsGkAtoms::onbeforeunload &&
       mTabChild &&
       (!mDoc || !(mDoc->GetSandboxFlags() & SANDBOXED_MODALS))) {
     MOZ_ASSERT(IsInnerWindow());
     mBeforeUnloadListenerCount--;
     MOZ_ASSERT(mBeforeUnloadListenerCount >= 0);
     mTabChild->BeforeUnloadRemoved();
   }
 }
 
 void
-nsGlobalWindow::NotifyVREventListenerAdded()
+nsGlobalWindowInner::NotifyVREventListenerAdded()
 {
   MOZ_ASSERT(IsInnerWindow());
   mHasVREvents = true;
   EnableVRUpdates();
 }
 
 bool
-nsGlobalWindow::HasUsedVR() const
+nsGlobalWindowInner::HasUsedVR() const
 {
   MOZ_ASSERT(IsInnerWindow());
 
   // Returns true only if any WebVR API call or related event
   // has been used
   return mHasVREvents;
 }
 
 bool
-nsGlobalWindow::IsVRContentDetected() const
+nsGlobalWindowInner::IsVRContentDetected() const
 {
   MOZ_ASSERT(IsInnerWindow());
 
   // Returns true only if the content will respond to
   // the VRDisplayActivate event.
   return mHasVRDisplayActivateEvents;
 }
 
 bool
-nsGlobalWindow::IsVRContentPresenting() const
+nsGlobalWindowInner::IsVRContentPresenting() const
 {
   for (const auto& display : mVRDisplays) {
     if (display->IsAnyPresenting(gfx::kVRGroupAll)) {
       return true;
     }
   }
   return false;
 }
 
 void
-nsGlobalWindow::EnableTimeChangeNotifications()
+nsGlobalWindowInner::EnableTimeChangeNotifications()
 {
   mozilla::time::AddWindowListener(AsInner());
 }
 
 void
-nsGlobalWindow::DisableTimeChangeNotifications()
+nsGlobalWindowInner::DisableTimeChangeNotifications()
 {
   mozilla::time::RemoveWindowListener(AsInner());
 }
 
 void
-nsGlobalWindow::AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const
+nsGlobalWindowInner::AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const
 {
   aWindowSizes.mDOMOtherSize += aWindowSizes.mState.mMallocSizeOf(this);
 
   if (IsInnerWindow()) {
     EventListenerManager* elm = GetExistingListenerManager();
     if (elm) {
       aWindowSizes.mDOMOtherSize +=
         elm->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
@@ -13759,46 +13621,46 @@ nsGlobalWindow::AddSizeOfIncludingThis(n
     aWindowSizes.mDOMPerformanceUserEntries =
       mPerformance->SizeOfUserEntries(aWindowSizes.mState.mMallocSizeOf);
     aWindowSizes.mDOMPerformanceResourceEntries =
       mPerformance->SizeOfResourceEntries(aWindowSizes.mState.mMallocSizeOf);
   }
 }
 
 void
-nsGlobalWindow::AddGamepad(uint32_t aIndex, Gamepad* aGamepad)
+nsGlobalWindowInner::AddGamepad(uint32_t aIndex, Gamepad* aGamepad)
 {
   MOZ_ASSERT(IsInnerWindow());
   // Create the index we will present to content based on which indices are
   // already taken, as required by the spec.
   // https://w3c.github.io/gamepad/gamepad.html#widl-Gamepad-index
   int index = 0;
   while(mGamepadIndexSet.Contains(index)) {
     ++index;
   }
   mGamepadIndexSet.Put(index);
   aGamepad->SetIndex(index);
   mGamepads.Put(aIndex, aGamepad);
 }
 
 void
-nsGlobalWindow::RemoveGamepad(uint32_t aIndex)
+nsGlobalWindowInner::RemoveGamepad(uint32_t aIndex)
 {
   MOZ_ASSERT(IsInnerWindow());
   RefPtr<Gamepad> gamepad;
   if (!mGamepads.Get(aIndex, getter_AddRefs(gamepad))) {
     return;
   }
   // Free up the index we were using so it can be reused
   mGamepadIndexSet.Remove(gamepad->Index());
   mGamepads.Remove(aIndex);
 }
 
 void
-nsGlobalWindow::GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads)
+nsGlobalWindowInner::GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads)
 {
   MOZ_ASSERT(IsInnerWindow());
   aGamepads.Clear();
 
   // navigator.getGamepads() always returns an empty array when
   // privacy.resistFingerprinting is true.
   if (nsContentUtils::ShouldResistFingerprinting()) {
     return;
@@ -13809,102 +13671,102 @@ nsGlobalWindow::GetGamepads(nsTArray<Ref
   for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {
     Gamepad* gamepad = iter.UserData();
     aGamepads.EnsureLengthAtLeast(gamepad->Index() + 1);
     aGamepads[gamepad->Index()] = gamepad;
   }
 }
 
 already_AddRefed<Gamepad>
-nsGlobalWindow::GetGamepad(uint32_t aIndex)
+nsGlobalWindowInner::GetGamepad(uint32_t aIndex)
 {
   MOZ_ASSERT(IsInnerWindow());
   RefPtr<Gamepad> gamepad;
 
   if (mGamepads.Get(aIndex, getter_AddRefs(gamepad))) {
     return gamepad.forget();
   }
 
   return nullptr;
 }
 
 void
-nsGlobalWindow::SetHasSeenGamepadInput(bool aHasSeen)
+nsGlobalWindowInner::SetHasSeenGamepadInput(bool aHasSeen)
 {
   MOZ_ASSERT(IsInnerWindow());
   mHasSeenGamepadInput = aHasSeen;
 }
 
 bool
-nsGlobalWindow::HasSeenGamepadInput()
+nsGlobalWindowInner::HasSeenGamepadInput()
 {
   MOZ_ASSERT(IsInnerWindow());
   return mHasSeenGamepadInput;
 }
 
 void
-nsGlobalWindow::SyncGamepadState()
+nsGlobalWindowInner::SyncGamepadState()
 {
   MOZ_ASSERT(IsInnerWindow());
   if (mHasSeenGamepadInput) {
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {
       gamepadManager->SyncGamepadState(iter.Key(), iter.UserData());
     }
   }
 }
 
 void
-nsGlobalWindow::StopGamepadHaptics()
+nsGlobalWindowInner::StopGamepadHaptics()
 {
   MOZ_ASSERT(IsInnerWindow());
   if (mHasSeenGamepadInput) {
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     gamepadManager->StopHaptics();
   }
 }
 
 bool
-nsGlobalWindow::UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDevices)
+nsGlobalWindowInner::UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDevices)
 {
   FORWARD_TO_INNER(UpdateVRDisplays, (aDevices), false);
 
   VRDisplay::UpdateVRDisplays(mVRDisplays, AsInner());
   aDevices = mVRDisplays;
   return true;
 }
 
 void
-nsGlobalWindow::NotifyActiveVRDisplaysChanged()
+nsGlobalWindowInner::NotifyActiveVRDisplaysChanged()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mNavigator) {
     mNavigator->NotifyActiveVRDisplaysChanged();
   }
 }
 
 uint32_t
-nsGlobalWindow::GetAutoActivateVRDisplayID()
+nsGlobalWindowInner::GetAutoActivateVRDisplayID()
 {
   MOZ_ASSERT(IsOuterWindow());
   uint32_t retVal = mAutoActivateVRDisplayID;
   mAutoActivateVRDisplayID = 0;
   return retVal;
 }
 
 void
-nsGlobalWindow::SetAutoActivateVRDisplayID(uint32_t aAutoActivateVRDisplayID)
+nsGlobalWindowInner::SetAutoActivateVRDisplayID(uint32_t aAutoActivateVRDisplayID)
 {
   MOZ_ASSERT(IsOuterWindow());
   mAutoActivateVRDisplayID = aAutoActivateVRDisplayID;
 }
 
 void
-nsGlobalWindow::DispatchVRDisplayActivate(uint32_t aDisplayID,
+nsGlobalWindowInner::DispatchVRDisplayActivate(uint32_t aDisplayID,
                                           mozilla::dom::VRDisplayEventReason aReason)
 {
   // Search for the display identified with aDisplayID and fire the
   // event if found.
   for (const auto& display : mVRDisplays) {
     if (display->DisplayId() == aDisplayID) {
       if (aReason != VRDisplayEventReason::Navigation &&
           display->IsAnyPresenting(gfx::kVRGroupContent)) {
@@ -13938,17 +13800,17 @@ nsGlobalWindow::DispatchVRDisplayActivat
       // Once we dispatch the event, we must not access any members as an event
       // listener can do anything, including closing windows.
       return;
     }
   }
 }
 
 void
-nsGlobalWindow::DispatchVRDisplayDeactivate(uint32_t aDisplayID,
+nsGlobalWindowInner::DispatchVRDisplayDeactivate(uint32_t aDisplayID,
                                             mozilla::dom::VRDisplayEventReason aReason)
 {
   // Search for the display identified with aDisplayID and fire the
   // event if found.
   for (const auto& display : mVRDisplays) {
     if (display->DisplayId() == aDisplayID && display->IsPresenting()) {
       // We only want to trigger this event to content that is presenting to
       // the display already.
@@ -13969,17 +13831,17 @@ nsGlobalWindow::DispatchVRDisplayDeactiv
       // Once we dispatch the event, we must not access any members as an event
       // listener can do anything, including closing windows.
       return;
     }
   }
 }
 
 void
-nsGlobalWindow::DispatchVRDisplayConnect(uint32_t aDisplayID)
+nsGlobalWindowInner::DispatchVRDisplayConnect(uint32_t aDisplayID)
 {
   // Search for the display identified with aDisplayID and fire the
   // event if found.
   for (const auto& display : mVRDisplays) {
     if (display->DisplayId() == aDisplayID) {
       // Fire event even if not presenting to the display.
       VRDisplayEventInit init;
       init.mBubbles = false;
@@ -13997,17 +13859,17 @@ nsGlobalWindow::DispatchVRDisplayConnect
       // Once we dispatch the event, we must not access any members as an event
       // listener can do anything, including closing windows.
       return;
     }
   }
 }
 
 void
-nsGlobalWindow::DispatchVRDisplayDisconnect(uint32_t aDisplayID)
+nsGlobalWindowInner::DispatchVRDisplayDisconnect(uint32_t aDisplayID)
 {
   // Search for the display identified with aDisplayID and fire the
   // event if found.
   for (const auto& display : mVRDisplays) {
     if (display->DisplayId() == aDisplayID) {
       // Fire event even if not presenting to the display.
       VRDisplayEventInit init;
       init.mBubbles = false;
@@ -14025,17 +13887,17 @@ nsGlobalWindow::DispatchVRDisplayDisconn
       // Once we dispatch the event, we must not access any members as an event
       // listener can do anything, including closing windows.
       return;
     }
   }
 }
 
 void
-nsGlobalWindow::DispatchVRDisplayPresentChange(uint32_t aDisplayID)
+nsGlobalWindowInner::DispatchVRDisplayPresentChange(uint32_t aDisplayID)
 {
   // Search for the display identified with aDisplayID and fire the
   // event if found.
   for (const auto& display : mVRDisplays) {
     if (display->DisplayId() == aDisplayID) {
       // Fire event even if not presenting to the display.
       VRDisplayEventInit init;
       init.mBubbles = false;
@@ -14060,17 +13922,17 @@ enum WindowState {
   // These constants need to match the constants in Window.webidl
   STATE_MAXIMIZED = 1,
   STATE_MINIMIZED = 2,
   STATE_NORMAL = 3,
   STATE_FULLSCREEN = 4
 };
 
 uint16_t
-nsGlobalWindow::WindowState()
+nsGlobalWindowInner::WindowState()
 {
   MOZ_ASSERT(IsInnerWindow());
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
   int32_t mode = widget ? widget->SizeMode() : 0;
 
   switch (mode) {
     case nsSizeMode_Minimized:
@@ -14085,82 +13947,82 @@ nsGlobalWindow::WindowState()
       NS_WARNING("Illegal window state for this chrome window");
       break;
   }
 
   return STATE_NORMAL;
 }
 
 bool
-nsGlobalWindow::IsFullyOccluded()
+nsGlobalWindowInner::IsFullyOccluded()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
   return widget && widget->IsFullyOccluded();
 }
 
 void
-nsGlobalWindow::Maximize()
+nsGlobalWindowInner::Maximize()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
   if (widget) {
     widget->SetSizeMode(nsSizeMode_Maximized);
   }
 }
 
 void
-nsGlobalWindow::Minimize()
+nsGlobalWindowInner::Minimize()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
   if (widget) {
     widget->SetSizeMode(nsSizeMode_Minimized);
   }
 }
 
 void
-nsGlobalWindow::Restore()
+nsGlobalWindowInner::Restore()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
   if (widget) {
     widget->SetSizeMode(nsSizeMode_Normal);
   }
 }
 
 void
-nsGlobalWindow::GetAttention(ErrorResult& aResult)
+nsGlobalWindowInner::GetAttention(ErrorResult& aResult)
 {
   MOZ_ASSERT(IsInnerWindow());
   return GetAttentionWithCycleCount(-1, aResult);
 }
 
 void
-nsGlobalWindow::GetAttentionWithCycleCount(int32_t aCycleCount,
+nsGlobalWindowInner::GetAttentionWithCycleCount(int32_t aCycleCount,
                                            ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   nsCOMPtr<nsIWidget> widget = GetMainWidget();
 
   if (widget) {
     aError = widget->GetAttention(aCycleCount);
   }
 }
 
 void
-nsGlobalWindow::BeginWindowMove(Event& aMouseDownEvent, Element* aPanel,
+nsGlobalWindowInner::BeginWindowMove(Event& aMouseDownEvent, Element* aPanel,
                                 ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   nsCOMPtr<nsIWidget> widget;
 
   // if a panel was supplied, use its widget instead.
 #ifdef MOZ_XUL
@@ -14189,33 +14051,33 @@ nsGlobalWindow::BeginWindowMove(Event& a
     aError.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   aError = widget->BeginMoveDrag(mouseEvent);
 }
 
 already_AddRefed<nsWindowRoot>
-nsGlobalWindow::GetWindowRootOuter()
+nsGlobalWindowInner::GetWindowRootOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   nsCOMPtr<nsPIWindowRoot> root = GetTopWindowRoot();
   return root.forget().downcast<nsWindowRoot>();
 }
 
 already_AddRefed<nsWindowRoot>
-nsGlobalWindow::GetWindowRoot(mozilla::ErrorResult& aError)
+nsGlobalWindowInner::GetWindowRoot(mozilla::ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetWindowRootOuter, (), aError, nullptr);
 }
 
 //Note: This call will lock the cursor, it will not change as it moves.
 //To unlock, the cursor must be set back to CURSOR_AUTO.
 void
-nsGlobalWindow::SetCursorOuter(const nsAString& aCursor, ErrorResult& aError)
+nsGlobalWindowInner::SetCursorOuter(const nsAString& aCursor, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   int32_t cursor;
 
   if (aCursor.EqualsLiteral("auto"))
     cursor = NS_STYLE_CURSOR_AUTO;
   else {
@@ -14259,63 +14121,63 @@ nsGlobalWindow::SetCursorOuter(const nsA
     // Call esm and set cursor.
     aError = presContext->EventStateManager()->SetCursor(cursor, nullptr,
                                                          false, 0.0f, 0.0f,
                                                          widget, true);
   }
 }
 
 void
-nsGlobalWindow::SetCursor(const nsAString& aCursor, ErrorResult& aError)
+nsGlobalWindowInner::SetCursor(const nsAString& aCursor, ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetCursorOuter, (aCursor, aError), aError, );
 }
 
 NS_IMETHODIMP
-nsGlobalWindow::GetBrowserDOMWindow(nsIBrowserDOMWindow **aBrowserWindow)
+nsGlobalWindowInner::GetBrowserDOMWindow(nsIBrowserDOMWindow **aBrowserWindow)
 {
   MOZ_RELEASE_ASSERT(IsChromeWindow());
   FORWARD_TO_INNER(GetBrowserDOMWindow, (aBrowserWindow), NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   NS_IF_ADDREF(*aBrowserWindow = GetBrowserDOMWindow(rv));
   return rv.StealNSResult();
 }
 
 nsIBrowserDOMWindow*
-nsGlobalWindow::GetBrowserDOMWindowOuter()
+nsGlobalWindowInner::GetBrowserDOMWindowOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   MOZ_ASSERT(IsChromeWindow());
   return mChromeFields.mBrowserDOMWindow;
 }
 
 nsIBrowserDOMWindow*
-nsGlobalWindow::GetBrowserDOMWindow(ErrorResult& aError)
+nsGlobalWindowInner::GetBrowserDOMWindow(ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(GetBrowserDOMWindowOuter, (), aError, nullptr);
 }
 
 void
-nsGlobalWindow::SetBrowserDOMWindowOuter(nsIBrowserDOMWindow* aBrowserWindow)
+nsGlobalWindowInner::SetBrowserDOMWindowOuter(nsIBrowserDOMWindow* aBrowserWindow)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   MOZ_ASSERT(IsChromeWindow());
   mChromeFields.mBrowserDOMWindow = aBrowserWindow;
 }
 
 void
-nsGlobalWindow::SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserWindow,
+nsGlobalWindowInner::SetBrowserDOMWindow(nsIBrowserDOMWindow* aBrowserWindow,
                                     ErrorResult& aError)
 {
   FORWARD_TO_OUTER_OR_THROW(SetBrowserDOMWindowOuter, (aBrowserWindow), aError, );
 }
 
 void
-nsGlobalWindow::NotifyDefaultButtonLoaded(Element& aDefaultButton,
+nsGlobalWindowInner::NotifyDefaultButtonLoaded(Element& aDefaultButton,
                                           ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
 #ifdef MOZ_XUL
   // Don't snap to a disabled button.
   nsCOMPtr<nsIDOMXULControlElement> xulControl =
                                       do_QueryInterface(&aDefaultButton);
   if (!xulControl) {
@@ -14354,55 +14216,55 @@ nsGlobalWindow::NotifyDefaultButtonLoade
     aError.Throw(rv);
   }
 #else
   aError.Throw(NS_ERROR_NOT_IMPLEMENTED);
 #endif
 }
 
 NS_IMETHODIMP
-nsGlobalWindow::GetMessageManager(nsIMessageBroadcaster** aManager)
+nsGlobalWindowInner::GetMessageManager(nsIMessageBroadcaster** aManager)
 {
   FORWARD_TO_INNER(GetMessageManager, (aManager), NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   NS_IF_ADDREF(*aManager = GetMessageManager(rv));
   return rv.StealNSResult();
 }
 
 nsIMessageBroadcaster*
-nsGlobalWindow::GetMessageManager(ErrorResult& aError)
+nsGlobalWindowInner::GetMessageManager(ErrorResult& aError)
 {
   MOZ_ASSERT(IsChromeWindow());
   MOZ_RELEASE_ASSERT(IsInnerWindow());
   if (!mChromeFields.mMessageManager) {
     nsCOMPtr<nsIMessageBroadcaster> globalMM =
       do_GetService("@mozilla.org/globalmessagemanager;1");
     mChromeFields.mMessageManager =
       new nsFrameMessageManager(nullptr,
                                 static_cast<nsFrameMessageManager*>(globalMM.get()),
                                 MM_CHROME | MM_BROADCASTER);
   }
   return mChromeFields.mMessageManager;
 }
 
 NS_IMETHODIMP
-nsGlobalWindow::GetGroupMessageManager(const nsAString& aGroup,
+nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup,
                                        nsIMessageBroadcaster** aManager)
 {
   MOZ_RELEASE_ASSERT(IsChromeWindow());
   FORWARD_TO_INNER(GetGroupMessageManager, (aGroup, aManager), NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   NS_IF_ADDREF(*aManager = GetGroupMessageManager(aGroup, rv));
   return rv.StealNSResult();
 }
 
 nsIMessageBroadcaster*
-nsGlobalWindow::GetGroupMessageManager(const nsAString& aGroup,
+nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup,
                                        ErrorResult& aError)
 {
   MOZ_ASSERT(IsChromeWindow());
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   nsCOMPtr<nsIMessageBroadcaster> messageManager =
     mChromeFields.mGroupMessageManagers.LookupForAdd(aGroup).OrInsert(
       [this, &aError] () {
@@ -14412,83 +14274,83 @@ nsGlobalWindow::GetGroupMessageManager(c
         return new nsFrameMessageManager(nullptr,
                                          parent,
                                          MM_CHROME | MM_BROADCASTER);
       });
   return messageManager;
 }
 
 nsresult
-nsGlobalWindow::SetOpenerForInitialContentBrowser(mozIDOMWindowProxy* aOpenerWindow)
+nsGlobalWindowInner::SetOpenerForInitialContentBrowser(mozIDOMWindowProxy* aOpenerWindow)
 {
   MOZ_RELEASE_ASSERT(IsChromeWindow());
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   MOZ_ASSERT(!mChromeFields.mOpenerForInitialContentBrowser);
   mChromeFields.mOpenerForInitialContentBrowser = aOpenerWindow;
   return NS_OK;
 }
 
 nsresult
-nsGlobalWindow::TakeOpenerForInitialContentBrowser(mozIDOMWindowProxy** aOpenerWindow)
+nsGlobalWindowInner::TakeOpenerForInitialContentBrowser(mozIDOMWindowProxy** aOpenerWindow)
 {
   MOZ_RELEASE_ASSERT(IsChromeWindow());
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   // Intentionally forget our own member
   mChromeFields.mOpenerForInitialContentBrowser.forget(aOpenerWindow);
   return NS_OK;
 }
 
 void
-nsGlobalWindow::InitWasOffline()
+nsGlobalWindowInner::InitWasOffline()
 {
   mWasOffline = NS_IsOffline();
 }
 
 #if defined(MOZ_WIDGET_ANDROID)
 int16_t
-nsGlobalWindow::Orientation(CallerType aCallerType) const
+nsGlobalWindowInner::Orientation(CallerType aCallerType) const
 {
   return nsContentUtils::ResistFingerprinting(aCallerType) ?
            0 : WindowOrientationObserver::OrientationAngle();
 }
 #endif
 
 Console*
-nsGlobalWindow::GetConsole(ErrorResult& aRv)
+nsGlobalWindowInner::GetConsole(ErrorResult& aRv)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mConsole) {
     mConsole = Console::Create(AsInner(), aRv);
     if (NS_WARN_IF(aRv.Failed())) {
       return nullptr;
     }
   }
 
   return mConsole;
 }
 
 bool
-nsGlobalWindow::IsSecureContext() const
+nsGlobalWindowInner::IsSecureContext() const
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   return JS_GetIsSecureContext(js::GetObjectCompartment(GetWrapperPreserveColor()));
 }
 
 bool
-nsGlobalWindow::IsSecureContextIfOpenerIgnored() const
+nsGlobalWindowInner::IsSecureContextIfOpenerIgnored() const
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   return mIsSecureContextIfOpenerIgnored;
 }
 
 already_AddRefed<External>
-nsGlobalWindow::GetExternal(ErrorResult& aRv)
+nsGlobalWindowInner::GetExternal(ErrorResult& aRv)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
 #ifdef HAVE_SIDEBAR
   if (!mExternal) {
     AutoJSContext cx;
     JS::Rooted<JSObject*> jsImplObj(cx);
     ConstructJSImplementation("@mozilla.org/sidebar;1", this, &jsImplObj, aRv);
@@ -14502,17 +14364,17 @@ nsGlobalWindow::GetExternal(ErrorResult&
   return external.forget();
 #else
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
   return nullptr;
 #endif
 }
 
 void
-nsGlobalWindow::GetSidebar(OwningExternalOrWindowProxy& aResult,
+nsGlobalWindowInner::GetSidebar(OwningExternalOrWindowProxy& aResult,
                            ErrorResult& aRv)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
 #ifdef HAVE_SIDEBAR
   // First check for a named frame named "sidebar"
   nsCOMPtr<nsPIDOMWindowOuter> domWindow = GetChildWindow(NS_LITERAL_STRING("sidebar"));
   if (domWindow) {
@@ -14525,37 +14387,37 @@ nsGlobalWindow::GetSidebar(OwningExterna
     aResult.SetAsExternal() = external;
   }
 #else
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
 #endif
 }
 
 void
-nsGlobalWindow::ClearDocumentDependentSlots(JSContext* aCx)
+nsGlobalWindowInner::ClearDocumentDependentSlots(JSContext* aCx)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   // If JSAPI OOMs here, there is basically nothing we can do to recover safely.
   if (!WindowBinding::ClearCachedDocumentValue(aCx, AssertInner()) ||
       !WindowBinding::ClearCachedPerformanceValue(aCx, AssertInner())) {
     MOZ_CRASH("Unhandlable OOM while clearing document dependent slots.");
   }
 }
 
 /* static */
 JSObject*
-nsGlobalWindow::CreateNamedPropertiesObject(JSContext *aCx,
+nsGlobalWindowInner::CreateNamedPropertiesObject(JSContext *aCx,
                                             JS::Handle<JSObject*> aProto)
 {
   return WindowNamedPropertiesHandler::Create(aCx, aProto);
 }
 
 bool
-nsGlobalWindow::GetIsPrerendered()
+nsGlobalWindowInner::GetIsPrerendered()
 {
   nsIDocShell* docShell = GetDocShell();
   return docShell && docShell->GetIsPrerendered();
 }
 
 void
 nsPIDOMWindowOuter::SetLargeAllocStatus(LargeAllocStatus aStatus)
 {
@@ -14571,17 +14433,17 @@ nsPIDOMWindowOuter::IsTopLevelWindow()
 
 bool
 nsPIDOMWindowOuter::HadOriginalOpener() const
 {
   return nsGlobalWindowOuter::Cast(this)->HadOriginalOpener();
 }
 
 void
-nsGlobalWindow::ReportLargeAllocStatus()
+nsGlobalWindowInner::ReportLargeAllocStatus()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   uint32_t errorFlags = nsIScriptError::warningFlag;
   const char* message = nullptr;
 
   switch (mLargeAllocStatus) {
     case LargeAllocStatus::SUCCESS:
@@ -14610,51 +14472,51 @@ nsGlobalWindow::ReportLargeAllocStatus()
   nsContentUtils::ReportToConsole(errorFlags,
                                   NS_LITERAL_CSTRING("DOM"),
                                   mDoc,
                                   nsContentUtils::eDOM_PROPERTIES,
                                   message);
 }
 
 void
-nsGlobalWindow::RedefineProperty(JSContext* aCx, const char* aPropName,
+nsGlobalWindowInner::RedefineProperty(JSContext* aCx, const char* aPropName,
                                  JS::Handle<JS::Value> aValue,
                                  ErrorResult& aError)
 {
   JS::Rooted<JSObject*> thisObj(aCx, GetWrapperPreserveColor());
   if (!thisObj) {
     aError.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 
   if (!JS_WrapObject(aCx, &thisObj) ||
       !JS_DefineProperty(aCx, thisObj, aPropName, aValue, JSPROP_ENUMERATE)) {
     aError.Throw(NS_ERROR_FAILURE);
   }
 }
 
 void
-nsGlobalWindow::GetReplaceableWindowCoord(JSContext* aCx,
-                                          nsGlobalWindow::WindowCoordGetter aGetter,
+nsGlobalWindowInner::GetReplaceableWindowCoord(JSContext* aCx,
+                                          nsGlobalWindowInner::WindowCoordGetter aGetter,
                                           JS::MutableHandle<JS::Value> aRetval,
                                           CallerType aCallerType,
                                           ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   int32_t coord = (this->*aGetter)(aCallerType, aError);
   if (!aError.Failed() &&
       !ToJSValue(aCx, coord, aRetval)) {
     aError.Throw(NS_ERROR_FAILURE);
   }
 }
 
 void
-nsGlobalWindow::SetReplaceableWindowCoord(JSContext* aCx,
-                                          nsGlobalWindow::WindowCoordSetter aSetter,
+nsGlobalWindowInner::SetReplaceableWindowCoord(JSContext* aCx,
+                                          nsGlobalWindowInner::WindowCoordSetter aSetter,
                                           JS::Handle<JS::Value> aValue,
                                           const char* aPropName,
                                           CallerType aCallerType,
                                           ErrorResult& aError)
 {
   MOZ_ASSERT(IsInnerWindow());
 
   /*
@@ -14769,60 +14631,60 @@ nsGlobalWindow::SetReplaceableWindowCoor
       }
     }
   }
 
   (this->*aSetter)(value, aCallerType, aError);
 }
 
 void
-nsGlobalWindow::FireOnNewGlobalObject()
+nsGlobalWindowInner::FireOnNewGlobalObject()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   // AutoEntryScript required to invoke debugger hook, which is a
   // Gecko-specific concept at present.
-  AutoEntryScript aes(this, "nsGlobalWindow report new global");
+  AutoEntryScript aes(this, "nsGlobalWindowInner report new global");
   JS::Rooted<JSObject*> global(aes.cx(), GetWrapper());
   JS_FireOnNewGlobalObject(aes.cx(), global);
 }
 
 #ifdef _WINDOWS_
 #error "Never include windows.h in this file!"
 #endif
 
 already_AddRefed<Promise>
-nsGlobalWindow::CreateImageBitmap(JSContext* aCx,
+nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
                                   const ImageBitmapSource& aImage,
                                   ErrorResult& aRv)
 {
   if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
     aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
     return nullptr;
   }
 
   return ImageBitmap::Create(this, aImage, Nothing(), aRv);
 }
 
 already_AddRefed<Promise>
-nsGlobalWindow::CreateImageBitmap(JSContext* aCx,
+nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
                                   const ImageBitmapSource& aImage,
                                   int32_t aSx, int32_t aSy, int32_t aSw, int32_t aSh,
                                   ErrorResult& aRv)
 {
   if (aImage.IsArrayBuffer() || aImage.IsArrayBufferView()) {
     aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
     return nullptr;
   }
 
   return ImageBitmap::Create(this, aImage, Some(gfx::IntRect(aSx, aSy, aSw, aSh)), aRv);
 }
 
 already_AddRefed<mozilla::dom::Promise>
-nsGlobalWindow::CreateImageBitmap(JSContext* aCx,
+nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
                                   const ImageBitmapSource& aImage,
                                   int32_t aOffset, int32_t aLength,
                                   ImageBitmapFormat aFormat,
                                   const Sequence<ChannelPixelLayout>& aLayout,
                                   ErrorResult& aRv)
 {
   if (!ImageBitmap::ExtensionsEnabled(aCx)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
@@ -14835,106 +14697,50 @@ nsGlobalWindow::CreateImageBitmap(JSCont
   aRv.Throw(NS_ERROR_TYPE_ERR);
   return nullptr;
 }
 
 // Helper called by methods that move/resize the window,
 // to ensure the presContext (if any) is aware of resolution
 // change that may happen in multi-monitor configuration.
 void
-nsGlobalWindow::CheckForDPIChange()
+nsGlobalWindowInner::CheckForDPIChange()
 {
   if (mDocShell) {
     RefPtr<nsPresContext> presContext;
     mDocShell->GetPresContext(getter_AddRefs(presContext));
     if (presContext) {
       if (presContext->DeviceContext()->CheckDPIChange()) {
         presContext->UIResolutionChanged();
       }
     }
   }
 }
 
 mozilla::dom::TabGroup*
-nsGlobalWindow::TabGroupOuter()
-{
-  MOZ_RELEASE_ASSERT(IsOuterWindow());
-
-  // Outer windows lazily join TabGroups when requested. This is usually done
-  // because a document is getting its NodePrincipal, and asking for the
-  // TabGroup to determine its DocGroup.
-  if (!mTabGroup) {
-    // Get mOpener ourselves, instead of relying on GetOpenerWindowOuter,
-    // because that way we dodge the LegacyIsCallerChromeOrNativeCode() call
-    // which we want to return false.
-    nsCOMPtr<nsPIDOMWindowOuter> piOpener = do_QueryReferent(mOpener);
-    nsPIDOMWindowOuter* opener = GetSanitizedOpener(piOpener);
-    nsPIDOMWindowOuter* parent = GetScriptableParentOrNull();
-    MOZ_ASSERT(!parent || !opener, "Only one of parent and opener may be provided");
-
-    mozilla::dom::TabGroup* toJoin = nullptr;
-    if (GetDocShell()->ItemType() == nsIDocShellTreeItem::typeChrome) {
-      toJoin = TabGroup::GetChromeTabGroup();
-    } else if (opener) {
-      toJoin = opener->TabGroup();
-    } else if (parent) {
-      toJoin = parent->TabGroup();
-    } else {
-      toJoin = TabGroup::GetFromWindow(AsOuter());
-    }
-
-#ifdef DEBUG
-    // Make sure that, if we have a tab group from the actor, it matches the one
-    // we're planning to join.
-    mozilla::dom::TabGroup* testGroup = TabGroup::GetFromWindow(AsOuter());
-    MOZ_ASSERT_IF(testGroup, testGroup == toJoin);
-#endif
-
-    mTabGroup = mozilla::dom::TabGroup::Join(AsOuter(), toJoin);
-  }
-  MOZ_ASSERT(mTabGroup);
-
-#ifdef DEBUG
-  // Ensure that we don't recurse forever
-  if (!mIsValidatingTabGroup) {
-    mIsValidatingTabGroup = true;
-    // We only need to do this check if we aren't in the chrome tab group
-    if (mIsChrome) {
-      MOZ_ASSERT(mTabGroup == TabGroup::GetChromeTabGroup());
-    } else {
-      // Sanity check that our tabgroup matches our opener or parent.
-      RefPtr<nsPIDOMWindowOuter> parent = GetScriptableParentOrNull();
-      MOZ_ASSERT_IF(parent, parent->TabGroup() == mTabGroup);
-      nsCOMPtr<nsPIDOMWindowOuter> piOpener = do_QueryReferent(mOpener);
-      nsPIDOMWindowOuter* opener = GetSanitizedOpener(piOpener);
-      MOZ_ASSERT_IF(opener && nsGlobalWindowOuter::Cast(opener) != this,
-                    opener->TabGroup() == mTabGroup);
-    }
-    mIsValidatingTabGroup = false;
-  }
-#endif
-
-  return mTabGroup;
+nsGlobalWindowInner::TabGroupOuter()
+{
+  MOZ_CRASH("Must be an outer window");
 }
 
 mozilla::dom::TabGroup*
-nsGlobalWindow::TabGroupInner()
+nsGlobalWindowInner::TabGroupInner()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   // If we don't have a TabGroup yet, try to get it from the outer window and
   // cache it.
   if (!mTabGroup) {
     nsGlobalWindowOuter* outer = GetOuterWindowInternal();
     // This will never be called without either an outer window, or a cached tab group.
     // This is because of the following:
     // * This method is only called on inner windows
     // * This method is called as a document is attached to it's script global
     //   by the document
-    // * Inner windows are created in nsGlobalWindow::SetNewDocument, which
+    // * Inner windows are created in nsGlobalWindowInner::SetNewDocument, which
     //   immediately sets a document, which will call this method, causing
     //   the TabGroup to be cached.
     MOZ_RELEASE_ASSERT(outer, "Inner window without outer window has no cached tab group!");
     mTabGroup = outer->TabGroup();
   }
   MOZ_ASSERT(mTabGroup);
 
 #ifdef DEBUG
@@ -14969,78 +14775,78 @@ nsPIDOMWindow<T>::GetDocGroup() const
   nsIDocument* doc = GetExtantDoc();
   if (doc) {
     return doc->GetDocGroup();
   }
   return nullptr;
 }
 
 nsresult
-nsGlobalWindow::Dispatch(TaskCategory aCategory,
+nsGlobalWindowInner::Dispatch(TaskCategory aCategory,
                          already_AddRefed<nsIRunnable>&& aRunnable)
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   if (GetDocGroup()) {
     return GetDocGroup()->Dispatch(aCategory, Move(aRunnable));
   }
   return DispatcherTrait::Dispatch(aCategory, Move(aRunnable));
 }
 
 nsISerialEventTarget*
-nsGlobalWindow::EventTargetFor(TaskCategory aCategory) const
+nsGlobalWindowInner::EventTargetFor(TaskCategory aCategory) const
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   if (GetDocGroup()) {
     return GetDocGroup()->EventTargetFor(aCategory);
   }
   return DispatcherTrait::EventTargetFor(aCategory);
 }
 
 AbstractThread*
-nsGlobalWindow::AbstractMainThreadFor(TaskCategory aCategory)
+nsGlobalWindowInner::AbstractMainThreadFor(TaskCategory aCategory)
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   if (GetDocGroup()) {
     return GetDocGroup()->AbstractMainThreadFor(aCategory);
   }
   return DispatcherTrait::AbstractMainThreadFor(aCategory);
 }
 
-nsGlobalWindow::TemporarilyDisableDialogs::TemporarilyDisableDialogs(
+nsGlobalWindowInner::TemporarilyDisableDialogs::TemporarilyDisableDialogs(
   nsGlobalWindowOuter* aWindow MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
 {
   MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 
   MOZ_ASSERT(aWindow);
   nsGlobalWindowOuter* topWindowOuter = aWindow->GetScriptableTopInternal();
   if (!topWindowOuter) {
-    NS_ERROR("nsGlobalWindow::TemporarilyDisableDialogs used without a top "
+    NS_ERROR("nsGlobalWindowInner::TemporarilyDisableDialogs used without a top "
              "window?");
     return;
   }
 
   // TODO: Warn if no top window?
   nsGlobalWindowInner* topWindow =
     topWindowOuter->GetCurrentInnerWindowInternal();
   if (topWindow) {
     mTopWindow = topWindow;
     mSavedDialogsEnabled = mTopWindow->mAreDialogsEnabled;
     mTopWindow->mAreDialogsEnabled = false;
   }
 }
 
-nsGlobalWindow::TemporarilyDisableDialogs::~TemporarilyDisableDialogs()
+nsGlobalWindowInner::TemporarilyDisableDialogs::~TemporarilyDisableDialogs()
 {
   if (mTopWindow) {
     mTopWindow->mAreDialogsEnabled = mSavedDialogsEnabled;
   }
 }
 
 Worklet*
-nsGlobalWindow::GetAudioWorklet(ErrorResult& aRv)
+nsGlobalWindowInner::GetAudioWorklet(ErrorResult& aRv)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mAudioWorklet) {
     nsIPrincipal* principal = GetPrincipal();
     if (!principal) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
@@ -15048,17 +14854,17 @@ nsGlobalWindow::GetAudioWorklet(ErrorRes
 
     mAudioWorklet = new Worklet(AsInner(), principal, Worklet::eAudioWorklet);
   }
 
   return mAudioWorklet;
 }
 
 Worklet*
-nsGlobalWindow::GetPaintWorklet(ErrorResult& aRv)
+nsGlobalWindowInner::GetPaintWorklet(ErrorResult& aRv)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mPaintWorklet) {
     nsIPrincipal* principal = GetPrincipal();
     if (!principal) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
@@ -15066,96 +14872,38 @@ nsGlobalWindow::GetPaintWorklet(ErrorRes
 
     mPaintWorklet = new Worklet(AsInner(), principal, Worklet::ePaintWorklet);
   }
 
   return mPaintWorklet;
 }
 
 void
-nsGlobalWindow::GetRegionalPrefsLocales(nsTArray<nsString>& aLocales)
+nsGlobalWindowInner::GetRegionalPrefsLocales(nsTArray<nsString>& aLocales)
 {
   AutoTArray<nsCString, 10> rpLocales;
   mozilla::intl::LocaleService::GetInstance()->GetRegionalPrefsLocales(rpLocales);
 
   for (const auto& loc : rpLocales) {
     aLocales.AppendElement(NS_ConvertUTF8toUTF16(loc));
   }
 }
 
 IntlUtils*
-nsGlobalWindow::GetIntlUtils(ErrorResult& aError)
+nsGlobalWindowInner::GetIntlUtils(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mIntlUtils) {
     mIntlUtils = new IntlUtils(AsInner());
   }
 
   return mIntlUtils;
 }
 
-nsGlobalWindowOuter::nsGlobalWindowOuter()
-  : nsGlobalWindow(nullptr)
-{
-  // Add ourselves to the outer windows list.
-  MOZ_ASSERT(sOuterWindowsById, "Outer Windows hash table must be created!");
-
-  // |this| is an outer window, add to the outer windows list.
-  MOZ_ASSERT(!sOuterWindowsById->Get(mWindowID),
-             "This window shouldn't be in the hash table yet!");
-  // We seem to see crashes in release builds because of null |sOuterWindowsById|.
-  if (sOuterWindowsById) {
-    sOuterWindowsById->Put(mWindowID, AssertOuter());
-  }
-}
-
-nsGlobalWindowOuter::~nsGlobalWindowOuter()
-{
-  // NOTE: We remove ourselves from the sOuterWindowsById table in
-  // nsGlobalWindow::~nsGlobalWindow. We can't do it here because we have to
-  // remove ourselves before running some cleanup in that function.
-}
-
-/* static */ already_AddRefed<nsGlobalWindowOuter>
-nsGlobalWindowOuter::Create(bool aIsChrome)
-{
-  RefPtr<nsGlobalWindowOuter> window = new nsGlobalWindowOuter();
-  if (aIsChrome) {
-    window->mIsChrome = true;
-    window->mCleanMessageManager = true;
-  }
-
-  window->InitWasOffline();
-  return window.forget();
-}
-
-nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow)
-  : nsGlobalWindow(aOuterWindow)
-{
-  // Add ourselves to the inner windows list.
-  MOZ_ASSERT(sInnerWindowsById, "Inner Windows hash table must be created!");
-  MOZ_ASSERT(!sInnerWindowsById->Get(mWindowID),
-             "This window shouldn't be in the hash table yet!");
-  // We seem to see crashes in release builds because of null |sInnerWindowsById|.
-  if (sInnerWindowsById) {
-    sInnerWindowsById->Put(mWindowID, AssertInner());
-    // NOTE: We remove ourselves from this table in
-    // nsGlobalWindow::~nsGlobalWindow. We can't do it here because we have to
-    // remove ourselves before running some cleanup in that function.
-  }
-}
-
-nsGlobalWindowInner::~nsGlobalWindowInner()
-{
-  // NOTE: We remove ourselves from the sInnerWindowsById table in
-  // nsGlobalWindow::~nsGlobalWindow. We can't do it here because we have to
-  // remove ourselves before running some cleanup in that function.
-}
-
 /* static */ already_AddRefed<nsGlobalWindowInner>
 nsGlobalWindowInner::Create(nsGlobalWindowOuter *aOuterWindow, bool aIsChrome)
 {
   RefPtr<nsGlobalWindowInner> window = new nsGlobalWindowInner(aOuterWindow);
   if (aIsChrome) {
     window->mIsChrome = true;
     window->mCleanMessageManager = true;
   }
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -17,17 +17,18 @@
 #include "js/TypeDecls.h"
 #include "nsRefPtrHashtable.h"
 
 // Only fired for inner windows.
 #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed"
 #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen"
 #define DOM_WINDOW_THAWED_TOPIC "dom-window-thawed"
 
-class nsGlobalWindow;
+class nsGlobalWindowInner;
+class nsGlobalWindowOuter;
 class nsIArray;
 class nsIContent;
 class nsICSSDeclaration;
 class nsIDocShell;
 class nsIDocShellLoadInfo;
 class nsIDocument;
 class nsIIdleObserver;
 class nsIPrincipal;
@@ -760,17 +761,18 @@ protected:
 #define NS_PIDOMWINDOWOUTER_IID \
   { 0x769693d4, 0xb009, 0x4fe2, \
   { 0xaf, 0x18, 0x7d, 0xc8, 0xdf, 0x74, 0x96, 0xdf } }
 
 // NB: It's very very important that these two classes have identical vtables
 // and memory layout!
 class nsPIDOMWindowInner : public nsPIDOMWindow<mozIDOMWindow>
 {
-  friend nsGlobalWindow;
+  friend nsGlobalWindowInner;
+  friend nsGlobalWindowOuter;
 
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOWINNER_IID)
 
   static nsPIDOMWindowInner* From(mozIDOMWindow* aFrom) {
     return static_cast<nsPIDOMWindowInner*>(aFrom);
   }
 
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -1020,17 +1020,19 @@ enum GetOrCreateReflectorWrapBehavior {
 };
 
 template <class T>
 struct TypeNeedsOuterization
 {
   // We only need to outerize Window objects, so anything inheriting from
   // nsGlobalWindow (which inherits from EventTarget itself).
   static const bool value =
-    IsBaseOf<nsGlobalWindow, T>::value || IsSame<EventTarget, T>::value;
+    IsBaseOf<nsGlobalWindowInner, T>::value ||
+    IsBaseOf<nsGlobalWindowOuter, T>::value ||
+    IsSame<EventTarget, T>::value;
 };
 
 #ifdef DEBUG
 template<typename T, bool isISupports=IsBaseOf<nsISupports, T>::value>
 struct CheckWrapperCacheTracing
 {
   static inline void Check(T* aObject)
   {