Register/restory mock factory correctly in test_getTypeFromExtension_with_empty_Content_Type.js
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 30 Jun 2010 16:31:03 -0400
changeset 47090 d88ae23ecbe76c85092d520165da844c217d8241
parent 47089 bcdc6518b6559ac9f36819d9d643b1ff6e39c889
child 47091 ea142ed538fc02e587a18c8db4655f36cec8e54e
push id14223
push userbsmedberg@mozilla.com
push dateThu, 01 Jul 2010 18:30:48 +0000
treeherdermozilla-central@836fd3f8feba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b2pre
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
Register/restory mock factory correctly in test_getTypeFromExtension_with_empty_Content_Type.js
uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
--- a/uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
+++ b/uriloader/exthandler/tests/unit/test_getTypeFromExtension_with_empty_Content_Type.js
@@ -145,20 +145,20 @@ function run_test() {
     }
   };
 
   // --- Mock nsIWindowsRegKey factory ---
 
   var componentRegistrar = Components.manager.
                            QueryInterface(Ci.nsIComponentRegistrar);
 
-  var originalWindowsRegKeyFactory;
+  var originalWindowsRegKeyCID;
   var mockWindowsRegKeyFactory;
 
-  const kWindowsRegKeyCID = "{a53bc624-d577-4839-b8ec-bb5040a52ff4}";
+  const kMockCID = Components.ID("{9b23dfe9-296b-4740-ba1c-d39c9a16e55e}");
   const kWindowsRegKeyContractID = "@mozilla.org/windows-registry-key;1";
   const kWindowsRegKeyClassName = "nsWindowsRegKey";
 
   function registerMockWindowsRegKeyFactory() {
     mockWindowsRegKeyFactory = {
       createInstance: function(aOuter, aIid) {
         if (aOuter != null)
           throw Cr.NS_ERROR_NO_AGGREGATION;
@@ -166,41 +166,40 @@ function run_test() {
         var innerKey = originalWindowsRegKeyFactory.createInstance(null, aIid);
         var key = new MockWindowsRegKey(innerKey);
 
         return key.QueryInterface(aIid);
       }
     };
 
     // Preserve the original factory
-    originalWindowsRegKeyFactory = Components.manager.getClassObject(
-                                   Cc[kWindowsRegKeyContractID], Ci.nsIFactory);
+    originalWindowsRegKeyCID = Cc[kWindowsRegKeyContractID].number;
 
     // Register the mock factory
     componentRegistrar.registerFactory(
-      Components.ID(kWindowsRegKeyCID),
+      kMockCID,
       "Mock Windows Registry Key Implementation",
       kWindowsRegKeyContractID,
       mockWindowsRegKeyFactory
     );
   }
 
   function unregisterMockWindowsRegKeyFactory() {
     // Free references to the mock factory
     componentRegistrar.unregisterFactory(
-      Components.ID(kWindowsRegKeyCID),
+      kMockCID,
       mockWindowsRegKeyFactory
     );
 
     // Restore the original factory
     componentRegistrar.registerFactory(
-      Components.ID(kWindowsRegKeyCID),
-      kWindowsRegKeyClassName,
+      Components.ID(originalWindowsRegKeyCID),
+      "",
       kWindowsRegKeyContractID,
-      originalWindowsRegKeyFactory
+      null
     );
   }
 
   // --- Test procedure ---
 
   // Activate the override of the ".txt" file association data in the registry
   registerMockWindowsRegKeyFactory();
   try {