Skip to content

Commit

Permalink
util: freeze kEnumerableProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
LiviaMedeiros committed Jun 12, 2022
1 parent 440d95a commit ea41944
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ const lazyDOMException = hideStackFrames((message, name) => {

const kEnumerableProperty = ObjectCreate(null);
kEnumerableProperty.enumerable = true;
ObjectFreeze(kEnumerableProperty);

const kEmptyObject = ObjectFreeze(ObjectCreate(null));

Expand Down
17 changes: 17 additions & 0 deletions test/parallel/test-internal-util-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ Object.prototype.blep = 'blop';
Object.getOwnPropertyNames(kEnumerableProperty),
[ 'enumerable' ]
);
assert.strictEqual(
Object.isExtensible(kEnumerableProperty),
false
);
assert.strictEqual(
Object.isSealed(kEnumerableProperty),
true
);
assert.strictEqual(
Object.isFrozen(kEnumerableProperty),
true
);

assert.throws(
() => kEnumerableProperty.enumerable = false,
TypeError
);
}

{
Expand Down

0 comments on commit ea41944

Please sign in to comment.