Bug 1447935 - P1. CreatePairwiseEntitylist uses loading principal when a channel doesn't have an associated top-level window r=baku

loads in appcache doesn't have a top-level window, use loading principal
instead.

Differential Revision: https://phabricator.services.mozilla.com/D80186
This commit is contained in:
Dimi Lee 2020-07-09 20:10:16 +00:00
parent b355fcc4bf
commit 5c5dfa4064

View File

@ -336,12 +336,26 @@ nsresult UrlClassifierCommon::CreatePairwiseEntityListURI(nsIChannel* aChannel,
auto clientPrincipalOrErr = clientInfo->GetPrincipal();
if (clientPrincipalOrErr.isOk()) {
nsCOMPtr<nsIPrincipal> principal = clientPrincipalOrErr.unwrap();
auto* basePrin = BasePrincipal::Cast(principal);
rv = basePrin->GetURI(getter_AddRefs(topWinURI));
Unused << NS_WARN_IF(NS_FAILED(rv));
if (principal) {
auto* basePrin = BasePrincipal::Cast(principal);
rv = basePrin->GetURI(getter_AddRefs(topWinURI));
Unused << NS_WARN_IF(NS_FAILED(rv));
}
}
}
}
if (!topWinURI) {
UC_LOG(
("CreatePairwiseWhiteListURI: No top-level window associated with "
"channel, get URI from loading principal instead"));
nsCOMPtr<nsIPrincipal> principal = loadInfo->GetLoadingPrincipal();
if (principal) {
auto* basePrin = BasePrincipal::Cast(principal);
rv = basePrin->GetURI(getter_AddRefs(topWinURI));
Unused << NS_WARN_IF(NS_FAILED(rv));
}
}
}
if (!topWinURI) {
@ -354,7 +368,7 @@ nsresult UrlClassifierCommon::CreatePairwiseEntityListURI(nsIChannel* aChannel,
uri->GetAsciiSpec(spec);
spec.Truncate(
std::min(spec.Length(), UrlClassifierCommon::sMaxSpecLength));
UC_LOG(("CreatePairwiseEntityListURI: No window URI associated with %s",
UC_LOG(("CreatePairwiseEntityListURI: No top-level URI associated with %s",
spec.get()));
}