Skip to content

Commit

Permalink
fixup console test
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Jun 22, 2019
1 parent b4365d0 commit e94164d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
19 changes: 6 additions & 13 deletions lib/internal/freeze_intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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:
*
Expand Down
16 changes: 6 additions & 10 deletions test/parallel/test-freeze-intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit e94164d

Please sign in to comment.