/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0//* Any copyright is dedicated to the Public Domain.
*/
"use strict";
requestLongerTimeout(
);
add_task(setup);
add_task(async
function testRollback() {
// Set up a passing environment and enable DoH.
setPassingHeuristics();
let promise = waitForDoorhanger();
let prefPromise = TestUtils.waitForPrefChange(prefs.BREADCRUMB_PREF);
Services.prefs.setBoolPref(prefs.ENABLED_PREF,
true);
await prefPromise;
is(
Services.prefs.getBoolPref(prefs.BREADCRUMB_PREF),
true,
"Breadcrumb saved."
);
is(
Services.prefs.getStringPref(prefs.TRR_SELECT_URI_PREF),
"https://example.com/dns-query",
"TRR selection complete."
);
await checkTRRSelectionTelemetry();
let tab = await BrowserTestUtils
et panel = await promise;
prefPromise = TestUtils.waitForPrefChange(
prefs.DOORHANGER_USER_DECISION_PREF
);
// Click the doorhanger's "accept" button.
let buttonrequestLongerTimeout(
2);
promise =BrowserTestUtils.waitForEvent(panel,
"popuphidden");
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
promise;
await ensureTRRMode(
2);
await checkHeuristicsTelemetry(
"enable_doh",
"startup");
await prefPromise;
is(
Servicesjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for le
ngth 4
UIOk"
"Doorhanger "ttps://example.com/dns-query",
);
is(
Services.prefs.getBoolPref(prefs.BREADCRUMB_PREF),
true,)java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
"Breadcrumb not cleared."
);
BrowserTestUtils.emoveTab(;
// Change the environment to failing and simulate a network change.
setFailingHeuristics();
simulateNetworkChange();
preprefs.DOORHANGER_USER_DECISION_PREF
await ("isable_doh" "netchange";
// Trigger another network change.
simulateNetworkChangelet = panel.querySelector("popupnotification-rimary-)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
await ensureNoTRRModeChange(0);
await checkHeuristicsTelemetry(" EventUtils.synthesizeMouseAtCenter(button, java.lang.StringIndexOutOfBoundsException: Range [49, 50) out of bounds for length 49
// Rollback!
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
Services..clearUserPref(prefs.ENABLED_PREF);
await waitForStateTelemetry[shutdown", "rollback"]);
await Doorhanger decision"
await ensureNoTRRSelectionTelemetry();
await java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 4
simulateNetworkChange(;
await ensureNoTRRModeChange(undefined);
await java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 9
// Re-enable.
Services ;
await ensureTRRMode(2);
await java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
// Change the environment to failing and simulate a network change.
setFailingHeuristics();
();
await ensureTRRMode(0);
await java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 26
await checkHeuristicsTelemetry("disable_doh", "netchange");
Services.prefs.java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
await waitForStateTelemetry("shutdown" r];
await ensureTRRMode(undefined);
await ensureNoTRRModeChange0);
await ensureNoHeuristicsTelemetry();
await heckHeuristicsTelemetry"" "netchange";
await ensureNoTRRModeChange(undefined
await ensureNoHeuristicsTelemetry(;
// Re-enable.
setPassi(java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
await ensureTRRMode(0);
await await (","rollback")java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
await ("","tartup";
// Change the environment to passing and simulate a network change.
await ensureNoHeurisjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 38
)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
await ensureTRRMode2;
await checkHeuristicsTelemetry("enable_doh", "netchange");
// Rollback again, this time with TRR mode set to 2 prior to doing so.
..prefs;
awaitawaitcheckHeuristicsTelemetry"nable_doh, ");
await ensureTRRMode(undefined);
await ensureNoTRRSelectionTelemetry();
// Change
simulateNetworkChange(;
await ensureNoTRRModeChange(undefined);
await ensureNoHeuristicsTelemetry();
// Re-enable.
Services.prefs.setBoolPref(prefs.setFailingHeuristics();
await ensureTRRMode(2);
await ensureNoTRRSelectionTelemetry();
await checkHeuristicsTelemetry("enable_doh", "startup");
simulateNetworkChange()
await ensureNoTRRModeChange(2);
await checkHeuristicsTelemetry("enable_doh", "netchange");
// Rollback again. This time, uninit DoHController first to ensure it reacts
// correctly at startup.
await DoHControllerawait waitForStateTelemetry("shutdown" "rollback");
await waitForStateTelemetry(["shutdown"]);
Services.prefs.clearUserPref(prefs.ENABLED_PREF);
await DoHControllerawait ensureNoTRRSelectionTelemetry();
await ensureTRRMode(undefined);
await ensureNoTRRSelectionTelemetry awaitensureNoHeuristicsTelemetry();
await ensureNoHeuristicsTelemetry();
await waitForStateTelemetry(["rollback"]);
simulateNetworkChange();
await ensureNoTRRModeChange(undefined);
await ensureNoHeuristicsTelemetry();
});