blob: 1706ed34cc6e1a04ce802a246ffd1203dc9eb1d1 (
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
|
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/openui/open-ui/issues/599">
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1359089">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<selectlist id=defaultlistbox>
<option>one</option>
<option>two</option>
</selectlist>
<selectlist id=customlistbox>
<listbox>
<option>one</option>
<option>two</option>
</listbox>
</selectlist>
<script>
const tabKey = '\uE004';
document.querySelectorAll('selectlist').forEach(selectlist => {
promise_test(async () => {
selectlist.focus();
await test_driver.send_keys(selectlist, ' ');
assert_true(selectlist.open, 'Listbox should be open after pressing space.');
selectlist.addEventListener('keydown', event => {
if (event.key === 'Tab') {
event.preventDefault();
}
}, {once: true});
await test_driver.send_keys(document.activeElement, tabKey);
assert_true(selectlist.open, 'Listbox should stay open when the tab keydown is preventDefaulted.');
await test_driver.send_keys(document.activeElement, tabKey);
assert_false(selectlist.open, 'Listbox should close after pressing the tab key.');
}, `${selectlist.id}: Pressing tab should close the listbox.`);
});
</script>
|