2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
6 function check(obj, name, value, readonly) {
7 // Start with a non-configurable, writable data property implemented via
8 // js::PropertyOp getter and setter.
9 var pd = Object.getOwnPropertyDescriptor(obj, name);
11 assertEq(pd.configurable, false, "non-configurable " + name);
12 assertEq(pd.writable, !readonly, "writable " + name);
15 // Do not allow a transition from js::PropertyOp to writable js::Value
17 Object.defineProperty(obj, name, {writable: true});
20 assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'");
25 // Do not allow the property denoted by name to become a true data
26 // property via a descriptor that preserves the native property's
27 // writable attribute.
28 Object.defineProperty(obj, name, {value: value});
31 assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'");
36 // Do not allow the property to be frozen at some bogus value.
37 Object.defineProperty(obj, name, {value: "bogus", writable: false});
40 assertEq('' + e, "TypeError: can't redefine non-configurable property '" + name + "'");
43 // Now make name non-writable.
44 Object.defineProperty(obj, name, {writable: false})
46 // Assert that the right getter result "stuck".
47 assertEq(obj[name], value);
49 // Test that it is operationally non-writable now.
51 assertEq(obj[name], value);
54 check(Object, 'caller', null, false);
55 check(Object, 'arguments', null, false);
57 // Reset RegExp.leftContext to the empty string.
59 check(RegExp, 'leftContext', '', true);
61 reportCompare(0, 0, "ok");