redefine-length-with-various-values-and-configurable-true.js (898B)
1 // Copyright (c) 2020 Rick Waldron. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-array-exotic-objects-defineownproperty-p-desc 6 description: > 7 Redefining "length" to `configurable: true` throws a TypeError exception 8 info: | 9 ArraySetLength ( A, Desc ) 10 11 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ) 12 ---*/ 13 14 let a = [1]; 15 16 assert.throws(TypeError, () => { 17 Object.defineProperty(a, "length", { 18 configurable: true 19 }); 20 }); 21 assert.throws(TypeError, () => { 22 Object.defineProperty(a, "length", { 23 value: 1, 24 configurable: true 25 }); 26 }); 27 assert.throws(TypeError, () => { 28 Object.defineProperty(a, "length", { 29 value: 2, 30 configurable: true 31 }); 32 }); 33 assert.throws(TypeError, () => { 34 Object.defineProperty(a, "length", { 35 value: 3, 36 configurable: true 37 }); 38 }); 39 40 reportCompare(0, 0);