mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
302 lines
11 KiB
HTML
302 lines
11 KiB
HTML
<html>
|
|
<head>
|
|
<title>Testing Microformats.js</title>
|
|
<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>
|
|
<style type="text/css">
|
|
/*vcards weee! */
|
|
.floated div {
|
|
float:left;
|
|
}
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
<div id="content" style="display: none">
|
|
<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>
|
|
|
|
<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>
|
|
</div>
|
|
|
|
<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>
|
|
|
|
<div class="vevent" id="date_vcal">
|
|
<span class="description">Mozilla's Birthday</span>
|
|
<span class="dtstart">1998-01-22</span>
|
|
</div>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
<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>
|
|
|
|
<pre id="test">
|
|
<script class="testbody" type="application/javascript;version=1.8">
|
|
|
|
test_Microformats();
|
|
test_hCard();
|
|
|
|
function test_Microformats() {
|
|
let { Microformats, hCard, hCalendar } = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js");
|
|
|
|
ok(Microformats, "Check global access to Microformats");
|
|
var hCards = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
|
|
is(hCards.length, 1, "Check Microformats.get");
|
|
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)");
|
|
ok(Microformats.isMicroformat(document.getElementById("vcard1_node")), "Check isMicroformat");
|
|
is(SpecialPowers.unwrap(Microformats.getParent(document.getElementById("vcard1_org"))), document.getElementById("vcard1_node"), "Check getParent");
|
|
is(Microformats.getNamesFromNode(document.getElementById("vcard1_node")), "hCard", "Check getNamesFromNode");
|
|
|
|
var hCardArray1 = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
|
|
is(hCardArray1.length, 1, "Check showHidden=true");
|
|
var hCardArray2 = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: false});
|
|
is(hCardArray2.length, 0, "Check showHidden=false");
|
|
|
|
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");
|
|
|
|
var valueCard = new hCard(document.getElementById("value_test"));
|
|
|
|
is(valueCard.fn, "JohnDoe", "value_test");
|
|
|
|
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");
|
|
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");
|
|
|
|
var dateCal = new hCalendar(document.getElementById("vcal_vcard"));
|
|
is(dateCal.description, "Mozilla's Birthday", "vcard in vcal");
|
|
|
|
is(Microformats.count("hCard", document.getElementById("float_test")), 2, "Check Microformats.count for floated div");
|
|
|
|
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");
|
|
is(nestedCal.summary, "New Years Party", "nested_header_include - summary");
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
function test_hCard() {
|
|
var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
|
|
|
|
var hCards = Microformats.get("hCard", document.getElementById("test_1"), {showHidden: true});
|
|
|
|
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>
|