Figuring out the behavior of WindowProxy in the face of non-configurable properties
Mark S. Miller
erights at google.com
Wed Jan 28 10:57:29 PST 2015
On Wed, Jan 28, 2015 at 8:51 AM, Domenic Denicola <d at domenic.me> wrote:
> From: Mark S. Miller [mailto:erights at google.com]
> > On Tue, Jan 27, 2015 at 5:53 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> >> I'd like to understand better the suggestion here, because I'm not sure
> I'm entirely following it. Specifically, I'd like to understand it in
> terms of the internal methods defined by <
> >> Presumably you're proposing that we keep all of that as-is except for
> [[DefineOwnProperty]], right?
> >> For [[DefineOwnProperty]], are we basically talking about changing step
> 1 to:
> >> 1) If the [[Configurable]] field of Desc is present and
> Desc.[[Configurable]] is false, then throw a TypeError exception.
> >> while keeping everything else as-is,
> > Exactly correct. I didn't realize until reading your reply is that this
> is all that's necessary -- that it successfully covers all the cases I was
> thinking about without any further case division.
> I'm having a bit of trouble understanding how this maps to the solution
> described in your previous message, Mark. Your "I didn't realize until
> reading your reply is that this is all that's necessary" indicates I'm
> probably just missing something, so help appreciated.
> My question is, what happens if Desc.[[Configurable]] is not present, and
> P does not already exist on W? By my reading, we then fall through to
> calling the [[DefineOwnProperty]] internal method of W with arguments P and
> Assuming W's [[DefineOwnProperty]] is that of an ordinary object, I
> believe that takes us through OrdinaryDefineOwnProperty(W, P, Desc). Since
> P does not exist on W, and W is extensible, that takes us to
> ValidateAndApplyPropertyDescriptor(O, P, true, Desc, undefined). Then
> according to step 2.c, " If the value of an attribute field of Desc is
> absent, the attribute of the newly created property is set to its default
> value." The default value is false, right? So won't this try to define a
> non-configurable property on W?
In this situation, it will try and succeed. This more closely obeys the
intent in the original code (e.g., the comment in the jQuery code), since
it creates a non-configurable property on the *Window* W. It does not
violate any invariant, since all that's observable on the *WindowProxy*
(given the rest of your draft spec, which remain unchanged) is a
configurable property of the same name.
> I would have thought the modification needed to be more like:
> [[DefineOwnProperty]] (P, Desc)
> 1. If desc.[[Configurable]] is not present, set desc.[[Configurable]] to
> 2. If desc.[[Configurable]] is false, then throw a TypeError exception.
> 3. Return the result of calling the [[DefineOwnProperty]] internal method
> of W with arguments P and Desc.
> (here I have inserted step 1, but step 2 and 3 are unchanged from the
> previous incarnation).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss