Debian Codegraph @

js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-251.js

raw
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-251
6 description: >
7 Object.defineProperty - 'O' is an Array, 'name' is an array index
8 named property, 'name' is data property and 'desc' is data
9 descriptor, and the [[Configurable]] attribute value of 'name' is
10 false, test TypeError is thrown if the [[Writable]] attribute
11 value of 'name' is false, and the [[Value]] field of 'desc' and
12 the [[Value]] attribute value of 'name' are two objects which
13 refer to the different objects (15.4.5.1 step 4.c)
14 includes: [propertyHelper.js]
15 ---*/
16
17 var arrObj = [];
18 var obj = {
19 length: 10
20 };
21
22 Object.defineProperty(arrObj, "1", {
23 value: obj
24 });
25
26 try {
27 Object.defineProperty(arrObj, "1", {
28 value: {}
29 });
30 throw new Test262Error("Expected an exception.");
31 } catch (e) {
32 if (!(e instanceof TypeError)) {
33 throw new Test262Error("Expected TypeError, got " + e);
34 }
35 }
36
37 verifyProperty(arrObj, "1", {
38 value: obj,
39 writable: false,
40 enumerable: false,
41 configurable: false,
42 });
43
44 reportCompare(0, 0);