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 86554bf

Browse filesBrowse files
cjihrigjuanarbol
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 <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>
1 parent 31b8cf1 commit 86554bf
Copy full SHA for 86554bf

File tree

Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/freeze_intrinsics.js‎

Copy file name to clipboardExpand all lines: lib/internal/freeze_intrinsics.js
+1-1Lines changed: 1 addition & 1 deletion
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,
Collapse file

‎test/parallel/test-freeze-intrinsics.js‎

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