4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
9 description('Checks incomplete datetime formats are rejected.');
11 var input
= document
.createElement('input');
13 document
.body
.appendChild(input
);
15 function setDateTimeFormat(pattern
) {
16 var value
= input
.value
;
17 getElementByPseudoId(internals
.youngestShadowRoot(input
), '-webkit-datetime-edit').setAttribute('pattern', pattern
);
18 input
.value
= ''; // Updates the element for new format
22 input
.value
= '23:59:01.234';
24 debug('Valid format');
25 setDateTimeFormat('ss:mm:hh a');
26 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:11 PM');
27 setDateTimeFormat('ss:mm:HH');
28 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:23');
29 setDateTimeFormat('ss:mm:HH a');
30 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:23 PM');
32 debug('Invalid format, fallback to HH:mm:ss');
33 setDateTimeFormat('HH');
34 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234');
35 setDateTimeFormat('mm:ss');
36 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234');
37 setDateTimeFormat('hh:mm:ss');
38 shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234');