W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2014

Re: WindowProxy as the key in ES6 Set/Map/WeakSet/WeakMap

From: Adam Barth <abarth@chromium.org>
Date: Wed, 16 Apr 2014 06:50:55 -0700
Message-ID: <CAP=28cdbYb=mGsn4t++EUHYpmkv0pC2VTAioN-i2-svg5OncGQ@mail.gmail.com>
To: "Mark S. Miller" <erights@google.com>
Cc: Toon Verwaest <verwaest@chromium.org>, Rick Waldron <waldron.rick@gmail.com>, Boris Zbarsky <bzbarsky@mit.edu>, Adam Klein <adamk@chromium.org>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Wed, Apr 16, 2014 at 12:37 AM, Mark S. Miller <erights@google.com> wrote:

> Summing up, using an object as a key, in either a Map or a WeakMap, should
> only depend on the same object identity as used by ===. There's no reason
> to make an exception for WindowProxy, so don't.
>

These classes let you ask questions about identity that previously there
was no way of asking.  Specifically, they let you ask whether a given
object has the same identity as another object at another time.  The ===
operator only lets you ask identity questions of two objects at the same
time.

Saying "just use the existing notion of identity" doesn't help resolve the
question.

Adam



> On Wed, Apr 16, 2014 at 3:16 AM, Toon Verwaest <verwaest@chromium.org>wrote:
>
>>
>> >> From a use cases perspective, there is one issue: how does one attach
>> state to a "web page"?
>> >
>> >
>> > That's a slippery notion because sometimes |w| acts like the container
>> and sometimes it acts like the thing contained.  Sounds like a recipe for
>> security vulnerabilities when the author and WeakMap disagree about whether
>> they're talking about the container or the thing contained...
>>
>> If you want to associate state with a proxy, use a WeakMap.
>>
>> If you want to attach state to a specific window with all security
>> checks, install a private symbol on the window itself. (Granted, this does
>> not exist yet :-)).
>>
>
>
>
> --
>     Cheers,
>     --MarkM
>
Received on Wednesday, 16 April 2014 13:51:43 UTC

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