2007-09-20 11:07:13 -07:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Testing Microformats.js</title>
|
2009-05-06 13:46:04 -07:00
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
2007-09-20 11:07:13 -07:00
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
|
2008-09-21 18:14:45 -07:00
|
|
|
<style type="text/css">
|
|
|
|
/*vcards weee! */
|
|
|
|
.floated div {
|
|
|
|
float:left;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2007-09-20 11:07:13 -07:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="content" style="display: none">
|
2008-02-12 09:48:48 -08:00
|
|
|
<div id="test_1">
|
|
|
|
<div class="vcard" id="vcard1_node">
|
|
|
|
<a class="url fn" href="http://tantek.com/">Tantek Çelik</a>
|
|
|
|
<div id="vcard1_org" class="org">Technorati</div>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="vcard2_node">
|
|
|
|
<a class="url" href="http://tantek.com/">Tantek Çelik</a>
|
|
|
|
<div id="vcard2_org" class="org">Technorati</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="outer_vcard">
|
|
|
|
<div class="vcard" id="middle_vcard">
|
|
|
|
<div class="vcard" id="inner_vcard">
|
|
|
|
<span class="fn">Inner User</span>
|
|
|
|
</div>
|
|
|
|
<span class="fn">Middle User</span>
|
|
|
|
</div>
|
|
|
|
<span class="fn">Outer User</span>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="outer_vcard2">
|
|
|
|
<div class="vevent" id="middle_vevent2">
|
|
|
|
<div class="vcard" id="inner_vcard2">
|
|
|
|
<span class="fn">Inner User</span>
|
|
|
|
</div>
|
|
|
|
<span class="summary">Middle Event</span>
|
|
|
|
</div>
|
|
|
|
<span class="fn">Outer User</span>
|
|
|
|
</div>
|
|
|
|
<div class="vevent" id="outer_vevent3">
|
|
|
|
<div class="vcard" id="middle_vcard3">
|
|
|
|
<div class="vevent" id="inner_vevent3">
|
|
|
|
<span class="summary">Inner Event</span>
|
|
|
|
</div>
|
|
|
|
<span class="fn">Middle User</span>
|
|
|
|
</div>
|
|
|
|
<span class="summary">Outer Event</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="vevent" id="outer_vevent4">
|
|
|
|
<a rel="tag" id="inner_tag4" href="http://www.example.com/inner_tag">
|
|
|
|
Inner tag
|
|
|
|
</a>
|
|
|
|
<span class="summary">Outer Event</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a rel="tag" id="outer_tag5" href="http://www.example.com/outer_tag">
|
|
|
|
<div class="vevent" id="inner_vevent5">
|
|
|
|
<span class="summary">Inner Event</span>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
|
2008-02-13 07:39:52 -08:00
|
|
|
<div class="vcard" id="value_test">
|
|
|
|
<span class="fn">
|
|
|
|
<span class="value">John</span>
|
|
|
|
<span><span class="value">Middle</span></span>
|
|
|
|
<span class="value">Doe</span>
|
|
|
|
</span>
|
2008-09-21 18:14:45 -07:00
|
|
|
</div>
|
2008-02-21 08:11:00 -08:00
|
|
|
|
|
|
|
<div class="vcard" id="nested_vcard1">
|
|
|
|
<div class="agent vcard" id="nested_vcard2">
|
|
|
|
<div class="agent vcard" id="nested_vcard3">
|
|
|
|
<span class="fn">Bob Smith</span>
|
|
|
|
<span class="title">Office Assistant</span>
|
|
|
|
</div>
|
|
|
|
<span class="fn">Jack Jones</span>
|
|
|
|
<span class="title">Executive Assistant</span>
|
|
|
|
</div>
|
|
|
|
<span class="fn">John Doe</span>
|
|
|
|
<span class="title">CEO</span>
|
|
|
|
</div>
|
|
|
|
|
2008-02-28 07:38:41 -08:00
|
|
|
<div class="vevent" id="date_vcal">
|
|
|
|
<span class="description">Mozilla's Birthday</span>
|
|
|
|
<span class="dtstart">1998-01-22</span>
|
|
|
|
</div>
|
|
|
|
|
2008-03-19 12:20:41 -07:00
|
|
|
<div class="vevent" id="vcal_vcard">
|
|
|
|
<div class="vcard">
|
|
|
|
<span class="description">
|
|
|
|
<span class="fn org">Mozilla</span>'s Birthday
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<span class="dtstart">1998-01-22</span>
|
|
|
|
</div>
|
2008-09-21 17:05:06 -07:00
|
|
|
|
|
|
|
<div id="geo_vcard" class="vcard">
|
|
|
|
<span class="fn">John Doe</span>
|
|
|
|
<span class="geo" id="ill_geo5">abc;def</span>
|
|
|
|
</div>
|
|
|
|
<div id="loc_vevent" class="vevent">
|
|
|
|
<span class="summary">Party</span>
|
|
|
|
<span class="location">The White House</span>
|
|
|
|
</div>
|
|
|
|
<div id="loc_vcard_vevent" class="vevent">
|
|
|
|
<span class="summary">Party</span>
|
|
|
|
<span class="location vcard"><span class="fn">The White House</span></span>
|
|
|
|
</div>
|
2008-03-19 12:20:41 -07:00
|
|
|
|
2008-09-21 18:14:45 -07:00
|
|
|
<div class="vcard" id="valuespace_1">
|
|
|
|
<span class="fn">
|
|
|
|
<span class="value">John</span>
|
|
|
|
<span class="value"> </span>
|
|
|
|
<span class="value">Doe</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="valuespace_2">
|
|
|
|
<span class="fn">
|
|
|
|
<span class="value">John</span>
|
|
|
|
<span class="value"> </span>
|
|
|
|
<span class="value">Doe</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="valuespace_3">
|
|
|
|
<span class="fn">
|
|
|
|
<span class="value"> John</span>
|
|
|
|
<span class="value"> </span>
|
|
|
|
<span class="value">Doe </span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="valuespace_4">
|
|
|
|
<span class="fn">
|
|
|
|
<span class="value">John </span>
|
|
|
|
<span class="value"> Doe</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="valuespace_5">
|
|
|
|
<span class="fn">
|
|
|
|
<span class="value"> John</span>
|
|
|
|
<span class="value"> Doe </span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="valuespace_6">
|
|
|
|
<span class="fn">
|
|
|
|
<span class="value">John
|
|
|
|
</span>
|
|
|
|
<span class="value">
|
|
|
|
Doe</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="valuespace_7">
|
|
|
|
<span class="fn">
|
|
|
|
<span class="value">John</span>
|
|
|
|
<span class="value">Doe</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
2008-09-14 20:15:00 -07:00
|
|
|
|
2008-09-14 20:37:41 -07:00
|
|
|
<span id="austin" class="location">Austin - Sixth Street</span>
|
|
|
|
<table summary="Timetable">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th id="location-1"><a href="#austin" class="include"></a>New York</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th id="time-1"><abbr title="2008-01-01" class="dtstart">Jan 1, 2008</abbr></th>
|
|
|
|
<td id="nested_header_include" class="vevent" headers="time-1 location-1"><div class="summary">New Years Party</div></td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2007-09-20 11:07:13 -07:00
|
|
|
</div>
|
2008-09-21 18:14:45 -07:00
|
|
|
|
|
|
|
<div id="float_test">
|
|
|
|
<div class="vcard floated" id="one">
|
|
|
|
<div class="fn">John Doe</div>
|
|
|
|
</div>
|
|
|
|
<div class="vcard" id="two">
|
|
|
|
<div class="fn">John Smith</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2007-09-20 11:07:13 -07:00
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
test_Microformats();
|
|
|
|
test_hCard();
|
|
|
|
|
|
|
|
function test_Microformats() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
|
|
|
|
Components.utils.import("resource://gre/modules/Microformats.js");
|
2008-02-28 07:38:41 -08:00
|
|
|
|
2007-09-20 11:07:13 -07:00
|
|
|
ok(Microformats, "Check global access to Microformats");
|
2008-02-12 09:48:48 -08:00
|
|
|
var hCards = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
|
2007-09-20 11:07:13 -07:00
|
|
|
is(hCards.length, 1, "Check Microformats.get");
|
2008-02-12 09:48:48 -08:00
|
|
|
is(Microformats.count("hCard", document.getElementById("test_1"), {showHidden: true}), 1, "Check Microformats.count");
|
|
|
|
is(Microformats.count("hCard", document.getElementById("test_1"), {showHidden: true, debug: true}), 2, "Check Microformats.count (debug)");
|
2007-09-20 11:07:13 -07:00
|
|
|
ok(Microformats.isMicroformat(document.getElementById("vcard1_node")), "Check isMicroformat");
|
|
|
|
is(Microformats.getParent(document.getElementById("vcard1_org")), document.getElementById("vcard1_node"), "Check getParent");
|
|
|
|
is(Microformats.getNamesFromNode(document.getElementById("vcard1_node")), "hCard", "Check getNamesFromNode");
|
|
|
|
|
2008-02-12 09:48:48 -08:00
|
|
|
var hCardArray1 = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
|
2007-12-14 11:58:54 -08:00
|
|
|
is(hCardArray1.length, 1, "Check showHidden=true");
|
2008-02-12 09:48:48 -08:00
|
|
|
var hCardArray2 = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: false});
|
2007-12-14 11:58:54 -08:00
|
|
|
is(hCardArray2.length, 0, "Check showHidden=false");
|
2008-02-12 09:48:48 -08:00
|
|
|
|
|
|
|
var inner_parent = Microformats.getParent(document.getElementById("inner_vcard"));
|
|
|
|
is(inner_parent.id, "middle_vcard", "GetParent gets correct ancestor 1");
|
|
|
|
|
|
|
|
var inner_parent = Microformats.getParent(document.getElementById("inner_vcard2"));
|
|
|
|
is(inner_parent.id, "middle_vevent2", "GetParent gets correct ancestor 2");
|
|
|
|
|
|
|
|
var inner_parent = Microformats.getParent(document.getElementById("middle_vevent2"));
|
|
|
|
is(inner_parent.id, "outer_vcard2", "GetParent gets correct ancestor 2a");
|
|
|
|
|
|
|
|
var inner_parent = Microformats.getParent(document.getElementById("inner_vevent3"));
|
|
|
|
is(inner_parent.id, "middle_vcard3", "GetParent gets correct ancestor 3");
|
|
|
|
|
|
|
|
var inner_parent = Microformats.getParent(document.getElementById("middle_vcard3"));
|
|
|
|
is(inner_parent.id, "outer_vevent3", "GetParent gets correct ancestor 3a");
|
|
|
|
|
|
|
|
var inner_parent = Microformats.getParent(document.getElementById("inner_tag4"));
|
|
|
|
is(inner_parent.id, "outer_vevent4", "GetParent gets correct ancestor 4");
|
|
|
|
|
|
|
|
var inner_parent = Microformats.getParent(document.getElementById("inner_vevent5"));
|
|
|
|
is(inner_parent.id, "outer_tag5", "GetParent gets correct ancestor 5");
|
2008-02-13 07:39:52 -08:00
|
|
|
|
|
|
|
var valueCard = new hCard(document.getElementById("value_test"));
|
|
|
|
|
|
|
|
is(valueCard.fn, "JohnDoe", "value_test");
|
2008-02-21 08:11:00 -08:00
|
|
|
|
|
|
|
var nestCard1 = new hCard(document.getElementById("nested_vcard1"));
|
|
|
|
var nestCard2 = new hCard(document.getElementById("nested_vcard2"));
|
|
|
|
var nestCard3 = new hCard(document.getElementById("nested_vcard3"));
|
|
|
|
|
|
|
|
is(nestCard1.fn, "John Doe", "nesting (fn) 1");
|
|
|
|
is(nestCard1.title, "CEO", "nesting (title) 1");
|
|
|
|
is(nestCard2.fn, "Jack Jones", "nesting (fn) 2");
|
|
|
|
is(nestCard2.title, "Executive Assistant", "nesting (title) 2");
|
|
|
|
is(nestCard3.fn, "Bob Smith", "nesting (fn) 3");
|
|
|
|
is(nestCard3.title, "Office Assistant", "nesting (title) 3");
|
2008-02-28 07:38:41 -08:00
|
|
|
is(nestCard1.agent[0].agent[0].fn, "Bob Smith", "nesting all");
|
|
|
|
|
|
|
|
var dateCal = new hCalendar(document.getElementById("date_vcal"));
|
|
|
|
jsdate = Microformats.dateFromISO8601(dateCal.dtstart);
|
|
|
|
origdate = Microformats.iso8601FromDate(jsdate, true);
|
|
|
|
is(dateCal.dtstart, origdate, "date round trip");
|
2008-03-19 12:20:41 -07:00
|
|
|
|
|
|
|
var dateCal = new hCalendar(document.getElementById("vcal_vcard"));
|
|
|
|
is(dateCal.description, "Mozilla's Birthday", "vcard in vcal");
|
2008-09-14 20:37:41 -07:00
|
|
|
|
2008-09-21 18:14:45 -07:00
|
|
|
is(Microformats.count("hCard", document.getElementById("float_test")), 2, "Check Microformats.count for floated div");
|
|
|
|
|
2008-09-21 17:05:06 -07:00
|
|
|
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");
|
|
|
|
|
2008-09-14 20:37:41 -07:00
|
|
|
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");
|
|
|
|
is(nestedCal.summary, "New Years Party", "nested_header_include - summary");
|
|
|
|
|
2008-09-14 20:15:00 -07:00
|
|
|
var valueCard = new hCard(document.getElementById("valuespace_1"));
|
|
|
|
is(valueCard.fn, "John Doe", "valuespace_1");
|
|
|
|
var valueCard = new hCard(document.getElementById("valuespace_2"));
|
|
|
|
is(valueCard.fn, "John Doe", "valuespace_2");
|
|
|
|
var valueCard = new hCard(document.getElementById("valuespace_3"));
|
|
|
|
is(valueCard.fn, "John Doe", "valuespace_3");
|
|
|
|
var valueCard = new hCard(document.getElementById("valuespace_4"));
|
|
|
|
is(valueCard.fn, "John Doe", "valuespace_4");
|
|
|
|
var valueCard = new hCard(document.getElementById("valuespace_5"));
|
|
|
|
is(valueCard.fn, "John Doe", "valuespace_5");
|
|
|
|
var valueCard = new hCard(document.getElementById("valuespace_6"));
|
|
|
|
is(valueCard.fn, "John Doe", "valuespace_6");
|
|
|
|
var valueCard = new hCard(document.getElementById("valuespace_7"));
|
|
|
|
is(valueCard.fn, "JohnDoe", "valuespace_7");
|
|
|
|
|
2007-09-20 11:07:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_hCard() {
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
|
|
|
|
Components.utils.import("resource://gre/modules/Microformats.js");
|
|
|
|
|
2008-02-12 09:48:48 -08:00
|
|
|
var hCards = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
|
2007-09-20 11:07:13 -07:00
|
|
|
|
|
|
|
is(hCards[0].fn, "Tantek Çelik", "Check for fn on test vcard");
|
|
|
|
is(hCards[0].url, "http://tantek.com/", "Check for url on test vcard");
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|