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 07:23:25 -0700
Message-ID: <CAP=28cemCodvzbm+BneND4CtKWnoxMf=jRuECQyrnwFp+heY7w@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: "Mark S. Miller" <erights@google.com>, 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 7:13 AM, Adam Barth <abarth@chromium.org> wrote:

> On Wed, Apr 16, 2014 at 6:57 AM, Domenic Denicola <
> domenic@domenicdenicola.com> wrote:
>
>> Let’s put it this way; perhaps what Mark’s saying will be clearer.
>>
>> Given:
>>
>> ```js
>> const m = new Map();
>> m.set(windowProxyInstance, "foo");
>> ```
>>
>> (and given that nothing else is added to `m`), then `m.get(x) === "foo"`
>> should be true _if and only if_ SameValueZero(x, windowProxyInstance) is
>> true (which in this case reduces to `x === windowProxyInstance`).
>>
>> Window proxies should do nothing to violate this invariant of `Map`s.
>>
>> With that in mind, is there something special about window proxies that
>> would allow them to abide by this invariant but still run into the
>> questions and problems stated in this thread?
>>
>
> Presumably you would agree that if I wrote:
>
> windowProxyInstance = someOtherObject;
>
> then operator=== questions about windowProxyInstance wouldn't be relevant
> for answering questions about how m.get behaves.
>
> One way of phrasing the original question is asking whether navigating a
> browsing context keeps the identity of the windowProxyInstance constant or
> whether the identity of the windowProxyInstance changes and all fields
> containing a reference to the previous windowProxyInstance are updated to
> refer to the new windowProxyInstance.
>
> I don't believe there's an experiment you can run today in browsers to
> answer that question.  Map would give you a way to answer that question,
> which is why we need to decide what the answer ought to be.
>

It might be interesting to think about how private names interact with
WindowProxy.

var tools = (function () {
  private unique;
  function store(x) { x.unique = 42; }
  function check(x) { return x.unique === 42; }
  return { store: store, check: check };
})();

const m = new WeakMap();

var a = ....
tools.store(a);
m.set(a, 42);

var b = ....
print tools.check(b);
print m.get(b);

Assuming there are no other callers of |store| and no other values added to
m, is it possible for this program to print two different values with the
two print statements?

Adam
Received on Wednesday, 16 April 2014 14:24:14 UTC

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