diff --git a/ipc/glue/BackgroundUtils.cpp b/ipc/glue/BackgroundUtils.cpp index fa141d2ff7d2..f9f5ede6d556 100644 --- a/ipc/glue/BackgroundUtils.cpp +++ b/ipc/glue/BackgroundUtils.cpp @@ -387,6 +387,7 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo, aLoadInfo->GetInnerWindowID(), aLoadInfo->GetOuterWindowID(), aLoadInfo->GetParentOuterWindowID(), + aLoadInfo->GetTopOuterWindowID(), aLoadInfo->GetFrameOuterWindowID(), aLoadInfo->GetEnforceSecurity(), aLoadInfo->GetInitialSecurityCheckDone(), @@ -482,6 +483,7 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs, loadInfoArgs.innerWindowID(), loadInfoArgs.outerWindowID(), loadInfoArgs.parentOuterWindowID(), + loadInfoArgs.topOuterWindowID(), loadInfoArgs.frameOuterWindowID(), loadInfoArgs.enforceSecurity(), loadInfoArgs.initialSecurityCheckDone(), diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index e319cc876a5d..594df3474bdb 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -29,6 +29,16 @@ using namespace mozilla::dom; namespace mozilla { namespace net { +static uint64_t +FindTopOuterWindowID(nsPIDOMWindowOuter* aOuter) +{ + nsCOMPtr outer = aOuter; + while (nsCOMPtr parent = outer->GetScriptableParentOrNull()) { + outer = parent; + } + return outer->WindowID(); +} + LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal, nsINode* aLoadingContext, @@ -51,6 +61,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, , mInnerWindowID(0) , mOuterWindowID(0) , mParentOuterWindowID(0) + , mTopOuterWindowID(0) , mFrameOuterWindowID(0) , mEnforceSecurity(false) , mInitialSecurityCheckDone(false) @@ -103,6 +114,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, mOuterWindowID = contextOuter->WindowID(); nsCOMPtr parent = contextOuter->GetScriptableParent(); mParentOuterWindowID = parent ? parent->WindowID() : mOuterWindowID; + mTopOuterWindowID = FindTopOuterWindowID(contextOuter); } mInnerWindowID = aLoadingContext->OwnerDoc()->InnerWindowID(); @@ -228,6 +240,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow, , mInnerWindowID(0) , mOuterWindowID(0) , mParentOuterWindowID(0) + , mTopOuterWindowID(0) , mFrameOuterWindowID(0) , mEnforceSecurity(false) , mInitialSecurityCheckDone(false) @@ -258,6 +271,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow, // with the hidden window. nsCOMPtr parent = aOuterWindow->GetScriptableParent(); mParentOuterWindowID = parent ? parent->WindowID() : 0; + mTopOuterWindowID = FindTopOuterWindowID(aOuterWindow); // get the docshell from the outerwindow, and then get the originattributes nsCOMPtr docShell = aOuterWindow->GetDocShell(); @@ -290,6 +304,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs) , mInnerWindowID(rhs.mInnerWindowID) , mOuterWindowID(rhs.mOuterWindowID) , mParentOuterWindowID(rhs.mParentOuterWindowID) + , mTopOuterWindowID(rhs.mTopOuterWindowID) , mFrameOuterWindowID(rhs.mFrameOuterWindowID) , mEnforceSecurity(rhs.mEnforceSecurity) , mInitialSecurityCheckDone(rhs.mInitialSecurityCheckDone) @@ -323,6 +338,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, uint64_t aInnerWindowID, uint64_t aOuterWindowID, uint64_t aParentOuterWindowID, + uint64_t aTopOuterWindowID, uint64_t aFrameOuterWindowID, bool aEnforceSecurity, bool aInitialSecurityCheckDone, @@ -351,6 +367,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, , mInnerWindowID(aInnerWindowID) , mOuterWindowID(aOuterWindowID) , mParentOuterWindowID(aParentOuterWindowID) + , mTopOuterWindowID(aTopOuterWindowID) , mFrameOuterWindowID(aFrameOuterWindowID) , mEnforceSecurity(aEnforceSecurity) , mInitialSecurityCheckDone(aInitialSecurityCheckDone) @@ -724,6 +741,13 @@ LoadInfo::GetParentOuterWindowID(uint64_t* aResult) return NS_OK; } +NS_IMETHODIMP +LoadInfo::GetTopOuterWindowID(uint64_t* aResult) +{ + *aResult = mTopOuterWindowID; + return NS_OK; +} + NS_IMETHODIMP LoadInfo::GetFrameOuterWindowID(uint64_t* aResult) { diff --git a/netwerk/base/LoadInfo.h b/netwerk/base/LoadInfo.h index 7e670bb0f9b0..2f97d3276fe3 100644 --- a/netwerk/base/LoadInfo.h +++ b/netwerk/base/LoadInfo.h @@ -107,6 +107,7 @@ private: uint64_t aInnerWindowID, uint64_t aOuterWindowID, uint64_t aParentOuterWindowID, + uint64_t aTopOuterWindowID, uint64_t aFrameOuterWindowID, bool aEnforceSecurity, bool aInitialSecurityCheckDone, @@ -159,6 +160,7 @@ private: uint64_t mInnerWindowID; uint64_t mOuterWindowID; uint64_t mParentOuterWindowID; + uint64_t mTopOuterWindowID; uint64_t mFrameOuterWindowID; bool mEnforceSecurity; bool mInitialSecurityCheckDone; diff --git a/netwerk/base/nsILoadInfo.idl b/netwerk/base/nsILoadInfo.idl index c0ef95bd4ece..1fcc33e5e579 100644 --- a/netwerk/base/nsILoadInfo.idl +++ b/netwerk/base/nsILoadInfo.idl @@ -507,15 +507,17 @@ interface nsILoadInfo : nsISupports /** * These are the window IDs of the window in which the element being * loaded lives. parentOuterWindowID is the window ID of this window's - * parent. + * parent. topOuterWindowID is the ID of the top-level window of the same + * docShell type. * * Note that these window IDs can be 0 if the window is not - * available. parentOuterWindowID will be the same as outerWindowID if the - * window has no parent. + * available. parentOuterWindowID and topOuterWindowID will be the same as + * outerWindowID if the window has no parent. */ [infallible] readonly attribute unsigned long long innerWindowID; [infallible] readonly attribute unsigned long long outerWindowID; [infallible] readonly attribute unsigned long long parentOuterWindowID; + [infallible] readonly attribute unsigned long long topOuterWindowID; /** * Only when the element being loaded is diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index 2426f72205a9..4c3d40c3f8fd 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -51,6 +51,7 @@ struct LoadInfoArgs uint64_t innerWindowID; uint64_t outerWindowID; uint64_t parentOuterWindowID; + uint64_t topOuterWindowID; uint64_t frameOuterWindowID; bool enforceSecurity; bool initialSecurityCheckDone;