Take a look at 
http://htmlunit.svn.sourceforge.net/viewvc/htmlunit/trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/

Christophe

Luca a écrit :
> Hello everyone,
>       I started a small project for a "light" JavaScript parser using the
> Rhino technology. My idea is to have a fake JavaScript parser that can
> execute the code inside a page and give me the final result of the
> execution as raw text. 
> 
> I started by writing some Java Classes which correspond to Javascript
> common objects, like Document, Window, Location, and then hooking them
> one by one such as: 
> 
> ScriptableObject.putProperty(scope, "window", jsWindow);
> 
> where jswindow belongs to the custom Java class JavaScriptWindow I
> wrote. This worked actually pretty well in many cases; I'm trying to run
> it on a very small set of 485 pages containing scripts, and they arrive
> to an end without exceptions (even though I can't say it's a "correct"
> execution) in 50% of the cases. 
> 
> In another 25% of cases the script cannot complete because some function
> is missing (it's probably incorporated from some external script) but on
> the remaining 25% is due some other objects missing. 
> 
> For instance, executing this line I get an error on indexOf: 
>       navigator.userAgent.indexOf('MSIE')>=0
> even if in my class JavaScriptNavigator there is a 
>       public String userAgens 
> field, and the class is hooked into the scope with: 
> ScriptableObject.putProperty(scope, "location", jsWindow.location);
> 
> I guess my whole approach is naive and I need to change it completely,
> maybe using Java classes that implement the Scriptable interface, but
> I'd like some expert advice on it. Can anybody give me a hint? 
> 
> Thanks,
> Luca 
> 
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to