Bug 489078 - (TUnit) xpcshell-tests test_getTypeFromExtension_with_empty_Content_Type.js leaks; r=sdwilsh
authorPaolo Amadini <paolo.02.prg@amadzone.org>
Wed, 22 Apr 2009 02:42:11 +0200
changeset 27592 02d8a0a5f71f8918b174d01ebdaf775261478b54
parent 27591 5617c22ea9aca301a6515dab91ab9a7ab7bb88dd
child 27593 9888445d74393cd7185aeda8c344b54ae940f782
push id6636
push usersgautherie.bz@free.fr
push dateWed, 22 Apr 2009 00:43:14 +0000
treeherdermozilla-central@9888445d7439 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh
bugs489078
milestone1.9.2a1pre
Bug 489078 - (TUnit) xpcshell-tests test_getTypeFromExtension_with_empty_Content_Type.js leaks; r=sdwilsh
uriloader/exthandler/tests/unit/head_handlerService.js
--- a/uriloader/exthandler/tests/unit/head_handlerService.js
+++ b/uriloader/exthandler/tests/unit/head_handlerService.js
@@ -76,34 +76,41 @@ var HandlerServiceTest = {
 
 
   //**************************************************************************//
   // Initialization & Destruction
   
   init: function HandlerServiceTest_init() {
     // Register ourselves as a directory provider for the datasource file
     // if there isn't one registered already.
-    try        { this._dirSvc.get("UMimTyp", Ci.nsIFile) }
-    catch (ex) { this._dirSvc.registerProvider(this) }
+    try {
+      this._dirSvc.get("UMimTyp", Ci.nsIFile);
+    } catch (ex) {
+      this._dirSvc.registerProvider(this);
+      this._providerRegistered = true;
+    }
 
     // Delete the existing datasource file, if any, so we start from scratch.
     // We also do this after finishing the tests, so there shouldn't be an old
     // file lying around, but just in case we delete it here as well.
     this._deleteDatasourceFile();
 
     // Turn on logging so we can troubleshoot problems with the tests.
     var prefBranch = Cc["@mozilla.org/preferences-service;1"].
                      getService(Ci.nsIPrefBranch);
     prefBranch.setBoolPref("browser.contentHandling.log", true);
   },
 
   destroy: function HandlerServiceTest_destroy() {
     // Delete the existing datasource file, if any, so we don't leave test files
     // lying around and we start from scratch the next time.
     this._deleteDatasourceFile();
+    // Unregister the directory service provider
+    if (this._providerRegistered)
+      this._dirSvc.unregisterProvider(this);
   },
 
 
   //**************************************************************************//
   // nsIDirectoryServiceProvider
 
   getFile: function HandlerServiceTest_getFile(property, persistent) {
     this.log("getFile: requesting " + property);