Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / week-multiple-fields / week-multiple-fields-mouse-events.html
blobe925b1de54d2c5f0725cfbf0d517d6b66b7451bf
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/ahem.js"></script>
5 <script src="../../../resources/js-test.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <p>
10 Please run this with DRT or WTR.
11 </p>
12 Test following mouse actions:
13 <ul>
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>
16 </ul>
17 <input id="input" type="week" style="font-family:ahem; font-size:16px;">
18 <div id="console"></div>
19 <script>
20 function keyDown(key, modifiers)
22 if (!window.eventSender)
23 return;
24 eventSender.keyDown(key, modifiers);
27 function mouseClickOn(x, y)
29 if (!window.eventSender)
30 return;
31 eventSender.mouseMoveTo(x + input.offsetLeft, y + input.offsetTop);
32 eventSender.mouseDown();
33 eventSender.mouseUp();
36 onload = function() {
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);
47 keyDown('upArrow');
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.
55 debug('');
56 debug('==> Focus on the year field.');
57 mouseClickOn(200, center);
58 keyDown('upArrow');
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.
66 debug('');
67 debug('==> Click on a disabled field.');
68 input.disabled = true;
69 mouseClickOn(100, center);
70 keyDown('upArrow');
71 shouldBeEqualToString('input.value', '2346-W08');
72 input.disabled = false;
74 debug('');
75 debug('==> Click on a read-only field.');
76 input.readOnly = true;
77 mouseClickOn(12, center);
78 keyDown('upArrow');
79 shouldBeEqualToString('input.value', '2346-W08');
80 input.readOnly = false;
82 debug('');
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', '');
95 debug('');
97 </script>
98 </body>
99 </html>