Bug 1629436 - requests with webExtension loading principal are not 3rd party, r=ckerschb,robwu,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D73027
This commit is contained in:
@@ -351,23 +351,22 @@ ThirdPartyUtil::IsThirdPartyChannel(nsIChannel* aChannel, nsIURI* aURI,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!doForce) {
|
||||
if (nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo()) {
|
||||
parentIsThird = loadInfo->GetIsInThirdPartyContext();
|
||||
if (!parentIsThird && loadInfo->GetExternalContentPolicyType() !=
|
||||
nsIContentPolicy::TYPE_DOCUMENT) {
|
||||
// Check if the channel itself is third-party to its own requestor.
|
||||
// Unforunately, we have to go through the loading principal.
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
|
||||
parentIsThird = loadInfo->GetIsInThirdPartyContext();
|
||||
BasePrincipal* loadingPrincipal =
|
||||
BasePrincipal::Cast(loadInfo->GetLoadingPrincipal());
|
||||
if (!parentIsThird &&
|
||||
loadInfo->GetExternalContentPolicyType() !=
|
||||
nsIContentPolicy::TYPE_DOCUMENT &&
|
||||
(!loadingPrincipal->AddonPolicy() ||
|
||||
!loadingPrincipal->AddonAllowsLoad(channelURI))) {
|
||||
// Check if the channel itself is third-party to its own requestor.
|
||||
// Unforunately, we have to go through the loading principal.
|
||||
|
||||
rv = loadInfo->GetLoadingPrincipal()->IsThirdPartyURI(channelURI,
|
||||
&parentIsThird);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = loadingPrincipal->IsThirdPartyURI(channelURI, &parentIsThird);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
NS_WARNING(
|
||||
"Found channel with no loadinfo, assuming third-party request");
|
||||
parentIsThird = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2110,8 +2110,10 @@ bool NS_IsSameSiteForeign(nsIChannel* aChannel, nsIURI* aHostURI) {
|
||||
// Do not treat loads triggered by web extensions as foreign
|
||||
nsCOMPtr<nsIURI> channelURI;
|
||||
NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI));
|
||||
if (BasePrincipal::Cast(loadInfo->TriggeringPrincipal())
|
||||
->AddonAllowsLoad(channelURI)) {
|
||||
RefPtr<BasePrincipal> triggeringPrincipal =
|
||||
BasePrincipal::Cast(loadInfo->TriggeringPrincipal());
|
||||
if (triggeringPrincipal->AddonPolicy() &&
|
||||
triggeringPrincipal->AddonAllowsLoad(channelURI)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2122,8 +2124,7 @@ bool NS_IsSameSiteForeign(nsIChannel* aChannel, nsIURI* aHostURI) {
|
||||
// for loads of TYPE_DOCUMENT we query the hostURI from the
|
||||
// triggeringPrincipal which returns the URI of the document that caused the
|
||||
// navigation.
|
||||
rv = loadInfo->TriggeringPrincipal()->IsThirdPartyChannel(aChannel,
|
||||
&isForeign);
|
||||
rv = triggeringPrincipal->IsThirdPartyChannel(aChannel, &isForeign);
|
||||
} else {
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
|
||||
do_GetService(THIRDPARTYUTIL_CONTRACTID);
|
||||
|
||||
Reference in New Issue
Block a user