Bug 586740 - Microformats test leak fix. r=kaply
authorBenjamin Stover <webapps@stechz.com>
Fri, 13 Aug 2010 18:40:13 -0700
changeset 50574 0346acf59bc6e82c9ee3e752d4e9b3f782ffe302
parent 50573 72491f4caf6d994cd64ca27ad5601cb369e7f744
child 50575 bcd40dd716400c3f44ec4afdfff30eb667759da5
push idunknown
push userunknown
push dateunknown
reviewerskaply
bugs586740
milestone2.0b4pre
Bug 586740 - Microformats test leak fix. r=kaply
toolkit/components/microformats/src/Microformats.js
toolkit/components/microformats/tests/test_Microformats_add.html
--- a/toolkit/components/microformats/src/Microformats.js
+++ b/toolkit/components/microformats/src/Microformats.js
@@ -307,16 +307,26 @@ var Microformats = {
       Microformats.list.push(microformat);
     }
     Microformats[microformat] = microformatDefinition;
     microformatDefinition.mfObject.prototype.debug =
       function(microformatObject) {
         return Microformats.debug(microformatObject)
       };
   },
+  remove: function remove(microformat) {
+    if (Microformats[microformat]) {
+      var list = Microformats.list;
+      var index = list.indexOf(microformat, 1);
+      if (index != -1) {
+        list.splice(index, 1);
+      }
+      delete Microformats[microformat];
+    }
+  },
   /* All parser specific functions are contained in this object */
   parser: {
     /**
      * Uses the microformat patterns to decide what the correct text for a
      * given microformat property is. This includes looking at things like
      * abbr, img/alt, area/alt and value excerpting.
      *
      * @param  propnode   The DOMNode to check
--- a/toolkit/components/microformats/tests/test_Microformats_add.html
+++ b/toolkit/components/microformats/tests/test_Microformats_add.html
@@ -225,13 +225,15 @@
 
     ok(mf.length, 1, "Check that test1 is a valid microformat");
 
     // Verify that the version 2 microformat is now also considered valid
     var mf2 = Microformats.get("hTest", document.getElementById("test2"), {});
 
     ok(mf2.length, 1, "Check that the mfTest microformat version 2 is now valid");
     doTest3_4_and5(true);
+
+    Microformats.remove("hTest");
   }
 
   </script>
 </body>
 </html>