Bug 1340201 Expose IsTopLevelWindow() and HadOriginalOpener() on nsPIDOMWindowOuter. r=bz
authorBen Kelly <ben@wanderview.com>
Thu, 16 Feb 2017 14:39:28 -0500
changeset 377486 57557d3aac0819f2bec608245d01c4a727d25de1
parent 377485 debb1b927f6a524a183a45d14367dea51f8ae7b8
child 377487 d0588456829814fac5e00bafed5f9ced886afdf6
push id36
push userfmarier@mozilla.com
push dateSat, 18 Feb 2017 19:38:57 +0000
reviewersbz
bugs1340201
milestone54.0a1
Bug 1340201 Expose IsTopLevelWindow() and HadOriginalOpener() on nsPIDOMWindowOuter. r=bz
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsPIDOMWindow.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -14321,16 +14321,28 @@ nsGlobalWindow::GetIsPrerendered()
 
 void
 nsPIDOMWindowOuter::SetLargeAllocStatus(LargeAllocStatus aStatus)
 {
   MOZ_ASSERT(mLargeAllocStatus == LargeAllocStatus::NONE);
   mLargeAllocStatus = aStatus;
 }
 
+bool
+nsPIDOMWindowOuter::IsTopLevelWindow()
+{
+  return nsGlobalWindow::Cast(this)->IsTopLevelWindow();
+}
+
+bool
+nsPIDOMWindowOuter::HadOriginalOpener() const
+{
+  return nsGlobalWindow::Cast(this)->HadOriginalOpener();
+}
+
 void
 nsGlobalWindow::ReportLargeAllocStatus()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   uint32_t errorFlags = nsIScriptError::warningFlag;
   const char* message = nullptr;
 
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -287,16 +287,20 @@ public:
   }
   static nsGlobalWindow* Cast(mozIDOMWindow* aWin) {
     return Cast(nsPIDOMWindowInner::From(aWin));
   }
   static nsGlobalWindow* Cast(nsPIDOMWindowOuter* aPIWin) {
     return static_cast<nsGlobalWindow*>(
                         reinterpret_cast<nsPIDOMWindow<nsISupports>*>(aPIWin));
   }
+  static const nsGlobalWindow* Cast(const nsPIDOMWindowOuter* aPIWin) {
+    return static_cast<const nsGlobalWindow*>(
+                        reinterpret_cast<const nsPIDOMWindow<nsISupports>*>(aPIWin));
+  }
   static nsGlobalWindow* Cast(mozIDOMWindowProxy* aWin) {
     return Cast(nsPIDOMWindowOuter::From(aWin));
   }
 
   // public methods
   nsPIDOMWindowOuter* GetPrivateParent();
 
   // callback for close event
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -969,16 +969,19 @@ public:
   void MaybeActiveMediaComponents();
 
   void SetServiceWorkersTestingEnabled(bool aEnabled);
   bool GetServiceWorkersTestingEnabled();
 
   float GetDevicePixelRatio(mozilla::dom::CallerType aCallerType);
 
   void SetLargeAllocStatus(mozilla::dom::LargeAllocStatus aStatus);
+
+  bool IsTopLevelWindow();
+  bool HadOriginalOpener() const;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindowOuter, NS_PIDOMWINDOWOUTER_IID)
 
 #include "nsPIDOMWindowInlines.h"
 
 #ifdef MOZILLA_INTERNAL_API
 PopupControlState