summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/HTMLSelectElement/select-element-item-argument.html
blob: ec9d0b69baee50ac891a54236e7bb784f749dc42 (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
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.w3.org/TR/html51/forms.html#dom-select-item">
<script src="../../js/resources/js-test-pre.js"></script>
</head>
<body>
<select id="target">
  <option value="a">a</option>
  <option value="b">b</option>
  <option value="c">c</option>
  <option value="d">d</option>
</select>

<script>
description("Tests that the HTMLSelectElement.item() argument is correctly validated.");

var select = document.getElementById('target');
shouldBe("select.__proto__", "HTMLSelectElement.prototype");

// getter Node item(unsigned long index);
shouldBeEqualToString("select.item(0).value", "a");
shouldBeEqualToString("select.item(1).value", "b");
shouldBeEqualToString("select.item(2).value", "c");
shouldBeEqualToString("select.item(3).value", "d");
shouldBeNull("select.item(4)");
shouldBeNull("select.item(-1)"); // Offset is too large (after wrapping)
shouldBeEqualToString("select.item(-4294967294).value", "c"); // Wraps to 2, which is a valid offset.
shouldThrow("select.item()", '"TypeError: Failed to execute \'item\' on \'HTMLSelectElement\': 1 argument required, but only 0 present."');

</script>
</body>
</html>