gecko/dom/notification/test/unit/test_notificationdb_bug1024090.js
Birunthan Mohanathas 71ebe5a4e2 Bug 1058101 - Move dom/src/notification/ into dom/. r=mccr8
--HG--
rename : dom/src/notification/ChromeNotifications.js => dom/notification/ChromeNotifications.js
rename : dom/src/notification/ChromeNotifications.manifest => dom/notification/ChromeNotifications.manifest
rename : dom/src/notification/DesktopNotification.cpp => dom/notification/DesktopNotification.cpp
rename : dom/src/notification/DesktopNotification.h => dom/notification/DesktopNotification.h
rename : dom/src/notification/Notification.cpp => dom/notification/Notification.cpp
rename : dom/src/notification/Notification.h => dom/notification/Notification.h
rename : dom/src/notification/NotificationDB.jsm => dom/notification/NotificationDB.jsm
rename : dom/src/notification/NotificationStorage.js => dom/notification/NotificationStorage.js
rename : dom/src/notification/NotificationStorage.manifest => dom/notification/NotificationStorage.manifest
rename : dom/src/notification/moz.build => dom/notification/moz.build
rename : dom/src/notification/test/unit/common_test_notificationdb.js => dom/notification/test/unit/common_test_notificationdb.js
rename : dom/src/notification/test/unit/test_notificationdb.js => dom/notification/test/unit/test_notificationdb.js
rename : dom/src/notification/test/unit/test_notificationdb_bug1024090.js => dom/notification/test/unit/test_notificationdb_bug1024090.js
rename : dom/src/notification/test/unit/xpcshell.ini => dom/notification/test/unit/xpcshell.ini
2014-08-30 21:43:46 -07:00

57 lines
1.6 KiB
JavaScript

"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() {
Cu.import("resource://gre/modules/osfile.jsm");
const NOTIFICATION_STORE_PATH =
OS.Path.join(OS.Constants.Path.profileDir, "notificationstore.json");
let cleanup = OS.File.writeAtomic(NOTIFICATION_STORE_PATH, "");
cleanup.then(
function onSuccess() {
ok(true, "Notification database cleaned.");
},
function onError(reason) {
ok(false, "Notification database error when cleaning: " + reason);
}
).then(function next() {
do_print("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: 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: requestID
});
});