gecko-dev/services/sync/tests/unit/test_service_startup.js
Gregory Szorc 4e49d56880 Bug 958561 - Measure Sync with Firefox Health Report; r=rnewman
Metrics for Sync have been added to Firefox Health Report. If Sync is
not configured, we'll report that fact and the supported and preferred
Sync protocols (1.1 or 1.5).

If Sync is configured, we report the daily counts of sync attempts and
how many are successful vs errored. We also report daily counts of the
device types attached to the account.

--HG--
extra : rebase_source : 77170b323706a85cbe1542ac993ebdc1dba3b505
extra : amend_source : 7802e80b4fc94937fbe3f67505b447bfb048732d
2014-02-05 08:08:14 -08:00

55 lines
1.6 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-common/observers.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js");
Svc.Prefs.set("registerEngines", "Tab,Bookmarks,Form,History");
Cu.import("resource://services-sync/service.js");
function run_test() {
_("When imported, Service.onStartup is called");
initTestLogging("Trace");
let xps = Cc["@mozilla.org/weave/service;1"]
.getService(Ci.nsISupports)
.wrappedJSObject;
do_check_false(xps.enabled);
// Test fixtures
Service.identity.username = "johndoe";
do_check_false(xps.enabled);
Cu.import("resource://services-sync/service.js");
_("Service is enabled.");
do_check_eq(Service.enabled, true);
_("Engines are registered.");
let engines = Service.engineManager.getAll();
do_check_true(Utils.deepEquals([engine.name for each (engine in engines)],
['tabs', 'bookmarks', 'forms', 'history']));
_("Observers are notified of startup");
do_test_pending();
do_check_false(Service.status.ready);
do_check_false(xps.ready);
Observers.add("weave:service:ready", function (subject, data) {
do_check_true(Service.status.ready);
do_check_true(xps.ready);
// Clean up.
Svc.Prefs.resetBranch("");
do_test_finished();
});
do_check_false(xps.enabled);
Service.identity.account = "johndoe";
Service.clusterURL = "http://localhost/";
do_check_true(xps.enabled);
}