Bug 981689 (Show a notice to beta users when we turn telemetry on by default on the beta channel) - For the new channel-override preference, use UpdateChannel.jsm rather than nsIXULRuntime so that it's easier to QA the feature by hacking install.js. As part of that, add a new argument to UpdateChannel.js for excluding partners. r=bsmbedberg.

This commit is contained in:
Asaf Romano 2014-04-28 17:04:51 +03:00
parent 62079d063c
commit 888a277a59
4 changed files with 54 additions and 11 deletions

View File

@ -30,6 +30,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-common/utils.js");
Cu.import("resource://gre/modules/UpdateChannel.jsm");
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
@ -503,7 +504,7 @@ this.DataReportingPolicy.prototype = Object.freeze({
*/
get minimumPolicyVersion() {
// First check if the current channel has an ove
let channel = Services.appinfo.defaultUpdateChannel;
let channel = UpdateChannel.get(false);
let channelPref = this._prefs.get("minimumPolicyVersion.channel-" + channel);
return channelPref !== undefined ?
channelPref : this._prefs.get("minimumPolicyVersion", 1);

View File

@ -0,0 +1,36 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/Preferences.jsm");
Components.utils.import("resource://gre/modules/UpdateChannel.jsm");
const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
const TEST_CHANNEL = "TestChannel";
const PREF_PARTNER_A = "app.partner.test_partner_a";
const TEST_PARTNER_A = "TestPartnerA";
const PREF_PARTNER_B = "app.partner.test_partner_b";
const TEST_PARTNER_B = "TestPartnerB";
function test_get() {
let defaultPrefs = new Preferences({ defaultBranch: true });
let currentChannel = defaultPrefs.get(PREF_APP_UPDATE_CHANNEL);
do_check_eq(UpdateChannel.get(), currentChannel);
do_check_eq(UpdateChannel.get(false), currentChannel);
defaultPrefs.set(PREF_APP_UPDATE_CHANNEL, TEST_CHANNEL);
do_check_eq(UpdateChannel.get(), TEST_CHANNEL);
do_check_eq(UpdateChannel.get(false), TEST_CHANNEL);
defaultPrefs.set(PREF_PARTNER_A, TEST_PARTNER_A);
defaultPrefs.set(PREF_PARTNER_B, TEST_PARTNER_B);
do_check_eq(UpdateChannel.get(),
TEST_CHANNEL + "-cck-" + TEST_PARTNER_A + "-" + TEST_PARTNER_B);
do_check_eq(UpdateChannel.get(false), TEST_CHANNEL);
}
function run_test() {
test_get();
}

View File

@ -3,3 +3,4 @@ head =
tail =
[test_contentAreaUtils.js]
[test_updateChannelModule.js]

View File

@ -15,8 +15,11 @@ this.UpdateChannel = {
* Read the update channel from defaults only. We do this to ensure that
* the channel is tightly coupled with the application and does not apply
* to other instances of the application that may use the same profile.
*
* @param [optional] aIncludePartners
* Whether or not to include the partner bits. Default: true.
*/
get: function UpdateChannel_get() {
get: function UpdateChannel_get(aIncludePartners = true) {
let channel = "@MOZ_UPDATE_CHANNEL@";
let defaults = Services.prefs.getDefaultBranch(null);
try {
@ -25,16 +28,18 @@ this.UpdateChannel = {
// use default value when pref not found
}
try {
let partners = Services.prefs.getChildList("app.partner.").sort();
if (partners.length) {
channel += "-cck";
partners.forEach(function (prefName) {
channel += "-" + Services.prefs.getCharPref(prefName);
});
if (aIncludePartners) {
try {
let partners = Services.prefs.getChildList("app.partner.").sort();
if (partners.length) {
channel += "-cck";
partners.forEach(function (prefName) {
channel += "-" + Services.prefs.getCharPref(prefName);
});
}
} catch (e) {
Cu.reportError(e);
}
} catch (e) {
Cu.reportError(e);
}
return channel;