toolkit/components/microformats/tests/test_Microformats_negative.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <html>
     2 <head>
     3   <title>Testing Mixed Up Microformat APIs</title>
     4   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     5   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
     7 </head>
     8 <body id="contentbody">
     9   <div id="testhere">
    10     <!-- Frames -->
    11     <frameset>
    12       <frame id="frame1">
    13         <div>
    14           <span class="notAMicroformat" id="notme">
    15             <abbr> class="foo">I am not a microformat</abbr>
    16             <abbr> class="title">Foolish title, not a format</abbr>
    17           </span>
    18         </div>
    19       </frame>
    20       <frame id="frame2">
    21         <div class="vcalendar">
    22           <span class="vevent" id="15-calendar-xml-lang">
    23             <a class="url" href="http://www.web2con.com/">
    24             <span class="summary">Web 2.0 Conference</span>: 
    25             <abbr class="dtend" title="2005-10-08">7</abbr>,
    26             at the <span class="location">Argent Hotel, San Francisco, CA</span>
    27             </a>
    28           </span>
    29         </div>
    30       </frame>
    31     </frameset>
    32   </div>
    34   <div id="content">
    35     <!-- some really messed up markup-->
    36     <p class="vcard" id="23-abbr-title-everything">
    37       <div id="random div no ending div either">
    38       <abbr class="fn" title="John Doe">foo</abbr>
    39       <span class="n"/>
    40       <abbr class="foo" title="JJ">jj</abbr>
    41       <abbr class="free" title="2006-04-04">April 4, 2006</abbr>
    42       <span class="adr">
    43         <abbr class="invalid" title="Box 1234">B. 1234</abbr>
    44         <abbr class="extended-address" title="Suite 100">Ste. 100</abbr>
    45         <abbr class="street-address" title="123 Fake Street"/>
    46         <abbr class="locality" title="San Francisco">San Fran</abbr>
    47         <abbr class="region" title="California">CA</abbr>
    48         <abbr class="postal-code" title="12345-6789">12345</abbr>
    49         <abbr class="country-name" title="United States of America">USA</abbr>
    50         <abbr class="typo" titl="work">workplace</abbr>
    51       </span>
    52       <span class="org">
    53         <abbr class="organization-name" title="Intellicorp">foo</abbr>
    54         <abbr class="organization-unit" title="Intelligence">bar</abbr>
    55   <!--       <abbr class="category" title=""></abbr> -->
    56       <abbr class="note" title="this is a note">this is not a note</abbr>
    57   <!--       <abbr class="rev" title=""></abbr>  (revision datetime) -->
    58   <!--       <abbr class="sort-string" title=""></abbr> -->
    59       <abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr>
    60       <abbr class="class" title="public">pub</abbr>
    61   <!--       <abbr class="key" title=""></abbr> -->
    62       </span>
    64   <!-- Ok, the test, here we go -->
    65   <pre id="test">
    66   <script class="testbody" type="text/javascript">
    68   test_MicroformatsAPI();
    70   function test_MicroformatsAPI() {
    71     var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
    73     // Test to see if we can get the invalid vcard
    74     var mfs = Microformats.get("hCard",
    75                                document.getElementById("content"),
    76                                { });
    78     is(mfs.length, 0, "Check that we can't get invalid vcard");
    80     // Invalid hCalendar - doesn't have a dtstart
    81     mfs = Microformats.get("hCalendar",
    82                            document.getElementById("testhere"),
    83                            {recurseExternalFrames: true});
    84     is(mfs.length, 0, "Check that we don't pick up invalid MFs.");
    86     mfs = Microformats.get("notAMicroformat",
    87                            document.getElementById("testhere"),
    88                            {recurseExternalFrames: true});
    90     is(mfs, null, "No microformat called notAMicroformat");
    92     // What if we try another way?
    93     is(Microformats.isMicroformat(document.getElementById("notme")), false,
    94        "Check that the NotAMicroformat is still not a microformat");
    96     // Attempt to physically add one to the object
    97     try {
    98       Microformats.push("notAMicroformat");
    99     } catch (ex) {
   100       ok(true, "Check thrown exception when adding to microformats object");
   101     }
   103     // Attempt to delete one from the object
   104     try {
   105       Microformats.pop();
   106     } catch (ex) {
   107       ok(true, "Check that exception thrown when removing items from Microformats");
   108     }
   109   }
   110   </script>
   111 </body>
   112 </html>

mercurial