1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/microformats/tests/test_Microformats_geo.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,218 @@ 1.4 +<html> 1.5 +<head> 1.6 + <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 1.7 + <title>Testing Microformats.js (geo)</title> 1.8 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"></link> 1.11 +</head> 1.12 +<body> 1.13 +<div id="content" style="display: none"> 1.14 + 1.15 + <span class="geo" id="01-geo-basic"> 1.16 + <span class="latitude">37.77</span> 1.17 + <span class="longitude">-122.411</span> 1.18 + </span> 1.19 + 1.20 + 1.21 + <span class="geo" id="01-geo-abbr-latlong" > 1.22 + <abbr class="latitude" title="37.77">Northern</abbr> 1.23 + <abbr class="longitude" title="-122.41">California</abbr> 1.24 + </span> 1.25 + 1.26 + <abbr class="geo" id="01-geo-abbr" title="30.267991;-97.739568">Paradise</abbr> 1.27 + 1.28 + <span class="vcard"> 1.29 + <span class="fn org">John Doe</span> 1.30 + <abbr class="geo" id="02-geo-vcard-01" title="37.77;-122.41"></abbr> 1.31 + </span> 1.32 + 1.33 + <span class="vcard"> 1.34 + <span class="fn org">John Doe</span> 1.35 + <abbr class="geo" id="02-geo-vcard-02" title="37.77;-122.41">Northern California</abbr> 1.36 + </span> 1.37 + 1.38 + <span class="vevent"> 1.39 + <span class="summary">SXSW Interactive (South by Southwest)</span> 1.40 + <ABBR title="20080307" class="dtstart">Friday, March 7, 2008</ABBR> 1.41 + - 1.42 + <ABBR title="20080311" class="dtend">Tuesday, March 11, 2008</ABBR> 1.43 + <abbr class="geo" id="02-geo-vevent-01" title="30.2622;-97.7399"></abbr> 1.44 + </span> 1.45 + 1.46 + <span class="vevent"> 1.47 + <span class="summary">SXSW Interactive (South by Southwest)</span> 1.48 + <ABBR title="20080307" class="dtstart">Friday, March 7, 2008</ABBR> 1.49 + - 1.50 + <ABBR title="20080311" class="dtend">Tuesday, March 11, 2008</ABBR> 1.51 + <abbr class="geo" id="02-geo-vevent-02" title="30.2622;-97.7399">Convention Center</abbr> 1.52 + </span> 1.53 + 1.54 +<h3>Legal geos</h3> 1.55 +<ul> 1.56 +<li><span class="geo" id="legal_geo1"><span class="latitude">0</span>,<span class="longitude">0</span></span></li> 1.57 +<li><span class="geo" id="legal_geo2"><span class="latitude">0.0</span>,<span class="longitude">0.0</span></span></li> 1.58 +<li><span class="geo" id="legal_geo3"><span class="latitude">0.</span>,<span class="longitude">0.</span></span></li> 1.59 +</ul> 1.60 +<h3>Illegal geos</h3> 1.61 + 1.62 +<ul> 1.63 +<li><span class="geo" id="ill_geo1"><span class="latitude">abc</span>,<span class="longitude">def</span></span></li> 1.64 +<li><span class="geo" id="ill_geo2"><span class="latitude">12.s2</span>,<span class="longitude">1d.23</span></span></li> 1.65 +<li><span class="geo" id="ill_geo3"><span class="latitude">999.99</span>,<span class="longitude">999</span></span></li> 1.66 +<li><span class="geo" id="ill_geo4"><span class="latitude">-181</span>,<span class="longitude">-361</span></span></li> 1.67 +<li><span class="geo" id="ill_geo5">abc;def</span></li> 1.68 +<li><span class="geo" id="ill_geo6">12.s2;1d.23</span></li> 1.69 +<li><span class="geo" id="ill_geo7">999.99;999</span></li> 1.70 +<li><span class="geo" id="ill_geo8">-181;-361</span></li> 1.71 +<li><span class="geo" id="ill_geo9">-18;;-31</span></li> 1.72 +<li><ABBR title="+23.70000;+90.30000" class="extra_geo">Dhaka, Bangladesh</ABBR></li> 1.73 +<li><span class="geo" id="zero_geo">0;0</span></li> 1.74 +</ul> 1.75 + 1.76 + 1.77 + 1.78 + 1.79 + 1.80 + 1.81 +</div> 1.82 +<pre id="test"> 1.83 +<script class="testbody" type="text/javascript"> 1.84 + 1.85 +test_Microformats(); 1.86 +test_geo(); 1.87 + 1.88 +function test_Microformats() { 1.89 + var Microformats = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").Microformats; 1.90 + 1.91 + ok(Microformats, "Check global access to Microformats"); 1.92 +}; 1.93 + 1.94 +function test_geo() { 1.95 + var geo = SpecialPowers.Cu.import("resource://gre/modules/Microformats.js").geo; 1.96 + 1.97 + var Geo; 1.98 + 1.99 + Geo = new geo(document.getElementById("01-geo-basic")); 1.100 + 1.101 + is(Geo.latitude, "37.77", "01-geo-basic - latitude"); 1.102 + is(Geo.longitude, "-122.411", "01-geo-basic - longitude"); 1.103 + 1.104 + Geo = new geo(document.getElementById("01-geo-abbr-latlong")); 1.105 + 1.106 + is(Geo.latitude, "37.77", "02-geo-abbr-latlong - latitude"); 1.107 + is(Geo.longitude, "-122.41", "02-geo-abbr-latlong - longitude"); 1.108 + 1.109 + Geo = new geo(document.getElementById("01-geo-abbr")); 1.110 + 1.111 + is(Geo.latitude, "30.267991", "01-geo-abbr - latitude"); 1.112 + is(Geo.longitude, "-97.739568", "01-geo-abbr - longitude"); 1.113 + 1.114 + Geo = new geo(document.getElementById("02-geo-vcard-01")); 1.115 + 1.116 + is(Geo.toString(), "John Doe", "02-geo-vcard-01"); 1.117 + 1.118 + Geo = new geo(document.getElementById("02-geo-vcard-02")); 1.119 + 1.120 + is(Geo.toString(), "Northern California", "02-geo-vcard-02"); 1.121 + 1.122 + Geo = new geo(document.getElementById("02-geo-vevent-01")); 1.123 + 1.124 + is(Geo.toString(), "SXSW Interactive (South by Southwest)", "02-geo-vevent-01"); 1.125 + 1.126 + Geo = new geo(document.getElementById("02-geo-vevent-02")); 1.127 + 1.128 + is(Geo.toString(), "Convention Center", "02-geo-vevent-02"); 1.129 + 1.130 + Geo = new geo(document.getElementById("legal_geo1")); 1.131 + 1.132 + is(Geo.latitude, 0, "legal_geo1 - lat"); 1.133 + is(Geo.longitude, 0, "legal_geo1 - long"); 1.134 + 1.135 + Geo = new geo(document.getElementById("legal_geo2")); 1.136 + 1.137 + is(Geo.latitude, 0, "legal_geo2 - lat"); 1.138 + is(Geo.longitude, 0, "legal_geo2 - long"); 1.139 + 1.140 + Geo = new geo(document.getElementById("legal_geo3")); 1.141 + 1.142 + is(Geo.latitude, 0, "legal_geo3 - lat"); 1.143 + is(Geo.longitude, 0, "legal_geo3 - long"); 1.144 + 1.145 + 1.146 + 1.147 + 1.148 + try { 1.149 + Geo = new geo(document.getElementById("ill_geo1"), true); 1.150 + ok(0, "ill_geo1 - should have been caught as invalid geo"); 1.151 + } catch (ex) { 1.152 + ok(1, "ill_geo1 - caught invalid geo"); 1.153 + } 1.154 + try { 1.155 + Geo = new geo(document.getElementById("ill_geo2"), true); 1.156 + ok(0, "ill_geo2 - should have been caught as invalid geo"); 1.157 + } catch (ex) { 1.158 + ok(1, "ill_geo2 - caught invalid geo"); 1.159 + } 1.160 + try { 1.161 + Geo = new geo(document.getElementById("ill_geo3"), true); 1.162 + ok(0, "ill_geo3 - should have been caught as invalid geo"); 1.163 + } catch (ex) { 1.164 + ok(1, "ill_geo3 - caught invalid geo"); 1.165 + } 1.166 + try { 1.167 + Geo = new geo(document.getElementById("ill_geo4"), true); 1.168 + ok(0, "ill_geo4 - should have been caught as invalid geo"); 1.169 + } catch (ex) { 1.170 + ok(1, "ill_geo4 - caught invalid geo"); 1.171 + } 1.172 + try { 1.173 + Geo = new geo(document.getElementById("ill_geo5"), true); 1.174 + ok(0, "ill_geo5 - should have been caught as invalid geo"); 1.175 + } catch (ex) { 1.176 + ok(1, "ill_geo5 - caught invalid geo"); 1.177 + } 1.178 + try { 1.179 + Geo = new geo(document.getElementById("ill_geo6"), true); 1.180 + ok(0, "ill_geo6 - should have been caught as invalid geo"); 1.181 + } catch (ex) { 1.182 + ok(1, "ill_geo6 - caught invalid geo"); 1.183 + } 1.184 + try { 1.185 + Geo = new geo(document.getElementById("ill_geo7"), true); 1.186 + ok(0, "ill_geo7 - should have been caught as invalid geo"); 1.187 + } catch (ex) { 1.188 + ok(1, "ill_geo7 - caught invalid geo"); 1.189 + } 1.190 + try { 1.191 + Geo = new geo(document.getElementById("ill_geo8"), true); 1.192 + ok(0, "ill_geo8 - should have been caught as invalid geo"); 1.193 + } catch (ex) { 1.194 + ok(1, "ill_geo8 - caught invalid geo"); 1.195 + } 1.196 + try { 1.197 + Geo = new geo(document.getElementById("ill_geo9"), true); 1.198 + ok(0, "ill_geo9 - should have been caught as invalid geo"); 1.199 + } catch (ex) { 1.200 + ok(1, "ill_geo9 - caught invalid geo"); 1.201 + } 1.202 + try { 1.203 + Geo = new geo(document.getElementById("zero_geo"), true); 1.204 + ok(1, "zero_geo - creation succeeded"); 1.205 + } catch (ex) { 1.206 + ok(0, "zero_geo - creation failed"); 1.207 + } 1.208 + try { 1.209 + Geo = new geo(document.getElementById("extra_geo"), true); 1.210 + ok(1, "extra_geo - creation succeeded"); 1.211 + } catch (ex) { 1.212 + ok(0, "extra_geo - creation failed"); 1.213 + } 1.214 +} 1.215 + 1.216 + 1.217 + 1.218 +</script> 1.219 +</pre> 1.220 +</body> 1.221 +</html>