[webkit-dev] The "thisObject" parameter for JSEvaluateScript

Darin Adler darin at apple.com
Mon Mar 24 13:22:51 PDT 2008


On Mar 24, 2008, at 11:40 AM, Scott Thompson wrote:

> I'm using JavaScript core to integrate JavaScript as an embedded  
> scripting engine in my application.
>
> I've gotten a lot of "stuff" working (which is a lot of fun, BTW).  
> I've been able to run scripts and see them manipulate objects in my  
> application model (windows and the like... just to see if I could)  
> as well as objects in the object model (in the MVC sense) of my  
> problem domain.
>
> I've added a scripting menu.  I want the scripts that are run  
> through that menu to be executed "in the scope" of the frontmost  
> document. That is, I would like the a script whose textual content  
> is the word  "this" to evaluate to the document object of the  
> frontmost document.  To that end, I'm calling JSEvaluateScript and  
> I'm passing the JSObjectRef for my document object as it's third  
> parameter, "thisObject".
>
> Even when doing so, however, I find that within my scripts the  
> variable "this" still refers to the global context and not the  
> frontmost document.

This is a bug.

I'm not sure there's a bug report about it. I'd really appreciate it  
if you'd file one. <http://webkit.org/quality/reporting.html> If you'd  
prefer not to, please let me know and I'll do it.

I noticed that the thisObject argument was not used while working on  
some JavaScript speed-ups and never had time to follow up and check if  
it was actually broken.

     -- Darin



More information about the webkit-dev mailing list