Bug 915951 - Fix browser_popupNotification.js to test that subframe navigations don't remove PopupNotifications. r=bsmedberg, a=test-only
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Thu, 31 Oct 2013 22:13:35 -0700
changeset 167316 47dad5d6661469cc76a41d7a6bf90946a6b5dea7
parent 167315 8d08677c7983f133919afd58f501d44dc3bd303f
child 167317 337662d0820797a9bab3d6379b454da50abf5285
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, test-only
bugs915951
milestone27.0a2
Bug 915951 - Fix browser_popupNotification.js to test that subframe navigations don't remove PopupNotifications. r=bsmedberg, a=test-only This patch was based on work from Tanvi Vyas and Benjamin Smedberg.
browser/base/content/test/general/browser_popupNotification.js
--- a/browser/base/content/test/general/browser_popupNotification.js
+++ b/browser/base/content/test/general/browser_popupNotification.js
@@ -856,33 +856,51 @@ var tests = [
 
           fgNotification.remove();
           gBrowser.removeTab(bgTab);
           goNext();
         });
       });
     }
   },
-  { // Test #28 - location change in embedded frame removes notification
+  { // Test #28 - location change in an embedded frame should not remove a notification
     run: function () {
-      loadURI("data:text/html,<iframe id='iframe' src='http://example.com/'>", function () {
-        let notifyObj = new basicNotification();
-        notifyObj.options.eventCallback = function (eventName) {
+      loadURI("data:text/html;charset=utf8,<iframe id='iframe' src='http://example.com/'>", function () {
+        this.notifyObj = new basicNotification();
+        this.notifyObj.options.eventCallback = function (eventName) {
           if (eventName == "removed") {
-            ok(true, "Notification removed in background tab after reloading");
-            executeSoon(goNext);
+            ok(false, "Test 28: Notification removed from browser when subframe navigated");
           }
         };
-        showNotification(notifyObj);
-        executeSoon(function () {
-          content.document.getElementById("iframe")
-                          .setAttribute("src", "http://example.org/");
-        });
-      });
-    }
+        showNotification(this.notifyObj);
+      }.bind(this));
+    },
+    onShown: function (popup) {
+      let self = this;
+      let progressListener = {
+        onLocationChange: function onLocationChange(aBrowser) {
+          if (aBrowser != gBrowser.selectedBrowser) {
+            return;
+          }
+          let notification = PopupNotifications.getNotification(self.notifyObj.id,
+                                                                self.notifyObj.browser);
+          ok(notification != null, "Test 28: Notification remained when subframe navigated");
+          self.notifyObj.options.eventCallback = undefined;
+
+          notification.remove();
+          gBrowser.removeTabsProgressListener(progressListener);
+        },
+      };
+
+      info("Test 28: Adding progress listener and performing navigation");
+      gBrowser.addTabsProgressListener(progressListener);
+      content.document.getElementById("iframe")
+                      .setAttribute("src", "http://example.org/");
+    },
+    onHidden: function () {}
   },
   { // Test #29 - Popup Notifications should catch exceptions from callbacks
     run: function () {
       let callbackCount = 0;
       this.testNotif1 = new basicNotification();
       this.testNotif1.message += " 1";
       showNotification(this.testNotif1);
       this.testNotif1.options.eventCallback = function (eventName) {