Bug 1416384 - Part 2b: Get split headers building but not linking, r=smaug
authorNika Layzell <nika@thelayzells.com>
Wed, 15 Nov 2017 11:33:29 -0500
changeset 436476 028e876d02bfabc06e5945d00ee3740fb5af823b
parent 436475 a1b15fe9224ebd2aa5a0e398b31383f3e938ab87
child 436477 71a0e504ebd0dd6349a8f16b28f8fac057aa5792
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewerssmaug
bugs1416384
milestone59.0a1
Bug 1416384 - Part 2b: Get split headers building but not linking, r=smaug MozReview-Commit-ID: JRvPtQTJqSX
dom/base/moz.build
dom/base/nsGlobalWindow.h
dom/base/nsGlobalWindowInner.h
dom/base/nsGlobalWindowOuter.h
dom/webidl/IdleDeadline.webidl
dom/webidl/Window.webidl
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -384,17 +384,17 @@ SOURCES += [
     'DOMIntersectionObserver.cpp',
     # 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',
+    # 'nsGlobalWindow.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',
 ]
 
new file mode 100644
--- /dev/null
+++ b/dom/base/nsGlobalWindow.h
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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___
+
+// 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.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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___
+#ifndef nsGlobalWindowInner_h___
+#define nsGlobalWindowInner_h___
 
 #include "nsPIDOMWindow.h"
 
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include "nsRefPtrHashtable.h"
 #include "nsInterfaceHashtable.h"
 
@@ -54,33 +54,16 @@
 #include "mozilla/dom/WindowBinding.h"
 #include "Units.h"
 #include "nsComponentManagerUtils.h"
 #include "nsSize.h"
 #include "nsCheapSets.h"
 #include "mozilla/dom/ImageBitmapSource.h"
 #include "mozilla/UniquePtr.h"
 
-#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
-
 class nsIArray;
 class nsIBaseWindow;
 class nsIContent;
 class nsICSSDeclaration;
 class nsIDocShellTreeOwner;
 class nsIDOMOfflineResourceList;
 class nsIScrollableFrame;
 class nsIControllers;
@@ -91,25 +74,27 @@ class nsITabChild;
 class nsITimeoutHandler;
 class nsIWebBrowserChrome;
 class mozIDOMWindowProxy;
 
 class nsDOMWindowList;
 class nsScreen;
 class nsHistory;
 class nsGlobalWindowObserver;
-class nsGlobalWindow;
+class nsGlobalWindowOuter;
 class nsDOMWindowUtils;
 class nsIIdleService;
 struct nsRect;
 
 class nsWindowSizes;
 
 class IdleRequestExecutor;
 
+class DialogValueHolder;
+
 namespace mozilla {
 class AbstractThread;
 class DOMEventTargetHelper;
 class ThrottledEventQueue;
 namespace dom {
 class BarProp;
 struct ChannelPixelLayout;
 class Console;
@@ -192,49 +177,19 @@ struct IdleObserverHolder
   }
 
   ~IdleObserverHolder()
   {
     MOZ_COUNT_DTOR(IdleObserverHolder);
   }
 };
 
-// Helper class to manage modal dialog arguments and all their quirks.
-//
-// Given our clunky embedding APIs, modal dialog arguments need to be passed
-// as an nsISupports parameter to WindowWatcher, get stuck inside an array of
-// length 1, and then passed back to the newly-created dialog.
-//
-// However, we need to track both the caller-passed value as well as the
-// caller's, so that we can do an origin check (even for primitives) when the
-// value is accessed. This class encapsulates that magic.
-//
-// We also use the same machinery for |returnValue|, which needs similar origin
-// checks.
-class DialogValueHolder final : public nsISupports
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS(DialogValueHolder)
-
-  DialogValueHolder(nsIPrincipal* aSubject, nsIVariant* aValue)
-    : mOrigin(aSubject)
-    , mValue(aValue) {}
-  nsresult Get(nsIPrincipal* aSubject, nsIVariant** aResult);
-  void Get(JSContext* aCx, JS::Handle<JSObject*> aScope, nsIPrincipal* aSubject,
-           JS::MutableHandle<JS::Value> aResult, mozilla::ErrorResult& aError);
-private:
-  virtual ~DialogValueHolder() {}
-
-  nsCOMPtr<nsIPrincipal> mOrigin;
-  nsCOMPtr<nsIVariant> mValue;
-};
-
-class nsGlobalWindowInner;
-class nsGlobalWindowOuter;
+// NOTE: Currently this file, despite being named mozilla/dom/Window.h, exports
+// the class nsGlobalWindowInner. It will be renamed in the future to
+// mozilla::dom::Window.
 
 //*****************************************************************************
 // nsGlobalWindow: Global Object for Scripting
 //*****************************************************************************
 // Beware that all scriptable interfaces implemented by
 // nsGlobalWindow will be reachable from JS, if you make this class
 // implement new interfaces you better know what you're
 // doing. Security wise this is very sensitive code. --
@@ -255,40 +210,85 @@ class nsGlobalWindowOuter;
 // type name. nsGlobalWindow doesn't want to doubly inherit (and have two
 // copies of everything), and it also doesn't want to privilege one over
 // the other by making it possible to convert types through the C++ type system
 // instead of our accessor methods (AsInner and AsOuter) that do dynamic
 // checking. So we inherit from nsPIDOMWindow<nsISupports>, which is also
 // identical to both nsPIDOMWindowInner and nsPIDOMWindowOuter, but not
 // convertible to either.
 
-class nsGlobalWindow : public mozilla::dom::EventTarget,
-                       public nsPIDOMWindow<nsISupports>,
-                       private nsIDOMWindow,
-                       // NOTE: This interface is private, as it's only
-                       // implemented on chrome windows.
-                       private nsIDOMChromeWindow,
-                       public nsIScriptGlobalObject,
-                       public nsIScriptObjectPrincipal,
-                       public nsSupportsWeakReference,
-                       public nsIInterfaceRequestor,
-                       public PRCListStr
+class nsGlobalWindowInner : public mozilla::dom::EventTarget,
+                            public nsPIDOMWindow<nsISupports>,
+                            private nsIDOMWindow,
+                            // NOTE: This interface is private, as it's only
+                            // implemented on chrome windows.
+                            private nsIDOMChromeWindow,
+                            public nsIScriptGlobalObject,
+                            public nsIScriptObjectPrincipal,
+                            public nsSupportsWeakReference,
+                            public nsIInterfaceRequestor,
+                            public PRCListStr
 {
 public:
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::TimeDuration TimeDuration;
 
+  typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowInner*> InnerWindowByIdTable;
+
   static void
   AssertIsOnMainThread()
 #ifdef DEBUG
   ;
 #else
   { }
 #endif
 
+  static nsGlobalWindowInner* Cast(nsPIDOMWindowInner* aPIWin) {
+    return static_cast<nsGlobalWindowInner*>(
+      reinterpret_cast<nsPIDOMWindow<nsISupports>*>(aPIWin));
+  }
+  static const nsGlobalWindowInner* Cast(const nsPIDOMWindowInner* aPIWin) {
+    return static_cast<const nsGlobalWindowInner*>(
+      reinterpret_cast<const nsPIDOMWindow<nsISupports>*>(aPIWin));
+  }
+  static nsGlobalWindowInner* Cast(mozIDOMWindow* aWin) {
+    return Cast(nsPIDOMWindowInner::From(aWin));
+  }
+
+  static nsGlobalWindowInner*
+  GetInnerWindowWithId(uint64_t aInnerWindowID)
+  {
+    AssertIsOnMainThread();
+
+    if (!sInnerWindowsById) {
+      return nullptr;
+    }
+
+    nsGlobalWindowInner* innerWindow =
+      sInnerWindowsById->Get(aInnerWindowID);
+    MOZ_ASSERT(!innerWindow || innerWindow->IsInnerWindow(),
+                "Outer window in sInnerWindowsById?");
+    return innerWindow;
+  }
+
+  static InnerWindowByIdTable* GetWindowsTable() {
+    AssertIsOnMainThread();
+
+    return sInnerWindowsById;
+  }
+
+  static nsGlobalWindowInner *FromSupports(nsISupports *supports)
+  {
+    // 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();
 
   // public methods
   nsPIDOMWindowOuter* GetPrivateParent();
 
   // callback for close event
   void ReallyCloseWindow();
@@ -463,26 +463,16 @@ public:
                  JS::MutableHandle<JS::PropertyDescriptor> aDesc);
   // The return value is whether DoResolve might end up resolving the given id.
   // If in doubt, return true.
   static bool MayResolve(jsid aId);
 
   void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
                            bool aEnumerableOnly, mozilla::ErrorResult& aRv);
 
-  // Object Management
-  static nsGlobalWindow *FromSupports(nsISupports *supports)
-  {
-    // Make sure this matches the casts we do in QueryInterface().
-    return (nsGlobalWindow *)(mozilla::dom::EventTarget *)supports;
-  }
-  static nsGlobalWindow *FromWrapper(nsIXPConnectWrappedNative *wrapper)
-  {
-    return FromSupports(wrapper->Native());
-  }
   already_AddRefed<nsPIDOMWindowOuter> GetTop() override;
   nsPIDOMWindowOuter* GetScriptableTop() override;
   inline nsGlobalWindowOuter *GetTopInternal();
 
   inline nsGlobalWindowOuter* GetScriptableTopInternal();
 
   nsPIDOMWindowOuter* GetChildWindow(const nsAString& aName);
 
@@ -565,17 +555,17 @@ public:
   static void Init();
   static void ShutDown();
   static bool IsCallerChrome();
 
   void CleanupCachedXBLHandlers();
 
   friend class WindowStateHolder;
 
-  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindow,
+  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindowInner,
                                                                    nsIDOMEventTarget)
 
 #ifdef DEBUG
   // Call Unlink on this window. This may cause bad things to happen, so use
   // with caution.
   void RiskyUnlink();
 #endif
 
@@ -806,17 +796,17 @@ public:
   already_AddRefed<nsIDOMWindowCollection> GetFrames() override;
   already_AddRefed<nsPIDOMWindowOuter> GetFrames(mozilla::ErrorResult& aError);
   uint32_t Length();
   already_AddRefed<nsPIDOMWindowOuter> GetTopOuter();
   already_AddRefed<nsPIDOMWindowOuter> GetTop(mozilla::ErrorResult& aError);
 
   nsresult GetPrompter(nsIPrompt** aPrompt) override;
 protected:
-  explicit nsGlobalWindow(nsGlobalWindowOuter *aOuterWindow);
+  explicit nsGlobalWindowInner(nsGlobalWindowOuter *aOuterWindow);
   nsPIDOMWindowOuter* GetOpenerWindowOuter();
   // Initializes the mWasOffline member variable
   void InitWasOffline();
 public:
   nsPIDOMWindowOuter*
   GetSanitizedOpener(nsPIDOMWindowOuter* aOpener);
 
   nsPIDOMWindowOuter* GetOpenerWindow(mozilla::ErrorResult& aError);
@@ -1252,22 +1242,22 @@ protected:
   // property in IDL.
   void RedefineProperty(JSContext* aCx, const char* aPropName,
                         JS::Handle<JS::Value> aValue,
                         mozilla::ErrorResult& aError);
 
   // Implementation guts for our writable IDL attributes that are really
   // supposed to be readonly replaceable.
   typedef int32_t
-    (nsGlobalWindow::*WindowCoordGetter)(mozilla::dom::CallerType aCallerType,
-                                         mozilla::ErrorResult&);
+    (nsGlobalWindowInner::*WindowCoordGetter)(mozilla::dom::CallerType aCallerType,
+                                              mozilla::ErrorResult&);
   typedef void
-    (nsGlobalWindow::*WindowCoordSetter)(int32_t,
-                                         mozilla::dom::CallerType aCallerType,
-                                         mozilla::ErrorResult&);
+    (nsGlobalWindowInner::*WindowCoordSetter)(int32_t,
+                                              mozilla::dom::CallerType aCallerType,
+                                              mozilla::ErrorResult&);
   void GetReplaceableWindowCoord(JSContext* aCx, WindowCoordGetter aGetter,
                                  JS::MutableHandle<JS::Value> aRetval,
                                  mozilla::dom::CallerType aCallerType,
                                  mozilla::ErrorResult& aError);
   void SetReplaceableWindowCoord(JSContext* aCx, WindowCoordSetter aSetter,
                                  JS::Handle<JS::Value> aValue,
                                  const char* aPropName,
                                  mozilla::dom::CallerType aCallerType,
@@ -1362,17 +1352,17 @@ protected:
   nsCOMPtr <nsIIdleService> mIdleService;
 
   RefPtr<mozilla::dom::WakeLock> mWakeLock;
 
   friend class HashchangeCallback;
   friend class mozilla::dom::BarProp;
 
   // Object Management
-  virtual ~nsGlobalWindow();
+  virtual ~nsGlobalWindowInner();
   void DropOuterWindowDocs();
   void CleanUp();
   void ClearControllers();
   // Outer windows only.
   void FinalClose();
 
   inline void MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner);
 
@@ -1954,16 +1944,18 @@ protected:
   // When non-zero, the document should receive a vrdisplayactivate event
   // after loading.  The value is the ID of the VRDisplay that content should
   // begin presentation on.
   uint32_t mAutoActivateVRDisplayID; // Outer windows only
   int64_t mBeforeUnloadListenerCount; // Inner windows only
 
   RefPtr<mozilla::dom::IntlUtils> mIntlUtils;
 
+  static InnerWindowByIdTable* sInnerWindowsById;
+
   // Members in the mChromeFields member should only be used in chrome windows.
   // All accesses to this field should be guarded by a check of mIsChrome.
   struct ChromeFields {
     ChromeFields()
       : mGroupMessageManagers(1)
     {}
 
     nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
@@ -1977,247 +1969,129 @@ protected:
   } mChromeFields;
 
   friend class nsDOMScriptableHelper;
   friend class nsDOMWindowUtils;
   friend class mozilla::dom::PostMessageEvent;
   friend class DesktopNotification;
   friend class mozilla::dom::TimeoutManager;
   friend class IdleRequestExecutor;
+  friend class nsGlobalWindowOuter;
 };
 
 inline nsISupports*
-ToSupports(nsGlobalWindow *p)
+ToSupports(nsGlobalWindowInner *p)
 {
     return static_cast<nsIDOMEventTarget*>(p);
 }
 
 inline nsISupports*
-ToCanonicalSupports(nsGlobalWindow *p)
+ToCanonicalSupports(nsGlobalWindowInner *p)
 {
     return static_cast<nsIDOMEventTarget*>(p);
 }
 
-class nsGlobalWindowOuter : public nsGlobalWindow
-{
-public:
-  typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowOuter*> OuterWindowByIdTable;
-
-  friend class nsGlobalWindow;
-  friend class nsGlobalWindowInner;
-
-  static nsGlobalWindowOuter* Cast(nsPIDOMWindowOuter* aPIWin) {
-    return static_cast<nsGlobalWindowOuter*>(
-                        reinterpret_cast<nsPIDOMWindow<nsISupports>*>(aPIWin));
-  }
-  static const nsGlobalWindowOuter* Cast(const nsPIDOMWindowOuter* aPIWin) {
-    return static_cast<const nsGlobalWindowOuter*>(
-                        reinterpret_cast<const nsPIDOMWindow<nsISupports>*>(aPIWin));
-  }
-  static nsGlobalWindowOuter* Cast(mozIDOMWindowProxy* aWin) {
-    return Cast(nsPIDOMWindowOuter::From(aWin));
-  }
-
-  static nsGlobalWindowOuter*
-  GetOuterWindowWithId(uint64_t aWindowID)
-  {
-    AssertIsOnMainThread();
-
-    if (!sOuterWindowsById) {
-      return nullptr;
-    }
-
-    nsGlobalWindowOuter* outerWindow = sOuterWindowsById->Get(aWindowID);
-    MOZ_ASSERT(!outerWindow || outerWindow->IsOuterWindow(),
-               "Inner window in sOuterWindowsById?");
-    return outerWindow;
-  }
-
-  static OuterWindowByIdTable* GetWindowsTable() {
-    AssertIsOnMainThread();
-
-    return sOuterWindowsById;
-  }
-
-  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);
-
-private:
-  nsGlobalWindowOuter();
-  ~nsGlobalWindowOuter();
-
-  static OuterWindowByIdTable* sOuterWindowsById;
-};
-
-class nsGlobalWindowInner : public nsGlobalWindow
-{
-public:
-  typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowInner*> InnerWindowByIdTable;
-
-  friend class nsGlobalWindow;
-  friend class nsGlobalWindowOuter;
-
-  static nsGlobalWindowInner* Cast(nsPIDOMWindowInner* aPIWin) {
-    return static_cast<nsGlobalWindowInner*>(
-                        reinterpret_cast<nsPIDOMWindow<nsISupports>*>(aPIWin));
-  }
-  static const nsGlobalWindowInner* Cast(const nsPIDOMWindowInner* aPIWin) {
-    return static_cast<const nsGlobalWindowInner*>(
-                        reinterpret_cast<const nsPIDOMWindow<nsISupports>*>(aPIWin));
-  }
-  static nsGlobalWindowInner* Cast(mozIDOMWindow* aWin) {
-    return Cast(nsPIDOMWindowInner::From(aWin));
-  }
-
-  static nsGlobalWindowInner*
-  GetInnerWindowWithId(uint64_t aInnerWindowID)
-  {
-    AssertIsOnMainThread();
-
-    if (!sInnerWindowsById) {
-      return nullptr;
-    }
-
-    nsGlobalWindowInner* innerWindow =
-      sInnerWindowsById->Get(aInnerWindowID);
-    MOZ_ASSERT(!innerWindow || innerWindow->IsInnerWindow(),
-               "Outer window in sInnerWindowsById?");
-    return innerWindow;
-  }
-
-  static InnerWindowByIdTable* GetWindowsTable() {
-    AssertIsOnMainThread();
-
-    return sInnerWindowsById;
-  }
-
-  static nsGlobalWindowInner *FromSupports(nsISupports *supports)
-  {
-    // Make sure this matches the casts we do in QueryInterface().
-    return (nsGlobalWindowInner *)(mozilla::dom::EventTarget *)supports;
-  }
-
-private:
-  static already_AddRefed<nsGlobalWindowInner>
-  Create(nsGlobalWindowOuter* aOuter, bool aIsChrome);
-
-  explicit nsGlobalWindowInner(nsGlobalWindowOuter* aOuter);
-  ~nsGlobalWindowInner();
-
-  static InnerWindowByIdTable* sInnerWindowsById;
-};
+// XXX: EWW - This is an awful hack - let's not do this
+#include "nsGlobalWindowOuter.h"
 
 inline nsIGlobalObject*
-nsGlobalWindow::GetOwnerGlobal() const
+nsGlobalWindowInner::GetOwnerGlobal() const
 {
   if (IsOuterWindow()) {
     return GetCurrentInnerWindowInternal();
   }
 
-  return const_cast<nsGlobalWindow*>(this);
+  return const_cast<nsGlobalWindowInner*>(this);
 }
 
 inline nsGlobalWindowOuter*
-nsGlobalWindow::GetTopInternal()
+nsGlobalWindowInner::GetTopInternal()
 {
   nsGlobalWindowOuter* outer = IsOuterWindow() ? AssertOuter() : GetOuterWindowInternal();
   nsCOMPtr<nsPIDOMWindowOuter> top = outer ? outer->GetTop() : nullptr;
   if (top) {
     return nsGlobalWindowOuter::Cast(top);
   }
   return nullptr;
 }
 
 inline nsGlobalWindowOuter*
-nsGlobalWindow::GetScriptableTopInternal()
+nsGlobalWindowInner::GetScriptableTopInternal()
 {
   nsPIDOMWindowOuter* top = GetScriptableTop();
   return nsGlobalWindowOuter::Cast(top);
 }
 
 inline nsIScriptContext*
-nsGlobalWindow::GetContextInternal()
-  {
-    if (mOuterWindow) {
-      return GetOuterWindowInternal()->mContext;
-    }
-
-    return mContext;
+nsGlobalWindowInner::GetContextInternal()
+{
+  if (mOuterWindow) {
+    return GetOuterWindowInternal()->mContext;
   }
 
+  return mContext;
+}
+
 inline nsGlobalWindowOuter*
-nsGlobalWindow::GetOuterWindowInternal()
+nsGlobalWindowInner::GetOuterWindowInternal()
 {
   return nsGlobalWindowOuter::Cast(GetOuterWindow());
 }
 
 inline nsGlobalWindowInner*
-nsGlobalWindow::GetCurrentInnerWindowInternal() const
+nsGlobalWindowInner::GetCurrentInnerWindowInternal() const
 {
   MOZ_ASSERT(IsOuterWindow());
   return nsGlobalWindowInner::Cast(mInnerWindow);
 }
 
 inline nsGlobalWindowInner*
-nsGlobalWindow::EnsureInnerWindowInternal()
+nsGlobalWindowInner::EnsureInnerWindowInternal()
 {
   return nsGlobalWindowInner::Cast(AsOuter()->EnsureInnerWindow());
 }
 
 inline bool
-nsGlobalWindow::IsTopLevelWindow()
+nsGlobalWindowInner::IsTopLevelWindow()
 {
   MOZ_ASSERT(IsOuterWindow());
   nsPIDOMWindowOuter* parentWindow = GetScriptableTop();
   return parentWindow == this->AsOuter();
 }
 
 inline bool
-nsGlobalWindow::IsPopupSpamWindow()
+nsGlobalWindowInner::IsPopupSpamWindow()
 {
   if (IsInnerWindow() && !mOuterWindow) {
     return false;
   }
 
   return GetOuterWindowInternal()->mIsPopupSpam;
 }
 
 inline bool
-nsGlobalWindow::IsFrame()
+nsGlobalWindowInner::IsFrame()
 {
   return GetParentInternal() != nullptr;
 }
 
 inline nsGlobalWindowInner*
-nsGlobalWindow::AssertInner()
+nsGlobalWindowInner::AssertInner()
 {
   MOZ_RELEASE_ASSERT(IsInnerWindow());
   return static_cast<nsGlobalWindowInner*>(this);
 }
 
 inline nsGlobalWindowOuter*
-nsGlobalWindow::AssertOuter()
+nsGlobalWindowInner::AssertOuter()
 {
-  MOZ_RELEASE_ASSERT(IsOuterWindow());
-  return static_cast<nsGlobalWindowOuter*>(this);
+  MOZ_CRASH("nsGlobalWindowInner is not an outer window");
 }
 
 inline void
-nsGlobalWindow::MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner)
+nsGlobalWindowInner::MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner)
 {
   if(mInnerWindow == aExpectedInner->AsInner()) {
     mInnerWindow = nullptr;
   }
 }
 
-/* factory function */
-inline already_AddRefed<nsGlobalWindowOuter>
-NS_NewScriptGlobalObject(bool aIsChrome)
-{
-  return nsGlobalWindowOuter::Create(aIsChrome);
-}
-
-#endif /* nsGlobalWindow_h___ */
+#endif /* nsGlobalWindowInner_h___ */
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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___
+#ifndef nsGlobalWindowOuter_h___
+#define nsGlobalWindowOuter_h___
 
 #include "nsPIDOMWindow.h"
 
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include "nsRefPtrHashtable.h"
 #include "nsInterfaceHashtable.h"
 
@@ -54,33 +54,16 @@
 #include "mozilla/dom/WindowBinding.h"
 #include "Units.h"
 #include "nsComponentManagerUtils.h"
 #include "nsSize.h"
 #include "nsCheapSets.h"
 #include "mozilla/dom/ImageBitmapSource.h"
 #include "mozilla/UniquePtr.h"
 
-#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
-
 class nsIArray;
 class nsIBaseWindow;
 class nsIContent;
 class nsICSSDeclaration;
 class nsIDocShellTreeOwner;
 class nsIDOMOfflineResourceList;
 class nsIScrollableFrame;
 class nsIControllers;
@@ -91,25 +74,27 @@ class nsITabChild;
 class nsITimeoutHandler;
 class nsIWebBrowserChrome;
 class mozIDOMWindowProxy;
 
 class nsDOMWindowList;
 class nsScreen;
 class nsHistory;
 class nsGlobalWindowObserver;
-class nsGlobalWindow;
+class nsGlobalWindowInner;
 class nsDOMWindowUtils;
 class nsIIdleService;
 struct nsRect;
 
 class nsWindowSizes;
 
 class IdleRequestExecutor;
 
+struct IdleObserverHolder;
+
 namespace mozilla {
 class AbstractThread;
 class DOMEventTargetHelper;
 class ThrottledEventQueue;
 namespace dom {
 class BarProp;
 struct ChannelPixelLayout;
 class Console;
@@ -161,47 +146,16 @@ NS_CreateJSTimeoutHandler(JSContext* aCx
 
 extern already_AddRefed<nsIScriptTimeoutHandler>
 NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindowInner *aWindow,
                           const nsAString& aExpression,
                           mozilla::ErrorResult& aError);
 
 extern const js::Class OuterWindowProxyClass;
 
-struct IdleObserverHolder
-{
-  nsCOMPtr<nsIIdleObserver> mIdleObserver;
-  uint32_t mTimeInS;
-  bool mPrevNotificationIdle;
-
-  IdleObserverHolder()
-    : mTimeInS(0), mPrevNotificationIdle(false)
-  {
-    MOZ_COUNT_CTOR(IdleObserverHolder);
-  }
-
-  IdleObserverHolder(const IdleObserverHolder& aOther)
-    : mIdleObserver(aOther.mIdleObserver), mTimeInS(aOther.mTimeInS),
-      mPrevNotificationIdle(aOther.mPrevNotificationIdle)
-  {
-    MOZ_COUNT_CTOR(IdleObserverHolder);
-  }
-
-  bool operator==(const IdleObserverHolder& aOther) const {
-    return
-      mIdleObserver == aOther.mIdleObserver &&
-      mTimeInS == aOther.mTimeInS;
-  }
-
-  ~IdleObserverHolder()
-  {
-    MOZ_COUNT_DTOR(IdleObserverHolder);
-  }
-};
-
 // Helper class to manage modal dialog arguments and all their quirks.
 //
 // Given our clunky embedding APIs, modal dialog arguments need to be passed
 // as an nsISupports parameter to WindowWatcher, get stuck inside an array of
 // length 1, and then passed back to the newly-created dialog.
 //
 // However, we need to track both the caller-passed value as well as the
 // caller's, so that we can do an origin check (even for primitives) when the
@@ -223,18 +177,20 @@ public:
            JS::MutableHandle<JS::Value> aResult, mozilla::ErrorResult& aError);
 private:
   virtual ~DialogValueHolder() {}
 
   nsCOMPtr<nsIPrincipal> mOrigin;
   nsCOMPtr<nsIVariant> mValue;
 };
 
-class nsGlobalWindowInner;
-class nsGlobalWindowOuter;
+
+// NOTE: Currently this file, despite being named mozilla/dom/WindowProxy.h,
+// exports the class nsGlobalWindowOuter. It will be renamed in the future to
+// mozilla::dom::WindowProxy.
 
 //*****************************************************************************
 // nsGlobalWindow: Global Object for Scripting
 //*****************************************************************************
 // Beware that all scriptable interfaces implemented by
 // nsGlobalWindow will be reachable from JS, if you make this class
 // implement new interfaces you better know what you're
 // doing. Security wise this is very sensitive code. --
@@ -255,40 +211,83 @@ class nsGlobalWindowOuter;
 // type name. nsGlobalWindow doesn't want to doubly inherit (and have two
 // copies of everything), and it also doesn't want to privilege one over
 // the other by making it possible to convert types through the C++ type system
 // instead of our accessor methods (AsInner and AsOuter) that do dynamic
 // checking. So we inherit from nsPIDOMWindow<nsISupports>, which is also
 // identical to both nsPIDOMWindowInner and nsPIDOMWindowOuter, but not
 // convertible to either.
 
-class nsGlobalWindow : public mozilla::dom::EventTarget,
-                       public nsPIDOMWindow<nsISupports>,
-                       private nsIDOMWindow,
-                       // NOTE: This interface is private, as it's only
-                       // implemented on chrome windows.
-                       private nsIDOMChromeWindow,
-                       public nsIScriptGlobalObject,
-                       public nsIScriptObjectPrincipal,
-                       public nsSupportsWeakReference,
-                       public nsIInterfaceRequestor,
-                       public PRCListStr
+class nsGlobalWindowOuter : public mozilla::dom::EventTarget,
+                            public nsPIDOMWindow<nsISupports>,
+                            private nsIDOMWindow,
+                            // NOTE: This interface is private, as it's only
+                            // implemented on chrome windows.
+                            private nsIDOMChromeWindow,
+                            public nsIScriptGlobalObject,
+                            public nsIScriptObjectPrincipal,
+                            public nsSupportsWeakReference,
+                            public nsIInterfaceRequestor,
+                            public PRCListStr
 {
 public:
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::TimeDuration TimeDuration;
 
+  typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowOuter*> OuterWindowByIdTable;
+
   static void
   AssertIsOnMainThread()
 #ifdef DEBUG
   ;
 #else
   { }
 #endif
 
+  static nsGlobalWindowOuter* Cast(nsPIDOMWindowOuter* aPIWin) {
+    return static_cast<nsGlobalWindowOuter*>(
+      reinterpret_cast<nsPIDOMWindow<nsISupports>*>(aPIWin));
+  }
+  static const nsGlobalWindowOuter* Cast(const nsPIDOMWindowOuter* aPIWin) {
+    return static_cast<const nsGlobalWindowOuter*>(
+      reinterpret_cast<const nsPIDOMWindow<nsISupports>*>(aPIWin));
+  }
+  static nsGlobalWindowOuter* Cast(mozIDOMWindowProxy* aWin) {
+    return Cast(nsPIDOMWindowOuter::From(aWin));
+  }
+
+  static nsGlobalWindowOuter*
+  GetOuterWindowWithId(uint64_t aWindowID)
+  {
+    AssertIsOnMainThread();
+
+    if (!sOuterWindowsById) {
+      return nullptr;
+    }
+
+    nsGlobalWindowOuter* outerWindow = sOuterWindowsById->Get(aWindowID);
+    MOZ_ASSERT(!outerWindow || outerWindow->IsOuterWindow(),
+                "Inner window in sOuterWindowsById?");
+    return outerWindow;
+  }
+
+  static OuterWindowByIdTable* GetWindowsTable() {
+    AssertIsOnMainThread();
+
+    return sOuterWindowsById;
+  }
+
+  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();
@@ -463,26 +462,16 @@ public:
                  JS::MutableHandle<JS::PropertyDescriptor> aDesc);
   // The return value is whether DoResolve might end up resolving the given id.
   // If in doubt, return true.
   static bool MayResolve(jsid aId);
 
   void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
                            bool aEnumerableOnly, mozilla::ErrorResult& aRv);
 
-  // Object Management
-  static nsGlobalWindow *FromSupports(nsISupports *supports)
-  {
-    // Make sure this matches the casts we do in QueryInterface().
-    return (nsGlobalWindow *)(mozilla::dom::EventTarget *)supports;
-  }
-  static nsGlobalWindow *FromWrapper(nsIXPConnectWrappedNative *wrapper)
-  {
-    return FromSupports(wrapper->Native());
-  }
   already_AddRefed<nsPIDOMWindowOuter> GetTop() override;
   nsPIDOMWindowOuter* GetScriptableTop() override;
   inline nsGlobalWindowOuter *GetTopInternal();
 
   inline nsGlobalWindowOuter* GetScriptableTopInternal();
 
   nsPIDOMWindowOuter* GetChildWindow(const nsAString& aName);
 
@@ -565,17 +554,17 @@ public:
   static void Init();
   static void ShutDown();
   static bool IsCallerChrome();
 
   void CleanupCachedXBLHandlers();
 
   friend class WindowStateHolder;
 
-  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindow,
+  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindowOuter,
                                                                    nsIDOMEventTarget)
 
 #ifdef DEBUG
   // Call Unlink on this window. This may cause bad things to happen, so use
   // with caution.
   void RiskyUnlink();
 #endif
 
@@ -806,17 +795,17 @@ public:
   already_AddRefed<nsIDOMWindowCollection> GetFrames() override;
   already_AddRefed<nsPIDOMWindowOuter> GetFrames(mozilla::ErrorResult& aError);
   uint32_t Length();
   already_AddRefed<nsPIDOMWindowOuter> GetTopOuter();
   already_AddRefed<nsPIDOMWindowOuter> GetTop(mozilla::ErrorResult& aError);
 
   nsresult GetPrompter(nsIPrompt** aPrompt) override;
 protected:
-  explicit nsGlobalWindow(nsGlobalWindowOuter *aOuterWindow);
+  explicit nsGlobalWindowOuter();
   nsPIDOMWindowOuter* GetOpenerWindowOuter();
   // Initializes the mWasOffline member variable
   void InitWasOffline();
 public:
   nsPIDOMWindowOuter*
   GetSanitizedOpener(nsPIDOMWindowOuter* aOpener);
 
   nsPIDOMWindowOuter* GetOpenerWindow(mozilla::ErrorResult& aError);
@@ -1252,22 +1241,22 @@ protected:
   // property in IDL.
   void RedefineProperty(JSContext* aCx, const char* aPropName,
                         JS::Handle<JS::Value> aValue,
                         mozilla::ErrorResult& aError);
 
   // Implementation guts for our writable IDL attributes that are really
   // supposed to be readonly replaceable.
   typedef int32_t
-    (nsGlobalWindow::*WindowCoordGetter)(mozilla::dom::CallerType aCallerType,
-                                         mozilla::ErrorResult&);
+    (nsGlobalWindowOuter::*WindowCoordGetter)(mozilla::dom::CallerType aCallerType,
+                                              mozilla::ErrorResult&);
   typedef void
-    (nsGlobalWindow::*WindowCoordSetter)(int32_t,
-                                         mozilla::dom::CallerType aCallerType,
-                                         mozilla::ErrorResult&);
+    (nsGlobalWindowOuter::*WindowCoordSetter)(int32_t,
+                                              mozilla::dom::CallerType aCallerType,
+                                              mozilla::ErrorResult&);
   void GetReplaceableWindowCoord(JSContext* aCx, WindowCoordGetter aGetter,
                                  JS::MutableHandle<JS::Value> aRetval,
                                  mozilla::dom::CallerType aCallerType,
                                  mozilla::ErrorResult& aError);
   void SetReplaceableWindowCoord(JSContext* aCx, WindowCoordSetter aSetter,
                                  JS::Handle<JS::Value> aValue,
                                  const char* aPropName,
                                  mozilla::dom::CallerType aCallerType,
@@ -1362,17 +1351,17 @@ protected:
   nsCOMPtr <nsIIdleService> mIdleService;
 
   RefPtr<mozilla::dom::WakeLock> mWakeLock;
 
   friend class HashchangeCallback;
   friend class mozilla::dom::BarProp;
 
   // Object Management
-  virtual ~nsGlobalWindow();
+  virtual ~nsGlobalWindowOuter();
   void DropOuterWindowDocs();
   void CleanUp();
   void ClearControllers();
   // Outer windows only.
   void FinalClose();
 
   inline void MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner);
 
@@ -1954,16 +1943,18 @@ protected:
   // When non-zero, the document should receive a vrdisplayactivate event
   // after loading.  The value is the ID of the VRDisplay that content should
   // begin presentation on.
   uint32_t mAutoActivateVRDisplayID; // Outer windows only
   int64_t mBeforeUnloadListenerCount; // Inner windows only
 
   RefPtr<mozilla::dom::IntlUtils> mIntlUtils;
 
+  static OuterWindowByIdTable* sOuterWindowsById;
+
   // Members in the mChromeFields member should only be used in chrome windows.
   // All accesses to this field should be guarded by a check of mIsChrome.
   struct ChromeFields {
     ChromeFields()
       : mGroupMessageManagers(1)
     {}
 
     nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
@@ -1977,247 +1968,136 @@ protected:
   } mChromeFields;
 
   friend class nsDOMScriptableHelper;
   friend class nsDOMWindowUtils;
   friend class mozilla::dom::PostMessageEvent;
   friend class DesktopNotification;
   friend class mozilla::dom::TimeoutManager;
   friend class IdleRequestExecutor;
+  friend class nsGlobalWindowInner;
 };
 
+// XXX: EWW - This is an awful hack - let's not do this
+#include "nsGlobalWindowInner.h"
+
 inline nsISupports*
-ToSupports(nsGlobalWindow *p)
+ToSupports(nsGlobalWindowOuter *p)
 {
     return static_cast<nsIDOMEventTarget*>(p);
 }
 
 inline nsISupports*
-ToCanonicalSupports(nsGlobalWindow *p)
+ToCanonicalSupports(nsGlobalWindowOuter *p)
 {
     return static_cast<nsIDOMEventTarget*>(p);
 }
 
-class nsGlobalWindowOuter : public nsGlobalWindow
-{
-public:
-  typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowOuter*> OuterWindowByIdTable;
-
-  friend class nsGlobalWindow;
-  friend class nsGlobalWindowInner;
-
-  static nsGlobalWindowOuter* Cast(nsPIDOMWindowOuter* aPIWin) {
-    return static_cast<nsGlobalWindowOuter*>(
-                        reinterpret_cast<nsPIDOMWindow<nsISupports>*>(aPIWin));
-  }
-  static const nsGlobalWindowOuter* Cast(const nsPIDOMWindowOuter* aPIWin) {
-    return static_cast<const nsGlobalWindowOuter*>(
-                        reinterpret_cast<const nsPIDOMWindow<nsISupports>*>(aPIWin));
-  }
-  static nsGlobalWindowOuter* Cast(mozIDOMWindowProxy* aWin) {
-    return Cast(nsPIDOMWindowOuter::From(aWin));
-  }
-
-  static nsGlobalWindowOuter*
-  GetOuterWindowWithId(uint64_t aWindowID)
-  {
-    AssertIsOnMainThread();
-
-    if (!sOuterWindowsById) {
-      return nullptr;
-    }
-
-    nsGlobalWindowOuter* outerWindow = sOuterWindowsById->Get(aWindowID);
-    MOZ_ASSERT(!outerWindow || outerWindow->IsOuterWindow(),
-               "Inner window in sOuterWindowsById?");
-    return outerWindow;
-  }
-
-  static OuterWindowByIdTable* GetWindowsTable() {
-    AssertIsOnMainThread();
-
-    return sOuterWindowsById;
-  }
-
-  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);
-
-private:
-  nsGlobalWindowOuter();
-  ~nsGlobalWindowOuter();
-
-  static OuterWindowByIdTable* sOuterWindowsById;
-};
-
-class nsGlobalWindowInner : public nsGlobalWindow
-{
-public:
-  typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowInner*> InnerWindowByIdTable;
-
-  friend class nsGlobalWindow;
-  friend class nsGlobalWindowOuter;
-
-  static nsGlobalWindowInner* Cast(nsPIDOMWindowInner* aPIWin) {
-    return static_cast<nsGlobalWindowInner*>(
-                        reinterpret_cast<nsPIDOMWindow<nsISupports>*>(aPIWin));
-  }
-  static const nsGlobalWindowInner* Cast(const nsPIDOMWindowInner* aPIWin) {
-    return static_cast<const nsGlobalWindowInner*>(
-                        reinterpret_cast<const nsPIDOMWindow<nsISupports>*>(aPIWin));
-  }
-  static nsGlobalWindowInner* Cast(mozIDOMWindow* aWin) {
-    return Cast(nsPIDOMWindowInner::From(aWin));
-  }
-
-  static nsGlobalWindowInner*
-  GetInnerWindowWithId(uint64_t aInnerWindowID)
-  {
-    AssertIsOnMainThread();
-
-    if (!sInnerWindowsById) {
-      return nullptr;
-    }
-
-    nsGlobalWindowInner* innerWindow =
-      sInnerWindowsById->Get(aInnerWindowID);
-    MOZ_ASSERT(!innerWindow || innerWindow->IsInnerWindow(),
-               "Outer window in sInnerWindowsById?");
-    return innerWindow;
-  }
-
-  static InnerWindowByIdTable* GetWindowsTable() {
-    AssertIsOnMainThread();
-
-    return sInnerWindowsById;
-  }
-
-  static nsGlobalWindowInner *FromSupports(nsISupports *supports)
-  {
-    // Make sure this matches the casts we do in QueryInterface().
-    return (nsGlobalWindowInner *)(mozilla::dom::EventTarget *)supports;
-  }
-
-private:
-  static already_AddRefed<nsGlobalWindowInner>
-  Create(nsGlobalWindowOuter* aOuter, bool aIsChrome);
-
-  explicit nsGlobalWindowInner(nsGlobalWindowOuter* aOuter);
-  ~nsGlobalWindowInner();
-
-  static InnerWindowByIdTable* sInnerWindowsById;
-};
-
 inline nsIGlobalObject*
-nsGlobalWindow::GetOwnerGlobal() const
+nsGlobalWindowOuter::GetOwnerGlobal() const
 {
   if (IsOuterWindow()) {
     return GetCurrentInnerWindowInternal();
   }
 
-  return const_cast<nsGlobalWindow*>(this);
+  return const_cast<nsGlobalWindowOuter*>(this);
 }
 
 inline nsGlobalWindowOuter*
-nsGlobalWindow::GetTopInternal()
+nsGlobalWindowOuter::GetTopInternal()
 {
   nsGlobalWindowOuter* outer = IsOuterWindow() ? AssertOuter() : GetOuterWindowInternal();
   nsCOMPtr<nsPIDOMWindowOuter> top = outer ? outer->GetTop() : nullptr;
   if (top) {
     return nsGlobalWindowOuter::Cast(top);
   }
   return nullptr;
 }
 
 inline nsGlobalWindowOuter*
-nsGlobalWindow::GetScriptableTopInternal()
+nsGlobalWindowOuter::GetScriptableTopInternal()
 {
   nsPIDOMWindowOuter* top = GetScriptableTop();
   return nsGlobalWindowOuter::Cast(top);
 }
 
 inline nsIScriptContext*
-nsGlobalWindow::GetContextInternal()
-  {
-    if (mOuterWindow) {
-      return GetOuterWindowInternal()->mContext;
-    }
-
-    return mContext;
+nsGlobalWindowOuter::GetContextInternal()
+{
+  if (mOuterWindow) {
+    return GetOuterWindowInternal()->mContext;
   }
 
+  return mContext;
+}
+
 inline nsGlobalWindowOuter*
-nsGlobalWindow::GetOuterWindowInternal()
+nsGlobalWindowOuter::GetOuterWindowInternal()
 {
   return nsGlobalWindowOuter::Cast(GetOuterWindow());
 }
 
 inline nsGlobalWindowInner*
-nsGlobalWindow::GetCurrentInnerWindowInternal() const
+nsGlobalWindowOuter::GetCurrentInnerWindowInternal() const
 {
   MOZ_ASSERT(IsOuterWindow());
   return nsGlobalWindowInner::Cast(mInnerWindow);
 }
 
 inline nsGlobalWindowInner*
-nsGlobalWindow::EnsureInnerWindowInternal()
+nsGlobalWindowOuter::EnsureInnerWindowInternal()
 {
   return nsGlobalWindowInner::Cast(AsOuter()->EnsureInnerWindow());
 }
 
 inline bool
-nsGlobalWindow::IsTopLevelWindow()
+nsGlobalWindowOuter::IsTopLevelWindow()
 {
   MOZ_ASSERT(IsOuterWindow());
   nsPIDOMWindowOuter* parentWindow = GetScriptableTop();
   return parentWindow == this->AsOuter();
 }
 
 inline bool
-nsGlobalWindow::IsPopupSpamWindow()
+nsGlobalWindowOuter::IsPopupSpamWindow()
 {
   if (IsInnerWindow() && !mOuterWindow) {
     return false;
   }
 
   return GetOuterWindowInternal()->mIsPopupSpam;
 }
 
 inline bool
-nsGlobalWindow::IsFrame()
+nsGlobalWindowOuter::IsFrame()
 {
   return GetParentInternal() != nullptr;
 }
 
 inline nsGlobalWindowInner*
-nsGlobalWindow::AssertInner()
+nsGlobalWindowOuter::AssertInner()
 {
-  MOZ_RELEASE_ASSERT(IsInnerWindow());
-  return static_cast<nsGlobalWindowInner*>(this);
+  MOZ_CRASH("nsGlobalWindowOuter is not an inner window");
 }
 
 inline nsGlobalWindowOuter*
-nsGlobalWindow::AssertOuter()
+nsGlobalWindowOuter::AssertOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
   return static_cast<nsGlobalWindowOuter*>(this);
 }
 
 inline void
-nsGlobalWindow::MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner)
+nsGlobalWindowOuter::MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner)
 {
   if(mInnerWindow == aExpectedInner->AsInner()) {
     mInnerWindow = nullptr;
   }
 }
 
 /* factory function */
 inline already_AddRefed<nsGlobalWindowOuter>
 NS_NewScriptGlobalObject(bool aIsChrome)
 {
   return nsGlobalWindowOuter::Create(aIsChrome);
 }
 
-#endif /* nsGlobalWindow_h___ */
+#endif /* nsGlobalWindowOuter_h___ */
--- a/dom/webidl/IdleDeadline.webidl
+++ b/dom/webidl/IdleDeadline.webidl
@@ -3,13 +3,13 @@
  * 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/.
  *
  * The origin of this IDL file is:
  * https://w3c.github.io/requestidlecallback/
  */
 
 [Exposed=(Window,System),
- Func="nsGlobalWindow::IsRequestIdleCallbackEnabled"]
+ Func="nsGlobalWindowInner::IsRequestIdleCallbackEnabled"]
 interface IdleDeadline {
   DOMHighResTimeStamp timeRemaining();
   readonly attribute boolean didTimeout;
 };
--- a/dom/webidl/Window.webidl
+++ b/dom/webidl/Window.webidl
@@ -74,17 +74,17 @@ interface XULControllers;
 #endif
   [Throws, Pref="browser.cache.offline.enable"] readonly attribute ApplicationCache applicationCache;
 
   // user prompts
   [Throws, UnsafeInPrerendering, NeedsSubjectPrincipal] void alert();
   [Throws, UnsafeInPrerendering, NeedsSubjectPrincipal] void alert(DOMString message);
   [Throws, UnsafeInPrerendering, NeedsSubjectPrincipal] boolean confirm(optional DOMString message = "");
   [Throws, UnsafeInPrerendering, NeedsSubjectPrincipal] DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
-  [Throws, UnsafeInPrerendering, Func="nsGlobalWindow::IsWindowPrintEnabled"]
+  [Throws, UnsafeInPrerendering, Func="nsGlobalWindowInner::IsWindowPrintEnabled"]
   void print();
 
   [Throws, CrossOriginCallable, NeedsSubjectPrincipal]
   void postMessage(any message, DOMString targetOrigin, optional sequence<object> transfer = []);
 
   // also has obsolete members
 };
 Window implements GlobalEventHandlers;