Test case: ``` window = this; (function() { // based on https://mathiasbynens.be/notes/globalthis 'use strict'; Object.defineProperty(Object.prototype, '__magic__', { get: function() { return this; } }); print('Is __magic__ a global', __magic__ === window); print('Is window.__magic__ a global', window.__magic__ === window); }()); ``` eshost-cli output: $ eshost -s test.js #### Chakra, SpiderMonkey, V8, V8 --harmony, XS Is __magic__ a global true Is window.__magic__ a global true #### JavaScriptCore Is __magic__ a global false Is window.__magic__ a global true
Looping in some JSC folks. Note that JSC’s behavior differs from other JS engines here. Does this seem like something you’d want to change?
Is there a test262 case for this?
I'm a bit confused; `window.__proto__ !== Object.prototype`, so why would `__magic__` be a global variable at all?
Object.prototype.isPrototypeOf(window) === true
ah, `window.__proto__.__proto__.__proto__.__proto__ === Object.prototype` - thanks for helping me understand :-)
I'm not sure how hard this is to change... could be anywhere from trivial to a huge rewrite. We should probably do it though since every other engine does it.
Note that this divergence only exists in strict mode -- all implementations do the same thing in sloppy mode.
Ross, in sloppy mode outcome is same, but I guess only because `this` in functions run without a context resolves to global So whether getter context is resolved as expected or not, doesn't make result any different.