Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / datetimelocal-multiple-fields / datetimelocal-multiple-fields-stepup-stepdown-from-renderer.html
blobc2496af09697d0658c5c5796d0933fbf353ec9ae
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <script src="../resources/common.js"></script>
6 </head>
7 <body>
8 <script>
9 description('Check stepping-up and -down for datetime-local input fields from renderer.');
11 var input = document.createElement('input');
13 document.body.appendChild(input);
15 function keyDown(key, modifiers)
17 if (!window.eventSender)
18 return;
19 eventSender.keyDown(key, modifiers);
22 function setInputAttributes(value, min, max, step) {
23 input.value = value;
24 input.min = min;
25 input.max = max;
26 input.step = step;
29 function test(value, step, min, max, keySequence) {
30 setInputAttributes(value, min, max, step);
31 for (var i = 0; i < keySequence.length; i++)
32 keyDown(keySequence[i]);
33 return input.value;
36 function stepUp(value, step, min, max) {
37 return test(value, step, min, max, ['upArrow']);
40 function stepDown(value, step, min, max) {
41 return test(value, step, min, max, ['downArrow']);
44 input.type = 'datetime-local';
45 input.focus();
46 debug('Function arguments are (value, step, min, max, [keySequence]).');
47 debug('The hour field respects min/max attributes when they have the same date.');
48 keyDown('rightArrow');
49 keyDown('rightArrow');
50 keyDown('rightArrow');
51 shouldBeEqualToString('stepUp("2013-01-16T17:00", 1, "2013-01-16T15:00", "2013-01-16T17:00")', '2013-01-16T15:00');
52 shouldBeEqualToString('stepDown("2013-01-16T15:00", 1, "2013-01-16T15:00", "2013-01-16T17:00")', '2013-01-16T17:00');
53 shouldBeEqualToString('stepUp("2013-01-16T17:00", 1, "2013-01-16T15:00", "2013-01-17T17:00")', '2013-01-16T18:00');
54 shouldBeEqualToString('stepDown("2013-01-16T17:00", 1, "2013-01-16T17:00", "2013-01-17T20:00")', '2013-01-16T16:00');
56 debug('');
57 document.body.removeChild(input);
58 </script>
59 </body>
60 </html>