Bug 1363395 - nsGlobalWindow::GetLocation should support to be called on the outer window, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 09 May 2017 22:41:19 +0200
changeset 391520 dfa904c745092fefb7874762667688c2d2b03d44
parent 391519 c41c78005666c97303ef9fba04c34325f6452871
child 391571 94600876bb6e45c6b73a4d7ff9bcec4c27bf2b28
push id53
push userfmarier@mozilla.com
push dateMon, 15 May 2017 17:28:28 +0000
reviewerssmaug
bugs1363395
milestone55.0a1
Bug 1363395 - nsGlobalWindow::GetLocation should support to be called on the outer window, r=smaug
chrome/nsChromeRegistry.cpp
dom/base/nsDocument.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsPIDOMWindow.h
dom/webidl/Window.webidl
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
toolkit/xre/nsNativeAppSupportWin.cpp
--- a/chrome/nsChromeRegistry.cpp
+++ b/chrome/nsChromeRegistry.cpp
@@ -504,17 +504,17 @@ nsChromeRegistry::ReloadChrome()
       rv = windowEnumerator->HasMoreElements(&more);
       if (NS_FAILED(rv)) return rv;
       while (more) {
         nsCOMPtr<nsISupports> protoWindow;
         rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
         if (NS_SUCCEEDED(rv)) {
           nsCOMPtr<nsPIDOMWindowOuter> domWindow = do_QueryInterface(protoWindow);
           if (domWindow) {
-            Location* location = domWindow->Location();
+            Location* location = domWindow->GetLocation();
             if (location) {
               rv = location->Reload(false);
               if (NS_FAILED(rv)) return rv;
             }
           }
         }
         rv = windowEnumerator->HasMoreElements(&more);
         if (NS_FAILED(rv)) return rv;
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -6869,17 +6869,17 @@ nsIDocument::GetLocation() const
 {
   nsCOMPtr<nsPIDOMWindowInner> w = do_QueryInterface(mScriptGlobalObject);
 
   if (!w) {
     return nullptr;
   }
 
   nsGlobalWindow* window = nsGlobalWindow::Cast(w);
-  RefPtr<Location> loc = window->Location();
+  RefPtr<Location> loc = window->GetLocation();
   return loc.forget();
 }
 
 Element*
 nsIDocument::GetHtmlElement() const
 {
   Element* rootElement = GetRootElement();
   if (rootElement && rootElement->IsHTMLElement(nsGkAtoms::html))
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -10433,18 +10433,21 @@ nsGlobalWindow::GetPrivateRoot()
       }
     }
   }
 
   return top;
 }
 
 Location*
-nsGlobalWindow::Location()
-{
+nsGlobalWindow::GetLocation()
+{
+  // This method can be called on the outer window as well.
+  FORWARD_TO_INNER(GetLocation, (), nullptr);
+
   MOZ_RELEASE_ASSERT(IsInnerWindow());
 
   if (!mLocation) {
     mLocation = new dom::Location(AsInner(), GetDocShell());
   }
 
   return mLocation;
 }
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -850,17 +850,17 @@ public:
   nsIDocument* GetDocument()
   {
     return GetDoc();
   }
   void GetNameOuter(nsAString& aName);
   void GetName(nsAString& aName, mozilla::ErrorResult& aError);
   void SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError);
   void SetName(const nsAString& aName, mozilla::ErrorResult& aError);
-  mozilla::dom::Location* Location() override;
+  mozilla::dom::Location* GetLocation() override;
   nsHistory* GetHistory(mozilla::ErrorResult& aError);
   mozilla::dom::CustomElementRegistry* CustomElements() override;
   mozilla::dom::BarProp* GetLocationbar(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetMenubar(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetPersonalbar(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetScrollbars(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetStatusbar(mozilla::ErrorResult& aError);
   mozilla::dom::BarProp* GetToolbar(mozilla::ErrorResult& aError);
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -568,17 +568,17 @@ public:
 
   uint32_t GetMarkedCCGeneration()
   {
     return mMarkedCCGeneration;
   }
 
   virtual nsIDOMScreen* GetScreen() = 0;
   virtual nsIDOMNavigator* GetNavigator() = 0;
-  virtual mozilla::dom::Location* Location() = 0;
+  virtual mozilla::dom::Location* GetLocation() = 0;
   virtual nsresult GetPrompter(nsIPrompt** aPrompt) = 0;
   virtual nsresult GetControllers(nsIControllers** aControllers) = 0;
   virtual already_AddRefed<nsISelection> GetSelection() = 0;
   virtual already_AddRefed<nsPIDOMWindowOuter> GetOpener() = 0;
   virtual already_AddRefed<nsIDOMWindowCollection> GetFrames() = 0;
   // aLoadInfo will be passed on through to the windowwatcher.
   // aForceNoOpener will act just like a "noopener" feature in aOptions except
   //                will not affect any other window features.
--- a/dom/webidl/Window.webidl
+++ b/dom/webidl/Window.webidl
@@ -30,17 +30,17 @@ interface nsIDOMCrypto;
 /*sealed*/ interface Window : EventTarget {
   // the current browsing context
   [Unforgeable, Constant, StoreInSlot,
    CrossOriginReadable] readonly attribute Window window;
   [Replaceable, Constant, StoreInSlot,
    CrossOriginReadable] readonly attribute Window self;
   [Unforgeable, StoreInSlot, Pure] readonly attribute Document? document;
   [Throws] attribute DOMString name;
-  [PutForwards=href, Unforgeable,
+  [PutForwards=href, Unforgeable, BinaryName="getLocation",
    CrossOriginReadable, CrossOriginWritable] readonly attribute Location location;
   [Throws] readonly attribute History history;
   [Func="CustomElementRegistry::IsCustomElementEnabled"]
   readonly attribute CustomElementRegistry customElements;
   [Replaceable, Throws] readonly attribute BarProp locationbar;
   [Replaceable, Throws] readonly attribute BarProp menubar;
   [Replaceable, Throws] readonly attribute BarProp personalbar;
   [Replaceable, Throws] readonly attribute BarProp scrollbars;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -604,17 +604,17 @@ PeerConnectionImpl::Initialize(PeerConne
   NS_ENSURE_STATE(mWindow);
 
   PRTime timestamp = PR_Now();
   // Ok if we truncate this.
   char temp[128];
 
   nsAutoCString locationCStr;
 
-  if (RefPtr<Location> location = mWindow->Location()) {
+  if (RefPtr<Location> location = mWindow->GetLocation()) {
     nsAutoString locationAStr;
     res = location->ToString(locationAStr);
     NS_ENSURE_SUCCESS(res, res);
 
     CopyUTF16toUTF8(locationAStr, locationCStr);
   }
 
   SprintfLiteral(temp,
--- a/toolkit/xre/nsNativeAppSupportWin.cpp
+++ b/toolkit/xre/nsNativeAppSupportWin.cpp
@@ -962,17 +962,17 @@ nsNativeAppSupportWin::HandleDDENotifica
                         }
 
                         // Get content window.
                         nsCOMPtr<nsPIDOMWindowOuter> internalContent = nsGlobalWindow::Cast(piNavWin)->GetContent();
                         if ( !internalContent ) {
                             break;
                         }
                         // Get location.
-                        RefPtr<dom::Location> location = internalContent->Location();
+                        RefPtr<dom::Location> location = internalContent->GetLocation();
                         if ( !location ) {
                             break;
                         }
                         // Get href for URL.
                         nsAutoString url;
                         if ( NS_FAILED( location->GetHref( url ) ) ) {
                             break;
                         }