Skip to content

Commit 7424c98

Browse files
committed
lib: make String(global) === '[object global]'
This inadvertently changed to `[object Object]` with the V8 upgrade in 8a24728...96933df. Use `Symbol.toStringTag` to undo this particular change. Fixes: nodejs#9274
1 parent 8f00455 commit 7424c98

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/internal/bootstrap_node.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@
188188
}
189189

190190
function setupGlobalVariables() {
191+
Object.defineProperty(global, Symbol.toStringTag, {
192+
value: 'global',
193+
writable: false,
194+
enumerable: false,
195+
configurable: true
196+
});
191197
global.process = process;
192198
const util = NativeModule.require('util');
193199

test/parallel/test-global.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ const fooBar = module.fooBar;
2121
assert.strictEqual('foo', fooBar.foo, 'x -> global.x in sub level not working');
2222

2323
assert.strictEqual('bar', fooBar.bar, 'global.x -> x in sub level not working');
24+
25+
assert.strictEqual(Object.prototype.toString.call(global), '[object global]');

0 commit comments

Comments
 (0)