blob: 9d4939a9885917d86faba198dbf8e7cbf652a187 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.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>
</body>
</html>
|