Bug 562803: Add cleanup function to avoid one failing xpinstall test from messing up subsequent tests. r=robstrong
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 22 Jun 2010 18:59:52 -0700
changeset 44161 875f50c22e24586ed875ae38e0d60788f4447b46
parent 44160 ba00f1a51ca508f879c47c934e1343b50b003ccd
child 44162 4c7be0d2836d7ec937a15cb17f6d1d66076cb13b
push id14001
push userdtownsend@mozilla.com
push dateWed, 23 Jun 2010 02:00:06 +0000
treeherdermozilla-central@875f50c22e24 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrobstrong
bugs562803
milestone1.9.3a6pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 562803: Add cleanup function to avoid one failing xpinstall test from messing up subsequent tests. r=robstrong
toolkit/mozapps/extensions/test/xpinstall/head.js
--- a/toolkit/mozapps/extensions/test/xpinstall/head.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/head.js
@@ -58,29 +58,28 @@ var Harness = {
     waitForExplicitFinish();
     Services.prefs.setBoolPref(PREF_LOGGING_ENABLED, true);
     Services.obs.addObserver(this, "addon-install-blocked", false);
     Services.wm.addListener(this);
 
     AddonManager.addInstallListener(this);
     this.installCount = 0;
     this.pendingCount = 0;
+
+    var self = this;
+    registerCleanupFunction(function() {
+      Services.prefs.clearUserPref(PREF_LOGGING_ENABLED);
+      Services.obs.removeObserver(self, "addon-install-blocked");
+      Services.wm.removeListener(self);
+
+      AddonManager.removeInstallListener(self);
+    });
   },
 
   finish: function() {
-    Services.prefs.clearUserPref(PREF_LOGGING_ENABLED);
-    Services.obs.removeObserver(this, "addon-install-blocked");
-    Services.wm.removeListener(this);
-
-    var win = Services.wm.getMostRecentWindow("Extension:Manager");
-    if (win)
-      win.close();
-
-    AddonManager.removeInstallListener(this);
-
     AddonManager.getAllInstalls(function(installs) {
       is(installs.length, 0, "Should be no active installs at the end of the test");
       finish();
     });
   },
 
   endTest: function() {
     // Defer the final notification to allow things like the InstallTrigger