summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-selectlist-element/tab-closes-listbox.tentative.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/semantics/forms/the-selectlist-element/tab-closes-listbox.tentative.html')
-rw-r--r--testing/web-platform/tests/html/semantics/forms/the-selectlist-element/tab-closes-listbox.tentative.html43
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/forms/the-selectlist-element/tab-closes-listbox.tentative.html b/testing/web-platform/tests/html/semantics/forms/the-selectlist-element/tab-closes-listbox.tentative.html
new file mode 100644
index 0000000000..1706ed34cc
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/forms/the-selectlist-element/tab-closes-listbox.tentative.html
@@ -0,0 +1,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>