Bug 626998: Better cleanup when browser_bug553455.js fails. r=dtownsend, a=tests
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Thu, 17 Feb 2011 09:57:00 -0800
changeset 62754 b99674516b458e19dd1652b56cc95b9013b46109
parent 62753 ca8863ba339b3d3171300af6a0287cf49bf4569b
child 62756 1249116e394c3712fd0ecf5e4376948eb005b29f
child 62812 e4731ce9398894035daa4dd47fc120d4f5193da4
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersdtownsend, tests
bugs626998, 553455
milestone2.0b12pre
Bug 626998: Better cleanup when browser_bug553455.js fails. r=dtownsend, a=tests
browser/base/content/test/browser_bug553455.js
--- a/browser/base/content/test/browser_bug553455.js
+++ b/browser/base/content/test/browser_bug553455.js
@@ -16,25 +16,27 @@ var jar = getJar(croot);
 if (jar) {
   var tmpdir = extractJarToTmp(jar);
   croot = 'file://' + tmpdir.path + '/';
 }
 const CHROMEROOT = croot;
 
 var gApp = document.getElementById("bundle_brand").getString("brandShortName");
 var gVersion = Services.appinfo.version;
+var check_notification;
 
 function wait_for_notification(aCallback) {
   info("Waiting for notification");
-  PopupNotifications.panel.addEventListener("popupshown", function() {
-    PopupNotifications.panel.removeEventListener("popupshown", arguments.callee, false);
+  check_notification = function() {
+    PopupNotifications.panel.removeEventListener("popupshown", check_notification, false);
     info("Saw notification");
     is(PopupNotifications.panel.childNodes.length, 1, "Should be only one notification");
     aCallback(PopupNotifications.panel);
-  }, false);
+  };
+  PopupNotifications.panel.addEventListener("popupshown", check_notification, false);
 }
 
 function wait_for_notification_close(aCallback) {
   info("Waiting for notification to close");
   PopupNotifications.panel.addEventListener("popuphidden", function() {
     PopupNotifications.panel.removeEventListener("popuphidden", arguments.callee, false);
     aCallback();
   }, false);
@@ -873,16 +875,17 @@ function test() {
   Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
   Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
   Services.obs.addObserver(XPInstallObserver, "addon-install-failed", false);
   Services.obs.addObserver(XPInstallObserver, "addon-install-complete", false);
 
   registerCleanupFunction(function() {
     // Make sure no more test parts run in case we were timed out
     TESTS = [];
+    PopupNotifications.panel.removeEventListener("popupshown", check_notification, false);
 
     AddonManager.getAllInstalls(function(aInstalls) {
       aInstalls.forEach(function(aInstall) {
         aInstall.cancel();
       });
     });
 
     Services.prefs.clearUserPref("extensions.logging.enabled");