chromium/third_party/blink/web_tests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html

<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<script>
description('Checks incomplete datetime formats are rejected.');

var input = document.createElement('input');
input.type = 'datetime-local';
document.body.appendChild(input);

function setDateTimeFormat(pattern) {
    var value = input.value;
    getElementByPseudoId(internals.shadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern);
    input.value = ''; // Updates the element for new format
    input.value = value;
}

input.value = '1999-07-31T23:59';

debug('Valid format');
setDateTimeFormat("yyyy-MM-dd hh:mm a");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31 11:59 PM');

debug("Invalid format, fallback to yyyy-MM-dd'T'HH:mm");
setDateTimeFormat('yyyy-MM-dd');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');
setDateTimeFormat('HH:mm');
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');
setDateTimeFormat("yyyy-MM-dd'T'hh:mm");
shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59');

</script>
</body>
</html>