diff --git a/toolkit/components/microformats/src/Microformats.js b/toolkit/components/microformats/src/Microformats.js index af447e0ef0f..b9b138a5c7b 100644 --- a/toolkit/components/microformats/src/Microformats.js +++ b/toolkit/components/microformats/src/Microformats.js @@ -569,10 +569,18 @@ var Microformats = { break; case "microformat": try { - result = new Microformats[prop.microformat].mfObject(node); + result = new Microformats[prop.microformat].mfObject(node, true); } catch (ex) { - /* We can swallow this exception. If the creation of the */ - /* mf object fails, then the node isn't a microformat */ + /* There are two reasons we get here, one because the node is not */ + /* a microformat and two because the node is a microformat and */ + /* creation failed. If the node is not a microformat, we just fall */ + /* through and use the default getter since there are some cases */ + /* (location in hCalendar) where a property can be either a microformat */ + /* or a string. If creation failed, we break and simply don't add the */ + /* microformat property to the parent microformat */ + if (ex != "Node is not a microformat (" + prop.microformat + ")") { + break; + } } if (result != undefined) { if (prop.microformat_property) { diff --git a/toolkit/components/microformats/tests/test_Microformats.html b/toolkit/components/microformats/tests/test_Microformats.html index 338e958c7b7..44164441161 100644 --- a/toolkit/components/microformats/tests/test_Microformats.html +++ b/toolkit/components/microformats/tests/test_Microformats.html @@ -93,6 +93,19 @@ 1998-01-22 + +
+ John Doe + abc;def +
+
+ Party + The White House +
+
+ Party + The White House +
@@ -228,6 +241,13 @@ function test_Microformats() { var dateCal = new hCalendar(document.getElementById("vcal_vcard")); is(dateCal.description, "Mozilla's Birthday", "vcard in vcal"); + var hcard = new hCard(document.getElementById("geo_vcard")); + ok(!hcard.geo, "Check if invalid geo does not exist"); + var hcal = new hCalendar(document.getElementById("loc_vevent")); + is(hcal.location, "The White House", "Check if non vcard location works"); + var hcal = new hCalendar(document.getElementById("loc_vcard_vevent")); + is(hcal.location.fn, "The White House", "Check if vcard location works"); + var nestedCal = new hCalendar(document.getElementById("nested_header_include")); is(nestedCal.dtstart, "2008-01-01", "nested_header_include - dtstart"); is(nestedCal.location, "Austin - Sixth Street", "nested_header_include - location");