summaryrefslogtreecommitdiffstats
path: root/services/sync/tests/unit/test_service_startup.js
diff options
context:
space:
mode:
Diffstat (limited to 'services/sync/tests/unit/test_service_startup.js')
-rw-r--r--services/sync/tests/unit/test_service_startup.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/services/sync/tests/unit/test_service_startup.js b/services/sync/tests/unit/test_service_startup.js
new file mode 100644
index 0000000000..389df0f0f6
--- /dev/null
+++ b/services/sync/tests/unit/test_service_startup.js
@@ -0,0 +1,44 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+Svc.Prefs.set("registerEngines", "Tab,Bookmarks,Form,History");
+
+add_task(async function run_test() {
+ validate_all_future_pings();
+ _("When imported, Service.onStartup is called");
+
+ let xps = Cc["@mozilla.org/weave/service;1"].getService(Ci.nsISupports)
+ .wrappedJSObject;
+ Assert.ok(!xps.enabled);
+
+ // Test fixtures
+ let { Service } = ChromeUtils.import("resource://services-sync/service.js");
+ Services.prefs.setStringPref("services.sync.username", "johndoe");
+ Assert.ok(xps.enabled);
+
+ _("Service is enabled.");
+ Assert.equal(Service.enabled, true);
+
+ _("Observers are notified of startup");
+ Assert.ok(!Service.status.ready);
+ Assert.ok(!xps.ready);
+
+ await promiseOneObserver("weave:service:ready");
+
+ Assert.ok(Service.status.ready);
+ Assert.ok(xps.ready);
+
+ _("Engines are registered.");
+ let engines = Service.engineManager.getAll();
+ Assert.ok(
+ Utils.deepEquals(
+ engines.map(engine => engine.name),
+ ["tabs", "bookmarks", "forms", "history"]
+ )
+ );
+
+ // Clean up.
+ Svc.Prefs.resetBranch("");
+
+ do_test_finished();
+});