michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 548671; michael@0: var summary = michael@0: "Don't use a shared-permanent inherited property to implement " + michael@0: "[].length or (function(){}).length"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var a = [1, 2, 3]; michael@0: a.__proto__ = null; michael@0: reportCompare("length" in a, true, "length should be own property of array"); michael@0: reportCompare(Object.hasOwnProperty.call(a, "length"), true, michael@0: "length should be own property of array"); michael@0: reportCompare(a.length, 3, "array length should be 3"); michael@0: michael@0: var a = [], b = []; michael@0: b.__proto__ = a; michael@0: reportCompare(b.hasOwnProperty("length"), true, michael@0: "length should be own property of array"); michael@0: b.length = 42; michael@0: reportCompare(b.length, 42, "should have mutated b's (own) length"); michael@0: reportCompare(a.length, 0, "should not have mutated a's (own) length"); michael@0: michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("All tests passed!");