-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This was decided in OpenUI here: openui/open-ui#773 Bug: 1121840 Change-Id: If3bc31860a48e0f3842481774cb874cbd42a8bb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4754199 Auto-Submit: Joey Arhar <[email protected]> Reviewed-by: Chris Bookholt <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1182736}
- Loading branch information
1 parent
1e673fb
commit 7f97a9b
Showing
81 changed files
with
2,019 additions
and
2,018 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
<link rel=author href="mailto:[email protected]"> | ||
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1291169"> | ||
|
||
<selectmenu></selectmenu> | ||
<selectlist></selectlist> | ||
<div></div> | ||
|
||
<script> | ||
(async () => { | ||
const selectmenu = document.querySelector('selectmenu'); | ||
const selectlist = document.querySelector('selectlist'); | ||
await getComputedAccessibleNode(document.querySelector('div')); | ||
selectmenu.style.setProperty('content-visibility', 'hidden'); | ||
selectlist.style.setProperty('content-visibility', 'hidden'); | ||
})(); | ||
</script> |
119 changes: 119 additions & 0 deletions
119
html/semantics/forms/the-selectlist-element/selectlist-ask-for-reset.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,119 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<title>HTMLSelectListElement Test: ask-for-reset</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<form name="fm1" id="form1"> | ||
<selectlist id="selectlist1"> | ||
<option>one</option> | ||
<option>two</option> | ||
</selectlist> | ||
|
||
<selectlist id="selectlist2"> | ||
<option>one</option> | ||
<option selected>two</option> | ||
</selectlist> | ||
|
||
<selectlist id="selectlist3"> | ||
<option>one</option> | ||
<option selected>two</option> | ||
<option selected>three</option> | ||
</selectlist> | ||
</form> | ||
|
||
<script> | ||
function createSelectList(numberOfOptions) { | ||
let selectList = document.createElement("selectlist"); | ||
for (let i = 0; i < numberOfOptions; i++) { | ||
let option = document.createElement("option"); | ||
option.value = i; | ||
selectList.appendChild(option); | ||
} | ||
return selectList; | ||
} | ||
|
||
function checkSelection(selectList, selectedOptionIndex, msg) { | ||
for (let i = 0; i < selectList.children.length; i++) { | ||
if (i != selectedOptionIndex) { | ||
assert_false(selectList.children[i].selected); | ||
} | ||
} | ||
assert_true(selectList.children[selectedOptionIndex].selected, msg); | ||
assert_equals(selectList.value, selectList.children[selectedOptionIndex].value); | ||
} | ||
|
||
test(() => { | ||
let selectList = createSelectList(5); | ||
|
||
selectList.children[4].selected = true; | ||
checkSelection(selectList, 4); | ||
|
||
selectList.children[4].remove(); | ||
checkSelection(selectList, 0, "After removing the selected option, selection should default to first option."); | ||
|
||
selectList.children[3].selected = true; | ||
checkSelection(selectList, 3); | ||
selectList.children[0].remove(); | ||
checkSelection(selectList, 2, "Removing non-selected option should have no effect."); | ||
}, "ask-for-reset when removing option"); | ||
|
||
test(() => { | ||
let selectList = createSelectList(3); | ||
selectList.children[1].selected = true; | ||
|
||
let newOption = document.createElement("option"); | ||
newOption.selected = true; | ||
selectList.appendChild(newOption); | ||
checkSelection(selectList, 3, "Inserting a selected option should update selection."); | ||
|
||
let newOption2 = document.createElement("option"); | ||
newOption2.selected = true; | ||
selectList.prepend(newOption2); | ||
checkSelection(selectList, 0, "Inserting a selected option should update selection, even though it's not last in tree order."); | ||
|
||
let newOption3 = document.createElement("option"); | ||
selectList.appendChild(newOption3); | ||
checkSelection(selectList, 0, "Inserting a non-selected option should have no effect."); | ||
}, "ask-for-reset when inserting option"); | ||
|
||
test(() => { | ||
let selectList = createSelectList(3); | ||
let options = selectList.children; | ||
|
||
// select options from first to last | ||
for (let i = 0; i < options.length; i++) { | ||
options[i].selected = true; | ||
checkSelection(selectList, i); | ||
} | ||
|
||
// select options from last to first | ||
for (let i = options.length - 1; i >= 0; i--) { | ||
options[i].selected = true; | ||
checkSelection(selectList, i); | ||
} | ||
|
||
options[2].selected = true; | ||
checkSelection(selectList, 2); | ||
options[2].selected = false; | ||
checkSelection(selectList, 0, "First non-disabled option should be selected."); | ||
|
||
options[0].disabled = true; | ||
options[2].selected = true; | ||
checkSelection(selectList, 2); | ||
options[2].selected = false; | ||
checkSelection(selectList, 1, "First non-disabled option should be selected."); | ||
}, "ask-for-reset when changing selectedness of option"); | ||
|
||
test(() => { | ||
let selectList1 = document.getElementById("selectlist1"); | ||
let selectList2 = document.getElementById("selectlist2"); | ||
let selectList3 = document.getElementById("selectlist3"); | ||
|
||
document.getElementById("form1").reset(); | ||
|
||
assert_equals(selectList1.value, "one", "First non-disabled option should be selected."); | ||
assert_equals(selectList2.value, "two", "The selected option should be selected."); | ||
assert_equals(selectList3.value, "three", "Last selected option should be selected.") | ||
}, "ask-for-reset for form"); | ||
</script> |
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
Oops, something went wrong.