| <!DOCTYPE html> |
| <body> |
| <input type="week" id="test1"> |
| <input type="week" id="test2" min="1998-W01" max="1999-W12"> |
| <script> |
| function fieldsText(input) { |
| return window.internals.oldestShadowRoot(input).textContent; |
| } |
| |
| 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() { |
| switch (pageName) { |
| case '?page1': |
| switch (parent.state) { |
| case 'direct': { |
| testInput1.value = '12012-W10'; |
| testInput2.focus(); |
| keyDown('upArrow'); // -> Week [01], yyyy |
| 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-W10' }, |
| { |
| 'description' : 'Went back to a page. Checking a form control which had a partial value', |
| 'actual' : fieldsText(testInput2), |
| 'expected' : 'Week 01, ----' |
| }); |
| 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-W11'; |
| testInput2.focus(); |
| keyDown('\t'); // -> Week ww, [yyyy] |
| keyDown('downArrow'); // -> Week ww, [1999] |
| 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-W11' |
| }, |
| { |
| 'description' : 'Went forward to a page. Checking a form control which had a partial value', |
| 'actual' : fieldsText(testInput2), |
| 'expected' : 'Week --, 1999' |
| }); |
| back('backTo1Second'); |
| break; |
| default: |
| parent.failed('Unexpected state(' + parent.state + ')'); |
| break; |
| } |
| break; |
| |
| default: |
| parent.failed('Unexpected page(' + pageName + ')'); |
| break; |
| } |
| }; |
| </script> |
| </body> |