Skip to content

Commit

Permalink
Merge pull request #307 from Ms2ger/form-named-getter-listed
Browse files Browse the repository at this point in the history
Add additional tests for the named getter in form with other listed elements.
  • Loading branch information
jgraham committed Aug 27, 2013
2 parents 472f7b3 + 70922ba commit fc7e746
Showing 1 changed file with 53 additions and 5 deletions.
58 changes: 53 additions & 5 deletions html/semantics/forms/the-form-element/form-nameditem.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<!-- XXX Nothing tests id attributes yet. -->
<!-- XXX Keygen. -->
<!-- XXX We also need tests for moving inputs and forms in the DOM. -->
<form>
<input type=button name=button>
Expand All @@ -12,6 +14,40 @@
<input type=radio name=radio value=z>
</form>

<form>
<button name=l1></button>
<fieldset name=l2></fieldset>
<input type=hidden name=l3>
<input type=text name=l4>
<input type=search name=l5>
<input type=tel name=l6>
<input type=url name=l7>
<input type=email name=l8>
<input type=password name=l9>
<input type=datetime name=l10>
<input type=date name=l11>
<input type=month name=l12>
<input type=week name=l13>
<input type=time name=l14>
<input type=datetime-local name=l15>
<input type=number name=l16>
<input type=range name=l17>
<input type=color name=l18>
<input type=checkbox name=l19>
<input type=radio name=l20>
<input type=file name=l21>
<input type=submit name=l22>
<input type=image name=l23>
<input type=reset name=l24>
<input type=button name=l25>
<input type=foo name=l26>
<input name=l27>
<object name=l28></object>
<output name=l29></output>
<select name=l30></select>
<textarea name=l31></textarea>
</form>

<form>
<!-- EventTarget -->
<input type=radio name=addEventListener>
Expand Down Expand Up @@ -112,6 +148,18 @@
}, "Invoking a legacycaller on the NodeList returned from the named getter " +
"should not work")

test(function() {
var form = document.getElementsByTagName("form")[1]
for (var i = 1; i <= 31; ++i) {
if (i == 23) {
// input type=image
assert_equals(form["l" + i], undefined)
} else {
assert_equals(form["l" + i], form.children[i - 1])
}
}
}, "All listed elements except input type=image should be present in the form")

test(function() {
var names = [
// EventTarget
Expand All @@ -127,14 +175,14 @@
"name", "noValidate", "target", "elements", "length", "submit", "reset",
"checkValidity"
]
var form = document.getElementsByTagName("form")[1]
var form = document.getElementsByTagName("form")[2]
names.forEach(function(name, i) {
assert_equals(form[name], form.children[i])
})
}, "Named elements should override builtins")

test(function() {
var form = document.getElementsByTagName("form")[2]
var form = document.getElementsByTagName("form")[3]
assert_equals(form.x, undefined, "x should not be associated with the form")
assert_equals(form.y, undefined, "y should not be associated with the form")
assert_equals(form.z, undefined, "z should not be associated with the form")
Expand All @@ -143,7 +191,7 @@
}, "Named items outside the form should not be returned (no children)")

test(function() {
var form = document.getElementsByTagName("form")[3]
var form = document.getElementsByTagName("form")[4]
assert_equals(form.x, undefined, "x should not be associated with the form")
assert_equals(form.y, undefined, "y should not be associated with the form")
assert_equals(form.z, undefined, "z should not be associated with the form")
Expand All @@ -152,7 +200,7 @@
}, "Named items outside the form should not be returned (one child)")

test(function() {
var form = document.getElementsByTagName("form")[4]
var form = document.getElementsByTagName("form")[5]
assert_equals(form.id, "a")

var input = document.getElementsByName("b")[0]
Expand All @@ -163,7 +211,7 @@
}, "The form attribute should be taken into account for named getters (single element)")

test(function() {
var form = document.getElementsByTagName("form")[5]
var form = document.getElementsByTagName("form")[6]
assert_equals(form.id, "c")

var input1 = document.getElementsByName("d")[0]
Expand Down

0 comments on commit fc7e746

Please sign in to comment.