Bug 1296252 - Part 2 - Verify that doorhanger notifications are never shown together. r=past draft
authorJohann Hofmann <jhofmann@mozilla.com>
Sun, 20 Nov 2016 18:40:16 +0100
changeset 441672 e09f6229e47481fbd3040932f82e08a48b85ca70
parent 441671 1364cfbaa6bcb176142ec2955085e121af528cb3
child 441673 b5ccef53f8be35d8bd70ff5c7f9fbc74a631e954
push id36488
push userpaolo.mozmail@amadzone.org
push dateSun, 20 Nov 2016 17:47:21 +0000
reviewerspast
bugs1296252
milestone53.0a1
Bug 1296252 - Part 2 - Verify that doorhanger notifications are never shown together. r=past MozReview-Commit-ID: Ck9F7HgNxWp
browser/base/content/test/popupNotifications/browser_popupNotification_5.js
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_5.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification_5.js
@@ -196,10 +196,70 @@ var tests = [
         ok(id.endsWith("Test#7"), "Should have found the notification from Test7");
         ok(PopupNotifications.isPanelOpen, "Should have shown the popup again after getting back to the window");
         this.notification.remove();
         gBrowser.removeTab(gBrowser.selectedTab);
         gBrowser.selectedTab = this.oldSelectedTab;
         goNext();
       });
     }
-  }
+  },
+  // Test that only the first persistent notification is shown on update
+  { id: "Test#8",
+    run: function() {
+      this.notifyObj1 = new BasicNotification(this.id);
+      this.notifyObj1.id += "_1";
+      this.notifyObj1.anchorID = "default-notification-icon";
+      this.notifyObj1.options.persistent = true;
+      this.notification1 = showNotification(this.notifyObj1);
+
+      this.notifyObj2 = new BasicNotification(this.id);
+      this.notifyObj2.id += "_2";
+      this.notifyObj2.anchorID = "geo-notification-icon";
+      this.notifyObj2.options.persistent = true;
+      this.notification2 = showNotification(this.notifyObj2);
+
+      PopupNotifications._update();
+    },
+    onShown: function(popup) {
+      checkPopup(popup, this.notifyObj1);
+      this.notification1.remove();
+      this.notification2.remove();
+    },
+    onHidden: function(popup) { }
+  },
+  // Test that persistent notifications are shown stacked by anchor on update
+  { id: "Test#9",
+    run: function() {
+      this.notifyObj1 = new BasicNotification(this.id);
+      this.notifyObj1.id += "_1";
+      this.notifyObj1.anchorID = "default-notification-icon";
+      this.notifyObj1.options.persistent = true;
+      this.notification1 = showNotification(this.notifyObj1);
+
+      this.notifyObj2 = new BasicNotification(this.id);
+      this.notifyObj2.id += "_2";
+      this.notifyObj2.anchorID = "geo-notification-icon";
+      this.notifyObj2.options.persistent = true;
+      this.notification2 = showNotification(this.notifyObj2);
+
+      this.notifyObj3 = new BasicNotification(this.id);
+      this.notifyObj3.id += "_3";
+      this.notifyObj3.anchorID = "default-notification-icon";
+      this.notifyObj3.options.persistent = true;
+      this.notification3 = showNotification(this.notifyObj3);
+
+      PopupNotifications._update();
+    },
+    onShown: function(popup) {
+      let notifications = popup.childNodes;
+      is(notifications.length, 2, "two notifications displayed");
+      let [notification1, notification2] = notifications;
+      is(notification1.id, this.notifyObj1.id + "-notification", "id 1 matches");
+      is(notification2.id, this.notifyObj3.id + "-notification", "id 2 matches");
+
+      this.notification1.remove();
+      this.notification2.remove();
+      this.notification3.remove();
+    },
+    onHidden: function(popup) { }
+  },
 ];