mirror of
https://github.com/nodejs/node.git
synced 2025-05-13 10:54:13 +00:00

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>
32 lines
801 B
JavaScript
32 lines
801 B
JavaScript
'use strict';
|
|
// copy console accessor because requiring ../common touches it
|
|
const consoleDescriptor = Object.getOwnPropertyDescriptor(global, 'console');
|
|
delete global.console;
|
|
global.console = {};
|
|
|
|
require('../common');
|
|
|
|
// This test checks that, if Node cannot put together the `console` object
|
|
// because it is low on stack space while doing so, it can succeed later
|
|
// once the stack has unwound a little, and `console` is in a usable state then.
|
|
|
|
let compiledConsole;
|
|
|
|
function a() {
|
|
try {
|
|
return a();
|
|
} catch (e) {
|
|
compiledConsole = consoleDescriptor.value;
|
|
if (compiledConsole.log) {
|
|
// Using `console.log` itself might not succeed yet, but the code for it
|
|
// has been compiled.
|
|
} else {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
|
|
a();
|
|
|
|
compiledConsole.log('Hello, World!');
|