Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 Cu.import("resource://services-common/observers.js");
5 Cu.import("resource://services-sync/engines.js");
6 Cu.import("resource://services-sync/util.js");
7 Cu.import("resource://testing-common/services/sync/utils.js");
9 Svc.Prefs.set("registerEngines", "Tab,Bookmarks,Form,History");
10 Cu.import("resource://services-sync/service.js");
12 function run_test() {
13 _("When imported, Service.onStartup is called");
14 initTestLogging("Trace");
16 let xps = Cc["@mozilla.org/weave/service;1"]
17 .getService(Ci.nsISupports)
18 .wrappedJSObject;
19 do_check_false(xps.enabled);
21 // Test fixtures
22 Service.identity.username = "johndoe";
23 do_check_false(xps.enabled);
25 Cu.import("resource://services-sync/service.js");
27 _("Service is enabled.");
28 do_check_eq(Service.enabled, true);
30 _("Engines are registered.");
31 let engines = Service.engineManager.getAll();
32 do_check_true(Utils.deepEquals([engine.name for each (engine in engines)],
33 ['tabs', 'bookmarks', 'forms', 'history']));
35 _("Observers are notified of startup");
36 do_test_pending();
38 do_check_false(Service.status.ready);
39 do_check_false(xps.ready);
40 Observers.add("weave:service:ready", function (subject, data) {
41 do_check_true(Service.status.ready);
42 do_check_true(xps.ready);
44 // Clean up.
45 Svc.Prefs.resetBranch("");
46 do_test_finished();
47 });
49 do_check_false(xps.enabled);
51 Service.identity.account = "johndoe";
52 Service.clusterURL = "http://localhost/";
53 do_check_true(xps.enabled);
54 }