diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/notification/test/unit/common_test_notificationdb.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/notification/test/unit/common_test_notificationdb.js')
-rw-r--r-- | dom/notification/test/unit/common_test_notificationdb.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/notification/test/unit/common_test_notificationdb.js b/dom/notification/test/unit/common_test_notificationdb.js new file mode 100644 index 000000000..116c7836a --- /dev/null +++ b/dom/notification/test/unit/common_test_notificationdb.js @@ -0,0 +1,60 @@ +"use strict"; + +var 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: "https://" + app + ".gaiamobile.org/", + id: id, + title: app + "Notification:" + Date.now(), + dir: "auto", + lang: "", + body: app + " notification body", + tag: tag || "", + icon: "icon.png" + }; +} + +var systemNotification = + getNotificationObject("system", "{2bc883bf-2809-4432-b0f4-f54e10372764}"); + +var 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]); + } +} |