2007-07-25 11:07:13 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
2011-07-01 17:52:32 -07:00
|
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
2007-07-25 11:07:13 -07:00
|
|
|
<!--
|
|
|
|
XUL Widget Test for datepicker
|
|
|
|
-->
|
|
|
|
<window title="datepicker" width="500" height="600"
|
|
|
|
onload="setTimeout(testtag_datepickers, 0);"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
2011-07-01 17:52:32 -07:00
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
2007-07-25 11:07:13 -07:00
|
|
|
|
2007-08-16 21:22:18 -07:00
|
|
|
<hbox onpopupshown="testtag_datepicker_UI_popup()"
|
|
|
|
onpopuphidden="testtag_finish()">
|
2007-07-25 11:07:13 -07:00
|
|
|
<datepicker id="datepicker"/>
|
|
|
|
<datepicker id="datepicker-popup" type="popup"/>
|
2011-12-08 01:21:32 -08:00
|
|
|
<hbox onDOMMouseScroll="mouseScrolled = event.defaultPrevented;">
|
2011-07-01 17:52:30 -07:00
|
|
|
<datepicker id="datepicker-grid" type="grid"/>
|
|
|
|
</hbox>
|
2007-08-16 21:22:18 -07:00
|
|
|
</hbox>
|
2007-07-25 11:07:13 -07:00
|
|
|
|
2009-08-17 15:26:08 -07:00
|
|
|
<!-- Test-only key bindings, but must not conflict with the application. -->
|
2008-01-31 18:52:36 -08:00
|
|
|
<keyset id="mainKeyset">
|
2009-08-17 15:26:08 -07:00
|
|
|
<key id="key_alt_z" key="Z" oncommand="return" modifiers="alt"/>
|
2008-01-31 18:52:36 -08:00
|
|
|
<key id="key_ctrl_q" key="Q" oncommand="return" modifiers="control"/>
|
|
|
|
<key id="key_meta_e" key="E" oncommand="return" modifiers="meta"/>
|
|
|
|
</keyset>
|
|
|
|
|
2007-07-25 11:07:13 -07:00
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<![CDATA[
|
|
|
|
|
2011-07-01 17:52:30 -07:00
|
|
|
var mouseScrolled = false;
|
|
|
|
|
2007-07-25 11:07:13 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
function testtag_datepickers()
|
|
|
|
{
|
2007-08-16 21:22:18 -07:00
|
|
|
var dppopup = document.getElementById("datepicker-popup");
|
2007-07-25 11:07:13 -07:00
|
|
|
testtag_datepicker(document.getElementById("datepicker"), "", "datepicker");
|
2007-08-16 21:22:18 -07:00
|
|
|
testtag_datepicker(dppopup, "popup", "datepicker popup");
|
2007-07-25 11:07:13 -07:00
|
|
|
testtag_datepicker(document.getElementById("datepicker-grid"), "grid", "datepicker grid");
|
2007-08-16 21:22:18 -07:00
|
|
|
dppopup.open = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function testtag_finish()
|
|
|
|
{
|
|
|
|
ok(!document.getElementById("datepicker-popup").open, "datepicker popup open false again");
|
2011-07-01 17:52:30 -07:00
|
|
|
|
|
|
|
var dpgrid = document.getElementById("datepicker-grid");
|
2012-08-11 18:42:36 -07:00
|
|
|
synthesizeWheel(dpgrid, 5, 5, { deltaY: 10.0,
|
|
|
|
deltaMode: WheelEvent.DOM_DELTA_LINE });
|
2011-07-01 17:52:32 -07:00
|
|
|
is(mouseScrolled, true, "mouse scrolled");
|
2011-07-01 17:52:30 -07:00
|
|
|
is(dpgrid.displayedMonth, 2, "mouse scroll changed month");
|
|
|
|
|
2007-07-25 11:07:13 -07:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
function testtag_datepicker(dp, type, testid)
|
|
|
|
{
|
|
|
|
testid += " ";
|
|
|
|
|
|
|
|
var today = new Date();
|
|
|
|
var tyear = today.getFullYear();
|
|
|
|
var tmonth = today.getMonth();
|
|
|
|
var tdate = today.getDate();
|
|
|
|
|
|
|
|
// testtag_comparedate(dp, testid + "initial", tyear, tmonth, tdate);
|
|
|
|
|
|
|
|
// check that setting the value property works
|
|
|
|
dp.value = testtag_getdatestring(tyear, tmonth, tdate);
|
|
|
|
testtag_comparedate(dp, testid + "set value", tyear, tmonth, tdate);
|
|
|
|
|
|
|
|
// check that setting the dateValue property works
|
|
|
|
dp.dateValue = today;
|
|
|
|
testtag_comparedate(dp, testid + "set dateValue", tyear, tmonth, tdate);
|
|
|
|
ok(dp.value !== today, testid + " set dateValue different date");
|
|
|
|
|
|
|
|
ok(!dp.readOnly, testid + "readOnly");
|
|
|
|
dp.readOnly = true;
|
|
|
|
ok(dp.readOnly, testid + "set readOnly");
|
|
|
|
dp.readOnly = false;
|
|
|
|
ok(!dp.readOnly, testid + "clear readOnly");
|
|
|
|
|
|
|
|
var setDateField = function(field, value, expectException,
|
|
|
|
expectedYear, expectedMonth, expectedDate)
|
|
|
|
{
|
|
|
|
var exh = false;
|
|
|
|
try {
|
|
|
|
dp[field] = value;
|
|
|
|
} catch (ex) { exh = true; }
|
|
|
|
is(exh, expectException, testid + "set " + field + " " + value);
|
|
|
|
testtag_comparedate(dp, testid + "set " + field + " " + value,
|
|
|
|
expectedYear, expectedMonth, expectedDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
// check the value property
|
|
|
|
setDateField("value", "2003-1-27", false, 2003, 0, 27);
|
|
|
|
setDateField("value", "2002-11-8", false, 2002, 10, 8);
|
|
|
|
setDateField("value", "2001-07-02", false, 2001, 6, 2);
|
|
|
|
setDateField("value", "2002-10-25", false, 2002, 9, 25);
|
|
|
|
|
|
|
|
// check that the year, month and date fields can be set properly
|
|
|
|
setDateField("year", 2002, false, 2002, 9, 25);
|
|
|
|
setDateField("year", 0, true, 2002, 9, 25);
|
|
|
|
|
|
|
|
setDateField("month", 6, false, 2002, 6, 25);
|
|
|
|
setDateField("month", 9, false, 2002, 9, 25);
|
|
|
|
setDateField("month", 10, false, 2002, 10, 25);
|
|
|
|
setDateField("month", -1, true, 2002, 10, 25);
|
|
|
|
setDateField("month", 12, true, 2002, 10, 25);
|
|
|
|
|
|
|
|
setDateField("date", 9, false, 2002, 10, 9);
|
|
|
|
setDateField("date", 10, false, 2002, 10, 10);
|
|
|
|
setDateField("date", 15, false, 2002, 10, 15);
|
|
|
|
setDateField("date", 0, true, 2002, 10, 15);
|
|
|
|
setDateField("date", 32, true, 2002, 10, 15);
|
|
|
|
|
|
|
|
// check that dates overflow properly
|
|
|
|
setDateField("value", "2002-2-40", false, 2002, 2, 12);
|
|
|
|
setDateField("value", "2003-03-32", false, 2003, 3, 1);
|
|
|
|
setDateField("value", "2003-12-32", false, 2004, 0, 1);
|
|
|
|
|
|
|
|
// check leap year handling
|
|
|
|
setDateField("value", "1600-2-29", false, 1600, 1, 29);
|
|
|
|
setDateField("value", "2000-2-29", false, 2000, 1, 29);
|
|
|
|
setDateField("value", "2003-2-29", false, 2003, 2, 1);
|
|
|
|
setDateField("value", "2004-2-29", false, 2004, 1, 29);
|
|
|
|
setDateField("value", "2100-2-29", false, 2100, 2, 1);
|
|
|
|
|
|
|
|
// check invalid values for the value and dateValue properties
|
|
|
|
dp.value = "2002-07-15";
|
|
|
|
setDateField("value", "", true, 2002, 6, 15);
|
|
|
|
setDateField("value", "2-2", true, 2002, 6, 15);
|
|
|
|
setDateField("value", "2000-5-6-6", true, 2002, 6, 15);
|
|
|
|
setDateField("value", "2000-a-19", true, 2002, 6, 15);
|
|
|
|
setDateField("dateValue", "none", true, 2002, 6, 15);
|
|
|
|
|
2011-04-13 10:53:24 -07:00
|
|
|
// grid and popup types can display a different month than the current one
|
|
|
|
var isGridOrPopup = (type == "grid" || type == "popup");
|
|
|
|
dp.displayedMonth = 3;
|
|
|
|
testtag_comparedate(dp, testid + "set displayedMonth",
|
|
|
|
2002, isGridOrPopup ? 6 : 3, 15, 3);
|
|
|
|
|
|
|
|
dp.displayedYear = 2009;
|
|
|
|
testtag_comparedate(dp, testid + "set displayedYear",
|
|
|
|
isGridOrPopup ? 2002 : 2009, isGridOrPopup ? 6 : 3, 15, 3, 2009);
|
|
|
|
|
|
|
|
if (isGridOrPopup) {
|
|
|
|
dp.value = "2008-02-29";
|
|
|
|
dp.displayedYear = 2009;
|
|
|
|
is(dp.displayedMonth, 1, "set displayedYear during leap year");
|
|
|
|
}
|
|
|
|
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.open, false, testid + "open false");
|
2007-08-16 21:22:18 -07:00
|
|
|
if (type != "popup") {
|
|
|
|
dp.open = true;
|
2007-07-25 11:07:13 -07:00
|
|
|
ok(!dp.open, testid + "open still false");
|
|
|
|
}
|
|
|
|
|
|
|
|
// check the fields
|
|
|
|
if (type != "grid") {
|
|
|
|
ok(dp.yearField instanceof HTMLInputElement, testid + "yearField");
|
|
|
|
ok(dp.monthField instanceof HTMLInputElement, testid + "monthField");
|
|
|
|
ok(dp.dateField instanceof HTMLInputElement, testid + "dateField");
|
|
|
|
|
|
|
|
testtag_datepicker_UI_fields(dp, testid);
|
|
|
|
|
|
|
|
dp.readOnly = true;
|
|
|
|
|
|
|
|
// check that keyboard usage doesn't change the value when the datepicker
|
|
|
|
// is read only
|
|
|
|
testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-01-29",
|
|
|
|
dp.yearField, 2003, 0, 29, 2003, 0, 29);
|
|
|
|
testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-04-29",
|
|
|
|
dp.monthField, 2003, 3, 29, 2003, 3, 29);
|
|
|
|
testtag_datepicker_UI_key(dp, testid + "readonly ", "2003-06-15",
|
|
|
|
dp.dateField, 2003, 5, 15, 2003, 5, 15);
|
2007-08-16 21:22:18 -07:00
|
|
|
|
|
|
|
dp.readOnly = false;
|
2007-07-25 11:07:13 -07:00
|
|
|
}
|
|
|
|
else {
|
2007-08-16 21:22:18 -07:00
|
|
|
testtag_datepicker_UI_grid(dp, "grid", testid);
|
2007-07-25 11:07:13 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function testtag_datepicker_UI_fields(dp, testid)
|
|
|
|
{
|
|
|
|
testid += "UI";
|
|
|
|
dp.focus();
|
|
|
|
|
|
|
|
// test adjusting the date with the up and down keys
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-01-29", dp.yearField, 2004, 0, 29, 2003, 0, 29);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "1600-02-29", dp.yearField, 1601, 1, 28, 1600, 1, 28);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2000-02-29", dp.yearField, 2001, 1, 28, 2000, 1, 28);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2004-02-29", dp.yearField, 2005, 1, 28, 2004, 1, 28);
|
|
|
|
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-04-29", dp.monthField, 2003, 4, 29, 2003, 3, 29);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-01-15", dp.monthField, 2003, 1, 15, 2003, 0, 15);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-12-29", dp.monthField, 2003, 0, 29, 2003, 11, 29);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-03-31", dp.monthField, 2003, 3, 30, 2003, 2, 30);
|
|
|
|
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-06-15", dp.dateField, 2003, 5, 16, 2003, 5, 15);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-06-01", dp.dateField, 2003, 5, 2, 2003, 5, 1);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-06-30", dp.dateField, 2003, 5, 1, 2003, 5, 30);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "1600-02-28", dp.dateField, 1600, 1, 29, 1600, 1, 28);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2000-02-28", dp.dateField, 2000, 1, 29, 2000, 1, 28);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2003-02-28", dp.dateField, 2003, 1, 1, 2003, 1, 28);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2004-02-28", dp.dateField, 2004, 1, 29, 2004, 1, 28);
|
|
|
|
testtag_datepicker_UI_key(dp, testid, "2100-02-28", dp.dateField, 2100, 1, 1, 2100, 1, 28);
|
2008-01-31 18:52:36 -08:00
|
|
|
|
2009-08-17 15:26:08 -07:00
|
|
|
synthesizeKeyExpectEvent('Z', { altKey: true }, $("key_alt_z"), "command", testid + " alt shortcut");
|
2008-01-31 18:52:36 -08:00
|
|
|
synthesizeKeyExpectEvent('Q', { ctrlKey: true }, $("key_ctrl_q"), "command", testid + " ctrl shortcut");
|
|
|
|
synthesizeKeyExpectEvent('E', { metaKey: true }, $("key_meta_e"), "command", testid + " meta shortcut");
|
2007-07-25 11:07:13 -07:00
|
|
|
}
|
|
|
|
|
2007-08-16 21:22:18 -07:00
|
|
|
function testtag_datepicker_UI_grid(dp, type, testid)
|
2007-07-25 11:07:13 -07:00
|
|
|
{
|
|
|
|
testid += "UI ";
|
|
|
|
|
2007-08-16 21:22:18 -07:00
|
|
|
// check that pressing the cursor keys moves the date properly. For grid
|
|
|
|
// types, focus the grid first. For popup types, the grid should be focused
|
|
|
|
// automatically when opening the popup.
|
|
|
|
var ktarget = dp;
|
|
|
|
if (type == "grid")
|
|
|
|
dp.focus();
|
|
|
|
else
|
|
|
|
ktarget = dp.attachedControl;
|
|
|
|
|
2007-07-25 11:07:13 -07:00
|
|
|
dp.value = "2003-02-22";
|
|
|
|
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-21", testid + "key left");
|
2007-08-16 21:22:18 -07:00
|
|
|
|
|
|
|
synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-22", testid + "key right");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right next week");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-23", testid + "key right next week");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left previous week");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-22", testid + "key left previous week");
|
|
|
|
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "change", testid + "key up");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-15", testid + "key up");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "change", testid + "key down");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-22", testid + "key down");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "change");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-03-01", testid + "key down next month", testid + "key down next month");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "change");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-22", testid + "key up previous month", testid + "key up previous month");
|
|
|
|
|
|
|
|
// the displayed month may be changed with the page up and page down keys,
|
|
|
|
// however this only changes the displayed month, not the current value.
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-22", testid + "key page down");
|
|
|
|
|
|
|
|
// the monthchange event is fired when the displayed month is changed
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "monthchange", testid + "key up after month change");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-15", testid + "key up after month change");
|
|
|
|
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-15", testid + "key page up");
|
|
|
|
|
2011-04-13 10:53:24 -07:00
|
|
|
// check handling at the start and end of the month
|
|
|
|
dp.value = "2010-10-01";
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-10-01");
|
|
|
|
is(dp.displayedMonth, 8, testid + "key page up 2010-10-01 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2010, testid + "key page up 2010-10-01 displayedYear");
|
|
|
|
|
|
|
|
dp.value = "2010-10-01";
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-10-01");
|
|
|
|
is(dp.displayedMonth, 10, testid + "key page down 2010-10-01 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2010, testid + "key page down 2010-10-01 displayedYear");
|
|
|
|
|
|
|
|
dp.value = "2010-10-31";
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-10-31");
|
|
|
|
is(dp.displayedMonth, 8, testid + "key page up 2010-10-31 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2010, testid + "key page up 2010-10-01 displayedYear");
|
|
|
|
dp.value = "2010-10-31";
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-10-31");
|
|
|
|
is(dp.displayedMonth, 10, testid + "key page down 2010-10-31 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2010, testid + "key page up 2010-10-31 displayedYear");
|
|
|
|
|
|
|
|
// check handling at the end of february
|
|
|
|
dp.value = "2010-03-31";
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-03-31");
|
|
|
|
is(dp.displayedMonth, 1, testid + "key page up 2010-03-31 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2010, testid + "key page up 2010-03-31 displayedYear");
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2010-02-28");
|
|
|
|
is(dp.displayedMonth, 0, testid + "key page up 2010-02-28 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2010, testid + "key page up 2010-02-28 displayedYear");
|
|
|
|
|
|
|
|
dp.value = "2010-01-31";
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-01-31");
|
|
|
|
is(dp.displayedMonth, 1, testid + "key page down 2010-01-31 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2010, testid + "key page up 2010-01-31 displayedYear");
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2010-02-28");
|
|
|
|
is(dp.displayedMonth, 2, testid + "key page down 2010-02-28 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2010, testid + "key page up 2010-02-28 displayedYear");
|
|
|
|
|
|
|
|
// check handling at the end of february during a leap year
|
|
|
|
dp.value = "2008-01-31";
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange", testid + "key page down 2008-01-31");
|
|
|
|
is(dp.displayedMonth, 1, testid + "key page down 2008-01-31 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2008, testid + "key page up 2008-01-31 displayedYear");
|
|
|
|
dp.value = "2008-03-31";
|
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange", testid + "key page up 2008-03-31");
|
|
|
|
is(dp.displayedMonth, 1, testid + "key page up 2008-03-31 displayedMonth");
|
|
|
|
is(dp.displayedYear, 2008, testid + "key page up 2008-03-31 displayedYear");
|
|
|
|
|
2007-07-25 11:07:13 -07:00
|
|
|
// the value of a read only datepicker cannot be changed
|
2011-04-13 10:53:24 -07:00
|
|
|
dp.value = "2003-02-15";
|
|
|
|
|
2007-07-25 11:07:13 -07:00
|
|
|
dp.readOnly = true;
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "!change", testid + "key left read only");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-15", testid + "key left read only");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "!change", testid + "key right read only");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-15", testid + "key right read only");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "!change", testid + "key down read only");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-15", testid + "key down read only");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "!change", testid + "key up read only");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-15", testid + "key up read only");
|
|
|
|
|
|
|
|
// month can still be changed even when readonly
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "monthchange",
|
2007-07-25 11:07:13 -07:00
|
|
|
testid + "key page up read only");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "monthchange",
|
2007-07-25 11:07:13 -07:00
|
|
|
testid + "key page down read only");
|
|
|
|
|
|
|
|
dp.readOnly = false;
|
2010-05-13 05:19:50 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "change", testid + "key left changeable again");
|
|
|
|
is(dp.value, "2003-02-14", testid + "key left changeable again");
|
2007-07-25 11:07:13 -07:00
|
|
|
|
|
|
|
// the value of a disabled datepicker cannot be changed
|
|
|
|
dp.disabled = true;
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_LEFT", { }, ktarget, "!change", testid + "key left disabled");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-14", testid + "key left disabled");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "!change", testid + "key right disabled");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-14", testid + "key right disabled");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_DOWN", { }, ktarget, "!change", testid + "key down disabled");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-14", testid + "key down disabled");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_UP", { }, ktarget, "!change", testid + "key up disabled");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-14", testid + "key up disabled");
|
|
|
|
|
|
|
|
// month cannot be changed even when disabled
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, ktarget, "!monthchange",
|
2007-07-25 11:07:13 -07:00
|
|
|
testid + "key page down disabled");
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_PAGE_UP", { }, ktarget, "!monthchange",
|
2007-07-25 11:07:13 -07:00
|
|
|
testid + "key page up disabled");
|
|
|
|
|
|
|
|
dp.disabled = false;
|
2007-08-16 21:22:18 -07:00
|
|
|
synthesizeKeyExpectEvent("VK_RIGHT", { }, ktarget, "change", testid + "key right enabled again");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.value, "2003-02-15", testid + "key right enabled again");
|
|
|
|
}
|
|
|
|
|
2007-08-16 21:22:18 -07:00
|
|
|
function testtag_datepicker_UI_popup()
|
|
|
|
{
|
|
|
|
var dppopup = document.getElementById("datepicker-popup");
|
|
|
|
is(dppopup.open, true, "datepicker popup after open");
|
|
|
|
testtag_datepicker_UI_grid(dppopup, "popup", "datepicker popup ");
|
|
|
|
dppopup.open = false;
|
|
|
|
}
|
|
|
|
|
2007-07-25 11:07:13 -07:00
|
|
|
function testtag_datepicker_UI_key(dp, testid, value, field,
|
|
|
|
uyear, umonth, udate,
|
|
|
|
dyear, dmonth, ddate)
|
|
|
|
{
|
|
|
|
dp.value = value;
|
|
|
|
field.focus();
|
|
|
|
|
|
|
|
synthesizeKey("VK_UP", { });
|
|
|
|
testtag_comparedate(dp, testid + " " + value + " key up", uyear, umonth, udate);
|
|
|
|
|
|
|
|
synthesizeKey("VK_DOWN", { });
|
|
|
|
testtag_comparedate(dp, testid + " " + value + " key down", dyear, dmonth, ddate);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testtag_getdatestring(year, month, date)
|
|
|
|
{
|
|
|
|
month = (month < 9) ? ("0" + ++month) : month + 1;
|
|
|
|
if (date < 10)
|
|
|
|
date = "0" + date;
|
|
|
|
return year + "-" + month + "-" + date;
|
|
|
|
}
|
|
|
|
|
2011-04-13 10:53:24 -07:00
|
|
|
function testtag_comparedate(dp, testid, year, month, date, displayedMonth, displayedYear)
|
2007-07-25 11:07:13 -07:00
|
|
|
{
|
|
|
|
is(dp.value, testtag_getdatestring(year, month, date), testid + " value");
|
|
|
|
if (testid.indexOf("initial") == -1)
|
|
|
|
is(dp.getAttribute("value"),
|
|
|
|
testtag_getdatestring(year, month, date),
|
|
|
|
testid + " value attribute");
|
|
|
|
|
|
|
|
var dateValue = dp.dateValue;
|
|
|
|
ok(dateValue.getFullYear() == year &&
|
|
|
|
dateValue.getMonth() == month &&
|
|
|
|
dateValue.getDate() == date,
|
|
|
|
testid + " dateValue");
|
|
|
|
|
|
|
|
is(dp.year, year, testid + " year");
|
|
|
|
is(dp.month, month, testid + " month");
|
2011-04-13 10:53:24 -07:00
|
|
|
is(dp.displayedMonth, displayedMonth ? displayedMonth : month, testid + " displayedMonth");
|
|
|
|
is(dp.displayedYear, displayedYear ? displayedYear : year, testid + " displayedYear");
|
2007-07-25 11:07:13 -07:00
|
|
|
is(dp.date, date, testid + " date");
|
|
|
|
}
|
|
|
|
|
|
|
|
]]>
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</window>
|