-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selectlist: support <button type=selectlist>
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
1 parent
43b0d74
commit d9e648d
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
html/semantics/forms/the-selectlist-element/button-type-selectlist-appearance-ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!DOCTYPE html> | ||
<button>button</button> |
6 changes: 6 additions & 0 deletions
6
html/semantics/forms/the-selectlist-element/button-type-selectlist-appearance.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
2 changes: 2 additions & 0 deletions
2
html/semantics/forms/the-selectlist-element/selectlist-button-type-appearance-ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!DOCTYPE html> | ||
<button>hello world</button> |
8 changes: 8 additions & 0 deletions
8
html/semantics/forms/the-selectlist-element/selectlist-button-type-appearance.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
45 changes: 45 additions & 0 deletions
45
html/semantics/forms/the-selectlist-element/selectlist-button-type-behavior.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |