Bug 1542790 - Part 1: BC::GetParent on toplevel windows should be self, r=peterv
authorNika Layzell <nika@thelayzells.com>
Wed, 17 Apr 2019 00:53:05 +0000
changeset 469826 5fde2cc9277a3d4bb73d859ba571c84fdc2ead9b
parent 469825 273bf7c8d7609189e977a85ced9d4c0f5889c107
child 469827 607e1bc95c9bd82cbf4dc5426cfa66147f1d9458
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1542790
milestone68.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 1542790 - Part 1: BC::GetParent on toplevel windows should be self, r=peterv Differential Revision: https://phabricator.services.mozilla.com/D26558
docshell/base/BrowsingContext.cpp
docshell/base/BrowsingContext.h
--- a/docshell/base/BrowsingContext.cpp
+++ b/docshell/base/BrowsingContext.cpp
@@ -644,22 +644,25 @@ void BrowsingContext::GetOpener(JSContex
     return;
   }
 
   if (!ToJSValue(aCx, WindowProxyHolder(opener), aOpener)) {
     aError.NoteJSContextException(aCx);
   }
 }
 
-Nullable<WindowProxyHolder> BrowsingContext::GetParent(
-    ErrorResult& aError) const {
+Nullable<WindowProxyHolder> BrowsingContext::GetParent(ErrorResult& aError) {
+  if (mClosed) {
+    return nullptr;
+  }
+
   // We never throw an error, but the implementation in nsGlobalWindow does and
   // we need to use the same signature.
   if (!mParent) {
-    return nullptr;
+    return WindowProxyHolder(this);
   }
   return WindowProxyHolder(mParent.get());
 }
 
 void BrowsingContext::PostMessageMoz(JSContext* aCx,
                                      JS::Handle<JS::Value> aMessage,
                                      const nsAString& aTargetOrigin,
                                      const Sequence<JSObject*>& aTransfer,
--- a/docshell/base/BrowsingContext.h
+++ b/docshell/base/BrowsingContext.h
@@ -242,17 +242,17 @@ class BrowsingContext : public nsWrapper
   bool GetClosed(ErrorResult&) { return mClosed; }
   void Focus(ErrorResult& aError);
   void Blur(ErrorResult& aError);
   BrowsingContext* GetFrames(ErrorResult& aError) { return Self(); }
   int32_t Length() const { return mChildren.Length(); }
   Nullable<WindowProxyHolder> GetTop(ErrorResult& aError);
   void GetOpener(JSContext* aCx, JS::MutableHandle<JS::Value> aOpener,
                  ErrorResult& aError) const;
-  Nullable<WindowProxyHolder> GetParent(ErrorResult& aError) const;
+  Nullable<WindowProxyHolder> GetParent(ErrorResult& aError);
   void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
                       const nsAString& aTargetOrigin,
                       const Sequence<JSObject*>& aTransfer,
                       nsIPrincipal& aSubjectPrincipal, ErrorResult& aError);
   void PostMessageMoz(JSContext* aCx, JS::Handle<JS::Value> aMessage,
                       const WindowPostMessageOptions& aOptions,
                       nsIPrincipal& aSubjectPrincipal, ErrorResult& aError);