INPUT_MULTIPLE_FIELDS_UI: Step-up/-down of hour field should respect min/max attributes
[WebKit-https.git] / LayoutTests / fast / forms / time-multiple-fields / time-multiple-fields-readonly-subfield.html
1 <!DOCTYPE html>
2 <body>
3 <script src="../../js/resources/js-test-pre.js"></script>
4 <script>
5 function createTimeInput(min, max, step, value) {
6     var input = document.createElement('input');
7     input.type = 'time';
8     input.min = min;
9     input.max = max;
10     input.step = step;
11     if (value)
12         input.value = value;
13     return input;
14 }
15
16 // FIXME: Rename this function and the test file.
17 function isReadOnlyField(input, pseudo) {
18     var node = internals.youngestShadowRoot(input).querySelector('*[pseudo="' + pseudo + '"]');
19     if (!node)
20         testFailed('Requested node is missing.');
21     return node && node.hasAttribute('disabled');
22 }
23
24 var pseudoMillisecond = '-webkit-datetime-edit-millisecond-field';
25 var pseudoSecond = '-webkit-datetime-edit-second-field';
26 var pseudoMinute = '-webkit-datetime-edit-minute-field';
27 var pseudoHour = '-webkit-datetime-edit-hour-field';
28 var pseudoAMPM = '-webkit-datetime-edit-ampm-field';
29 var step1sec = '1';
30 var step1min = '60';
31 var step1hour = '3600';
32 var step1day = '86400';
33
34 description('Sub-fields in input[type=time] should be read-only in some cases. This requires window.internals.');
35 debug('createTimeInput argument order: min, max, step, value');
36 debug('');
37
38 debug('Milliseconds field:');
39 shouldBeTrue('isReadOnlyField(createTimeInput("00:00:00.500", null, step1sec, ""), pseudoMillisecond)');
40 shouldBeTrue('isReadOnlyField(createTimeInput("00:00:00.500", null, step1sec, "00:00:00.500"), pseudoMillisecond)');
41 shouldBeFalse('isReadOnlyField(createTimeInput("00:00:00.500", null, step1sec, "00:00:00.600"), pseudoMillisecond)');
42 shouldBeFalse('isReadOnlyField(createTimeInput("00:00:00.000", null, step1sec, "00:00:00.600"), pseudoMillisecond)');
43
44 debug('Seconds field:');
45 shouldBeTrue('isReadOnlyField(createTimeInput("00:00:30", null, step1min, ""), pseudoSecond)');
46 shouldBeTrue('isReadOnlyField(createTimeInput("00:00:30", null, step1min, "00:00:30"), pseudoSecond)');
47 shouldBeTrue('isReadOnlyField(createTimeInput("00:00:30.500", null, step1min, "00:00:30.600"), pseudoSecond)');
48 shouldBeFalse('isReadOnlyField(createTimeInput("00:00:30", null, step1min, "00:00:35"), pseudoSecond)');
49 shouldBeFalse('isReadOnlyField(createTimeInput("00:00:00", null, step1min, "00:00:35"), pseudoSecond)');
50
51 debug('Minutes field:');
52 shouldBeTrue('isReadOnlyField(createTimeInput("00:30", null, step1hour, ""), pseudoMinute)');
53 shouldBeTrue('isReadOnlyField(createTimeInput("00:30", null, step1hour, "00:30"), pseudoMinute)');
54 shouldBeFalse('isReadOnlyField(createTimeInput("00:30", null, step1hour, "00:35"), pseudoMinute)');
55 shouldBeFalse('isReadOnlyField(createTimeInput("00:00", null, step1hour, "00:35"), pseudoMinute)');
56
57 debug('Hour field:');
58 shouldBeFalse('isReadOnlyField(createTimeInput("11:00", null, step1day, ""), pseudoHour)');
59 shouldBeFalse('isReadOnlyField(createTimeInput("11:00", null, step1day, ""), pseudoAMPM)');
60 shouldBeTrue('isReadOnlyField(createTimeInput("11:00", null, step1day, ""), pseudoMinute)');
61 shouldBeFalse('isReadOnlyField(createTimeInput("11:30", null, step1day, "11:30"), pseudoHour)');
62 shouldBeFalse('isReadOnlyField(createTimeInput("11:30", null, step1day, "11:30"), pseudoAMPM)');
63 shouldBeTrue('isReadOnlyField(createTimeInput("11:30", null, step1day, "11:30"), pseudoMinute)');
64 shouldBeFalse('isReadOnlyField(createTimeInput("11:30", null, step1day, "12:30"), pseudoHour)');
65 shouldBeFalse('isReadOnlyField(createTimeInput("11:30", null, step1day, "12:30"), pseudoAMPM)');
66 shouldBeTrue('isReadOnlyField(createTimeInput("11:30", null, step1day, "12:30"), pseudoMinute)');
67 shouldBeFalse('isReadOnlyField(createTimeInput("00:00", null, step1day, "12:30"), pseudoHour)');
68 shouldBeFalse('isReadOnlyField(createTimeInput("00:00", null, step1day, "12:30"), pseudoAMPM)');
69 shouldBeFalse('isReadOnlyField(createTimeInput("00:00", null, step1day, "12:30"), pseudoMinute)');
70 shouldBeTrue('isReadOnlyField(createTimeInput("00:00", "00:30", step1min, ""), pseudoHour)');
71 shouldBeTrue('isReadOnlyField(createTimeInput("00:00", "00:30", step1min, ""), pseudoAMPM)');
72 shouldBeFalse('isReadOnlyField(createTimeInput("00:00", "00:30", step1min, ""), pseudoMinute)');
73 shouldBeFalse('isReadOnlyField(createTimeInput("00:00", "00:00", step1hour, ""), pseudoHour)');
74 shouldBeTrue('isReadOnlyField(createTimeInput("00:00", "00:00", step1hour, ""), pseudoAMPM)');
75 shouldBeTrue('isReadOnlyField(createTimeInput("00:00", "00:00", step1hour, ""), pseudoMinute)');
76
77 debug('AM/PM field:');
78 shouldBeFalse('isReadOnlyField(createTimeInput("00:00", null, step1min, ""), pseudoAMPM)');
79 shouldBeFalse('isReadOnlyField(createTimeInput("23:00", null, step1min, ""), pseudoAMPM)');
80 shouldBeFalse('isReadOnlyField(createTimeInput(null, "01:00", step1min, ""), pseudoAMPM)');
81 shouldBeFalse('isReadOnlyField(createTimeInput(null, "23:00", step1min, ""), pseudoAMPM)');
82 shouldBeTrue('isReadOnlyField(createTimeInput("00:00", "11:59", step1min, ""), pseudoAMPM)');
83 shouldBeFalse('isReadOnlyField(createTimeInput("00:00", "12:00", step1min, ""), pseudoAMPM)');
84 shouldBeTrue('isReadOnlyField(createTimeInput("12:00", "12:00", step1min, ""), pseudoAMPM)');
85 shouldBeTrue('isReadOnlyField(createTimeInput("12:00", "23:59", step1min, ""), pseudoAMPM)');
86
87
88 </script>
89 <script src="../../js/resources/js-test-post.js"></script>
90 </body>
91