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