Debian Codegraph @

js/src/tests/test262/built-ins/Object/defineProperty/15.2.3.6-4-95.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-95
6 description: >
7 Object.defineProperty will throw TypeError when name.configurable
8 = false, name.writable = false, desc.value and name.value are two
9 objects which refer to the different objects (8.12.9 step
10 10.a.ii.1)
11 includes: [propertyHelper.js]
12 ---*/
13
14
15 var obj = {};
16
17 var obj1 = {
18 length: 10
19 };
20
21 Object.defineProperty(obj, "foo", {
22 value: obj1,
23 writable: false,
24 configurable: false
25 });
26
27 var obj2 = {
28 length: 20
29 };
30
31 try {
32 Object.defineProperty(obj, "foo", {
33 value: obj2
34 });
35 throw new Test262Error("Expected an exception.");
36 } catch (e) {
37 if (!(e instanceof TypeError)) {
38 throw new Test262Error("Expected TypeError, got " + e);
39 }
40 }
41
42 verifyProperty(obj, "foo", {
43 value: obj1,
44 writable: false,
45 enumerable: false,
46 configurable: false,
47 });
48
49 reportCompare(0, 0);