Bug 1543001 - ContentBlocking exception should cover top-level domain too, r=Ehsan

Differential Revision: https://phabricator.services.mozilla.com/D26732

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2019-04-10 07:08:28 +00:00
Родитель 4f73dda990
Коммит 7ebd463919
1 изменённых файлов: 31 добавлений и 14 удалений

Просмотреть файл

@ -376,25 +376,42 @@ bool CheckContentBlockingAllowList(nsIHttpChannel* aChannel) {
return entry.Data().mResult;
}
nsCOMPtr<nsIHttpChannelInternal> chan = do_QueryInterface(aChannel);
if (chan) {
nsCOMPtr<nsIURI> topWinURI;
nsresult rv = chan->GetTopWindowURI(getter_AddRefs(topWinURI));
if (NS_SUCCEEDED(rv)) {
const bool result = CheckContentBlockingAllowList(
topWinURI, NS_UsePrivateBrowsing(aChannel));
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
nsContentPolicyType contentPolicyType =
loadInfo->GetExternalContentPolicyType();
entry.Set(ContentBlockingAllowListEntry(aChannel, result));
nsCOMPtr<nsIURI> uri;
return result;
// This is the top-level request. Let's use the channel URI.
if (contentPolicyType == nsIContentPolicy::TYPE_DOCUMENT) {
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
if (NS_WARN_IF(NS_FAILED(rv)) || !uri) {
LOG(
("Could not check the content blocking allow list because the "
"channel URI is not accessible"));
entry.Set(ContentBlockingAllowListEntry(aChannel, false));
return false;
}
} else {
nsCOMPtr<nsIHttpChannelInternal> chan = do_QueryInterface(aChannel);
MOZ_ASSERT(chan);
nsresult rv = chan->GetTopWindowURI(getter_AddRefs(uri));
if (NS_WARN_IF(NS_FAILED(rv)) || !uri) {
LOG(
("Could not check the content blocking allow list because the top "
"window wasn't accessible"));
entry.Set(ContentBlockingAllowListEntry(aChannel, false));
return false;
}
}
LOG(
("Could not check the content blocking allow list because the top "
"window wasn't accessible"));
entry.Set(ContentBlockingAllowListEntry(aChannel, false));
return false;
MOZ_ASSERT(uri);
const bool result =
CheckContentBlockingAllowList(uri, NS_UsePrivateBrowsing(aChannel));
entry.Set(ContentBlockingAllowListEntry(aChannel, result));
return result;
}
void ReportBlockingToConsole(nsPIDOMWindowOuter* aWindow, nsIURI* aURI,