[Bug 29421] Should getters on a global without an explicit 'this' really throw TypeError?

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29421

--- Comment #2 from Christophe Dumez <dchris@gmail.com> ---
(In reply to Boris Zbarsky from comment #1)
> So the big web compat constraint here is that this should do the right thing:
> 
>   var perf = performance;
> 
> needs to work.  I believe in spec terms this ends up in
> http://www.ecma-international.org/ecma-262/6.0/#sec-object-environment-
> records-getbindingvalue-n-s which lands in
> http://www.ecma-international.org/ecma-262/6.0/#sec-get-o-p which will use
> the object associated with the object enviroment record (in this case the
> global) as "this".  So for this part to work, no effort is needed on the
> part of IDL.
> 
> You're correct that the current Firefox behavior makes this also work:
> 
>   Object.getOwnPropertyDescriptor(window, "performance").get.call()
> 
> I tried this in a few other browsers, with the following results:
> 
> 1) Chrome.  Seems to not actually have accessor properties on the window
> yet.  Presumably they're still updating to Web IDL for the window...  In any
> case, Object.getOwnPropertyDescriptor(window, "performance") returns a value
> descriptor.
> 
> 2) Safari.  Has some bizarre setup where descriptors on the global have
> undefined get and no value, but stuff somehow still works.  Basically,
> totally violates the ES spec.

Yes, I work on WebKit and am currently fixing this issue. This is also why I
wanted the behavior of implicit 'this' for the global Window Object to be
clarified.

On WebKit nightly, it does return getters/setters now but the following:
$ Object.getOwnPropertyDescriptor(window.__proto__, "performance").get.call()
throws a "TypeError: The DOMWindow.performance getter can only be used on
instances of DOMWindow" for now.

> 
> 3) IE11.  This seems to put the properties on window.__proto__, not window. 
> Subject to that constraint,
> Object.getOwnPropertyDescriptor(window.__proto__, "performance").get.call()
> works.
> 
> 4) Edge.  Object.getOwnPropertyDescriptor(window, "performance").get.call()
> works.
> 
> Speccing the Firefox/Edge behavior makes some sense to me, especially
> because the only reason the bareword works otherwise is because it takes a
> weird path to the getter.

Also, I think we should be clear about which window we should fall back to when
'this' is null/undefined, in the case of subframes. E.g.

otherWin = open("about:blank");
locationGetter = Object.getOwnPropertyDescriptor(otherWin, "location");
locationGetter.call()

should this be identical to:
locationGetter.call(otherWin)
or
locationGetter.call(window)
?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Friday, 5 February 2016 19:40:34 UTC