|
1 <!DOCTYPE html> |
|
2 <meta charset=utf-8> |
|
3 <title>Test for named getter enumerability</title> |
|
4 <script src="/resources/testharness.js"></script> |
|
5 <script src="/resources/testharnessreport.js"></script> |
|
6 <div id="log"></div> |
|
7 <script> |
|
8 test(function() { |
|
9 var list = document.getElementsByTagName("div"); |
|
10 var desc = Object.getOwnPropertyDescriptor(list, "0"); |
|
11 assert_equals(typeof desc, "object", "Should have a '0' property"); |
|
12 assert_true(desc.enumerable, "'0' property should be enumerable"); |
|
13 desc = Object.getOwnPropertyDescriptor(list, "log"); |
|
14 assert_equals(typeof desc, "object", "Should have a 'log' property"); |
|
15 assert_false(desc.enumerable, "'log' property should not be enumerable"); |
|
16 }, "Correct getOwnPropertyDescriptor behavior"); |
|
17 test(function() { |
|
18 var list = document.getElementsByTagName("div"); |
|
19 props = []; |
|
20 for (var prop in list) { |
|
21 props.push(prop); |
|
22 } |
|
23 assert_not_equals(props.indexOf("0"), -1, "Should enumerate '0'"); |
|
24 assert_equals(props.indexOf("log"), -1, "Should not enumerate 'log'"); |
|
25 }, "Correct enumeration behavior"); |
|
26 test(function() { |
|
27 var list = document.getElementsByTagName("div"); |
|
28 props = Object.keys(list) |
|
29 assert_not_equals(props.indexOf("0"), -1, "Keys should contain '0'"); |
|
30 assert_equals(props.indexOf("log"), -1, "Keys should not contain 'log'"); |
|
31 }, "Correct keys() behavior"); |
|
32 test(function() { |
|
33 var list = document.getElementsByTagName("div"); |
|
34 props = Object.getOwnPropertyNames(list) |
|
35 assert_not_equals(props.indexOf("0"), -1, |
|
36 "own prop names should contain '0'"); |
|
37 assert_not_equals(props.indexOf("log"), -1, |
|
38 "own prop names should contain 'log'"); |
|
39 }, "Correct getOwnPropertyNames() behavior"); |
|
40 </script> |