chromium/third_party/blink/web_tests/fast/forms/month-multiple-fields/month-multiple-fields-readonly-subfield.html

<!DOCTYPE html>
<body>
<script src="../../../resources/js-test.js"></script>
<script>
function createMonthInput(min, max, value) {
    var input = document.createElement('input');
    input.type = 'month';
    if (min)
        input.min = min;
    if (max)
        input.max = max;
    if (value)
        input.value = value;
    return input;
}

// FIXME: Rename this function and the test file.
function isReadOnlyField(input, pseudo) {
    var node = internals.shadowRoot(input).querySelector('*[pseudo="' + pseudo + '"]');
    if (!node)
        testFailed('Requested node is missing.');
    return node && node.hasAttribute('disabled');
}

var pseudoMonth = '-webkit-datetime-edit-month-field';
var pseudoYear = '-webkit-datetime-edit-year-field';

description('Sub-fields in input[type=month] should be read-only in some cases. This requires window.internals.');
debug('createMonthInput argument order: min, max, value');
debug('');

debug('Year field:');
shouldBeFalse('isReadOnlyField(createMonthInput("", "", ""), pseudoYear)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "", ""), pseudoYear)');
shouldBeFalse('isReadOnlyField(createMonthInput("", "2012-12", ""), pseudoYear)');
shouldBeFalse('isReadOnlyField(createMonthInput("", "", "2012-12"), pseudoYear)');
shouldBeTrue('isReadOnlyField(createMonthInput("2012-01", "2012-12", ""), pseudoYear)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-01", "2013-12", ""), pseudoYear)');
shouldBeTrue('isReadOnlyField(createMonthInput("2012-01", "2012-12", "2012-05"), pseudoYear)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-01", "2012-12", "2013-01"), pseudoYear)');

debug('Month field:');
debug('We should not make all the fields readonly by min/max, so day field is always editable.');
shouldBeFalse('isReadOnlyField(createMonthInput("", "", ""), pseudoMonth)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "", ""), pseudoMonth)');
shouldBeFalse('isReadOnlyField(createMonthInput("", "2012-12", ""), pseudoMonth)');
shouldBeFalse('isReadOnlyField(createMonthInput("", "", "2012-12"), pseudoMonth)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "2012-12", ""), pseudoMonth)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-11", "2013-12", ""), pseudoMonth)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "2013-12", ""), pseudoMonth)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "2012-12", "2012-12"), pseudoMonth)');
shouldBeFalse('isReadOnlyField(createMonthInput("2012-12", "2012-12", "2012-11"), pseudoMonth)');

</script>
</body>