Bug 1542781 - Expose browsingContext on FrameLoaderOwner, r=farre
authorNika Layzell <nika@thelayzells.com>
Mon, 08 Apr 2019 16:27:28 +0000
changeset 468385 bba4f161674c8e119b45e8a2f4b6b758c229f8b5
parent 468384 95b3298fd2d462ecf0aab134289838317009fb3c
child 468386 5324d739ccf5435bfa05e5b3f33a88d7886e4960
push id35835
push useraciure@mozilla.com
push dateMon, 08 Apr 2019 19:00:29 +0000
treeherdermozilla-central@40456af7da1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1542781
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 1542781 - Expose browsingContext on FrameLoaderOwner, r=farre Differential Revision: https://phabricator.services.mozilla.com/D26548
dom/base/nsFrameLoaderOwner.cpp
dom/base/nsFrameLoaderOwner.h
dom/webidl/MozFrameLoaderOwner.webidl
--- a/dom/base/nsFrameLoaderOwner.cpp
+++ b/dom/base/nsFrameLoaderOwner.cpp
@@ -2,25 +2,34 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsFrameLoaderOwner.h"
 #include "nsFrameLoader.h"
 #include "mozilla/dom/FrameLoaderBinding.h"
+#include "mozilla/dom/BrowsingContext.h"
 
 already_AddRefed<nsFrameLoader> nsFrameLoaderOwner::GetFrameLoader() {
   return do_AddRef(mFrameLoader);
 }
 
 void nsFrameLoaderOwner::SetFrameLoader(nsFrameLoader* aNewFrameLoader) {
   mFrameLoader = aNewFrameLoader;
 }
 
+already_AddRefed<mozilla::dom::BrowsingContext>
+nsFrameLoaderOwner::GetBrowsingContext() {
+  if (mFrameLoader) {
+    return mFrameLoader->GetBrowsingContext();
+  }
+  return nullptr;
+}
+
 void nsFrameLoaderOwner::ChangeRemoteness(
     const mozilla::dom::RemotenessOptions& aOptions, mozilla::ErrorResult& rv) {
   // If we already have a Frameloader, destroy it.
   if (mFrameLoader) {
     mFrameLoader->Destroy();
     mFrameLoader = nullptr;
   }
 
--- a/dom/base/nsFrameLoaderOwner.h
+++ b/dom/base/nsFrameLoaderOwner.h
@@ -6,18 +6,19 @@
 
 #ifndef nsFrameLoaderOwner_h_
 #define nsFrameLoaderOwner_h_
 
 class nsFrameLoader;
 namespace mozilla {
 class ErrorResult;
 namespace dom {
+class BrowsingContext;
 struct RemotenessOptions;
-}
+}  // namespace dom
 }  // namespace mozilla
 
 // IID for the FrameLoaderOwner interface
 #define NS_FRAMELOADEROWNER_IID                      \
   {                                                  \
     0x1b4fd25c, 0x2e57, 0x11e9, {                    \
       0x9e, 0x5a, 0x5b, 0x86, 0xe9, 0x89, 0xa5, 0xc0 \
     }                                                \
@@ -33,16 +34,18 @@ struct RemotenessOptions;
 class nsFrameLoaderOwner : public nsISupports {
  public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAMELOADEROWNER_IID)
 
   nsFrameLoaderOwner() = default;
   already_AddRefed<nsFrameLoader> GetFrameLoader();
   void SetFrameLoader(nsFrameLoader* aNewFrameLoader);
 
+  already_AddRefed<mozilla::dom::BrowsingContext> GetBrowsingContext();
+
   // Destroy (if it exists) and recreate our frameloader, based on new
   // remoteness requirements. This should follow the same path as
   // tabbrowser.js's updateBrowserRemoteness, including running the same logic
   // and firing the same events as unbinding a XULBrowserElement from the tree.
   // However, this method is available from backend and does not manipulate the
   // DOM.
   void ChangeRemoteness(const mozilla::dom::RemotenessOptions& aOptions,
                         mozilla::ErrorResult& rv);
--- a/dom/webidl/MozFrameLoaderOwner.webidl
+++ b/dom/webidl/MozFrameLoaderOwner.webidl
@@ -10,16 +10,19 @@ dictionary RemotenessOptions {
   WindowProxy? opener;
 };
 
 [NoInterfaceObject]
 interface MozFrameLoaderOwner {
   [ChromeOnly]
   readonly attribute FrameLoader? frameLoader;
 
+  [ChromeOnly]
+  readonly attribute BrowsingContext? browsingContext;
+
   [ChromeOnly, Throws]
   void presetOpenerWindow(WindowProxy? window);
 
   [ChromeOnly, Throws]
   void swapFrameLoaders(XULFrameElement aOtherLoaderOwner);
 
   [ChromeOnly, Throws]
   void swapFrameLoaders(HTMLIFrameElement aOtherLoaderOwner);