Skip to content

Commit d24bd20

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: #9274 PR-URL: #9279 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
1 parent 53520f0 commit d24bd20

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/internal/bootstrap_node.js

+6
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

+2
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)