diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index f4c781c7b841f0..6135c3090dac25 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -72,7 +72,6 @@ module.exports = function() { Function.prototype, // 19.2 Boolean.prototype, // 19.3 - // Disabled pending stack trace mutation handling Error.prototype, // 19.5 EvalError.prototype, RangeError.prototype, @@ -115,9 +114,8 @@ module.exports = function() { DataView.prototype, // 24.3 Promise.prototype, // 25.4 - getPrototypeOf(console), - - // Other APIs + // Other APIs / Web Compatibility + console.Console.prototype, BigInt.prototype, WebAssembly.Module.prototype, WebAssembly.Instance.prototype, @@ -222,17 +220,14 @@ module.exports = function() { escape, unescape, - // Web compatibility + // Other APIs / Web Compatibility clearImmediate, clearInterval, clearTimeout, setImmediate, setInterval, setTimeout, - console, - - // Other APIs BigInt, Atomics, WebAssembly, @@ -250,14 +245,12 @@ module.exports = function() { } intrinsicPrototypes.forEach(enableDerivedOverrides); + + const frozenSet = new WeakSet(); intrinsics.forEach(deepFreeze); + // Objects that are deeply frozen. function deepFreeze(root) { - // Objects that are deeply frozen. - // It turns out that Error is reachable from WebAssembly so it is - // explicitly added here to ensure it is not frozen - const frozenSet = new WeakSet([Error, Error.prototype]); - /** * "innerDeepFreeze()" acts like "Object.freeze()", except that: * diff --git a/test/parallel/test-freeze-intrinsics.js b/test/parallel/test-freeze-intrinsics.js index 284c9fcd67ee4b..0cae3167f9eaeb 100644 --- a/test/parallel/test-freeze-intrinsics.js +++ b/test/parallel/test-freeze-intrinsics.js @@ -10,18 +10,14 @@ assert.throws( // Ensure we can extend Console { - const logs = []; - class ExtendedConsole extends console.Console { - constructor() { - super(); - - this.log = (msg) => logs.push(msg); - } - } + class ExtendedConsole extends console.Console {} - const s = new ExtendedConsole(); + const s = new ExtendedConsole(process.stdout); + const logs = []; + s.log = (msg) => logs.push(msg); s.log('custom'); - + s.log = undefined; + assert.strictEqual(s.log, undefined); assert.strictEqual(logs.length, 1); assert.strictEqual(logs[0], 'custom'); }