зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1239480
- Make test_TelemetryReportingPolicy.js set the minimum policy version pref for the right channel. r=gfritzsche
This commit is contained in:
Родитель
b9482ce919
Коммит
6d722c27d8
|
@ -14,6 +14,7 @@ Cu.import("resource://gre/modules/TelemetryReportingPolicy.jsm", this);
|
|||
Cu.import("resource://gre/modules/TelemetryUtils.jsm", this);
|
||||
Cu.import("resource://gre/modules/Timer.jsm", this);
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
|
||||
Cu.import("resource://gre/modules/UpdateUtils.jsm", this);
|
||||
|
||||
const PREF_BRANCH = "toolkit.telemetry.";
|
||||
const PREF_SERVER = PREF_BRANCH + "server";
|
||||
|
@ -40,6 +41,21 @@ function fakeResetAcceptedPolicy() {
|
|||
Preferences.reset(PREF_ACCEPTED_POLICY_VERSION);
|
||||
}
|
||||
|
||||
function setMinimumPolicyVersion(aNewPolicyVersion) {
|
||||
const CHANNEL_NAME = UpdateUtils.getUpdateChannel(false);
|
||||
// We might have channel-dependent minimum policy versions.
|
||||
const CHANNEL_DEPENDENT_PREF = PREF_MINIMUM_POLICY_VERSION + ".channel-" + CHANNEL_NAME;
|
||||
|
||||
// Does the channel-dependent pref exist? If so, set its value.
|
||||
if (Preferences.get(CHANNEL_DEPENDENT_PREF, undefined)) {
|
||||
Preferences.set(CHANNEL_DEPENDENT_PREF, aNewPolicyVersion);
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't have a channel specific minimu, so set the common one.
|
||||
Preferences.set(PREF_MINIMUM_POLICY_VERSION, aNewPolicyVersion);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
// Addon manager needs a profile directory
|
||||
do_get_profile(true);
|
||||
|
@ -109,7 +125,7 @@ add_task(function* test_prefs() {
|
|||
|
||||
// Set a new minimum policy version and check that user is no longer notified.
|
||||
let newMinimum = Preferences.get(PREF_CURRENT_POLICY_VERSION, 1) + 1;
|
||||
Preferences.set(PREF_MINIMUM_POLICY_VERSION, newMinimum);
|
||||
setMinimumPolicyVersion(newMinimum);
|
||||
Assert.ok(!TelemetryReportingPolicy.testIsUserNotified(),
|
||||
"A greater minimum policy version must invalidate the policy and disable upload.");
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче