| 1 |
// Copyright (c) 2012 Ecma International. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
es5id: 15.2.3.6-4-256 |
| 6 |
description: > |
| 7 |
Object.defineProperty - 'O' is an Array, 'name' is an array index |
| 8 |
named property, 'name' is accessor property and 'desc' is accessor |
| 9 |
descriptor, and the [[Configurable]] attribute value of 'name' is |
| 10 |
false, test TypeError is thrown if the [[Get]] field of 'desc' is |
| 11 |
present, and the [[Get]] field of 'desc' is an object and the |
| 12 |
[[Get]] attribute value of 'name' is undefined (15.4.5.1 step 4.c) |
| 13 |
includes: [propertyHelper.js] |
| 14 |
---*/ |
| 15 |
|
| 16 |
var arrObj = []; |
| 17 |
|
| 18 |
function getFunc() { |
| 19 |
return 12; |
| 20 |
} |
| 21 |
|
| 22 |
Object.defineProperty(arrObj, "1", { |
| 23 |
get: getFunc |
| 24 |
}); |
| 25 |
|
| 26 |
try { |
| 27 |
Object.defineProperty(arrObj, "1", { |
| 28 |
get: undefined |
| 29 |
}); |
| 30 |
$ERROR("Expected TypeError"); |
| 31 |
} catch (e) { |
| 32 |
assert(e instanceof TypeError); |
| 33 |
assert(arrObj.hasOwnProperty("1")); |
| 34 |
|
| 35 |
var desc = Object.getOwnPropertyDescriptor(arrObj, "1"); |
| 36 |
|
| 37 |
assert(arrObj[1] === getFunc()); |
| 38 |
assert(desc.hasOwnProperty("set") && typeof desc.set === "undefined"); |
| 39 |
|
| 40 |
verifyNotWritable(arrObj, "1"); |
| 41 |
|
| 42 |
verifyNotConfigurable(arrObj, "1"); |
| 43 |
} |