Backed out 5 changesets (bug 1640709, bug 1631609) for doh-rollout failures. CLOSED TREE

Backed out changeset 9e1db3f3e44a (bug 1640709)
Backed out changeset 87f51b855906 (bug 1631609)
Backed out changeset f201e950b155 (bug 1631609)
Backed out changeset b40a0f8c92b4 (bug 1631609)
Backed out changeset a72c39358236 (bug 1631609)
This commit is contained in:
Csoregi Natalia 2020-06-05 01:50:19 +03:00
Родитель 63635ef2aa
Коммит cd4ffe7bbe
15 изменённых файлов: 104 добавлений и 315 удалений

Просмотреть файл

@ -18,6 +18,11 @@ async function log() {
// Gate-keeping pref to run the add-on
const DOH_ENABLED_PREF = "doh-rollout.enabled";
// When in automation, we parse this string pref as JSON and use it as our
// heuristics results set. This allows tests to set up different cases and
// verify the correct response.
const MOCK_HEURISTICS_PREF = "doh-rollout.heuristics.mockValues";
// Pref that sets DoH to on/off. It has multiple modes:
// 0: Off (default)
// 1: null (No setting)
@ -218,6 +223,14 @@ const rollout = {
// Pretend that there was a network change at the beginning of time.
lastNetworkChangeTime: 0,
async isTesting() {
if (this._isTesting === undefined) {
this._isTesting = await browser.experiments.heuristics.isTesting();
}
return this._isTesting;
},
addDoorhangerListeners() {
browser.experiments.doorhanger.onDoorhangerAccept.addListener(
rollout.doorhangerAcceptListener
@ -266,7 +279,17 @@ const rollout = {
}
// Run heuristics defined in heuristics.js and experiments/heuristics/api.js
let results = await runHeuristics();
let results;
if (await rollout.isTesting()) {
results = await browser.experiments.preferences.getCharPref(
MOCK_HEURISTICS_PREF,
`{ "test": "disable_doh" }`
);
results = JSON.parse(results);
} else {
results = await runHeuristics();
}
// Check if DoH should be disabled
let decision = Object.values(results).includes("disable_doh")

Просмотреть файл

@ -31,7 +31,6 @@ const HEURISTICS_TELEMETRY_EVENTS = {
"browserParent",
"thirdPartyRoots",
"policy",
"steeredProvider",
"evaluateReason",
],
record_on_release: true,
@ -93,10 +92,6 @@ this.heuristics = class heuristics extends ExtensionAPI {
},
async checkEnterprisePolicies() {
if (Cu.isInAutomation) {
return "no_policy_set";
}
if (Services.policies.status === Services.policies.ACTIVE) {
let policies = Services.policies.getActivePolicies();
@ -119,10 +114,6 @@ this.heuristics = class heuristics extends ExtensionAPI {
},
async checkParentalControls() {
if (Cu.isInAutomation) {
return "enable_doh";
}
if (pcs.parentalControlsEnabled) {
return "disable_doh";
}
@ -130,10 +121,6 @@ this.heuristics = class heuristics extends ExtensionAPI {
},
async checkThirdPartyRoots() {
if (Cu.isInAutomation) {
return "enable_doh";
}
let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
Ci.nsIX509CertDB
);

Просмотреть файл

@ -62,10 +62,6 @@
"description": "Indicates whether browser policy blocks DoH",
"type": "string"
},
"steeredProvider": {
"description": "Indicates whether we steered to a provider-endpoint. Value is the name of the provider",
"type": "string"
},
"evaluateReason": {
"description": "Reason why we are running heuristics, e.g. startup",
"type": "string"

Просмотреть файл

@ -82,7 +82,7 @@
"parameters": [
{
"type": "string",
"enum": ["doh-rollout.doorhanger-decision", "doh-rollout.heuristics.mockValues", "doh-rollout.provider-steering.provider-list"]
"enum": ["doh-rollout.doorhanger-decision", "doh-rollout.heuristics.mockValues"]
},
{
"type": "string",

Просмотреть файл

@ -52,7 +52,7 @@ this.trrselect = class trrselect extends ExtensionAPI {
if (Cu.isInAutomation) {
// For mochitests, just record telemetry with a dummy result.
// TRRPerformance.jsm is tested in xpcshell.
setDryRunResultAndRecordTelemetry("https://dummytrr.com/query");
setDryRunResultAndRecordTelemetry("dummyTRR");
return;
}
@ -72,22 +72,14 @@ this.trrselect = class trrselect extends ExtensionAPI {
},
async run() {
// If persisting the selection is disabled, clear the existing
// selection.
if (!Services.prefs.getBoolPref(kCommitSelectionPref, false)) {
Services.prefs.clearUserPref(kRolloutURIPref);
}
if (!Services.prefs.getBoolPref(kEnabledPref, false)) {
return;
}
// If we already have a selection, nothing to be done.
if (Services.prefs.prefHasUserValue(kRolloutURIPref)) {
return;
}
// Populate the dry-run-result if needed.
await this.dryRun();
// If persisting the selection is disabled, don't commit the value.
@ -95,7 +87,6 @@ this.trrselect = class trrselect extends ExtensionAPI {
return;
}
// All good, commit the value!
Services.prefs.setCharPref(
kRolloutURIPref,
Services.prefs.getCharPref(kDryRunResultPref)

Просмотреть файл

@ -11,24 +11,19 @@ const GLOBAL_CANARY = "use-application-dns.net";
const NXDOMAIN_ERR = "NS_ERROR_UNKNOWN_HOST";
async function dnsLookup(hostname, resolveCanonicalName = false) {
async function dnsLookup(hostname) {
let flags = ["disable_trr", "disable_ipv6", "bypass_cache"];
if (resolveCanonicalName) {
flags.push("canonical_name");
}
let addresses, canonicalName, err;
let addresses, err;
try {
let response = await browser.dns.resolve(hostname, flags);
addresses = response.addresses;
canonicalName = response.canonicalName;
} catch (e) {
addresses = [null];
err = e.message;
}
return { addresses, canonicalName, err };
return { addresses, err };
}
async function dnsListLookup(domainList) {
@ -126,86 +121,26 @@ async function modifiedRoots() {
return "enable_doh";
}
// Check if the network provides a DoH endpoint to use. Returns the name of the
// provider if the check is successful, else null.
async function providerSteering() {
if (
!(await browser.experiments.preferences.getBoolPref(
"doh-rollout.provider-steering.enabled",
false
))
) {
return null;
}
const TEST_DOMAIN = "doh.test";
// Array of { name, canonicalName, uri } where name is an identifier for
// telemetry, canonicalName is the expected CNAME when looking up doh.test,
// and uri is the provider's DoH endpoint.
let steeredProviders = await browser.experiments.preferences.getCharPref(
"doh-rollout.provider-steering.provider-list",
"[]"
);
try {
steeredProviders = JSON.parse(steeredProviders);
} catch (e) {
console.log("Provider list is invalid JSON, moving on.");
return null;
}
if (!steeredProviders || !steeredProviders.length) {
return null;
}
let { canonicalName, err } = await dnsLookup(TEST_DOMAIN, true);
if (err || !canonicalName) {
return null;
}
let provider = steeredProviders.find(p => {
return p && p.canonicalName == canonicalName;
});
if (!provider || !provider.uri || !provider.name) {
return null;
}
// We handle this here instead of background.js since we need to set this
// override every time we run heuristics.
browser.experiments.heuristics.setDetectedTrrURI(provider.uri);
return provider.name;
}
async function runHeuristics() {
// First run enterprise and OS-level parental controls heuristics.
let results = {
google: "",
youtube: "",
zscalerCanary: "",
canary: await globalCanary(),
modifiedRoots: await modifiedRoots(),
browserParent: await browser.experiments.heuristics.checkParentalControls(),
thirdPartyRoots: await browser.experiments.heuristics.checkThirdPartyRoots(),
policy: await browser.experiments.heuristics.checkEnterprisePolicies(),
steeredProvider: "",
};
// If any of those were triggered, return the results immediately.
if (Object.values(results).includes("disable_doh")) {
return results;
}
// Check for provider steering, return results immediately if triggered.
results.steeredProvider = (await providerSteering()) || "";
if (results.steeredProvider) {
return results;
}
// Finally, run safe search checks and zscaler canary.
let safeSearchChecks = await safeSearch();
results.google = safeSearchChecks.google;
results.youtube = safeSearchChecks.youtube;
results.zscalerCanary = await zscalerCanary();
let zscalerCheck = await zscalerCanary();
let canaryCheck = await globalCanary();
let modifiedRootsCheck = await modifiedRoots();
return results;
// Check other heuristics through privileged code
let browserParentCheck = await browser.experiments.heuristics.checkParentalControls();
let enterpriseCheck = await browser.experiments.heuristics.checkEnterprisePolicies();
let thirdPartyRootsCheck = await browser.experiments.heuristics.checkThirdPartyRoots();
// Return result of each heuristic
return {
google: safeSearchChecks.google,
youtube: safeSearchChecks.youtube,
zscalerCanary: zscalerCheck,
canary: canaryCheck,
modifiedRoots: modifiedRootsCheck,
browserParent: browserParentCheck,
thirdPartyRoots: thirdPartyRootsCheck,
policy: enterpriseCheck,
};
}

Просмотреть файл

@ -8,7 +8,6 @@ skip-if = debug # Bug 1548006 - reloading an addon upsets the leak checker.
[browser_doorhanger_newProfile.js]
[browser_policyOverride.js]
skip-if = (!debug && bits == 64) #Bug 1605297
[browser_providerSteering.js]
[browser_rollback.js]
skip-if = asan && !debug && os == 'linux' && bits == 64 && os_version == '18.04' # Bug 1613994 for linux1804
[browser_trrSelect.js]

Просмотреть файл

@ -13,7 +13,7 @@ add_task(async function testCleanFlow() {
is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved.");
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete."
);
await checkTRRSelectionTelemetry();

Просмотреть файл

@ -13,7 +13,7 @@ add_task(async function testDoorhangerUserReject() {
is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved.");
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete."
);
await checkTRRSelectionTelemetry();

Просмотреть файл

@ -16,7 +16,7 @@ add_task(async function testDoorhanger() {
is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved.");
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete."
);
await checkTRRSelectionTelemetry();

Просмотреть файл

@ -1,77 +0,0 @@
"use strict";
const TEST_DOMAIN = "doh.test";
add_task(setup);
add_task(async function testProviderSteering() {
setPassingHeuristics();
Preferences.set(prefs.DOH_ENABLED_PREF, true);
await BrowserTestUtils.waitForCondition(() => {
return Preferences.get(prefs.DOH_SELF_ENABLED_PREF);
});
is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved.");
await checkHeuristicsTelemetry("enable_doh", "startup");
let providerTestcases = [
{
name: "provider1",
canonicalName: "foo.provider1.com",
uri: "https://foo.provider1.com/query",
},
{
name: "provider2",
canonicalName: "bar.provider2.com",
uri: "https://bar.provider2.com/query",
},
];
Preferences.set(
prefs.DOH_PROVIDER_STEERING_LIST_PREF,
JSON.stringify(providerTestcases)
);
for (let { name, canonicalName, uri } of providerTestcases) {
gDNSOverride.addIPOverride(TEST_DOMAIN, "9.9.9.9");
gDNSOverride.setCnameOverride(TEST_DOMAIN, canonicalName);
let trrURIChanged = TestUtils.topicObserved(
"network:trr-uri-changed",
() => {
// We need this check because this topic is observed once immediately
// after the network change when the URI is reset, and then when the
// provider steering heuristic runs and sets it to our uri.
return gDNSService.currentTrrURI == uri;
}
);
simulateNetworkChange();
await trrURIChanged;
is(gDNSService.currentTrrURI, uri, "TRR URI set to provider endpoint");
await checkHeuristicsTelemetry("enable_doh", "netchange", name);
gDNSOverride.clearHostOverride(TEST_DOMAIN);
}
let trrURIChanged = TestUtils.topicObserved("network:trr-uri-changed");
simulateNetworkChange();
await trrURIChanged;
is(
gDNSService.currentTrrURI,
"https://dummytrr.com/query",
"TRR URI set to auto-selected"
);
await checkHeuristicsTelemetry("enable_doh", "netchange");
// Set enterprise roots enabled and ensure provider steering is disabled.
Preferences.set("security.enterprise_roots.enabled", true);
gDNSOverride.setCnameOverride(
TEST_DOMAIN,
providerTestcases[0].canonicalName
);
simulateNetworkChange();
await checkHeuristicsTelemetry("disable_doh", "netchange");
is(
gDNSService.currentTrrURI,
"https://dummytrr.com/query",
"TRR URI set to auto-selected"
);
Preferences.reset("security.enterprise_roots.enabled");
gDNSOverride.clearHostOverride(TEST_DOMAIN);
});

Просмотреть файл

@ -15,7 +15,7 @@ add_task(async function testRollback() {
is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved.");
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete."
);
await checkTRRSelectionTelemetry();

Просмотреть файл

@ -10,22 +10,23 @@ add_task(async function testTRRSelect() {
.getDefaultBranch("")
.setCharPref(
"network.trr.resolvers",
`[{"url": "https://dummytrr.com/query"}, {"url": "https://dummytrr2.com/query"}]`
`[{"url": "dummyTRR"}, {"url": "dummyTRR2"}]`
);
Services.prefs.setCharPref(
"network.trr.resolvers",
`[{"url": "https://dummytrr.com/query"}, {"url": "https://dummytrr2.com/query"}, {"url": "https://dummytrr3.com/query"}]`
`[{"url": "dummyTRR"}, {"url": "dummyTRR2"}, {"url": "dummyTRR3"}]`
);
// Clean start: doh-rollout.uri should be set after init.
setPassingHeuristics();
let prefPromise = TestUtils.waitForPrefChange(prefs.DOH_SELF_ENABLED_PREF);
Preferences.set(prefs.DOH_ENABLED_PREF, true);
await prefPromise;
await BrowserTestUtils.waitForCondition(() => {
return Preferences.get(prefs.DOH_SELF_ENABLED_PREF);
});
is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved.");
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete."
);
@ -36,13 +37,13 @@ add_task(async function testTRRSelect() {
// Reset and restart add-on for good measure.
Preferences.reset(prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF);
Preferences.reset(prefs.DOH_TRR_SELECT_URI_PREF);
prefPromise = TestUtils.waitForPrefChange(prefs.DOH_TRR_SELECT_URI_PREF);
await restartAddon();
await prefPromise;
await BrowserTestUtils.waitForCondition(() => {
return Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF);
});
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete."
);
@ -50,38 +51,11 @@ add_task(async function testTRRSelect() {
await ensureTRRMode(2);
await checkHeuristicsTelemetry("enable_doh", "startup");
// Disable committing and reset. The committed URI should be cleared but the
// dry-run-result should persist.
Preferences.set(prefs.DOH_TRR_SELECT_COMMIT_PREF, false);
prefPromise = TestUtils.waitForPrefChange(prefs.DOH_TRR_SELECT_URI_PREF);
await restartAddon();
await prefPromise;
ok(
!Preferences.isSet(prefs.DOH_TRR_SELECT_URI_PREF),
"TRR selection cleared."
);
try {
await BrowserTestUtils.waitForCondition(() => {
return !Preferences.isSet(prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF);
});
ok(false, "Dry run result was cleared, fail!");
} catch (e) {
ok(true, "Dry run result was not cleared.");
}
is(
Preferences.get(prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF),
"https://dummytrr.com/query",
"dry-run result has the correct value."
);
// Wait for heuristics to complete.
await ensureTRRMode(2);
await checkHeuristicsTelemetry("enable_doh", "startup");
// Reset and restart add-on again, dry-run-result should be recorded but not
// be committed. Committing is still disabled from above.
// Reset and restart add-on again, but this time with committing disabled.
// dry-run-result should be recorded but not be committed.
Preferences.reset(prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF);
Preferences.reset(prefs.DOH_TRR_SELECT_URI_PREF);
Preferences.set(prefs.DOH_TRR_SELECT_COMMIT_PREF, false);
await restartAddon();
try {
await BrowserTestUtils.waitForCondition(() => {
@ -93,7 +67,7 @@ add_task(async function testTRRSelect() {
}
is(
Preferences.get(prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete, dry-run result recorded."
);
Preferences.set(prefs.DOH_TRR_SELECT_COMMIT_PREF, true);
@ -105,16 +79,14 @@ add_task(async function testTRRSelect() {
// Reset doh-rollout.uri, and change the dry-run-result to another one on the
// default list. After init, the existing dry-run-result should be committed.
Preferences.reset(prefs.DOH_TRR_SELECT_URI_PREF);
Preferences.set(
prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF,
"https://dummytrr2.com/query"
);
prefPromise = TestUtils.waitForPrefChange(prefs.DOH_TRR_SELECT_URI_PREF);
Preferences.set(prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF, "dummyTRR2");
await restartAddon();
await prefPromise;
await BrowserTestUtils.waitForCondition(() => {
return Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF);
});
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr2.com/query",
"dummyTRR2",
"TRR selection complete, existing dry-run-result committed."
);
@ -125,16 +97,14 @@ add_task(async function testTRRSelect() {
// Reset doh-rollout.uri, and change the dry-run-result to another one NOT on
// default list. After init, a new TRR should be selected and committed.
Preferences.reset(prefs.DOH_TRR_SELECT_URI_PREF);
Preferences.set(
prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF,
"https://dummytrr3.com/query"
);
prefPromise = TestUtils.waitForPrefChange(prefs.DOH_TRR_SELECT_URI_PREF);
Preferences.set(prefs.DOH_TRR_SELECT_DRY_RUN_RESULT_PREF, "dummyTRR3");
await restartAddon();
await prefPromise;
await BrowserTestUtils.waitForCondition(() => {
return Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF);
});
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete, existing dry-run-result discarded and refreshed."
);

Просмотреть файл

@ -13,7 +13,7 @@ add_task(async function testUserInterference() {
is(Preferences.get(prefs.DOH_SELF_ENABLED_PREF), true, "Breadcrumb saved.");
is(
Preferences.get(prefs.DOH_TRR_SELECT_URI_PREF),
"https://dummytrr.com/query",
"dummyTRR",
"TRR selection complete."
);
await checkTRRSelectionTelemetry();

Просмотреть файл

@ -12,20 +12,6 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/Preferences.jsm"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"gDNSService",
"@mozilla.org/network/dns-service;1",
"nsIDNSService"
);
XPCOMUtils.defineLazyServiceGetter(
this,
"gDNSOverride",
"@mozilla.org/network/native-dns-override;1",
"nsINativeDNSResolverOverride"
);
const { CommonUtils } = ChromeUtils.import(
"resource://services-common/utils.js"
);
@ -51,12 +37,32 @@ const prefs = {
DOH_TRR_SELECT_COMMIT_PREF: "doh-rollout.trr-selection.commit-result",
DOH_TRR_SELECT_DRY_RUN_RESULT_PREF:
"doh-rollout.trr-selection.dry-run-result",
DOH_PROVIDER_STEERING_PREF: "doh-rollout.provider-steering.enabled",
DOH_PROVIDER_STEERING_LIST_PREF:
"doh-rollout.provider-steering.provider-list",
MOCK_HEURISTICS_PREF: "doh-rollout.heuristics.mockValues",
PROFILE_CREATION_THRESHOLD_PREF: "doh-rollout.profileCreationThreshold",
};
const fakePassingHeuristics = JSON.stringify({
google: "enable_doh",
youtube: "enable_doh",
zscalerCanary: "enable_doh",
canary: "enable_doh",
modifiedRoots: "enable_doh",
browserParent: "enable_doh",
thirdPartyRoots: "enable_doh",
policy: "enable_doh",
});
const fakeFailingHeuristics = JSON.stringify({
google: "disable_doh",
youtube: "disable_doh",
zscalerCanary: "disable_doh",
canary: "disable_doh",
modifiedRoots: "disable_doh",
browserParent: "disable_doh",
thirdPartyRoots: "disable_doh",
policy: "disable_doh",
});
async function setup() {
SpecialPowers.pushPrefEnv({
set: [["security.notification_enable_delay", 0]],
@ -78,36 +84,9 @@ async function setup() {
// it can be controlled e.g. via Normandy, but for testing let's set enable.
Preferences.set(prefs.DOH_TRR_SELECT_COMMIT_PREF, true);
// Enable provider steering. This pref ships false by default so it can be
// controlled e.g. via Normandy, but for testing let's enable.
Preferences.set(prefs.DOH_PROVIDER_STEERING_PREF, true);
// Set up heuristics, all passing by default.
// Google safesearch overrides
gDNSOverride.addIPOverride("www.google.com", "1.1.1.1");
gDNSOverride.addIPOverride("google.com", "1.1.1.1");
gDNSOverride.addIPOverride("forcesafesearch.google.com", "1.1.1.2");
// YouTube safesearch overrides
gDNSOverride.addIPOverride("www.youtube.com", "2.1.1.1");
gDNSOverride.addIPOverride("m.youtube.com", "2.1.1.1");
gDNSOverride.addIPOverride("youtubei.googleapis.com", "2.1.1.1");
gDNSOverride.addIPOverride("youtube.googleapis.com", "2.1.1.1");
gDNSOverride.addIPOverride("www.youtube-nocookie.com", "2.1.1.1");
gDNSOverride.addIPOverride("restrict.youtube.com", "2.1.1.2");
gDNSOverride.addIPOverride("restrictmoderate.youtube.com", "2.1.1.2");
// Zscaler override
gDNSOverride.addIPOverride("sitereview.zscaler.com", "3.1.1.1");
// Global canary
gDNSOverride.addIPOverride("use-application-dns.net", "4.1.1.1");
registerCleanupFunction(async () => {
Services.telemetry.canRecordExtended = oldCanRecord;
Services.telemetry.clearEvents();
gDNSOverride.clearOverrides();
await resetPrefsAndRestartAddon();
});
}
@ -127,11 +106,7 @@ async function checkTRRSelectionTelemetry() {
e[3] == "dryrunresult"
);
is(events.length, 1, "Found the expected trrselect event.");
is(
events[0][4],
"https://dummytrr.com/query",
"The event records the expected decision"
);
is(events[0][4], "dummyTRR", "The event records the expected decision");
}
function ensureNoTRRSelectionTelemetry() {
@ -151,11 +126,7 @@ function ensureNoTRRSelectionTelemetry() {
is(events.length, 0, "Found no trrselect events.");
}
async function checkHeuristicsTelemetry(
decision,
evaluateReason,
steeredProvider = ""
) {
async function checkHeuristicsTelemetry(decision, evaluateReason) {
let events;
await BrowserTestUtils.waitForCondition(() => {
events = Services.telemetry.snapshotEvents(
@ -171,7 +142,6 @@ async function checkHeuristicsTelemetry(
if (evaluateReason) {
is(events[0][5].evaluateReason, evaluateReason, "Got the expected reason.");
}
is(events[0][5].steeredProvider, steeredProvider, "Got expected provider.");
// After checking the event, clear all telemetry. Since we check for a single
// event above, this ensures all heuristics events are intentional and tested.
@ -208,17 +178,12 @@ async function waitForStateTelemetry() {
Services.telemetry.clearEvents();
}
// setPassing/FailingHeuristics are used generically to test that DoH is enabled
// or disabled correctly. We use the zscaler canary arbitrarily here, individual
// heuristics are tested separately.
function setPassingHeuristics() {
gDNSOverride.clearHostOverride("sitereview.zscaler.com");
gDNSOverride.addIPOverride("sitereview.zscaler.com", "3.1.1.1");
Preferences.set(prefs.MOCK_HEURISTICS_PREF, fakePassingHeuristics);
}
function setFailingHeuristics() {
gDNSOverride.clearHostOverride("sitereview.zscaler.com");
gDNSOverride.addIPOverride("sitereview.zscaler.com", "213.152.228.242");
Preferences.set(prefs.MOCK_HEURISTICS_PREF, fakeFailingHeuristics);
}
async function restartAddon() {