Closed Bug 296581 Opened 20 years ago Closed 20 years ago

dispatchEvent prevents default (can't access to core event listener)

Categories

(Core :: DOM: Events, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: math.parent, Unassigned)

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050603 Firefox/1.0+
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050603 Firefox/1.0+

Using

  var eventToSend = document.createEvent("Events");
  eventToSend.initEvent('focus', true, true);
  someInput.dispatchEvent(eventToSend);

doesn't focus the input field


it is the same with all events (mousedown/up/move,click,...)

according to http://www.w3.org/TR/DOM-Level-2-Events/ , we should probably use
DOMFocusIn event, but i can't get it worked


Also, make sure this is safe against spoofing or whatever (maybe enable just for
xul)

this can be very usefull for automation (click here, then drag and drop this
here, ...)

Reproducible: Always

Steps to Reproduce:
1.Go to test case
2. Click 'focus using dispatchEvent()'

Actual Results:  
Nothing happen

Expected Results:  
Should focus the input field (like 'focus using focus()' does)

Can be really usefull to fix
Bug 288194 XUL <textbox> is too hard to focus
Attached file testcase
Keywords: testcase
This seems invalid to me. The 'focus' event doesn't focus an element, it is
fired after the element is focused.
according to w3c spec:
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget-dispatchEvent
''
dispatchEvent
   Return Value
    (boolean) The return value of dispatchEvent indicates whether any of the
listeners which handled the event called preventDefault. If preventDefault was
called the value is false, else the value is true.
''

the specification is not very clear.

But as dispatchEvent returns the preventDefault information, it means that the
default behavior is not a listener.

i agree, it is invalid

but is there any way to raise events, different from focus() and click(), like
mousemove, mouseup, drag_ ... ?

I'll fill a new bug about automation ...
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: