google-code-export / gwt-test-utils

Automatically exported from code.google.com/p/gwt-test-utils
1 stars 0 forks source link

Events fired twice on Composite widgets #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create myWidget extending com.google.gwt.user.client.ui.Composite
2. Write a test calling Browser.click(myWidget)
3. The event will be fired twice

What is the expected output? What do you see instead?

The event should only be fired once.

What version of the product are you using? On what operating system?

Version: gwt-test-utils-0.28.6-20110809.075218-9

Please provide any additional information below.

The reason for this behaviour is the implementation of Composite overriding 
onBrowserEvent(Event). gwt-test-utils patches the Widget type including a 
bubbling algorithm in 
com.octo.gwt.test.internal.patchers.WidgetPatcher#onBrowserEventWithBubble. 
Unfortunately, the Composite implementation fires the event on the composite as 
well as on its inner widget, so the patch leads to a double event firing 
because it walks the widget chain directly, where GWT would only walk the dom 
element chain. 

One possible fix is two-part: first, specifically handle Composites in the 
bubbling algorithm, and second, patch the Composite type to uses the same 
algorithm. (Source codes for both patchers attached).

This issue may also be related to the following GWT issue:
http://code.google.com/p/google-web-toolkit/issues/detail?id=3533

Original issue reported on code.google.com by stefan.s...@googlemail.com on 11 Aug 2011 at 1:01

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 11 Aug 2011 at 1:33

GoogleCodeExporter commented 9 years ago
Actually, patching Widget.onBrowserEvent() or Composite.onBrowserEvent() to 
inject the bubbling algorithm was wrong. 
When calling widget.onBrowserEvent(..) or DomEvent.fireNativeEvent(..) during a 
real GWT execution, events are not dispatch to  parent elements.
Bubbling is a web browser concern, so the algorithm should be coded directly in 
the Browser class.

This is what I did :-) I've also deployed new snapshots with the fix. Could you 
please give it a try and as usual, give me some feedback ?

Original comment by gael.laz...@gmail.com on 22 Aug 2011 at 6:30

GoogleCodeExporter commented 9 years ago
So I removed most of our custom patchers now. Tests run smooth and fail-free.

Thanks.

Using: gwt-test-utils-0.28.6-20110822.061452-16.jar

Original comment by stefan.s...@googlemail.com on 22 Aug 2011 at 7:36

GoogleCodeExporter commented 9 years ago
thanks :-)

Original comment by gael.laz...@gmail.com on 22 Aug 2011 at 7:47