On 23 April 2013 14:54, Allen Wirfs-Brock <[email protected]> wrote:
> Even if we had per object realm associations, it isn't clear to me what
> exactly we are trying to block WRT cross-realm [[Prototype]] chains. Is the
> assertion that all objects in a [[Prototype]] chain must come from the same
> realm. Does that mean that we must block creating such chains via
> Object.create or class declarations or classic constructor functions. It
> isn't clear to me why such cross-realm chains are necessarily evil. It also
> isn't clear to me why __proto__ should be prevented from creating them if we
> don't also prevent all other ways of doing so. In that case, the appropiate
> place to put semantic restrictions on prototype chain
> construction/modification is in the semantics of the ordinary object
> [[SetInheritance]] internal method rather than in individual built-in
> functions and abstract operations that invoke [[SetInheritance]].
Preventing cross-realm prototype chains was not the intention. The
intention was to prevent using a protosetter from another realm to
mutate a prototype chain in a realm where Object.prototype.__proto__
has been removed.
Here is my example again:
// Realm A
delete Object.prototype.__proto__ // no messing around
let other = getObjectFromSomewherePotentiallyAnotherRealmB()
let p1 = Object.create(other, {a: {value: 1}})
let o = Object.create(p1)
let p2 = Object.create({})
o.__proto__ = p2 // say what?
Everything is fine up to the last step. In particular, o has a
cross-realm prototype chain just fine. The only problem is with the
last line, which actually makes use of the __proto__ inherited from a
different realm to mutate o's prototype. My understanding was that
_that_ is the kind of thing we anted to prevent.
/Andreas
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss