Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / htmloptionscollection-enumerated-properties.html
blob14cc13de83c2639533d470e974484e6bfb7bd649
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>
13 <script>
14 description("This tests verifies the enumerated properties on HTMLOptionsCollection and their order.");
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");
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 objects.
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, with the id of an element preceding its
26 // name if it contributes both, they differ from each other, and neither is the duplicate of an earlier entry.
27 var expectedEnumeratedProperties = ["0", "1", "2", "3", "4", "length", "selectedIndex", "id1", "name1a", "name1b", "id2", "name2", "id3", "name3", "id4", "namedItem", "add", "remove", "item"].sort();
29 var enumeratedProperties = [];
30 for (var property in htmlOptionsCollection) {
31 enumeratedProperties[enumeratedProperties.length] = property;
33 enumeratedProperties.sort();
34 shouldBe("enumeratedProperties", "expectedEnumeratedProperties");
35 </script>
36 </body>
37 </html>