OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <meta charset=utf-8> |
| 3 <link rel=help href=https://dom.spec.whatwg.org/#interface-htmlcollection> |
| 4 <script src=../../../../resources/testharness.js></script> |
| 5 <script src=../../../../resources/testharnessreport.js></script> |
| 6 |
| 7 <div id=log></div> |
| 8 |
| 9 <!-- with no attribute --> |
| 10 <span></span> |
| 11 |
| 12 <!-- with `id` attribute --> |
| 13 <span id=''></span> |
| 14 <span id='some-id'></span> |
| 15 <span id='some-id'></span><!-- to ensure no duplicates --> |
| 16 |
| 17 <!-- with `name` attribute --> |
| 18 <span name=''></span> |
| 19 <span name='some-name'></span> |
| 20 <span name='some-name'></span><!-- to ensure no duplicates --> |
| 21 |
| 22 <!-- with `name` and `id` attribute --> |
| 23 <span id='another-id' name='another-name'></span> |
| 24 |
| 25 <script> |
| 26 test(function () { |
| 27 var elements = document.getElementsByTagName("span"); |
| 28 assert_array_equals( |
| 29 Object.getOwnPropertyNames(elements), |
| 30 ['0', '1', '2', '3', '4', '5', '6', '7', 'some-id', 'some-name', 'another-id
', 'another-name'] |
| 31 ); |
| 32 }, 'Object.getOwnPropertyNames on HTMLCollection'); |
| 33 |
| 34 test(function () { |
| 35 var elem = document.createElementNS('some-random-namespace', 'foo'); |
| 36 this.add_cleanup(function () {elem.remove();}); |
| 37 elem.setAttribute("name", "some-name"); |
| 38 document.body.appendChild(elem); |
| 39 |
| 40 var elements = document.getElementsByTagName("foo"); |
| 41 assert_array_equals(Object.getOwnPropertyNames(elements), ['0']); |
| 42 }, 'Object.getOwnPropertyNames on HTMLCollection with non-HTML namespace'); |
| 43 |
| 44 test(function () { |
| 45 var elem = document.createElement('foo'); |
| 46 this.add_cleanup(function () {elem.remove();}); |
| 47 document.body.appendChild(elem); |
| 48 |
| 49 var elements = document.getElementsByTagName("foo"); |
| 50 elements.someProperty = "some value"; |
| 51 |
| 52 assert_array_equals(Object.getOwnPropertyNames(elements), ['0', 'someProperty'
]); |
| 53 }, 'Object.getOwnPropertyNames on HTMLCollection with expando object'); |
| 54 </script> |
OLD | NEW |