From c94c6a578599e3c42814170da969f3a026e1a4ba Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 10 Jul 2024 09:14:47 +0200 Subject: [PATCH] [Dom/network] Disable DNS prefetching if document nodePrincipal is systemPrincipal --- dom/html/nsHTMLDNSPrefetch.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dom/html/nsHTMLDNSPrefetch.cpp b/dom/html/nsHTMLDNSPrefetch.cpp index 6a2d0e1d6c..6a7217021f 100644 --- a/dom/html/nsHTMLDNSPrefetch.cpp +++ b/dom/html/nsHTMLDNSPrefetch.cpp @@ -94,8 +94,15 @@ nsHTMLDNSPrefetch::Shutdown() } bool -nsHTMLDNSPrefetch::IsAllowed (nsIDocument *aDocument) +nsHTMLDNSPrefetch::IsAllowed(nsIDocument *aDocument) { + // Do not use prefetch if the document's node principal is the system + // principal. + nsCOMPtr principal = aDocument->NodePrincipal(); + if (nsContentUtils::IsSystemPrincipal(principal)) { + return false; + } + // There is no need to do prefetch on non UI scenarios such as XMLHttpRequest. return aDocument->IsDNSPrefetchAllowed() && aDocument->GetWindow(); }