OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="../../resources/js-test.js"></script> |
| 5 <select id="testSelect"> |
| 6 <option value="volvo" id="id1" name="name1a">Volvo</option> |
| 7 <option value="saab" id="id1" name="name1b">Saab</option> |
| 8 <option value="mercedes" id="id2" name="name2">Mercedes</option> |
| 9 <option value="audi" id="id3" name="name3">Audi</option> |
| 10 <option value="renault" id="id4" name="name3">Renault</option> |
| 11 </select> |
| 12 |
| 13 <script> |
| 14 description("This tests verifies the enumerated properties on HTMLOptionsCollect
ion and their order."); |
| 15 |
| 16 var testSelect = document.getElementById("testSelect"); |
| 17 var htmlOptionsCollection = testSelect.options; |
| 18 shouldBe("htmlOptionsCollection.__proto__", "HTMLOptionsCollection.prototype"); |
| 19 shouldBe("htmlOptionsCollection.__proto__.__proto__", "HTMLCollection.prototype"
); |
| 20 shouldBe("htmlOptionsCollection.length", "5"); |
| 21 |
| 22 // As per http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom
-interfaces.html#htmloptionscollection: |
| 23 // - The object's supported property indices are as defined for HTMLCollection o
bjects. |
| 24 // - The supported property names consist of the non-empty values of all the id
and name attributes of all the elements |
| 25 // represented by the collection, in tree order, ignoring later duplicates, wi
th the id of an element preceding its |
| 26 // name if it contributes both, they differ from each other, and neither is th
e duplicate of an earlier entry. |
| 27 var expectedEnumeratedProperties = ["0", "1", "2", "3", "4", "length", "selected
Index", "id1", "name1a", "name1b", "id2", "name2", "id3", "name3", "id4", "named
Item", "add", "remove", "item"]; |
| 28 |
| 29 var enumeratedProperties = []; |
| 30 for (var property in htmlOptionsCollection) { |
| 31 enumeratedProperties[enumeratedProperties.length] = property; |
| 32 } |
| 33 shouldBe("enumeratedProperties", "expectedEnumeratedProperties"); |
| 34 </script> |
| 35 </body> |
| 36 </html> |
OLD | NEW |