3 <input type=
"datetime-local" id=
"test1">
4 <input type=
"datetime-local" id=
"test2" min=
"1999-01-01T00:00" max=
"2000-12-31T23:59">
6 function fieldsText(input
) {
7 return window
.internals
.oldestShadowRoot(input
).textContent
;
10 // On Linux/Android with a newer ICU, date and time are separated by ','.
11 function insertCommaIfNecessary(expected
, input
) {
12 return (fieldsText(input
).indexOf(', ') == -1) ? expected
:
13 expected
.replace(' ', ', ');
16 function back(newState
) {
17 parent
.state
= newState
;
21 function forward(newState
) {
22 parent
.state
= newState
;
26 function keyDown(key
) {
27 eventSender
.keyDown(key
);
30 var testInput1
= document
.getElementById('test1');
31 var testInput2
= document
.getElementById('test2');
32 var pageName
= location
.search
|| '?page1';
34 window
.onload = function() {
37 switch (parent
.state
) {
39 testInput1
.value
= '12012-10-09T01:23';
41 keyDown('upArrow'); // -> [01]/dd/yyyy --:-- --
42 keyDown('\t'); // -> 01/[dd]/yyyy --:-- --
43 keyDown('\t'); // -> 01/dd/[yyyy] --:-- --
44 keyDown('upArrow'); // -> 01/dd/[1999] --:-- --
45 keyDown('\t'); // -> 01/dd/1999 [--]:-- --
46 keyDown('\t'); // -> 01/dd/1999 --:[--] --
47 keyDown('upArrow'); // -> 01/dd/1999 --:[00] --
49 var nextUri
= location
.toString().replace('?page1', '?page2');
50 setTimeout(function() { window
.location
.href
= nextUri
; }, 0);
54 parent
.testCases
.push(
56 'description' : 'Went back to a page. Checking a form control which had a full value',
57 'actual' : testInput1
.value
,
58 'expected' : '12012-10-09T01:23' },
60 'description' : 'Went back to a page. Checking a form control which had a partial value',
61 'actual' : fieldsText(testInput2
),
62 'expected' : insertCommaIfNecessary('01/dd/1999 --:00 --', testInput1
)
64 forward('forwardTo2');
70 parent
.failed('Unexpected state(' + parent
.state
+ ')');
76 switch (parent
.state
) {
78 testInput1
.value
= '0001-11-17T23:55';
80 keyDown('\t'); // -> mm/[dd]/yyyy --:-- --
81 keyDown('downArrow'); // -> mm/[31]/yyyy --:-- --
82 keyDown('\t'); // -> mm/31/[yyyy] --:-- --
83 keyDown('\t'); // -> mm/31/yyyy [--]:-- --
84 keyDown('downArrow'); // -> mm/31/yyyy [12]:-- --
85 keyDown('\t'); // -> mm/31/yyyy 12:[--] --
86 keyDown('\t'); // -> mm/31/yyyy 12:-- [--]
87 keyDown('downArrow'); // -> mm/31/yyyy 12:-- [PM]
91 parent
.testCases
.push(
93 'description' : 'Went forward to a page. Checking a form control which had a full value',
94 'actual' : testInput1
.value
,
95 'expected' : '0001-11-17T23:55'
98 'description' : 'Went forward to a page. Checking a form control which had a partial value',
99 'actual' : fieldsText(testInput2
),
100 'expected' : insertCommaIfNecessary('mm/31/yyyy 12:-- PM', testInput1
)
102 back('backTo1Second');
105 parent
.failed('Unexpected state(' + parent
.state
+ ')');
111 parent
.failed('Unexpected page(' + pageName
+ ')');