W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2016

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

From: <bugzilla@jessica.w3.org>
Date: Fri, 05 Feb 2016 17:58:24 +0000
To: public-script-coord@w3.org
Message-ID: <bug-29421-3890-0Ios7ZG0Jj@http.www.w3.org/Bugs/Public/>

Boris Zbarsky <bzbarsky@mit.edu> changed:

           What    |Removed                     |Added
                 CC|                            |bzbarsky@mit.edu

--- Comment #1 from Boris Zbarsky <bzbarsky@mit.edu> ---
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
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

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.

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()

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.

You are receiving this mail because:
You are on the CC list for the bug.
Received on Friday, 5 February 2016 17:58:31 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:24 UTC