Closed Bug 254795 Opened 21 years ago Closed 21 years ago

[FIXr]When using createEvent for a link middle-click, the normal click event also seems to get fired to the link

Categories

(Core :: DOM: Events, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8alpha4

People

(Reporter: martijn.martijn, Assigned: bzbarsky)

Details

Attachments

(2 files, 1 obsolete file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a3) Gecko/20040808 Firefox/0.9.1+ Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a3) Gecko/20040808 Firefox/0.9.1+ See upcoming testcase. Clicking the button fires this function: function openintab(sType,e) { x.href='http://www.google.com'; var ev = document.createEvent("MouseEvents"); ev.initMouseEvent(sType, 0, 1, window, 1,0,0,0,0,0,0,0,0,1, x); x.dispatchEvent(ev); } And that's working nice. But when you left click on the button, not only the middle click action seems to be fired on the dummy link, but also the left click action (although it is not visible in the event listener). The result is that not only a new link has been opened in a new tab, but also the current tab gets replaced by the link location (http://www.google.com). Reproducible: Always Steps to Reproduce: 1. See testcase 2. Click button: 'open Google in new tab' 3. Actual Results: New tab appeared with 'http://www.google.com', but also this tab replaced with 'http://www.google.com' Expected Results: Only a new should appear with 'http://www.google.com'.
Attached file Testcase
Attached patch Fix (obsolete) — Splinter Review
Comment on attachment 155527 [details] [diff] [review] Fix The short story is that InitEvent() sets the message based on the even name only. That's not good enough in this case...
Attachment #155527 - Flags: superreview?(jst)
Attachment #155527 - Flags: review?(bryner)
Attachment #155527 - Flags: superreview?(jst) → superreview+
Attachment #155527 - Flags: review?(bryner) → review+
Assignee: events → bzbarsky
OS: Windows XP → All
Priority: -- → P2
Hardware: PC → All
Summary: When using createEvent for a link middle-click, the normal click event also seems to get fired to the link → [FIXr]When using createEvent for a link middle-click, the normal click event also seems to get fired to the link
Target Milestone: --- → mozilla1.8alpha4
Attached patch Updated to tipSplinter Review
Attachment #155527 - Attachment is obsolete: true
Fix checked in for 1.8a4
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: