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: https://github.com/nodejs/node/issues/9274
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Anna Henningsen 2016-10-25 22:13:24 +02:00
parent 45a716c968
commit 0fb21df6e6
No known key found for this signature in database
GPG Key ID: D8B9F5AEAE84E4CF
2 changed files with 8 additions and 0 deletions

View File

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

View File

@ -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]');