Bug 81661 - keypress event fired at <body> ends up adding text to a text field
Summary: keypress event fired at <body> ends up adding text to a text field
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-20 07:01 PDT by jochen
Modified: 2012-03-30 01:27 PDT (History)
3 users (show)

See Also:


Attachments
layout test (752 bytes, patch)
2012-03-20 07:01 PDT, jochen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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