Skip to content

Commit 053347c

Browse files
LiviaMedeirostargos
authored andcommitted
util: freeze kEnumerableProperty
PR-URL: #43390 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 705a8af commit 053347c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/internal/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ function structuredClone(value) {
511511

512512
const kEnumerableProperty = ObjectCreate(null);
513513
kEnumerableProperty.enumerable = true;
514+
ObjectFreeze(kEnumerableProperty);
514515

515516
const kEmptyObject = ObjectFreeze(ObjectCreate(null));
516517

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

+29
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,35 @@ Object.prototype.blep = 'blop';
2929
Object.getOwnPropertyNames(kEnumerableProperty),
3030
[ 'enumerable' ]
3131
);
32+
33+
assert.throws(
34+
() => Object.setPrototypeOf(kEnumerableProperty, { value: undefined }),
35+
TypeError
36+
);
37+
assert.throws(
38+
() => delete kEnumerableProperty.enumerable,
39+
TypeError
40+
);
41+
assert.throws(
42+
() => kEnumerableProperty.enumerable = false,
43+
TypeError
44+
);
45+
assert.throws(
46+
() => Object.assign(kEnumerableProperty, { enumerable: false }),
47+
TypeError
48+
);
49+
assert.throws(
50+
() => kEnumerableProperty.value = undefined,
51+
TypeError
52+
);
53+
assert.throws(
54+
() => Object.assign(kEnumerableProperty, { value: undefined }),
55+
TypeError
56+
);
57+
assert.throws(
58+
() => Object.defineProperty(kEnumerableProperty, 'value', {}),
59+
TypeError
60+
);
3261
}
3362

3463
{

0 commit comments

Comments
 (0)