Security Demands Simplicity (was: Private Slots)

Brandon Benvie brandon at brandonbenvie.com
Sun Jan 20 18:37:54 PST 2013


This looks to address the issues. The reason Proxoes would work (it doesn't
currently because I opted to switch back to using a regular internal
property because of the issue I mentioned) is because getting the date
value changes from "get internal property value" for which Proxies have no
specified forwarding method, to "forward [[Get]] of @@DateValue" which
obviously they have the mechanism to accomplish.

On Sunday, January 20, 2013, Allen Wirfs-Brock wrote:

>
> On Jan 20, 2013, at 4:42 PM, Brandon Benvie wrote:
>
> On Sunday, January 20, 2013, Allen Wirfs-Brock wrote:
>>
>> I'm not sure if you are getting at something other than what I've
>> described above.  If a @@DateValue private symbol is actually used as the
>> implementation of [[DateValue]] then actuality that would happen.
>>
>
> I explored implementing [[DateValue]], [[NumberValue]], etc. as symbols
> e.g. @@DateValue, but this causes observably different behavior from what
> is specified with a.) inheritance, and b.) interaction with proxies.
>
>
> I spend a lot of time working of Date last week, so you don't have the
> latests.
>
> In the case of inheritance at least, if it has observably different
> behavior it hasn't been implemented correctly or the spec. is still buggy.
>
> This is what my working draft currently says:
>
> Unless explicitly stated otherwise, the methods of the Date prototype
> object defined below are not generic and the *this* value passed to them
> must be an object that has a [[DateValue]] internal data property that has
> been initialized to a time value.
>
> The abstract operation thisTimeValue(*value*) performs the following
> steps:
>
>    1. If Type(*value)* is Object and *value* has a [[DateValue]] internal
>    data property, then
>       1. Let *n* be the Number that is the value of *value’s*[[NumberData]] internal data property.
>       2. If *n* is not *undefined*, then return *n*.
>    2. Throw a *TypeError* exception.
>
> In following descriptions of functions that are properties of the Date
> prototype object, the phrase “this Date object” refers to the object that
> is the *this* value for the invocation of the function. The phrase “this
> time value” within the specification of a method refers to the result
> returned  by calling the abstract operation thisTimeValue with the *this*value of the method invocation passed as the argument.
>
>
>     Object.create(new Date).getDate(); // works but is specified to not
> work
>
>
> If you are using a private Symbol for [[DateValue]] then the "has a
> [[DateValue]] internal data property" check in the above code needs to do a
> [[HasOwnProperty]] check rather than a [[HasProperty]]
>
>
>     new Proxy(new Date, {}).getDate(); // works but is specified to not
> work
>
>
> Not sure why this works in you implementation.  Can you explain.
>
>
> Since Proxy is new in ES6 this of course can still be fixed, but to make
> the first case work would be a (probably benign) backward incompatible
> change and isn't going to work cross-engine unless the spec is changed to
> explicitly allow/require it.
>
>
> Right, everything is still in flux which is why it is great that you are
> trying these things.
>
> Allen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130120/7b30cb21/attachment-0001.html>


More information about the es-discuss mailing list