зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1641905
- ThirdPartyUtil::IsThirdPartyWindow returns different values in fission - use the principal to inherit for about:blank channels, r=dimi
Differential Revision: https://phabricator.services.mozilla.com/D81558
This commit is contained in:
Родитель
118d838da8
Коммит
b397940b11
|
@ -100,7 +100,9 @@ nsresult ThirdPartyUtil::IsThirdPartyInternal(const nsCString& aFirstDomain,
|
||||||
nsresult rv = GetBaseDomain(aSecondURI, secondDomain);
|
nsresult rv = GetBaseDomain(aSecondURI, secondDomain);
|
||||||
LOG(("ThirdPartyUtil::IsThirdPartyInternal %s =? %s", aFirstDomain.get(),
|
LOG(("ThirdPartyUtil::IsThirdPartyInternal %s =? %s", aFirstDomain.get(),
|
||||||
secondDomain.get()));
|
secondDomain.get()));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
*aResult = IsThirdPartyInternal(aFirstDomain, secondDomain);
|
*aResult = IsThirdPartyInternal(aFirstDomain, secondDomain);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -161,7 +163,9 @@ ThirdPartyUtil::IsThirdPartyURI(nsIURI* aFirstURI, nsIURI* aSecondURI,
|
||||||
|
|
||||||
nsAutoCString firstHost;
|
nsAutoCString firstHost;
|
||||||
nsresult rv = GetBaseDomain(aFirstURI, firstHost);
|
nsresult rv = GetBaseDomain(aFirstURI, firstHost);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
return IsThirdPartyInternal(firstHost, aSecondURI, aResult);
|
return IsThirdPartyInternal(firstHost, aSecondURI, aResult);
|
||||||
}
|
}
|
||||||
|
@ -275,25 +279,58 @@ ThirdPartyUtil::IsThirdPartyChannel(nsIChannel* aChannel, nsIURI* aURI,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parentIsThird = false;
|
bool parentIsThird = false;
|
||||||
|
nsAutoCString channelDomain;
|
||||||
|
|
||||||
// Obtain the URI from the channel, and its base domain.
|
// Obtain the URI from the channel, and its base domain.
|
||||||
nsCOMPtr<nsIURI> channelURI;
|
nsCOMPtr<nsIURI> channelURI;
|
||||||
rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI));
|
rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
nsAutoCString channelDomain;
|
BasePrincipal* loadingPrincipal = nullptr;
|
||||||
rv = GetBaseDomain(channelURI, channelDomain);
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
if (!doForce) {
|
if (!doForce) {
|
||||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
|
||||||
parentIsThird = loadInfo->GetIsInThirdPartyContext();
|
parentIsThird = loadInfo->GetIsInThirdPartyContext();
|
||||||
if (!parentIsThird && loadInfo->GetExternalContentPolicyType() !=
|
if (!parentIsThird && loadInfo->GetExternalContentPolicyType() !=
|
||||||
nsIContentPolicy::TYPE_DOCUMENT) {
|
nsIContentPolicy::TYPE_DOCUMENT) {
|
||||||
// Check if the channel itself is third-party to its own requestor.
|
// Check if the channel itself is third-party to its own requestor.
|
||||||
// Unforunately, we have to go through the loading principal.
|
// Unfortunately, we have to go through the loading principal.
|
||||||
BasePrincipal* loadingPrincipal =
|
loadingPrincipal = BasePrincipal::Cast(loadInfo->GetLoadingPrincipal());
|
||||||
BasePrincipal::Cast(loadInfo->GetLoadingPrincipal());
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special consideration must be done for about:blank URIs because those
|
||||||
|
// inherit the principal from the parent context. For them, let's consider the
|
||||||
|
// principal URI.
|
||||||
|
if (NS_IsAboutBlank(channelURI)) {
|
||||||
|
nsCOMPtr<nsIPrincipal> principalToInherit =
|
||||||
|
loadInfo->FindPrincipalToInherit(aChannel);
|
||||||
|
if (!principalToInherit) {
|
||||||
|
*aResult = true;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = principalToInherit->GetBaseDomain(channelDomain);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadingPrincipal) {
|
||||||
|
rv = loadingPrincipal->IsThirdPartyPrincipal(principalToInherit,
|
||||||
|
&parentIsThird);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rv = GetBaseDomain(channelURI, channelDomain);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadingPrincipal) {
|
||||||
rv = loadingPrincipal->IsThirdPartyURI(channelURI, &parentIsThird);
|
rv = loadingPrincipal->IsThirdPartyURI(channelURI, &parentIsThird);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче