summaryrefslogtreecommitdiffstats
path: root/dom/notification/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /dom/notification/test
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/notification/test')
-rw-r--r--dom/notification/test/unit/head_notificationdb.js3
-rw-r--r--dom/notification/test/unit/test_notificationdb.js86
2 files changed, 89 insertions, 0 deletions
diff --git a/dom/notification/test/unit/head_notificationdb.js b/dom/notification/test/unit/head_notificationdb.js
index 1b23d88729..44b0d7c01b 100644
--- a/dom/notification/test/unit/head_notificationdb.js
+++ b/dom/notification/test/unit/head_notificationdb.js
@@ -31,6 +31,9 @@ var calendarNotification = getNotificationObject(
// Helper to start the NotificationDB
function startNotificationDB() {
+ ChromeUtils.importESModule(
+ "resource://gre/modules/MemoryNotificationDB.sys.mjs"
+ );
ChromeUtils.importESModule("resource://gre/modules/NotificationDB.sys.mjs");
}
diff --git a/dom/notification/test/unit/test_notificationdb.js b/dom/notification/test/unit/test_notificationdb.js
index b6ca8bd79c..4fc1e6389d 100644
--- a/dom/notification/test/unit/test_notificationdb.js
+++ b/dom/notification/test/unit/test_notificationdb.js
@@ -338,3 +338,89 @@ add_test(function test_delete_previous() {
requestID,
});
});
+
+add_test(function test_notification_onDiskPersistence() {
+ let verifyDisk = async function (expectedId) {
+ const NOTIFICATION_STORE_PATH = PathUtils.join(
+ PathUtils.profileDir,
+ "notificationstore.json"
+ );
+
+ const onDiskNotificationStr = await IOUtils.readUTF8(
+ NOTIFICATION_STORE_PATH
+ );
+ return onDiskNotificationStr.includes(expectedId);
+ };
+
+ let persistedNotification = getNotificationObject(
+ systemNotification.origin,
+ "{315aaf98-6c72-48fe-8e2c-a841e1b00027}",
+ "" /* tag */,
+ true /* scope */
+ );
+
+ addAndSend(
+ "Notification:Save",
+ "Notification:Save:Return:OK",
+ async () => {
+ Assert.ok(await verifyDisk(persistedNotification.id));
+ },
+ {
+ origin: persistedNotification.origin,
+ notification: persistedNotification,
+ requestID: 2,
+ }
+ );
+
+ let nonPersistedNotification = getNotificationObject(
+ systemNotification.origin,
+ "{8110ed62-303f-4f9b-a257-a62487aaa09c}",
+ "" /* tag */,
+ true /* scope */
+ );
+
+ addAndSend(
+ "MemoryNotification:Save",
+ "MemoryNotification:Save:Return:OK",
+ async () => {
+ // memoryonly notification must not exist on disk.
+ Assert.ok(!(await verifyDisk(nonPersistedNotification.id)));
+ },
+ {
+ origin: nonPersistedNotification.origin,
+ notification: nonPersistedNotification,
+ requestID: 3,
+ }
+ );
+
+ let verifyMemory = function (message, expectedId) {
+ return message.data.notifications.some(notification => {
+ return notification.id == expectedId;
+ });
+ };
+
+ addAndSend(
+ "Notification:GetAll",
+ "Notification:GetAll:Return:OK",
+ message => {
+ Assert.ok(verifyMemory(message, persistedNotification.id));
+ },
+ {
+ origin: persistedNotification.origin,
+ requestID: 4,
+ }
+ );
+
+ addAndSend(
+ "MemoryNotification:GetAll",
+ "MemoryNotification:GetAll:Return:OK",
+ message => {
+ // memoryonly notification must exist in-memory
+ Assert.ok(verifyMemory(message, nonPersistedNotification.id));
+ },
+ {
+ origin: persistedNotification.origin,
+ requestID: 5,
+ }
+ );
+});