Bug 1100876 - Add showOnlyOnce to MozBehavior dict. r=mhenretty, r=smaug

There are some notifications that we know we don't want to resend. For
instance, Voicemail notifications are some, since everytime the network
will be ready it will notify us of the status, so we don't have to
resend it on reboot. We add a 'showOnlyOnce' key in the MozBehavior dict
for this usecase.
This commit is contained in:
Alexandre Lissy 2014-11-25 08:26:00 -05:00
parent 7f8189c9d4
commit 1903e36586
3 changed files with 35 additions and 0 deletions

View File

@ -54,6 +54,11 @@ ChromeNotifications.prototype = {
} catch(e) {
behavior = undefined;
}
if (behavior && behavior.showOnlyOnce === true) {
return;
}
appNotifier.showAppNotification(
notification.icon,
notification.title,

View File

@ -86,6 +86,35 @@
});
},
function (done) {
info("Sending one non-resendable notification");
var behavior = {
showOnlyOnce: true
};
var notif = new Notification("title", { mozbehavior: behavior });
ok(notif, "Notification object is valid");
notifications.push(notif);
var promise = Notification.get();
promise.then(function (notifications) {
is(notifications.length, 1, "one notification has been sent");
done();
});
},
function (done) {
info("Trying to resend non-resendable notification");
var notif = notifications.pop();
notif.onclose = function() {
done();
};
navigator.mozChromeNotifications.mozResendAllNotifications(function(number) {
is(number, 0, "One notification not resent");
notif.close();
});
},
function (done) {
info("Sending two notifications, closing one");
var notif1 = new Notification("title1");

View File

@ -72,6 +72,7 @@ dictionary GetNotificationOptions {
dictionary NotificationBehavior {
boolean noscreen = false;
boolean noclear = false;
boolean showOnlyOnce = false;
DOMString soundFile = "";
sequence<unsigned long> vibrationPattern;
};