osdir.com
mailing list archive

Subject: [HtmlUnit] [ htmlunit-Bugs-1531821 ] 302 response's Location is not being followed - msg#00048

List: java.htmlunit.devel

Date: Prev Next Index Thread: Prev Next Index
Bugs item #1531821, was opened at 2006-07-31 10:42
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1531821&group_id=47038

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: 1.8
Status: Open
Resolution: None
Priority: 5
Submitted By: craig (craig_copeland)
Assigned to: Nobody/Anonymous (nobody)
Summary: 302 response's Location is not being followed

Initial Comment:
HtmlUnit is not following the 302 response in
particular situations. This seems to be exactly what
davidmhill was trying to describe in bug:
https://sourceforge.net/tracker/index.php?func=detail&aid=1359254&group_id=47038&atid=448267
1. Looking at the HTTP headers in AID 1359254, you see
a POST to URL x, and a 302 response with Location x.
2. There may also be a strict enforcement of RFC 2068
that is superceding a relevant Note in RFC 2616.
Please, see the email below for more info on this.

In the meantime I will attempt to find a simple
reproduction scenario if needed. Please contact me if
this is needed.

-----------
Hi Craig,

perhaps could you open an issue / add this comment to
an existing one by htmlunit?

Marc Guillemot.

Craig Copeland wrote:
> Marc,
>
> I think this issue is likely two fold.
> 1. The Location returned in the 302 is identical to
> the original submitted. This could potentially cause
> an inifite loop. The user-agent could allow for a
> finite number of redirects to the same location.
> The software I'm testing uses other fields to know
> if a 302 should be issued after a POST, which would
> keep the infinite loop from occurring.
> 2. It could also be that since HtmlUnit is a very
> strict user-agent implementation, that section
> 10.3.3 of RFC 2616 (concerning 302 responses) is
> being enforced in respect to how to treat a 302
> redirect if the inital method was POST instead of
> GET (or HEAD). However, looking at the full context
> of RFC 2616,
> www.w3.org/Protocols/rfc2616/rfc2616-sec10.html,
> it says:
> If the 302 status code is received in response to
> a request other than GET or HEAD, the user agent
> MUST NOT automatically redirect the request unless
> it can be confirmed by the user, since this might
> change the conditions under which the request was
> issued.
> Note: RFC 1945 and RFC 2068 specify that the
> client is not allowed to change the method on
> the redirected request. However, most
> existing user agent implementations treat 302
> as if it were a 303 response, performing a
> GET on the Location field-value regardless
> of the original request method. The status
> codes 303 and 307 have been added for servers
> that wish to make unambiguously clear which
> kind of reaction is expected of the client.
>
> HtmlUnit may be strictly enforcing 1945 & 2068, and
> disregarding the Note above.
>
> Again, thanks!
> Craig

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1531821&group_id=47038

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: [HtmlUnit] Any roadmap to implement org.w3c.dom.html within htmlunit?

Hi Alessio, I fear too that it would involve changes on a lot of files. Perhaps is it possible to split it down: first implement org.w3c.dom.* and then org.w3c.dom.html.*. A "small" start job could be start use org.w3c.dom.Attr. Marc. Alessio Pace wrote: > Hi again, > > sorry for the late answer I was kinda busy :( > > Anyway, I gave a look some days ago to org.w3c.dom.html, and it is not a > straight 1:1 thing to make htmlunit types implement those interfaces, > but we can try :-) > > I can try to contribute somehow in the free time, I was wondering which > is the best way to proceed, since it could be a long and big code base > change.. > > Regards, > -- > Alessio Pace. > http://www.jroller.com/page/alessiopace > > On 7/21/06, *Marc Guillemot* <mguillemot@xxxxxxxx > <mailto:mguillemot@xxxxxxxx>> wrote: > > Hi Alessio, > > there is no roadmap, only best use of available time. > > I still think that it would be good to implement org.w3c.dom.html but > this isn't very high on my priority list currently. Nevertheless maybe > someone else (you?) will work on it. > > Marc. > > Alessio Pace wrote: > > Hi, > > > > I was wondering if there is a plan to implement org.w3c.dom.html > > interfaces within HtmlUnit (I remember on the mailing list something > > about a migration to org.w3c.dom for htmlunit-2.x or later). > > > > Best regards, > > > > -- > > Alessio Pace. > > http://www.jroller.com/page/alessiopace > > > > > > > ------------------------------------------------------------------------ > > > > > > > ------------------------------------------------------------------------- > > > Using Tomcat but need to do more? Need to support web services, > security? > > Get stuff done quickly with pre-integrated technology to make > your job easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642> > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > HtmlUnit-develop mailing list > > HtmlUnit-develop@xxxxxxxxxxxxxxxxxxxxx > <mailto:HtmlUnit-develop@xxxxxxxxxxxxxxxxxxxxx> > > https://lists.sourceforge.net/lists/listinfo/htmlunit-develop > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV> > _______________________________________________ > HtmlUnit-develop mailing list > HtmlUnit-develop@xxxxxxxxxxxxxxxxxxxxx > <mailto:HtmlUnit-develop@xxxxxxxxxxxxxxxxxxxxx> > https://lists.sourceforge.net/lists/listinfo/htmlunit-develop > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > ------------------------------------------------------------------------ > > _______________________________________________ > HtmlUnit-develop mailing list > HtmlUnit-develop@xxxxxxxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/htmlunit-develop ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Next Message by Date: click to view message preview

[HtmlUnit] [ htmlunit-Bugs-1531928 ] Comparison of document.links to "undefined" fails.

Bugs item #1531928, was opened at 2006-07-31 11:59 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1531928&group_id=47038 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Latest code in CVS Status: Open Resolution: None Priority: 5 Submitted By: koo (kooroshv) Assigned to: Nobody/Anonymous (nobody) Summary: Comparison of document.links to "undefined" fails. Initial Comment: Running following HTML code throught HTLMUNIT version 1.9 cases failure: ========================================== <html> <head> <title>TEST PAGE</title> <script language="JavaScript"> _undef="undefined"; function LEN(a) { return a!=_undef?a.length:0 // type = typeof a; // return type!=_undef?a.length:0 } function BADCALL(a) { a=document; len=LEN(a.links); } function EVENT(a,b,c) { if (a.addEventListener) { a.addEventListener(b,c,false) } else if (a.attachEvent) { a.attachEvent("on"+b,c) } } EVENT(window,"load",BADCALL); </script> <body> <a href="/goto1">Link1</a> <a href="/goto2">Link2</a> </body> </html> ======================================= Here is the explanation that Marc gave on why HTMLUnit is failing: ================================== Hi Koorosh, I've found the cause of the problem (but not yet the fix ;-() Your script causes a String conversion of document.links to compare with "undefined" and this is what fails. More exactly both: document.links != "undefined" and document.links.toString() If you can modify your html/js code, you should change _undef="undefined"; to _undef = undefined; First this would be more correct (undefined is an Object in js) and your script would compare objects rather than strings (what would be faster) AND current htmlunit version would work correctly with it! Marc. ========================================== Here is the exception stack trace coming out of WebTest an application that uses HTMLUNIT framework. [invoke] ======= EXCEPTION START ======== [invoke] Exception class=[org.mozilla.javascript.EvaluatorException] [invoke] com.gargoylesoftware.htmlunit.ScriptException: Zero arguments; need an index or a key. (Embedded script in http://localhost/test.html#4) [invoke] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:307) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:737) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.runEventHandler(HtmlPage.java:1463) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeOnLoadHandlersIfNeeded(HtmlPage.java:964) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:145) [invoke] at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:440) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389) [invoke] at com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.java:69) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTargetAction.java:68) [invoke] at com.canoo.webtest.steps.request.InvokePage.findTarget(InvokePage.java:134) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAction.java:108) [invoke] at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:88) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTargetAction.java:106) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTargetAction.java:78) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:130) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:58) [invoke] at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:39) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:130) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:152) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [invoke] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [invoke] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.Main.runBuild(Main.java:668) [invoke] at org.apache.tools.ant.Main.startAnt(Main.java:187) [invoke] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) [invoke] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) [invoke] Caused by: org.mozilla.javascript.EvaluatorException: Zero arguments; need an index or a key. (Embedded script in http://localhost/test.html#4) [invoke] at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:114) [invoke] at org.mozilla.javascript.Context.reportRuntimeError(Context.java:966) [invoke] at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1022) [invoke] at com.gargoylesoftware.htmlunit.javascript.ElementArray.call(ElementArray.java:133) [invoke] at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:577) [invoke] at com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.getDefaultValue(SimpleScriptable.java:508) [invoke] at org.mozilla.javascript.ScriptRuntime.toPrimitive(ScriptRuntime.java:2438) [invoke] at org.mozilla.javascript.ScriptRuntime.eqString(ScriptRuntime.java:2566) [invoke] at org.mozilla.javascript.ScriptRuntime.eq(ScriptRuntime.java:2511) [invoke] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2561) [invoke] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250) [invoke] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149) [invoke] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337) [invoke] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755) [invoke] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:147) [invoke] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:302) [invoke] ... 50 more [invoke] Enclosed exception: [invoke] org.mozilla.javascript.EvaluatorException: Zero arguments; need an index or a key. (Embedded script in http://localhost/test.html#4) [invoke] at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:114) [invoke] at org.mozilla.javascript.Context.reportRuntimeError(Context.java:966) [invoke] at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1022) [invoke] at com.gargoylesoftware.htmlunit.javascript.ElementArray.call(ElementArray.java:133) [invoke] at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:577) [invoke] at com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.getDefaultValue(SimpleScriptable.java:508) [invoke] at org.mozilla.javascript.ScriptRuntime.toPrimitive(ScriptRuntime.java:2438) [invoke] at org.mozilla.javascript.ScriptRuntime.eqString(ScriptRuntime.java:2566) [invoke] at org.mozilla.javascript.ScriptRuntime.eq(ScriptRuntime.java:2511) [invoke] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2561) [invoke] at script.LEN(Embedded script in http://localhost/test.html:4) [invoke] at script.BADCALL(Embedded script in http://localhost/test.html:11) [invoke] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250) [invoke] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149) [invoke] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337) [invoke] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755) [invoke] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:147) [invoke] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:302) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:737) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.runEventHandler(HtmlPage.java:1463) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeOnLoadHandlersIfNeeded(HtmlPage.java:964) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:145) [invoke] at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:440) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389) [invoke] at com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.java:69) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTargetAction.java:68) [invoke] at com.canoo.webtest.steps.request.InvokePage.findTarget(InvokePage.java:134) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAction.java:108) [invoke] at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:88) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTargetAction.java:106) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTargetAction.java:78) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:130) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:58) [invoke] at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:39) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:130) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:152) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [invoke] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [invoke] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.Main.runBuild(Main.java:668) [invoke] at org.apache.tools.ant.Main.startAnt(Main.java:187) [invoke] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) [invoke] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) [invoke] == CALLING JAVASCRIPT == [invoke] function BADCALL(a) { [invoke] a = document; [invoke] len = LEN(a.links); [invoke] } [invoke] ======= EXCEPTION END ======== ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1531928&group_id=47038 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Previous Message by Thread: click to view message preview

[HtmlUnit] htmlunit--possible new feature

Hello, my name is Jef. I'm new to this mailing list and I don't know how things work around here so go easy on me. :] I have a ~35,000-loc web test project using HtmlUnit and have written a simple framework in addition to HtmlUnit to make testing easier. One of the framework's components is a system of conditions that HtmlElements either satisfy or don't satisfy. There are many types of conditions and they can be combined using standard logic operations to form very complex conditions. For example, you could find a table with class "specialTable" that is inside a div with id "leftPane" that doesn't contain text matching regular expression "\w+ settings" or text "setup". The conditions can find HtmlElements that match them in a variety of ways. This framework is used in ~90% of my tests and is extremely useful, especially for complex sites where not everything is labeled. I'm wondering if you would be interested in a patch to incorporate this framework into HtmlUnit. The code consists of 18 classes and is very well documented and clean. I can send you the base class of the framework along with javadoc if you want. Thanks. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Next Message by Thread: click to view message preview

[HtmlUnit] [ htmlunit-Bugs-1531928 ] Comparison of document.links to "undefined" fails.

Bugs item #1531928, was opened at 2006-07-31 11:59 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1531928&group_id=47038 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Latest code in CVS Status: Open Resolution: None Priority: 5 Submitted By: koo (kooroshv) Assigned to: Nobody/Anonymous (nobody) Summary: Comparison of document.links to "undefined" fails. Initial Comment: Running following HTML code throught HTLMUNIT version 1.9 cases failure: ========================================== <html> <head> <title>TEST PAGE</title> <script language="JavaScript"> _undef="undefined"; function LEN(a) { return a!=_undef?a.length:0 // type = typeof a; // return type!=_undef?a.length:0 } function BADCALL(a) { a=document; len=LEN(a.links); } function EVENT(a,b,c) { if (a.addEventListener) { a.addEventListener(b,c,false) } else if (a.attachEvent) { a.attachEvent("on"+b,c) } } EVENT(window,"load",BADCALL); </script> <body> <a href="/goto1">Link1</a> <a href="/goto2">Link2</a> </body> </html> ======================================= Here is the explanation that Marc gave on why HTMLUnit is failing: ================================== Hi Koorosh, I've found the cause of the problem (but not yet the fix ;-() Your script causes a String conversion of document.links to compare with "undefined" and this is what fails. More exactly both: document.links != "undefined" and document.links.toString() If you can modify your html/js code, you should change _undef="undefined"; to _undef = undefined; First this would be more correct (undefined is an Object in js) and your script would compare objects rather than strings (what would be faster) AND current htmlunit version would work correctly with it! Marc. ========================================== Here is the exception stack trace coming out of WebTest an application that uses HTMLUNIT framework. [invoke] ======= EXCEPTION START ======== [invoke] Exception class=[org.mozilla.javascript.EvaluatorException] [invoke] com.gargoylesoftware.htmlunit.ScriptException: Zero arguments; need an index or a key. (Embedded script in http://localhost/test.html#4) [invoke] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:307) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:737) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.runEventHandler(HtmlPage.java:1463) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeOnLoadHandlersIfNeeded(HtmlPage.java:964) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:145) [invoke] at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:440) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389) [invoke] at com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.java:69) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTargetAction.java:68) [invoke] at com.canoo.webtest.steps.request.InvokePage.findTarget(InvokePage.java:134) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAction.java:108) [invoke] at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:88) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTargetAction.java:106) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTargetAction.java:78) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:130) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:58) [invoke] at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:39) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:130) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:152) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [invoke] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [invoke] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.Main.runBuild(Main.java:668) [invoke] at org.apache.tools.ant.Main.startAnt(Main.java:187) [invoke] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) [invoke] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) [invoke] Caused by: org.mozilla.javascript.EvaluatorException: Zero arguments; need an index or a key. (Embedded script in http://localhost/test.html#4) [invoke] at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:114) [invoke] at org.mozilla.javascript.Context.reportRuntimeError(Context.java:966) [invoke] at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1022) [invoke] at com.gargoylesoftware.htmlunit.javascript.ElementArray.call(ElementArray.java:133) [invoke] at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:577) [invoke] at com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.getDefaultValue(SimpleScriptable.java:508) [invoke] at org.mozilla.javascript.ScriptRuntime.toPrimitive(ScriptRuntime.java:2438) [invoke] at org.mozilla.javascript.ScriptRuntime.eqString(ScriptRuntime.java:2566) [invoke] at org.mozilla.javascript.ScriptRuntime.eq(ScriptRuntime.java:2511) [invoke] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2561) [invoke] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250) [invoke] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149) [invoke] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337) [invoke] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755) [invoke] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:147) [invoke] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:302) [invoke] ... 50 more [invoke] Enclosed exception: [invoke] org.mozilla.javascript.EvaluatorException: Zero arguments; need an index or a key. (Embedded script in http://localhost/test.html#4) [invoke] at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:114) [invoke] at org.mozilla.javascript.Context.reportRuntimeError(Context.java:966) [invoke] at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1022) [invoke] at com.gargoylesoftware.htmlunit.javascript.ElementArray.call(ElementArray.java:133) [invoke] at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:577) [invoke] at com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.getDefaultValue(SimpleScriptable.java:508) [invoke] at org.mozilla.javascript.ScriptRuntime.toPrimitive(ScriptRuntime.java:2438) [invoke] at org.mozilla.javascript.ScriptRuntime.eqString(ScriptRuntime.java:2566) [invoke] at org.mozilla.javascript.ScriptRuntime.eq(ScriptRuntime.java:2511) [invoke] at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2561) [invoke] at script.LEN(Embedded script in http://localhost/test.html:4) [invoke] at script.BADCALL(Embedded script in http://localhost/test.html:11) [invoke] at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250) [invoke] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149) [invoke] at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337) [invoke] at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755) [invoke] at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:147) [invoke] at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:302) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:737) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.runEventHandler(HtmlPage.java:1463) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.executeOnLoadHandlersIfNeeded(HtmlPage.java:964) [invoke] at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:145) [invoke] at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:440) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:335) [invoke] at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:389) [invoke] at com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.java:69) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTargetAction.java:68) [invoke] at com.canoo.webtest.steps.request.InvokePage.findTarget(InvokePage.java:134) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAction.java:108) [invoke] at com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:88) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTargetAction.java:106) [invoke] at com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTargetAction.java:78) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:130) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:58) [invoke] at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:39) [invoke] at com.canoo.webtest.steps.Step.execute(Step.java:130) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:152) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382) [invoke] at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107) [invoke] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [invoke] at org.apache.tools.ant.Task.perform(Task.java:364) [invoke] at org.apache.tools.ant.Target.execute(Target.java:341) [invoke] at org.apache.tools.ant.Target.performTasks(Target.java:369) [invoke] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) [invoke] at org.apache.tools.ant.Project.executeTarget(Project.java:1185) [invoke] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) [invoke] at org.apache.tools.ant.Project.executeTargets(Project.java:1068) [invoke] at org.apache.tools.ant.Main.runBuild(Main.java:668) [invoke] at org.apache.tools.ant.Main.startAnt(Main.java:187) [invoke] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246) [invoke] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67) [invoke] == CALLING JAVASCRIPT == [invoke] function BADCALL(a) { [invoke] a = document; [invoke] len = LEN(a.links); [invoke] } [invoke] ======= EXCEPTION END ======== ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1531928&group_id=47038 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by