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

Drew Wilson atwilson at google.com
Tue Jun 23 17:11:24 PDT 2009


On Tue, Jun 23, 2009 at 4:53 PM, Maciej Stachowiak <mjs at apple.com> wrote:

>
>
> The code above means that Worker.prototype is set at the time the Worker constructor itself is created, which is good. In the line you bolded, a fresh prototype object is created, and under the covers it will get cached. However, it looks to me like the Worker wrapper will use the prototype from the Window where the reference is created, rather than the one that the Worker constructor came from. So everything I said may be wrong. Short version: this all needs tests.
>

Agreed, tests would be good. BTW, I don't see where the code is using the
prototype from the Window where the reference is created. I do see where the
current ScriptExecutionContext is passed in to the Worker() constructor, but
that's just the WebCore class and shouldn't affect the JSWorker prototype?


>
> Also, there might be a subtle bug in the above code: what if window.Worker
> is first accessed from a different frame? Then the prototype of the Worker
> constructor itself will use the other frame's Object prototype as its
> prototype. I'm not sure if that is right. I think maybe JSWorkerConstructor
> should be passed the global object from which it is retrieved as a property,
> instead of using the lexical global object.
>

Good catch. This bug seems to be in all our custom generated constructors.


>
> Regards,
> Maciej
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090623/801b054c/attachment.html>


More information about the webkit-dev mailing list