| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test.js"></script> |
| <script src="../resources/common.js"></script> |
| </head> |
| <body> |
| <script> |
| description('Check stepping-up and -down for datetime-local input fields from renderer.'); |
| |
| var input = document.createElement('input'); |
| |
| document.body.appendChild(input); |
| |
| function keyDown(key, modifiers) |
| { |
| if (!window.eventSender) |
| return; |
| eventSender.keyDown(key, modifiers); |
| } |
| |
| function setInputAttributes(value, min, max, step) { |
| input.value = value; |
| input.min = min; |
| input.max = max; |
| input.step = step; |
| } |
| |
| function test(value, step, min, max, keySequence) { |
| setInputAttributes(value, min, max, step); |
| for (var i = 0; i < keySequence.length; i++) |
| keyDown(keySequence[i]); |
| return input.value; |
| } |
| |
| function stepUp(value, step, min, max) { |
| return test(value, step, min, max, ['ArrowUp']); |
| } |
| |
| function stepDown(value, step, min, max) { |
| return test(value, step, min, max, ['ArrowDown']); |
| } |
| |
| input.type = 'datetime-local'; |
| input.focus(); |
| debug('Function arguments are (value, step, min, max, [keySequence]).'); |
| debug('The hour field respects min/max attributes when they have the same date.'); |
| keyDown('ArrowRight'); |
| keyDown('ArrowRight'); |
| keyDown('ArrowRight'); |
| shouldBeEqualToString('stepUp("2013-01-16T17:00", 1, "2013-01-16T15:00", "2013-01-16T17:00")', '2013-01-16T15:00'); |
| shouldBeEqualToString('stepDown("2013-01-16T15:00", 1, "2013-01-16T15:00", "2013-01-16T17:00")', '2013-01-16T17:00'); |
| shouldBeEqualToString('stepUp("2013-01-16T17:00", 1, "2013-01-16T15:00", "2013-01-17T17:00")', '2013-01-16T18:00'); |
| shouldBeEqualToString('stepDown("2013-01-16T17:00", 1, "2013-01-16T17:00", "2013-01-17T20:00")', '2013-01-16T16:00'); |
| |
| debug('The hour field wraps am/pm.'); |
| shouldBeEqualToString('stepUp("2013-01-16T11:00", 1, "2013-01-16T00:00", "2013-01-16T23:59")', '2013-01-16T12:00'); |
| shouldBeEqualToString('stepUp("2013-01-16T23:00", 1, "2013-01-16T00:00", "2013-01-16T23:59")', '2013-01-16T00:00'); |
| shouldBeEqualToString('stepDown("2013-01-16T12:00", 1, "2013-01-16T00:00", "2013-01-16T23:59")', '2013-01-16T11:00'); |
| shouldBeEqualToString('stepDown("2013-01-16T00:00", 1, "2013-01-16T00:00", "2013-01-16T23:59")', '2013-01-16T23:00'); |
| |
| debug(''); |
| document.body.removeChild(input); |
| </script> |
| </body> |
| </html> |