1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/microformats/tests/test_Microformats_negative.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 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 + <div id="testhere"> 1.13 + <!-- Frames --> 1.14 + <frameset> 1.15 + <frame id="frame1"> 1.16 + <div> 1.17 + <span class="notAMicroformat" id="notme"> 1.18 + <abbr> class="foo">I am not a microformat</abbr> 1.19 + <abbr> class="title">Foolish title, not a format</abbr> 1.20 + </span> 1.21 + </div> 1.22 + </frame> 1.23 + <frame id="frame2"> 1.24 + <div class="vcalendar"> 1.25 + <span class="vevent" id="15-calendar-xml-lang"> 1.26 + <a class="url" href="http://www.web2con.com/"> 1.27 + <span class="summary">Web 2.0 Conference</span>: 1.28 + <abbr class="dtend" title="2005-10-08">7</abbr>, 1.29 + at the <span class="location">Argent Hotel, San Francisco, CA</span> 1.30 + </a> 1.31 + </span> 1.32 + </div> 1.33 + </frame> 1.34 + </frameset> 1.35 + </div> 1.36 + 1.37 + <div id="content"> 1.38 + <!-- some really messed up markup--> 1.39 + <p class="vcard" id="23-abbr-title-everything"> 1.40 + <div id="random div no ending div either"> 1.41 + <abbr class="fn" title="John Doe">foo</abbr> 1.42 + <span class="n"/> 1.43 + <abbr class="foo" title="JJ">jj</abbr> 1.44 + <abbr class="free" title="2006-04-04">April 4, 2006</abbr> 1.45 + <span class="adr"> 1.46 + <abbr class="invalid" title="Box 1234">B. 1234</abbr> 1.47 + <abbr class="extended-address" title="Suite 100">Ste. 100</abbr> 1.48 + <abbr class="street-address" title="123 Fake Street"/> 1.49 + <abbr class="locality" title="San Francisco">San Fran</abbr> 1.50 + <abbr class="region" title="California">CA</abbr> 1.51 + <abbr class="postal-code" title="12345-6789">12345</abbr> 1.52 + <abbr class="country-name" title="United States of America">USA</abbr> 1.53 + <abbr class="typo" titl="work">workplace</abbr> 1.54 + </span> 1.55 + <span class="org"> 1.56 + <abbr class="organization-name" title="Intellicorp">foo</abbr> 1.57 + <abbr class="organization-unit" title="Intelligence">bar</abbr> 1.58 + <!-- <abbr class="category" title=""></abbr> --> 1.59 + <abbr class="note" title="this is a note">this is not a note</abbr> 1.60 + <!-- <abbr class="rev" title=""></abbr> (revision datetime) --> 1.61 + <!-- <abbr class="sort-string" title=""></abbr> --> 1.62 + <abbr class="uid" title="abcdefghijklmnopqrstuvwxyz">alpha</abbr> 1.63 + <abbr class="class" title="public">pub</abbr> 1.64 + <!-- <abbr class="key" title=""></abbr> --> 1.65 + </span> 1.66 + 1.67 + <!-- Ok, the test, here we go --> 1.68 + <pre id="test"> 1.69 + <script class="testbody" type="text/javascript"> 1.70 + 1.71 + test_MicroformatsAPI(); 1.72 + 1.73 + function test_MicroformatsAPI() { 1.74 + var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats; 1.75 + 1.76 + // Test to see if we can get the invalid vcard 1.77 + var mfs = Microformats.get("hCard", 1.78 + document.getElementById("content"), 1.79 + { }); 1.80 + 1.81 + is(mfs.length, 0, "Check that we can't get invalid vcard"); 1.82 + 1.83 + // Invalid hCalendar - doesn't have a dtstart 1.84 + mfs = Microformats.get("hCalendar", 1.85 + document.getElementById("testhere"), 1.86 + {recurseExternalFrames: true}); 1.87 + is(mfs.length, 0, "Check that we don't pick up invalid MFs."); 1.88 + 1.89 + mfs = Microformats.get("notAMicroformat", 1.90 + document.getElementById("testhere"), 1.91 + {recurseExternalFrames: true}); 1.92 + 1.93 + is(mfs, null, "No microformat called notAMicroformat"); 1.94 + 1.95 + // What if we try another way? 1.96 + is(Microformats.isMicroformat(document.getElementById("notme")), false, 1.97 + "Check that the NotAMicroformat is still not a microformat"); 1.98 + 1.99 + // Attempt to physically add one to the object 1.100 + try { 1.101 + Microformats.push("notAMicroformat"); 1.102 + } catch (ex) { 1.103 + ok(true, "Check thrown exception when adding to microformats object"); 1.104 + } 1.105 + 1.106 + // Attempt to delete one from the object 1.107 + try { 1.108 + Microformats.pop(); 1.109 + } catch (ex) { 1.110 + ok(true, "Check that exception thrown when removing items from Microformats"); 1.111 + } 1.112 + } 1.113 + </script> 1.114 +</body> 1.115 +</html>