/** *@import{NotificationDB}from"../../NotificationDB.sys.mjs" *@type{NotificationDB}
*/
let db;
/** @type {NotificationDB} */
let memoryDb;
add_setup(async function run_test() {
do_get_profile();
db = ChromeUtils.importESModule( "moz-src:///dom/notification/NotificationDB.sys.mjs"
).db;
let { MemoryNotificationDB } = ChromeUtils.importESModule( "moz-src:///dom/notification/MemoryNotificationDB.sys.mjs"
);
memoryDb = new MemoryNotificationDB();
});
// Get one notification, none exists
add_task(async function test_get_none() {
let notifications = await db.queueTask("getall", {
origin: systemNotification.origin,
});
Assert.equal(0, notifications.length);
});
add_task(async function test_send_and_get_one() { // Store one notification
await db.queueTask("save", {
origin: systemNotification.origin,
notification: systemNotification,
});
// Get one notification, one exists
let notifications = await db.queueTask("getall", {
origin: systemNotification.origin,
});
Assert.equal(1, notifications.length); // compare the content
compareNotification(systemNotification, notifications[0]);
});
add_task(async function test_delete_one_get_none_again() { // Delete one notification
await db.queueTask("delete", {
origin: systemNotification.origin,
id: systemNotification.id,
});
// Get one notification, none exists
let notifications = await db.queueTask("getall", {
origin: systemNotification.origin,
}); Assert.equal(0, notifications.length);
});
// Delete one notification that do not exists anymore
add_task(async function test_delete_one_nonexistent() {
await db.queueTask("delete", {
origin: systemNotification.origin,
id: systemNotification.id,
});
});
// Store two notifications with the same id
add_task(async function test_send_two_get_one() {
await db.queueTask("save", {
origin: systemNotification.origin,
notification: systemNotification,
});
// Store two notifications from same origin with the same tag
add_task(async function test_send_two_get_one() {
let tag = "voicemail";
let systemNotification1 = getNotificationObject( "system", "{f271f9ee-3955-4c10-b1f2-af552fb270ee}",
tag
);
let systemNotification2 = getNotificationObject( "system", "{8ef9a628-f0f4-44b4-820d-c117573c33e3}",
tag
);
// Trigger getall for each origin
let notifications = await db.queueTask("getall", {
origin: systemNotification1.origin,
});
// one notification per origin Assert.equal(1, notifications.length); // first call should be system notification
compareNotification(systemNotification1, notifications[0]);
// one notification per origin Assert.equal(1, notifications.length); // second and last call should be calendar notification
compareNotification(calendarNotification2, notifications[0]);
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.