Bug 1296252 - Add tests for stacked permission anchors on PopupNotifications update. r=past draft
authorJohann Hofmann <jhofmann@mozilla.com>
Mon, 12 Sep 2016 14:30:03 +0200
changeset 412603 f43196b4036b0951116dbeab9200dccf3b2f8f6e
parent 412602 186b3fb067944e82dd7277500483c34b3f9efc19
child 531029 3b8e61198333b0f1e91176c8afd83db36a68b46a
push id29216
push userbmo:jhofmann@mozilla.com
push dateMon, 12 Sep 2016 12:30:23 +0000
reviewerspast
bugs1296252
milestone51.0a1
Bug 1296252 - Add tests for stacked permission anchors on PopupNotifications update. r=past MozReview-Commit-ID: 3GHYFP5i17A
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) { }
+  },
 ];