4 <script src=
"../../../resources/js-test.js"></script>
5 <script src=
"../resources/common.js"></script>
8 <p id=
"description"></p>
9 <div id=
"console"></div>
10 <input type=
"week" id=
"input" value=
"2000-W01">
12 description('Test if change event fires when the user selects the default value after the value was changed by JS.');
14 var eventsCounter
= {};
15 function recordEvent(event
) {
16 if (eventsCounter
[event
.type
] === undefined)
17 eventsCounter
[event
.type
] = 0;
18 eventsCounter
[event
.type
]++;
19 debug('==> "' + event
.type
+ '" event was dispatched.');
22 var input
= document
.getElementById('input');
23 input
.addEventListener('input', recordEvent
, false);
24 input
.addEventListener('change', recordEvent
, false);
26 input
.value
= '2001-W01';
28 shouldBeEqualToString('input.value', '2001-W01');
29 shouldBeUndefined('eventsCounter.input');
30 shouldBeUndefined('eventsCounter.change');
32 // We assume the date format is Week ww, yyyy.
35 eventSender
.keyDown('rightArrow');
36 eventSender
.keyDown('downArrow');
38 shouldBeEqualToString('input.value', '2000-W01');
39 shouldBe('eventsCounter.input', '1');
40 shouldBe('eventsCounter.change', '1');