--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -662,16 +662,17 @@ nsDocShell::LoadURI(nsIURI* aURI,
return NS_OK; // JS may not handle returning of an error code
}
nsCOMPtr<nsIURI> referrer;
nsCOMPtr<nsIURI> originalURI;
Maybe<nsCOMPtr<nsIURI>> resultPrincipalURI;
bool keepResultPrincipalURIIfSet = false;
bool loadReplace = false;
+ bool isFromProcessingFrameAttributes = false;
nsCOMPtr<nsIInputStream> postStream;
nsCOMPtr<nsIInputStream> headersStream;
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
bool inheritPrincipal = false;
bool principalIsExplicit = false;
bool sendReferrer = true;
uint32_t referrerPolicy = RP_Unset;
bool isSrcdoc = false;
@@ -694,16 +695,17 @@ nsDocShell::LoadURI(nsIURI* aURI,
// Extract the info from the DocShellLoadInfo struct...
if (aLoadInfo) {
referrer = aLoadInfo->Referrer();
originalURI = aLoadInfo->OriginalURI();
aLoadInfo->GetMaybeResultPrincipalURI(resultPrincipalURI);
keepResultPrincipalURIIfSet = aLoadInfo->KeepResultPrincipalURIIfSet();
loadReplace = aLoadInfo->LoadReplace();
+ isFromProcessingFrameAttributes = aLoadInfo->GetIsFromProcessingFrameAttributes();
// Get the appropriate loadType from nsIDocShellLoadInfo type
loadType = aLoadInfo->LoadType();
triggeringPrincipal = aLoadInfo->TriggeringPrincipal();
inheritPrincipal = aLoadInfo->InheritPrincipal();
principalIsExplicit = aLoadInfo->PrincipalIsExplicit();
shEntry = aLoadInfo->SHEntry();
aLoadInfo->GetTarget(target);
@@ -989,16 +991,17 @@ nsDocShell::LoadURI(nsIURI* aURI,
flags |= INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC;
}
return InternalLoad(aURI,
originalURI,
resultPrincipalURI,
keepResultPrincipalURIIfSet,
loadReplace,
+ isFromProcessingFrameAttributes,
referrer,
referrerPolicy,
triggeringPrincipal,
principalToInherit,
flags,
target,
nullptr, // No type hint
VoidString(), // No forced download
@@ -4912,17 +4915,18 @@ nsDocShell::LoadErrorPage(nsIURI* aError
if (mLSHE) {
// Abandon mLSHE's BFCache entry and create a new one. This way, if
// we go back or forward to another SHEntry with the same doc
// identifier, the error page won't persist.
mLSHE->AbandonBFCacheEntry();
}
- return InternalLoad(aErrorURI, nullptr, Nothing(), false, false, nullptr, RP_Unset,
+ return InternalLoad(aErrorURI, nullptr, Nothing(), false, false,
+ false, nullptr, RP_Unset,
nsContentUtils::GetSystemPrincipal(), nullptr,
INTERNAL_LOAD_FLAGS_NONE, EmptyString(),
nullptr, VoidString(), nullptr, nullptr,
LOAD_ERROR_PAGE, nullptr, true, VoidString(), this,
nullptr, nullptr, nullptr);
}
NS_IMETHODIMP
@@ -5009,16 +5013,17 @@ nsDocShell::Reload(uint32_t aReloadFlags
// Reload always rewrites result principal URI.
Maybe<nsCOMPtr<nsIURI>> emplacedResultPrincipalURI;
emplacedResultPrincipalURI.emplace(std::move(resultPrincipalURI));
rv = InternalLoad(currentURI,
originalURI,
emplacedResultPrincipalURI,
false,
loadReplace,
+ false, // IsFromProcessingFrameAttributes
referrerURI,
referrerPolicy,
triggeringPrincipal,
triggeringPrincipal,
flags,
EmptyString(), // No window target
NS_LossyConvertUTF16toASCII(contentTypeHint).get(),
VoidString(), // No forced download
@@ -9088,16 +9093,17 @@ class InternalLoadEvent : public Runnabl
{
public:
InternalLoadEvent(nsDocShell* aDocShell,
nsIURI* aURI,
nsIURI* aOriginalURI,
Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
bool aKeepResultPrincipalURIIfSet,
bool aLoadReplace,
+ bool aIsFromProcessingFrameAttributes,
nsIURI* aReferrer, uint32_t aReferrerPolicy,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
uint32_t aFlags,
const char* aTypeHint,
nsIInputStream* aPostData,
nsIInputStream* aHeadersData,
uint32_t aLoadType,
@@ -9109,16 +9115,17 @@ public:
: mozilla::Runnable("InternalLoadEvent")
, mSrcdoc(aSrcdoc)
, mDocShell(aDocShell)
, mURI(aURI)
, mOriginalURI(aOriginalURI)
, mResultPrincipalURI(aResultPrincipalURI)
, mKeepResultPrincipalURIIfSet(aKeepResultPrincipalURIIfSet)
, mLoadReplace(aLoadReplace)
+ , mIsFromProcessingFrameAttributes(aIsFromProcessingFrameAttributes)
, mReferrer(aReferrer)
, mReferrerPolicy(aReferrerPolicy)
, mTriggeringPrincipal(aTriggeringPrincipal)
, mPrincipalToInherit(aPrincipalToInherit)
, mPostData(aPostData)
, mHeadersData(aHeadersData)
, mSHEntry(aSHEntry)
, mFlags(aFlags)
@@ -9136,16 +9143,17 @@ public:
}
NS_IMETHOD
Run() override
{
return mDocShell->InternalLoad(mURI, mOriginalURI, mResultPrincipalURI,
mKeepResultPrincipalURIIfSet,
mLoadReplace,
+ mIsFromProcessingFrameAttributes,
mReferrer,
mReferrerPolicy,
mTriggeringPrincipal, mPrincipalToInherit,
mFlags, EmptyString(),
mTypeHint.IsVoid() ? nullptr
: mTypeHint.get(),
VoidString(), mPostData,
mHeadersData, mLoadType, mSHEntry,
@@ -9159,16 +9167,17 @@ private:
nsString mSrcdoc;
RefPtr<nsDocShell> mDocShell;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI;
Maybe<nsCOMPtr<nsIURI>> mResultPrincipalURI;
bool mKeepResultPrincipalURIIfSet;
bool mLoadReplace;
+ bool mIsFromProcessingFrameAttributes;
nsCOMPtr<nsIURI> mReferrer;
uint32_t mReferrerPolicy;
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
nsCOMPtr<nsIPrincipal> mPrincipalToInherit;
nsCOMPtr<nsIInputStream> mPostData;
nsCOMPtr<nsIInputStream> mHeadersData;
nsCOMPtr<nsISHEntry> mSHEntry;
uint32_t mFlags;
@@ -9206,16 +9215,17 @@ nsDocShell::CreatePrincipalFromReferrer(
}
NS_IMETHODIMP
nsDocShell::InternalLoad(nsIURI* aURI,
nsIURI* aOriginalURI,
Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
bool aKeepResultPrincipalURIIfSet,
bool aLoadReplace,
+ bool aIsFromProcessingFrameAttributes,
nsIURI* aReferrer,
uint32_t aReferrerPolicy,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
uint32_t aFlags,
const nsAString& aWindowTarget,
const char* aTypeHint,
const nsAString& aFileName,
@@ -9555,16 +9565,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// window target name from to prevent recursive retargeting!
//
if (NS_SUCCEEDED(rv) && targetDocShell) {
rv = targetDocShell->InternalLoad(aURI,
aOriginalURI,
aResultPrincipalURI,
aKeepResultPrincipalURIIfSet,
aLoadReplace,
+ aIsFromProcessingFrameAttributes,
aReferrer,
aReferrerPolicy,
aTriggeringPrincipal,
principalToInherit,
aFlags,
EmptyString(), // No window target
aTypeHint,
VoidString(), // No forced download
@@ -9653,17 +9664,18 @@ nsDocShell::InternalLoad(nsIURI* aURI,
if (LOAD_TYPE_HAS_FLAGS(aLoadType, LOAD_FLAGS_REPLACE_HISTORY)) {
mLoadType = LOAD_NORMAL_REPLACE;
}
// Do this asynchronously
nsCOMPtr<nsIRunnable> ev =
new InternalLoadEvent(this, aURI, aOriginalURI, aResultPrincipalURI,
aKeepResultPrincipalURIIfSet,
- aLoadReplace, aReferrer, aReferrerPolicy,
+ aLoadReplace, aIsFromProcessingFrameAttributes,
+ aReferrer, aReferrerPolicy,
aTriggeringPrincipal, principalToInherit,
aFlags, aTypeHint, aPostData,
aHeadersData, aLoadType, aSHEntry, aFirstParty,
aSrcdoc, aSourceDocShell, aBaseURI);
return DispatchToTabGroup(TaskCategory::Other, ev.forget());
}
// Just ignore this load attempt
@@ -10172,16 +10184,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
PredictorLearn(aURI, nullptr,
nsINetworkPredictor::LEARN_LOAD_TOPLEVEL, attrs);
PredictorPredict(aURI, nullptr,
nsINetworkPredictor::PREDICT_LOAD, attrs, nullptr);
nsCOMPtr<nsIRequest> req;
rv = DoURILoad(aURI, aOriginalURI, aResultPrincipalURI,
aKeepResultPrincipalURIIfSet, aLoadReplace,
+ aIsFromProcessingFrameAttributes,
loadFromExternal,
(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI),
(aFlags & INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC),
aReferrer,
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
aReferrerPolicy,
aTriggeringPrincipal, principalToInherit, aTypeHint,
aFileName, aPostData, aHeadersData,
@@ -10320,16 +10333,17 @@ IsConsideredSameOriginForUIR(nsIPrincipa
}
nsresult
nsDocShell::DoURILoad(nsIURI* aURI,
nsIURI* aOriginalURI,
Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
bool aKeepResultPrincipalURIIfSet,
bool aLoadReplace,
+ bool aIsFromProcessingFrameAttributes,
bool aLoadFromExternal,
bool aForceAllowDataURI,
bool aOriginalFrameSrc,
nsIURI* aReferrerURI,
bool aSendReferrer,
uint32_t aReferrerPolicy,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
@@ -10491,17 +10505,17 @@ nsDocShell::DoURILoad(nsIURI* aURI,
if (inheritPrincipal) {
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
}
if (isSandBoxed) {
securityFlags |= nsILoadInfo::SEC_SANDBOXED;
}
- nsCOMPtr<nsILoadInfo> loadInfo =
+ RefPtr<LoadInfo> loadInfo =
(aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT) ?
new LoadInfo(loadingWindow, aTriggeringPrincipal, topLevelLoadingContext,
securityFlags) :
new LoadInfo(loadingPrincipal, aTriggeringPrincipal, loadingNode,
securityFlags, aContentPolicyType);
if (aPrincipalToInherit) {
loadInfo->SetPrincipalToInherit(aPrincipalToInherit);
@@ -10537,16 +10551,20 @@ nsDocShell::DoURILoad(nsIURI* aURI,
return rv;
}
// Document loads should set the reload flag on the channel so that it
// can be exposed on the service worker FetchEvent.
rv = loadInfo->SetIsDocshellReload(mLoadType & LOAD_CMD_RELOAD);
NS_ENSURE_SUCCESS(rv, rv);
+ if (aIsFromProcessingFrameAttributes) {
+ loadInfo->SetIsFromProcessingFrameAttributes();
+ }
+
if (!isSrcdoc) {
rv = NS_NewChannelInternal(getter_AddRefs(channel),
aURI,
loadInfo,
nullptr, // PerformanceStorage
nullptr, // loadGroup
static_cast<nsIInterfaceRequestor*>(this),
loadFlags);
@@ -12226,16 +12244,17 @@ nsDocShell::LoadHistoryEntry(nsISHEntry*
// first created. bug 947716 has been created to address this issue.
Maybe<nsCOMPtr<nsIURI>> emplacedResultPrincipalURI;
emplacedResultPrincipalURI.emplace(std::move(resultPrincipalURI));
rv = InternalLoad(uri,
originalURI,
emplacedResultPrincipalURI,
false,
loadReplace,
+ false, // IsFromProcessingFrameAttributes
referrerURI,
referrerPolicy,
triggeringPrincipal,
principalToInherit,
flags,
EmptyString(), // No window target
contentType.get(), // Type hint
VoidString(), // No forced file download
@@ -13414,16 +13433,17 @@ nsDocShell::OnLinkClickSync(nsIContent*
flags |= INTERNAL_LOAD_FLAGS_IS_USER_TRIGGERED;
}
nsresult rv = InternalLoad(aURI, // New URI
nullptr, // Original URI
Nothing(), // Let the protocol handler assign it
false,
false, // LoadReplace
+ false, // IsFromProcessingFrameAttributes
referer, // Referer URI
refererPolicy, // Referer policy
triggeringPrincipal,
aContent->NodePrincipal(),
flags,
target, // Window target
NS_LossyConvertUTF16toASCII(typeHint).get(),
aFileName, // Download as file
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -89,16 +89,17 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadin
, mForcePreflight(false)
, mIsPreflight(false)
, mLoadTriggeredFromExternal(false)
, mServiceWorkerTaintingSynthesized(false)
, mIsTracker(false)
, mIsTrackerBlocked(false)
, mDocumentHasUserInteracted(false)
, mDocumentHasLoaded(false)
+ , mIsFromProcessingFrameAttributes(false)
{
MOZ_ASSERT(mLoadingPrincipal);
MOZ_ASSERT(mTriggeringPrincipal);
#ifdef DEBUG
// TYPE_DOCUMENT loads initiated by javascript tests will go through
// nsIOService and use the wrong constructor. Don't enforce the
// !TYPE_DOCUMENT check in those cases
@@ -361,16 +362,17 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* a
, mForcePreflight(false)
, mIsPreflight(false)
, mLoadTriggeredFromExternal(false)
, mServiceWorkerTaintingSynthesized(false)
, mIsTracker(false)
, mIsTrackerBlocked(false)
, mDocumentHasUserInteracted(false)
, mDocumentHasLoaded(false)
+ , mIsFromProcessingFrameAttributes(false)
{
// Top-level loads are never third-party
// Grab the information we can out of the window.
MOZ_ASSERT(aOuterWindow);
MOZ_ASSERT(mTriggeringPrincipal);
// if the load is sandboxed, we can not also inherit the principal
if (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED) {
@@ -463,16 +465,17 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
, mIsPreflight(rhs.mIsPreflight)
, mLoadTriggeredFromExternal(rhs.mLoadTriggeredFromExternal)
// mServiceWorkerTaintingSynthesized must be handled specially during redirect
, mServiceWorkerTaintingSynthesized(false)
, mIsTracker(rhs.mIsTracker)
, mIsTrackerBlocked(rhs.mIsTrackerBlocked)
, mDocumentHasUserInteracted(rhs.mDocumentHasUserInteracted)
, mDocumentHasLoaded(rhs.mDocumentHasLoaded)
+ , mIsFromProcessingFrameAttributes(rhs.mIsFromProcessingFrameAttributes)
{
}
LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aSandboxedLoadingPrincipal,
nsIPrincipal* aTopLevelPrincipal,
@@ -557,16 +560,17 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadin
, mForcePreflight(aForcePreflight)
, mIsPreflight(aIsPreflight)
, mLoadTriggeredFromExternal(aLoadTriggeredFromExternal)
, mServiceWorkerTaintingSynthesized(aServiceWorkerTaintingSynthesized)
, mIsTracker(false)
, mIsTrackerBlocked(false)
, mDocumentHasUserInteracted(aDocumentHasUserInteracted)
, mDocumentHasLoaded(aDocumentHasLoaded)
+ , mIsFromProcessingFrameAttributes(false)
{
// Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal
MOZ_ASSERT(mLoadingPrincipal || aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT);
MOZ_ASSERT(mTriggeringPrincipal);
mRedirectChainIncludingInternalRedirects.SwapElements(
aRedirectChainIncludingInternalRedirects);
@@ -1462,16 +1466,30 @@ LoadInfo::SetDocumentHasLoaded(bool aDoc
NS_IMETHODIMP
LoadInfo::GetIsTopLevelLoad(bool *aResult)
{
*aResult = mFrameOuterWindowID ? mFrameOuterWindowID == mOuterWindowID
: mParentOuterWindowID == mOuterWindowID;
return NS_OK;
}
+void
+LoadInfo::SetIsFromProcessingFrameAttributes()
+{
+ mIsFromProcessingFrameAttributes = true;
+}
+
+NS_IMETHODIMP
+LoadInfo::GetIsFromProcessingFrameAttributes(bool *aIsFromProcessingFrameAttributes)
+{
+ MOZ_ASSERT(aIsFromProcessingFrameAttributes);
+ *aIsFromProcessingFrameAttributes = mIsFromProcessingFrameAttributes;
+ return NS_OK;
+}
+
NS_IMETHODIMP
LoadInfo::GetResultPrincipalURI(nsIURI **aURI)
{
NS_IF_ADDREF(*aURI = mResultPrincipalURI);
return NS_OK;
}
NS_IMETHODIMP