Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / select / setting-to-invalid-value.html
blob9d4939a9885917d86faba198dbf8e7cbf652a187
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <select id="theSelect">
8 <option value="a">A</option>
9 <option value="b">B</option>
10 </select>
11 <select id="theMultipleSelect" multiple>
12 <option value="a">A</option>
13 <option value="b">B</option>
14 <option value="c">C</option>
15 <option value="d">D</option>
16 </select>
17 <div id="console"></div>
19 <script>
20 description("https://bugs.webkit.org/show_bug.cgi?id=67233 - Setting the value of a select to an invalid value should unset the selection.");
22 function resetSingleSelect() {
23 sel.value = 'a';
24 shouldBe("sel.selectedIndex", "0", true);
27 function resetMultipleSelect() {
28 sel.item(1).selected = true;
29 sel.item(3).selected = true;
32 function runTestsOnSelect(resetSelect) {
33 debug("Setting the value to an invalid value:");
34 resetSelect(sel);
35 sel.value = 'x';
36 shouldBe("sel.selectedIndex", "-1");
38 debug("Setting the value to null:");
39 resetSelect(sel);
40 sel.value = null;
41 shouldBe("sel.selectedIndex", "-1");
43 debug("Setting the value to undefined:");
44 resetSelect(sel);
45 sel.value = undefined;
46 shouldBe("sel.selectedIndex", "-1");
49 debug("-- Menu list select:");
50 sel = document.getElementById("theSelect");
51 runTestsOnSelect(resetSingleSelect);
53 debug("-- List box select:");
54 sel = document.getElementById("theMultipleSelect");
55 runTestsOnSelect(resetMultipleSelect);
57 successfullyParsed = true;
58 </script>
60 </body>
61 </html>