Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/defineProperty/15.2.3.6-4-14.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 info: |
6 Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method
7 of O to define the property. For configurable properties, step 9b of
8 [[DefineOwnProperty]] permits changing the kind of a property.
9 es5id: 15.2.3.6-4-14
10 description: >
11 Object.defineProperty permits changing data property to accessor
12 property for configurable properties
13 ---*/
14
15 var o = {};
16
17 // create a data property. In this case,
18 // [[Enumerable]] and [[Configurable]] are true
19 o["foo"] = 101;
20
21 // changing "foo" to be an accessor should succeed, since [[Configurable]]
22 // on the original property will be true. Existing values of [[Configurable]]
23 // and [[Enumerable]] need to be preserved and the rest need to be set to
24 // their default values
25
26 // dummy getter
27 var getter = function() {
28 return 1;
29 }
30 var d1 = {
31 get: getter
32 };
33 Object.defineProperty(o, "foo", d1);
34
35 var d2 = Object.getOwnPropertyDescriptor(o, "foo");
36
37 assert.sameValue(d2.get, getter, 'd2.get');
38 assert.sameValue(d2.enumerable, true, 'd2.enumerable');
39 assert.sameValue(d2.configurable, true, 'd2.configurable');