When using Rhino / Java 6's script engine:
ScriptEngine engine = manager.getEngineByName("JavaScript");
My problem is when I evaluate some scripts (normally written for the browser environment) the script engines crashes, due to "window" is not defined, which I fully understand since DOM is something created browser browsers.
However, what is the best way to simulate/mock the DOM environment (for example the "window" object).
Can this be done in Java (for example enabling something in ScriptEngine / Java) or do I have to include some kind of JavaScript that simulates the DOM?
What is currently the best solution to simulate this for Rhino/ Java 6 script engine?
The DOM is a HUGE environment. A complete simulation of everything in a browser is probably not available. HOWEVER, take a look at Bringing the Browser to the Server. If this has been maintained, it may be enough for your purposes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With