summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-stepup-stepdown-from-renderer.html
blob: c2496af09697d0658c5c5796d0933fbf353ec9ae (plain)
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
<!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, ['upArrow']);
}

function stepDown(value, step, min, max) {
    return test(value, step, min, max, ['downArrow']);
}

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('rightArrow');
keyDown('rightArrow');
keyDown('rightArrow');
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('');
document.body.removeChild(input);
</script>
</body>
</html>