gecko/dom/notification/test/unit/common_test_notificationdb.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

61 lines
1.7 KiB
JavaScript

"use strict";
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
function getNotificationObject(app, id, tag) {
return {
origin: "app://" + app + ".gaiamobile.org/manifest.webapp",
id: id,
title: app + "Notification:" + Date.now(),
dir: "auto",
lang: "",
body: app + " notification body",
tag: tag || "",
icon: "icon.png"
};
}
let systemNotification =
getNotificationObject("system", "{2bc883bf-2809-4432-b0f4-f54e10372764}");
let calendarNotification =
getNotificationObject("calendar", "{d8d11299-a58e-429b-9a9a-57c562982fbf}");
// Helper to start the NotificationDB
function startNotificationDB() {
Cu.import("resource://gre/modules/NotificationDB.jsm");
}
// Helper function to add a listener, send message and treat the reply
function addAndSend(msg, reply, callback, payload, runNext = true) {
let handler = {
receiveMessage: function(message) {
if (message.name === reply) {
cpmm.removeMessageListener(reply, handler);
callback(message);
if (runNext) {
run_next_test();
}
}
}
};
cpmm.addMessageListener(reply, handler);
cpmm.sendAsyncMessage(msg, payload);
}
// helper fonction, comparing two notifications
function compareNotification(notif1, notif2) {
// retrieved notification should be the second one sent
for (let prop in notif1) {
// compare each property
do_check_eq(notif1[prop], notif2[prop]);
}
}