Bug 1522637 - Part 2: Include BrowsingContextID in LoadInfo for subdocument loads, r=valentin
☠☠ backed out by 3433b7761096 ☠ ☠
authorNika Layzell <nika@thelayzells.com>
Fri, 08 Feb 2019 17:36:00 +0000
changeset 458333 5f49cd87b1bd2f90441e2be2b155cc1c0d77af32
parent 458332 f82ba91f5ea209f9849ac97a9a46392d706f6cc3
child 458334 5a8067fd848cba55ed8309a52e5d01adec17e329
push id35524
push userncsoregi@mozilla.com
push dateSat, 09 Feb 2019 09:40:21 +0000
treeherdermozilla-central@ec61d092ed67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1522637
milestone67.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 1522637 - Part 2: Include BrowsingContextID in LoadInfo for subdocument loads, r=valentin Depends on D18602 Differential Revision: https://phabricator.services.mozilla.com/D18603
browser/components/sessionstore/SessionStore.jsm
ipc/glue/BackgroundUtils.cpp
netwerk/base/LoadInfo.cpp
netwerk/base/LoadInfo.h
netwerk/base/nsILoadInfo.idl
netwerk/ipc/NeckoChannelParams.ipdlh
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -2318,25 +2318,29 @@ var SessionStoreInternal = {
     if (!E10SUtils.useHttpResponseProcessSelection()) {
       return;
     }
 
     if (!aChannel.isDocument || !aChannel.loadInfo) {
       return; // Not a document load.
     }
 
-    let browsingContext = aChannel.loadInfo.browsingContext;
+    let cpType = aChannel.loadInfo.externalContentPolicyType;
+    let toplevel = cpType == Ci.nsIContentPolicy.TYPE_DOCUMENT;
+    if (!toplevel) {
+      return; // Not loading a toplevel document.
+    }
+
+    let browsingContext = toplevel
+        ? aChannel.loadInfo.browsingContext
+        : aChannel.loadInfo.frameBrowsingContext;
     if (!browsingContext) {
       return; // Not loading in a browsing context.
     }
 
-    if (browsingContext.parent) {
-      return; // Not a toplevel load, can't flip procs.
-    }
-
     // Get principal for a document already loaded in the BrowsingContext.
     let currentPrincipal = null;
     if (browsingContext.currentWindowGlobal) {
       currentPrincipal = browsingContext.currentWindowGlobal.documentPrincipal;
     }
 
     let parentChannel = aChannel.notificationCallbacks
                                 .getInterface(Ci.nsIParentChannel);
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -469,17 +469,18 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadI
       aLoadInfo->GetVerifySignedContent(), aLoadInfo->GetEnforceSRI(),
       aLoadInfo->GetForceAllowDataURI(),
       aLoadInfo->GetAllowInsecureRedirectToDataURI(),
       aLoadInfo->GetSkipContentPolicyCheckForWebRequest(),
       aLoadInfo->GetForceInheritPrincipalDropped(),
       aLoadInfo->GetInnerWindowID(), aLoadInfo->GetOuterWindowID(),
       aLoadInfo->GetParentOuterWindowID(), aLoadInfo->GetTopOuterWindowID(),
       aLoadInfo->GetFrameOuterWindowID(), aLoadInfo->GetBrowsingContextID(),
-      aLoadInfo->GetEnforceSecurity(), aLoadInfo->GetInitialSecurityCheckDone(),
+      aLoadInfo->GetFrameBrowsingContextID(), aLoadInfo->GetEnforceSecurity(),
+      aLoadInfo->GetInitialSecurityCheckDone(),
       aLoadInfo->GetIsInThirdPartyContext(), aLoadInfo->GetIsDocshellReload(),
       aLoadInfo->GetSendCSPViolationEvents(), aLoadInfo->GetOriginAttributes(),
       redirectChainIncludingInternalRedirects, redirectChain,
       ancestorPrincipals, aLoadInfo->AncestorOuterWindowIDs(), ipcClientInfo,
       ipcReservedClientInfo, ipcInitialClientInfo, ipcController,
       aLoadInfo->CorsUnsafeHeaders(), aLoadInfo->GetForcePreflight(),
       aLoadInfo->GetIsPreflight(), aLoadInfo->GetLoadTriggeredFromExternal(),
       aLoadInfo->GetServiceWorkerTaintingSynthesized(),
@@ -626,18 +627,18 @@ nsresult LoadInfoArgsToLoadInfo(
       loadInfoArgs.browserWouldUpgradeInsecureRequests(),
       loadInfoArgs.verifySignedContent(), loadInfoArgs.enforceSRI(),
       loadInfoArgs.forceAllowDataURI(),
       loadInfoArgs.allowInsecureRedirectToDataURI(),
       loadInfoArgs.skipContentPolicyCheckForWebRequest(),
       loadInfoArgs.forceInheritPrincipalDropped(), loadInfoArgs.innerWindowID(),
       loadInfoArgs.outerWindowID(), loadInfoArgs.parentOuterWindowID(),
       loadInfoArgs.topOuterWindowID(), loadInfoArgs.frameOuterWindowID(),
-      loadInfoArgs.browsingContextID(), loadInfoArgs.enforceSecurity(),
-      loadInfoArgs.initialSecurityCheckDone(),
+      loadInfoArgs.browsingContextID(), loadInfoArgs.frameBrowsingContextID(),
+      loadInfoArgs.enforceSecurity(), loadInfoArgs.initialSecurityCheckDone(),
       loadInfoArgs.isInThirdPartyContext(), loadInfoArgs.isDocshellReload(),
       loadInfoArgs.sendCSPViolationEvents(), loadInfoArgs.originAttributes(),
       redirectChainIncludingInternalRedirects, redirectChain,
       std::move(ancestorPrincipals), loadInfoArgs.ancestorOuterWindowIDs(),
       loadInfoArgs.corsUnsafeHeaders(), loadInfoArgs.forcePreflight(),
       loadInfoArgs.isPreflight(), loadInfoArgs.loadTriggeredFromExternal(),
       loadInfoArgs.serviceWorkerTaintingSynthesized(),
       loadInfoArgs.documentHasUserInteracted(),
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -75,16 +75,17 @@ LoadInfo::LoadInfo(
       mOriginalFrameSrcLoad(false),
       mForceInheritPrincipalDropped(false),
       mInnerWindowID(0),
       mOuterWindowID(0),
       mParentOuterWindowID(0),
       mTopOuterWindowID(0),
       mFrameOuterWindowID(0),
       mBrowsingContextID(0),
+      mFrameBrowsingContextID(0),
       mEnforceSecurity(false),
       mInitialSecurityCheckDone(false),
       mIsThirdPartyContext(false),
       mIsDocshellReload(false),
       mSendCSPViolationEvents(true),
       mForcePreflight(false),
       mIsPreflight(false),
       mLoadTriggeredFromExternal(false),
@@ -226,16 +227,19 @@ LoadInfo::LoadInfo(
     RefPtr<nsFrameLoader> fl =
         frameLoaderOwner ? frameLoaderOwner->GetFrameLoader() : nullptr;
     if (fl) {
       nsCOMPtr<nsIDocShell> docShell = fl->GetDocShell(IgnoreErrors());
       if (docShell) {
         nsCOMPtr<nsPIDOMWindowOuter> outerWindow = do_GetInterface(docShell);
         if (outerWindow) {
           mFrameOuterWindowID = outerWindow->WindowID();
+
+          RefPtr<dom::BrowsingContext> bc = outerWindow->GetBrowsingContext();
+          mFrameBrowsingContextID = bc ? bc->Id() : 0;
         }
       }
     }
 
     // if the document forces all requests to be upgraded from http to https,
     // then we should do that for all requests. If it only forces preloads to be
     // upgraded then we should enforce upgrade insecure requests only for
     // preloads.
@@ -358,16 +362,17 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* a
       mOriginalFrameSrcLoad(false),
       mForceInheritPrincipalDropped(false),
       mInnerWindowID(0),
       mOuterWindowID(0),
       mParentOuterWindowID(0),
       mTopOuterWindowID(0),
       mFrameOuterWindowID(0),
       mBrowsingContextID(0),
+      mFrameBrowsingContextID(0),
       mEnforceSecurity(false),
       mInitialSecurityCheckDone(false),
       mIsThirdPartyContext(false),  // NB: TYPE_DOCUMENT implies !third-party.
       mIsDocshellReload(false),
       mSendCSPViolationEvents(true),
       mForcePreflight(false),
       mIsPreflight(false),
       mLoadTriggeredFromExternal(false),
@@ -497,20 +502,20 @@ LoadInfo::LoadInfo(
     bool aBrowserUpgradeInsecureRequests,
     bool aBrowserWouldUpgradeInsecureRequests, bool aVerifySignedContent,
     bool aEnforceSRI, bool aForceAllowDataURI,
     bool aAllowInsecureRedirectToDataURI,
     bool aSkipContentPolicyCheckForWebRequest,
     bool aForceInheritPrincipalDropped, uint64_t aInnerWindowID,
     uint64_t aOuterWindowID, uint64_t aParentOuterWindowID,
     uint64_t aTopOuterWindowID, uint64_t aFrameOuterWindowID,
-    uint64_t aBrowsingContextID, bool aEnforceSecurity,
-    bool aInitialSecurityCheckDone, bool aIsThirdPartyContext,
-    bool aIsDocshellReload, bool aSendCSPViolationEvents,
-    const OriginAttributes& aOriginAttributes,
+    uint64_t aBrowsingContextID, uint64_t aFrameBrowsingContextID,
+    bool aEnforceSecurity, bool aInitialSecurityCheckDone,
+    bool aIsThirdPartyContext, bool aIsDocshellReload,
+    bool aSendCSPViolationEvents, const OriginAttributes& aOriginAttributes,
     RedirectHistoryArray& aRedirectChainIncludingInternalRedirects,
     RedirectHistoryArray& aRedirectChain,
     nsTArray<nsCOMPtr<nsIPrincipal>>&& aAncestorPrincipals,
     const nsTArray<uint64_t>& aAncestorOuterWindowIDs,
     const nsTArray<nsCString>& aCorsUnsafeHeaders, bool aForcePreflight,
     bool aIsPreflight, bool aLoadTriggeredFromExternal,
     bool aServiceWorkerTaintingSynthesized, bool aDocumentHasUserInteracted,
     bool aDocumentHasLoaded)
@@ -540,16 +545,17 @@ LoadInfo::LoadInfo(
       mOriginalFrameSrcLoad(false),
       mForceInheritPrincipalDropped(aForceInheritPrincipalDropped),
       mInnerWindowID(aInnerWindowID),
       mOuterWindowID(aOuterWindowID),
       mParentOuterWindowID(aParentOuterWindowID),
       mTopOuterWindowID(aTopOuterWindowID),
       mFrameOuterWindowID(aFrameOuterWindowID),
       mBrowsingContextID(aBrowsingContextID),
+      mFrameBrowsingContextID(aFrameBrowsingContextID),
       mEnforceSecurity(aEnforceSecurity),
       mInitialSecurityCheckDone(aInitialSecurityCheckDone),
       mIsThirdPartyContext(aIsThirdPartyContext),
       mIsDocshellReload(aIsDocshellReload),
       mSendCSPViolationEvents(aSendCSPViolationEvents),
       mOriginAttributes(aOriginAttributes),
       mAncestorPrincipals(std::move(aAncestorPrincipals)),
       mAncestorOuterWindowIDs(aAncestorOuterWindowIDs),
@@ -993,22 +999,34 @@ LoadInfo::GetFrameOuterWindowID(uint64_t
 
 NS_IMETHODIMP
 LoadInfo::GetBrowsingContextID(uint64_t* aResult) {
   *aResult = mBrowsingContextID;
   return NS_OK;
 }
 
 NS_IMETHODIMP
+LoadInfo::GetFrameBrowsingContextID(uint64_t* aResult) {
+  *aResult = mFrameBrowsingContextID;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 LoadInfo::GetBrowsingContext(dom::BrowsingContext** aResult) {
   *aResult = BrowsingContext::Get(mBrowsingContextID).take();
   return NS_OK;
 }
 
 NS_IMETHODIMP
+LoadInfo::GetFrameBrowsingContext(dom::BrowsingContext** aResult) {
+  *aResult = BrowsingContext::Get(mFrameBrowsingContextID).take();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 LoadInfo::GetScriptableOriginAttributes(
     JSContext* aCx, JS::MutableHandle<JS::Value> aOriginAttributes) {
   if (NS_WARN_IF(!ToJSValue(aCx, mOriginAttributes, aOriginAttributes))) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
--- a/netwerk/base/LoadInfo.h
+++ b/netwerk/base/LoadInfo.h
@@ -105,19 +105,20 @@ class LoadInfo final : public nsILoadInf
            bool aUpgradeInsecureRequests, bool aBrowserUpgradeInsecureRequests,
            bool aBrowserWouldUpgradeInsecureRequests, bool aVerifySignedContent,
            bool aEnforceSRI, bool aForceAllowDataURI,
            bool aAllowInsecureRedirectToDataURI,
            bool aSkipContentPolicyCheckForWebRequest,
            bool aForceInheritPrincipalDropped, uint64_t aInnerWindowID,
            uint64_t aOuterWindowID, uint64_t aParentOuterWindowID,
            uint64_t aTopOuterWindowID, uint64_t aFrameOuterWindowID,
-           uint64_t aBrowsingContextID, bool aEnforceSecurity,
-           bool aInitialSecurityCheckDone, bool aIsThirdPartyRequest,
-           bool aIsDocshellReload, bool aSendCSPViolationEvents,
+           uint64_t aBrowsingContextID, uint64_t aFrameBrowsingContextID,
+           bool aEnforceSecurity, bool aInitialSecurityCheckDone,
+           bool aIsThirdPartyRequest, bool aIsDocshellReload,
+           bool aSendCSPViolationEvents,
            const OriginAttributes& aOriginAttributes,
            RedirectHistoryArray& aRedirectChainIncludingInternalRedirects,
            RedirectHistoryArray& aRedirectChain,
            nsTArray<nsCOMPtr<nsIPrincipal>>&& aAncestorPrincipals,
            const nsTArray<uint64_t>& aAncestorOuterWindowIDs,
            const nsTArray<nsCString>& aUnsafeHeaders, bool aForcePreflight,
            bool aIsPreflight, bool aLoadTriggeredFromExternal,
            bool aServiceWorkerTaintingSynthesized,
@@ -177,16 +178,17 @@ class LoadInfo final : public nsILoadInf
   bool mOriginalFrameSrcLoad;
   bool mForceInheritPrincipalDropped;
   uint64_t mInnerWindowID;
   uint64_t mOuterWindowID;
   uint64_t mParentOuterWindowID;
   uint64_t mTopOuterWindowID;
   uint64_t mFrameOuterWindowID;
   uint64_t mBrowsingContextID;
+  uint64_t mFrameBrowsingContextID;
   bool mEnforceSecurity;
   bool mInitialSecurityCheckDone;
   bool mIsThirdPartyContext;
   bool mIsDocshellReload;
   bool mSendCSPViolationEvents;
   OriginAttributes mOriginAttributes;
   RedirectHistoryArray mRedirectChainIncludingInternalRedirects;
   RedirectHistoryArray mRedirectChain;
--- a/netwerk/base/nsILoadInfo.idl
+++ b/netwerk/base/nsILoadInfo.idl
@@ -630,16 +630,23 @@ interface nsILoadInfo : nsISupports
 
   /**
    * The BrowsingContext performing the load for this nsILoadInfo object.
    */
   [infallible] readonly attribute unsigned long long browsingContextID;
   readonly attribute BrowsingContext browsingContext;
 
   /**
+   * Like `frameOuterWindowID`, however returning the BrowsingContextID
+   * instead.
+   */
+  [infallible] readonly attribute unsigned long long frameBrowsingContextID;
+  readonly attribute BrowsingContext frameBrowsingContext;
+
+  /**
    * Resets the PrincipalToInherit to a freshly created NullPrincipal
    * which inherits the origin attributes from the loadInfo.
    *
    * WARNING: Please only use that function if you know exactly what
    * you are doing!!!
    */
   void resetPrincipalToInheritToNullPrincipal();
 
--- a/netwerk/ipc/NeckoChannelParams.ipdlh
+++ b/netwerk/ipc/NeckoChannelParams.ipdlh
@@ -59,16 +59,17 @@ struct LoadInfoArgs
   bool                        skipContentPolicyCheckForWebRequest;
   bool                        forceInheritPrincipalDropped;
   uint64_t                    innerWindowID;
   uint64_t                    outerWindowID;
   uint64_t                    parentOuterWindowID;
   uint64_t                    topOuterWindowID;
   uint64_t                    frameOuterWindowID;
   uint64_t                    browsingContextID;
+  uint64_t                    frameBrowsingContextID;
   bool                        enforceSecurity;
   bool                        initialSecurityCheckDone;
   bool                        isInThirdPartyContext;
   bool                        isDocshellReload;
   bool                        sendCSPViolationEvents;
   OriginAttributes            originAttributes;
   RedirectHistoryEntryInfo[]  redirectChainIncludingInternalRedirects;
   RedirectHistoryEntryInfo[]  redirectChain;