This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1613659 - Remove network listeners and reset TRR mode when enable…
…d pref is rolled back. r=dragana Differential Revision: https://phabricator.services.mozilla.com/D61845
- Loading branch information
Showing
3 changed files
with
151 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
browser/extensions/doh-rollout/test/browser/browser_rollback.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
"use strict"; | ||
|
||
add_task(setup); | ||
|
||
add_task(async function testRollback() { | ||
// Set up a passing environment and enable DoH. | ||
setPassingHeuristics(); | ||
let promise = waitForDoorhanger(); | ||
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."); | ||
|
||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, EXAMPLE_URL); | ||
let panel = await promise; | ||
is( | ||
Preferences.get(prefs.DOH_DOORHANGER_SHOWN_PREF), | ||
undefined, | ||
"Doorhanger shown pref undefined before user interaction." | ||
); | ||
|
||
// Click the doorhanger's "accept" button. | ||
let button = panel.querySelector(".popup-notification-primary-button"); | ||
promise = BrowserTestUtils.waitForEvent(panel, "popuphidden"); | ||
EventUtils.synthesizeMouseAtCenter(button, {}); | ||
await promise; | ||
|
||
await ensureTRRMode(2); | ||
await checkHeuristicsTelemetry("enable_doh", "startup"); | ||
|
||
await BrowserTestUtils.waitForCondition(() => { | ||
return Preferences.get(prefs.DOH_DOORHANGER_SHOWN_PREF); | ||
}); | ||
is( | ||
Preferences.get(prefs.DOH_DOORHANGER_SHOWN_PREF), | ||
true, | ||
"Doorhanger shown pref saved." | ||
); | ||
is( | ||
Preferences.get(prefs.DOH_DOORHANGER_USER_DECISION_PREF), | ||
"UIOk", | ||
"Doorhanger decision saved." | ||
); | ||
is( | ||
Preferences.get(prefs.DOH_SELF_ENABLED_PREF), | ||
true, | ||
"Breadcrumb not cleared." | ||
); | ||
|
||
BrowserTestUtils.removeTab(tab); | ||
|
||
// Change the environment to failing and simulate a network change. | ||
setFailingHeuristics(); | ||
simulateNetworkChange(); | ||
await ensureTRRMode(0); | ||
await checkHeuristicsTelemetry("disable_doh", "netchange"); | ||
|
||
// Trigger another network change. | ||
simulateNetworkChange(); | ||
await ensureNoTRRModeChange(0); | ||
await checkHeuristicsTelemetry("disable_doh", "netchange"); | ||
|
||
// Rollback! | ||
setPassingHeuristics(); | ||
Preferences.reset(prefs.DOH_ENABLED_PREF); | ||
await ensureTRRMode(0); | ||
simulateNetworkChange(); | ||
await ensureNoTRRModeChange(0); | ||
await ensureNoHeuristicsTelemetry(); | ||
|
||
// Re-enable. | ||
Preferences.set(prefs.DOH_ENABLED_PREF, true); | ||
|
||
await ensureTRRMode(2); | ||
await checkHeuristicsTelemetry("enable_doh", "startup"); | ||
|
||
// Change the environment to failing and simulate a network change. | ||
setFailingHeuristics(); | ||
simulateNetworkChange(); | ||
await ensureTRRMode(0); | ||
await checkHeuristicsTelemetry("disable_doh", "netchange"); | ||
|
||
// Rollback again for good measure! This time with failing heuristics. | ||
Preferences.reset(prefs.DOH_ENABLED_PREF); | ||
await ensureTRRMode(0); | ||
simulateNetworkChange(); | ||
await ensureNoTRRModeChange(0); | ||
await ensureNoHeuristicsTelemetry(); | ||
|
||
// Re-enable. | ||
Preferences.set(prefs.DOH_ENABLED_PREF, true); | ||
|
||
await ensureNoTRRModeChange(0); | ||
await checkHeuristicsTelemetry("disable_doh", "startup"); | ||
|
||
// Change the environment to passing and simulate a network change. | ||
setPassingHeuristics(); | ||
simulateNetworkChange(); | ||
await ensureTRRMode(2); | ||
await checkHeuristicsTelemetry("enable_doh", "netchange"); | ||
|
||
// Rollback again, this time with TRR mode set to 2 prior to doing so. | ||
Preferences.reset(prefs.DOH_ENABLED_PREF); | ||
await ensureTRRMode(0); | ||
simulateNetworkChange(); | ||
await ensureNoTRRModeChange(0); | ||
await ensureNoHeuristicsTelemetry(); | ||
}); |