michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: * Contributor: michael@0: * Jeff Walden michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 858381; michael@0: var summary = michael@0: "Array length redefinition behavior with non-configurable elements"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var arr = [0, 1, 2]; michael@0: Object.defineProperty(arr, 1, { configurable: false }); michael@0: michael@0: try michael@0: { michael@0: Object.defineProperty(arr, "length", { value: 0, writable: false }); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof TypeError, true, michael@0: "must throw TypeError when array truncation would have to remove " + michael@0: "non-configurable elements"); michael@0: } michael@0: michael@0: assertEq(arr.length, 2, "length is highest remaining index plus one"); michael@0: michael@0: var desc = Object.getOwnPropertyDescriptor(arr, "length"); michael@0: assertEq(desc !== undefined, true); michael@0: michael@0: assertEq(desc.value, 2); michael@0: assertEq(desc.writable, false); michael@0: assertEq(desc.enumerable, false); michael@0: assertEq(desc.configurable, false); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");