toolkit/content/tests/chrome/test_datepicker.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 XUL Widget Test for datepicker
michael@0 6 -->
michael@0 7 <window title="datepicker" width="500" height="600"
michael@0 8 onload="setTimeout(testtag_datepickers, 0);"
michael@0 9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 12
michael@0 13 <hbox onpopupshown="testtag_datepicker_UI_popup()"
michael@0 14 onpopuphidden="testtag_finish()">
michael@0 15 <datepicker id="datepicker"/>
michael@0 16 <datepicker id="datepicker-popup" type="popup"/>
michael@0 17 <hbox onDOMMouseScroll="mouseScrolled = event.defaultPrevented;">
michael@0 18 <datepicker id="datepicker-grid" type="grid"/>
michael@0 19 </hbox>
michael@0 20 </hbox>
michael@0 21
michael@0 22 <!-- Test-only key bindings, but must not conflict with the application. -->
michael@0 23 <keyset id="mainKeyset">
michael@0 24 <key id="key_alt_z" key="Z" oncommand="return" modifiers="alt"/>
michael@0 25 <key id="key_ctrl_q" key="Q" oncommand="return" modifiers="control"/>
michael@0 26 <key id="key_meta_e" key="E" oncommand="return" modifiers="meta"/>
michael@0 27 </keyset>
michael@0 28
michael@0 29 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 30 <p id="display"></p>
michael@0 31 <div id="content" style="display: none">
michael@0 32 </div>
michael@0 33 <pre id="test">
michael@0 34 </pre>
michael@0 35 </body>
michael@0 36
michael@0 37 <script>
michael@0 38 <![CDATA[
michael@0 39
michael@0 40 var mouseScrolled = false;
michael@0 41
michael@0 42 SimpleTest.waitForExplicitFinish();
michael@0 43
michael@0 44 function testtag_datepickers()
michael@0 45 {
michael@0 46 var dppopup = document.getElementById("datepicker-popup");
michael@0 47 testtag_datepicker(document.getElementById("datepicker"), "", "datepicker");
michael@0 48 testtag_datepicker(dppopup, "popup", "datepicker popup");
michael@0 49 testtag_datepicker(document.getElementById("datepicker-grid"), "grid", "datepicker grid");
michael@0 50 dppopup.open = true;
michael@0 51 }
michael@0 52
michael@0 53 function testtag_finish()
michael@0 54 {
michael@0 55 ok(!document.getElementById("datepicker-popup").open, "datepicker popup open false again");
michael@0 56
michael@0 57 var dpgrid = document.getElementById("datepicker-grid");
michael@0 58 synthesizeWheel(dpgrid, 5, 5, { deltaY: 10.0,
michael@0 59 deltaMode: WheelEvent.DOM_DELTA_LINE });
michael@0 60 is(mouseScrolled, true, "mouse scrolled");
michael@0 61 is(dpgrid.displayedMonth, 2, "mouse scroll changed month");
michael@0 62
michael@0 63 SimpleTest.finish();
michael@0 64 }
michael@0 65
michael@0 66 function testtag_datepicker(dp, type, testid)
michael@0 67 {
michael@0 68 testid += " ";
michael@0 69
michael@0 70 var today = new Date();
michael@0 71 var tyear = today.getFullYear();
michael@0 72 var tmonth = today.getMonth();
michael@0 73 var tdate = today.getDate();
michael@0 74
michael@0 75 // testtag_comparedate(dp, testid + "initial", tyear, tmonth, tdate);
michael@0 76
michael@0 77 // check that setting the value property works
michael@0 78 dp.value = testtag_getdatestring(tyear, tmonth, tdate);
michael@0 79 testtag_comparedate(dp, testid + "set value", tyear, tmonth, tdate);
michael@0 80
michael@0 81 // check that setting the dateValue property works
michael@0 82 dp.dateValue = today;
michael@0 83 testtag_comparedate(dp, testid + "set dateValue", tyear, tmonth, tdate);
michael@0 84 ok(dp.value !== today, testid + " set dateValue different date");
michael@0 85
michael@0 86 ok(!dp.readOnly, testid + "readOnly");
michael@0 87 dp.readOnly = true;
michael@0 88 ok(dp.readOnly, testid + "set readOnly");
michael@0 89 dp.readOnly = false;
michael@0 90 ok(!dp.readOnly, testid + "clear readOnly");
michael@0 91
michael@0 92 var setDateField = function(field, value, expectException,
michael@0 93 expectedYear, expectedMonth, expectedDate)
michael@0 94 {
michael@0 95 var exh = false;
michael@0 96 try {
michael@0 97 dp[field] = value;
michael@0 98 } catch (ex) { exh = true; }
michael@0 99 is(exh, expectException, testid + "set " + field + " " + value);
michael@0 100 testtag_comparedate(dp, testid + "set " + field + " " + value,
michael@0 101 expectedYear, expectedMonth, expectedDate);
michael@0 102 }
michael@0 103
michael@0 104 // check the value property
michael@0 105 setDateField("value", "2003-1-27", false, 2003, 0, 27);
michael@0 106 setDateField("value", "2002-11-8", false, 2002, 10, 8);
michael@0 107 setDateField("value", "2001-07-02", false, 2001, 6, 2);
michael@0 108 setDateField("value", "2002-10-25", false, 2002, 9, 25);
michael@0 109
michael@0 110 // check that the year, month and date fields can be set properly
michael@0 111 setDateField("year", 2002, false, 2002, 9, 25);
michael@0 112 setDateField("year", 0, true, 2002, 9, 25);
michael@0 113
michael@0 114 setDateField("month", 6, false, 2002, 6, 25);
michael@0 115 setDateField("month", 9, false, 2002, 9, 25);
michael@0 116 setDateField("month", 10, false, 2002, 10, 25);
michael@0 117 setDateField("month", -1, true, 2002, 10, 25);
michael@0 118 setDateField("month", 12, true, 2002, 10, 25);
michael@0 119
michael@0 120 setDateField("date", 9, false, 2002, 10, 9);
michael@0 121 setDateField("date", 10, false, 2002, 10, 10);
michael@0 122 setDateField("date", 15, false, 2002, 10, 15);
michael@0 123 setDateField("date", 0, true, 2002, 10, 15);
michael@0 124 setDateField("date", 32, true, 2002, 10, 15);
michael@0 125
michael@0 126 // check that dates overflow properly
michael@0 127 setDateField("value", "2002-2-40", false, 2002, 2, 12);
michael@0 128 setDateField("value", "2003-03-32", false, 2003, 3, 1);
michael@0 129 setDateField("value", "2003-12-32", false, 2004, 0, 1);
michael@0 130
michael@0 131 // check leap year handling
michael@0 132 setDateField("value", "1600-2-29", false, 1600, 1, 29);
michael@0 133 setDateField("value", "2000-2-29", false, 2000, 1, 29);
michael@0 134 setDateField("value", "2003-2-29", false, 2003, 2, 1);
michael@0 135 setDateField("value", "2004-2-29", false, 2004, 1, 29);
michael@0 136 setDateField("value", "2100-2-29", false, 2100, 2, 1);
michael@0 137
michael@0 138 // check invalid values for the value and dateValue properties
michael@0 139 dp.value = "2002-07-15";
michael@0 140 setDateField("value", "", true, 2002, 6, 15);
michael@0 141 setDateField("value", "2-2", true, 2002, 6, 15);
michael@0 142 setDateField("value", "2000-5-6-6", true, 2002, 6, 15);
michael@0 143 setDateField("value", "2000-a-19", true, 2002, 6, 15);
michael@0 144 setDateField("dateValue", "none", true, 2002, 6, 15);
michael@0 145
michael@0 146 // grid and popup types can display a different month than the current one
michael@0 147 var isGridOrPopup = (type == "grid" || type == "popup");
michael@0 148 dp.displayedMonth = 3;
michael@0 149 testtag_comparedate(dp, testid + "set displayedMonth",
michael@0 150 2002, isGridOrPopup ? 6 : 3, 15, 3);
michael@0 151
michael@0 152 dp.displayedYear = 2009;
michael@0 153 testtag_comparedate(dp, testid + "set displayedYear",
michael@0 154 isGridOrPopup ? 2002 : 2009, isGridOrPopup ? 6 : 3, 15, 3, 2009);
michael@0 155
michael@0 156 if (isGridOrPopup) {
michael@0 157 dp.value = "2008-02-29";
michael@0 158 dp.displayedYear = 2009;
michael@0 159 is(dp.displayedMonth, 1, "set displayedYear during leap year");
michael@0 160 }
michael@0 161
michael@0 162 is(dp.open, false, testid + "open false");
michael@0 163 if (type != "popup") {
michael@0 164 dp.open = true;
michael@0 165 ok(!dp.open, testid + "open still false");
michael@0 166 }
michael@0 167
michael@0 168 // check the fields
michael@0 169 if (type != "grid") {
michael@0 170 ok(dp.yearField instanceof HTMLInputElement, testid + "yearField");
michael@0 171 ok(dp.monthField instanceof HTMLInputElement, testid + "monthField");
michael@0 172 ok(dp.dateField instanceof HTMLInputElement, testid + "dateField");
michael@0 173
michael@0 174 testtag_datepicker_UI_fields(dp, testid);
michael@0 175
michael@0 176 dp.readOnly = true;
michael@0 177
michael@0 178 // check that keyboard usage doesn't change the value when the datepicker
michael@0 179 // is read only
michael@0 180 testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-01-29",
michael@0 181 dp.yearField, 2003, 0, 29, 2003, 0, 29);
michael@0 182 testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-04-29",
michael@0 183 dp.monthField, 2003, 3, 29, 2003, 3, 29);
michael@0 184 testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-06-15",
michael@0 185 dp.dateField, 2003, 5, 15, 2003, 5, 15);
michael@0 186
michael@0 187 dp.readOnly = false;
michael@0 188 }
michael@0 189 else {
michael@0 190 testtag_datepicker_UI_grid(dp, "grid", testid);
michael@0 191 }
michael@0 192 }
michael@0 193
michael@0 194 function testtag_datepicker_UI_fields(dp, testid)
michael@0 195 {
michael@0 196 testid += "UI";
michael@0 197 dp.focus();
michael@0 198
michael@0 199 // test adjusting the date with the up and down keys
michael@0 200 testtag_datepicker_UI_key(dp, testid, "2003-01-29", dp.yearField, 2004, 0, 29, 2003, 0, 29);
michael@0 201 testtag_datepicker_UI_key(dp, testid, "1600-02-29", dp.yearField, 1601, 1, 28, 1600, 1, 28);
michael@0 202 testtag_datepicker_UI_key(dp, testid, "2000-02-29", dp.yearField, 2001, 1, 28, 2000, 1, 28);
michael@0 203 testtag_datepicker_UI_key(dp, testid, "2004-02-29", dp.yearField, 2005, 1, 28, 2004, 1, 28);
michael@0 204
michael@0 205 testtag_datepicker_UI_key(dp, testid, "2003-04-29", dp.monthField, 2003, 4, 29, 2003, 3, 29);
michael@0 206 testtag_datepicker_UI_key(dp, testid, "2003-01-15", dp.monthField, 2003, 1, 15, 2003, 0, 15);
michael@0 207 testtag_datepicker_UI_key(dp, testid, "2003-12-29", dp.monthField, 2003, 0, 29, 2003, 11, 29);
michael@0 208 testtag_datepicker_UI_key(dp, testid, "2003-03-31", dp.monthField, 2003, 3, 30, 2003, 2, 30);
michael@0 209
michael@0 210 testtag_datepicker_UI_key(dp, testid, "2003-06-15", dp.dateField, 2003, 5, 16, 2003, 5, 15);
michael@0 211 testtag_datepicker_UI_key(dp, testid, "2003-06-01", dp.dateField, 2003, 5, 2, 2003, 5, 1);
michael@0 212 testtag_datepicker_UI_key(dp, testid, "2003-06-30", dp.dateField, 2003, 5, 1, 2003, 5, 30);
michael@0 213 testtag_datepicker_UI_key(dp, testid, "1600-02-28", dp.dateField, 1600, 1, 29, 1600, 1, 28);
michael@0 214 testtag_datepicker_UI_key(dp, testid, "2000-02-28", dp.dateField, 2000, 1, 29, 2000, 1, 28);
michael@0 215 testtag_datepicker_UI_key(dp, testid, "2003-02-28", dp.dateField, 2003, 1, 1, 2003, 1, 28);
michael@0 216 testtag_datepicker_UI_key(dp, testid, "2004-02-28", dp.dateField, 2004, 1, 29, 2004, 1, 28);
michael@0 217 testtag_datepicker_UI_key(dp, testid, "2100-02-28", dp.dateField, 2100, 1, 1, 2100, 1, 28);
michael@0 218
michael@0 219 synthesizeKeyExpectEvent('Z', { altKey: true }, $("key_alt_z"), "command", testid + " alt shortcut");
michael@0 220 synthesizeKeyExpectEvent('Q', { ctrlKey: true }, $("key_ctrl_q"), "command", testid + " ctrl shortcut");
michael@0 221 synthesizeKeyExpectEvent('E', { metaKey: true }, $("key_meta_e"), "command", testid + " meta shortcut");
michael@0 222 }
michael@0 223
michael@0 224 function testtag_datepicker_UI_grid(dp, type, testid)
michael@0 225 {
michael@0 226 testid += "UI ";
michael@0 227
michael@0 228 // check that pressing the cursor keys moves the date properly. For grid
michael@0 229 // types, focus the grid first. For popup types, the grid should be focused
michael@0 230 // automatically when opening the popup.
michael@0 231 var ktarget = dp;
michael@0 232 if (type == "grid")
michael@0 233 dp.focus();
michael@0 234 else
michael@0 235 ktarget = dp.attachedControl;
michael@0 236
michael@0 237 dp.value = "2003-02-22";
michael@0 238
michael@0 239 synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left");
michael@0 240 is(dp.value, "2003-02-21", testid + "key left");
michael@0 241
michael@0 242 synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right");
michael@0 243 is(dp.value, "2003-02-22", testid + "key right");
michael@0 244 synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right next week");
michael@0 245 is(dp.value, "2003-02-23", testid + "key right next week");
michael@0 246 synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left previous week");
michael@0 247 is(dp.value, "2003-02-22", testid + "key left previous week");
michael@0 248
michael@0 249 synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "change", testid + "key up");
michael@0 250 is(dp.value, "2003-02-15", testid + "key up");
michael@0 251 synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "change", testid + "key down");
michael@0 252 is(dp.value, "2003-02-22", testid + "key down");
michael@0 253 synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "change");
michael@0 254 is(dp.value, "2003-03-01", testid + "key down next month", testid + "key down next month");
michael@0 255 synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "change");
michael@0 256 is(dp.value, "2003-02-22", testid + "key up previous month", testid + "key up previous month");
michael@0 257
michael@0 258 // the displayed month may be changed with the page up and page down keys,
michael@0 259 // however this only changes the displayed month, not the current value.
michael@0 260 synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down");
michael@0 261 is(dp.value, "2003-02-22", testid + "key page down");
michael@0 262
michael@0 263 // the monthchange event is fired when the displayed month is changed
michael@0 264 synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "monthchange", testid + "key up after month change");
michael@0 265 is(dp.value, "2003-02-15", testid + "key up after month change");
michael@0 266
michael@0 267 synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up");
michael@0 268 is(dp.value, "2003-02-15", testid + "key page up");
michael@0 269
michael@0 270 // check handling at the start and end of the month
michael@0 271 dp.value = "2010-10-01";
michael@0 272 synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-10-01");
michael@0 273 is(dp.displayedMonth, 8, testid + "key page up 2010-10-01 displayedMonth");
michael@0 274 is(dp.displayedYear, 2010, testid + "key page up 2010-10-01 displayedYear");
michael@0 275
michael@0 276 dp.value = "2010-10-01";
michael@0 277 synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-10-01");
michael@0 278 is(dp.displayedMonth, 10, testid + "key page down 2010-10-01 displayedMonth");
michael@0 279 is(dp.displayedYear, 2010, testid + "key page down 2010-10-01 displayedYear");
michael@0 280
michael@0 281 dp.value = "2010-10-31";
michael@0 282 synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-10-31");
michael@0 283 is(dp.displayedMonth, 8, testid + "key page up 2010-10-31 displayedMonth");
michael@0 284 is(dp.displayedYear, 2010, testid + "key page up 2010-10-01 displayedYear");
michael@0 285 dp.value = "2010-10-31";
michael@0 286 synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-10-31");
michael@0 287 is(dp.displayedMonth, 10, testid + "key page down 2010-10-31 displayedMonth");
michael@0 288 is(dp.displayedYear, 2010, testid + "key page up 2010-10-31 displayedYear");
michael@0 289
michael@0 290 // check handling at the end of february
michael@0 291 dp.value = "2010-03-31";
michael@0 292 synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-03-31");
michael@0 293 is(dp.displayedMonth, 1, testid + "key page up 2010-03-31 displayedMonth");
michael@0 294 is(dp.displayedYear, 2010, testid + "key page up 2010-03-31 displayedYear");
michael@0 295 synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-02-28");
michael@0 296 is(dp.displayedMonth, 0, testid + "key page up 2010-02-28 displayedMonth");
michael@0 297 is(dp.displayedYear, 2010, testid + "key page up 2010-02-28 displayedYear");
michael@0 298
michael@0 299 dp.value = "2010-01-31";
michael@0 300 synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-01-31");
michael@0 301 is(dp.displayedMonth, 1, testid + "key page down 2010-01-31 displayedMonth");
michael@0 302 is(dp.displayedYear, 2010, testid + "key page up 2010-01-31 displayedYear");
michael@0 303 synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-02-28");
michael@0 304 is(dp.displayedMonth, 2, testid + "key page down 2010-02-28 displayedMonth");
michael@0 305 is(dp.displayedYear, 2010, testid + "key page up 2010-02-28 displayedYear");
michael@0 306
michael@0 307 // check handling at the end of february during a leap year
michael@0 308 dp.value = "2008-01-31";
michael@0 309 synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2008-01-31");
michael@0 310 is(dp.displayedMonth, 1, testid + "key page down 2008-01-31 displayedMonth");
michael@0 311 is(dp.displayedYear, 2008, testid + "key page up 2008-01-31 displayedYear");
michael@0 312 dp.value = "2008-03-31";
michael@0 313 synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2008-03-31");
michael@0 314 is(dp.displayedMonth, 1, testid + "key page up 2008-03-31 displayedMonth");
michael@0 315 is(dp.displayedYear, 2008, testid + "key page up 2008-03-31 displayedYear");
michael@0 316
michael@0 317 // the value of a read only datepicker cannot be changed
michael@0 318 dp.value = "2003-02-15";
michael@0 319
michael@0 320 dp.readOnly = true;
michael@0 321 synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "!change", testid + "key left read only");
michael@0 322 is(dp.value, "2003-02-15", testid + "key left read only");
michael@0 323 synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "!change", testid + "key right read only");
michael@0 324 is(dp.value, "2003-02-15", testid + "key right read only");
michael@0 325 synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "!change", testid + "key down read only");
michael@0 326 is(dp.value, "2003-02-15", testid + "key down read only");
michael@0 327 synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "!change", testid + "key up read only");
michael@0 328 is(dp.value, "2003-02-15", testid + "key up read only");
michael@0 329
michael@0 330 // month can still be changed even when readonly
michael@0 331 synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange",
michael@0 332 testid + "key page up read only");
michael@0 333 synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange",
michael@0 334 testid + "key page down read only");
michael@0 335
michael@0 336 dp.readOnly = false;
michael@0 337 synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left changeable again");
michael@0 338 is(dp.value, "2003-02-14", testid + "key left changeable again");
michael@0 339
michael@0 340 // the value of a disabled datepicker cannot be changed
michael@0 341 dp.disabled = true;
michael@0 342 synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "!change", testid + "key left disabled");
michael@0 343 is(dp.value, "2003-02-14", testid + "key left disabled");
michael@0 344 synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "!change", testid + "key right disabled");
michael@0 345 is(dp.value, "2003-02-14", testid + "key right disabled");
michael@0 346 synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "!change", testid + "key down disabled");
michael@0 347 is(dp.value, "2003-02-14", testid + "key down disabled");
michael@0 348 synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "!change", testid + "key up disabled");
michael@0 349 is(dp.value, "2003-02-14", testid + "key up disabled");
michael@0 350
michael@0 351 // month cannot be changed even when disabled
michael@0 352 synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "!monthchange",
michael@0 353 testid + "key page down disabled");
michael@0 354 synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "!monthchange",
michael@0 355 testid + "key page up disabled");
michael@0 356
michael@0 357 dp.disabled = false;
michael@0 358 synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right enabled again");
michael@0 359 is(dp.value, "2003-02-15", testid + "key right enabled again");
michael@0 360 }
michael@0 361
michael@0 362 function testtag_datepicker_UI_popup()
michael@0 363 {
michael@0 364 var dppopup = document.getElementById("datepicker-popup");
michael@0 365 is(dppopup.open, true, "datepicker popup after open");
michael@0 366 testtag_datepicker_UI_grid(dppopup, "popup", "datepicker popup ");
michael@0 367 dppopup.open = false;
michael@0 368 }
michael@0 369
michael@0 370 function testtag_datepicker_UI_key(dp, testid, value, field,
michael@0 371 uyear, umonth, udate,
michael@0 372 dyear, dmonth, ddate)
michael@0 373 {
michael@0 374 dp.value = value;
michael@0 375 field.focus();
michael@0 376
michael@0 377 synthesizeKey("VK_UP", { });
michael@0 378 testtag_comparedate(dp, testid + " " + value + " key up", uyear, umonth, udate);
michael@0 379
michael@0 380 synthesizeKey("VK_DOWN", { });
michael@0 381 testtag_comparedate(dp, testid + " " + value + " key down", dyear, dmonth, ddate);
michael@0 382 }
michael@0 383
michael@0 384 function testtag_getdatestring(year, month, date)
michael@0 385 {
michael@0 386 month = (month < 9) ? ("0" + ++month) : month + 1;
michael@0 387 if (date < 10)
michael@0 388 date = "0" + date;
michael@0 389 return year + "-" + month + "-" + date;
michael@0 390 }
michael@0 391
michael@0 392 function testtag_comparedate(dp, testid, year, month, date, displayedMonth, displayedYear)
michael@0 393 {
michael@0 394 is(dp.value, testtag_getdatestring(year, month, date), testid + " value");
michael@0 395 if (testid.indexOf("initial") == -1)
michael@0 396 is(dp.getAttribute("value"),
michael@0 397 testtag_getdatestring(year, month, date),
michael@0 398 testid + " value attribute");
michael@0 399
michael@0 400 var dateValue = dp.dateValue;
michael@0 401 ok(dateValue.getFullYear() == year &&
michael@0 402 dateValue.getMonth() == month &&
michael@0 403 dateValue.getDate() == date,
michael@0 404 testid + " dateValue");
michael@0 405
michael@0 406 is(dp.year, year, testid + " year");
michael@0 407 is(dp.month, month, testid + " month");
michael@0 408 is(dp.displayedMonth, displayedMonth ? displayedMonth : month, testid + " displayedMonth");
michael@0 409 is(dp.displayedYear, displayedYear ? displayedYear : year, testid + " displayedYear");
michael@0 410 is(dp.date, date, testid + " date");
michael@0 411 }
michael@0 412
michael@0 413 ]]>
michael@0 414
michael@0 415 </script>
michael@0 416
michael@0 417 </window>

mercurial