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

michael@0 1 <html>
michael@0 2 <head>
michael@0 3 <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
michael@0 4 <title>Testing Microformats.js (geo)</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link>
michael@0 8 </head>
michael@0 9 <body>
michael@0 10 <div id="content" style="display: none">
michael@0 11
michael@0 12 <span class="geo" id="01-geo-basic">
michael@0 13 <span class="latitude">37.77</span>
michael@0 14 <span class="longitude">-122.411</span>
michael@0 15 </span>
michael@0 16
michael@0 17
michael@0 18 <span class="geo" id="01-geo-abbr-latlong" >
michael@0 19 <abbr class="latitude" title="37.77">Northern</abbr>
michael@0 20 <abbr class="longitude" title="-122.41">California</abbr>
michael@0 21 </span>
michael@0 22
michael@0 23 <abbr class="geo" id="01-geo-abbr" title="30.267991;-97.739568">Paradise</abbr>
michael@0 24
michael@0 25 <span class="vcard">
michael@0 26 <span class="fn org">John Doe</span>
michael@0 27 <abbr class="geo" id="02-geo-vcard-01" title="37.77;-122.41"></abbr>
michael@0 28 </span>
michael@0 29
michael@0 30 <span class="vcard">
michael@0 31 <span class="fn org">John Doe</span>
michael@0 32 <abbr class="geo" id="02-geo-vcard-02" title="37.77;-122.41">Northern California</abbr>
michael@0 33 </span>
michael@0 34
michael@0 35 <span class="vevent">
michael@0 36 <span class="summary">SXSW Interactive (South by Southwest)</span>
michael@0 37 <ABBR title="20080307" class="dtstart">Friday, March 7, 2008</ABBR>
michael@0 38 -
michael@0 39 <ABBR title="20080311" class="dtend">Tuesday, March 11, 2008</ABBR>
michael@0 40 <abbr class="geo" id="02-geo-vevent-01" title="30.2622;-97.7399"></abbr>
michael@0 41 </span>
michael@0 42
michael@0 43 <span class="vevent">
michael@0 44 <span class="summary">SXSW Interactive (South by Southwest)</span>
michael@0 45 <ABBR title="20080307" class="dtstart">Friday, March 7, 2008</ABBR>
michael@0 46 -
michael@0 47 <ABBR title="20080311" class="dtend">Tuesday, March 11, 2008</ABBR>
michael@0 48 <abbr class="geo" id="02-geo-vevent-02" title="30.2622;-97.7399">Convention Center</abbr>
michael@0 49 </span>
michael@0 50
michael@0 51 <h3>Legal geos</h3>
michael@0 52 <ul>
michael@0 53 <li><span class="geo" id="legal_geo1"><span class="latitude">0</span>,<span class="longitude">0</span></span></li>
michael@0 54 <li><span class="geo" id="legal_geo2"><span class="latitude">0.0</span>,<span class="longitude">0.0</span></span></li>
michael@0 55 <li><span class="geo" id="legal_geo3"><span class="latitude">0.</span>,<span class="longitude">0.</span></span></li>
michael@0 56 </ul>
michael@0 57 <h3>Illegal geos</h3>
michael@0 58
michael@0 59 <ul>
michael@0 60 <li><span class="geo" id="ill_geo1"><span class="latitude">abc</span>,<span class="longitude">def</span></span></li>
michael@0 61 <li><span class="geo" id="ill_geo2"><span class="latitude">12.s2</span>,<span class="longitude">1d.23</span></span></li>
michael@0 62 <li><span class="geo" id="ill_geo3"><span class="latitude">999.99</span>,<span class="longitude">999</span></span></li>
michael@0 63 <li><span class="geo" id="ill_geo4"><span class="latitude">-181</span>,<span class="longitude">-361</span></span></li>
michael@0 64 <li><span class="geo" id="ill_geo5">abc;def</span></li>
michael@0 65 <li><span class="geo" id="ill_geo6">12.s2;1d.23</span></li>
michael@0 66 <li><span class="geo" id="ill_geo7">999.99;999</span></li>
michael@0 67 <li><span class="geo" id="ill_geo8">-181;-361</span></li>
michael@0 68 <li><span class="geo" id="ill_geo9">-18;;-31</span></li>
michael@0 69 <li><ABBR title="+23.70000;+90.30000" class="extra_geo">Dhaka, Bangladesh</ABBR></li>
michael@0 70 <li><span class="geo" id="zero_geo">0;0</span></li>
michael@0 71 </ul>
michael@0 72
michael@0 73
michael@0 74
michael@0 75
michael@0 76
michael@0 77
michael@0 78 </div>
michael@0 79 <pre id="test">
michael@0 80 <script class="testbody" type="text/javascript">
michael@0 81
michael@0 82 test_Microformats();
michael@0 83 test_geo();
michael@0 84
michael@0 85 function test_Microformats() {
michael@0 86 var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats;
michael@0 87
michael@0 88 ok(Microformats, "Check global access to Microformats");
michael@0 89 };
michael@0 90
michael@0 91 function test_geo() {
michael@0 92 var geo = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").geo;
michael@0 93
michael@0 94 var Geo;
michael@0 95
michael@0 96 Geo = new geo(document.getElementById("01-geo-basic"));
michael@0 97
michael@0 98 is(Geo.latitude, "37.77", "01-geo-basic - latitude");
michael@0 99 is(Geo.longitude, "-122.411", "01-geo-basic - longitude");
michael@0 100
michael@0 101 Geo = new geo(document.getElementById("01-geo-abbr-latlong"));
michael@0 102
michael@0 103 is(Geo.latitude, "37.77", "02-geo-abbr-latlong - latitude");
michael@0 104 is(Geo.longitude, "-122.41", "02-geo-abbr-latlong - longitude");
michael@0 105
michael@0 106 Geo = new geo(document.getElementById("01-geo-abbr"));
michael@0 107
michael@0 108 is(Geo.latitude, "30.267991", "01-geo-abbr - latitude");
michael@0 109 is(Geo.longitude, "-97.739568", "01-geo-abbr - longitude");
michael@0 110
michael@0 111 Geo = new geo(document.getElementById("02-geo-vcard-01"));
michael@0 112
michael@0 113 is(Geo.toString(), "John Doe", "02-geo-vcard-01");
michael@0 114
michael@0 115 Geo = new geo(document.getElementById("02-geo-vcard-02"));
michael@0 116
michael@0 117 is(Geo.toString(), "Northern California", "02-geo-vcard-02");
michael@0 118
michael@0 119 Geo = new geo(document.getElementById("02-geo-vevent-01"));
michael@0 120
michael@0 121 is(Geo.toString(), "SXSW Interactive (South by Southwest)", "02-geo-vevent-01");
michael@0 122
michael@0 123 Geo = new geo(document.getElementById("02-geo-vevent-02"));
michael@0 124
michael@0 125 is(Geo.toString(), "Convention Center", "02-geo-vevent-02");
michael@0 126
michael@0 127 Geo = new geo(document.getElementById("legal_geo1"));
michael@0 128
michael@0 129 is(Geo.latitude, 0, "legal_geo1 - lat");
michael@0 130 is(Geo.longitude, 0, "legal_geo1 - long");
michael@0 131
michael@0 132 Geo = new geo(document.getElementById("legal_geo2"));
michael@0 133
michael@0 134 is(Geo.latitude, 0, "legal_geo2 - lat");
michael@0 135 is(Geo.longitude, 0, "legal_geo2 - long");
michael@0 136
michael@0 137 Geo = new geo(document.getElementById("legal_geo3"));
michael@0 138
michael@0 139 is(Geo.latitude, 0, "legal_geo3 - lat");
michael@0 140 is(Geo.longitude, 0, "legal_geo3 - long");
michael@0 141
michael@0 142
michael@0 143
michael@0 144
michael@0 145 try {
michael@0 146 Geo = new geo(document.getElementById("ill_geo1"), true);
michael@0 147 ok(0, "ill_geo1 - should have been caught as invalid geo");
michael@0 148 } catch (ex) {
michael@0 149 ok(1, "ill_geo1 - caught invalid geo");
michael@0 150 }
michael@0 151 try {
michael@0 152 Geo = new geo(document.getElementById("ill_geo2"), true);
michael@0 153 ok(0, "ill_geo2 - should have been caught as invalid geo");
michael@0 154 } catch (ex) {
michael@0 155 ok(1, "ill_geo2 - caught invalid geo");
michael@0 156 }
michael@0 157 try {
michael@0 158 Geo = new geo(document.getElementById("ill_geo3"), true);
michael@0 159 ok(0, "ill_geo3 - should have been caught as invalid geo");
michael@0 160 } catch (ex) {
michael@0 161 ok(1, "ill_geo3 - caught invalid geo");
michael@0 162 }
michael@0 163 try {
michael@0 164 Geo = new geo(document.getElementById("ill_geo4"), true);
michael@0 165 ok(0, "ill_geo4 - should have been caught as invalid geo");
michael@0 166 } catch (ex) {
michael@0 167 ok(1, "ill_geo4 - caught invalid geo");
michael@0 168 }
michael@0 169 try {
michael@0 170 Geo = new geo(document.getElementById("ill_geo5"), true);
michael@0 171 ok(0, "ill_geo5 - should have been caught as invalid geo");
michael@0 172 } catch (ex) {
michael@0 173 ok(1, "ill_geo5 - caught invalid geo");
michael@0 174 }
michael@0 175 try {
michael@0 176 Geo = new geo(document.getElementById("ill_geo6"), true);
michael@0 177 ok(0, "ill_geo6 - should have been caught as invalid geo");
michael@0 178 } catch (ex) {
michael@0 179 ok(1, "ill_geo6 - caught invalid geo");
michael@0 180 }
michael@0 181 try {
michael@0 182 Geo = new geo(document.getElementById("ill_geo7"), true);
michael@0 183 ok(0, "ill_geo7 - should have been caught as invalid geo");
michael@0 184 } catch (ex) {
michael@0 185 ok(1, "ill_geo7 - caught invalid geo");
michael@0 186 }
michael@0 187 try {
michael@0 188 Geo = new geo(document.getElementById("ill_geo8"), true);
michael@0 189 ok(0, "ill_geo8 - should have been caught as invalid geo");
michael@0 190 } catch (ex) {
michael@0 191 ok(1, "ill_geo8 - caught invalid geo");
michael@0 192 }
michael@0 193 try {
michael@0 194 Geo = new geo(document.getElementById("ill_geo9"), true);
michael@0 195 ok(0, "ill_geo9 - should have been caught as invalid geo");
michael@0 196 } catch (ex) {
michael@0 197 ok(1, "ill_geo9 - caught invalid geo");
michael@0 198 }
michael@0 199 try {
michael@0 200 Geo = new geo(document.getElementById("zero_geo"), true);
michael@0 201 ok(1, "zero_geo - creation succeeded");
michael@0 202 } catch (ex) {
michael@0 203 ok(0, "zero_geo - creation failed");
michael@0 204 }
michael@0 205 try {
michael@0 206 Geo = new geo(document.getElementById("extra_geo"), true);
michael@0 207 ok(1, "extra_geo - creation succeeded");
michael@0 208 } catch (ex) {
michael@0 209 ok(0, "extra_geo - creation failed");
michael@0 210 }
michael@0 211 }
michael@0 212
michael@0 213
michael@0 214
michael@0 215 </script>
michael@0 216 </pre>
michael@0 217 </body>
michael@0 218 </html>

mercurial