lib: fix incorrect use of console intrinsic

The console object was not being frozen because the intrinsic
freezing code was accessing undefined instead of the console
object.

PR-URL: https://github.com/nodejs/node/pull/46044
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
cjihrig authored and Node.js GitHub Bot committed 2023-01-03 17:28:30 +00:00
1 parent 30a548475b
commit 57048acedc
2 files changed
+10 -1

No files matched your search

+1 -1
View File
@@ -135,7 +135,7 @@ const {
module.exports = function() {
const { Console } = require('internal/console/constructor');
const { console } = require('internal/console/global');
const console = require('internal/console/global');
const {
clearImmediate,
clearInterval,
+9
View File
@@ -37,3 +37,12 @@ assert.throws(
{ name: 'TypeError' });
assert.strictEqual(globalThis.globalThis, globalThis);
}
// Ensure that we cannot override console properties.
{
const { log } = console;
assert.throws(() => { console.log = null; },
{ name: 'TypeError' });
assert.strictEqual(console.log, log);
}