toolkit/components/microformats/tests/test_Microformats_getters.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/microformats/tests/test_Microformats_getters.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,156 @@
     1.4 +<html>
     1.5 +<head>
     1.6 +  <title>Testing Mixed Up Microformat APIs</title>
     1.7 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     1.9 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
    1.10 +</head>
    1.11 +<body id="contentbody">
    1.12 +  <pre id="test">
    1.13 +  <script class="testbody" type="text/javascript">
    1.14 +
    1.15 +  // Called from onload in iframe
    1.16 +  function test_MicroformatsAPI() {
    1.17 +    var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
    1.18 +
    1.19 +    // Test that we can get them all
    1.20 +    var mfs = [];
    1.21 +    mfs = Microformats.get("adr",
    1.22 +                           document.getElementById("content"),
    1.23 +                           {showHidden: true});
    1.24 +
    1.25 +    is(mfs.length, 2, "Two adr's in our array");
    1.26 +
    1.27 +    mfs = Microformats.get("geo",
    1.28 +                           document.getElementById("content"),
    1.29 +                           {recurseExternalFrames: true});
    1.30 +    is(mfs.length, 3, "Three geo's in our array");
    1.31 +
    1.32 +    mfs = Microformats.get("hCalendar",
    1.33 +                            document.getElementById("content"),
    1.34 +                            {recurseExternalFrames: false});
    1.35 +    // Should get the hCalendar whether we recurseExternalFrames or not.
    1.36 +    is(mfs.length, 2, "Two hCalendar returned not recursing frames");
    1.37 +
    1.38 +    mfs = Microformats.get("hCalendar",
    1.39 +                           document.getElementById("content"),
    1.40 +                           {recurseExternalFrames: true});
    1.41 +    is(mfs.length, 2, "Two hCalendars returned recursing frames");
    1.42 +
    1.43 +    mfs = Microformats.get("hCard",
    1.44 +                           document.getElementById("content"),
    1.45 +                           {recurseExternalFrames: true},
    1.46 +                           mfs);
    1.47 +    is(mfs.length, 3, "Two hCalendars and one hCard");
    1.48 +
    1.49 +    mfs = Microformats.get("hCalendar", document.getElementById("secondnode"));
    1.50 +
    1.51 +    is(mfs[0].summary, "Pseudo Conference", 
    1.52 +       "Make sure we get the proper hCalendar from the second level node");
    1.53 +    is(mfs.length, 1, "And we should only get one hCalendar not two from this node.");
    1.54 +  }
    1.55 +  </script>
    1.56 +  </pre>
    1.57 +  <div id="content">
    1.58 +    <!-- hCard -->
    1.59 +    <p class="vcard" id="23-abbr-title-everything">
    1.60 +      <!-- perhaps the most annoying test ever -->
    1.61 +      <abbr class="fn" title="John Doe">foo</abbr>
    1.62 +      <span class="n">
    1.63 +        <abbr class="honorific-prefix" title="Mister">Mr.</abbr>
    1.64 +        <abbr class="given-name" title="Jonathan">John</abbr>
    1.65 +        <abbr class="additional-name" title="John">J</abbr>
    1.66 +        <abbr class="family-name" title="Doe-Smith">Doe</abbr>
    1.67 +        <abbr class="honorific-suffix" title="Medical Doctor">M.D</abbr>
    1.68 +      </span>
    1.69 +      <abbr class="nickname" title="JJ">jj</abbr>
    1.70 +      <abbr class="bday" title="2006-04-04">April 4, 2006</abbr>
    1.71 +      <span class="adr">
    1.72 +        <abbr class="post-office-box" title="Box 1234">B. 1234</abbr>
    1.73 +        <abbr class="extended-address" title="Suite 100">Ste. 100</abbr>
    1.74 +        <abbr class="street-address" title="123 Fake Street">123 Fake St.</abbr>
    1.75 +        <abbr class="locality" title="San Francisco">San Fran</abbr>
    1.76 +        <abbr class="region" title="California">CA</abbr>
    1.77 +        <abbr class="postal-code" title="12345-6789">12345</abbr>
    1.78 +        <abbr class="country-name" title="United States of America">USA</abbr>
    1.79 +        <abbr class="type" title="work">workplace</abbr>
    1.80 +      </span>
    1.81 +      <abbr class="tel" title="415.555.1234">1234</abbr>
    1.82 +      <abbr class="tel-type-value" title="work">workplace</abbr>
    1.83 +  <!--       mailer  -->
    1.84 +      <abbr class="tz" title="-0700">Pacific Time</abbr>
    1.85 +      <span class="geo">
    1.86 +        <abbr class="latitude" title="37.77">Northern</abbr>
    1.87 +        <abbr class="longitude" title="-122.41">California</abbr>
    1.88 +      </span>
    1.89 +      <abbr class="title" title="President">pres.</abbr> and
    1.90 +      <abbr class="role" title="Chief">cat wrangler</abbr>
    1.91 +  <!--       <span class="agent"></span> -->
    1.92 +      <span class="org">
    1.93 +        <abbr class="organization-name" title="Intellicorp">foo</abbr>
    1.94 +        <abbr class="organization-unit" title="Intelligence">bar</abbr>
    1.95 +      </span>
    1.96 +  <!--       <abbr class="category" title=""></abbr> -->
    1.97 +      <abbr class="note" title="this is a note">this is not a note</abbr>
    1.98 +  <!--       <abbr class="rev" title=""></abbr>  (revision datetime) -->
    1.99 +  <!--       <abbr class="sort-string" title=""></abbr> -->
   1.100 +      <abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr>
   1.101 +      <abbr class="class" title="public">pub</abbr>
   1.102 +  <!--       <abbr class="key" title=""></abbr> -->
   1.103 +    </p>
   1.104 +
   1.105 +    <!-- hCalendar -->
   1.106 +    <frameset>
   1.107 +      <frame id="frame1">
   1.108 +        <div>
   1.109 +          <span class="notAMicroformat" id="notme">
   1.110 +            <abbr> class="foo">I am not a microformat</abbr>
   1.111 +            <abbr> class="title">Foolish title, not a format</abbr>
   1.112 +          </span>
   1.113 +        </div>
   1.114 +      </frame>
   1.115 +      <frame id="frame3">
   1.116 +        <span class="geo" id="02-geo-abbr-latlong" >
   1.117 +          <abbr class="latitude" title="75.77">Far Northern</abbr>
   1.118 +          <abbr class="longitude" title="-122.41">Canada</abbr>
   1.119 +        </span>
   1.120 +      <frame id="frame2">
   1.121 +        <div class="vcalendar">
   1.122 +          <span class="vevent" id="15-calendar-xml-lang">
   1.123 +            <a class="url" href="http://www.web2con.com/">
   1.124 +            <span class="summary">Web 2.0 Conference</span>: 
   1.125 +            <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
   1.126 +            <abbr class="dtend" title="2005-10-08">7</abbr>,
   1.127 +            at the <span class="location">Argent Hotel, San Francisco, CA</span>
   1.128 +            </a>
   1.129 +          </span>
   1.130 +        </div>
   1.131 +      </frame>
   1.132 +    </frameset>
   1.133 +
   1.134 +    <div id="secondnode">
   1.135 +      <span>some interesting content</span>
   1.136 +
   1.137 +      <!-- Geo Fire test once we know this is loaded.-->
   1.138 +      <iframe src="geo.html" onload="test_MicroformatsAPI();">
   1.139 +      </iframe>
   1.140 +
   1.141 +      <!-- adr -->
   1.142 +      <div class="adr" id="01-extended-address">
   1.143 +        <span class="extended-address">Park Bench</span>
   1.144 +      </div>
   1.145 +
   1.146 +      <div class="vcalendar">
   1.147 +        <span class="vevent" id="16-calendar-xml-lang">
   1.148 +          <a class="url" href="http://www.foo.com/">
   1.149 +          <span class="summary">Pseudo Conference</span>: 
   1.150 +          <abbr class="dtstart" title="2008-04-01">April 1</abbr>-
   1.151 +          <abbr class="dtend" title="2008-04-03">April 3</abbr>,
   1.152 +          at the <span class="location">Argent Hotel, San Francisco, CA</span>
   1.153 +          </a>
   1.154 +        </span>
   1.155 +      </div>
   1.156 +    </div>
   1.157 +  </div>
   1.158 +</body>
   1.159 +</html>

mercurial