Bug 1063859 - Do not iterate on undefined valued when querying notifications. r=mhenretty

When we are performing the getAll/getAllCrossOrigin requests and there
is no notifications, then this.notifications[origin] (with a valid
origin) is just undefined. We should make sure we do not iterate over in
this case.
This commit is contained in:
Alexandre Lissy 2014-09-23 08:02:00 -04:00
parent a2b5d8654e
commit 9d98ab3d50

View File

@ -293,8 +293,10 @@ let NotificationDB = {
var origin = data.origin;
var notifications = [];
// Grab only the notifications for specified origin.
for (var i in this.notifications[origin]) {
notifications.push(this.notifications[origin][i]);
if (this.notifications[origin]) {
for (var i in this.notifications[origin]) {
notifications.push(this.notifications[origin][i]);
}
}
return Promise.resolve(notifications);
},
@ -303,6 +305,10 @@ let NotificationDB = {
if (DEBUG) { debug("Task, getting all whatever origin"); }
var notifications = [];
for (var origin in this.notifications) {
if (!this.notifications[origin]) {
continue;
}
for (var i in this.notifications[origin]) {
var notification = this.notifications[origin][i];