Open Bug 679566 Opened 13 years ago Updated 2 years ago

javascript opens dual windows

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

9 Branch
x86
Windows XP
defect

Tracking

()

People

(Reporter: ecdowney, Assigned: smaug)

Details

(Whiteboard: TE?)

Attachments

(1 file, 4 obsolete files)

User Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0
Build ID: 20110615151330

Steps to reproduce:

went to http://www.clearskyinstitute.com/ham


Actual results:

clicked on any item in the blue menu system. the item opened in two windows. This only happens in Firefox 6. It works correctly in all older versions.


Expected results:

the item should only open in one window.
Confirmed on Mozilla/5.0 (Windows NT 5.1; rv:8.0a1) Gecko/20110816 Firefox/8.0a1 ID:20110816030741

Only 1 window opens on Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110614 Firefox/3.6.18 ID:20110614230723

Clicking on the link causes 2 windows to be opened. Clicking on the surrounding box only opens 1 window.

There is both a href with a _blank target and this function:

function tdMouseClick(theElement)
{
  eval(obj+'(theElement).click()')
}


TE?
Version: 6 Branch → 8 Branch
Still happens in 6.0.1
Boris -> If a link has both a HREF target="_blank" and an onclick event should 2 windows be opened or is this a regression? 3.6 opens 1, FF > 4 opens 2 windows.

Code in comment 1
Whiteboard: TE?
Version: 8 Branch → 9 Branch
Still happens in 6.0.2.
In general, the markup shown should in fact trigger the link twice.  It didn't use to in older versions of Gecko because we did not support click() on links.

The things that confuse me are:

1)  Why does the event click() fires not bubble back up to the cell and cause another
    recursive click()?
2)  Why is there only one window created in WebKit/Presto?

Olli, could you take a look?
Component: General → Event Handling
Product: Firefox → Core
QA Contact: general → events
(In reply to Boris Zbarsky (:bz) from comment #5)
> 1)  Why does the event click() fires not bubble back up to the cell and
> cause another
>     recursive click()?
It does propagate back up, but click() has a flag for recursion prevention.


> 2)  Why is there only one window created in WebKit/Presto?
Still investigating...
Aha, webkit doesn't have a.click(). Javascript console in Chrome tells that
"foobar" has no method click().

Opera seems to create only on click in this case, and so does IE.

The spec is wrong but need to figure out how to fix it.
Attached patch patch (obsolete) — Splinter Review
This gives us the behavior IE and Opera have.
It is a bit strange behavior though.
<a>some text <span> some text</span> some text</a> breaks the behavior, if
one clicks inside <span>.
Assignee: nobody → Olli.Pettay
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attachment #559123 - Attachment is obsolete: true
Attached patch patch (obsolete) — Splinter Review
Uploaded to tryserver. Needs tests.
Attached patch patch (obsolete) — Splinter Review
Attachment #559399 - Attachment is obsolete: true
Attached patch + some tests (obsolete) — Splinter Review
Uploaded to try.

I need to still file a spec bug.
Attachment #559401 - Attachment is obsolete: true
Attached patch special case XULSplinter Review
Seems like some XUL tests relies on the old behavior.
I'm not sure whether we should actually do this.

Posted to tryserver.
Attachment #561186 - Attachment is obsolete: true
Still happens in 7.0.

Thanks for the on going efforts.
Yes, it happens because nothing has changed.
The question is whether to change the spec (FF does what the spec says), or whether the web page
should be modified.
If you tell me the code on that page is bad, I'll accept that. But then I'd like to know why it works fine on Safari, Chrome, Opera and even Firefox prior to 5.0.
Elwood, before Firefox 5 we didn't have a "click" method on anchors, so the JS just threw an exception.

It works in Safari and Chrome because they also have no such click method; Olli said so clearly in comment 7.

Why Opera works is the open question; they're not doing what the spec says to do, but the question is _what_ they're doing.
So based on my testing both IE and Opera set some kind of internal flag to click target while
handling a click, and while that flag is set, the target can't receive other click events.
But the handling of the flag isn't the same in Opera and IE.
(Based on the spec, the flag should be set only when calling .click(), http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#dom-click)

In case like
<a href="http://www.mozilla.org" target="_blank">foo<span onclick="this.parentNode.click()">bar</span></a>
if one clicks 'bar' in IE, it opens two new windows, but Opera only one.
Ok, well I really appreciate all your efforts. I fiddled with the javascript on that page and got the problem to go away using 7.0.1. You can close this as far as I am concerned. Thanks everyone.
Component: Event Handling → User events and focus handling
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: