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
PR-URL: #9279
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
  • Loading branch information
addaleax committed Nov 2, 2016
1 parent 53520f0 commit d24bd20
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 d24bd20

Please sign in to comment.