Bug 1416384 - Part 6: Eliminate calls to Assert{Inner,Outer} and As{Inner,Outer} in nsGlobalWindow, r=smaug
authorNika Layzell <nika@thelayzells.com>
Wed, 15 Nov 2017 11:34:27 -0500
changeset 392034 10eb6ec39ef1a34243c212c64047c7097499f8f8
parent 392033 aaed1999291a6622a030f20f5f7469fa59f622e5
child 392035 149ba94317911ec3bafa545db59e59f7abe2fcf0
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 6: Eliminate calls to Assert{Inner,Outer} and As{Inner,Outer} in nsGlobalWindow, r=smaug MozReview-Commit-ID: GIiSlDzjgWb
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsGlobalWindowOuter.h
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -798,17 +798,17 @@ nsDOMClassInfo::PostCreatePrototype(JSCo
                                     &contentDefinedProperty)) {
     return NS_ERROR_FAILURE;
   }
 
   nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
   NS_ENSURE_TRUE(nameSpaceManager, NS_OK);
 
   JS::Rooted<JS::PropertyDescriptor> desc(cx);
-  nsresult rv = ResolvePrototype(sXPConnect, win->AssertInner(), cx, global,
+  nsresult rv = ResolvePrototype(sXPConnect, win, cx, global,
                                  mData->mNameUTF16, mData, nullptr,
                                  nameSpaceManager, proto, &desc);
   NS_ENSURE_SUCCESS(rv, rv);
   if (!contentDefinedProperty && desc.object() && !desc.value().isUndefined()) {
     desc.attributesRef() |= JSPROP_RESOLVING;
     if (!JS_DefineUCProperty(cx, global, mData->mNameUTF16,
                              NS_strlen(mData->mNameUTF16), desc)) {
       return NS_ERROR_UNEXPECTED;
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -166,17 +166,17 @@ public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(IdleRequestExecutor, nsIRunnable)
 
   NS_DECL_NSIRUNNABLE
   NS_DECL_NSINAMED
   nsresult Cancel() override;
   void SetDeadline(TimeStamp aDeadline) override;
 
-  bool IsCancelled() const { return !mWindow || mWindow->AsInner()->InnerObjectsFreed(); }
+  bool IsCancelled() const { return !mWindow || mWindow->InnerObjectsFreed(); }
   // Checks if aRequest shouldn't execute in the current idle period
   // since it has been queued from a chained call to
   // requestIdleCallback from within a running idle callback.
   bool IneligibleForCurrentIdlePeriod(IdleRequest* aRequest) const
   {
     return aRequest->Handle() >= mIdlePeriodLimit.mLastRequestIdInIdlePeriod &&
            TimeStamp::Now() <= mIdlePeriodLimit.mEndOfIdlePeriod;
   }
@@ -260,17 +260,17 @@ IdleRequestExecutor::Run()
 }
 
 nsresult
 IdleRequestExecutor::Cancel()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mDelayedExecutorHandle && mWindow) {
-    mWindow->AsInner()->TimeoutManager().ClearTimeout(
+    mWindow->TimeoutManager().ClearTimeout(
       mDelayedExecutorHandle.value(),
       Timeout::Reason::eIdleCallbackTimeout);
   }
 
   mWindow = nullptr;
   return NS_OK;
 }
 
@@ -336,17 +336,17 @@ IdleRequestExecutor::ScheduleDispatch()
 }
 
 void
 IdleRequestExecutor::DelayedDispatch(uint32_t aDelay)
 {
   MOZ_ASSERT(mWindow);
   MOZ_ASSERT(mDelayedExecutorHandle.isNothing());
   int32_t handle;
-  mWindow->AsInner()->TimeoutManager().SetTimeout(
+  mWindow->TimeoutManager().SetTimeout(
     mDelayedExecutorDispatcher, aDelay, false, Timeout::Reason::eIdleCallbackTimeout, &handle);
   mDelayedExecutorHandle = Some(handle);
 }
 
 nsresult
 IdleRequestExecutorTimeoutHandler::Call()
 {
   if (!mExecutor->IsCancelled()) {
@@ -356,17 +356,17 @@ IdleRequestExecutorTimeoutHandler::Call(
 }
 
 void
 nsGlobalWindowInner::ScheduleIdleRequestDispatch()
 {
   AssertIsOnMainThread();
 
   if (!mIdleRequestExecutor) {
-    mIdleRequestExecutor = new IdleRequestExecutor(AssertInner());
+    mIdleRequestExecutor = new IdleRequestExecutor(this);
   }
 
   mIdleRequestExecutor->MaybeDispatch();
 }
 
 void
 nsGlobalWindowInner::SuspendIdleRequests()
 {
@@ -409,17 +409,17 @@ nsGlobalWindowInner::RemoveIdleCallback(
 nsresult
 nsGlobalWindowInner::RunIdleRequest(IdleRequest* aRequest,
                                DOMHighResTimeStamp aDeadline,
                                bool aDidTimeout)
 {
   AssertIsOnMainThread();
   RefPtr<IdleRequest> request(aRequest);
   RemoveIdleCallback(request);
-  return request->IdleRun(AsInner(), aDeadline, aDidTimeout);
+  return request->IdleRun(this, aDeadline, aDidTimeout);
 }
 
 nsresult
 nsGlobalWindowInner::ExecuteIdleRequest(TimeStamp aDeadline)
 {
   AssertIsOnMainThread();
   RefPtr<IdleRequest> request = mIdleRequestCallbacks.getFirst();
 
@@ -504,17 +504,17 @@ nsGlobalWindowInner::RequestIdleCallback
 
   uint32_t handle = mIdleRequestCallbackCounter++;
 
   RefPtr<IdleRequest> request =
     new IdleRequest(&aCallback, handle);
 
   if (aOptions.mTimeout.WasPassed()) {
     int32_t timeoutHandle;
-    nsCOMPtr<nsITimeoutHandler> handler(new IdleRequestTimeoutHandler(aCx, request, AsInner()));
+    nsCOMPtr<nsITimeoutHandler> handler(new IdleRequestTimeoutHandler(aCx, request, this));
 
     nsresult rv = mTimeoutManager->SetTimeout(
         handler, aOptions.mTimeout.Value(), false,
         Timeout::Reason::eIdleCallbackTimeout, &timeoutHandle);
 
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return 0;
     }
@@ -628,17 +628,17 @@ nsGlobalWindowInner::nsGlobalWindowInner
   // Initialize the PRCList (this).
   PR_INIT_CLIST(this);
 
   if (aOuterWindow) {
     // |this| is an inner window, add this inner window to the outer
     // window list of inners.
     PR_INSERT_AFTER(this, aOuterWindow);
 
-    mObserver = new nsGlobalWindowObserver(AssertInner());
+    mObserver = new nsGlobalWindowObserver(this);
     if (mObserver) {
       nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
       if (os) {
         // Watch for online/offline status changes so we can fire events. Use
         // a strong reference.
         os->AddObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
                         false);
 
@@ -703,17 +703,17 @@ nsGlobalWindowInner::nsGlobalWindowInner
           ("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());
+    sInnerWindowsById->Put(mWindowID, this);
   }
 }
 
 #ifdef DEBUG
 
 /* static */
 void
 nsGlobalWindowInner::AssertIsOnMainThread()
@@ -800,17 +800,17 @@ nsGlobalWindowInner::~nsGlobalWindowInne
   // list if inner windows.
 
   PR_REMOVE_LINK(this);
 
   // If our outer window's inner window is this window, null out the
   // outer window's reference to this window that's being deleted.
   nsGlobalWindowOuter *outer = GetOuterWindowInternal();
   if (outer) {
-    outer->MaybeClearInnerWindow(AssertInner());
+    outer->MaybeClearInnerWindow(this);
   }
 
   // We don't have to leave the tab group if we are an inner window.
 
   // While CleanUp generally seems to be intended to clean up outers, we've
   // historically called it for both. Changing this would probably involve
   // auditing all of the references that inners and outers can have, and
   // separating the handling into CleanUp() and FreeInnerObjects.
@@ -1008,25 +1008,25 @@ nsGlobalWindowInner::ClearControllers()
 void
 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());
+  NotifyDOMWindowDestroyed(this);
   if (auto* reporter = nsWindowMemoryReporter::Get()) {
-    reporter->ObserveDOMWindowDetached(AssertInner());
+    reporter->ObserveDOMWindowDetached(this);
   }
 
   mInnerObjectsFreed = true;
 
   // Kill all of the workers for this window.
-  mozilla::dom::workers::CancelWorkersForWindow(AsInner());
+  mozilla::dom::workers::CancelWorkersForWindow(this);
 
   if (mTimeoutManager) {
     mTimeoutManager->ClearAllTimeouts();
   }
 
   if (mIdleTimer) {
     mIdleTimer->Cancel();
     mIdleTimer = nullptr;
@@ -1118,20 +1118,20 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   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))) {
-    foundInterface = AsInner();
+    foundInterface = static_cast<nsPIDOMWindowInner*>(this);
   } else
   if (aIID.Equals(NS_GET_IID(mozIDOMWindow)) && IsInnerWindow()) {
-    foundInterface = AsInner();
+    foundInterface = static_cast<mozIDOMWindow*>(this);
   } else
   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
 
@@ -1286,17 +1286,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mServiceWorkerRegistrationTable)
 
 #ifdef MOZ_WEBSPEECH
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mSpeechSynthesis)
 #endif
 
   if (tmp->mOuterWindow) {
     nsGlobalWindowOuter::Cast(tmp->mOuterWindow)->
-      MaybeClearInnerWindow(tmp->AssertInner());
+      MaybeClearInnerWindow(tmp);
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mOuterWindow)
   }
 
   if (tmp->mListenerManager) {
     tmp->mListenerManager->Disconnect();
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mListenerManager)
   }
 
@@ -1496,17 +1496,17 @@ nsGlobalWindowInner::SetNewDocument(nsID
   MOZ_ASSERT(aDocument);
 
   if (!mOuterWindow) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   // Refuse to set a new document if the call came from an inner
   // window that's not the current inner window.
-  if (mOuterWindow->GetCurrentInnerWindow() != AsInner()) {
+  if (mOuterWindow->GetCurrentInnerWindow() != this) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   return GetOuterWindowInternal()->SetNewDocument(aDocument, aState,
                                                   aForceReuseInnerWindow);
 }
 
 void
@@ -1909,17 +1909,17 @@ nsGlobalWindowInner::Self()
 }
 
 Navigator*
 nsGlobalWindowInner::Navigator()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mNavigator) {
-    mNavigator = new mozilla::dom::Navigator(AsInner());
+    mNavigator = new mozilla::dom::Navigator(this);
   }
 
   return mNavigator;
 }
 
 nsIDOMNavigator*
 nsGlobalWindowInner::GetNavigator()
 {
@@ -1927,17 +1927,17 @@ nsGlobalWindowInner::GetNavigator()
 }
 
 nsScreen*
 nsGlobalWindowInner::GetScreen(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mScreen) {
-    mScreen = nsScreen::Create(AsInner());
+    mScreen = nsScreen::Create(this);
     if (!mScreen) {
       aError.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
   }
 
   return mScreen;
 }
@@ -1952,48 +1952,42 @@ nsGlobalWindowInner::GetScreen()
 }
 
 nsHistory*
 nsGlobalWindowInner::GetHistory(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mHistory) {
-    mHistory = new nsHistory(AsInner());
+    mHistory = new nsHistory(this);
   }
 
   return mHistory;
 }
 
 CustomElementRegistry*
 nsGlobalWindowInner::CustomElements()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mCustomElements) {
-    mCustomElements = new CustomElementRegistry(AsInner());
+    mCustomElements = new CustomElementRegistry(this);
   }
 
   return mCustomElements;
 }
 
 Performance*
 nsPIDOMWindowInner::GetPerformance()
 {
   MOZ_ASSERT(IsInnerWindow());
   CreatePerformanceObjectIfNeeded();
   return mPerformance;
 }
 
-Performance*
-nsGlobalWindowInner::GetPerformance()
-{
-  return AsInner()->GetPerformance();
-}
-
 void
 nsPIDOMWindowInner::CreatePerformanceObjectIfNeeded()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mPerformance || !mDoc) {
     return;
   }
@@ -2050,17 +2044,17 @@ void
 nsPIDOMWindowInner::SyncStateFromParentWindow()
 {
   nsGlobalWindowInner::Cast(this)->SyncStateFromParentWindow();
 }
 
 void
 nsGlobalWindowInner::UpdateTopInnerWindow()
 {
-  if (!IsInnerWindow() || AsInner()->IsTopInnerWindow() || !mTopInnerWindow) {
+  if (!IsInnerWindow() || IsTopInnerWindow() || !mTopInnerWindow) {
     return;
   }
 
   mTopInnerWindow->UpdateWebSocketCount(-(int32_t)mNumOfOpenWebSockets);
 }
 
 void
 nsPIDOMWindowInner::AddPeerConnection()
@@ -2137,17 +2131,17 @@ nsPIDOMWindowInner::TryToCacheTopInnerWi
   if (mHasTriedToCacheTopInnerWindow) {
     return;
   }
 
   MOZ_ASSERT(!mInnerObjectsFreed);
 
   mHasTriedToCacheTopInnerWindow = true;
 
-  nsGlobalWindowInner* window = nsGlobalWindowInner::Cast(AsInner());
+  nsGlobalWindowInner* window = nsGlobalWindowInner::Cast(this);
 
   MOZ_ASSERT(window);
 
   if (nsCOMPtr<nsPIDOMWindowOuter> topOutter = window->GetScriptableTop()) {
     mTopInnerWindow = topOutter->GetCurrentInnerWindow();
   }
 }
 
@@ -2246,17 +2240,17 @@ nsPIDOMWindowInner::SetAudioCapture(bool
 
 #ifdef MOZ_WEBSPEECH
 SpeechSynthesis*
 nsGlobalWindowInner::GetSpeechSynthesis(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mSpeechSynthesis) {
-    mSpeechSynthesis = new SpeechSynthesis(AsInner());
+    mSpeechSynthesis = new SpeechSynthesis(this);
   }
 
   return mSpeechSynthesis;
 }
 
 bool
 nsGlobalWindowInner::HasActiveSpeechSynthesis()
 {
@@ -2368,74 +2362,74 @@ nsGlobalWindowInner::GetPrompter(nsIProm
 }
 
 BarProp*
 nsGlobalWindowInner::GetMenubar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mMenubar) {
-    mMenubar = new MenubarProp(AssertInner());
+    mMenubar = new MenubarProp(this);
   }
 
   return mMenubar;
 }
 
 BarProp*
 nsGlobalWindowInner::GetToolbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mToolbar) {
-    mToolbar = new ToolbarProp(AssertInner());
+    mToolbar = new ToolbarProp(this);
   }
 
   return mToolbar;
 }
 
 BarProp*
 nsGlobalWindowInner::GetLocationbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mLocationbar) {
-    mLocationbar = new LocationbarProp(AssertInner());
+    mLocationbar = new LocationbarProp(this);
   }
   return mLocationbar;
 }
 
 BarProp*
 nsGlobalWindowInner::GetPersonalbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mPersonalbar) {
-    mPersonalbar = new PersonalbarProp(AssertInner());
+    mPersonalbar = new PersonalbarProp(this);
   }
   return mPersonalbar;
 }
 
 BarProp*
 nsGlobalWindowInner::GetStatusbar(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mStatusbar) {
-    mStatusbar = new StatusbarProp(AssertInner());
+    mStatusbar = new StatusbarProp(this);
   }
   return mStatusbar;
 }
 
 BarProp*
 nsGlobalWindowInner::GetScrollbars(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mScrollbars) {
-    mScrollbars = new ScrollbarsProp(AssertInner());
+    mScrollbars = new ScrollbarsProp(this);
   }
 
   return mScrollbars;
 }
 
 bool
 nsGlobalWindowInner::GetClosed(ErrorResult& aError)
 {
@@ -2478,17 +2472,17 @@ nsGlobalWindowInner::DoResolve(JSContext
   if (!WebIDLGlobalNameHash::DefineIfEnabled(aCx, aObj, aId, aDesc, &found)) {
     return false;
   }
 
   if (found) {
     return true;
   }
 
-  nsresult rv = nsWindowSH::GlobalResolve(AssertInner(), aCx, aObj, aId, aDesc);
+  nsresult rv = nsWindowSH::GlobalResolve(this, aCx, aObj, aId, aDesc);
   if (NS_FAILED(rv)) {
     return Throw(aCx, rv);
   }
 
   return true;
 }
 
 /* static */
@@ -2569,17 +2563,17 @@ nsGlobalWindowInner::GetOwnPropertyNames
         WebIDLGlobalNameHash::UnresolvedNamesOnly :
         WebIDLGlobalNameHash::AllNames;
     if (!WebIDLGlobalNameHash::GetNames(aCx, wrapper, nameType, aNames)) {
       aRv.NoteJSContextException(aCx);
     }
 
     for (auto i = nameSpaceManager->GlobalNameIter(); !i.Done(); i.Next()) {
       const GlobalNameMapEntry* entry = i.Get();
-      if (nsWindowSH::NameStructEnabled(aCx, AssertInner(), entry->mKey,
+      if (nsWindowSH::NameStructEnabled(aCx, this, entry->mKey,
                                         entry->mGlobalName)) {
         // Just append all of these; even if they get deleted our resolve hook
         // just goes ahead and recreates them.
         JSString* str = JS_AtomizeUCStringN(aCx,
                                             entry->mKey.BeginReading(),
                                             entry->mKey.Length());
         if (!str || !aNames.append(NON_INTEGER_ATOM_TO_JSID(str))) {
           aRv.NoteJSContextException(aCx);
@@ -2624,17 +2618,17 @@ nsGlobalWindowInner::GetApplicationCache
       return nullptr;
     }
 
     nsCOMPtr<nsIURI> manifestURI;
     nsContentUtils::GetOfflineAppManifest(mDoc, getter_AddRefs(manifestURI));
 
     RefPtr<nsDOMOfflineResourceList> applicationCache =
       new nsDOMOfflineResourceList(manifestURI, uri, mDoc->NodePrincipal(),
-                                   AsInner());
+                                   this);
 
     applicationCache->Init();
 
     mApplicationCache = applicationCache;
   }
 
   return mApplicationCache;
 }
@@ -2662,17 +2656,17 @@ nsGlobalWindowInner::GetCrypto(ErrorResu
 }
 
 mozilla::dom::U2F*
 nsGlobalWindowInner::GetU2f(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mU2F) {
-    RefPtr<U2F> u2f = new U2F(AsInner());
+    RefPtr<U2F> u2f = new U2F(this);
     u2f->Init(aError);
     if (NS_WARN_IF(aError.Failed())) {
       return nullptr;
     }
 
     mU2F = u2f;
   }
   return mU2F;
@@ -2753,17 +2747,17 @@ nsGlobalWindowInner::SetOpener(JSContext
 
     auto* globalWindow = xpc::WindowOrNull(unwrapped);
     if (!globalWindow) {
       // Wasn't a window
       aError.Throw(NS_ERROR_INVALID_ARG);
       return;
     }
 
-    win = globalWindow->AsInner();
+    win = globalWindow;
   }
 
   nsPIDOMWindowOuter* outer = nullptr;
   if (win) {
     if (!win->IsCurrentInnerWindow()) {
       aError.Throw(NS_ERROR_FAILURE);
       return;
     }
@@ -3877,17 +3871,17 @@ nsGlobalWindowInner::NotifyDOMWindowDest
                       DOM_WINDOW_DESTROYED_TOPIC, nullptr);
   }
 }
 
 void
 nsGlobalWindowInner::NotifyWindowIDDestroyed(const char* aTopic)
 {
   nsCOMPtr<nsIRunnable> runnable =
-    new WindowDestroyedEvent(AssertInner(), mWindowID, aTopic);
+    new WindowDestroyedEvent(this, mWindowID, aTopic);
   nsresult rv = Dispatch(TaskCategory::Other, runnable.forget());
   if (NS_SUCCEEDED(rv)) {
     mNotifiedIDDestroyed = true;
   }
 }
 
 // static
 void
@@ -4178,17 +4172,17 @@ nsGlobalWindowInner::Btoa(const nsAStrin
 
 //*****************************************************************************
 // nsGlobalWindowInner::nsIDOMEventTarget
 //*****************************************************************************
 
 nsPIDOMWindowOuter*
 nsGlobalWindowInner::GetOwnerGlobalForBindings()
 {
-  return nsPIDOMWindowOuter::GetFromCurrentInner(AsInner());
+  return nsPIDOMWindowOuter::GetFromCurrentInner(this);
 }
 
 NS_IMETHODIMP
 nsGlobalWindowInner::RemoveEventListener(const nsAString& aType,
                                     nsIDOMEventListener* aListener,
                                     bool aUseCapture)
 {
   if (RefPtr<EventListenerManager> elm = GetExistingListenerManager()) {
@@ -4197,17 +4191,17 @@ nsGlobalWindowInner::RemoveEventListener
   return NS_OK;
 }
 
 NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsGlobalWindowInner)
 
 NS_IMETHODIMP
 nsGlobalWindowInner::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal)
 {
-  if (!AsInner()->IsCurrentInnerWindow()) {
+  if (!IsCurrentInnerWindow()) {
     NS_WARNING("DispatchEvent called on non-current inner window, dropping. "
                "Please check the window in the caller instead.");
     return NS_ERROR_FAILURE;
   }
 
   if (!mDoc) {
     return NS_ERROR_FAILURE;
   }
@@ -4216,18 +4210,18 @@ nsGlobalWindowInner::DispatchEvent(nsIDO
   nsIPresShell *shell = mDoc->GetShell();
   RefPtr<nsPresContext> presContext;
   if (shell) {
     // Retrieve the context
     presContext = shell->GetPresContext();
   }
 
   nsEventStatus status = nsEventStatus_eIgnore;
-  nsresult rv = EventDispatcher::DispatchDOMEvent(AsInner(), nullptr, aEvent,
-                                                  presContext, &status);
+  nsresult rv = EventDispatcher::DispatchDOMEvent(ToSupports(this), nullptr,
+                                                  aEvent, presContext, &status);
 
   *aRetVal = (status != nsEventStatus_eConsumeNoDefault);
   return rv;
 }
 
 NS_IMETHODIMP
 nsGlobalWindowInner::AddEventListener(const nsAString& aType,
                                  nsIDOMEventListener *aListener,
@@ -4310,17 +4304,17 @@ nsGlobalWindowInner::GetExistingListener
 {
   return mListenerManager;
 }
 
 nsIScriptContext*
 nsGlobalWindowInner::GetContextForEventHandlers(nsresult* aRv)
 {
   *aRv = NS_ERROR_UNEXPECTED;
-  NS_ENSURE_TRUE(AsInner()->IsCurrentInnerWindow(), nullptr);
+  NS_ENSURE_TRUE(IsCurrentInnerWindow(), nullptr);
 
   nsIScriptContext* scx;
   if ((scx = GetContext())) {
     *aRv = NS_OK;
     return scx;
   }
   return nullptr;
 }
@@ -4341,17 +4335,17 @@ nsGlobalWindowInner::GetPrivateRoot()
 }
 
 Location*
 nsGlobalWindowInner::GetLocation()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mLocation) {
-    mLocation = new dom::Location(AsInner(), GetDocShell());
+    mLocation = new dom::Location(this, GetDocShell());
   }
 
   return mLocation;
 }
 
 void
 nsGlobalWindowInner::ActivateOrDeactivate(bool aActivate)
 {
@@ -4406,41 +4400,41 @@ nsGlobalWindowInner::MaybeUpdateTouchSta
 void
 nsGlobalWindowInner::EnableGamepadUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasGamepad) {
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     if (gamepadManager) {
-      gamepadManager->AddListener(AssertInner());
+      gamepadManager->AddListener(this);
     }
   }
 }
 
 void
 nsGlobalWindowInner::DisableGamepadUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasGamepad) {
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     if (gamepadManager) {
-      gamepadManager->RemoveListener(AssertInner());
+      gamepadManager->RemoveListener(this);
     }
   }
 }
 
 void
 nsGlobalWindowInner::EnableVRUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (mHasVREvents && !mVREventObserver) {
-    mVREventObserver = new VREventObserver(AssertInner());
+    mVREventObserver = new VREventObserver(this);
   }
 }
 
 void
 nsGlobalWindowInner::DisableVRUpdates()
 {
   MOZ_ASSERT(IsInnerWindow());
   if (mVREventObserver) {
@@ -4637,33 +4631,33 @@ nsGlobalWindowInner::DispatchAsyncHashch
   NS_ENSURE_SUCCESS(rv, rv);
   rv = aNewURI->GetSpec(newSpec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ConvertUTF8toUTF16 oldWideSpec(oldSpec);
   NS_ConvertUTF8toUTF16 newWideSpec(newSpec);
 
   nsCOMPtr<nsIRunnable> callback =
-    new HashchangeCallback(oldWideSpec, newWideSpec, AssertInner());
+    new HashchangeCallback(oldWideSpec, newWideSpec, this);
   return Dispatch(TaskCategory::Other, callback.forget());
 }
 
 nsresult
 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;
   }
 
   // Get a presentation shell for use in creating the hashchange event.
-  NS_ENSURE_STATE(AsInner()->IsCurrentInnerWindow());
+  NS_ENSURE_STATE(IsCurrentInnerWindow());
 
   nsIPresShell *shell = mDoc->GetShell();
   RefPtr<nsPresContext> presContext;
   if (shell) {
     presContext = shell->GetPresContext();
   }
 
   HashChangeEventInit init;
@@ -4707,17 +4701,17 @@ nsGlobalWindowInner::DispatchSyncPopStat
   nsIPresShell *shell = mDoc->GetShell();
   RefPtr<nsPresContext> presContext;
   if (shell) {
     presContext = shell->GetPresContext();
   }
 
   bool result = true;
   AutoJSAPI jsapi;
-  result = jsapi.Init(AsInner());
+  result = jsapi.Init(this);
   NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> stateJSValue(cx, JS::NullValue());
   result = stateObj ? VariantToJsval(cx, stateObj, &stateJSValue) : true;
   NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
 
   RootedDictionary<PopStateEventInit> init(cx);
@@ -4901,17 +4895,17 @@ nsGlobalWindowInner::GetSessionStorage(E
 
     nsCOMPtr<nsIDOMStorageManager> storageManager = do_QueryInterface(docShell, &rv);
     if (NS_FAILED(rv)) {
       aError.Throw(rv);
       return nullptr;
     }
 
     nsCOMPtr<nsIDOMStorage> storage;
-    aError = storageManager->CreateStorage(AsInner(), principal, documentURI,
+    aError = storageManager->CreateStorage(this, principal, documentURI,
                                            IsPrivateBrowsing(),
                                            getter_AddRefs(storage));
     if (aError.Failed()) {
       return nullptr;
     }
 
     mSessionStorage = static_cast<Storage*>(storage.get());
     MOZ_ASSERT(mSessionStorage);
@@ -4936,17 +4930,17 @@ nsGlobalWindowInner::GetLocalStorage(Err
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!Preferences::GetBool(kStorageEnabled)) {
     return nullptr;
   }
 
   if (!mLocalStorage) {
-    if (nsContentUtils::StorageAllowedForWindow(AsInner()) ==
+    if (nsContentUtils::StorageAllowedForWindow(this) ==
           nsContentUtils::StorageAccess::eDeny) {
       aError.Throw(NS_ERROR_DOM_SECURITY_ERR);
       return nullptr;
     }
 
     nsIPrincipal *principal = GetPrincipal();
     if (!principal) {
       return nullptr;
@@ -4964,17 +4958,17 @@ nsGlobalWindowInner::GetLocalStorage(Err
     if (mDoc) {
       aError = mDoc->GetDocumentURI(documentURI);
       if (NS_WARN_IF(aError.Failed())) {
         return nullptr;
       }
     }
 
     nsCOMPtr<nsIDOMStorage> storage;
-    aError = storageManager->CreateStorage(AsInner(), principal, documentURI,
+    aError = storageManager->CreateStorage(this, principal, documentURI,
                                            IsPrivateBrowsing(),
                                            getter_AddRefs(storage));
     if (aError.Failed()) {
       return nullptr;
     }
 
     mLocalStorage = static_cast<Storage*>(storage.get());
     MOZ_ASSERT(mLocalStorage);
@@ -4984,17 +4978,17 @@ nsGlobalWindowInner::GetLocalStorage(Err
 }
 
 IDBFactory*
 nsGlobalWindowInner::GetIndexedDB(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
   if (!mIndexedDB) {
     // This may keep mIndexedDB null without setting an error.
-    aError = IDBFactory::CreateForWindow(AsInner(),
+    aError = IDBFactory::CreateForWindow(this,
                                          getter_AddRefs(mIndexedDB));
   }
 
   return mIndexedDB;
 }
 
 //*****************************************************************************
 // nsGlobalWindowInner::nsIInterfaceRequestor
@@ -5082,17 +5076,17 @@ nsGlobalWindowInner::GetCaches(ErrorResu
 {
   MOZ_ASSERT(IsInnerWindow());
 
   if (!mCacheStorage) {
     bool forceTrustedOrigin =
       GetOuterWindow()->GetServiceWorkersTestingEnabled();
 
     nsContentUtils::StorageAccess access =
-      nsContentUtils::StorageAllowedForWindow(AsInner());
+      nsContentUtils::StorageAllowedForWindow(this);
 
     // We don't block the cache API when being told to only allow storage for the
     // current session.
     bool storageBlocked = access <= nsContentUtils::StorageAccess::ePrivateBrowsing;
 
     mCacheStorage = CacheStorage::CreateOnMainThread(cache::DEFAULT_NAMESPACE,
                                                      this, GetPrincipal(),
                                                      storageBlocked,
@@ -5120,17 +5114,17 @@ void
 nsPIDOMWindowInner::InvalidateServiceWorkerRegistration(const nsAString& aScope)
 {
   mServiceWorkerRegistrationTable.Remove(aScope);
 }
 
 void
 nsGlobalWindowInner::FireOfflineStatusEventIfChanged()
 {
-  if (!AsInner()->IsCurrentInnerWindow())
+  if (!IsCurrentInnerWindow())
     return;
 
   // Don't fire an event if the status hasn't changed
   if (mWasOffline == NS_IsOffline()) {
     return;
   }
 
   mWasOffline = !mWasOffline;
@@ -5196,17 +5190,17 @@ nsGlobalWindowInner::NotifyIdleObserver(
 {
   MOZ_ASSERT(IsInnerWindow());
   MOZ_ASSERT(aIdleObserverHolder);
   aIdleObserverHolder->mPrevNotificationIdle = aCallOnidle;
 
   nsCOMPtr<nsIRunnable> caller =
     new NotifyIdleObserverRunnable(aIdleObserverHolder->mIdleObserver,
                                    aIdleObserverHolder->mTimeInS,
-                                   aCallOnidle, AssertInner());
+                                   aCallOnidle, this);
   if (NS_FAILED(Dispatch(TaskCategory::Other, caller.forget()))) {
     NS_WARNING("Failed to dispatch thread for idle observer notification.");
   }
 }
 
 bool
 nsGlobalWindowInner::ContainsIdleObserver(nsIIdleObserver* aIdleObserver, uint32_t aTimeInS)
 {
@@ -5277,17 +5271,17 @@ nsGlobalWindowInner::ScheduleNextIdleObs
   uint32_t callbackTimeMS = 0;
   if (idleObserver.mTimeInS * 1000 + mIdleFuzzFactor > userIdleTimeMS) {
     callbackTimeMS = idleObserver.mTimeInS * 1000 - userIdleTimeMS + mIdleFuzzFactor;
   }
 
   mIdleTimer->Cancel();
   rv = mIdleTimer->InitWithNamedFuncCallback(
     IdleObserverTimerCallback,
-    AssertInner(),
+    this,
     callbackTimeMS,
     nsITimer::TYPE_ONE_SHOT,
     "nsGlobalWindowInner::ScheduleNextIdleObserverCallback");
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
@@ -5324,17 +5318,17 @@ nsGlobalWindowInner::ScheduleActiveTimer
   }
 
   MOZ_ASSERT(mIdleTimer);
   mIdleTimer->Cancel();
 
   uint32_t fuzzFactorInMS = GetFuzzTimeMS();
   nsresult rv = mIdleTimer->InitWithNamedFuncCallback(
     IdleActiveTimerCallback,
-    AssertInner(),
+    this,
     fuzzFactorInMS,
     nsITimer::TYPE_ONE_SHOT,
     "nsGlobalWindowInner::ScheduleActiveTimerCallback");
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
 nsresult
@@ -5380,17 +5374,17 @@ nsGlobalWindowInner::ShowSlowScriptDialo
   // (since that spins the event loop). In that (rare) case, we just kill the
   // script and report a warning.
   if (!nsContentUtils::IsSafeToRunScript()) {
     JS_ReportWarningASCII(cx, "A long running script was terminated");
     return KillSlowScript;
   }
 
   // If our document is not active, just kill the script: we've been unloaded
-  if (!AsInner()->HasActiveDocument()) {
+  if (!HasActiveDocument()) {
     return KillSlowScript;
   }
 
   // Check if we should offer the option to debug
   JS::AutoFilename filename;
   unsigned lineno;
   // Computing the line number can be very expensive (see bug 1330231 for
   // example), and we don't use the line number anywhere except than in the
@@ -5796,28 +5790,28 @@ nsGlobalWindowInner::Observe(nsISupports
   }
 
   if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_IDLE)) {
     mCurrentlyIdle = true;
     if (IsFrozen()) {
       // need to fire only one idle event while the window is frozen.
       mNotifyIdleObserversIdleOnThaw = true;
       mNotifyIdleObserversActiveOnThaw = false;
-    } else if (AsInner()->IsCurrentInnerWindow()) {
+    } else if (IsCurrentInnerWindow()) {
       HandleIdleActiveEvent();
     }
     return NS_OK;
   }
 
   if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_ACTIVE)) {
     mCurrentlyIdle = false;
     if (IsFrozen()) {
       mNotifyIdleObserversActiveOnThaw = true;
       mNotifyIdleObserversIdleOnThaw = false;
-    } else if (AsInner()->IsCurrentInnerWindow()) {
+    } else if (IsCurrentInnerWindow()) {
       MOZ_ASSERT(IsInnerWindow());
       ScheduleActiveTimerCallback();
     }
     return NS_OK;
   }
 
   if (!nsCRT::strcmp(aTopic, "offline-cache-update-added")) {
     if (mApplicationCache)
@@ -5846,17 +5840,17 @@ nsGlobalWindowInner::Observe(nsISupports
     // very likely situation where an event handler will try to read its value.
 
     if (mNavigator) {
       NavigatorBinding::ClearCachedLanguageValue(mNavigator);
       NavigatorBinding::ClearCachedLanguagesValue(mNavigator);
     }
 
     // The event has to be dispatched only to the current inner window.
-    if (!AsInner()->IsCurrentInnerWindow()) {
+    if (!IsCurrentInnerWindow()) {
       return NS_OK;
     }
 
     RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
     event->InitEvent(NS_LITERAL_STRING("languagechange"), false, false);
     event->SetTrusted(true);
 
     bool dummy;
@@ -5880,17 +5874,17 @@ nsGlobalWindowInner::ObserveStorageNotif
   if (aPrivateBrowsing != IsPrivateBrowsing()) {
     return;
   }
 
   // LocalStorage can only exist on an inner window, and we don't want to
   // generate events on frozen or otherwise-navigated-away from windows.
   // (Actually, this code used to try and buffer events for frozen windows,
   // but it never worked, so we've removed it.  See bug 1285898.)
-  if (!IsInnerWindow() || !AsInner()->IsCurrentInnerWindow() || IsFrozen()) {
+  if (!IsInnerWindow() || !IsCurrentInnerWindow() || IsFrozen()) {
     return;
   }
 
   nsIPrincipal *principal = GetPrincipal();
   if (!principal) {
     return;
   }
 
@@ -6025,17 +6019,17 @@ nsGlobalWindowInner::Suspend()
   // 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
   // windows into the bfcache.  It only expects windows suspended due to the
   // Freeze() method which occurs while the window is still the current inner.
   // So we must not call Suspend() on bfcache windows at this point or this
   // 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()) {
+  if (!IsCurrentInnerWindow()) {
     return;
   }
 
   // All children are also suspended.  This ensure mSuspendDepth is
   // set properly and the timers are properly canceled for each child.
   CallOnChildren(&nsGlobalWindowInner::Suspend);
 
   mSuspendDepth += 1;
@@ -6046,17 +6040,17 @@ nsGlobalWindowInner::Suspend()
   nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
   if (ac) {
     for (uint32_t i = 0; i < mEnabledSensors.Length(); i++)
       ac->RemoveWindowListener(mEnabledSensors[i], this);
   }
   DisableGamepadUpdates();
   DisableVRUpdates();
 
-  mozilla::dom::workers::SuspendWorkersForWindow(AsInner());
+  mozilla::dom::workers::SuspendWorkersForWindow(this);
 
   SuspendIdleRequests();
 
   mTimeoutManager->Suspend();
 
   // Suspend all of the AudioContexts for this window
   for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
     ErrorResult dummy;
@@ -6071,17 +6065,17 @@ nsGlobalWindowInner::Resume()
   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()) {
+  if (!IsCurrentInnerWindow()) {
     return;
   }
 
   // Resume all children.  This restores timers recursively canceled
   // in Suspend() and ensures all children have the correct mSuspendDepth.
   CallOnChildren(&nsGlobalWindowInner::Resume);
 
   MOZ_ASSERT(mSuspendDepth != 0);
@@ -6109,17 +6103,17 @@ nsGlobalWindowInner::Resume()
 
   mTimeoutManager->Resume();
 
   ResumeIdleRequests();
 
   // 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());
+  mozilla::dom::workers::ResumeWorkersForWindow(this);
 }
 
 bool
 nsGlobalWindowInner::IsSuspended() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   return mSuspendDepth != 0;
 }
@@ -6132,67 +6126,67 @@ nsGlobalWindowInner::Freeze()
   FreezeInternal();
 }
 
 void
 nsGlobalWindowInner::FreezeInternal()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(IsInnerWindow());
-  MOZ_DIAGNOSTIC_ASSERT(AsInner()->IsCurrentInnerWindow());
+  MOZ_DIAGNOSTIC_ASSERT(IsCurrentInnerWindow());
   MOZ_DIAGNOSTIC_ASSERT(IsSuspended());
 
   CallOnChildren(&nsGlobalWindowInner::FreezeInternal);
 
   mFreezeDepth += 1;
   MOZ_ASSERT(mSuspendDepth >= mFreezeDepth);
   if (mFreezeDepth != 1) {
     return;
   }
 
-  mozilla::dom::workers::FreezeWorkersForWindow(AsInner());
+  mozilla::dom::workers::FreezeWorkersForWindow(this);
 
   mTimeoutManager->Freeze();
 
   if (IsInnerWindow()) {
-    NotifyDOMWindowFrozen(AssertInner());
+    NotifyDOMWindowFrozen(this);
   }
 }
 
 void
 nsGlobalWindowInner::Thaw()
 {
   MOZ_ASSERT(NS_IsMainThread());
   ThawInternal();
   Resume();
 }
 
 void
 nsGlobalWindowInner::ThawInternal()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(IsInnerWindow());
-  MOZ_DIAGNOSTIC_ASSERT(AsInner()->IsCurrentInnerWindow());
+  MOZ_DIAGNOSTIC_ASSERT(IsCurrentInnerWindow());
   MOZ_DIAGNOSTIC_ASSERT(IsSuspended());
 
   CallOnChildren(&nsGlobalWindowInner::ThawInternal);
 
   MOZ_ASSERT(mFreezeDepth != 0);
   mFreezeDepth -= 1;
   MOZ_ASSERT(mSuspendDepth >= mFreezeDepth);
   if (mFreezeDepth != 0) {
     return;
   }
 
   mTimeoutManager->Thaw();
 
-  mozilla::dom::workers::ThawWorkersForWindow(AsInner());
+  mozilla::dom::workers::ThawWorkersForWindow(this);
 
   if (IsInnerWindow()) {
-    NotifyDOMWindowThawed(AssertInner());
+    NotifyDOMWindowThawed(this);
   }
 }
 
 bool
 nsGlobalWindowInner::IsFrozen() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   bool frozen = mFreezeDepth != 0;
@@ -6201,17 +6195,17 @@ nsGlobalWindowInner::IsFrozen() const
 }
 
 void
 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());
+  MOZ_ASSERT(IsCurrentInnerWindow());
   nsPIDOMWindowOuter* outer = GetOuterWindow();
   MOZ_ASSERT(outer);
 
   // Attempt to find our parent windows.
   nsCOMPtr<Element> frame = outer->GetFrameElementInternal();
   nsPIDOMWindowOuter* parentOuter = frame ? frame->OwnerDoc()->GetWindow()
                                           : nullptr;
   nsGlobalWindowInner* parentInner =
@@ -6246,17 +6240,17 @@ nsGlobalWindowInner::SyncStateFromParent
 }
 
 template<typename Method>
 void
 nsGlobalWindowInner::CallOnChildren(Method aMethod)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(IsInnerWindow());
-  MOZ_ASSERT(AsInner()->IsCurrentInnerWindow());
+  MOZ_ASSERT(IsCurrentInnerWindow());
 
   nsCOMPtr<nsIDocShell> docShell = GetDocShell();
   if (!docShell) {
     return;
   }
 
   int32_t childCount = 0;
   docShell->GetChildCount(&childCount);
@@ -6410,17 +6404,17 @@ nsGlobalWindowInner::SetTimeoutOrInterva
   }
 
   if (inner != this) {
     return inner->SetTimeoutOrInterval(aCx, aFunction, aTimeout, aArguments,
                                        aIsInterval, aError);
   }
 
   nsCOMPtr<nsIScriptTimeoutHandler> handler =
-    NS_CreateJSTimeoutHandler(aCx, AssertInner(), aFunction, aArguments, aError);
+    NS_CreateJSTimeoutHandler(aCx, this, aFunction, aArguments, aError);
   if (!handler) {
     return 0;
   }
 
   int32_t result;
   aError = mTimeoutManager->SetTimeout(handler, aTimeout, aIsInterval,
                                       Timeout::Reason::eTimeoutOrInterval,
                                       &result);
@@ -6438,17 +6432,17 @@ nsGlobalWindowInner::SetTimeoutOrInterva
   }
 
   if (inner != this) {
     return inner->SetTimeoutOrInterval(aCx, aHandler, aTimeout, aIsInterval,
                                        aError);
   }
 
   nsCOMPtr<nsIScriptTimeoutHandler> handler =
-    NS_CreateJSTimeoutHandler(aCx, AssertInner(), aHandler, aError);
+    NS_CreateJSTimeoutHandler(aCx, this, aHandler, aError);
   if (!handler) {
     return 0;
   }
 
   int32_t result;
   aError = mTimeoutManager->SetTimeout(handler, aTimeout, aIsInterval,
                                       Timeout::Reason::eTimeoutOrInterval,
                                       &result);
@@ -6691,17 +6685,17 @@ nsGlobalWindowInner::DisableDeviceSensor
 #if defined(MOZ_WIDGET_ANDROID)
 void
 nsGlobalWindowInner::EnableOrientationChangeListener()
 {
   MOZ_ASSERT(IsInnerWindow());
   if (!nsContentUtils::ShouldResistFingerprinting(mDocShell) &&
       !mOrientationChangeObserver) {
     mOrientationChangeObserver =
-      MakeUnique<WindowOrientationObserver>(AssertInner());
+      MakeUnique<WindowOrientationObserver>(this);
   }
 }
 
 void
 nsGlobalWindowInner::DisableOrientationChangeListener()
 {
   MOZ_ASSERT(IsInnerWindow());
 
@@ -6802,23 +6796,23 @@ nsGlobalWindowInner::IsVRContentPresenti
     }
   }
   return false;
 }
 
 void
 nsGlobalWindowInner::EnableTimeChangeNotifications()
 {
-  mozilla::time::AddWindowListener(AsInner());
+  mozilla::time::AddWindowListener(this);
 }
 
 void
 nsGlobalWindowInner::DisableTimeChangeNotifications()
 {
-  mozilla::time::RemoveWindowListener(AsInner());
+  mozilla::time::RemoveWindowListener(this);
 }
 
 void
 nsGlobalWindowInner::AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const
 {
   aWindowSizes.mDOMOtherSize += aWindowSizes.mState.mMallocSizeOf(this);
 
   EventListenerManager* elm = GetExistingListenerManager();
@@ -6827,17 +6821,17 @@ nsGlobalWindowInner::AddSizeOfIncludingT
       elm->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
     aWindowSizes.mDOMEventListenersCount += elm->ListenerCount();
   }
   if (mDoc) {
     // Multiple global windows can share a document. So only measure the
     // document if it (a) doesn't have a global window, or (b) it's the
     // primary document for the window.
     if (!mDoc->GetInnerWindow() ||
-        mDoc->GetInnerWindow() == AsInner()) {
+        mDoc->GetInnerWindow() == this) {
       mDoc->DocAddSizeOfIncludingThis(aWindowSizes);
     }
   }
 
   if (mNavigator) {
     aWindowSizes.mDOMOtherSize +=
       mNavigator->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
   }
@@ -6964,17 +6958,17 @@ nsGlobalWindowInner::StopGamepadHaptics(
     RefPtr<GamepadManager> gamepadManager(GamepadManager::GetService());
     gamepadManager->StopHaptics();
   }
 }
 
 bool
 nsGlobalWindowInner::UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDevices)
 {
-  VRDisplay::UpdateVRDisplays(mVRDisplays, AsInner());
+  VRDisplay::UpdateVRDisplays(mVRDisplays, this);
   aDevices = mVRDisplays;
   return true;
 }
 
 void
 nsGlobalWindowInner::NotifyActiveVRDisplaysChanged()
 {
   MOZ_ASSERT(IsInnerWindow());
@@ -7445,17 +7439,17 @@ nsGlobalWindowInner::Orientation(CallerT
 #endif
 
 Console*
 nsGlobalWindowInner::GetConsole(ErrorResult& aRv)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mConsole) {
-    mConsole = Console::Create(AsInner(), aRv);
+    mConsole = Console::Create(this, aRv);
     if (NS_WARN_IF(aRv.Failed())) {
       return nullptr;
     }
   }
 
   return mConsole;
 }
 
@@ -7523,18 +7517,18 @@ nsGlobalWindowInner::GetSidebar(OwningEx
 }
 
 void
 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())) {
+  if (!WindowBinding::ClearCachedDocumentValue(aCx, this) ||
+      !WindowBinding::ClearCachedPerformanceValue(aCx, this)) {
     MOZ_CRASH("Unhandlable OOM while clearing document dependent slots.");
   }
 }
 
 /* static */
 JSObject*
 nsGlobalWindowInner::CreateNamedPropertiesObject(JSContext *aCx,
                                             JS::Handle<JSObject*> aProto)
@@ -7886,17 +7880,17 @@ nsGlobalWindowInner::GetAudioWorklet(Err
 
   if (!mAudioWorklet) {
     nsIPrincipal* principal = GetPrincipal();
     if (!principal) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
 
-    mAudioWorklet = new Worklet(AsInner(), principal, Worklet::eAudioWorklet);
+    mAudioWorklet = new Worklet(this, principal, Worklet::eAudioWorklet);
   }
 
   return mAudioWorklet;
 }
 
 Worklet*
 nsGlobalWindowInner::GetPaintWorklet(ErrorResult& aRv)
 {
@@ -7904,17 +7898,17 @@ nsGlobalWindowInner::GetPaintWorklet(Err
 
   if (!mPaintWorklet) {
     nsIPrincipal* principal = GetPrincipal();
     if (!principal) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
 
-    mPaintWorklet = new Worklet(AsInner(), principal, Worklet::ePaintWorklet);
+    mPaintWorklet = new Worklet(this, principal, Worklet::ePaintWorklet);
   }
 
   return mPaintWorklet;
 }
 
 void
 nsGlobalWindowInner::GetRegionalPrefsLocales(nsTArray<nsString>& aLocales)
 {
@@ -7927,17 +7921,17 @@ nsGlobalWindowInner::GetRegionalPrefsLoc
 }
 
 IntlUtils*
 nsGlobalWindowInner::GetIntlUtils(ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mIntlUtils) {
-    mIntlUtils = new IntlUtils(AsInner());
+    mIntlUtils = new IntlUtils(this);
   }
 
   return mIntlUtils;
 }
 
 /* static */ already_AddRefed<nsGlobalWindowInner>
 nsGlobalWindowInner::Create(nsGlobalWindowOuter *aOuterWindow, bool aIsChrome)
 {
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -276,19 +276,16 @@ public:
   {
     // Make sure this matches the casts we do in QueryInterface().
     return (nsGlobalWindowInner *)(mozilla::dom::EventTarget *)supports;
   }
 
   static already_AddRefed<nsGlobalWindowInner>
   Create(nsGlobalWindowOuter* aOuter, bool aIsChrome);
 
-  nsGlobalWindowInner* AssertInner();
-  nsGlobalWindowOuter* AssertOuter();
-
   // callback for close event
   void ReallyCloseWindow();
 
   // nsISupports
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   // nsWrapperCache
   virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override
@@ -1071,18 +1068,16 @@ public:
                       mozilla::ErrorResult& aError);
 
   void GetInterface(JSContext* aCx, nsIJSID* aIID,
                     JS::MutableHandle<JS::Value> aRetval,
                     mozilla::ErrorResult& aError);
 
   already_AddRefed<nsWindowRoot> GetWindowRoot(mozilla::ErrorResult& aError);
 
-  mozilla::dom::Performance* GetPerformance();
-
   void UpdateTopInnerWindow();
 
   virtual bool IsInSyncOperation() override
   {
     return GetExtantDoc() && GetExtantDoc()->IsInSyncOperation();
   }
 
 protected:
@@ -1696,29 +1691,16 @@ nsGlobalWindowInner::IsPopupSpamWindow()
 }
 
 inline bool
 nsGlobalWindowInner::IsFrame()
 {
   return GetParentInternal() != nullptr;
 }
 
-inline nsGlobalWindowInner*
-nsGlobalWindowInner::AssertInner()
-{
-  MOZ_RELEASE_ASSERT(IsInnerWindow());
-  return static_cast<nsGlobalWindowInner*>(this);
-}
-
-inline nsGlobalWindowOuter*
-nsGlobalWindowInner::AssertOuter()
-{
-  MOZ_CRASH("nsGlobalWindowInner is not an outer window");
-}
-
 inline void
 nsGlobalWindowInner::MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner)
 {
   if(mInnerWindow == aExpectedInner->AsInner()) {
     mInnerWindow = nullptr;
   }
 }
 
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -724,17 +724,17 @@ nsGlobalWindowOuter::nsGlobalWindowOuter
   // 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());
+    sOuterWindowsById->Put(mWindowID, this);
   }
 }
 
 #ifdef DEBUG
 
 /* static */
 void
 nsGlobalWindowOuter::AssertIsOnMainThread()
@@ -824,17 +824,17 @@ nsGlobalWindowOuter::~nsGlobalWindowOute
   PRCList* w;
   while ((w = PR_LIST_HEAD(this)) != this) {
     PR_REMOVE_AND_INIT_LINK(w);
   }
 
   DropOuterWindowDocs();
 
   if (mTabGroup) {
-    mTabGroup->Leave(AsOuter());
+    mTabGroup->Leave(this);
   }
 
   // Outer windows are always supposed to call CleanUp before letting themselves
   // be destroyed.
   MOZ_ASSERT(mCleanedUp);
 
   nsCOMPtr<nsIDeviceSensors> ac = do_GetService(NS_DEVICE_SENSORS_CONTRACTID);
   if (ac)
@@ -1026,20 +1026,20 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   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(nsPIDOMWindowOuter))) {
-    foundInterface = AsOuter();
+    foundInterface = static_cast<nsPIDOMWindowOuter*>(this);
   } else
   if (aIID.Equals(NS_GET_IID(mozIDOMWindowProxy)) && IsOuterWindow()) {
-    foundInterface = AsOuter();
+    foundInterface = static_cast<mozIDOMWindowProxy*>(this);
   } else
   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
 
@@ -1192,22 +1192,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPerformance)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mServiceWorkerRegistrationTable)
 
 #ifdef MOZ_WEBSPEECH
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mSpeechSynthesis)
 #endif
 
-  if (tmp->mOuterWindow) {
-    nsGlobalWindowOuter::Cast(tmp->mOuterWindow)->
-      MaybeClearInnerWindow(tmp->AssertInner());
-    NS_IMPL_CYCLE_COLLECTION_UNLINK(mOuterWindow)
-  }
-
   if (tmp->mListenerManager) {
     tmp->mListenerManager->Disconnect();
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mListenerManager)
   }
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mTopInnerWindow)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocation)
@@ -1635,18 +1629,18 @@ nsGlobalWindowOuter::SetNewDocument(nsID
                   "mDocumentPrincipal prematurely set!");
   MOZ_ASSERT(aDocument);
 
   NS_PRECONDITION(IsOuterWindow(), "Must only be called on outer windows");
 
   // Bail out early if we're in process of closing down the window.
   NS_ENSURE_STATE(!mCleanedUp);
 
-  NS_ASSERTION(!AsOuter()->GetCurrentInnerWindow() ||
-               AsOuter()->GetCurrentInnerWindow()->GetExtantDoc() == mDoc,
+  NS_ASSERTION(!GetCurrentInnerWindow() ||
+               GetCurrentInnerWindow()->GetExtantDoc() == mDoc,
                "Uh, mDoc doesn't match the current inner window "
                "document!");
 
   bool wouldReuseInnerWindow = WouldReuseInnerWindow(aDocument);
   if (aForceReuseInnerWindow &&
       !wouldReuseInnerWindow &&
       mDoc &&
       mDoc->NodePrincipal() != aDocument->NodePrincipal()) {
@@ -1672,17 +1666,17 @@ nsGlobalWindowOuter::SetNewDocument(nsID
   if (!mDoc) {
     // First document load.
 
     // Get our private root. If it is equal to us, then we need to
     // attach our global key bindings that handles browser scrolling
     // and other browser commands.
     nsPIDOMWindowOuter* privateRoot = GetPrivateRoot();
 
-    if (privateRoot == AsOuter()) {
+    if (privateRoot == this) {
       nsXBLService::AttachGlobalKeyHandler(mChromeEventHandler);
     }
   }
 
   /* 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.) */
 
@@ -1768,17 +1762,17 @@ nsGlobalWindowOuter::SetNewDocument(nsID
       // get created with a principal that subsumes our new principal.
       xpc::ClearContentXBLScope(newInnerGlobal);
     }
   } else {
     if (aState) {
       newInnerWindow = wsh->GetInnerWindow();
       newInnerGlobal = newInnerWindow->GetWrapperPreserveColor();
     } else {
-      newInnerWindow = nsGlobalWindowInner::Create(AssertOuter(), thisChrome);
+      newInnerWindow = nsGlobalWindowInner::Create(this, thisChrome);
 
       // The outer window is automatically treated as frozen when we
       // null out the inner window. As a result, initializing classes
       // on the new inner won't end up reaching into the old inner
       // window for classes etc.
       //
       // [This happens with Object.prototype when XPConnect creates
       // a temporary global while initializing classes; the reason
@@ -2132,21 +2126,21 @@ nsGlobalWindowOuter::SetDocShell(nsIDocS
   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()) {
+    if (parentWindow.get() != this) {
       mChromeEventHandler = parentWindow->GetChromeEventHandler();
     }
     else {
-      mChromeEventHandler = NS_NewWindowRoot(AsOuter());
+      mChromeEventHandler = NS_NewWindowRoot(this);
       mIsRootOuterWindow = true;
     }
   }
 
   bool docShellActive;
   mDocShell->GetIsActive(&docShellActive);
   SetIsBackgroundInternal(!docShellActive);
 }
@@ -2166,17 +2160,17 @@ nsGlobalWindowOuter::DetachFromDocShell(
   // are GC-owned.
   RefPtr<nsGlobalWindowInner> inner;
   for (PRCList* node = PR_LIST_HEAD(this);
        node != this;
        node = PR_NEXT_LINK(inner)) {
     // This cast is safe because `node != this`. Non-this nodes are inner windows.
     inner = static_cast<nsGlobalWindowInner*>(node);
     MOZ_ASSERT(inner->IsInnerWindow());
-    MOZ_ASSERT(!inner->mOuterWindow || inner->mOuterWindow == AsOuter());
+    MOZ_ASSERT(!inner->mOuterWindow || inner->mOuterWindow == this);
     inner->FreeInnerObjects();
   }
 
   // Don't report that we were detached to the nsWindowMemoryReporter, as it
   // only tracks inner windows.
 
   NotifyWindowIDDestroyed("outer-window-destroyed");
 
@@ -2272,17 +2266,17 @@ nsGlobalWindowOuter::UpdateParentTarget(
 
   nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal();
   nsCOMPtr<EventTarget> eventTarget =
     TryGetTabChildGlobalAsEventTarget(frameElement);
 
   if (!eventTarget) {
     nsGlobalWindowOuter* topWin = GetScriptableTopInternal();
     if (topWin) {
-      frameElement = topWin->AsOuter()->GetFrameElementInternal();
+      frameElement = topWin->GetFrameElementInternal();
       eventTarget = TryGetTabChildGlobalAsEventTarget(frameElement);
     }
   }
 
   if (!eventTarget) {
     eventTarget = TryGetTabChildGlobalAsEventTarget(mChromeEventHandler);
   }
 
@@ -2397,17 +2391,17 @@ nsGlobalWindowOuter::ConfirmDialogIfNeed
   nsAutoPopupStatePusher popupStatePusher(openAbused, true);
 
   bool disableDialog = false;
   nsAutoString label, title;
   nsContentUtils::GetLocalizedString(nsContentUtils::eCOMMON_DIALOG_PROPERTIES,
                                      "ScriptDialogLabel", label);
   nsContentUtils::GetLocalizedString(nsContentUtils::eCOMMON_DIALOG_PROPERTIES,
                                      "ScriptDialogPreventTitle", title);
-  promptSvc->Confirm(AsOuter(), title.get(), label.get(), &disableDialog);
+  promptSvc->Confirm(this, title.get(), label.get(), &disableDialog);
   if (disableDialog) {
     DisableDialogs();
     return false;
   }
 
   return true;
 }
 
@@ -2528,17 +2522,17 @@ nsPIDOMWindowOuter::SetInitialKeyboardIn
   MOZ_ASSERT(IsOuterWindow());
   MOZ_ASSERT(!GetCurrentInnerWindow());
 
   nsPIDOMWindowOuter* piWin = GetPrivateRoot();
   if (!piWin) {
     return;
   }
 
-  MOZ_ASSERT(piWin == AsOuter());
+  MOZ_ASSERT(piWin == this);
 
   // only change the flags that have been modified
   nsCOMPtr<nsPIWindowRoot> windowRoot = do_QueryInterface(mChromeEventHandler);
   if (!windowRoot) {
     return;
   }
 
   if (aShowAccelerators != UIStateChangeType_NoChange) {
@@ -2723,17 +2717,17 @@ nsGlobalWindowOuter::GetParentOuter()
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return nullptr;
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> parent;
   if (mDocShell->GetIsMozBrowser()) {
-    parent = AsOuter();
+    parent = this;
   } else {
     parent = GetParent();
   }
 
   return parent.forget();
 }
 
 /**
@@ -2777,29 +2771,29 @@ nsGlobalWindowOuter::GetParent()
   nsCOMPtr<nsIDocShell> parent;
   mDocShell->GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent));
 
   if (parent) {
     nsCOMPtr<nsPIDOMWindowOuter> win = parent->GetWindow();
     return win.forget();
   }
 
-  nsCOMPtr<nsPIDOMWindowOuter> win(AsOuter());
+  nsCOMPtr<nsPIDOMWindowOuter> win(this);
   return win.forget();
 }
 
 static nsresult
 GetTopImpl(nsGlobalWindowOuter* aWin, nsPIDOMWindowOuter** aTop, bool aScriptable)
 {
   *aTop = nullptr;
 
   // Walk up the parent chain.
 
-  nsCOMPtr<nsPIDOMWindowOuter> prevParent = aWin->AsOuter();
-  nsCOMPtr<nsPIDOMWindowOuter> parent = aWin->AsOuter();
+  nsCOMPtr<nsPIDOMWindowOuter> prevParent = aWin;
+  nsCOMPtr<nsPIDOMWindowOuter> parent = aWin;
   do {
     if (!parent) {
       break;
     }
 
     prevParent = parent;
 
     nsCOMPtr<nsPIDOMWindowOuter> newParent;
@@ -2827,26 +2821,26 @@ GetTopImpl(nsGlobalWindowOuter* aWin, ns
  * 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*
 nsGlobalWindowOuter::GetScriptableTop()
 {
   nsCOMPtr<nsPIDOMWindowOuter> window;
-  GetTopImpl(AssertOuter(), getter_AddRefs(window), /* aScriptable = */ true);
+  GetTopImpl(this, getter_AddRefs(window), /* aScriptable = */ true);
   return window.get();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
 nsGlobalWindowOuter::GetTop()
 {
   MOZ_ASSERT(IsOuterWindow());
   nsCOMPtr<nsPIDOMWindowOuter> window;
-  GetTopImpl(AssertOuter(), getter_AddRefs(window), /* aScriptable = */ false);
+  GetTopImpl(this, getter_AddRefs(window), /* aScriptable = */ false);
   return window.forget();
 }
 
 void
 nsGlobalWindowOuter::GetContentOuter(JSContext* aCx,
                                 JS::MutableHandle<JSObject*> aRetval,
                                 CallerType aCallerType,
                                 ErrorResult& aError)
@@ -4411,17 +4405,17 @@ nsGlobalWindowOuter::SetFullscreenIntern
   // gone full screen, the state trap above works.
   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)) {
+    if (MakeWidgetFullscreen(this, aReason, aFullScreen)) {
       // The rest of code for switching fullscreen is in nsGlobalWindowOuter::
       // FinishFullscreenChange() which will be called after sizemodechange
       // event is dispatched.
       return NS_OK;
     }
   }
 
   FinishFullscreenChange(aFullScreen);
@@ -4429,17 +4423,17 @@ nsGlobalWindowOuter::SetFullscreenIntern
 }
 
 bool
 nsGlobalWindowOuter::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(!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);
@@ -4514,17 +4508,17 @@ nsGlobalWindowOuter::FinishFullscreenCha
       power::PowerManagerService::GetInstance();
     if (!pmService) {
       return;
     }
 
     // XXXkhuey using the inner here, do we need to do something if it changes?
     ErrorResult rv;
     mWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("DOM_Fullscreen"),
-                                       AsOuter()->GetCurrentInnerWindow(), rv);
+                                       GetCurrentInnerWindow(), rv);
     NS_WARNING_ASSERTION(!rv.Failed(), "Failed to lock the wakelock");
     rv.SuppressException();
   } else if (mWakeLock && !mFullScreen) {
     ErrorResult rv;
     mWakeLock->Unlock(rv);
     mWakeLock = nullptr;
     rv.SuppressException();
   }
@@ -4752,17 +4746,17 @@ nsGlobalWindowOuter::AlertOrConfirm(bool
   nsCOMPtr<nsIPromptFactory> promptFac =
     do_GetService("@mozilla.org/prompter;1", &rv);
   if (NS_FAILED(rv)) {
     aError.Throw(rv);
     return false;
   }
 
   nsCOMPtr<nsIPrompt> prompt;
-  aError = promptFac->GetPrompt(AsOuter(), NS_GET_IID(nsIPrompt),
+  aError = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
                                 getter_AddRefs(prompt));
   if (aError.Failed()) {
     return false;
   }
 
   // Always allow tab modal prompts for alert and confirm.
   if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt)) {
     promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), true);
@@ -4853,17 +4847,17 @@ nsGlobalWindowOuter::PromptOuter(const n
   nsCOMPtr<nsIPromptFactory> promptFac =
     do_GetService("@mozilla.org/prompter;1", &rv);
   if (NS_FAILED(rv)) {
     aError.Throw(rv);
     return;
   }
 
   nsCOMPtr<nsIPrompt> prompt;
-  aError = promptFac->GetPrompt(AsOuter(), NS_GET_IID(nsIPrompt),
+  aError = promptFac->GetPrompt(this, NS_GET_IID(nsIPrompt),
                                 getter_AddRefs(prompt));
   if (aError.Failed()) {
     return;
   }
 
   // Always allow tab modal prompts for prompt.
   if (nsCOMPtr<nsIWritablePropertyBag2> promptBag = do_QueryInterface(prompt)) {
     promptBag->SetPropertyAsBool(NS_LITERAL_STRING("allowTabModal"), true);
@@ -4963,17 +4957,17 @@ nsGlobalWindowOuter::FocusOuter(ErrorRes
   }
 
   nsCOMPtr<nsIPresShell> presShell;
   // Don't look for a presshell if we're a root chrome window that's got
   // about:blank loaded.  We don't want to focus our widget in that case.
   // XXXbz should we really be checking for IsInitialDocument() instead?
   bool lookForPresShell = true;
   if (mDocShell->ItemType() == nsIDocShellTreeItem::typeChrome &&
-      GetPrivateRoot() == AsOuter() && mDoc) {
+      GetPrivateRoot() == this && mDoc) {
     nsIURI* ourURI = mDoc->GetDocumentURI();
     if (ourURI) {
       lookForPresShell = !NS_IsAboutBlank(ourURI);
     }
   }
 
   if (lookForPresShell) {
     mDocShell->GetEldestPresShell(getter_AddRefs(presShell));
@@ -5001,17 +4995,17 @@ nsGlobalWindowOuter::FocusOuter(ErrorRes
     }
     return;
   }
 
   if (canFocus) {
     // 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());
+    aError = fm->SetActiveWindow(this);
   }
 }
 
 nsresult
 nsGlobalWindowOuter::Focus()
 {
   FORWARD_TO_INNER(Focus, (), NS_ERROR_UNEXPECTED);
 }
@@ -5035,20 +5029,20 @@ nsGlobalWindowOuter::BlurOuter()
   if (siteWindow) {
     // This method call may cause mDocShell to become nullptr.
     siteWindow->Blur();
 
     // if the root is focused, clear the focus
     nsIFocusManager* fm = nsFocusManager::GetFocusManager();
     if (fm && mDoc) {
       nsCOMPtr<nsIDOMElement> element;
-      fm->GetFocusedElementForWindow(AsOuter(), false, nullptr, getter_AddRefs(element));
+      fm->GetFocusedElementForWindow(this, false, nullptr, getter_AddRefs(element));
       nsCOMPtr<nsIContent> content = do_QueryInterface(element);
       if (content == mDoc->GetRootElement()) {
-        fm->ClearFocus(AsOuter());
+        fm->ClearFocus(this);
       }
     }
   }
 }
 
 void
 nsGlobalWindowOuter::BackOuter(ErrorResult& aError)
 {
@@ -5581,17 +5575,17 @@ nsGlobalWindowOuter::CanSetProperty(cons
 
 bool
 nsGlobalWindowOuter::PopupWhitelisted()
 {
   if (!IsPopupBlocked(mDoc))
     return true;
 
   nsCOMPtr<nsPIDOMWindowOuter> parent = GetParent();
-  if (parent == AsOuter())
+  if (parent == this)
   {
     return false;
   }
 
   return nsGlobalWindowOuter::Cast(parent)->PopupWhitelisted();
 }
 
 /*
@@ -5794,17 +5788,17 @@ nsGlobalWindowOuter::OpenDialogOuter(JSC
                         false,            // aForceNoOpener
                         getter_AddRefs(dialog));
   return dialog.forget();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
 nsGlobalWindowOuter::GetFramesOuter()
 {
-  RefPtr<nsPIDOMWindowOuter> frames(AsOuter());
+  RefPtr<nsPIDOMWindowOuter> frames(this);
   FlushPendingNotifications(FlushType::ContentAndNotify);
   return frames.forget();
 }
 
 nsGlobalWindowInner*
 nsGlobalWindowOuter::CallerInnerWindow()
 {
   JSContext *cx = nsContentUtils::GetCurrentJSContext();
@@ -5968,17 +5962,17 @@ nsGlobalWindowOuter::PostMessageMozOuter
 
   // Create and asynchronously dispatch a runnable which will handle actual DOM
   // event creation and dispatch.
   RefPtr<PostMessageEvent> event =
     new PostMessageEvent(nsContentUtils::IsCallerChrome() || !callerInnerWin
                          ? nullptr
                          : callerInnerWin->GetOuterWindowInternal(),
                          origin,
-                         AssertOuter(),
+                         this,
                          providedPrincipal,
                          callerInnerWin
                          ? callerInnerWin->GetDoc()
                          : nullptr,
                          nsContentUtils::IsCallerChrome());
 
   JS::Rooted<JS::Value> message(aCx, aMessage);
   JS::Rooted<JS::Value> transfer(aCx, aTransfer);
@@ -6197,18 +6191,18 @@ nsGlobalWindowOuter::FinalClose()
   //
   // In particular, if some inner of |win| is the entry global, we must
   // complete _two_ round-trips to the event loop before the call to
   // ReallyCloseWindow. This allows setTimeout handlers that are set after
   // FinalClose() is called to run before the window is torn down.
   nsCOMPtr<nsPIDOMWindowInner> entryWindow =
     do_QueryInterface(GetEntryGlobal());
   bool indirect =
-    entryWindow && entryWindow->GetOuterWindow() == this->AsOuter();
-  if (NS_FAILED(nsCloseEvent::PostCloseEvent(AssertOuter(), indirect))) {
+    entryWindow && entryWindow->GetOuterWindow() == this;
+  if (NS_FAILED(nsCloseEvent::PostCloseEvent(this, indirect))) {
     ReallyCloseWindow();
   } else {
     mHavePendingClose = true;
   }
 }
 
 
 void
@@ -6244,17 +6238,17 @@ nsGlobalWindowOuter::ReallyCloseWindow()
            to prevent an errant tab from doing so when it shouldn't.
            This works because we reach this code when we shouldn't only
            in the particular circumstance that we belong to a tab
            that has just been closed (and is therefore already missing
            from the list of browsers) (and has an unload handler
            that closes the window). */
         // XXXbz now that we have mHavePendingClose, is this needed?
         bool isTab;
-        if (rootWin == AsOuter() ||
+        if (rootWin == this ||
             !bwin ||
             (NS_SUCCEEDED(bwin->IsTabContentWindow(GetOuterWindowInternal(),
                                                    &isTab)) && isTab)) {
           treeOwnerAsWin->Destroy();
         }
       }
     }
 
@@ -6571,18 +6565,18 @@ nsGlobalWindowOuter::FindOuter(const nsA
   finder->SetSearchFrames(aSearchInFrames);
 
   // the nsIWebBrowserFind is initialized to use this window
   // as the search root, but uses focus to set the current search
   // frame. If we're being called from JS (as here), this window
   // should be the current search frame.
   nsCOMPtr<nsIWebBrowserFindInFrames> framesFinder(do_QueryInterface(finder));
   if (framesFinder) {
-    framesFinder->SetRootSearchFrame(AsOuter());   // paranoia
-    framesFinder->SetCurrentSearchFrame(AsOuter());
+    framesFinder->SetRootSearchFrame(this);   // paranoia
+    framesFinder->SetCurrentSearchFrame(this);
   }
 
   if (aString.IsEmpty()) {
     return false;
   }
 
   // Launch the search with the passed in search string
   bool didFind = false;
@@ -6727,17 +6721,17 @@ nsGlobalWindowOuter::GetContextForEventH
 
 nsPIDOMWindowOuter*
 nsGlobalWindowOuter::GetPrivateParent()
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsCOMPtr<nsPIDOMWindowOuter> parent = GetParent();
 
-  if (AsOuter() == parent) {
+  if (this == parent) {
     nsCOMPtr<nsIContent> chromeElement(do_QueryInterface(mChromeEventHandler));
     if (!chromeElement)
       return nullptr;             // This is ok, just means a null parent.
 
     nsIDocument* doc = chromeElement->GetComposedDoc();
     if (!doc)
       return nullptr;             // This is ok, just means a null parent.
 
@@ -6857,17 +6851,17 @@ nsGlobalWindowOuter::IsTopLevelWindowAct
    return domWindow && domWindow->IsActive();
 }
 
 void
 nsGlobalWindowOuter::SetIsBackground(bool aIsBackground)
 {
   MOZ_ASSERT(IsOuterWindow());
 
-  bool changed = aIsBackground != AsOuter()->IsBackground();
+  bool changed = aIsBackground != IsBackground();
   SetIsBackgroundInternal(aIsBackground);
 
   nsGlobalWindowInner* inner = GetCurrentInnerWindowInternal();
 
   if (inner && changed) {
     inner->mTimeoutManager->UpdateBackgroundState();
   }
 
@@ -6917,17 +6911,17 @@ nsGlobalWindowOuter::SetChromeEventHandl
   // update the chrome event handler on all our inner windows
   RefPtr<nsGlobalWindowInner> inner;
   for (PRCList* node = PR_LIST_HEAD(this);
        node != this;
        node = PR_NEXT_LINK(inner)) {
     // This cast is only safe if `node != this`, as nsGlobalWindowOuter is also
     // in the list.
     inner = static_cast<nsGlobalWindowInner*>(node);
-    NS_ASSERTION(!inner->mOuterWindow || inner->mOuterWindow == AsOuter(),
+    NS_ASSERTION(!inner->mOuterWindow || inner->mOuterWindow == this,
                  "bad outer window pointer");
     inner->SetChromeEventHandlerInternal(aChromeEventHandler);
   }
 }
 
 void
 nsGlobalWindowOuter::SetFocusedNode(nsIContent* aNode,
                                uint32_t aFocusMethod,
@@ -6954,17 +6948,17 @@ nsGlobalWindowOuter::SetKeyboardIndicato
 {
   MOZ_ASSERT(IsOuterWindow());
 
   nsPIDOMWindowOuter* piWin = GetPrivateRoot();
   if (!piWin) {
     return;
   }
 
-  MOZ_ASSERT(piWin == AsOuter());
+  MOZ_ASSERT(piWin == this);
 
   bool oldShouldShowFocusRing = ShouldShowFocusRing();
 
   // only change the flags that have been modified
   nsCOMPtr<nsPIWindowRoot> windowRoot = do_QueryInterface(mChromeEventHandler);
   if (!windowRoot) {
     return;
   }
@@ -7188,17 +7182,17 @@ nsGlobalWindowOuter::FireDelayedDOMEvent
 // nsGlobalWindowOuter: Window Control Functions
 //*****************************************************************************
 
 nsPIDOMWindowOuter*
 nsGlobalWindowOuter::GetParentInternal()
 {
   nsCOMPtr<nsPIDOMWindowOuter> parent = GetParent();
 
-  if (parent && parent != AsOuter()) {
+  if (parent && parent != this) {
     return parent;
   }
 
   return nullptr;
 }
 
 void
 nsGlobalWindowOuter::UnblockScriptedClosing()
@@ -7322,19 +7316,19 @@ nsGlobalWindowOuter::OpenInternal(const 
         // But if we're doing a window.open on ourselves and block the popup,
         // prevent this window from closing until after this script terminates
         // so that whatever popup blocker UI the app has will be visible.
         nsCOMPtr<nsPIDOMWindowInner> entryWindow =
           do_QueryInterface(GetEntryGlobal());
         // Note that entryWindow can be null here if some JS component was the
         // place where script was entered for this JS execution.
         if (entryWindow &&
-            entryWindow->GetOuterWindow() == this->AsOuter()) {
+            entryWindow->GetOuterWindow() == this) {
           mBlockScriptedClosingFlag = true;
-          closeUnblocker.emplace(AssertOuter());
+          closeUnblocker.emplace(this);
         }
       }
 
       FireAbuseEvents(aUrl, aName, aOptions);
       return aDoJSFixups ? NS_OK : NS_ERROR_FAILURE;
     }
   }
 
@@ -7364,17 +7358,17 @@ nsGlobalWindowOuter::OpenInternal(const 
     // Reset popup state while opening a window to prevent the
     // current state from being active the whole time a modal
     // dialog is open.
     nsAutoPopupStatePusher popupStatePusher(openAbused, true);
 
     if (!aCalledNoScript) {
       // We asserted at the top of this function that aNavigate is true for
       // !aCalledNoScript.
-      rv = pwwatch->OpenWindow2(AsOuter(), url.IsVoid() ? nullptr : url.get(),
+      rv = pwwatch->OpenWindow2(this, url.IsVoid() ? nullptr : url.get(),
                                 name_ptr,
                                 options_ptr, /* aCalledFromScript = */ true,
                                 aDialog, aNavigate, argv,
                                 isPopupSpamWindow,
                                 forceNoOpener,
                                 aLoadInfo,
                                 getter_AddRefs(domReturn));
     } else {
@@ -7387,17 +7381,17 @@ nsGlobalWindowOuter::OpenInternal(const 
       // that we don't force a system caller here, because that screws it up
       // when it tries to compute the caller principal to associate with dialog
       // arguments. That whole setup just really needs to be rewritten. :-(
       Maybe<AutoNoJSAPI> nojsapi;
       if (!aContentModal) {
         nojsapi.emplace();
       }
 
-      rv = pwwatch->OpenWindow2(AsOuter(), url.IsVoid() ? nullptr : url.get(),
+      rv = pwwatch->OpenWindow2(this, url.IsVoid() ? nullptr : url.get(),
                                 name_ptr,
                                 options_ptr, /* aCalledFromScript = */ false,
                                 aDialog, aNavigate, aExtraArgument,
                                 isPopupSpamWindow,
                                 forceNoOpener,
                                 aLoadInfo,
                                 getter_AddRefs(domReturn));
 
@@ -7492,17 +7486,17 @@ nsGlobalWindowOuter::GetScrollFrame()
   return nullptr;
 }
 
 nsresult
 nsGlobalWindowOuter::SecurityCheckURL(const char *aURL)
 {
   nsCOMPtr<nsPIDOMWindowInner> sourceWindow = do_QueryInterface(GetEntryGlobal());
   if (!sourceWindow) {
-    sourceWindow = AsOuter()->GetCurrentInnerWindow();
+    sourceWindow = GetCurrentInnerWindow();
   }
   AutoJSContext cx;
   nsGlobalWindowInner* sourceWin = nsGlobalWindowInner::Cast(sourceWindow);
   JSAutoCompartment ac(cx, sourceWin->GetGlobalJSObject());
 
   // Resolve the baseURI, which could be relative to the calling window.
   //
   // Note the algorithm to get the base URI should match the one
@@ -7990,27 +7984,27 @@ nsGlobalWindowOuter::TabGroupOuter()
     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());
+      toJoin = TabGroup::GetFromWindow(this);
     }
 
 #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());
+    mozilla::dom::TabGroup* testGroup = TabGroup::GetFromWindow(this);
     MOZ_ASSERT_IF(testGroup, testGroup == toJoin);
 #endif
 
-    mTabGroup = mozilla::dom::TabGroup::Join(AsOuter(), toJoin);
+    mTabGroup = mozilla::dom::TabGroup::Join(this, 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
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -266,19 +266,16 @@ public:
   static nsGlobalWindowOuter *FromSupports(nsISupports *supports)
   {
     // Make sure this matches the casts we do in QueryInterface().
     return (nsGlobalWindowOuter *)(mozilla::dom::EventTarget *)supports;
   }
 
   static already_AddRefed<nsGlobalWindowOuter> Create(bool aIsChrome);
 
-  nsGlobalWindowInner* AssertInner();
-  nsGlobalWindowOuter* AssertOuter();
-
   // public methods
   nsPIDOMWindowOuter* GetPrivateParent();
 
   // callback for close event
   void ReallyCloseWindow();
 
   // nsISupports
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@@ -1527,29 +1524,16 @@ nsGlobalWindowOuter::IsPopupSpamWindow()
 }
 
 inline bool
 nsGlobalWindowOuter::IsFrame()
 {
   return GetParentInternal() != nullptr;
 }
 
-inline nsGlobalWindowInner*
-nsGlobalWindowOuter::AssertInner()
-{
-  MOZ_CRASH("nsGlobalWindowOuter is not an inner window");
-}
-
-inline nsGlobalWindowOuter*
-nsGlobalWindowOuter::AssertOuter()
-{
-  MOZ_RELEASE_ASSERT(IsOuterWindow());
-  return static_cast<nsGlobalWindowOuter*>(this);
-}
-
 inline void
 nsGlobalWindowOuter::MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner)
 {
   if(mInnerWindow == aExpectedInner->AsInner()) {
     mInnerWindow = nullptr;
   }
 }
 
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -739,17 +739,17 @@ PeerConnectionImpl::Initialize(PeerConne
   PeerConnectionConfiguration converted;
   nsresult res = converted.Init(aConfiguration);
   if (NS_FAILED(res)) {
     CSFLogError(LOGTAG, "%s: Invalid RTCConfiguration", __FUNCTION__);
     rv.Throw(res);
     return;
   }
 
-  res = Initialize(aObserver, aWindow.AssertInner(), converted, aThread);
+  res = Initialize(aObserver, &aWindow, converted, aThread);
   if (NS_FAILED(res)) {
     rv.Throw(res);
     return;
   }
 
   if (!aConfiguration.mPeerIdentity.IsEmpty()) {
     mPeerIdentity = new PeerIdentity(aConfiguration.mPeerIdentity);
     mPrivacyRequested = true;