mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
8 years ago
committed by
GitHub
1 changed files with 51 additions and 0 deletions
@ -0,0 +1,51 @@ |
|||
/* |
|||
* Properties inherited from Object.prototype must not prevent object |
|||
* literal creation. This ensures the internal code setting the object |
|||
* properties doesn't accidentally invoke side effects, etc. |
|||
*/ |
|||
|
|||
/*=== |
|||
{"nonConfigurable":123,"nonWritable":234,"nonConfigurableNonWritable":345,"nonConfigurableSetter":456} |
|||
===*/ |
|||
|
|||
function test() { |
|||
Object.defineProperties(Object.prototype, { |
|||
nonConfigurable: { |
|||
value: 'ancestor', |
|||
writable: true, |
|||
enumerable: false, |
|||
configurable: false |
|||
}, |
|||
nonWritable: { |
|||
value: 'ancestor', |
|||
writable: false, |
|||
enumerable: false, |
|||
configurable: true |
|||
}, |
|||
nonConfigurableNonWritable: { |
|||
value: 'ancestor', |
|||
writable: false, |
|||
enumerable: false, |
|||
configurable: false |
|||
}, |
|||
nonConfigurableSetter: { |
|||
set: function (v) { print('SETTER CALLED!'); }, |
|||
enumerable: false, |
|||
configurable: false |
|||
} |
|||
}); |
|||
|
|||
var obj = { |
|||
nonConfigurable: 123, |
|||
nonWritable: 234, |
|||
nonConfigurableNonWritable: 345, |
|||
nonConfigurableSetter: 456 |
|||
}; |
|||
print(JSON.stringify(obj)); |
|||
} |
|||
|
|||
try { |
|||
test(); |
|||
} catch (e) { |
|||
print(e.stack || e); |
|||
} |
Loading…
Reference in new issue