Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / month-multiple-fields / month-multiple-fields-readonly-subfield.html
blobb0bf28b211b40a4d4a1396a8c94dc215c8cb3711
1 <!DOCTYPE html>
2 <body>
3 <script src="../../../resources/js-test.js"></script>
4 <script>
5 function createMonthInput(min, max, value) {
6 var input = document.createElement('input');
7 input.type = 'month';
8 if (min)
9 input.min = min;
10 if (max)
11 input.max = max;
12 if (value)
13 input.value = value;
14 return input;
17 // FIXME: Rename this function and the test file.
18 function isReadOnlyField(input, pseudo) {
19 var node = internals.youngestShadowRoot(input).querySelector('*[pseudo="' + pseudo + '"]');
20 if (!node)
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');
30 debug('');
32 debug('Year field:');
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)');
54 </script>
55 </body>