| 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.9-2-c-3 |
| 6 |
description: > |
| 7 |
Object.freeze - The [[Configurable]] attribute of all own data |
| 8 |
property of 'O' is set to false while other attributes are |
| 9 |
unchanged |
| 10 |
includes: [propertyHelper.js] |
| 11 |
---*/ |
| 12 |
|
| 13 |
var obj = {}; |
| 14 |
var resultSetFun = false; |
| 15 |
|
| 16 |
Object.defineProperty(obj, "foo1", { |
| 17 |
value: 10, |
| 18 |
writable: false, |
| 19 |
enumerable: true, |
| 20 |
configurable: true |
| 21 |
}); |
| 22 |
|
| 23 |
function get_func() { |
| 24 |
return 10; |
| 25 |
} |
| 26 |
|
| 27 |
function set_func() { |
| 28 |
resultSetFun = true; |
| 29 |
} |
| 30 |
|
| 31 |
Object.defineProperty(obj, "foo2", { |
| 32 |
get: get_func, |
| 33 |
set: set_func, |
| 34 |
enumerable: true, |
| 35 |
configurable: true |
| 36 |
}); |
| 37 |
|
| 38 |
Object.freeze(obj); |
| 39 |
|
| 40 |
verifyNotConfigurable(obj, "foo2"); |
| 41 |
verifyEqualTo(obj, "foo2", 10); |
| 42 |
|
| 43 |
obj.foo2 = 12; |
| 44 |
if (!resultSetFun) { |
| 45 |
$ERROR('Expected obj["foo2"] set() to be called, but was not.'); |
| 46 |
} |
| 47 |
|
| 48 |
if (!isEnumerable(obj, "foo2")) { |
| 49 |
$ERROR('Expected obj["foo2"] to be enumerable.'); |
| 50 |
} |
| 51 |
|
| 52 |
var desc1 = Object.getOwnPropertyDescriptor(obj, "foo1"); |
| 53 |
if (desc1.configurable || desc1.writable) { |
| 54 |
$ERROR('Expected obj["foo1"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc1)); |
| 55 |
} |
| 56 |
|
| 57 |
var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2"); |
| 58 |
if (desc2.configurable || desc2.writable) { |
| 59 |
$ERROR('Expected obj["foo2"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc2)); |
| 60 |
} |
| 61 |
|
| 62 |
verifyEqualTo(obj, "foo1", 10); |
| 63 |
|
| 64 |
verifyNotWritable(obj, "foo1"); |
| 65 |
|
| 66 |
verifyEnumerable(obj, "foo1"); |
| 67 |
|
| 68 |
verifyNotConfigurable(obj, "foo1"); |