1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<p>
Please run this with DRT or WTR.
</p>
Test following mouse actions:
<ul>
<li>Mouse click to focus each of sub-fields</li>
<li>Mouse click on the spin button to update each of sub-fields</li>
</ul>
<input id="input" type="datetime-local" style="font-family:ahem; font-size:16px;">
<div id="console"></div>
<script>
description('Multiple fields UI of datetime-local input type with mouse events');
var input = document.getElementById('input');
function keyDown(key, modifiers)
{
if (!window.eventSender)
return;
eventSender.keyDown(key, modifiers);
}
function mouseClickOn(x, y)
{
if (!window.eventSender)
return;
eventSender.mouseMoveTo(x + input.offsetLeft, y + input.offsetTop);
eventSender.mouseDown();
eventSender.mouseUp();
}
input.value = '2345-07-19T10:00';
var center = input.offsetHeight / 2;
var spinButtonOffset = 26;
var clearButtonOffset = 41;
debug('==> Focus on the month field.');
mouseClickOn(12, center);
keyDown('upArrow');
shouldBeEqualToString('input.value', '2345-08-19T10:00');
mouseClickOn(input.offsetWidth - spinButtonOffset, center - 1);
shouldBeEqualToString('input.value', '2345-09-19T10:00');
mouseClickOn(input.offsetWidth - spinButtonOffset, center + 1);
shouldBeEqualToString('input.value', '2345-08-19T10:00');
shouldBeZero('window.getSelection().rangeCount'); // No text selection.
debug('');
debug('==> Focus on the day field.');
mouseClickOn(60, center);
keyDown('upArrow');
shouldBeEqualToString('input.value', '2345-08-20T10:00');
mouseClickOn(input.offsetWidth - spinButtonOffset, center - 1);
shouldBeEqualToString('input.value', '2345-08-21T10:00');
mouseClickOn(input.offsetWidth - spinButtonOffset, center + 1);
shouldBeEqualToString('input.value', '2345-08-20T10:00');
shouldBeZero('window.getSelection().rangeCount'); // No text selection.
debug('');
debug('==> Focus on the year field.');
mouseClickOn(108, center);
keyDown('upArrow');
shouldBeEqualToString('input.value', '2346-08-20T10:00');
mouseClickOn(input.offsetWidth - spinButtonOffset, center - 1);
shouldBeEqualToString('input.value', '2347-08-20T10:00');
mouseClickOn(input.offsetWidth - spinButtonOffset, center + 1);
shouldBeEqualToString('input.value', '2346-08-20T10:00');
shouldBeZero('window.getSelection().rangeCount'); // No text selection.
debug('');
debug('==> Focus on the hour field.');
mouseClickOn(190, center);
keyDown('upArrow');
shouldBeEqualToString('input.value', '2346-08-20T11:00');
mouseClickOn(input.offsetWidth - spinButtonOffset, center - 1);
shouldBeEqualToString('input.value', '2346-08-20T00:00');
mouseClickOn(input.offsetWidth - spinButtonOffset, center + 1);
shouldBeEqualToString('input.value', '2346-08-20T11:00');
shouldBeZero('window.getSelection().rangeCount'); // No text selection.
debug('');
debug('==> Focus on the minute field.');
mouseClickOn(240, center);
keyDown('upArrow');
shouldBeEqualToString('input.value', '2346-08-20T11:01');
mouseClickOn(input.offsetWidth - spinButtonOffset, center - 1);
shouldBeEqualToString('input.value', '2346-08-20T11:02');
mouseClickOn(input.offsetWidth - spinButtonOffset, center + 1);
shouldBeEqualToString('input.value', '2346-08-20T11:01');
shouldBeZero('window.getSelection().rangeCount'); // No text selection.
debug('');
debug('==> Click on a disabled field.');
input.disabled = true;
mouseClickOn(12, center);
keyDown('upArrow');
shouldBeEqualToString('input.value', '2346-08-20T11:01');
input.disabled = false;
debug('');
debug('==> Click on a read-only field.');
input.readOnly = true;
mouseClickOn(12, center);
keyDown('upArrow');
shouldBeEqualToString('input.value', '2346-08-20T11:01');
input.readOnly = false;
debug('');
debug('==> Click on clear button.');
input.readOnly = true;
mouseClickOn(input.offsetWidth - clearButtonOffset, center);
shouldBeEqualToString('input.value', '2346-08-20T11:01');
input.disabled = true;
input.readOnly = false;
mouseClickOn(input.offsetWidth - clearButtonOffset, center);
shouldBeEqualToString('input.value', '2346-08-20T11:01');
input.disabled = false;
mouseClickOn(input.offsetWidth - clearButtonOffset, center);
shouldBeEqualToString('input.value', '');
debug('');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
|