Relationship between globals, Realms, and global environment records

Allen Wirfs-Brock allen at
Tue Nov 25 11:48:09 PST 2014

On Nov 25, 2014, at 11:27 AM, Boris Zbarsky wrote:

> On 11/25/14, 2:23 PM, Domenic Denicola wrote:
>> The only remaining issue is that ES specifies that `this` is the global object in script code, whereas in browsers `this === window`, i.e. it is not actually the global object but instead the WindowProxy.
> Yep.  This is the one remaining problem with this whole setup.
> Note that this is kinda needed for web compat no matter what we do with the case, by the way, because if people grab "this" and hand it out to some script outside the window in question and then navigate the window, the "some script" needs to end up having a proxy for the new global.

It would be trivial to change the ES spec. to allow for the script this binding and global object to be set to independent value when a Realm is created. 

Can anybody in ES land see any negative consequences to allowing this?

Note that the top-level this binding in a module has the value undefined.  This means that at a module top level: 'window.x' access 'x' via the window proxy, 'x' accesses via the global object, and 'this.x' throws.


More information about the es-discuss mailing list