Bug 1880374 - Disable DNS prefetching if document nodePrincipal is systemPrincipal r=valentin

Differential Revision: https://phabricator.services.mozilla.com/D210830
This commit is contained in:
Julian Descottes 2024-05-24 08:28:22 +00:00
parent 6c87301889
commit 31308a6d79

View File

@ -180,6 +180,13 @@ static bool EnsureDNSService() {
}
bool HTMLDNSPrefetch::IsAllowed(Document* aDocument) {
// Do not use prefetch if the document's node principal is the system
// principal.
nsCOMPtr<nsIPrincipal> principal = aDocument->NodePrincipal();
if (principal->IsSystemPrincipal()) {
return false;
}
// There is no need to do prefetch on non UI scenarios such as XMLHttpRequest.
return aDocument->IsDNSPrefetchAllowed() && aDocument->GetWindow();
}