4 <script src=
"../../../resources/ahem.js"></script>
5 <script src=
"../../../resources/js-test.js"></script>
8 <p id=
"description"></p>
10 Please run this with DRT or WTR.
12 Test following mouse actions:
14 <li>Mouse click to focus each of sub-fields
</li>
15 <li>Mouse click on the spin button to update each of sub-fields
</li>
17 <input id=
"input" type=
"date" style=
"font-family:ahem; font-size:16px;">
18 <div id=
"console"></div>
20 function keyDown(key
, modifiers
)
22 if (!window
.eventSender
)
24 eventSender
.keyDown(key
, modifiers
);
27 function mouseClickOn(x
, y
)
29 if (!window
.eventSender
)
31 eventSender
.mouseMoveTo(x
+ input
.offsetLeft
, y
+ input
.offsetTop
);
32 eventSender
.mouseDown();
33 eventSender
.mouseUp();
37 description('Multiple fields UI of date input type with mouse events');
38 var input
= document
.getElementById('input');
40 input
.value
= '2345-07-19';
41 var center
= input
.offsetHeight
/ 2;
42 var spinButtonOffset
= 26;
43 var clearButtonOffset
= 41;
45 debug('==> Focus on the month field.');
46 mouseClickOn(12, center
);
48 shouldBeEqualToString('input.value', '2345-08-19');
49 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
- 1);
50 shouldBeEqualToString('input.value', '2345-09-19');
51 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
+ 1);
52 shouldBeEqualToString('input.value', '2345-08-19');
53 shouldBeZero('window.getSelection().rangeCount'); // No text selection.
56 debug('==> Focus on the day field.');
57 mouseClickOn(60, center
);
59 shouldBeEqualToString('input.value', '2345-08-20');
60 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
- 1);
61 shouldBeEqualToString('input.value', '2345-08-21');
62 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
+ 1);
63 shouldBeEqualToString('input.value', '2345-08-20');
64 shouldBeZero('window.getSelection().rangeCount'); // No text selection.
67 debug('==> Focus on the year field.');
68 mouseClickOn(input
.offsetWidth
- 115, center
);
70 shouldBeEqualToString('input.value', '2346-08-20');
71 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
- 1);
72 shouldBeEqualToString('input.value', '2347-08-20');
73 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
+ 1);
74 shouldBeEqualToString('input.value', '2346-08-20');
75 shouldBeZero('window.getSelection().rangeCount'); // No text selection.
78 debug('==> Click on a disabled field.');
79 input
.disabled
= true;
80 mouseClickOn(12, center
);
82 shouldBeEqualToString('input.value', '2346-08-20');
83 input
.disabled
= false;
86 debug('==> Click on a read-only field.');
87 input
.readOnly
= true;
88 mouseClickOn(12, center
);
90 shouldBeEqualToString('input.value', '2346-08-20');
91 input
.readOnly
= false;
94 debug('==> Click on clear button.');
95 input
.readOnly
= true;
96 mouseClickOn(input
.offsetWidth
- clearButtonOffset
, center
);
97 shouldBeEqualToString('input.value', '2346-08-20');
98 input
.disabled
= true;
99 input
.readOnly
= false;
100 mouseClickOn(input
.offsetWidth
- clearButtonOffset
, center
);
101 shouldBeEqualToString('input.value', '2346-08-20');
102 input
.disabled
= false;
103 mouseClickOn(input
.offsetWidth
- clearButtonOffset
, center
);
104 shouldBeEqualToString('input.value', '');