diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /services/sync/tests/unit/test_service_startup.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'services/sync/tests/unit/test_service_startup.js')
-rw-r--r-- | services/sync/tests/unit/test_service_startup.js | 58 |
1 files changed, 58 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..beb4d1d18a --- /dev/null +++ b/services/sync/tests/unit/test_service_startup.js @@ -0,0 +1,58 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const { AppConstants } = ChromeUtils.importESModule( + "resource://gre/modules/AppConstants.sys.mjs" +); + +// Svc.Prefs.set("services.sync.log.appender.dump", "All"); +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.importESModule( + "resource://services-sync/service.sys.mjs" + ); + 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(); + if (AppConstants.MOZ_APP_NAME == "thunderbird") { + // Thunderbird's engines are registered later, so they're not here yet. + Assert.deepEqual( + engines.map(engine => engine.name), + [] + ); + } else { + Assert.deepEqual( + engines.map(engine => engine.name), + ["tabs", "bookmarks", "forms", "history"] + ); + } + + // Clean up. + Svc.Prefs.resetBranch(""); + + do_test_finished(); +}); |