The global object in browsers

David-Sarah Hopwood david.hopwood at
Thu Feb 19 01:20:44 PST 2009

Ian Hickson wrote:
> On Tue, 17 Feb 2009, Mark S. Miller wrote:
>> 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?
> I don't really mind what the objects are called, the point is just that 
> the object at the top of the scope chain is not the same as the object 
> returned by "this" (or "window" on the global object).

MarkM's point is that *given that the object called Window is inaccessible*,
there's no way to observe that the object called Window is at the top of
the scope chain. An implementation could reflect all property changes
in that object to the object called WindowProxy, by some unspecified
mechanism (which is allowed since they are both host objects).

>> 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?
> When a browsing context navigates from page A to page B, the object at the 
> top of the scope chain in code from page A and the oject at the top of the 
> scope chain in code from page B are not the same object,

It's not possible to observe that, since by hypothesis neither object is
accessible to ECMAScript code.

> but the object returned by the global-scope "this" in scripts from A and B
> are the same object (===).

That would still be the case in MarkM's relabelling.

I'm confused by the motivation of the change in HTML5. It seems like it is
imposing most of the complexity that would be needed to fix some of the
security problems associated with the global object, *without* actually
fixing those problems.

Also, it is a breach of standards development etiquette for the HTML WG to
make a a change (even in a draft) that it believes to be incompatible with
the ECMAScript spec, without consulting TC39. It should not have been left
to you in the role of an implementor to point out the incompatibility.

David-Sarah Hopwood ⚥

More information about the Es-discuss mailing list