dom/bindings/test/test_named_getter_enumerability.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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>

mercurial