[Webtest] Re: Onblur event handler not fired

Marc Guillemot webtest@lists.canoo.com
Tue, 12 Apr 2005 09:56:31 +0200


Hi Vikram,

vikrams@mastek.com wrote:
> Hi Marc,
> 
> I have checked the source of HtmlUnit as well as Webtest. HtmlUnit have
> exposed API's to call the focus / blur event on the elements
> (FocusableElemet and FocusableHostElement). These API's are not being
> called from Webtest. Hence I am not sure whether this will be a change
> only in the HtmlUnit source.

Ups, you're right, onblur handlers should be executed as well and according to current htmlunit's state, it should be 
webtest job to set the focus before to set the value. Indeed if we change htmlunit to first set the focus while setting 
the value, it wouldn't allow anymore to bypass the focus and blur handlers and this is needed for instance in js execution.


> I tried calling the focus() just before we set the value in the text
> box. This then triggered the focus event handler for current element and
> blur event handler for the previous element.
> 
> Is this the correct way? Mind you the current JavaScript (onblur event
> handler calling focus on some other element) that I have causes HtmlUnit
> go in a recursive do while true loop.

seems correct. Blur and focus handling are not so easy, some previous versions of popular browsers had problems in this 
area as well.
Can you open a bug issue by htmlunit and provide a unit test?


> Do let me know what would be the best approach. And also the changes
> that I did to make it work are in the right direction or not.

I think that you're right and you're patches are welcome to improve both webtest and htmlunit.

Marc.