gecko/toolkit/components/microformats/tests/test_Microformats_getters.html

159 lines
6.5 KiB
HTML

<html>
<head>
<title>Testing Mixed Up Microformat APIs</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<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>
</head>
<body id="contentbody">
<div id="content">
<!-- hCard -->
<p class="vcard" id="23-abbr-title-everything">
<!-- perhaps the most annoying test ever -->
<abbr class="fn" title="John Doe">foo</abbr>
<span class="n">
<abbr class="honorific-prefix" title="Mister">Mr.</abbr>
<abbr class="given-name" title="Jonathan">John</abbr>
<abbr class="additional-name" title="John">J</abbr>
<abbr class="family-name" title="Doe-Smith">Doe</abbr>
<abbr class="honorific-suffix" title="Medical Doctor">M.D</abbr>
</span>
<abbr class="nickname" title="JJ">jj</abbr>
<abbr class="bday" title="2006-04-04">April 4, 2006</abbr>
<span class="adr">
<abbr class="post-office-box" title="Box 1234">B. 1234</abbr>
<abbr class="extended-address" title="Suite 100">Ste. 100</abbr>
<abbr class="street-address" title="123 Fake Street">123 Fake St.</abbr>
<abbr class="locality" title="San Francisco">San Fran</abbr>
<abbr class="region" title="California">CA</abbr>
<abbr class="postal-code" title="12345-6789">12345</abbr>
<abbr class="country-name" title="United States of America">USA</abbr>
<abbr class="type" title="work">workplace</abbr>
</span>
<abbr class="tel" title="415.555.1234">1234</abbr>
<abbr class="tel-type-value" title="work">workplace</abbr>
<!-- mailer -->
<abbr class="tz" title="-0700">Pacific Time</abbr>
<span class="geo">
<abbr class="latitude" title="37.77">Northern</abbr>
<abbr class="longitude" title="-122.41">California</abbr>
</span>
<abbr class="title" title="President">pres.</abbr> and
<abbr class="role" title="Chief">cat wrangler</abbr>
<!-- <span class="agent"></span> -->
<span class="org">
<abbr class="organization-name" title="Intellicorp">foo</abbr>
<abbr class="organization-unit" title="Intelligence">bar</abbr>
</span>
<!-- <abbr class="category" title=""></abbr> -->
<abbr class="note" title="this is a note">this is not a note</abbr>
<!-- <abbr class="rev" title=""></abbr> (revision datetime) -->
<!-- <abbr class="sort-string" title=""></abbr> -->
<abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr>
<abbr class="class" title="public">pub</abbr>
<!-- <abbr class="key" title=""></abbr> -->
</p>
<!-- hCalendar -->
<frameset>
<frame id="frame1">
<div>
<span class="notAMicroformat" id="notme">
<abbr> class="foo">I am not a microformat</abbr>
<abbr> class="title">Foolish title, not a format</abbr>
</span>
</div>
</frame>
<frame id="frame3">
<span class="geo" id="02-geo-abbr-latlong" >
<abbr class="latitude" title="75.77">Far Northern</abbr>
<abbr class="longitude" title="-122.41">Canada</abbr>
</span>
<frame id="frame2">
<div class="vcalendar">
<span class="vevent" id="15-calendar-xml-lang">
<a class="url" href="http://www.web2con.com/">
<span class="summary">Web 2.0 Conference</span>:
<abbr class="dtstart" title="2005-10-05">October 5</abbr>-
<abbr class="dtend" title="2005-10-08">7</abbr>,
at the <span class="location">Argent Hotel, San Francisco, CA</span>
</a>
</span>
</div>
</frame>
</frameset>
<div id="secondnode">
<span>some interesting content</span>
<!-- Geo Fire test once we know this is loaded.-->
<iframe src="geo.html" onload="test_MicroformatsAPI();">
</iframe>
<!-- adr -->
<div class="adr" id="01-extended-address">
<span class="extended-address">Park Bench</span>
</div>
<div class="vcalendar">
<span class="vevent" id="16-calendar-xml-lang">
<a class="url" href="http://www.foo.com/">
<span class="summary">Pseudo Conference</span>:
<abbr class="dtstart" title="2008-04-01">April 1</abbr>-
<abbr class="dtend" title="2008-04-03">April 3</abbr>,
at the <span class="location">Argent Hotel, San Francisco, CA</span>
</a>
</span>
</div>
</div>
</div>
<!-- Ok, the test, here we go -->
<pre id="test">
<script class="testbody" type="text/javascript">
// Called from onload in iframe
function test_MicroformatsAPI() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Components.utils.import("resource://gre/modules/Microformats.js");
// Test that we can get them all
var mfs = [];
mfs = Microformats.get("adr",
document.getElementById("content"),
{showHidden: true});
is(mfs.length, 2, "Two adr's in our array");
mfs = Microformats.get("geo",
document.getElementById("content"),
{recurseExternalFrames: true});
is(mfs.length, 3, "Three geo's in our array");
mfs = Microformats.get("hCalendar",
document.getElementById("content"),
{recurseExternalFrames: false});
// Should get the hCalendar whether we recurseExternalFrames or not.
is(mfs.length, 2, "Two hCalendar returned not recursing frames");
mfs = Microformats.get("hCalendar",
document.getElementById("content"),
{recurseExternalFrames: true});
is(mfs.length, 2, "Two hCalendars returned recursing frames");
mfs = Microformats.get("hCard",
document.getElementById("content"),
{recurseExternalFrames: true},
mfs);
is(mfs.length, 3, "Two hCalendars and one hCard");
mfs = Microformats.get("hCalendar", document.getElementById("secondnode"));
is(mfs[0].summary, "Pseudo Conference",
"Make sure we get the proper hCalendar from the second level node");
is(mfs.length, 1, "And we should only get one hCalendar not two from this node.");
}
</script>
</body>
</html>