diff --git a/browser/components/doh/TRRPerformance.jsm b/browser/components/doh/TRRPerformance.jsm index f410b438f458..3e024d34dfda 100644 --- a/browser/components/doh/TRRPerformance.jsm +++ b/browser/components/doh/TRRPerformance.jsm @@ -59,21 +59,9 @@ XPCOMUtils.defineLazyServiceGetter( ); // The list of participating TRRs. -XPCOMUtils.defineLazyPreferenceGetter( - this, - "kTRRs", - "network.trr.resolvers", - null, - null, - val => - val - ? JSON.parse(val).map(trr => trr.url) - : [ - "https://mozilla.cloudflare-dns.com/dns-query", - "https://trr.dns.nextdns.io/", - "https://doh.xfinity.com/dns-query", - ] -); +const kTRRs = JSON.parse( + Services.prefs.getDefaultBranch("").getCharPref("network.trr.resolvers") +).map(trr => trr.url); // The canonical domain whose subdomains we will be resolving. XPCOMUtils.defineLazyPreferenceGetter( diff --git a/browser/components/doh/test/unit/head.js b/browser/components/doh/test/unit/head.js index d2790b9a60c2..9d2125eefd64 100644 --- a/browser/components/doh/test/unit/head.js +++ b/browser/components/doh/test/unit/head.js @@ -15,9 +15,7 @@ const { TestUtils } = ChromeUtils.import( ); let h2Port, trrServer1, trrServer2; -const { DNSLookup, LookupAggregator, TRRRacer } = ChromeUtils.import( - "resource:///modules/TRRPerformance.jsm" -); +let DNSLookup, LookupAggregator, TRRRacer; function readFile(file) { let fstream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance( @@ -75,11 +73,6 @@ function setup() { ); addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u"); - Services.prefs.setCharPref( - "network.trr.resolvers", - `[{"url": "${trrServer1}"}, {"url": "${trrServer2}"}]` - ); - Services.prefs.setIntPref("doh-rollout.trrRace.randomSubdomainCount", 2); Services.prefs.setCharPref( @@ -92,6 +85,24 @@ function setup() { "firefox-dns-perf-test.net" ); + let defaultPrefBranch = Services.prefs.getDefaultBranch(""); + let origResolverList = defaultPrefBranch.getCharPref("network.trr.resolvers"); + + Services.prefs + .getDefaultBranch("") + .setCharPref( + "network.trr.resolvers", + `[{"url": "${trrServer1}"}, {"url": "${trrServer2}"}]` + ); + + let TRRPerformance = ChromeUtils.import( + "resource:///modules/TRRPerformance.jsm" + ); + + DNSLookup = TRRPerformance.DNSLookup; + LookupAggregator = TRRPerformance.LookupAggregator; + TRRRacer = TRRPerformance.TRRRacer; + let oldCanRecord = Services.telemetry.canRecordExtended; Services.telemetry.canRecordExtended = true; @@ -99,7 +110,7 @@ function setup() { Services.prefs.clearUserPref("network.http.spdy.enabled"); Services.prefs.clearUserPref("network.http.spdy.enabled.http2"); Services.prefs.clearUserPref("network.dns.native-is-localhost"); - Services.prefs.clearUserPref("network.trr.resolvers"); + defaultPrefBranch.setCharPref("network.trr.resolvers", origResolverList); Services.telemetry.canRecordExtended = oldCanRecord; });