Skip to content

Commit

Permalink
selectlist: support <button type=selectlist>
Browse files Browse the repository at this point in the history
In the new selectlist architecture, any descendant <button
type=selectlist> should get the behavior of opening the listbox.

Bug: 1121840
Change-Id: Ib9f4efdcdec706e6750c38534d163be8d065390d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4796450
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1189620}
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Aug 29, 2023
1 parent 43b0d74 commit d9e648d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<button>button</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/openui/open-ui/issues/702">
<link rel=match href="button-type-selectlist-appearance-ref.html">

<button type=selectlist>button</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<button>hello world</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/openui/open-ui/issues/702">
<link rel=match href="selectlist-button-type-appearance-ref.html">

<selectlist>
<button type=selectlist>hello world</button>
</selectlist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/openui/open-ui/issues/702">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<selectlist>
<button type=selectlist id=b1>first button</button>
<button type=selectlist id=b2>second button</button>
<button id=b3>third button</button>
<option>option</option>
</selectlist>

<script>
const ESC = '\uE00C'

promise_test(async () => {
const selectlist = document.querySelector('selectlist');
const b1 = document.getElementById('b1');
const b2 = document.getElementById('b2');
const b3 = document.getElementById('b3');

assert_false(selectlist.open, 'The selectlist should start closed.');
await test_driver.click(b1);
assert_true(selectlist.open, 'The selectlist should get opened when the button is clicked.');

await test_driver.send_keys(selectlist, ESC);
assert_false(selectlist.open, 'Pressing escape should close the selectlist.');

await test_driver.click(b2);
assert_true(selectlist.open, 'The selectlist should get opened when a second type=selectlist button is clicked.');
await test_driver.send_keys(selectlist, ESC);
assert_false(selectlist.open, 'Pressing escape should close the selectlist.');

await test_driver.click(b3);
assert_false(selectlist.open, 'Clicking a button witout type=selectlist should not open the listbox.');

b1.removeAttribute('type');
await test_driver.click(b1);
assert_false(selectlist.open, 'If the button is not type=selectlist, it should not open the selectlist.');
}, '<button type=selectlist> should open the parent selectlist when clicked.');
</script>

0 comments on commit d9e648d

Please sign in to comment.