Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / datetimelocal-multiple-fields / datetimelocal-multiple-fields-choose-default-value-after-set-value.html
blobe36c1ccd448b81edf069aea4388d219b1b2627b5
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <script src="../resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10 <input type="datetime-local" id="input" value="2000-01-01T01:01:01">
11 <script>
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-01-01T01:01:01';
28 shouldBeEqualToString('input.value', '2001-01-01T01:01:01');
29 shouldBeUndefined('eventsCounter.input');
30 shouldBeUndefined('eventsCounter.change');
32 // We assume the date format is MM/dd/yyyy h:m a.
34 input.focus();
35 eventSender.keyDown('rightArrow');
36 eventSender.keyDown('rightArrow');
37 eventSender.keyDown('downArrow');
39 shouldBeEqualToString('input.value', '2000-01-01T01:01:01');
40 shouldBe('eventsCounter.input', '1');
41 shouldBe('eventsCounter.change', '1');
43 </script>
44 </body>
45 </html>