lib: make console writable and non-enumerable

According to the standard the property descriptor of console
should be writable and non-enumerable.

PR-URL: https://github.com/nodejs/node/pull/17708
Fixes: https://github.com/nodejs/node/issues/11805
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
This commit is contained in:
Ruben Bridgewater 2017-12-16 04:29:40 -02:00
parent f054855bbf
commit e99ae7764d
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
2 changed files with 3 additions and 5 deletions

View File

@ -321,10 +321,8 @@
const wrappedConsole = NativeModule.require('console'); const wrappedConsole = NativeModule.require('console');
Object.defineProperty(global, 'console', { Object.defineProperty(global, 'console', {
configurable: true, configurable: true,
enumerable: true, enumerable: false,
get() { value: wrappedConsole
return wrappedConsole;
}
}); });
setupInspector(originalConsole, wrappedConsole, Module); setupInspector(originalConsole, wrappedConsole, Module);
} }

View File

@ -16,7 +16,7 @@ function a() {
try { try {
return a(); return a();
} catch (e) { } catch (e) {
compiledConsole = consoleDescriptor.get(); compiledConsole = consoleDescriptor.value;
if (compiledConsole.log) { if (compiledConsole.log) {
// Using `console.log` itself might not succeed yet, but the code for it // Using `console.log` itself might not succeed yet, but the code for it
// has been compiled. // has been compiled.