Bug 1605297 - Wait for balrog migration at test start to prevent intermittent failures in DoH tests. r=JuniorHsu

There was a race between the add-on adding its pref listener and us flipping the enabled pref. By waiting for
the balrog migration, we give the add-on time to start listening for the pref before setting it.

Differential Revision: https://phabricator.services.mozilla.com/D58422

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nihanth Subramanya 2020-01-01 23:34:25 +00:00
parent 95af7e4a88
commit 15616d95ec
6 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,8 @@
"use strict";
add_task(async function testCleanFlow() {
await waitForBalrogMigration();
// Set up a passing environment and enable DoH.
setPassingHeuristics();
let promise = waitForDoorhanger();

View File

@ -1,6 +1,8 @@
"use strict";
add_task(async function testDirtyEnable() {
await waitForBalrogMigration();
// Set up a failing environment, pre-set DoH to enabled, and verify that
// when the add-on is enabled, it doesn't do anything - DoH remains turned on.
setFailingHeuristics();

View File

@ -1,6 +1,8 @@
"use strict";
add_task(async function testDoorhangerUserReject() {
await waitForBalrogMigration();
// Set up a passing environment and enable DoH.
setPassingHeuristics();
let promise = waitForDoorhanger();

View File

@ -6,6 +6,8 @@ const { EnterprisePolicyTesting } = ChromeUtils.import(
);
add_task(async function testPolicyOverride() {
await waitForBalrogMigration();
// Set up an arbitrary enterprise policy. Its existence should be sufficient
// to disable heuristics.
await EnterprisePolicyTesting.setupPolicyEngineWithJson({

View File

@ -1,6 +1,8 @@
"use strict";
add_task(async function testUserInterference() {
await waitForBalrogMigration();
// Set up a passing environment and enable DoH.
setPassingHeuristics();
let promise = waitForDoorhanger();

View File

@ -63,6 +63,17 @@ function setFailingHeuristics() {
Preferences.set(prefs.MOCK_HEURISTICS_PREF, fakeFailingHeuristics);
}
async function waitForBalrogMigration() {
await BrowserTestUtils.waitForCondition(() => {
return Preferences.get(prefs.DOH_BALROG_MIGRATION_PREF, false);
});
is(
Preferences.get(prefs.DOH_BALROG_MIGRATION_PREF, false),
true,
"Balrog migration is complete and pref is set."
);
}
async function restartAddon() {
let addon = await AddonManager.getAddonByID(ADDON_ID);
await addon.reload();