| 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-214 |
| 6 |
description: > |
| 7 |
Object.defineProperty - 'O' is an Array, 'name' is an array index |
| 8 |
property and its configurable and writable attributes are set to |
| 9 |
false, test TypeError is thrown when the type of the [[Value]] |
| 10 |
field of 'desc' is different from the type of the [[Value]] |
| 11 |
attribute value of 'name' (15.4.5.1 step 4.c) |
| 12 |
includes: [propertyHelper.js] |
| 13 |
---*/ |
| 14 |
|
| 15 |
var arrObj = []; |
| 16 |
|
| 17 |
Object.defineProperty(arrObj, 0, { |
| 18 |
value: 101, |
| 19 |
writable: false, |
| 20 |
configurable: false |
| 21 |
}); |
| 22 |
|
| 23 |
try { |
| 24 |
Object.defineProperty(arrObj, "0", { |
| 25 |
value: "abc" |
| 26 |
}); |
| 27 |
$ERROR("Expected an exception."); |
| 28 |
} catch (e) { |
| 29 |
verifyEqualTo(arrObj, "0", 101); |
| 30 |
|
| 31 |
verifyNotWritable(arrObj, "0"); |
| 32 |
|
| 33 |
verifyNotEnumerable(arrObj, "0"); |
| 34 |
|
| 35 |
verifyNotConfigurable(arrObj, "0"); |
| 36 |
|
| 37 |
if (!(e instanceof TypeError)) { |
| 38 |
$ERROR("Expected TypeError, got " + e); |
| 39 |
} |
| 40 |
|
| 41 |
} |