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 /dom/notification/test/unit/test_notificationdb_bug1024090.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/notification/test/unit/test_notificationdb_bug1024090.js')
-rw-r--r-- | dom/notification/test/unit/test_notificationdb_bug1024090.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/dom/notification/test/unit/test_notificationdb_bug1024090.js b/dom/notification/test/unit/test_notificationdb_bug1024090.js new file mode 100644 index 0000000000..37dee0a639 --- /dev/null +++ b/dom/notification/test/unit/test_notificationdb_bug1024090.js @@ -0,0 +1,59 @@ +"use strict"; + +function run_test() { + do_get_profile(); + run_next_test(); +} + +// For bug 1024090: test edge case of notificationstore.json +add_test(function test_bug1024090_purge() { + const NOTIFICATION_STORE_PATH = PathUtils.join( + PathUtils.profileDir, + "notificationstore" + ); + let cleanup = IOUtils.remove(NOTIFICATION_STORE_PATH, { recursive: true }); + cleanup + .then( + function onSuccess() { + ok(true, "Notification database cleaned."); + }, + function onError(reason) { + ok(false, "Notification database error when cleaning: " + reason); + } + ) + .then(function next() { + info("Cleanup steps completed: " + NOTIFICATION_STORE_PATH); + startNotificationDB(); + run_next_test(); + }); +}); + +// Store one notification +add_test(function test_bug1024090_send_one() { + let requestID = 1; + let msgReply = "Notification:Save:Return:OK"; + let msgHandler = function (message) { + equal(requestID, message.data.requestID, "Checking requestID"); + }; + + addAndSend("Notification:Save", msgReply, msgHandler, { + origin: systemNotification.origin, + notification: systemNotification, + requestID, + }); +}); + +// Get one notification, one exists +add_test(function test_bug1024090_get_one() { + let requestID = 2; + let msgReply = "Notification:GetAll:Return:OK"; + let msgHandler = function (message) { + equal(requestID, message.data.requestID, "Checking requestID"); + equal(1, message.data.notifications.length, "One notification stored"); + }; + + addAndSend("Notification:GetAll", msgReply, msgHandler, { + origin: systemNotification.origin, + requestID, + }); +}); |