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