Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 56b8cc5

Browse filesBrowse files
LiviaMedeirosdanielleadams
authored andcommitted
util: freeze kEnumerableProperty
PR-URL: #43390 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent fe7fd85 commit 56b8cc5
Copy full SHA for 56b8cc5

File tree

Expand file treeCollapse file tree

2 files changed

+30
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+30
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/util.js‎

Copy file name to clipboardExpand all lines: lib/internal/util.js
+1Lines 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

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-internal-util-objects.js
+29Lines changed: 29 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.