Skip to content

Commit 8684dae

Browse files
cjihrigRafaelGSS
authored andcommitted
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: #46044 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent e90a3a6 commit 8684dae

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/internal/freeze_intrinsics.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const {
135135

136136
module.exports = function() {
137137
const { Console } = require('internal/console/constructor');
138-
const { console } = require('internal/console/global');
138+
const console = require('internal/console/global');
139139
const {
140140
clearImmediate,
141141
clearInterval,

test/parallel/test-freeze-intrinsics.js

+9
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ assert.throws(
3737
{ name: 'TypeError' });
3838
assert.strictEqual(globalThis.globalThis, globalThis);
3939
}
40+
41+
// Ensure that we cannot override console properties.
42+
{
43+
const { log } = console;
44+
45+
assert.throws(() => { console.log = null; },
46+
{ name: 'TypeError' });
47+
assert.strictEqual(console.log, log);
48+
}

0 commit comments

Comments
 (0)