I use rhino 1.7R2 to run JavaScript code outside of a browser to test it. This works fine but as soon as the tested code uses jQuery I get this error message:
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "1.0" from null (jquery.js#6313)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
at org.mozilla.javascript.ScriptRuntime.c开发者_StackOverflow社区onstructError(ScriptRuntime.java:3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3595)
at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1343)
at org.mozilla.javascript.gen.c30._c1(jquery.js:6313)
At line 6313 of jquery.js I don't see code which could cause such an error message:
6313 jQuery.extend({
Anyone knows on what object jquery tries to access a property named "1.0"? I probably need to mock this object but up to now I was not able to find out what jquery tries to do here.
Be sure you have jquery file included.
Found the problem. I mocked only "location" but not "window.location" (Or the other way around, can't remember).
精彩评论