Bug 1693527 - When migrating old TRR mode, don't clear network.trr.mode if its value is 5. r=valentin

Differential Revision: https://phabricator.services.mozilla.com/D105625
This commit is contained in:
Nihanth Subramanya 2021-02-18 14:34:03 +00:00
parent 613f319b79
commit 5fbb6b0564
2 changed files with 26 additions and 1 deletions

View File

@ -234,7 +234,9 @@ const DoHController = {
return;
}
Preferences.reset(NETWORK_TRR_MODE_PREF);
if (Preferences.get(NETWORK_TRR_MODE_PREF) !== 5) {
Preferences.reset(NETWORK_TRR_MODE_PREF);
}
Preferences.reset(PREVIOUS_TRR_MODE_PREF);
},

View File

@ -30,4 +30,27 @@ add_task(async function testTRRModeMigration() {
false,
"TRR mode cleared."
);
await DoHController._uninit();
Preferences.set(prefs.NETWORK_TRR_MODE_PREF, 5);
Preferences.set(prefs.PREVIOUS_TRR_MODE_PREF, 0);
previousModePromise = TestUtils.waitForPrefChange(
prefs.PREVIOUS_TRR_MODE_PREF
);
await DoHController.init();
try {
await TestUtils.waitForCondition(
() => !Preferences.isSet(prefs.NETWORK_TRR_MODE_PREF)
);
ok(false, "TRR mode should not have been cleared after migration");
} catch (e) {
ok(true, "TRR mode wasn't cleared after migration");
}
await previousModePromise;
is(
Preferences.get(prefs.PREVIOUS_TRR_MODE_PREF),
undefined,
"Previous TRR mode pref cleared."
);
is(Preferences.get(prefs.NETWORK_TRR_MODE_PREF), 5, "TRR mode remained 5.");
});