summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/xpcshell/test_ext_notifications_unsupported.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /toolkit/components/extensions/test/xpcshell/test_ext_notifications_unsupported.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/extensions/test/xpcshell/test_ext_notifications_unsupported.js')
-rw-r--r--toolkit/components/extensions/test/xpcshell/test_ext_notifications_unsupported.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_notifications_unsupported.js b/toolkit/components/extensions/test/xpcshell/test_ext_notifications_unsupported.js
new file mode 100644
index 0000000000..1213ae4f23
--- /dev/null
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_notifications_unsupported.js
@@ -0,0 +1,41 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
+const registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(
+ Components.ID("{18f25bb4-ab12-4e24-b3b0-69215056160b}"),
+ "unsupported alerts service",
+ ALERTS_SERVICE_CONTRACT_ID,
+ {} // This object lacks an implementation of nsIAlertsService.
+);
+
+add_task(async function test_notification_unsupported_backend() {
+ let extension = ExtensionTestUtils.loadExtension({
+ manifest: {
+ permissions: ["notifications"],
+ },
+ async background() {
+ let closedPromise = new Promise(resolve => {
+ browser.notifications.onClosed.addListener(resolve);
+ });
+ let createdId = await browser.notifications.create("notifid", {
+ type: "basic",
+ title: "titl",
+ message: "msg",
+ });
+ let closedId = await closedPromise;
+ browser.test.assertEq(createdId, closedId, "ID of closed notification");
+ browser.test.assertEq(
+ "{}",
+ JSON.stringify(await browser.notifications.getAll()),
+ "no notifications left"
+ );
+ browser.test.sendMessage("notification_closed");
+ },
+ });
+ await extension.startup();
+ await extension.awaitMessage("notification_closed");
+ await extension.unload();
+});