From dacc355ec3267f43135400b88fe3ad814ca894c0 Mon Sep 17 00:00:00 2001 From: Kristen Wright Date: Wed, 21 Aug 2019 10:11:04 +0000 Subject: [PATCH] Bug 1572505 - Convert network.dns.disablePrefetchFromHTTPS to static pref. r=smaug,njn Converts network.dns.disablePrefetchFromHTTPS to a static pref. Though the original VarCache pref default to `false`, it looks like the intended value is `true`. (see comment #0 in bug 1572505) Differential Revision: https://phabricator.services.mozilla.com/D42737 --HG-- extra : moz-landing-system : lando --- dom/base/Document.cpp | 6 +++--- dom/html/nsHTMLDNSPrefetch.cpp | 8 -------- modules/libpref/init/StaticPrefList.yaml | 5 +++++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 4daf897f483b..4ec241cce397 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -34,6 +34,7 @@ #include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_full_screen_api.h" #include "mozilla/StaticPrefs_layout.h" +#include "mozilla/StaticPrefs_network.h" #include "mozilla/StaticPrefs_page_load.h" #include "mozilla/StaticPrefs_plugins.h" #include "mozilla/StaticPrefs_privacy.h" @@ -351,8 +352,6 @@ #define NS_MAX_DOCUMENT_WRITE_DEPTH 20 -extern bool sDisablePrefetchHTTPSPref; - mozilla::LazyLogModule gPageCacheLog("PageCache"); namespace mozilla { @@ -3495,7 +3494,8 @@ void Document::RemoveFromIdTable(Element* aElement, nsAtom* aId) { void Document::SetPrincipals(nsIPrincipal* aNewPrincipal, nsIPrincipal* aNewStoragePrincipal) { MOZ_ASSERT(!!aNewPrincipal == !!aNewStoragePrincipal); - if (aNewPrincipal && mAllowDNSPrefetch && sDisablePrefetchHTTPSPref) { + if (aNewPrincipal && mAllowDNSPrefetch && + StaticPrefs::network_dns_disablePrefetchFromHTTPS()) { nsCOMPtr uri; aNewPrincipal->GetURI(getter_AddRefs(uri)); if (!uri || uri->SchemeIs("https")) { diff --git a/dom/html/nsHTMLDNSPrefetch.cpp b/dom/html/nsHTMLDNSPrefetch.cpp index 1484f525dcc3..ef90e7efb25e 100644 --- a/dom/html/nsHTMLDNSPrefetch.cpp +++ b/dom/html/nsHTMLDNSPrefetch.cpp @@ -38,7 +38,6 @@ using namespace mozilla::dom; using namespace mozilla::net; static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID); -bool sDisablePrefetchHTTPSPref; static bool sInitialized = false; static nsIDNSService* sDNSService = nullptr; static nsHTMLDNSPrefetch::nsDeferrals* sPrefetches = nullptr; @@ -59,15 +58,8 @@ nsresult nsHTMLDNSPrefetch::Initialize() { sPrefetches->Activate(); - Preferences::AddBoolVarCache(&sDisablePrefetchHTTPSPref, - "network.dns.disablePrefetchFromHTTPS"); - Preferences::AddBoolVarCache(&sEsniEnabled, "network.security.esni.enabled"); - // Default is false, so we need an explicit call to prime the cache. - sDisablePrefetchHTTPSPref = - Preferences::GetBool("network.dns.disablePrefetchFromHTTPS", true); - sEsniEnabled = Preferences::GetBool("network.security.esni.enabled", false); NS_IF_RELEASE(sDNSService); diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 483ad8057b03..be744738a9a6 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -5985,6 +5985,11 @@ value: 0 mirror: always +- name: network.dns.disablePrefetchFromHTTPS + type: bool + value: true + mirror: always + # Max time to shutdown the resolver threads - name: network.dns.resolver_shutdown_timeout_ms type: uint32_t