The global object in browsers

Mark S. Miller erights at
Tue Feb 17 14:36:11 PST 2009

On Tue, Feb 17, 2009 at 2:02 PM, Ian Hickson <ian at> wrote:
> For HTML5, this behaviour has been defined in more detail. The global
> object is a Window object. This object is per-Document. The object
> returned by the "window" attribute on that global object is actually a
> WindowProxy object, which forwards everything to the "current" Window
> object. However, doing this has required that I require browsers to
> violate the requirement that the ES3 spec has, namely that "this" and the
> object at the top of the scope chain are both the global object, because
> in this model an invariant is that script cannot access the actual global
> object directly, only the proxy. The HTML5 spec says:
>   If the script's global object is a Window object, then in JavaScript,
>   the this keyword in the global scope must, contrary to the ECMAScript
>   specification, return the Window object's WindowProxy object.
> If it would be possible for the ECMAScript specification to have a hook
> that allowed me to require this without violating the spec, that would be
> great.

I don't understand. If the object you're calling Window is
inaccessible from ES code, and if the object you're calling
WindowProxy forwards everything to your Window, why not just relabel
Window -> InternalWindow, WindowProxy -> Window? And in any case, why
not just provide your WindowProxy as the global object to ES code? Why
does ES need to be aware of your Window at all?

The deeper problem here is that ES specs to date -- including the
draft ES3.1 spec -- have not yet admitted the existence of multiple
global objects. We all know we need to, but it is *way* too late to
consider such a change for ES3.1. For ES-Harmony, I think we all agree
we will take this step. Also, the draft module proposal at
<>, proposed by Ihab
Awad and Kris Kowal for ES-Harmony, relies on the introduction of a
"hermetic eval" which omits the global object from the bottom of the
scope chain.


More information about the Es-discuss mailing list