[webkit-dev] Question about Constructors in WebKit JS Bindings

Maciej Stachowiak mjs at apple.com
Tue Jun 23 16:41:18 PDT 2009


On Jun 23, 2009, at 3:44 PM, Adam Barth wrote:

> I don't mean to pick on workers specifically.  We have lots of bugs in
> the bindings where we attach the __proto__ property of new objects to
> the wrong prototype chain.  My specific concern is that we should fix
> these bugs.  :)

Tentatively speaking, I think it's always right to attach to the  
prototype chain from the constructor object actually used (i.e. the  
one present in its "prototype" property). Any time we don't do that, I  
believe it is a bug. (I'm qualifying all my statements because this  
area is complex enough that I'm unsure whether there are exceptions.)

  - Maciej

>
> Adam
>
>
> On Tue, Jun 23, 2009 at 3:38 PM, Drew Wilson<atwilson at google.com>  
> wrote:
>> BTW, Adam - can you elaborate your specific concerns?
>>
>> On Tue, Jun 23, 2009 at 3:37 PM, Drew Wilson <atwilson at google.com>  
>> wrote:
>>>
>>> Not sure. There's language in the WebIDL spec around prototype  
>>> objects of
>>> interface objects, but I'm not sure how window.Worker.prototype is  
>>> intended
>>> to relate to
>>> new Worker().prototype (if at all), based on my 10 minutes of  
>>> scanning specs.
>>> -atw
>>>
>>> On Tue, Jun 23, 2009 at 3:26 PM, Adam Barth <abarth at webkit.org>  
>>> wrote:
>>>>
>>>> 2009/6/23 Drew Wilson <atwilson at google.com>:
>>>>> On Tue, Jun 23, 2009 at 11:49 AM, Adam Barth <abarth at webkit.org>  
>>>>> wrote:
>>>>>>
>>>>>>> I am not even sure all of these should have the same behavior,
>>>>>>> however. For instance, as I read the Web Workers spec, the  
>>>>>>> lexical
>>>>>>> global
>>>>>>> object may be correct thing to use for the Worker constructor.
>>>>>>
>>>>>> I looked at the spec briefly.  What leads you to think that?   
>>>>>> It's
>>>>>> probably a bug in the spec.
>>>>>
>>>>> Section 4.5 of the web workers spec reads:
>>>>>>
>>>>>> Given a script's global scope o when creating or obtaining a  
>>>>>> worker,
>>>>>> the list of relevant Document objects to add depends on the  
>>>>>> type of o. If o
>>>>>> is a WorkerGlobalScope object (i.e. if we are creating a nested  
>>>>>> worker),
>>>>>> then the relevant Documents are the Documents that are in o's  
>>>>>> own list of
>>>>>> the worker's Documents. Otherwise, o is a Window object, and  
>>>>>> the relevant
>>>>>> Document is just the Document that is the active document of  
>>>>>> the Window
>>>>>> object o.
>>>>>
>>>>> So it seems to imply that parent document for a worker is  
>>>>> derived from
>>>>> the currently executing script's global scope. I'll ping IanH  
>>>>> about this -
>>>>> it may not be what he intended.
>>>>
>>>> There's another question, which is where does the prototype chain  
>>>> of
>>>> the JS object you get out of the worker constructor point?  It  
>>>> might
>>>> not have anything to do with this Document calculation.
>>>>
>>>> Adam
>>>
>>
>>



More information about the webkit-dev mailing list