Bug 61123 - DOMActivateEvent should be one of event sources of user gesture
Summary: DOMActivateEvent should be one of event sources of user gesture
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-19 06:35 PDT by Johnny(Jianning) Ding
Modified: 2011-05-19 07:15 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johnny(Jianning) Ding 2011-05-19 06:35:20 PDT
In current ScriptController::processingUserGesture implementation, it returns false if current event type is DOMActivateEvent (even UserGestureIndicator::getUserGestureState is DefinitelyProcessingUserGesture). It's because Event::fromUserGesture does not accept DOMActivateEvent as event sources of user gesture. It is wrong because

1. DOMActivateEvent is generate by clickEvent, see Node.cpp:2925
2. Some elements' click handler can only be called via DOMActivateEvent. like <input type=file>, it's because the input-file control's UI actually is a shadow input-button, which's click handler is not to open file dialog, the file dialog will be opened by calling FileInputType::handleDOMActivateEvent (see HTMLInputElement.cpp:1091-1092), which calls RenderFileUploadControl::click.   If ScriptController::processingUserGesture returns false when event is DOMActivateEvent in RenderFileUploadControl::click, no file dialog will be opened. This situation now is only happened in LayoutTest mode because in normal mode, there is no JavaScript stack, so ScriptController::processingUserGesture always returns true.(See ScriptController.cpp 252).

The following test case is to prove my analysis. Running it with patch in bug 55110, no file dialog will be opened when running openFileDialog(true), If you want to pass it, the temporary way is to add "onclick=this.click()" in <input type="file" name="file" id="f">

 see the following testcase
<head>
<script>
if (window.layoutTestController) {
    layoutTestController.dumpAsText();
    layoutTestController.setCanOpenWindows();
    layoutTestController.waitUntilDone();
}

function openFileDialog(withUserGesture) {
    window.console.log("Open the file dialog " + (withUserGesture ? "with" : "without") + " a user gesture.");
    if (withUserGesture) {
        eventSender.mouseMoveTo(10, 10);
        eventSender.mouseDown();
        eventSender.mouseUp();
    } else {
        document.getElementById('f').click();
    }
}

function startTest() {
    if (!window.layoutTestController)
        return;
    openFileDialog(false);
    openFileDialog(true);
    layoutTestController.notifyDone();
}
</script>
</head>
<body style="margin:0px; padding:0px" onload="startTest();">
<form>
<input type="file" name="file" id="f">
</form>
Comment 1 Johnny(Jianning) Ding 2011-05-19 07:15:41 PDT
(In reply to comment #0)

> 2. Some elements' click handler can only be called via DOMActivateEvent. 
My previous analysis was wrong. Close this bug. Sorry