f9bcf57faae677fdaa9f17b70088dbad58ecafbb
[WebKit-https.git] / LayoutTests / fast / forms / datetimelocal-multiple-fields / datetimelocal-multiple-fields-readonly-subfield.html
1 <!DOCTYPE html>
2 <body>
3 <script src="../../js/resources/js-test-pre.js"></script>
4 <script>
5 function createInput(min, max, step, value) {
6     var input = document.createElement('input');
7     input.type = 'datetime-local';
8     if (min)
9         input.min = min;
10     if (max)
11         input.max = max;
12     if (step)
13         input.step = step;
14     if (value)
15         input.value = value;
16     return input;
17 }
18
19 // FIXME: Rename this function and the test file.
20 function isReadOnlyField(input, pseudo) {
21     var node = internals.youngestShadowRoot(input).querySelector('*[pseudo="' + pseudo + '"]');
22     if (!node)
23         testFailed('Requested node is missing.');
24     return node && node.hasAttribute('disabled');
25 }
26
27 var pseudoMinute = '-webkit-datetime-edit-minute-field';
28 var pseudoHour = '-webkit-datetime-edit-hour-field';
29 var pseudoAMPM = '-webkit-datetime-edit-ampm-field';
30 var step1day = '86400';
31
32 description('Sub-fields in input[type=datetime-local] should be read-only in some cases. This requires window.internals.');
33 debug('createInput argument order: min, max, step, value');
34 debug('');
35
36 debug('Hour field:');
37 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:00", "", step1day, ""), pseudoHour)');
38 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:00", "", step1day, ""), pseudoAMPM)');
39 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:00", "", step1day, ""), pseudoMinute)');
40
41 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:30", "", step1day, "2013-01-16T11:30"), pseudoHour)');
42 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:30", "", step1day, "2013-01-16T11:30"), pseudoAMPM)');
43 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:30", "", step1day, "2013-01-16T11:30"), pseudoMinute)');
44
45 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T11:30", "", step1day, "2013-01-16T12:30"), pseudoHour)');
46 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T11:30", "", step1day, "2013-01-16T12:30"), pseudoAMPM)');
47 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:30", "", step1day, "2013-01-16T12:30"), pseudoMinute)');
48
49 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T00:00", "", step1day, "2013-01-16T12:30"), pseudoHour)');
50 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T00:00", "", step1day, "2013-01-16T12:30"), pseudoAMPM)');
51 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T00:00", "", step1day, "2013-01-16T12:30"), pseudoMinute)');
52
53 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T11:00", "2013-01-16T23:00", step1day, ""), pseudoHour)');
54 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T11:00", "2013-01-16T23:00", step1day, ""), pseudoAMPM)');
55 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:00", "2013-01-16T23:00", step1day, ""), pseudoMinute)');
56
57 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T11:30", "2013-01-16T23:00", step1day, "2013-01-16T11:30"), pseudoHour)');
58 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T11:30", "2013-01-16T23:00", step1day, "2013-01-16T11:30"), pseudoAMPM)');
59 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:30", "2013-01-16T23:00", step1day, "2013-01-16T11:30"), pseudoMinute)');
60
61 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T11:30", "2013-01-16T11:59", step1day, "2013-01-16T11:30"), pseudoHour)');
62 shouldBeFalse('isReadOnlyField(createInput("2013-01-16T11:30", "2013-01-16T11:59", step1day, "2013-01-16T11:30"), pseudoAMPM)');
63 shouldBeTrue('isReadOnlyField(createInput("2013-01-16T11:30", "2013-01-16T11:59", step1day, "2013-01-16T11:30"), pseudoMinute)');
64
65 </script>
66 <script src="../../js/resources/js-test-post.js"></script>
67 </body>
68