Skip to content

Commit

Permalink
lib: make String(global) === '[object global]'
Browse files Browse the repository at this point in the history
This inadvertently changed to `[object Object]` with the V8 upgrade
in 8a24728...96933df. Use `Symbol.toStringTag` to undo this
particular change.

Fixes: #9274
  • Loading branch information
addaleax committed Oct 26, 2016
1 parent 8f00455 commit 7424c98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/internal/bootstrap_node.js
Expand Up @@ -188,6 +188,12 @@
}

function setupGlobalVariables() {
Object.defineProperty(global, Symbol.toStringTag, {
value: 'global',
writable: false,
enumerable: false,
configurable: true
});
global.process = process;
const util = NativeModule.require('util');

Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-global.js
Expand Up @@ -21,3 +21,5 @@ const fooBar = module.fooBar;
assert.strictEqual('foo', fooBar.foo, 'x -> global.x in sub level not working');

assert.strictEqual('bar', fooBar.bar, 'global.x -> x in sub level not working');

assert.strictEqual(Object.prototype.toString.call(global), '[object global]');

0 comments on commit 7424c98

Please sign in to comment.