Bug 1305878 - Add sync client counts to UITour.
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
--- 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() {