2010-06-16 14:30:08 -07:00
|
|
|
Cu.import("resource://services-sync/ext/Observers.js");
|
|
|
|
Cu.import("resource://services-sync/ext/Sync.js");
|
|
|
|
Cu.import("resource://services-sync/identity.js");
|
|
|
|
Cu.import("resource://services-sync/util.js");
|
2010-06-04 09:05:55 -07:00
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
_("When imported, Weave.Service.onStartup is called");
|
|
|
|
|
|
|
|
// Test fixtures
|
|
|
|
let observerCalled = false;
|
|
|
|
Observers.add("weave:service:ready", function (subject, data) {
|
|
|
|
observerCalled = true;
|
|
|
|
});
|
2010-06-09 17:22:03 -07:00
|
|
|
Svc.Prefs.set("registerEngines", "Tab,Bookmarks,Form,History");
|
2010-06-04 09:05:55 -07:00
|
|
|
Svc.Prefs.set("username", "johndoe");
|
|
|
|
|
|
|
|
try {
|
2010-06-16 14:30:08 -07:00
|
|
|
Cu.import("resource://services-sync/service.js");
|
2010-06-04 09:05:55 -07:00
|
|
|
|
|
|
|
_("Service is enabled.");
|
|
|
|
do_check_eq(Weave.Service.enabled, true);
|
|
|
|
|
|
|
|
_("Engines are registered.");
|
|
|
|
let engines = Weave.Engines.getAll();
|
2010-06-09 17:22:03 -07:00
|
|
|
do_check_true(Utils.deepEquals([engine.name for each (engine in engines)],
|
|
|
|
['tabs', 'bookmarks', 'forms', 'history']));
|
2010-06-04 09:05:55 -07:00
|
|
|
|
|
|
|
_("Identities are registered.");
|
|
|
|
do_check_eq(ID.get('WeaveID').username, "johndoe");
|
|
|
|
do_check_eq(ID.get('WeaveCryptoID').username, "johndoe");
|
|
|
|
|
|
|
|
_("Observers are notified of startup");
|
2010-06-10 17:04:49 -07:00
|
|
|
// Synchronize with Weave.Service.onStartup's async notification
|
|
|
|
Sync.sleep(0);
|
2010-06-04 09:05:55 -07:00
|
|
|
do_check_true(observerCalled);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
Svc.Prefs.resetBranch("");
|
|
|
|
}
|
|
|
|
}
|