Bug 1315317 - Regression test. r=Gijs
authorMike Conley <mconley@mozilla.com>
Fri, 04 Nov 2016 18:15:32 -0400
changeset 351480 23667d366a5d4e04e7ee2e327596d8256d439bd0
parent 351479 7e61b840c16203a16144765b789f8777bf067369
child 351481 478f38ea7eca5d6d05ef64854798768b99278815
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1315317
milestone52.0a1
Bug 1315317 - Regression test. r=Gijs MozReview-Commit-ID: 2neRqZsn68
browser/base/content/test/popupNotifications/browser.ini
browser/base/content/test/popupNotifications/browser_reshow_in_background.js
--- a/browser/base/content/test/popupNotifications/browser.ini
+++ b/browser/base/content/test/popupNotifications/browser.ini
@@ -9,8 +9,10 @@ skip-if = (os == "linux" && (debug || as
 [browser_popupNotification_2.js]
 skip-if = (os == "linux" && (debug || asan))
 [browser_popupNotification_3.js]
 skip-if = (os == "linux" && (debug || asan))
 [browser_popupNotification_4.js]
 skip-if = (os == "linux" && (debug || asan))
 [browser_popupNotification_checkbox.js]
 skip-if = (os == "linux" && (debug || asan))
+[browser_reshow_in_background.js]
+skip-if = (os == "linux" && (debug || asan))
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/popupNotifications/browser_reshow_in_background.js
@@ -0,0 +1,52 @@
+"use strict";
+
+/**
+ * Tests that when PopupNotifications for background tabs are reshown, they
+ * don't show up in the foreground tab, but only in the background tab that
+ * they belong to.
+ */
+add_task(function* test_background_notifications_dont_reshow_in_foreground() {
+  // Our initial tab will be A. Let's open two more tabs B and C, but keep
+  // A selected. Then, we'll trigger a PopupNotification in C, and then make
+  // it reshow.
+  let tabB = gBrowser.addTab("about:blank");
+  let tabC = gBrowser.addTab("about:blank");
+
+  let seenEvents = [];
+
+  let options = {
+    dismissed: false,
+    eventCallback(popupEvent) {
+      seenEvents.push(popupEvent);
+    },
+  };
+
+  let notification =
+    PopupNotifications.show(tabC.linkedBrowser, "test-notification",
+                            "", "plugins-notification-icon",
+                            null, null, options);
+  Assert.deepEqual(seenEvents, [], "Should have seen no events yet.");
+
+  yield BrowserTestUtils.switchTab(gBrowser, tabB);
+  Assert.deepEqual(seenEvents, [], "Should have seen no events yet.");
+
+  notification.reshow();
+  Assert.deepEqual(seenEvents, [], "Should have seen no events yet.");
+
+  let panelShown =
+    BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown");
+  yield BrowserTestUtils.switchTab(gBrowser, tabC);
+  yield panelShown;
+
+  Assert.equal(seenEvents.length, 2, "Should have seen two events.");
+  Assert.equal(seenEvents[0], "showing", "Should have said popup was showing.");
+  Assert.equal(seenEvents[1], "shown", "Should have said popup was shown.");
+
+  let panelHidden =
+    BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popuphidden");
+  PopupNotifications.remove(notification);
+  yield panelHidden;
+
+  yield BrowserTestUtils.removeTab(tabB);
+  yield BrowserTestUtils.removeTab(tabC);
+});