diff --git a/lib/internal/util.js b/lib/internal/util.js index 030af62be8761e..36736da36d5313 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -504,6 +504,7 @@ const lazyDOMException = hideStackFrames((message, name) => { const kEnumerableProperty = ObjectCreate(null); kEnumerableProperty.enumerable = true; +ObjectFreeze(kEnumerableProperty); const kEmptyObject = ObjectFreeze(ObjectCreate(null)); diff --git a/test/parallel/test-internal-util-objects.js b/test/parallel/test-internal-util-objects.js index 092deb9e09464b..74068e4c577bd6 100644 --- a/test/parallel/test-internal-util-objects.js +++ b/test/parallel/test-internal-util-objects.js @@ -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 + ); } {