New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ask_for_reset for HTMLSelectElement. #7963
Merged
+184
−2
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b1d6b0f
Implement ask_for_reset for HTMLSelectElement.
dagnir 6e9e146
Implement pick_option.
dagnir c070c7a
Update and correct tests.
dagnir 663801e
ask for reset and pick on option insert.
dagnir ea21db6
Move cast into if block.
dagnir fcfc391
Update test.
dagnir b5e991c
Replace if-else with match.
dagnir d561b4f
Remove extra indent.
dagnir 15a8b6b
Mark failure for remove test as expected.
dagnir 92e0083
Add fixes based on review.
dagnir 4849033
Add fixes based on review.
dagnir File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
| "path": "html/semantics/forms/the-select-element/select-remove.html", | ||
| "url": "/html/semantics/forms/the-select-element/select-remove.html" | ||
| }, | ||
| { | ||
| "path": "html/semantics/forms/the-select-element/select-ask-for-reset.html", | ||
| "url": "/html/semantics/forms/the-select-element/select-ask-for-reset.html" | ||
| }, | ||
| { | ||
| "path": "html/semantics/forms/the-textarea-element/textarea-type.html", | ||
| "url": "/html/semantics/forms/the-textarea-element/textarea-type.html" |
| @@ -0,0 +1,4 @@ | ||
| [select-ask-for-reset.html] | ||
|
||
| type: testharness | ||
| [ask for reset on node remove, non multiple.] | ||
| expected: FAIL | ||
| @@ -0,0 +1,97 @@ | ||
| <!doctype html> | ||
| <meta charset=utf-8> | ||
| <title>HTMLSelectElement ask for reset</title> | ||
| <link rel="author" title="Dongie Agnir" href="dongie.agnir@gmail.com"> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <div id=log></div> | ||
| <script> | ||
| test(function() { | ||
| var select = makeSelect(5); | ||
|
|
||
| select.children[4].selected = true; | ||
| unselectedExcept(select, 4); | ||
|
|
||
| select.children[4].remove(); | ||
| unselectedExcept(select, 0); // remove selected node, should default to first | ||
|
|
||
| select.children[3].selected = true; | ||
|
|
||
| select.children[0].remove(); | ||
| unselectedExcept(select, 2); // last node still selected | ||
|
|
||
| select.size = 2; | ||
| select.children[2].remove(); | ||
|
|
||
| unselectedExcept(select, null); | ||
| }, "ask for reset on node remove, non multiple."); | ||
|
|
||
| test(function() { | ||
| var select = makeSelect(3); | ||
| select.children[1].selected = true; | ||
|
|
||
| // insert selected option, should remain selected | ||
| var opt4 = document.createElement("option"); | ||
| opt4.selected = true; | ||
| select.appendChild(opt4); | ||
| unselectedExcept(select, 3); | ||
|
|
||
| // insert unselected, 3 should remain selected | ||
| var opt5 = document.createElement("option"); | ||
| select.appendChild(opt5); | ||
| unselectedExcept(select, 3); | ||
| }, "ask for reset on node insert, non multiple."); | ||
|
|
||
| test(function() { | ||
| var select = makeSelect(3); | ||
|
|
||
| var options = select.children; | ||
|
|
||
| // select options from first to last | ||
| for (var i = 0; i < options.length; ++i) { | ||
| options[i].selected = true; | ||
| unselectedExcept(select, i); | ||
| } | ||
|
|
||
| // select options from last to first | ||
| for (var i = options.length - 1; i >= 0; --i) { | ||
| options[i].selected = true; | ||
| unselectedExcept(select, i); | ||
| } | ||
|
|
||
| options[2].selected = true; | ||
| options[2].selected = false; // none selected | ||
| unselectedExcept(select, 0); | ||
|
|
||
| // disable first so option at index 1 is first eligible | ||
| options[0].disabled = true; | ||
| options[2].selected = true; | ||
| options[2].selected = false; // none selected | ||
| unselectedExcept(select, 1); | ||
|
|
||
| select.size = 2; | ||
| options[1].selected = false; | ||
| unselectedExcept(select, null); // size > 1 so should not default to any | ||
| }, "change selectedness of option, non multiple."); | ||
|
|
||
|
|
||
| function unselectedExcept(sel, opt) { | ||
| for (var i = 0; i < sel.children.length; ++i) { | ||
| if (i != opt) { | ||
| assert_false(sel.children[i].selected, "option should not be selected."); | ||
| } | ||
| if (opt != null) { | ||
| assert_true(sel.children[opt].selected, "option should be selected."); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function makeSelect(n) { | ||
| var sel = document.createElement("select"); | ||
| for (var i = 0; i < n; ++i) { | ||
| opt = document.createElement("option"); | ||
| sel.appendChild(opt); | ||
| } | ||
| return sel; | ||
| } | ||
| </script> |
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Is there any reason why this test is marked as failing?