toolkit/components/microformats/tests/test_Microformats_hCalendar.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.

     1 <html>
     2 <head>
     3   <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
     4   <title>Testing Microformats.js (hCalendar)</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     7   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
     8 </head>
     9 <body>
    10 <div id="content" style="display: none">
    12   From http://hg.microformats.org/tests
    14   <div class="vevent" id="01-component-vevent-dtstart-date">
    15     <div>Dates: <abbr class="dtstart" title="19970903">September 3, 1997</abbr></div>
    16   </div>
    18   <div class="vevent" id="02-component-vevent-dtstart-datetime">
    19     <div>Dates: <abbr class="dtstart" title="19970903T163000Z">September 3, 1997, 16:30</abbr></div>
    20   </div>
    22   <div class="vevent" id="03-component-vevent-dtend-date">
    23     <div>Dates: <abbr class="dtstart" title="19970903">September 3, 1997</abbr>
    24     <abbr class="dtend" title="19970904">( all day )</abbr></div>
    25   </div>
    27   <div class="vevent" id="04-component-vevent-dtend-datetime">
    28     <div>Date: <abbr class="dtstart" title="19970903T160000Z">September 3, 1997 at 4pm</abbr>
    29     <abbr class="dtend" title="19970903T180000Z"> for 2 hours.</abbr></div>
    30   </div>
    32   <div class="vcalendar">
    33     <span class="vevent" id="05-calendar-simple">
    34       <a class="url" href="http://www.web2con.com/">
    35         <span class="summary">Web 2.0 Conference</span>: 
    36         <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
    37         <abbr class="dtend" title="2005-10-08">7</abbr>,
    38         at the <span class="location">Argent Hotel, San Francisco, CA</span>
    39       </a>
    40     </span>
    41   </div>
    43   <p class="vevent" id="06-component-vevent-uri-relative">
    44     <a class="url summary" href="/squidlist/calendar/12279/2006/1/15">Bad Movie Night - Gigli (blame mike spiegelman)</a>
    45     <br />
    46     <abbr class="dtstart" title="20060115T000000">Sun, Jan 15 : 8pm</abbr>
    47     <br />
    48   </p>
    50   <div class="vevent" id="07-component-vevent-description-simple">
    51     <div class="description">Project xyz Review Meeting Minutes</div>
    52   </div>
    54   <div class="aaa vevent" id="08-component-vevent-multiple-classes">
    55     <a class="bbb url" href="http://www.web2con.com/">
    56       <span class="ccc summary">Web 2.0 Conference</span>: 
    57       <abbr class="ddd dtstart" title="2005-10-05">October 5</abbr>-
    58       <abbr class="eee dtend" title="2005-10-08">7</abbr>,
    59       at the <span class="fff location">Argent Hotel, San Francisco, CA</span>
    60     </a>
    61   </div>
    63   <ul>
    64     <li class="vevent" id="09-component-vevent-summary-in-img-alt">
    65      <a class="url" href="http://conferences.oreillynet.com/et2006/">
    66       <img style="display:block" class="summary" 
    67        src="http://mochi.test:8888/tests/browser/microformats/test/picture.png"
    68        alt="O'Reilly Emerging Technology Conference" />
    69       <abbr class="dtstart" title="20060306">
    70         3/6</abbr>-<abbr class="dtend" title="20060310">9</abbr>
    71       @
    72       <span class="location">
    73          Manchester Grand Hyatt in San Diego, CA
    74        </span>
    75      </a>
    76     </li>
    77   </ul>
    79   <div class="vcalendar">
    80     <div class="vevent" id="10-component-vevent-entity">
    81       <div class="summary">Cricket &amp; Tennis Centre</div>
    82       <div class="description">Melbourne&apos;s Cricket &amp; Tennis Centres are in the heart of the city</div>
    83     </div>
    84   </div>
    86   <p class="schedule vevent" id="11-component-vevent-summary-in-subelements">
    87     <span class="summary">
    88       <span style="font-weight:bold; color: #3E4876;">Welcome!</span>
    89       <a href="/cs/web2005/view/e_spkr/1852">John Battelle</a>,
    90       <a href="/cs/web2005/view/e_spkr/416">Tim O'Reilly</a>
    91     </span>
    92     <br />
    93     <b>Time:</b>
    94     <abbr class="dtstart" title="20051005T1630-0700">4:30pm</abbr>-
    95     <abbr class="dtend" title="20051005T1645-0700">4:45pm
    96     </abbr>
    97   </p>
    99   <p class="vevent" id="12-component-vevent-summary-url-in-same-class">
   100     <a class="url summary" href="http://www.laughingsquid.com/squidlist/calendar/12377/2006/1/25">Art Reception for Tom Schultz and Felix Macnee</a>
   101     <br />
   102     <abbr class="dtstart" title="20060125T000000">Wed, Jan 25 : 6:00 pm - 9:00 pm</abbr>
   103     <br />
   104   </p>
   106   <div class="vcalendar">
   107     <div class="vevent" id="13-component-vevent-summary-url-property">
   108       <span class="summary">
   109         <a class="url" href="http://dps1.travelocity.com/dparcobrand.ctl?smls=Y&amp;Service=YHOE&amp;.intl=us&amp;aln_name=AA&amp;flt_num=1655&amp;dep_arp_name=&amp;arr_arp_name=&amp;dep_dt_dy_1=23&amp;dep_dt_mn_1=Jan&amp;dep_dt_yr_1=2006&amp;dep_tm_1=9:00am">ORD-SFO/AA 1655</a>
   110       </span>
   111     </div>
   112   </div>
   114   <div class="vcalendar">
   115     <span class="vevent" id="15-calendar-xml-lang">
   116       <a class="url" href="http://www.web2con.com/">
   117       <span class="summary">Web 2.0 Conference</span>: 
   118       <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
   119       <abbr class="dtend" title="2005-10-08">7</abbr>,
   120       at the <span class="location">Argent Hotel, San Francisco, CA</span>
   121       </a>
   122     </span>
   123   </div>
   125     <div class="vcalendar">
   126       <span class="vevent" id="16-calendar-force-outlook">
   127         <a class="url" href="http://www.web2con.com/">
   128           <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
   129           <abbr class="dtend" title="2005-10-08">7</abbr>,
   130           at the <span class="location">Argent Hotel, San Francisco, CA</span>
   131         </a>
   132       </span>
   133     </div>
   135   <p class="vevent" id="17-component-vevent-description-value-in-subelements">
   136     <span class="description">
   137       RESOLUTION: to have a
   138       <b class="summary">3rd PAW ftf meeting</b> 
   139       <abbr class="dtstart" title="2006-01-18">18</abbr>-<abbr class="dtend" title="2006-01-20">19 Jan</abbr> in 
   140       <em class="location">Maryland</em>; location contingent on confirmation from timbl</span>
   141   </p>
   143   <div class="vevent" id="18-component-vevent-uid.1">
   144     <div>UID: <span class="uid">http://example.com/foo.html</span></div>
   145   </div>
   146   <div class="vevent" id="18-component-vevent-uid.2">
   147     UID: <a class="uid" href="http://example.com/foo.html">another hcal event</a>
   148   </div>
   150   <div class="vevent" id="18-component-vevent-uid.3">
   151     UID: <object class="uid" data="http://example.com/foo.html">another hcal event</object>
   152   </div>
   154   <div class="vevent" id="18-component-vevent-uid.4">
   155     UID: <map id="foo"><area alt="uid" class="uid" href="http://example.com/foo.html" /></map>
   156   </div>
   158   <div class="vevent" id="18-component-vevent-uid.5">
   159     UID: <img class="uid" alt="uid" src="http://example.com/foo.html" />
   160   </div>
   162   <div class="vcalendar">
   163     <div class="vevent" id="19-calendar-attachments">
   164       <div>Start Time: <abbr class="dtstart" title="19970324T123000Z">March 24, 1997 12:30 UTC</abbr></div>
   165       <div class="summary">Calendaring Interoperability Planning Meeting</div>
   167       <div>Attachments: 
   168           <ul>
   169               <li><a class="attach" href="http://microformats.org/img/logo.gif">microformats logo</a></li>
   170               <li><a class="attach" type="application/postscript" href="ftp://xyzCorp.com/pub/conf/bkgrnd.ps">ftp://xyzCorp.com/pub/conf/bkgrnd.ps</a></li>
   171           </ul>
   172       </div>
   173     </div>
   174   </div>
   176   <div class="vevent" id="empty-description">
   177     <span class="description"></span>
   178   </div>
   181 </div>
   183 <pre id="test">
   184 <script class="testbody" type="text/javascript">
   186 test_Microformats();
   187 test_hCard();
   189 function test_Microformats() {
   190   var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
   192   ok(Microformats, "Check global access to Microformats");
   193 };
   195 function test_hCard() {
   196   var hCalendar = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").hCalendar;
   198   var hcalendar;
   200   hcalendar = new hCalendar(document.getElementById("01-component-vevent-dtstart-date"));
   202   is(hcalendar.dtstart, "1997-09-03", "01-component-vevent-dtstart-date - dtstart");
   204   hcalendar = new hCalendar(document.getElementById("02-component-vevent-dtstart-datetime"));
   206   is(hcalendar.dtstart, "1997-09-03T16:30:00Z", "02-component-vevent-dtstart-datetime - dtstart");
   208   hcalendar = new hCalendar(document.getElementById("03-component-vevent-dtend-date"));
   210   is(hcalendar.dtstart, "1997-09-03", "03-component-vevent-dtend-date - dtstart");
   211   is(hcalendar.dtend, "1997-09-04", "03-component-vevent-dtend-date - dtend");
   214   hcalendar = new hCalendar(document.getElementById("04-component-vevent-dtend-datetime"));
   216   is(hcalendar.dtstart, "1997-09-03T16:00:00Z", "04-component-vevent-dtend-datetime - dtstart");
   217   is(hcalendar.dtend, "1997-09-03T18:00:00Z", "04-component-vevent-dtend-datetime - dtend");
   219   hcalendar = new hCalendar(document.getElementById("05-calendar-simple"));
   221   is(hcalendar.dtstart, "2005-10-05", "05-calendar-simple - dtstart");
   222   is(hcalendar.dtend, "2005-10-08", "05-calendar-simple - dtend");
   223   is(hcalendar.url, "http://www.web2con.com/", "05-calendar-simple - url");
   224   is(hcalendar.summary, "Web 2.0 Conference", "05-calendar-simple - summary");
   225   is(hcalendar.location, "Argent Hotel, San Francisco, CA", "05-calendar-simple - location");
   227   hcalendar = new hCalendar(document.getElementById("06-component-vevent-uri-relative"));
   228   is(hcalendar.url, "http://mochi.test:8888/squidlist/calendar/12279/2006/1/15", "06-component-vevent-uri-relative - url");
   229   is(hcalendar.summary, "Bad Movie Night - Gigli (blame mike spiegelman)", "06-component-vevent-uri-relative - summary");
   230   is(hcalendar.dtstart, "2006-01-15T00:00:00", "06-component-vevent-uri-relative - dtstart");
   232   hcalendar = new hCalendar(document.getElementById("07-component-vevent-description-simple"));
   233   is(hcalendar.description, "Project xyz Review Meeting Minutes", "07-component-vevent-description-simple - description");
   235   hcalendar = new hCalendar(document.getElementById("08-component-vevent-multiple-classes"));
   236   is(hcalendar.dtstart, "2005-10-05", "08-component-vevent-multiple-classes - dtstart");
   237   is(hcalendar.dtend, "2005-10-08", "08-component-vevent-multiple-classes - dtend");
   238   is(hcalendar.url, "http://www.web2con.com/", "08-component-vevent-multiple-classes - url");
   239   is(hcalendar.summary, "Web 2.0 Conference", "08-component-vevent-multiple-classes - summary");
   240   is(hcalendar.location, "Argent Hotel, San Francisco, CA", "08-component-vevent-multiple-classes - location");
   242   hcalendar = new hCalendar(document.getElementById("09-component-vevent-summary-in-img-alt"));
   243   is(hcalendar.dtstart, "2006-03-06", "09-component-vevent-summary-in-img-alt - dtstart");
   244   is(hcalendar.dtend, "2006-03-10", "09-component-vevent-summary-in-img-alt - dtend");
   245   is(hcalendar.url, "http://conferences.oreillynet.com/et2006/", "09-component-vevent-summary-in-img-alt - url");
   246   is(hcalendar.summary, "O'Reilly Emerging Technology Conference", "09-component-vevent-summary-in-img-alt - summary");
   247   is(hcalendar.location, "Manchester Grand Hyatt in San Diego, CA", "09-component-vevent-summary-in-img-alt - location");
   249   hcalendar = new hCalendar(document.getElementById("10-component-vevent-entity"));
   250   is(hcalendar.summary, "Cricket & Tennis Centre", "10-component-vevent-entity - summary");
   251   is(hcalendar.description, "Melbourne's Cricket & Tennis Centres are in the heart of the city", "10-component-vevent-entity - description");
   253   hcalendar = new hCalendar(document.getElementById("11-component-vevent-summary-in-subelements"));
   254   is(hcalendar.dtstart, "2005-10-05T16:30:00-0700", "11-component-vevent-summary-in-subelements - dtstart");
   255   is(hcalendar.dtend, "2005-10-05T16:45:00-0700", "11-component-vevent-summary-in-subelements - dtend");
   256   is(hcalendar.summary, "Welcome! John Battelle, Tim O'Reilly", "11-component-vevent-summary-in-subelements - summary");
   258   hcalendar = new hCalendar(document.getElementById("12-component-vevent-summary-url-in-same-class"));
   259   is(hcalendar.dtstart, "2006-01-25T00:00:00", "12-component-vevent-summary-url-in-same-class - dtstart");
   260   is(hcalendar.summary, "Art Reception for Tom Schultz and Felix Macnee", "12-component-vevent-summary-url-in-same-class - summary");
   261   is(hcalendar.url, "http://www.laughingsquid.com/squidlist/calendar/12377/2006/1/25", "12-component-vevent-summary-url-in-same-class - url");
   263   hcalendar = new hCalendar(document.getElementById("13-component-vevent-summary-url-property"));
   264   is(hcalendar.summary, "ORD-SFO/AA 1655", "13-component-vevent-summary-url-property - summary");
   265   is(hcalendar.url, "http://dps1.travelocity.com/dparcobrand.ctl?smls=Y&Service=YHOE&.intl=us&aln_name=AA&flt_num=1655&dep_arp_name=&arr_arp_name=&dep_dt_dy_1=23&dep_dt_mn_1=Jan&dep_dt_yr_1=2006&dep_tm_1=9:00am", "13-component-vevent-summary-url-property - url");
   267   hcalendar = new hCalendar(document.getElementById("15-calendar-xml-lang"));
   268   is(hcalendar.dtend, "2005-10-08", "15-calendar-xml-lang - dtend");
   269   is(hcalendar.dtstart, "2005-10-05", "15-calendar-xml-lang - dtstart");
   270   is(hcalendar.location, "Argent Hotel, San Francisco, CA", "15-calendar-xml-lang - location");
   271   is(hcalendar.summary, "Web 2.0 Conference", "15-calendar-xml-lang - summary");
   272   is(hcalendar.url, "http://www.web2con.com/", "15-calendar-xml-lang - url");
   274   hcalendar = new hCalendar(document.getElementById("16-calendar-force-outlook"));
   275   is(hcalendar.dtend, "2005-10-08", "16-calendar-force-outlook - dtend");
   276   is(hcalendar.dtstart, "2005-10-05", "16-calendar-force-outlook - dtstart");
   277   is(hcalendar.location, "Argent Hotel, San Francisco, CA", "16-calendar-force-outlook - location");
   278   is(hcalendar.url, "http://www.web2con.com/", "16-calendar-force-outlook - url");
   280   hcalendar = new hCalendar(document.getElementById("17-component-vevent-description-value-in-subelements"));
   281   is(hcalendar.description, "RESOLUTION: to have a 3rd PAW ftf meeting 18-19 Jan in Maryland; location contingent on confirmation from timbl", "17-component-vevent-description-value-in-subelements - description");
   282   is(hcalendar.dtstart, "2006-01-18", "17-component-vevent-description-value-in-subelements - dtstart");
   283   is(hcalendar.dtend, "2006-01-20", "17-component-vevent-description-value-in-subelements - dtend");
   284   is(hcalendar.location, "Maryland", "17-component-vevent-description-value-in-subelements - location");
   285   is(hcalendar.summary, "3rd PAW ftf meeting", "17-component-vevent-description-value-in-subelements - summary");
   287   hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.1"));
   289   hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.2"));
   291   hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.3"));
   293   hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.4"));
   295   hcalendar = new hCalendar(document.getElementById("18-component-vevent-uid.5"));
   297   hcalendar = new hCalendar(document.getElementById("19-calendar-attachments"));
   299   hcalendar = new hCalendar(document.getElementById("empty-description"));
   300   is (hcalendar.description, "", "Empty description");
   301 }
   303 </script>
   304 </pre>
   305 </body>
   306 </html>

mercurial