FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

util: freeze `kEnumerableProperty` by LiviaMedeiros · Pull Request #43390 · nodejs/node · GitHub

/ node Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions lib/internal/util.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
29 changes: 29 additions & 0 deletions test/parallel/test-internal-util-objects.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,35 @@ Object.prototype.blep = 'blop';
Object.getOwnPropertyNames(kEnumerableProperty),
[ 'enumerable' ]
);

assert.throws(
() => Object.setPrototypeOf(kEnumerableProperty, { value: undefined }),
TypeError
);
assert.throws(
() => delete kEnumerableProperty.enumerable,
TypeError
);
assert.throws(
() => kEnumerableProperty.enumerable = false,
TypeError
);
assert.throws(
() => Object.assign(kEnumerableProperty, { enumerable: false }),
TypeError
);
assert.throws(
() => kEnumerableProperty.value = undefined,
TypeError
);
assert.throws(
() => Object.assign(kEnumerableProperty, { value: undefined }),
TypeError
);
assert.throws(
() => Object.defineProperty(kEnumerableProperty, 'value', {}),
TypeError
);
}

{
Expand Down

Back | FazBrowse Home | New Git URL