| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <select id="theSelect"> |
| <option value="a">A</option> |
| <option value="b">B</option> |
| </select> |
| <select id="theMultipleSelect" multiple> |
| <option value="a">A</option> |
| <option value="b">B</option> |
| <option value="c">C</option> |
| <option value="d">D</option> |
| </select> |
| <div id="console"></div> |
| |
| <script> |
| description("https://bugs.webkit.org/show_bug.cgi?id=67233 - Setting the value of a select to an invalid value should unset the selection."); |
| |
| function resetSingleSelect() { |
| sel.value = 'a'; |
| shouldBe("sel.selectedIndex", "0", true); |
| } |
| |
| function resetMultipleSelect() { |
| sel.item(1).selected = true; |
| sel.item(3).selected = true; |
| } |
| |
| function runTestsOnSelect(resetSelect) { |
| debug("Setting the value to an invalid value:"); |
| resetSelect(sel); |
| sel.value = 'x'; |
| shouldBe("sel.selectedIndex", "-1"); |
| |
| debug("Setting the value to null:"); |
| resetSelect(sel); |
| sel.value = null; |
| shouldBe("sel.selectedIndex", "-1"); |
| |
| debug("Setting the value to undefined:"); |
| resetSelect(sel); |
| sel.value = undefined; |
| shouldBe("sel.selectedIndex", "-1"); |
| } |
| |
| debug("-- Menu list select:"); |
| sel = document.getElementById("theSelect"); |
| runTestsOnSelect(resetSingleSelect); |
| |
| debug("-- List box select:"); |
| sel = document.getElementById("theMultipleSelect"); |
| runTestsOnSelect(resetMultipleSelect); |
| |
| successfullyParsed = true; |
| </script> |
| |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |