summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/select/menulist-popup-open-hide-using-keyboard.html
blob: c5656703427b1304ea443e63f70217cc9789af7d (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<select id="select">
<option value="one">One</option>
<option value="two">Two</option>
</select>
<script>
window.jsTestIsAsync = true;

function test()
{
    description('Test for opening select popup and closing.');

    popup = document.getElementById('select');

    debug('These tests run specfically for Linux and Windows');

    debug('Test opening and closing of popup using alt and down arrow key');
    popup.focus();
    eventSender.keyDown('downArrow', ['altKey']);
    shouldBeTrue('internals.isSelectPopupVisible(popup)');
    eventSender.keyDown('downArrow', ['altKey']);
    // We need this delay because in ListPicker._handleKeyDown we hide the
    // popup with a delay to avoid reopening the popup.
    setTimeout(test2, 0);
}
function test2() {
    shouldBeFalse('internals.isSelectPopupVisible(popup)');

    debug('Test opening and closing of popup using alt and up arrow key');
    popup.focus();
    eventSender.keyDown('upArrow', ['altKey']);
    shouldBeTrue('internals.isSelectPopupVisible(popup)');
    eventSender.keyDown('upArrow', ['altKey']);
    // We need this delay because in ListPicker._handleKeyDown we hide the
    // popup with a delay to avoid reopening the popup.
    setTimeout(test3, 0);
}
function test3() {
    shouldBeFalse('internals.isSelectPopupVisible(popup)');
    popup.blur();

    debug('Test opening of popup using F4');
    popup.focus();
    eventSender.keyDown('F4');
    shouldBeTrue('internals.isSelectPopupVisible(popup)');
    popup.blur();

    debug('Test opening of popup using enter key');
    popup.focus();
    eventSender.keyDown('\r', []);
    shouldBeTrue('internals.isSelectPopupVisible(popup)');
    popup.blur();

    debug('Works for all platforms');

    debug('Test opening of popup using space key');
    popup.focus();
    eventSender.keyDown(' ');
    shouldBeTrue('internals.isSelectPopupVisible(popup)');
    popup.blur();

    debug('Works for only mac');

    debug('Test opening of popup using up key');
    popup.focus();
    eventSender.keyDown('upArrow');
    shouldBeTrue('internals.isSelectPopupVisible(popup)');
    popup.blur();

    finishJSTest();
}
test();
</script>
</body>
</html>