Bug 81661

Summary: keypress event fired at <body> ends up adding text to a text field
Product: WebKit Reporter: jochen
Component: UI EventsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: ap, ojan, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
layout test none

Description jochen 2012-03-20 07:01:37 PDT
Created attachment 132820 [details]
layout test

The attached layout tests demonstrates that a keypress event fired at body (or some other non-editable node for that matter) can end up editing another part of the node, if one of the event handlers changes the selection.

I've tested this with Chrome, and Safari, both will insert "a" into the text field. Firefox does not, IE9 does enter it.

It's not clear to me, what the expected behavior is?

See also bug 81660
Comment 1 Alexey Proskuryakov 2012-03-20 09:52:31 PDT
WebKit/IE behavior makes good sense to me.
Comment 2 jochen 2012-03-20 12:21:49 PDT
(In reply to comment #1)
> WebKit/IE behavior makes good sense to me.

what strikes me as strange is that the event target is the body element, while the text is inserted in the input field.
Comment 3 Ryosuke Niwa 2012-03-20 12:25:31 PDT
(In reply to comment #2)
> (In reply to comment #1)
> > WebKit/IE behavior makes good sense to me.
> 
> what strikes me as strange is that the event target is the body element, while the text is inserted in the input field.

But the focus is at the input element, right? The event target can't be changed once the event is dispatched, but the focus element can be changed after the fact.
Comment 4 jochen 2012-03-20 12:29:03 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > WebKit/IE behavior makes good sense to me.
> > 
> > what strikes me as strange is that the event target is the body element, while the text is inserted in the input field.
> 
> But the focus is at the input element, right? The event target can't be changed once the event is dispatched, but the focus element can be changed after the fact.

yes
Comment 5 jochen 2012-03-30 01:27:29 PDT
Closing as invalid as this seems to be working as intended