diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 8d4d7c6e9bc7..01a3cf4ae53a 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9734,13 +9734,13 @@ static bool HasHttpScheme(nsIURI* aURI) { nsDocShellLoadState* aLoadState, LoadInfo* aLoadInfo, nsIInterfaceRequestor* aCallbacks, nsDocShell* aDocShell, const nsString* aInitiatorType, nsLoadFlags aLoadFlags, uint32_t aLoadType, - uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc, nsresult& aRv, - nsIChannel** aChannel) { + uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc, + bool aHasNonEmptySandboxingFlags, nsresult& aRv, nsIChannel** aChannel) { if (StaticPrefs::browser_tabs_documentchannel() && XRE_IsContentProcess() && HasHttpScheme(aLoadState->URI())) { RefPtr child = new DocumentChannelChild( aLoadState, aLoadInfo, aInitiatorType, aLoadFlags, aLoadType, aCacheKey, - aIsActive, aIsTopLevelDoc); + aIsActive, aIsTopLevelDoc, aHasNonEmptySandboxingFlags); child->SetNotificationCallbacks(aCallbacks); child.forget(aChannel); aRv = NS_OK; @@ -9902,7 +9902,8 @@ static bool HasHttpScheme(nsIURI* aURI) { /* static */ nsresult nsDocShell::ConfigureChannel( nsIChannel* aChannel, nsDocShellLoadState* aLoadState, - const nsString* aInitiatorType, uint32_t aLoadType, uint32_t aCacheKey) { + const nsString* aInitiatorType, uint32_t aLoadType, uint32_t aCacheKey, + bool aHasNonEmptySandboxingFlags) { nsCOMPtr props(do_QueryInterface(aChannel)); if (props) { nsCOMPtr referrer; @@ -10075,6 +10076,14 @@ static bool HasHttpScheme(nsIURI* aURI) { return NS_ERROR_CSP_NAVIGATE_TO_VIOLATION; } } + + if (aHasNonEmptySandboxingFlags) { + nsCOMPtr httpChannel(do_QueryInterface(aChannel)); + if (httpChannel) { + httpChannel->SetHasNonEmptySandboxingFlag(true); + } + } + return rv; } @@ -10375,9 +10384,10 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, bool isActive = mIsActive || (mLoadType & (LOAD_CMD_NORMAL | LOAD_CMD_HISTORY)); - if (!CreateChannelForLoadState( - aLoadState, loadInfo, this, this, initiatorType, loadFlags, mLoadType, - cacheKey, isActive, isTopLevelDoc, rv, getter_AddRefs(channel))) { + if (!CreateChannelForLoadState(aLoadState, loadInfo, this, this, + initiatorType, loadFlags, mLoadType, cacheKey, + isActive, isTopLevelDoc, mSandboxFlags, rv, + getter_AddRefs(channel))) { return rv; } @@ -10387,8 +10397,8 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, NS_ADDREF(*aRequest = channel); } - rv = - ConfigureChannel(channel, aLoadState, initiatorType, mLoadType, cacheKey); + rv = ConfigureChannel(channel, aLoadState, initiatorType, mLoadType, cacheKey, + mSandboxFlags); NS_ENSURE_SUCCESS(rv, rv); const nsACString& typeHint = aLoadState->TypeHint(); @@ -10520,13 +10530,6 @@ nsresult nsDocShell::DoChannelLoad(nsIChannel* aChannel, loadFlags |= nsIRequest::LOAD_DOCUMENT_NEEDS_COOKIE; } - if (mSandboxFlags) { - nsCOMPtr httpChannel(do_QueryInterface(aChannel)); - if (httpChannel) { - httpChannel->SetHasNonEmptySandboxingFlag(true); - } - } - // Load attributes depend on load type... switch (mLoadType) { case LOAD_HISTORY: { diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 6338967342ed..3ed4c69a2fc3 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -479,12 +479,14 @@ class nsDocShell final : public nsDocLoader, nsIInterfaceRequestor* aCallbacks, nsDocShell* aDocShell, const nsString* aInitiatorType, nsLoadFlags aLoadFlags, uint32_t aLoadType, uint32_t aCacheKey, bool aIsActive, - bool aIsTopLevelDoc, nsresult& rv, nsIChannel** aChannel); + bool aIsTopLevelDoc, bool aHasNonEmptySandboxingFlags, nsresult& rv, + nsIChannel** aChannel); static nsresult ConfigureChannel(nsIChannel* aChannel, nsDocShellLoadState* aLoadState, const nsString* aInitiatorType, - uint32_t aLoadType, uint32_t aCacheKey); + uint32_t aLoadType, uint32_t aCacheKey, + bool aHasNonEmptySandboxingFlags); // Notify consumers of a search being loaded through the observer service: static void MaybeNotifyKeywordSearchLoading(const nsString& aProvider, diff --git a/netwerk/ipc/DocumentChannelChild.cpp b/netwerk/ipc/DocumentChannelChild.cpp index 235a3882850a..39e33ac657e1 100644 --- a/netwerk/ipc/DocumentChannelChild.cpp +++ b/netwerk/ipc/DocumentChannelChild.cpp @@ -51,13 +51,15 @@ NS_IMPL_RELEASE_INHERITED(DocumentChannelChild, nsBaseChannel) DocumentChannelChild::DocumentChannelChild( nsDocShellLoadState* aLoadState, net::LoadInfo* aLoadInfo, const nsString* aInitiatorType, nsLoadFlags aLoadFlags, uint32_t aLoadType, - uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc) + uint32_t aCacheKey, bool aIsActive, bool aIsTopLevelDoc, + bool aHasNonEmptySandboxingFlags) : mLoadState(aLoadState), mInitiatorType(aInitiatorType ? Some(*aInitiatorType) : Nothing()), mLoadType(aLoadType), mCacheKey(aCacheKey), mIsActive(aIsActive), - mIsTopLevelDoc(aIsTopLevelDoc) { + mIsTopLevelDoc(aIsTopLevelDoc), + mHasNonEmptySandboxingFlags(aHasNonEmptySandboxingFlags) { mEventQueue = new ChannelEventQueue(static_cast(this)); SetURI(aLoadState->URI()); SetLoadInfo(aLoadInfo); @@ -147,6 +149,7 @@ DocumentChannelChild::AsyncOpen(nsIStreamListener* aListener) { args.cacheKey() = mCacheKey; args.isActive() = mIsActive; args.isTopLevelDoc() = mIsTopLevelDoc; + args.hasNonEmptySandboxingFlags() = mHasNonEmptySandboxingFlags; args.channelId() = *mChannelId; nsCOMPtr loadContext; diff --git a/netwerk/ipc/DocumentChannelChild.h b/netwerk/ipc/DocumentChannelChild.h index 6b774bcd09e4..37ff7851507c 100644 --- a/netwerk/ipc/DocumentChannelChild.h +++ b/netwerk/ipc/DocumentChannelChild.h @@ -32,7 +32,7 @@ class DocumentChannelChild final : public PDocumentChannelChild, class LoadInfo* aLoadInfo, const nsString* aInitiatorType, nsLoadFlags aLoadFlags, uint32_t aLoadType, uint32_t aCacheKey, bool aIsActive, - bool aIsTopLevelDoc); + bool aIsTopLevelDoc, bool aHasNonEmptySandboxingFlags); NS_DECL_ISUPPORTS_INHERITED; NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK @@ -120,6 +120,7 @@ class DocumentChannelChild final : public PDocumentChannelChild, const uint32_t mCacheKey; const bool mIsActive; const bool mIsTopLevelDoc; + const bool mHasNonEmptySandboxingFlags; bool mCanceled = false; uint32_t mSuspendCount = 0; diff --git a/netwerk/ipc/DocumentChannelParent.cpp b/netwerk/ipc/DocumentChannelParent.cpp index 3ada7abc713d..c07fdc35de2f 100644 --- a/netwerk/ipc/DocumentChannelParent.cpp +++ b/netwerk/ipc/DocumentChannelParent.cpp @@ -69,15 +69,15 @@ bool DocumentChannelParent::Init(const DocumentChannelCreationArgs& aArgs) { bool result = nsDocShell::CreateChannelForLoadState( loadState, loadInfo, mListener, nullptr, aArgs.initiatorType().ptrOr(nullptr), aArgs.loadFlags(), aArgs.loadType(), - aArgs.cacheKey(), aArgs.isActive(), aArgs.isTopLevelDoc(), rv, - getter_AddRefs(mChannel)); + aArgs.cacheKey(), aArgs.isActive(), aArgs.isTopLevelDoc(), + aArgs.hasNonEmptySandboxingFlags(), rv, getter_AddRefs(mChannel)); if (!result) { return SendFailedAsyncOpen(rv); } - nsDocShell::ConfigureChannel(mChannel, loadState, - aArgs.initiatorType().ptrOr(nullptr), - aArgs.loadType(), aArgs.cacheKey()); + nsDocShell::ConfigureChannel( + mChannel, loadState, aArgs.initiatorType().ptrOr(nullptr), + aArgs.loadType(), aArgs.cacheKey(), aArgs.hasNonEmptySandboxingFlags()); // Computation of the top window uses the docshell tree, so only // works in the source process. We compute it manually and override diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index e1c6d54fe818..9508dd22c903 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -365,6 +365,7 @@ struct DocumentChannelCreationArgs { uint32_t cacheKey; bool isActive; bool isTopLevelDoc; + bool hasNonEmptySandboxingFlags; };