Merge fx-team to m-c
authorWes Kocher <wkocher@mozilla.com>
Mon, 28 Apr 2014 16:20:24 -0700
changeset 181041 d7c07694f3392e453619adee3aeede9473757f6b
parent 181037 b7062df8c7c30a78e8add83a276ca187b98aa7e8 (current diff)
parent 181040 bef43b38d6ae2baa0f18c9da53f27b9b9a6ed0b3 (diff)
child 181042 2c14ea7a713c2c96458b1cef262c4b41d3b794f6
child 181131 8d91d190192358639111546a244fc92033a76319
child 181141 b680dd41b954093b06528a435c2d92772ec2d3d9
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
milestone32.0a1
Merge fx-team to m-c
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -195,16 +195,20 @@ const PanelUI = {
           this.toggle(aEvent);
         break;
       case "keypress":
         this.toggle(aEvent);
         break;
     }
   },
 
+  isReady: function() {
+    return !!this._isReady;
+  },
+
   /**
    * Registering the menu panel is done lazily for performance reasons. This
    * method is exposed so that CustomizationMode can force panel-readyness in the
    * event that customization mode is started before the panel has been opened
    * by the user.
    *
    * @param aCustomizing (optional) set to true if this was called while entering
    *        customization mode. If that's the case, we trust that customization
@@ -258,16 +262,17 @@ const PanelUI = {
         try {
           CustomizableUI.registerMenuPanel(this.contents);
         } finally {
           this.endBatchUpdate();
         }
       }
       this._updateQuitTooltip();
       this.panel.hidden = false;
+      this._isReady = true;
     }.bind(this)).then(null, Cu.reportError);
 
     return this._readyPromise;
   },
 
   /**
    * Switch the panel to the main view if it's not already
    * in that view.
--- a/browser/components/customizableui/src/CustomizeMode.jsm
+++ b/browser/components/customizableui/src/CustomizeMode.jsm
@@ -183,20 +183,22 @@ CustomizeMode.prototype = {
       // menu button means a quick exit from customization mode.
       window.PanelUI.hide();
       window.PanelUI.menuButton.addEventListener("command", this);
       window.PanelUI.menuButton.open = true;
       window.PanelUI.beginBatchUpdate();
 
       // The menu panel is lazy, and registers itself when the popup shows. We
       // need to force the menu panel to register itself, or else customization
-      // is really not going to work. We pass "true" to ensureRegistered to
+      // is really not going to work. We pass "true" to ensureReady to
       // indicate that we're handling calling startBatchUpdate and
       // endBatchUpdate.
-      yield window.PanelUI.ensureReady(true);
+      if (!window.PanelUI.isReady()) {
+        yield window.PanelUI.ensureReady(true);
+      }
 
       // Hide the palette before starting the transition for increased perf.
       this.visiblePalette.hidden = true;
       this.visiblePalette.removeAttribute("showing");
 
       // Disable the button-text fade-out mask
       // during the transition for increased perf.
       let panelContents = window.PanelUI.contents;
--- a/browser/experiments/Experiments.jsm
+++ b/browser/experiments/Experiments.jsm
@@ -1118,17 +1118,19 @@ Experiments.Experiments.prototype = {
           reason = e;
         }
 
         if (!applicable && reason && reason[0] != "was-active") {
           // Report this from here to avoid over-reporting.
           let desc = TELEMETRY_LOG.ACTIVATION;
           let data = [TELEMETRY_LOG.ACTIVATION.REJECTED, id];
           data = data.concat(reason);
-          TelemetryLog.log(TELEMETRY_LOG.ACTIVATION_KEY, data);
+          const key = TELEMETRY_LOG.ACTIVATION_KEY;
+          TelemetryLog.log(key, data);
+          this._log.trace("evaluateExperiments() - added " + key + " to TelemetryLog: " + JSON.stringify(data));
         }
 
         if (!applicable) {
           continue;
         }
 
         this._log.debug("evaluateExperiments() - activating experiment " + id);
         try {
--- a/browser/experiments/test/xpcshell/test_telemetry.js
+++ b/browser/experiments/test/xpcshell/test_telemetry.js
@@ -170,16 +170,17 @@ add_task(function* test_telemetryBasics(
   defineNow(gPolicy, now);
 
   yield experiments.updateManifest();
   let list = yield experiments.getExperiments();
   Assert.equal(list.length, 0, "Experiment list should be empty.");
 
   expectedLogLength += 2;
   let log = TelemetryPing.getPayload().log;
+  do_print("Telemetry log: " + JSON.stringify(log));
   Assert.equal(log.length, expectedLogLength, "Telemetry log should have " + expectedLogLength + " entries.");
   checkEvent(log[log.length-2], TLOG.ACTIVATION_KEY,
              [TLOG.ACTIVATION.REJECTED, EXPERIMENT1_ID, "startTime"]);
   checkEvent(log[log.length-1], TLOG.ACTIVATION_KEY,
              [TLOG.ACTIVATION.REJECTED, EXPERIMENT2_ID, "startTime"]);
 
   // Trigger update, clock set for experiment 1 to start.
 
--- a/services/datareporting/policy.jsm
+++ b/services/datareporting/policy.jsm
@@ -25,16 +25,17 @@ this.EXPORTED_SYMBOLS = [
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 #endif
 
 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;
 
 // Used as a sanity lower bound for dates stored in prefs. This module was
 // implemented in 2012, so any earlier dates indicate an incorrect clock.
 const OLDEST_ALLOWED_YEAR = 2012;
 
 const CURRENT_POLICY_VERSION = 2;
@@ -498,17 +499,17 @@ this.DataReportingPolicy.prototype = Obj
   },
 
   /**
    * The minimum policy version which for dataSubmissionPolicyAccepted to
    * to be valid.
    */
   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);
   },
 
   /**
    * Whether the user has accepted that data submission can occur.
    *
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/unit/test_updateChannelModule.js
@@ -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();
+}
--- a/toolkit/content/tests/unit/xpcshell.ini
+++ b/toolkit/content/tests/unit/xpcshell.ini
@@ -1,5 +1,6 @@
 [DEFAULT]
 head = 
 tail = 
 
 [test_contentAreaUtils.js]
+[test_updateChannelModule.js]
--- a/toolkit/modules/UpdateChannel.jsm
+++ b/toolkit/modules/UpdateChannel.jsm
@@ -10,33 +10,38 @@ const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 
 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 {
       channel = defaults.getCharPref("app.update.channel");
     } catch (e) {
       // 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;
   }
 };