3 <script src=
"../../../resources/js-test.js"></script>
5 function createDateInput(min
, max
, value
) {
6 var input
= document
.createElement('input');
17 // FIXME: Rename this function and the test file.
18 function isReadOnlyField(input
, pseudo
) {
19 var node
= internals
.youngestShadowRoot(input
).querySelector('*[pseudo="' + pseudo
+ '"]');
21 testFailed('Requested node is missing.');
22 return node
&& node
.hasAttribute('disabled');
25 var pseudoDay
= '-webkit-datetime-edit-day-field';
26 var pseudoMonth
= '-webkit-datetime-edit-month-field';
27 var pseudoYear
= '-webkit-datetime-edit-year-field';
29 description('Sub-fields in input[type=date] should be read-only in some cases. This requires window.internals.');
30 debug('createDateInput argument order: min, max, value');
34 shouldBeFalse('isReadOnlyField(createDateInput("", "", ""), pseudoYear)');
35 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "", ""), pseudoYear)');
36 shouldBeFalse('isReadOnlyField(createDateInput("", "2012-12-17", ""), pseudoYear)');
37 shouldBeFalse('isReadOnlyField(createDateInput("", "", "2012-12-17"), pseudoYear)');
38 shouldBeTrue('isReadOnlyField(createDateInput("2012-01-01", "2012-12-31", ""), pseudoYear)');
39 shouldBeFalse('isReadOnlyField(createDateInput("2012-01-01", "2013-12-31", ""), pseudoYear)');
40 shouldBeTrue('isReadOnlyField(createDateInput("2012-01-01", "2012-12-31", "2012-05-30"), pseudoYear)');
41 shouldBeFalse('isReadOnlyField(createDateInput("2012-01-01", "2012-12-31", "2013-01-01"), pseudoYear)');
43 debug('Month field:');
44 shouldBeFalse('isReadOnlyField(createDateInput("", "", ""), pseudoMonth)');
45 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "", ""), pseudoMonth)');
46 shouldBeFalse('isReadOnlyField(createDateInput("", "2012-12-17", ""), pseudoMonth)');
47 shouldBeFalse('isReadOnlyField(createDateInput("", "", "2012-12-17"), pseudoMonth)');
48 shouldBeTrue('isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", ""), pseudoMonth)');
49 shouldBeFalse('isReadOnlyField(createDateInput("2012-11-01", "2013-12-31", ""), pseudoMonth)');
50 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-01", "2013-12-31", ""), pseudoMonth)');
51 shouldBeTrue('isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", "2012-12-15"), pseudoMonth)');
52 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-01", "2012-12-31", "2012-11-30"), pseudoMonth)');
55 debug('We should not make all the fields readonly by min/max, so day field is always editable.');
56 shouldBeFalse('isReadOnlyField(createDateInput("", "", ""), pseudoDay)');
57 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "", ""), pseudoDay)');
58 shouldBeFalse('isReadOnlyField(createDateInput("", "2012-12-17", ""), pseudoDay)');
59 shouldBeFalse('isReadOnlyField(createDateInput("", "", "2012-12-17"), pseudoDay)');
60 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", ""), pseudoDay)');
61 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "2013-12-18", ""), pseudoDay)');
62 shouldBeFalse('isReadOnlyField(createDateInput("2012-11-17", "2012-12-17", ""), pseudoDay)');
63 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "2013-12-17", ""), pseudoDay)');
64 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", "2012-12-17"), pseudoDay)');
65 shouldBeFalse('isReadOnlyField(createDateInput("2012-12-17", "2012-12-17", "2012-12-18"), pseudoDay)');