gecko/services/sync/tests/unit/test_service_startup.js
Gregory Szorc ef8e5bb3be Bug 836120 - Reduce memory overhead of Sync when it's not configured; r=rnewman
If Sync is (likely) not configured, the only loaded JS is for the XPCOM
service itself.

The UI code is now smart enough to initialize the Sync service if it
isn't yet loaded. This addresses bug 825728.
2013-01-30 07:05:12 -08:00

49 lines
1.4 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");
new SyncTestingInfrastructure();
// Test fixtures
Service.identity.username = "johndoe";
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();
let xps = Cc["@mozilla.org/weave/service;1"]
.getService(Ci.nsISupports)
.wrappedJSObject;
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();
});
}