3 <input type=
"week" id=
"test1">
4 <input type=
"week" id=
"test2" min=
"1998-W01" max=
"1999-W12">
6 function fieldsText(input
) {
7 return window
.internals
.oldestShadowRoot(input
).textContent
;
10 function back(newState
) {
11 parent
.state
= newState
;
15 function forward(newState
) {
16 parent
.state
= newState
;
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() {
31 switch (parent
.state
) {
33 testInput1
.value
= '12012-W10';
35 keyDown('upArrow'); // -> Week [01], yyyy
36 var nextUri
= location
.toString().replace('?page1', '?page2');
37 setTimeout(function() { window
.location
.href
= nextUri
; }, 0);
41 parent
.testCases
.push(
43 'description' : 'Went back to a page. Checking a form control which had a full value',
44 'actual' : testInput1
.value
,
45 'expected' : '12012-W10' },
47 'description' : 'Went back to a page. Checking a form control which had a partial value',
48 'actual' : fieldsText(testInput2
),
49 'expected' : 'Week 01, ----'
51 forward('forwardTo2');
57 parent
.failed('Unexpected state(' + parent
.state
+ ')');
63 switch (parent
.state
) {
65 testInput1
.value
= '0001-W11';
67 keyDown('\t'); // -> Week ww, [yyyy]
68 keyDown('downArrow'); // -> Week ww, [1999]
72 parent
.testCases
.push(
74 'description' : 'Went forward to a page. Checking a form control which had a full value',
75 'actual' : testInput1
.value
,
76 'expected' : '0001-W11'
79 'description' : 'Went forward to a page. Checking a form control which had a partial value',
80 'actual' : fieldsText(testInput2
),
81 'expected' : 'Week --, 1999'
83 back('backTo1Second');
86 parent
.failed('Unexpected state(' + parent
.state
+ ')');
92 parent
.failed('Unexpected page(' + pageName
+ ')');