Menu

#425 window.event.srcElement not working for onsubmit

closed
None
5
2014-12-30
2007-01-30
No

There is a Problem on Canoo Webtest using Htmlunit.
The JavaScript-function: onsubmit causes an error.

(Marc Guillemot: onsubmit was one of the first supported events in htmlunit and has not been refactored to use common facilities that set the event object correctly depending of the browsers).

Im using Cannoo Webtest build on svn-sources.

Canoo Webtest - Error-Messages:

 [java]      [java] [clickButton]  INFO (com.canoo.webtest.steps.Step) - Message was: Step[clickButton "save contractor" (16/71)]: Script error loading page execut

ing webtest at: clickButton TypeError: Cannot read property "srcElement" from undefined (http://bendera:8888/adds/convertCurlyQuotes.js#29)
[java] [java] [clickButton] Source code:

 [java]      [java] [clickButton]   function windowEvent(event) {
 [java]      [java] [clickButton]       var elmForm = getTarget(event);
 [java]      [java] [clickButton]       var arTextareas = elmForm.getElementsByTagName("textarea");
 [java]      [java] [clickButton]       for (var i = arTextareas.length - 1; i >= 0; i--) {
 [java]      [java] [clickButton]           var elmTextarea = arTextareas[i];
 [java]      [java] [clickButton]           elmTextarea.value = filterChars(elmTextarea.value);
 [java]      [java] [clickButton]       }
 [java]      [java] [clickButton]   }

the relevant JS-function is:
function getTarget(evt) {
if(evt.srcElement)
return evt.srcElement;
else
return evt.target;
}

I attached the JavaScript source-file.

I hope - this was my first bugtracker entry for htmlunit - my description is helpfull and contains all the information you need to help.
mfg
Michael Habbert

Discussion

  • Michael Habbert

    Michael Habbert - 2007-01-30

    The JavaScript-File causing the Error.

     
  • Marc Guillemot

    Marc Guillemot - 2007-01-30

    Logged In: YES
    user_id=402164
    Originator: NO

    Should now be fixed in SVN.

    Note: I couldn't test the code with IE but just with FF as I've currently only a Linux system but I'm confident as the onsubmit handling now just reuse what other handlers use.

     

Log in to post a comment.