From 1f038cd026a9b684545d856c7caebce70a867c6f Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 14 Nov 2024 21:53:59 +0100 Subject: [PATCH 01/12] No Issue - stop spewing useless xfo < CSP warning in non-debug builds This warning throws off a lot of users reporting issues. It's not even a proper warning as it's informative at best. Leave it in for debug builds, but stop spewing these common notices in release builds. --- docshell/base/nsDSURIContentListener.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp index 7aa3a5d14d..cac2a1786c 100644 --- a/docshell/base/nsDSURIContentListener.cpp +++ b/docshell/base/nsDSURIContentListener.cpp @@ -427,6 +427,7 @@ ShouldIgnoreFrameOptions(nsIChannel* aChannel, nsIPrincipal* aPrincipal) return false; } +#ifdef DEBUG // log warning to console that xfo is ignored because of CSP nsCOMPtr loadInfo = aChannel->GetLoadInfo(); uint64_t innerWindowID = loadInfo ? loadInfo->GetInnerWindowID() : 0; @@ -440,7 +441,7 @@ ShouldIgnoreFrameOptions(nsIChannel* aChannel, nsIPrincipal* aPrincipal) 0, // no columnnumber nsIScriptError::warningFlag, "CSP", innerWindowID); - +#endif return true; } From f5ef327563c900105a8b546b7a0354f446daa64b Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 15 Nov 2024 12:25:52 +0100 Subject: [PATCH 02/12] Issue #2652 - Part 1: Add a way to programmatically clear the DNS cache. --- netwerk/dns/ChildDNSService.cpp | 7 +++++++ netwerk/dns/nsDNSService2.cpp | 6 ++++++ netwerk/dns/nsIDNSService.idl | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/netwerk/dns/ChildDNSService.cpp b/netwerk/dns/ChildDNSService.cpp index a3a1f3347b..c95c3551fe 100644 --- a/netwerk/dns/ChildDNSService.cpp +++ b/netwerk/dns/ChildDNSService.cpp @@ -202,6 +202,13 @@ ChildDNSService::GetDNSCacheEntries(nsTArray *arg return NS_ERROR_NOT_AVAILABLE; } +NS_IMETHODIMP +ChildDNSService::ClearCache() +{ + // Not available in IPC children. + return NS_ERROR_NOT_AVAILABLE; +} + NS_IMETHODIMP ChildDNSService::GetMyHostName(nsACString &result) { diff --git a/netwerk/dns/nsDNSService2.cpp b/netwerk/dns/nsDNSService2.cpp index e8e257d0f9..4ebfb647d8 100644 --- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -1052,6 +1052,12 @@ nsDNSService::GetDNSCacheEntries(nsTArray *args) return NS_OK; } +NS_IMETHODIMP +nsDNSService::ClearCache() { + mResolver->FlushCache(); + return NS_OK; +} + size_t nsDNSService::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { diff --git a/netwerk/dns/nsIDNSService.idl b/netwerk/dns/nsIDNSService.idl index 2704790dc3..816d01dd60 100644 --- a/netwerk/dns/nsIDNSService.idl +++ b/netwerk/dns/nsIDNSService.idl @@ -115,6 +115,11 @@ interface nsIDNSService : nsISupports */ [noscript] void getDNSCacheEntries(in EntriesArray args); + /** + * Clears the DNS cache. + */ + void clearCache(); + /** * @return the hostname of the operating system. */ From 60e671e956938a46a9da9a11e973eada03ca11d2 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 15 Nov 2024 12:47:24 +0100 Subject: [PATCH 03/12] Issue #2652 - Part2: Add "Clear DNS cache" button to about:networking Resolves #2652 --- toolkit/content/aboutNetworking.js | 8 ++++++++ toolkit/content/aboutNetworking.xhtml | 2 ++ toolkit/locales/en-US/chrome/global/aboutNetworking.dtd | 1 + 3 files changed, 11 insertions(+) diff --git a/toolkit/content/aboutNetworking.js b/toolkit/content/aboutNetworking.js index 9400ae9d70..633af63c0e 100644 --- a/toolkit/content/aboutNetworking.js +++ b/toolkit/content/aboutNetworking.js @@ -176,6 +176,14 @@ function init() { doLookup(); }); + let clearDNSCache = document.getElementById("clearDNSCache"); + clearDNSCache.addEventListener("click", function() { + Cc["@mozilla.org/network/dns-service;1"] + .getService(Ci.nsIDNSService) + .clearCache(); + requestAllNetworkingData(); + }); + let setLogButton = document.getElementById("set-log-file-button"); setLogButton.addEventListener("click", setLogFile); diff --git a/toolkit/content/aboutNetworking.xhtml b/toolkit/content/aboutNetworking.xhtml index 440ee78385..17bcc2ac49 100644 --- a/toolkit/content/aboutNetworking.xhtml +++ b/toolkit/content/aboutNetworking.xhtml @@ -96,6 +96,8 @@