Browse Source

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>
v6
Anna Henningsen 8 years ago
parent
commit
0fb21df6e6
No known key found for this signature in database GPG Key ID: D8B9F5AEAE84E4CF
  1. 6
      lib/internal/bootstrap_node.js
  2. 2
      test/parallel/test-global.js

6
lib/internal/bootstrap_node.js

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

2
test/parallel/test-global.js

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

Loading…
Cancel
Save