diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html b/testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html new file mode 100644 index 0000000000..e348064151 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/forms/the-select-element/select-multiple.html @@ -0,0 +1,48 @@ +<!doctype html> +<meta charset=utf-8> +<title>HTMLSelectElement ask for reset</title> +<link rel="author" title="Sebastian Mayr" href="wpt@smayr.name"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<select multiple id="initial-selected"> + <option selected>Test 1</option> + <option selected>Test 2</option> +</select> +<select multiple id="scripted-select"> + <option selected>Test 1</option> + <option>Test 2</option> +</select> +<div id=log></div> +<script> +"use strict"; + +test(() => { + + const select = document.getElementById("initial-selected"); + assert_true(select.options[0].selected, "first option should be selected."); + assert_true(select.options[1].selected, "second option should be selected."); + +}, "multiple selected options exist, both set from markup"); + +test(() => { + + const select = document.getElementById("initial-selected"); + select.options[1].selected = true; + + assert_true(select.options[0].selected, "first option should be selected."); + assert_true(select.options[1].selected, "second option should be selected."); + +}, "multiple selected options exist, one set from script"); + +// crbug.com/1245443 +test(() => { + let select = document.createElement("select"); + select.length = 4; + let o1 = select.options.item(1); + select.multiple = true; + select.selectedIndex = 2; + o1.selected = true; + select.multiple = false; + assert_equals(select.selectedOptions.length, 1); +}, "Removing multiple attribute reduces the number of selected OPTIONs to 1"); +</script> |