Bug 1600109 - Implement setup function in head.js to set up prefs and telemetry, and call it in all tests. r=dragana,JuniorHsu

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nihanth Subramanya 2020-01-22 22:16:48 +00:00
Родитель dc9c52a9d5
Коммит cb4ffdf160
6 изменённых файлов: 24 добавлений и 4 удалений

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

@ -1,5 +1,7 @@
"use strict"; "use strict";
add_task(setup);
add_task(async function testCleanFlow() { add_task(async function testCleanFlow() {
// Set up a passing environment and enable DoH. // Set up a passing environment and enable DoH.
setPassingHeuristics(); setPassingHeuristics();

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

@ -1,5 +1,7 @@
"use strict"; "use strict";
add_task(setup);
add_task(async function testDirtyEnable() { add_task(async function testDirtyEnable() {
// Set up a failing environment, pre-set DoH to enabled, and verify that // 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. // when the add-on is enabled, it doesn't do anything - DoH remains turned on.

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

@ -1,5 +1,7 @@
"use strict"; "use strict";
add_task(setup);
add_task(async function testDoorhangerUserReject() { add_task(async function testDoorhangerUserReject() {
// Set up a passing environment and enable DoH. // Set up a passing environment and enable DoH.
setPassingHeuristics(); setPassingHeuristics();

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

@ -1,5 +1,7 @@
"use strict"; "use strict";
add_task(setup);
const { EnterprisePolicyTesting } = ChromeUtils.import( const { EnterprisePolicyTesting } = ChromeUtils.import(
"resource://testing-common/EnterprisePolicyTesting.jsm", "resource://testing-common/EnterprisePolicyTesting.jsm",
null null

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

@ -1,5 +1,7 @@
"use strict"; "use strict";
add_task(setup);
add_task(async function testUserInterference() { add_task(async function testUserInterference() {
// Set up a passing environment and enable DoH. // Set up a passing environment and enable DoH.
setPassingHeuristics(); setPassingHeuristics();

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

@ -12,10 +12,6 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/Preferences.jsm" "resource://gre/modules/Preferences.jsm"
); );
SpecialPowers.pushPrefEnv({
set: [["security.notification_enable_delay", 0]],
});
const ADDON_ID = "doh-rollout@mozilla.org"; const ADDON_ID = "doh-rollout@mozilla.org";
const prefs = { const prefs = {
@ -55,6 +51,20 @@ const fakeFailingHeuristics = JSON.stringify({
policy: "disable_doh", policy: "disable_doh",
}); });
async function setup() {
SpecialPowers.pushPrefEnv({
set: [["security.notification_enable_delay", 0]],
});
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
Services.telemetry.clearEvents();
registerCleanupFunction(() => {
Services.telemetry.canRecordExtended = oldCanRecord;
Services.telemetry.clearEvents();
});
}
function setPassingHeuristics() { function setPassingHeuristics() {
Preferences.set(prefs.MOCK_HEURISTICS_PREF, fakePassingHeuristics); Preferences.set(prefs.MOCK_HEURISTICS_PREF, fakePassingHeuristics);
} }