CSP: Support for "LoadInfo::GetLoadingContext" and "LoadInfo::GetLoadingContextXPCOM()"

https://bugzilla.mozilla.org/show_bug.cgi?id=1439713 (partially)
This commit is contained in:
janekptacijarabaci 2018-06-21 20:56:16 +02:00 committed by Roy Tam
commit 09a81da02d
2 changed files with 38 additions and 2 deletions

View file

@ -81,7 +81,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
// This constructor shouldn't be used for TYPE_DOCUMENT loads that don't
// have a loadingPrincipal
MOZ_ASSERT(skipContentTypeCheck ||
MOZ_ASSERT(skipContentTypeCheck || mLoadingPrincipal ||
mInternalContentPolicyType != nsIContentPolicy::TYPE_DOCUMENT);
// TODO(bug 1259873): Above, we initialize mIsThirdPartyContext to false meaning
@ -493,6 +493,27 @@ LoadInfo::ContextForTopLevelLoad()
return context;
}
already_AddRefed<nsISupports>
LoadInfo::GetLoadingContext()
{
nsCOMPtr<nsISupports> context;
if (mInternalContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT) {
context = ContextForTopLevelLoad();
}
else {
context = LoadingNode();
}
return context.forget();
}
NS_IMETHODIMP
LoadInfo::GetLoadingContextXPCOM(nsISupports** aResult)
{
nsCOMPtr<nsISupports> context = GetLoadingContext();
context.forget(aResult);
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult)
{