- From: Travis Leithead <travis.leithead@microsoft.com>
- Date: Fri, 15 Jun 2012 22:24:46 +0000
- To: Boris Zbarsky <bzbarsky@MIT.EDU>, "public-script-coord@w3.org" <public-script-coord@w3.org>
> -----Original Message----- > From: Boris Zbarsky [mailto:bzbarsky@MIT.EDU] > [Constructor()] interface A {}; > [Constructor()] interface B {}; > interface C { > readonly attribute long foo; > } > A implements C; > B implements C; > > and the following script: > > var b = new B(); > b.__proto__ = A.prototype; > b.foo; > // Or grab the getter using getOwnPropertyDescriptor > // and .call(), either way. > > Should this work? Quite honestly, my preference is that it should not, because > otherwise each of the getters will have to know how to deal with all possible > implementations of C. Similiarly, my preference is that the getter on > C.prototype not work for instances of either A or B... First of all, changing an instance's internal prototype is not legit ECMAScript. Beyond that, the getter (or setter) always has to validate the "this" value whenever it is invoked because you can always "bind" or "call" the method with _any_ this value. E.g., A.prototype.foo.call(b); So, I would expect implementations to already validate the calling object before allowing the getter to run. (Our implementation does.) Off topic: Usually interfaces that are right-hand-side targets for the implements statement Are marked with [NoInterfaceObject] so that you don't typically see this problem, but the scenario above can happen.
Received on Friday, 15 June 2012 22:25:36 UTC