Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / Object / freeze / 15.2.3.9-2-c-4.js
blobf211cbeb730aa9a97caaffb4d3c97b3510eaa96a
1 // Copyright (c) 2012 Ecma International.  All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 es5id: 15.2.3.9-2-c-4
6 description: >
7     Object.freeze - all own properties of 'O' are not writable and not
8     configurable
9 includes: [propertyHelper.js]
10 ---*/
12 var obj = {};
13 var resultSetFun = false;
15 Object.defineProperty(obj, "foo1", {
16   value: 10,
17   writable: false,
18   enumerable: true,
19   configurable: false
20 });
22 function get_func() {
23   return 10;
26 function set_func() {
27   resultSetFun = true;
30 Object.defineProperty(obj, "foo2", {
31   get: get_func,
32   set: set_func,
33   enumerable: true,
34   configurable: true
35 });
37 Object.freeze(obj);
39 verifyEqualTo(obj, "foo2", 10);
41 verifyProperty(obj, "foo2", {
42   configurable: false,
43 });
45 obj.foo2 = 12;
46 if (!resultSetFun) {
47   throw new Test262Error('Expected obj["foo2"] set() to be called, but was not.');
50 verifyProperty(obj, "foo2", {
51   enumerable: true,
52   configurable: false,
53 });
55 var desc2 = Object.getOwnPropertyDescriptor(obj, "foo2");
56 if (desc2.writable) {
57   throw new Test262Error('Expected obj["foo2"] to be non-writable, non-configurable; actually ' + JSON.stringify(desc2));
60 verifyProperty(obj, "foo1", {
61   value: 10,
62   writable: false,
63   enumerable: true,
64   configurable: false,
65 });
67 reportCompare(0, 0);