[Webkit-unassigned] [Bug 50386] Event::fromUserGesture() should be based on Event creation

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Dec 3 11:45:54 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=50386





--- Comment #5 from Johnny(Jianning) Ding <jnd at chromium.org>  2010-12-03 11:45:53 PST ---
Hi kristianm,
Thanks for your patch. I am not a reviewer, I recently work on the gesture APIs, so I'd like to share my different point.

Yes, currently  Event is considered as a UserGesture if UserGestureIndicator::processingUserGesture() returns true when the event is handled, that is because when event is out of event handling process, it is not user gesture any more. The gesture status should not be cached when event is created.  Please take a look the following test case.

<a onclick="alert(event.type);window.open('http://www.google.com')" id="test"> open a new window </a>
<script>
function dispatchEvent(obj, evt)  { 
  return function() {
     return obj.dispatchEvent(evt);
  }
}
function simulateClick() {
  var evt = document.createEvent("MouseEvents");
  evt.initMouseEvent("click", true, true, window,
    0, 0, 0, 0, 0, false, false, false, false, 0, null);
  var cb = document.getElementById("test"); 
  setTimeout(dispatchEvent(cb, evt), 3000);
}
</script>
<input type="button" onclick="simulateClick();" value="click me" id="btn">

On this case, when clicking button "click me", the evt is created and will be delayed to dispatch 3 seconds later and trigger a popup window to www.google.com.

In original gesture implementation, when the evt is dispatched, since the original real click event is gone, UserGestureIndicator::processingUserGesture() returns false, the popup window is considered as not user-initiated, the popup blocker can block it.

Using your way, the evt was created under a gesture and kept the status in this test case. When the evt is dispatched, it is considered as a user gesture, so the popup blocker let the popup window pass.  Some sites can use the way to create lots of events in a legal user-initiated event and dispatch them in any time they want, and popup blocker can not do anything under this case.

In NavigationScheduler, since there is no chance to create event, so it's fine to cache the gesture status.

Please correct me if I misunderstand your point. 

Adam is expert in the area, he may have more thoughts.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list