Bug 9215

Summary: test case with click handler that calls click() loops forever in WebKit, but not in Firefox
Product: WebKit Reporter: Sornalatha Rathnasamy <sornalatha.rathnasamy>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED WORKSFORME    
Severity: Normal CC: ian
Priority: P2    
Version: 420+   
Hardware: PC   
OS: OS X 10.4   
Attachments:
Description Flags
test case
none
patch for fixing the bug
none
patch for fixing the bug darin: review-

Description Sornalatha Rathnasamy 2006-06-01 13:04:56 PDT
it goes to a infinite loop if the event is a bubble_event and
while bubbling if one of the ancestor node calls the same event on the target node which originated the event
suggestion for fixing is that don't call the event :
1) if the event phase is BUBBLING_PHASE
2) and if the current event's target element(the originator of the event) is the same as the node on which the event is going to be invoked
3) and if the event types(id such as click,focus etc) of the above two nodes are same.

Please suggest any drawbacks to this fix or if there is a better fix.
The test page is:
<html>
<head/>
<body>
<form>
<div onclick="JavaScript:alert('div element');JavaScript:document.getElementById('segment116985839').click();">
<input name="segment1" id="segment116985839" value="test" type="radio" onclick="javascript:alert('input element');">
</div>
</input>
</form>
</body>
</html>
Comment 1 Sornalatha Rathnasamy 2006-06-01 13:06:16 PDT
Created attachment 8650 [details]
test case
Comment 2 Sornalatha Rathnasamy 2006-06-20 13:30:17 PDT
Created attachment 8935 [details]
patch for fixing the bug
Comment 3 Sornalatha Rathnasamy 2006-06-20 13:32:37 PDT
Created attachment 8936 [details]
patch for fixing the bug
Comment 4 Darin Adler 2006-06-22 12:39:34 PDT
Comment on attachment 8935 [details]
patch for fixing the bug

Duplicate copy of patch. Removing it.
Comment 5 Darin Adler 2006-06-22 12:44:00 PDT
Comment on attachment 8936 [details]
patch for fixing the bug

This patch won't work, because it's got DOM:: and Undefined() in it. Those are long-renaemed things that don't exist in our current tip of tree.

It's also not formatted based on the style guildlines.

In addition, I don't think this fix is correct. It checks for one of the many different ways an infiite loop could happen, and it could prevent legitimate code that loops once from working. There are all sorts of other similar infinite loops that this code change would not prevent, for example, one involving two different events that each dispatched the other.

What we need to diagnose this is a test page that works in other browsers and fails in WebKit so we can figure out what behavior is wrong. I'm absolutely certain this isn't it.

Infinite loops can happen, and the way to handle that is to allow you to interrupt the script.
Comment 6 Darin Adler 2006-06-22 12:47:14 PDT
We should figure out what's different that prevents this from being an infinite loop in Firefox.

It's possible that the click() function in Firefox is a no op if you're already inside another invocation of click(), which could explain why Firefox goes through the loop twice, but not more than twice.
Comment 7 Mark Rowe (bdash) 2007-09-30 22:11:05 PDT
This appears to work correctly in r25813.