Debian Codegraph @

rhino/testsrc/doctests/object.issealed.doctest

raw
1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 js> load('testsrc/doctests/util.js');
6
7 js> Object.isSealed
8 function isSealed() { [native code for Object.isSealed, arity=1] }
9
10 js> expectTypeError(function() { Object.isSealed() });
11 js> [undefined, null, true, 1, 'hello'].forEach(function(value) {
12 > expectTypeError(function() { Object.isSealed(value) })
13 > })
14
15 js> Object.isSealed({})
16 false
17
18 js> var obj = Object.preventExtensions({});
19 js> Object.isSealed(obj);
20 true
21
22 js> var obj = Object.defineProperty({}, 'a', {configurable:false});
23 js> var _ = Object.preventExtensions(obj);
24 js> Object.isSealed(obj);
25 true
26
27 js> var obj = Object.defineProperty({}, 'a', {configurable:true});
28 js> var _ = Object.preventExtensions(obj);
29 js> Object.isSealed(obj);
30 false