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

RE: Question about implements statements

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>
Message-ID: <9768D477C67135458BF978A45BCF9B38383977FB@TK5EX14MBXW602.wingroup.windeploy.ntdev.microsoft.com>
> -----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. 


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

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