Bug 1498720 - Ensure that we revoke a subframe's storage access when it is removed from the DOM r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 15 Oct 2018 10:37:11 +0000
changeset 489634 bb057b527690f626ad617828044c96cd113d4122
parent 489633 7b24c0c835bf54698cf49b5a21538bddd616642b
child 489635 801c33dcde58caa5a8be251eb1b0f9597cd26777
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersbaku
bugs1498720
milestone64.0a1
Bug 1498720 - Ensure that we revoke a subframe's storage access when it is removed from the DOM r=baku Differential Revision: https://phabricator.services.mozilla.com/D8615
docshell/base/nsDocShell.cpp
dom/base/nsGlobalWindowOuter.h
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -2983,16 +2983,22 @@ nsDocShell::SetDocLoaderParent(nsDocLoad
   nsCOMPtr<nsIURIContentListener> parentURIListener(do_GetInterface(parent));
   if (parentURIListener) {
     mContentListener->SetParentContentListener(parentURIListener);
   }
 
   // Our parent has changed. Recompute scriptability.
   RecomputeCanExecuteScripts();
 
+  nsCOMPtr<nsPIDOMWindowOuter> window = GetWindow();
+  if (window) {
+    auto* win = nsGlobalWindowOuter::Cast(window);
+    win->ParentWindowChanged();
+  }
+
   NS_ASSERTION(mInheritPrivateBrowsingId || wasPrivate == UsePrivateBrowsing(),
                "Private browsing state changed while inheritance was disabled");
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent)
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -732,16 +732,22 @@ public:
 
   nsIDOMWindowUtils* WindowUtils();
 
   virtual bool IsInSyncOperation() override
   {
     return GetExtantDoc() && GetExtantDoc()->IsInSyncOperation();
   }
 
+  void ParentWindowChanged()
+  {
+    // Reset our storage access flag when we get reparented.
+    mHasStorageAccess = false;
+  }
+
 public:
   int32_t GetInnerWidthOuter(mozilla::ErrorResult& aError);
 protected:
   nsresult GetInnerWidth(int32_t* aWidth) override;
   void SetInnerWidthOuter(int32_t aInnerWidth,
                           mozilla::dom::CallerType aCallerType,
                           mozilla::ErrorResult& aError);
 public: