Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea41944

Browse files
committed
util: freeze kEnumerableProperty
1 parent 440d95a commit ea41944

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/internal/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ const lazyDOMException = hideStackFrames((message, name) => {
504504

505505
const kEnumerableProperty = ObjectCreate(null);
506506
kEnumerableProperty.enumerable = true;
507+
ObjectFreeze(kEnumerableProperty);
507508

508509
const kEmptyObject = ObjectFreeze(ObjectCreate(null));
509510

test/parallel/test-internal-util-objects.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ Object.prototype.blep = 'blop';
2929
Object.getOwnPropertyNames(kEnumerableProperty),
3030
[ 'enumerable' ]
3131
);
32+
assert.strictEqual(
33+
Object.isExtensible(kEnumerableProperty),
34+
false
35+
);
36+
assert.strictEqual(
37+
Object.isSealed(kEnumerableProperty),
38+
true
39+
);
40+
assert.strictEqual(
41+
Object.isFrozen(kEnumerableProperty),
42+
true
43+
);
44+
45+
assert.throws(
46+
() => kEnumerableProperty.enumerable = false,
47+
TypeError
48+
);
3249
}
3350

3451
{

0 commit comments

Comments
 (0)