Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Reflect/preventExtensions/prevent-extensions.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 26.1.12
5 description: >
6 Prevent extentions on target.
7 info: |
8 26.1.12 Reflect.preventExtensions ( target )
9
10 ...
11 2. Return target.[[PreventExtensions]]().
12
13 9.1.4 [[PreventExtensions]] ( )
14
15 1. Set the value of the [[Extensible]] internal slot of O to false.
16 ...
17 ---*/
18
19 var o = {};
20 Reflect.preventExtensions(o);
21 assert.sameValue(Object.isExtensible(o), false, 'object is not extensible');
22
23 assert.throws(TypeError, function() {
24 Object.defineProperty(o, 'y', {});
25 });
26 assert.throws(TypeError, function() {
27 Object.setPrototypeOf(o, Array.prototype);
28 });
29
30 Reflect.preventExtensions(o);
31 assert.sameValue(
32 Object.isExtensible(o), false,
33 'object is still not extensible on exhausted calls'
34 );