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