Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
Bug 1254958 - browser_mozLoop_telemetry.js fails due to not resetting…
Browse files Browse the repository at this point in the history
… prefs. r=mancas
  • Loading branch information
Standard8 committed Mar 9, 2016
1 parent df564ab commit bcca86d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions add-on/chrome/test/mochitest/browser_mozLoop_telemetry.js
Expand Up @@ -11,13 +11,27 @@ var [, gHandlers] = LoopAPI.inspect();
var gConstants;
gHandlers.GetAllConstants({}, constants => gConstants = constants);

function resetMauPrefs() {
Services.prefs.clearUserPref("loop.mau.openPanel");
Services.prefs.clearUserPref("loop.mau.openConversation");
Services.prefs.clearUserPref("loop.mau.roomOpen");
Services.prefs.clearUserPref("loop.mau.roomShare");
Services.prefs.clearUserPref("loop.mau.roomDelete");
}

/**
* Enable local telemetry recording for the duration of the tests.
*/
add_task(function* test_initialize() {
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;

// Ensure prefs are their default values.
resetMauPrefs();

registerCleanupFunction(function() {
// Clean up the prefs after use to be nice.
resetMauPrefs();
Services.telemetry.canRecordExtended = oldCanRecord;
});
});
Expand Down Expand Up @@ -179,6 +193,9 @@ add_task(function* test_mozLoop_telemetryAdd_loopMauType_buckets() {
"LOOP_MAU_TYPE.ROOM_SHARE");
Assert.strictEqual(snapshot.counts[ACTION_TYPES.ROOM_DELETE], 1,
"LOOP_MAU_TYPE.ROOM_DELETE");

// Reset the prefs here, so we don't affect other tests in this file.
resetMauPrefs();
});

/**
Expand All @@ -205,7 +222,8 @@ add_task(function* test_mozLoop_telemetryAdd_loopMau_more_than_30_days() {
Assert.strictEqual(snapshot.counts[ACTION_TYPES.OPEN_PANEL], 2,
"LOOP_MAU_TYPE.OPEN_PANEL");

Services.prefs.clearUserPref("loop.mau.openPanel");
// Reset the prefs here, so we don't affect other tests in this file.
resetMauPrefs();
});

add_task(function* test_mozLoop_telemetryAdd_loopMau_less_than_30_days() {
Expand All @@ -228,5 +246,6 @@ add_task(function* test_mozLoop_telemetryAdd_loopMau_less_than_30_days() {
Assert.strictEqual(snapshot.counts[ACTION_TYPES.OPEN_PANEL], 1,
"LOOP_MAU_TYPE.OPEN_PANEL");

Services.prefs.clearUserPref("loop.mau.openPanel");
// Reset the prefs here, so we don't affect other tests in this file.
resetMauPrefs();
});

0 comments on commit bcca86d

Please sign in to comment.