Bug 1310146 - Add sync client counts to UITour, r=gijs,data-r=bsmedberg, a=ritu
authorMichael Kelly <mkelly@mozilla.com>
Fri, 07 Oct 2016 16:39:39 -0700
changeset 350740 c5487cf50dbc2052912a75ffc33c5b44d36ed6df
parent 350739 32fccc1a23928d8908a164ad8446ef0c487bf48d
child 350741 f6ee39199d93be1dd8fc4083d499d5046fcc9b4c
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgijs, ritu
bugs1310146
milestone50.0
Bug 1310146 - Add sync client counts to UITour, r=gijs,data-r=bsmedberg, a=ritu Amends UITour's getConfiguration function to include "desktopDevices", "mobileDevices", and "totalDevices" counts (pulled from the Sync preferences services.sync.clients.devices.desktop, services.sync.clients.devices.mobile, and services.sync.numClients respectively) if they are available. MozReview-Commit-ID: D22lKr4DcaT
browser/components/uitour/UITour.jsm
browser/components/uitour/test/browser_UITour_sync.js
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -6,16 +6,17 @@
 
 this.EXPORTED_SYMBOLS = ["UITour"];
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/AppConstants.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 Cu.import("resource:///modules/RecentWindow.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/TelemetryController.jsm");
 Cu.import("resource://gre/modules/Timer.jsm");
 
 Cu.importGlobalProperties(["URL"]);
 
@@ -1860,16 +1861,19 @@ this.UITour = {
             data = {engines: [], searchEngineIdentifier: ""};
           }
           this.sendPageCallback(aMessageManager, aCallbackID, data);
         });
         break;
       case "sync":
         this.sendPageCallback(aMessageManager, aCallbackID, {
           setup: Services.prefs.prefHasUserValue("services.sync.username"),
+          desktopDevices: Preferences.get("services.sync.clients.devices.desktop", 0),
+          mobileDevices: Preferences.get("services.sync.clients.devices.mobile", 0),
+          totalDevices: Preferences.get("services.sync.numClients", 0),
         });
         break;
       case "canReset":
         this.sendPageCallback(aMessageManager, aCallbackID, ResetProfile.resetSupported());
         break;
       default:
         log.error("getConfiguration: Unknown configuration requested: " + aConfiguration);
         break;
--- a/browser/components/uitour/test/browser_UITour_sync.js
+++ b/browser/components/uitour/test/browser_UITour_sync.js
@@ -16,16 +16,44 @@ add_UITour_task(function* test_checkSync
 });
 
 add_UITour_task(function* test_checkSyncSetup_enabled() {
   Services.prefs.setCharPref("services.sync.username", "uitour@tests.mozilla.org");
   let result = yield getConfigurationPromise("sync");
   is(result.setup, true, "Sync should be setup");
 });
 
+add_UITour_task(function* test_checkSyncCounts() {
+  Services.prefs.setIntPref("services.sync.clients.devices.desktop", 4);
+  Services.prefs.setIntPref("services.sync.clients.devices.mobile", 5);
+  Services.prefs.setIntPref("services.sync.numClients", 9);
+  let result = yield getConfigurationPromise("sync");
+  is(result.mobileDevices, 5, "mobileDevices should be set");
+  is(result.desktopDevices, 4, "desktopDevices should be set");
+  is(result.totalDevices, 9, "totalDevices should be set");
+
+  Services.prefs.clearUserPref("services.sync.clients.devices.desktop");
+  result = yield getConfigurationPromise("sync");
+  is(result.mobileDevices, 5, "mobileDevices should be set");
+  is(result.desktopDevices, 0, "desktopDevices should be 0");
+  is(result.totalDevices, 9, "totalDevices should be set");
+
+  Services.prefs.clearUserPref("services.sync.clients.devices.mobile");
+  result = yield getConfigurationPromise("sync");
+  is(result.mobileDevices, 0, "mobileDevices should be 0");
+  is(result.desktopDevices, 0, "desktopDevices should be 0");
+  is(result.totalDevices, 9, "totalDevices should be set");
+
+  Services.prefs.clearUserPref("services.sync.numClients");
+  result = yield getConfigurationPromise("sync");
+  is(result.mobileDevices, 0, "mobileDevices should be 0");
+  is(result.desktopDevices, 0, "desktopDevices should be 0");
+  is(result.totalDevices, 0, "totalDevices should be 0");
+});
+
 // The showFirefoxAccounts API is sync related, so we test that here too...
 add_UITour_task(function* test_firefoxAccountsNoParams() {
   yield gContentAPI.showFirefoxAccounts();
   yield BrowserTestUtils.browserLoaded(gTestTab.linkedBrowser, false,
                                        "about:accounts?action=signup&entrypoint=uitour");
 });
 
 add_UITour_task(function* test_firefoxAccountsValidParams() {