Bug 18048 - The "thisObject" parameter to JSEvaluateScript is not used properly
Summary: The "thisObject" parameter to JSEvaluateScript is not used properly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-24 14:14 PDT by Scott Thompson
Modified: 2008-03-24 19:27 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Thompson 2008-03-24 14:14:06 PDT
I created some code that tried to use JSEvaluateScript to pass a script to an object.  My expectation was that the script would be evaluated in the context of the object passed into the "thisObject" parameter, but I found that the script is always evaluated in the global context.

For example, I tried to do something like

JSObjectRef myDocumentObject = GetObjectRefForDocument(<some document here>);
JSEvaluateScript(jsContext, myScript, myDocumentObject, ... other args ...);

I wanted to pass the script:

this.addDocumentElement()

but that came up with a type error.  I had to use:

this.documents[0].addDocumentElement()

Which says to me that the script was evaluated in my global context, and not the context of my document object.
Comment 1 Sam Weinig 2008-03-24 19:27:59 PDT
Fix landed in r31267.