3 <script src=
"../../../resources/js-test.js"></script>
5 function createMonthInput(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 pseudoMonth
= '-webkit-datetime-edit-month-field';
26 var pseudoYear
= '-webkit-datetime-edit-year-field';
28 description('Sub-fields in input[type=month] should be read-only in some cases. This requires window.internals.');
29 debug('createMonthInput argument order: min, max, value');
33 shouldBeFalse('isReadOnlyField(createMonthInput("", "", ""), pseudoYear)');
34 shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "", ""), pseudoYear)');
35 shouldBeFalse('isReadOnlyField(createMonthInput("", "2012-12", ""), pseudoYear)');
36 shouldBeFalse('isReadOnlyField(createMonthInput("", "", "2012-12"), pseudoYear)');
37 shouldBeTrue('isReadOnlyField(createMonthInput("2012-01", "2012-12", ""), pseudoYear)');
38 shouldBeFalse('isReadOnlyField(createMonthInput("2012-01", "2013-12", ""), pseudoYear)');
39 shouldBeTrue('isReadOnlyField(createMonthInput("2012-01", "2012-12", "2012-05"), pseudoYear)');
40 shouldBeFalse('isReadOnlyField(createMonthInput("2012-01", "2012-12", "2013-01"), pseudoYear)');
42 debug('Month field:');
43 debug('We should not make all the fields readonly by min/max, so day field is always editable.');
44 shouldBeFalse('isReadOnlyField(createMonthInput("", "", ""), pseudoMonth)');
45 shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "", ""), pseudoMonth)');
46 shouldBeFalse('isReadOnlyField(createMonthInput("", "2012-12", ""), pseudoMonth)');
47 shouldBeFalse('isReadOnlyField(createMonthInput("", "", "2012-12"), pseudoMonth)');
48 shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "2012-12", ""), pseudoMonth)');
49 shouldBeFalse('isReadOnlyField(createMonthInput("2012-11", "2013-12", ""), pseudoMonth)');
50 shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "2013-12", ""), pseudoMonth)');
51 shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "2012-12", "2012-12"), pseudoMonth)');
52 shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "2012-12", "2012-11"), pseudoMonth)');