4 <script src=
"../../resources/js-test.js"></script>
6 <input id=
"id1" name=
"name1"></input>
7 <input id=
"id2" name=
"name1"></input>
8 <input id=
"id3"></input>
9 <input id=
"id4" name=
"name4"></input>
10 <input name=
"name5"></input>
11 <input id=
"id4" name=
"name6"></input>
15 description("This tests verifies the enumerated properties on HTMLFormControlsCollection and their order.");
17 var testForm
= document
.getElementById("testForm");
18 var htmlFormControlsCollection
= testForm
.elements
;
19 shouldBe("htmlFormControlsCollection.__proto__", "HTMLFormControlsCollection.prototype");
20 shouldBe("htmlFormControlsCollection.__proto__.__proto__", "HTMLCollection.prototype");
21 shouldBe("htmlFormControlsCollection.length", "6");
23 // As per http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlformcontrolscollection-0:
24 // - The object's supported property indices are as defined for HTMLCollection objects.
25 // - The supported property names consist of the non-empty values of all the id and name attributes of all the elements
26 // represented by the collection, in tree order, ignoring later duplicates, with the id of an element preceding its name if
27 // it contributes both, they differ from each other, and neither is the duplicate of an earlier entry.
28 var expectedEnumeratedProperties
= ["0", "1" , "2", "3", "4", "5", "length", "id1", "name1", "id2", "id3", "id4", "name4", "name5", "name6", "namedItem", "item"].sort();
30 var enumeratedProperties
= [];
31 for (var property
in htmlFormControlsCollection
) {
32 enumeratedProperties
[enumeratedProperties
.length
] = property
;
34 enumeratedProperties
.sort();
35 shouldBe("enumeratedProperties", "expectedEnumeratedProperties");