summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-focusin-event.html
blob: 519cef955c3a7323816ed19f9d75825ed7d4347a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<body>
<form>
<input type="text" id="text">
<input type="date" id="date">
<input type="time" id="time">
</form>
<script>
description('Test Date/Time input field dispatches focusin event when pressed tab');
var dispatchedFocusInEvent = 0;
var dispatchedDOMFocusInEvent = 0;

document.documentElement.addEventListener('focusin', focusin, false);
document.documentElement.addEventListener('DOMFocusIn', domfocusin, false);

function focusin()
{
    dispatchedFocusInEvent++;
}

function domfocusin()
{
    dispatchedDOMFocusInEvent++;
}

document.getElementById('text').focus();
shouldBeEqualToString('document.activeElement.id', 'text');
shouldBe('dispatchedFocusInEvent', '1');
shouldBe('dispatchedDOMFocusInEvent', '1');

debug('Move to date field, should generate foucsin event');
eventSender.keyDown('\t'); // move to date input element.
shouldBeEqualToString('document.activeElement.id', 'date');
shouldBe('dispatchedFocusInEvent', '2');
shouldBe('dispatchedDOMFocusInEvent', '2');
eventSender.keyDown('\t'); // move to date field.
eventSender.keyDown('\t'); // move to  year field.

debug('Move to time field, should generate foucsin event');
eventSender.keyDown('\t'); // move to time field.
shouldBeEqualToString('document.activeElement.id', 'time');
shouldBe('dispatchedFocusInEvent', '3');
shouldBe('dispatchedDOMFocusInEvent', '3');

</script>
</body>