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=
"week" 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-W07';
41 var center
= input
.offsetHeight
/ 2;
42 var spinButtonOffset
= 26;
43 var clearButtonOffset
= 41;
45 debug('==> Focus on the week field.');
46 mouseClickOn(100, center
);
48 shouldBeEqualToString('input.value', '2345-W08');
49 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
- 1);
50 shouldBeEqualToString('input.value', '2345-W09');
51 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
+ 1);
52 shouldBeEqualToString('input.value', '2345-W08');
53 shouldBeZero('window.getSelection().rangeCount'); // No text selection.
56 debug('==> Focus on the year field.');
57 mouseClickOn(200, center
);
59 shouldBeEqualToString('input.value', '2346-W08');
60 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
- 1);
61 shouldBeEqualToString('input.value', '2347-W08');
62 mouseClickOn(input
.offsetWidth
- spinButtonOffset
, center
+ 1);
63 shouldBeEqualToString('input.value', '2346-W08');
64 shouldBeZero('window.getSelection().rangeCount'); // No text selection.
67 debug('==> Click on a disabled field.');
68 input
.disabled
= true;
69 mouseClickOn(100, center
);
71 shouldBeEqualToString('input.value', '2346-W08');
72 input
.disabled
= false;
75 debug('==> Click on a read-only field.');
76 input
.readOnly
= true;
77 mouseClickOn(12, center
);
79 shouldBeEqualToString('input.value', '2346-W08');
80 input
.readOnly
= false;
83 debug('==> Click on clear button.');
84 input
.readOnly
= true;
85 mouseClickOn(input
.offsetWidth
- clearButtonOffset
, center
);
86 shouldBeEqualToString('input.value', '2346-W08');
87 input
.disabled
= true;
88 input
.readOnly
= false;
89 mouseClickOn(input
.offsetWidth
- clearButtonOffset
, center
);
90 shouldBeEqualToString('input.value', '2346-W08');
91 input
.disabled
= false;
92 mouseClickOn(input
.offsetWidth
- clearButtonOffset
, center
);
93 shouldBeEqualToString('input.value', '');