toolkit/components/microformats/tests/test_Microformats_getters.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 <html>
michael@0 2 <head>
michael@0 3 <title>Testing Mixed Up Microformat APIs</title>
michael@0 4 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
michael@0 7 </head>
michael@0 8 <body id="contentbody">
michael@0 9 <pre id="test">
michael@0 10 <script class="testbody" type="text/javascript">
michael@0 11
michael@0 12 // Called from onload in iframe
michael@0 13 function test_MicroformatsAPI() {
michael@0 14 var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
michael@0 15
michael@0 16 // Test that we can get them all
michael@0 17 var mfs = [];
michael@0 18 mfs = Microformats.get("adr",
michael@0 19 document.getElementById("content"),
michael@0 20 {showHidden: true});
michael@0 21
michael@0 22 is(mfs.length, 2, "Two adr's in our array");
michael@0 23
michael@0 24 mfs = Microformats.get("geo",
michael@0 25 document.getElementById("content"),
michael@0 26 {recurseExternalFrames: true});
michael@0 27 is(mfs.length, 3, "Three geo's in our array");
michael@0 28
michael@0 29 mfs = Microformats.get("hCalendar",
michael@0 30 document.getElementById("content"),
michael@0 31 {recurseExternalFrames: false});
michael@0 32 // Should get the hCalendar whether we recurseExternalFrames or not.
michael@0 33 is(mfs.length, 2, "Two hCalendar returned not recursing frames");
michael@0 34
michael@0 35 mfs = Microformats.get("hCalendar",
michael@0 36 document.getElementById("content"),
michael@0 37 {recurseExternalFrames: true});
michael@0 38 is(mfs.length, 2, "Two hCalendars returned recursing frames");
michael@0 39
michael@0 40 mfs = Microformats.get("hCard",
michael@0 41 document.getElementById("content"),
michael@0 42 {recurseExternalFrames: true},
michael@0 43 mfs);
michael@0 44 is(mfs.length, 3, "Two hCalendars and one hCard");
michael@0 45
michael@0 46 mfs = Microformats.get("hCalendar", document.getElementById("secondnode"));
michael@0 47
michael@0 48 is(mfs[0].summary, "Pseudo Conference",
michael@0 49 "Make sure we get the proper hCalendar from the second level node");
michael@0 50 is(mfs.length, 1, "And we should only get one hCalendar not two from this node.");
michael@0 51 }
michael@0 52 </script>
michael@0 53 </pre>
michael@0 54 <div id="content">
michael@0 55 <!-- hCard -->
michael@0 56 <p class="vcard" id="23-abbr-title-everything">
michael@0 57 <!-- perhaps the most annoying test ever -->
michael@0 58 <abbr class="fn" title="John Doe">foo</abbr>
michael@0 59 <span class="n">
michael@0 60 <abbr class="honorific-prefix" title="Mister">Mr.</abbr>
michael@0 61 <abbr class="given-name" title="Jonathan">John</abbr>
michael@0 62 <abbr class="additional-name" title="John">J</abbr>
michael@0 63 <abbr class="family-name" title="Doe-Smith">Doe</abbr>
michael@0 64 <abbr class="honorific-suffix" title="Medical Doctor">M.D</abbr>
michael@0 65 </span>
michael@0 66 <abbr class="nickname" title="JJ">jj</abbr>
michael@0 67 <abbr class="bday" title="2006-04-04">April 4, 2006</abbr>
michael@0 68 <span class="adr">
michael@0 69 <abbr class="post-office-box" title="Box 1234">B. 1234</abbr>
michael@0 70 <abbr class="extended-address" title="Suite 100">Ste. 100</abbr>
michael@0 71 <abbr class="street-address" title="123 Fake Street">123 Fake St.</abbr>
michael@0 72 <abbr class="locality" title="San Francisco">San Fran</abbr>
michael@0 73 <abbr class="region" title="California">CA</abbr>
michael@0 74 <abbr class="postal-code" title="12345-6789">12345</abbr>
michael@0 75 <abbr class="country-name" title="United States of America">USA</abbr>
michael@0 76 <abbr class="type" title="work">workplace</abbr>
michael@0 77 </span>
michael@0 78 <abbr class="tel" title="415.555.1234">1234</abbr>
michael@0 79 <abbr class="tel-type-value" title="work">workplace</abbr>
michael@0 80 <!-- mailer -->
michael@0 81 <abbr class="tz" title="-0700">Pacific Time</abbr>
michael@0 82 <span class="geo">
michael@0 83 <abbr class="latitude" title="37.77">Northern</abbr>
michael@0 84 <abbr class="longitude" title="-122.41">California</abbr>
michael@0 85 </span>
michael@0 86 <abbr class="title" title="President">pres.</abbr> and
michael@0 87 <abbr class="role" title="Chief">cat wrangler</abbr>
michael@0 88 <!-- <span class="agent"></span> -->
michael@0 89 <span class="org">
michael@0 90 <abbr class="organization-name" title="Intellicorp">foo</abbr>
michael@0 91 <abbr class="organization-unit" title="Intelligence">bar</abbr>
michael@0 92 </span>
michael@0 93 <!-- <abbr class="category" title=""></abbr> -->
michael@0 94 <abbr class="note" title="this is a note">this is not a note</abbr>
michael@0 95 <!-- <abbr class="rev" title=""></abbr> (revision datetime) -->
michael@0 96 <!-- <abbr class="sort-string" title=""></abbr> -->
michael@0 97 <abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr>
michael@0 98 <abbr class="class" title="public">pub</abbr>
michael@0 99 <!-- <abbr class="key" title=""></abbr> -->
michael@0 100 </p>
michael@0 101
michael@0 102 <!-- hCalendar -->
michael@0 103 <frameset>
michael@0 104 <frame id="frame1">
michael@0 105 <div>
michael@0 106 <span class="notAMicroformat" id="notme">
michael@0 107 <abbr> class="foo">I am not a microformat</abbr>
michael@0 108 <abbr> class="title">Foolish title, not a format</abbr>
michael@0 109 </span>
michael@0 110 </div>
michael@0 111 </frame>
michael@0 112 <frame id="frame3">
michael@0 113 <span class="geo" id="02-geo-abbr-latlong" >
michael@0 114 <abbr class="latitude" title="75.77">Far Northern</abbr>
michael@0 115 <abbr class="longitude" title="-122.41">Canada</abbr>
michael@0 116 </span>
michael@0 117 <frame id="frame2">
michael@0 118 <div class="vcalendar">
michael@0 119 <span class="vevent" id="15-calendar-xml-lang">
michael@0 120 <a class="url" href="http://www.web2con.com/">
michael@0 121 <span class="summary">Web 2.0 Conference</span>:
michael@0 122 <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
michael@0 123 <abbr class="dtend" title="2005-10-08">7</abbr>,
michael@0 124 at the <span class="location">Argent Hotel, San Francisco, CA</span>
michael@0 125 </a>
michael@0 126 </span>
michael@0 127 </div>
michael@0 128 </frame>
michael@0 129 </frameset>
michael@0 130
michael@0 131 <div id="secondnode">
michael@0 132 <span>some interesting content</span>
michael@0 133
michael@0 134 <!-- Geo Fire test once we know this is loaded.-->
michael@0 135 <iframe src="geo.html" onload="test_MicroformatsAPI();">
michael@0 136 </iframe>
michael@0 137
michael@0 138 <!-- adr -->
michael@0 139 <div class="adr" id="01-extended-address">
michael@0 140 <span class="extended-address">Park Bench</span>
michael@0 141 </div>
michael@0 142
michael@0 143 <div class="vcalendar">
michael@0 144 <span class="vevent" id="16-calendar-xml-lang">
michael@0 145 <a class="url" href="http://www.foo.com/">
michael@0 146 <span class="summary">Pseudo Conference</span>:
michael@0 147 <abbr class="dtstart" title="2008-04-01">April 1</abbr>-
michael@0 148 <abbr class="dtend" title="2008-04-03">April 3</abbr>,
michael@0 149 at the <span class="location">Argent Hotel, San Francisco, CA</span>
michael@0 150 </a>
michael@0 151 </span>
michael@0 152 </div>
michael@0 153 </div>
michael@0 154 </div>
michael@0 155 </body>
michael@0 156 </html>

mercurial