From: Vinay M. <vin...@gm...> - 2005-03-03 06:44:31
|
Hi, I am using HtmlUnit to connect to a site that requires me to perform a SSL client authentication. The site works by installing a certificate in my browser using the IE ActiveX object XEnroll to make the certificate request. I trying to do the same through HtmlUnit and I think I havent been to load the ActiveX object at all. The page specifies the ActiveX object within a span element as : <span id="spanXenroll" style="display:none"> <Object ClassID="....." Codebase="...." ID="XEnroll"> </Object> </span> The code relating to the ActiveX Object is set dynamically using span's innerHtml property. The page also has a method to check if the ActiveX object has been loaded. This method is executed every 500ms using javascript's setTimeOut method. This method gets executed five times after which I get the following exception trace: Exception class=[org.mozilla.javascript.WrappedException] com.gargoylesoftware.htmlunit.ScriptException: Wrapped java.lang.IllegalArgumentException at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:294) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:709) at com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:266) at java.lang.Thread.run(Thread.java:534) WrappedException: org.mozilla.javascript.WrappedException: Wrapped java.lang.IllegalArgumentException at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1776) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:191) at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:456) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:3026) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:149) at org.mozilla.javascript.Context.evaluateString(Context.java:1220) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:289) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:709) at com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:266) at java.lang.Thread.run(Thread.java:534) Caused by: java.lang.IllegalArgumentException at java.lang.Thread.setPriority(Thread.java:873) at com.gargoylesoftware.htmlunit.javascript.host.Window.jsFunction_setTimeout(Window.java:287) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:174) ... 14 more Inside wrapped exception: java.lang.IllegalArgumentException at java.lang.Thread.setPriority(Thread.java:873) at com.gargoylesoftware.htmlunit.javascript.host.Window.jsFunction_setTimeout(Window.java:287) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:174) at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:456) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:3026) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:149) at org.mozilla.javascript.Context.evaluateString(Context.java:1220) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:289) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:709) at com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:266) at java.lang.Thread.run(Thread.java:534) == CALLING JAVASCRIPT == GargoyleWrapper4() ======= EXCEPTION END ======== The currentThread's priority falls out of the accepted range because of the repeated execution of the above function to test if the ActiveX object has been loaded. Is there anything else that I need to be doing to load the ActiveX object ? Any help would be greatly appreciated... Regards Vinay |
From: Brad C. <yo...@br...> - 2005-03-03 17:29:02
|
HtmlUnit's ActiveX support is really just a way of allowing pages with ActiveX controls to load without mock objects, not loading the real controls (unless you make an object that does that). A good example is the unit test for this: http://htmlunit.sourceforge.net/xref-test/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngineTest.html#755 SSL is also a bit of extra work to set up: http://htmlunit.sourceforge.net/jsse.html You've also hit a known bug when using setTimeout recursively: http://sourceforge.net/tracker/index.php?func=detail&aid=1103735&group_id=47038&atid=448266 I would suggest setting up jsse and making a mock object for your control that just always say that SSL is ready. You might also consider using setInterval in your web page instead of a recursive setTimeout. --- Vinay Murthy <vin...@gm...> wrote: > Hi, > > I am using HtmlUnit to connect to a site that requires me to perform a > SSL client authentication. The site works by installing a certificate > in my browser using the IE ActiveX object XEnroll to make the > certificate request. I trying to do the same through HtmlUnit and I > think I havent been to load the ActiveX object at all. > > The page specifies the ActiveX object within a span element as : > > <span id="spanXenroll" style="display:none"> > <Object ClassID="....." Codebase="...." ID="XEnroll"> > </Object> > </span> > > The code relating to the ActiveX Object is set dynamically using > span's innerHtml property. > > The page also has a method to check if the ActiveX object has been > loaded. This method is executed every 500ms using javascript's > setTimeOut method. This method gets executed five times after which I > get the following exception trace: > > Exception class=[org.mozilla.javascript.WrappedException] > com.gargoylesoftware.htmlunit.ScriptException: Wrapped > java.lang.IllegalArgumentException > at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:294) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:709) > at com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:266) > at java.lang.Thread.run(Thread.java:534) > > WrappedException: org.mozilla.javascript.WrappedException: Wrapped > java.lang.IllegalArgumentException > at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1776) > at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:191) > at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:456) > at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:3026) > at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164) > at > org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) > at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304) > at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769) > at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145) > at > org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) > at > org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:149) > at org.mozilla.javascript.Context.evaluateString(Context.java:1220) > at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:289) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:709) > at com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:266) > at java.lang.Thread.run(Thread.java:534) > Caused by: java.lang.IllegalArgumentException > at java.lang.Thread.setPriority(Thread.java:873) > at > com.gargoylesoftware.htmlunit.javascript.host.Window.jsFunction_setTimeout(Window.java:287) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:174) > ... 14 more > > Inside wrapped exception: > java.lang.IllegalArgumentException > at java.lang.Thread.setPriority(Thread.java:873) > at > com.gargoylesoftware.htmlunit.javascript.host.Window.jsFunction_setTimeout(Window.java:287) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:174) > at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:456) > at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:3026) > at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164) > at > org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) > at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304) > at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769) > at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145) > at > org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) > at > org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:149) > at org.mozilla.javascript.Context.evaluateString(Context.java:1220) > at > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:289) > at > com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:709) > at com.gargoylesoftware.htmlunit.javascript.host.Window$1.run(Window.java:266) > at java.lang.Thread.run(Thread.java:534) > == CALLING JAVASCRIPT == > GargoyleWrapper4() > ======= EXCEPTION END ======== > > The currentThread's priority falls out of the accepted range because > of the repeated execution of the above function to test if the ActiveX > object has been loaded. > > Is there anything else that I need to be doing to load the ActiveX object ? > > Any help would be greatly appreciated... > > Regards > Vinay |