Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / date-multiple-fields / resources / preserve-value-after-history-back-frame.html
blobc7c3e997818261d6212811175f8dc6b4cbc11efa
1 <!DOCTYPE html>
2 <body>
3 <input type="date" id="test1">
4 <input type="date" id="test2" min="1999-01-01" max="2000-12-31">
5 <script>
6 function fieldsText(input) {
7 return window.internals.oldestShadowRoot(input).textContent;
10 function back(newState) {
11 parent.state = newState;
12 history.back();
15 function forward(newState) {
16 parent.state = newState;
17 history.forward();
20 function keyDown(key) {
21 eventSender.keyDown(key);
24 var testInput1 = document.getElementById('test1');
25 var testInput2 = document.getElementById('test2');
26 var pageName = location.search || '?page1';
28 window.onload = function() {
29 switch (pageName) {
30 case '?page1':
31 switch (parent.state) {
32 case 'direct': {
33 testInput1.value = '12012-10-09';
34 testInput2.focus();
35 keyDown('upArrow'); // -> [01]/dd/yyyy
36 keyDown('\t'); // -> 01/[dd]/yyyy
37 keyDown('\t'); // -> 01/dd/[yyyy]
38 keyDown('upArrow'); // -> 01/dd/[1999]
39 var nextUri = location.toString().replace('?page1', '?page2');
40 setTimeout(function() { window.location.href = nextUri; }, 0);
41 break;
43 case 'backTo1':
44 parent.testCases.push(
46 'description' : 'Went back to a page. Checking a form control which had a full value',
47 'actual' : testInput1.value,
48 'expected' : '12012-10-09' },
50 'description' : 'Went back to a page. Checking a form control which had a partial value',
51 'actual' : fieldsText(testInput2),
52 'expected' : '01/dd/1999'
53 });
54 forward('forwardTo2');
55 break;
56 case 'backTo1Second':
57 parent.finishTest();
58 break;
59 default:
60 parent.failed('Unexpected state(' + parent.state + ')');
61 break;
63 break;
65 case '?page2':
66 switch (parent.state) {
67 case 'direct':
68 testInput1.value = '0001-11-17';
69 testInput2.focus();
70 keyDown('\t'); // -> mm/[dd]/yyyy
71 keyDown('downArrow'); // -> mm/[31]/yyyy
72 back('backTo1');
73 break;
74 case 'forwardTo2':
75 parent.testCases.push(
77 'description' : 'Went forward to a page. Checking a form control which had a full value',
78 'actual' : testInput1.value,
79 'expected' : '0001-11-17'
82 'description' : 'Went forward to a page. Checking a form control which had a partial value',
83 'actual' : fieldsText(testInput2),
84 'expected' : 'mm/31/yyyy'
85 });
86 back('backTo1Second');
87 break;
88 default:
89 parent.failed('Unexpected state(' + parent.state + ')');
90 break;
92 break;
94 default:
95 parent.failed('Unexpected page(' + pageName + ')');
96 break;
99 </script>
100 </body>