Closed
Bug 213144
Opened 22 years ago
Closed 19 years ago
dispatchEvent for a key event stopped working since Mozilla 1.4
Categories
(Core :: DOM: Events, defect)
Tracking
()
RESOLVED
FIXED
mozilla1.7alpha
People
(Reporter: orlink, Assigned: bryner)
References
Details
Attachments
(1 file)
1.17 KB,
patch
|
bzbarsky
:
review+
bzbarsky
:
superreview+
chofmann
:
approval1.7a+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624
This code used to work with Mozilla 1.0, 1.1, 1.2, and I think under 1.3a. It
is not working anymore.
The event seems to get initialized properly, but after dispatchEvent nothing
appears.
var k=1050; // key code
e=document.createEvent("KeyEvents");
e.initKeyEvent("keypress",1,1,null,0,0,0,0,k,k);
elmnt.dispatchEvent(e);
Reproducible: Always
Steps to Reproduce:
1. Create a simple web page with a text box
2. Add a function to generate a keypress event like the code above
3. Call the function with setTimeout for example.
Actual Results:
No character appears in the text box
Expected Results:
A character should appear in the textbox.
![]() |
||
Comment 1•22 years ago
|
||
Does it work if you also send keydown and keyup events? Could you attach a
testcase?
It's not inconceivable that this is a security fix....
Reporter | ||
Comment 2•22 years ago
|
||
I am not sure about keyup and keydown. The strange thing is that an event
listener catches the dispatched event, but nothing appears.
Here is a test page:
http://www.kredor.com/keyevent/keyevent.html
Clicking on the button 'Keypress' should put a character into the text field,
but nothing appears. The event listener attached to the text field catches
the event though and its keyCode and charCode values are correct.
Thank you very much for the assistance.
![]() |
||
Comment 3•22 years ago
|
||
Yeah, this this definitely feels like a security fix.
Reporter | ||
Comment 4•22 years ago
|
||
Hi Boris,
Can you explain why it seems to be a security fix? Can it be restored to the
way it was? How? How can I find out what the cause is for sure?
If I can set the value of a field via javascript why would sending keystrokes
to it be a problem?
If it is a security fix, maybe the fix should be blocking non-printable
characters only.
![]() |
||
Comment 5•22 years ago
|
||
I'm just basing that comment on remembering some vulnerabilities associated with
key events (eg key events bubbling up to the browser toolbar, etc). It _may_ be
that one of those fixes changed the behavior here.
Reporter | ||
Comment 6•22 years ago
|
||
Hi Boris,
Are you familiar with mozilla processes? What can I do to get this bug fixed?
Thanks.
Severity: normal → major
![]() |
||
Comment 7•22 years ago
|
||
Well, the first step is to find out what changed...
It looks like the behavior changed between the 2003-03-23-05 build and
2003-03-25-05 build. The checkin that looks most suspicious in that period is
the one for bug 54035.
bryner, do events created via the DOM get dispatched to the system group?
Reporter | ||
Comment 8•22 years ago
|
||
Wow, thank you Boris!
That's significant progress! I hope Brian can shed light on this.
Updated•21 years ago
|
Flags: blocking1.6?
Comment 9•21 years ago
|
||
getting assignment straighened out. cc jst. maybe byner, jst, or callion can
make some progress on this for 1.7
Assignee: saari → bryner
Flags: blocking1.6? → blocking1.6-
Comment 10•21 years ago
|
||
I think http://bugzilla.mozilla.org/show_bug.cgi?id=178134 is dublicate of this bug.
Comment 11•21 years ago
|
||
Just wanted to comment that this bug is blocking development of a keymapping
extension that would allow users to easily define new key combinations for
browser commands.
In the SuperScroll extension for Mozilla Firebird, which allows for vi-style
directional scrolling that does not interfere with the Find As You Type search
feature, I am forced to emulate key commands (scroll / PageUp / PageDown / Home
/ End) instead of being able to simply create a new keypress event that can be
handled by the browser core or another event listener.
Flags: blocking1.7a?
Assignee | ||
Comment 13•21 years ago
|
||
This patch sends synthetic events through the system event group the same way
as user events, by mirroring the logic in PresShell::HandleEventInternal().
This would have regressed when editor was changed to use the system event group
for typing characters.
(It would be nice to have this code shared between ESM and PresShell... I'd
like to centralize event dispatch sometime which would make that sharing easy
to do).
Assignee | ||
Updated•21 years ago
|
Attachment #141475 -
Flags: superreview?(bzbarsky)
Attachment #141475 -
Flags: review?(bzbarsky)
![]() |
||
Comment 14•21 years ago
|
||
Comment on attachment 141475 [details] [diff] [review]
patch
r+sr=bzbarsky. And yes, centralizing event dispatch would be great....
especially if it makes possible dispatch of events in documents with no
presshell (eg mutation events).
Attachment #141475 -
Flags: superreview?(bzbarsky)
Attachment #141475 -
Flags: superreview+
Attachment #141475 -
Flags: review?(bzbarsky)
Attachment #141475 -
Flags: review+
Assignee | ||
Updated•21 years ago
|
Attachment #141475 -
Flags: approval1.7a?
Comment 15•21 years ago
|
||
Comment on attachment 141475 [details] [diff] [review]
patch
a=chofmann for 1.7a
Attachment #141475 -
Flags: approval1.7a? → approval1.7a+
Assignee | ||
Comment 16•21 years ago
|
||
checked in.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 17•21 years ago
|
||
(In reply to comment #16)
> checked in.
Great Job! Thanks!
Comment 18•21 years ago
|
||
(In reply to comment #2)
> Here is a test page:
> http://www.kredor.com/keyevent/keyevent.html
[Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8a1) Gecko/20040520] (release) (W98SE)
This works :-)
But, for the record,
{{
e.keyCode=90;
}}
generates
{{
Error: setting a property that has only a getter
Source File: http://www.kredor.com/keyevent/keyevent.html
Line: 17
}}
Target Milestone: --- → mozilla1.7alpha
Reporter | ||
Comment 19•19 years ago
|
||
(In reply to comment #17)
> (In reply to comment #16)
> > checked in.
>
> Great Job! Thanks!
The bug reappeared in Firefox 1.06! It behaves exactly the same as the previous
time two years ago. See the demo page in the second comment.
Thank you!
Orlin
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 20•19 years ago
|
||
The bug on regression is bug 303713.
Status: REOPENED → RESOLVED
Closed: 21 years ago → 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•