<!DOCTYPE html>
<body>
<input type="datetime-local" id="test1">
<input type="datetime-local" id="test2" min="1999-01-01T00:00" max="2000-12-31T23:59">
<script>
function fieldsText(input) {
return internals.shadowRoot(input).textContent;
}
// On Linux/Android with a newer ICU, date and time are separated by ','.
function insertCommaIfNecessary(expected, input) {
return (fieldsText(input).indexOf(', ') == -1) ? expected :
expected.replace(' ', ', ');
}
function back(newState) {
parent.state = newState;
history.back();
}
function forward(newState) {
parent.state = newState;
history.forward();
}
function keyDown(key) {
eventSender.keyDown(key);
}
var testInput1 = document.getElementById('test1');
var testInput2 = document.getElementById('test2');
var pageName = location.search || '?page1';
window.onload = function() { setTimeout(function() {
switch (pageName) {
case '?page1':
switch (parent.state) {
case 'direct': {
testInput1.value = '12012-10-09T01:23';
testInput2.focus();
keyDown('ArrowUp'); // -> [01]/dd/yyyy --:-- --
keyDown('\t'); // -> 01/[dd]/yyyy --:-- --
keyDown('\t'); // -> 01/dd/[yyyy] --:-- --
keyDown('ArrowUp'); // -> 01/dd/[1999] --:-- --
keyDown('\t'); // -> 01/dd/1999 [--]:-- --
keyDown('\t'); // -> 01/dd/1999 --:[--] --
keyDown('ArrowUp'); // -> 01/dd/1999 --:[00] --
var nextUri = location.toString().replace('?page1', '?page2');
setTimeout(function() { window.location.href = nextUri; }, 0);
break;
}
case 'backTo1':
parent.testCases.push(
{
'description' : 'Went back to a page. Checking a form control which had a full value',
'actual' : testInput1.value,
'expected' : '12012-10-09T01:23' },
{
'description' : 'Went back to a page. Checking a form control which had a partial value',
'actual' : fieldsText(testInput2),
'expected' : insertCommaIfNecessary('01/dd/1999 --:00\u202f--', testInput1)
});
forward('forwardTo2');
break;
case 'backTo1Second':
parent.finishTest();
break;
default:
parent.failed('Unexpected state(' + parent.state + ')');
break;
}
break;
case '?page2':
switch (parent.state) {
case 'direct':
testInput1.value = '0001-11-17T23:55';
testInput2.focus();
keyDown('\t'); // -> mm/[dd]/yyyy --:-- --
keyDown('ArrowDown'); // -> mm/[31]/yyyy --:-- --
keyDown('\t'); // -> mm/31/[yyyy] --:-- --
keyDown('\t'); // -> mm/31/yyyy [--]:-- --
keyDown('ArrowDown'); // -> mm/31/yyyy [12]:-- --
keyDown('\t'); // -> mm/31/yyyy 12:[--] --
keyDown('\t'); // -> mm/31/yyyy 12:-- [--]
keyDown('ArrowDown'); // -> mm/31/yyyy 12:-- [PM]
back('backTo1');
break;
case 'forwardTo2':
parent.testCases.push(
{
'description' : 'Went forward to a page. Checking a form control which had a full value',
'actual' : testInput1.value,
'expected' : '0001-11-17T23:55'
},
{
'description' : 'Went forward to a page. Checking a form control which had a partial value',
'actual' : fieldsText(testInput2),
'expected' : insertCommaIfNecessary('mm/31/yyyy 12:--\u202fPM', testInput1)
});
back('backTo1Second');
break;
default:
parent.failed('Unexpected state(' + parent.state + ')');
break;
}
break;
default:
parent.failed('Unexpected page(' + pageName + ')');
break;
}
}, 1); };
</script>
</body>