1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_datepicker.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,417 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 + XUL Widget Test for datepicker 1.9 + --> 1.10 +<window title="datepicker" width="500" height="600" 1.11 + onload="setTimeout(testtag_datepickers, 0);" 1.12 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.14 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.15 + 1.16 +<hbox onpopupshown="testtag_datepicker_UI_popup()" 1.17 + onpopuphidden="testtag_finish()"> 1.18 +<datepicker id="datepicker"/> 1.19 +<datepicker id="datepicker-popup" type="popup"/> 1.20 +<hbox onDOMMouseScroll="mouseScrolled = event.defaultPrevented;"> 1.21 + <datepicker id="datepicker-grid" type="grid"/> 1.22 +</hbox> 1.23 +</hbox> 1.24 + 1.25 +<!-- Test-only key bindings, but must not conflict with the application. --> 1.26 +<keyset id="mainKeyset"> 1.27 + <key id="key_alt_z" key="Z" oncommand="return" modifiers="alt"/> 1.28 + <key id="key_ctrl_q" key="Q" oncommand="return" modifiers="control"/> 1.29 + <key id="key_meta_e" key="E" oncommand="return" modifiers="meta"/> 1.30 +</keyset> 1.31 + 1.32 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.33 +<p id="display"></p> 1.34 +<div id="content" style="display: none"> 1.35 +</div> 1.36 +<pre id="test"> 1.37 +</pre> 1.38 +</body> 1.39 + 1.40 +<script> 1.41 +<![CDATA[ 1.42 + 1.43 +var mouseScrolled = false; 1.44 + 1.45 +SimpleTest.waitForExplicitFinish(); 1.46 + 1.47 +function testtag_datepickers() 1.48 +{ 1.49 + var dppopup = document.getElementById("datepicker-popup"); 1.50 + testtag_datepicker(document.getElementById("datepicker"), "", "datepicker"); 1.51 + testtag_datepicker(dppopup, "popup", "datepicker popup"); 1.52 + testtag_datepicker(document.getElementById("datepicker-grid"), "grid", "datepicker grid"); 1.53 + dppopup.open = true; 1.54 +} 1.55 + 1.56 +function testtag_finish() 1.57 +{ 1.58 + ok(!document.getElementById("datepicker-popup").open, "datepicker popup open false again"); 1.59 + 1.60 + var dpgrid = document.getElementById("datepicker-grid"); 1.61 + synthesizeWheel(dpgrid, 5, 5, { deltaY: 10.0, 1.62 + deltaMode: WheelEvent.DOM_DELTA_LINE }); 1.63 + is(mouseScrolled, true, "mouse scrolled"); 1.64 + is(dpgrid.displayedMonth, 2, "mouse scroll changed month"); 1.65 + 1.66 + SimpleTest.finish(); 1.67 +} 1.68 + 1.69 +function testtag_datepicker(dp, type, testid) 1.70 +{ 1.71 + testid += " "; 1.72 + 1.73 + var today = new Date(); 1.74 + var tyear = today.getFullYear(); 1.75 + var tmonth = today.getMonth(); 1.76 + var tdate = today.getDate(); 1.77 + 1.78 + // testtag_comparedate(dp, testid + "initial", tyear, tmonth, tdate); 1.79 + 1.80 + // check that setting the value property works 1.81 + dp.value = testtag_getdatestring(tyear, tmonth, tdate); 1.82 + testtag_comparedate(dp, testid + "set value", tyear, tmonth, tdate); 1.83 + 1.84 + // check that setting the dateValue property works 1.85 + dp.dateValue = today; 1.86 + testtag_comparedate(dp, testid + "set dateValue", tyear, tmonth, tdate); 1.87 + ok(dp.value !== today, testid + " set dateValue different date"); 1.88 + 1.89 + ok(!dp.readOnly, testid + "readOnly"); 1.90 + dp.readOnly = true; 1.91 + ok(dp.readOnly, testid + "set readOnly"); 1.92 + dp.readOnly = false; 1.93 + ok(!dp.readOnly, testid + "clear readOnly"); 1.94 + 1.95 + var setDateField = function(field, value, expectException, 1.96 + expectedYear, expectedMonth, expectedDate) 1.97 + { 1.98 + var exh = false; 1.99 + try { 1.100 + dp[field] = value; 1.101 + } catch (ex) { exh = true; } 1.102 + is(exh, expectException, testid + "set " + field + " " + value); 1.103 + testtag_comparedate(dp, testid + "set " + field + " " + value, 1.104 + expectedYear, expectedMonth, expectedDate); 1.105 + } 1.106 + 1.107 + // check the value property 1.108 + setDateField("value", "2003-1-27", false, 2003, 0, 27); 1.109 + setDateField("value", "2002-11-8", false, 2002, 10, 8); 1.110 + setDateField("value", "2001-07-02", false, 2001, 6, 2); 1.111 + setDateField("value", "2002-10-25", false, 2002, 9, 25); 1.112 + 1.113 + // check that the year, month and date fields can be set properly 1.114 + setDateField("year", 2002, false, 2002, 9, 25); 1.115 + setDateField("year", 0, true, 2002, 9, 25); 1.116 + 1.117 + setDateField("month", 6, false, 2002, 6, 25); 1.118 + setDateField("month", 9, false, 2002, 9, 25); 1.119 + setDateField("month", 10, false, 2002, 10, 25); 1.120 + setDateField("month", -1, true, 2002, 10, 25); 1.121 + setDateField("month", 12, true, 2002, 10, 25); 1.122 + 1.123 + setDateField("date", 9, false, 2002, 10, 9); 1.124 + setDateField("date", 10, false, 2002, 10, 10); 1.125 + setDateField("date", 15, false, 2002, 10, 15); 1.126 + setDateField("date", 0, true, 2002, 10, 15); 1.127 + setDateField("date", 32, true, 2002, 10, 15); 1.128 + 1.129 + // check that dates overflow properly 1.130 + setDateField("value", "2002-2-40", false, 2002, 2, 12); 1.131 + setDateField("value", "2003-03-32", false, 2003, 3, 1); 1.132 + setDateField("value", "2003-12-32", false, 2004, 0, 1); 1.133 + 1.134 + // check leap year handling 1.135 + setDateField("value", "1600-2-29", false, 1600, 1, 29); 1.136 + setDateField("value", "2000-2-29", false, 2000, 1, 29); 1.137 + setDateField("value", "2003-2-29", false, 2003, 2, 1); 1.138 + setDateField("value", "2004-2-29", false, 2004, 1, 29); 1.139 + setDateField("value", "2100-2-29", false, 2100, 2, 1); 1.140 + 1.141 + // check invalid values for the value and dateValue properties 1.142 + dp.value = "2002-07-15"; 1.143 + setDateField("value", "", true, 2002, 6, 15); 1.144 + setDateField("value", "2-2", true, 2002, 6, 15); 1.145 + setDateField("value", "2000-5-6-6", true, 2002, 6, 15); 1.146 + setDateField("value", "2000-a-19", true, 2002, 6, 15); 1.147 + setDateField("dateValue", "none", true, 2002, 6, 15); 1.148 + 1.149 + // grid and popup types can display a different month than the current one 1.150 + var isGridOrPopup = (type == "grid" || type == "popup"); 1.151 + dp.displayedMonth = 3; 1.152 + testtag_comparedate(dp, testid + "set displayedMonth", 1.153 + 2002, isGridOrPopup ? 6 : 3, 15, 3); 1.154 + 1.155 + dp.displayedYear = 2009; 1.156 + testtag_comparedate(dp, testid + "set displayedYear", 1.157 + isGridOrPopup ? 2002 : 2009, isGridOrPopup ? 6 : 3, 15, 3, 2009); 1.158 + 1.159 + if (isGridOrPopup) { 1.160 + dp.value = "2008-02-29"; 1.161 + dp.displayedYear = 2009; 1.162 + is(dp.displayedMonth, 1, "set displayedYear during leap year"); 1.163 + } 1.164 + 1.165 + is(dp.open, false, testid + "open false"); 1.166 + if (type != "popup") { 1.167 + dp.open = true; 1.168 + ok(!dp.open, testid + "open still false"); 1.169 + } 1.170 + 1.171 + // check the fields 1.172 + if (type != "grid") { 1.173 + ok(dp.yearField instanceof HTMLInputElement, testid + "yearField"); 1.174 + ok(dp.monthField instanceof HTMLInputElement, testid + "monthField"); 1.175 + ok(dp.dateField instanceof HTMLInputElement, testid + "dateField"); 1.176 + 1.177 + testtag_datepicker_UI_fields(dp, testid); 1.178 + 1.179 + dp.readOnly = true; 1.180 + 1.181 + // check that keyboard usage doesn't change the value when the datepicker 1.182 + // is read only 1.183 + testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-01-29", 1.184 + dp.yearField, 2003, 0, 29, 2003, 0, 29); 1.185 + testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-04-29", 1.186 + dp.monthField, 2003, 3, 29, 2003, 3, 29); 1.187 + testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-06-15", 1.188 + dp.dateField, 2003, 5, 15, 2003, 5, 15); 1.189 + 1.190 + dp.readOnly = false; 1.191 + } 1.192 + else { 1.193 + testtag_datepicker_UI_grid(dp, "grid", testid); 1.194 + } 1.195 +} 1.196 + 1.197 +function testtag_datepicker_UI_fields(dp, testid) 1.198 +{ 1.199 + testid += "UI"; 1.200 + dp.focus(); 1.201 + 1.202 + // test adjusting the date with the up and down keys 1.203 + testtag_datepicker_UI_key(dp, testid, "2003-01-29", dp.yearField, 2004, 0, 29, 2003, 0, 29); 1.204 + testtag_datepicker_UI_key(dp, testid, "1600-02-29", dp.yearField, 1601, 1, 28, 1600, 1, 28); 1.205 + testtag_datepicker_UI_key(dp, testid, "2000-02-29", dp.yearField, 2001, 1, 28, 2000, 1, 28); 1.206 + testtag_datepicker_UI_key(dp, testid, "2004-02-29", dp.yearField, 2005, 1, 28, 2004, 1, 28); 1.207 + 1.208 + testtag_datepicker_UI_key(dp, testid, "2003-04-29", dp.monthField, 2003, 4, 29, 2003, 3, 29); 1.209 + testtag_datepicker_UI_key(dp, testid, "2003-01-15", dp.monthField, 2003, 1, 15, 2003, 0, 15); 1.210 + testtag_datepicker_UI_key(dp, testid, "2003-12-29", dp.monthField, 2003, 0, 29, 2003, 11, 29); 1.211 + testtag_datepicker_UI_key(dp, testid, "2003-03-31", dp.monthField, 2003, 3, 30, 2003, 2, 30); 1.212 + 1.213 + testtag_datepicker_UI_key(dp, testid, "2003-06-15", dp.dateField, 2003, 5, 16, 2003, 5, 15); 1.214 + testtag_datepicker_UI_key(dp, testid, "2003-06-01", dp.dateField, 2003, 5, 2, 2003, 5, 1); 1.215 + testtag_datepicker_UI_key(dp, testid, "2003-06-30", dp.dateField, 2003, 5, 1, 2003, 5, 30); 1.216 + testtag_datepicker_UI_key(dp, testid, "1600-02-28", dp.dateField, 1600, 1, 29, 1600, 1, 28); 1.217 + testtag_datepicker_UI_key(dp, testid, "2000-02-28", dp.dateField, 2000, 1, 29, 2000, 1, 28); 1.218 + testtag_datepicker_UI_key(dp, testid, "2003-02-28", dp.dateField, 2003, 1, 1, 2003, 1, 28); 1.219 + testtag_datepicker_UI_key(dp, testid, "2004-02-28", dp.dateField, 2004, 1, 29, 2004, 1, 28); 1.220 + testtag_datepicker_UI_key(dp, testid, "2100-02-28", dp.dateField, 2100, 1, 1, 2100, 1, 28); 1.221 + 1.222 + synthesizeKeyExpectEvent('Z', { altKey: true }, $("key_alt_z"), "command", testid + " alt shortcut"); 1.223 + synthesizeKeyExpectEvent('Q', { ctrlKey: true }, $("key_ctrl_q"), "command", testid + " ctrl shortcut"); 1.224 + synthesizeKeyExpectEvent('E', { metaKey: true }, $("key_meta_e"), "command", testid + " meta shortcut"); 1.225 +} 1.226 + 1.227 +function testtag_datepicker_UI_grid(dp, type, testid) 1.228 +{ 1.229 + testid += "UI "; 1.230 + 1.231 + // check that pressing the cursor keys moves the date properly. For grid 1.232 + // types, focus the grid first. For popup types, the grid should be focused 1.233 + // automatically when opening the popup. 1.234 + var ktarget = dp; 1.235 + if (type == "grid") 1.236 + dp.focus(); 1.237 + else 1.238 + ktarget = dp.attachedControl; 1.239 + 1.240 + dp.value = "2003-02-22"; 1.241 + 1.242 + synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left"); 1.243 + is(dp.value, "2003-02-21", testid + "key left"); 1.244 + 1.245 + synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right"); 1.246 + is(dp.value, "2003-02-22", testid + "key right"); 1.247 + synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right next week"); 1.248 + is(dp.value, "2003-02-23", testid + "key right next week"); 1.249 + synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left previous week"); 1.250 + is(dp.value, "2003-02-22", testid + "key left previous week"); 1.251 + 1.252 + synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "change", testid + "key up"); 1.253 + is(dp.value, "2003-02-15", testid + "key up"); 1.254 + synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "change", testid + "key down"); 1.255 + is(dp.value, "2003-02-22", testid + "key down"); 1.256 + synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "change"); 1.257 + is(dp.value, "2003-03-01", testid + "key down next month", testid + "key down next month"); 1.258 + synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "change"); 1.259 + is(dp.value, "2003-02-22", testid + "key up previous month", testid + "key up previous month"); 1.260 + 1.261 + // the displayed month may be changed with the page up and page down keys, 1.262 + // however this only changes the displayed month, not the current value. 1.263 + synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down"); 1.264 + is(dp.value, "2003-02-22", testid + "key page down"); 1.265 + 1.266 + // the monthchange event is fired when the displayed month is changed 1.267 + synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "monthchange", testid + "key up after month change"); 1.268 + is(dp.value, "2003-02-15", testid + "key up after month change"); 1.269 + 1.270 + synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up"); 1.271 + is(dp.value, "2003-02-15", testid + "key page up"); 1.272 + 1.273 + // check handling at the start and end of the month 1.274 + dp.value = "2010-10-01"; 1.275 + synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-10-01"); 1.276 + is(dp.displayedMonth, 8, testid + "key page up 2010-10-01 displayedMonth"); 1.277 + is(dp.displayedYear, 2010, testid + "key page up 2010-10-01 displayedYear"); 1.278 + 1.279 + dp.value = "2010-10-01"; 1.280 + synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-10-01"); 1.281 + is(dp.displayedMonth, 10, testid + "key page down 2010-10-01 displayedMonth"); 1.282 + is(dp.displayedYear, 2010, testid + "key page down 2010-10-01 displayedYear"); 1.283 + 1.284 + dp.value = "2010-10-31"; 1.285 + synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-10-31"); 1.286 + is(dp.displayedMonth, 8, testid + "key page up 2010-10-31 displayedMonth"); 1.287 + is(dp.displayedYear, 2010, testid + "key page up 2010-10-01 displayedYear"); 1.288 + dp.value = "2010-10-31"; 1.289 + synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-10-31"); 1.290 + is(dp.displayedMonth, 10, testid + "key page down 2010-10-31 displayedMonth"); 1.291 + is(dp.displayedYear, 2010, testid + "key page up 2010-10-31 displayedYear"); 1.292 + 1.293 + // check handling at the end of february 1.294 + dp.value = "2010-03-31"; 1.295 + synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-03-31"); 1.296 + is(dp.displayedMonth, 1, testid + "key page up 2010-03-31 displayedMonth"); 1.297 + is(dp.displayedYear, 2010, testid + "key page up 2010-03-31 displayedYear"); 1.298 + synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-02-28"); 1.299 + is(dp.displayedMonth, 0, testid + "key page up 2010-02-28 displayedMonth"); 1.300 + is(dp.displayedYear, 2010, testid + "key page up 2010-02-28 displayedYear"); 1.301 + 1.302 + dp.value = "2010-01-31"; 1.303 + synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-01-31"); 1.304 + is(dp.displayedMonth, 1, testid + "key page down 2010-01-31 displayedMonth"); 1.305 + is(dp.displayedYear, 2010, testid + "key page up 2010-01-31 displayedYear"); 1.306 + synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-02-28"); 1.307 + is(dp.displayedMonth, 2, testid + "key page down 2010-02-28 displayedMonth"); 1.308 + is(dp.displayedYear, 2010, testid + "key page up 2010-02-28 displayedYear"); 1.309 + 1.310 + // check handling at the end of february during a leap year 1.311 + dp.value = "2008-01-31"; 1.312 + synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2008-01-31"); 1.313 + is(dp.displayedMonth, 1, testid + "key page down 2008-01-31 displayedMonth"); 1.314 + is(dp.displayedYear, 2008, testid + "key page up 2008-01-31 displayedYear"); 1.315 + dp.value = "2008-03-31"; 1.316 + synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2008-03-31"); 1.317 + is(dp.displayedMonth, 1, testid + "key page up 2008-03-31 displayedMonth"); 1.318 + is(dp.displayedYear, 2008, testid + "key page up 2008-03-31 displayedYear"); 1.319 + 1.320 + // the value of a read only datepicker cannot be changed 1.321 + dp.value = "2003-02-15"; 1.322 + 1.323 + dp.readOnly = true; 1.324 + synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "!change", testid + "key left read only"); 1.325 + is(dp.value, "2003-02-15", testid + "key left read only"); 1.326 + synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "!change", testid + "key right read only"); 1.327 + is(dp.value, "2003-02-15", testid + "key right read only"); 1.328 + synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "!change", testid + "key down read only"); 1.329 + is(dp.value, "2003-02-15", testid + "key down read only"); 1.330 + synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "!change", testid + "key up read only"); 1.331 + is(dp.value, "2003-02-15", testid + "key up read only"); 1.332 + 1.333 + // month can still be changed even when readonly 1.334 + synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", 1.335 + testid + "key page up read only"); 1.336 + synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", 1.337 + testid + "key page down read only"); 1.338 + 1.339 + dp.readOnly = false; 1.340 + synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left changeable again"); 1.341 + is(dp.value, "2003-02-14", testid + "key left changeable again"); 1.342 + 1.343 + // the value of a disabled datepicker cannot be changed 1.344 + dp.disabled = true; 1.345 + synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "!change", testid + "key left disabled"); 1.346 + is(dp.value, "2003-02-14", testid + "key left disabled"); 1.347 + synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "!change", testid + "key right disabled"); 1.348 + is(dp.value, "2003-02-14", testid + "key right disabled"); 1.349 + synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "!change", testid + "key down disabled"); 1.350 + is(dp.value, "2003-02-14", testid + "key down disabled"); 1.351 + synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "!change", testid + "key up disabled"); 1.352 + is(dp.value, "2003-02-14", testid + "key up disabled"); 1.353 + 1.354 + // month cannot be changed even when disabled 1.355 + synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "!monthchange", 1.356 + testid + "key page down disabled"); 1.357 + synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "!monthchange", 1.358 + testid + "key page up disabled"); 1.359 + 1.360 + dp.disabled = false; 1.361 + synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right enabled again"); 1.362 + is(dp.value, "2003-02-15", testid + "key right enabled again"); 1.363 +} 1.364 + 1.365 +function testtag_datepicker_UI_popup() 1.366 +{ 1.367 + var dppopup = document.getElementById("datepicker-popup"); 1.368 + is(dppopup.open, true, "datepicker popup after open"); 1.369 + testtag_datepicker_UI_grid(dppopup, "popup", "datepicker popup "); 1.370 + dppopup.open = false; 1.371 +} 1.372 + 1.373 +function testtag_datepicker_UI_key(dp, testid, value, field, 1.374 + uyear, umonth, udate, 1.375 + dyear, dmonth, ddate) 1.376 +{ 1.377 + dp.value = value; 1.378 + field.focus(); 1.379 + 1.380 + synthesizeKey("VK_UP", { }); 1.381 + testtag_comparedate(dp, testid + " " + value + " key up", uyear, umonth, udate); 1.382 + 1.383 + synthesizeKey("VK_DOWN", { }); 1.384 + testtag_comparedate(dp, testid + " " + value + " key down", dyear, dmonth, ddate); 1.385 +} 1.386 + 1.387 +function testtag_getdatestring(year, month, date) 1.388 +{ 1.389 + month = (month < 9) ? ("0" + ++month) : month + 1; 1.390 + if (date < 10) 1.391 + date = "0" + date; 1.392 + return year + "-" + month + "-" + date; 1.393 +} 1.394 + 1.395 +function testtag_comparedate(dp, testid, year, month, date, displayedMonth, displayedYear) 1.396 +{ 1.397 + is(dp.value, testtag_getdatestring(year, month, date), testid + " value"); 1.398 + if (testid.indexOf("initial") == -1) 1.399 + is(dp.getAttribute("value"), 1.400 + testtag_getdatestring(year, month, date), 1.401 + testid + " value attribute"); 1.402 + 1.403 + var dateValue = dp.dateValue; 1.404 + ok(dateValue.getFullYear() == year && 1.405 + dateValue.getMonth() == month && 1.406 + dateValue.getDate() == date, 1.407 + testid + " dateValue"); 1.408 + 1.409 + is(dp.year, year, testid + " year"); 1.410 + is(dp.month, month, testid + " month"); 1.411 + is(dp.displayedMonth, displayedMonth ? displayedMonth : month, testid + " displayedMonth"); 1.412 + is(dp.displayedYear, displayedYear ? displayedYear : year, testid + " displayedYear"); 1.413 + is(dp.date, date, testid + " date"); 1.414 +} 1.415 + 1.416 +]]> 1.417 + 1.418 +</script> 1.419 + 1.420 +</window>