Skip to content

Commit

Permalink
lib: fix incorrect use of console intrinsic
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
cjihrig authored and RafaelGSS committed Jan 20, 2023
1 parent e90a3a6 commit 8684dae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/freeze_intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-freeze-intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 8684dae

Please sign in to comment.