Bug 1594529: Infer nsDocShell::IsFrame from BrowsingContext. r=nika
☠☠ backed out by f26294c01862 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Wed, 06 Nov 2019 20:34:36 +0000
changeset 500965 eaee8979fdc423b979a8d1dc3915e45eea79a34d
parent 500964 848a87a2c19b66818aab4936655e59a0997c9863
child 500966 f5bdb80f1108f7a3a1dff8a6d6aec73784a36fa1
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1594529
milestone72.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 1594529: Infer nsDocShell::IsFrame from BrowsingContext. r=nika This fixes the content policy type for document loads in these frames, where the explicit mIsFrame flag was not set, due to DocShell creation taking a different code path in remote frames than in in-process frames. Differential Revision: https://phabricator.services.mozilla.com/D52093
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
dom/base/nsFrameLoader.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -383,17 +383,16 @@ nsDocShell::nsDocShell(BrowsingContext* 
       mIsPrintingOrPP(false),
       mSavingOldViewer(false),
       mDynamicallyCreated(false),
       mAffectPrivateSessionLifetime(true),
       mInvisible(false),
       mHasLoadedNonBlankURI(false),
       mBlankTiming(false),
       mTitleValidForCurrentURI(false),
-      mIsFrame(false),
       mSkipBrowsingContextDetachOnDestroy(false),
       mWatchedByDevtools(false),
       mIsNavigating(false) {
   AssertOriginAttributesMatchPrivateBrowsing();
 
   // If no outer window ID was provided, generate a new one.
   if (aContentWindowID == 0) {
     mContentWindowID = nsContentUtils::GenerateWindowId();
@@ -12083,18 +12082,16 @@ nsresult nsDocShell::EnsureFind() {
   rv = findInFrames->SetCurrentSearchFrame(windowToSearch);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   return NS_OK;
 }
 
-bool nsDocShell::IsFrame() { return mIsFrame; }
-
 NS_IMETHODIMP
 nsDocShell::IsBeingDestroyed(bool* aDoomed) {
   NS_ENSURE_ARG(aDoomed);
   *aDoomed = mIsBeingDestroyed;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -343,18 +343,16 @@ class nsDocShell final : public nsDocLoa
   // Notify Scroll observers when an async panning/zooming transform
   // is no longer applied
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   void NotifyAsyncPanZoomStopped();
 
   void SetInFrameSwap(bool aInSwap) { mInFrameSwap = aInSwap; }
   bool InFrameSwap();
 
-  void SetIsFrame() { mIsFrame = true; };
-
   const mozilla::Encoding* GetForcedCharset() { return mForcedCharset; }
 
   mozilla::HTMLEditor* GetHTMLEditorInternal();
   nsresult SetHTMLEditorInternal(mozilla::HTMLEditor* aHTMLEditor);
 
   // Handle page navigation due to charset changes
   nsresult CharsetChangeReloadDocument(const char* aCharset = nullptr,
                                        int32_t aSource = kCharsetUninitialized);
@@ -966,17 +964,17 @@ class nsDocShell final : public nsDocLoa
                               already_AddRefed<nsIRunnable>&& aRunnable);
 
   void SetupReferrerInfoFromChannel(nsIChannel* aChannel);
   void SetReferrerInfo(nsIReferrerInfo* aReferrerInfo);
   void ReattachEditorToWindow(nsISHEntry* aSHEntry);
   void RecomputeCanExecuteScripts();
   void ClearFrameHistory(nsISHEntry* aEntry);
   void UpdateGlobalHistoryTitle(nsIURI* aURI);
-  bool IsFrame();
+  bool IsFrame() { return mBrowsingContext->GetParent(); }
   bool CanSetOriginAttributes();
   bool ShouldBlockLoadingForBackButton();
   bool ShouldDiscardLayoutState(nsIHttpChannel* aChannel);
   bool HasUnloadedParent();
   bool JustStartedNetworkLoad();
   bool IsPrintingOrPP(bool aDisplayErrorDialog = true);
   bool IsNavigationAllowed(bool aDisplayPrintErrorDialog = true,
                            bool aCheckIfUnloadFired = true);
@@ -1325,18 +1323,16 @@ class nsDocShell final : public nsDocLoa
   // This flag means that mTiming has been initialized but nulled out.
   // We will check the innerWin's timing before creating a new one
   // in MaybeInitTiming()
   bool mBlankTiming : 1;
 
   // This flag indicates when the title is valid for the current URI.
   bool mTitleValidForCurrentURI : 1;
 
-  bool mIsFrame : 1;
-
   // If mSkipBrowsingContextDetachOnDestroy is set to true, then when the
   // docshell is destroyed, the browsing context will not be detached. This is
   // for cases where we want to preserve the BC for future use.
   bool mSkipBrowsingContextDetachOnDestroy : 1;
 
   // Set when activity in this docshell is being watched by the developer tools.
   bool mWatchedByDevtools : 1;
 
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2128,18 +2128,16 @@ nsresult nsFrameLoader::MaybeCreateDocSh
                "docshell and document should have the same privateBrowsingId "
                "attribute.");
 
     attrs = oa;
   }
 
   if (OwnerIsMozBrowserFrame()) {
     docShell->SetFrameType(nsIDocShell::FRAME_TYPE_BROWSER);
-  } else if (mBrowsingContext->GetParent()) {
-    docShell->SetIsFrame();
   }
 
   // Apply sandbox flags even if our owner is not an iframe, as this copies
   // flags from our owning content's owning document.
   // Note: ApplySandboxFlags should be called after docShell->SetFrameType
   // because we need to get the correct presentation URL in ApplySandboxFlags.
   uint32_t sandboxFlags = 0;
   HTMLIFrameElement* iframe = HTMLIFrameElement::FromNode(mOwnerContent);