Closed Bug 311956 Opened 18 years ago Closed 13 years ago

[Linux] window.focus() doesn't focus previous opened popup, even when allowed

Categories

(Firefox :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: malix0, Unassigned)

References

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050928 Firefox/1.0.7
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050928 Firefox/1.0.7

Under Linux when click on a link that open a popup. If the popup is already
opened, it doesn't get focus even if the window.focus() method is called. This
work on Windows.

Reproducible: Always

Steps to Reproduce:
1.Click on a link that open a new window with
w=window.open('http://www.google.com', 'Google'); w.focus();
2.A new window is open and get focus
3.Bring the main window in foregroun and click the link again.
4.The popup remain in background and doesn't get focus

Actual Results:  
The open window doesn't get focus

Expected Results:  
That the window get focus like what happen on Windows
Do you have "Allow scripts to: raise or lower windows" checked in advanced
JavaScript preferences?
I have observed this same behavior on Linux, specifically Xandros 3 (Debian
2.6.11). Neither window.focus() nor window.blur() are at all functional.
Preferences are set to enable JavaScript to raise/lower windows. 
(In reply to comment #1)
> Do you have "Allow scripts to: raise or lower windows" checked in advanced
> JavaScript preferences?

Yes, this option is enabled.
I test this under kde and Gnome and Fluxbox on a Gentoo system. I can confirm
this problem.

When did this regress? 
Flags: blocking1.8rc1?
(In reply to comment #4)
> When did this regress? 

I first noticed it when I switched from Mozilla to Firefox, at 1.0.4, I believe
it was. I actually added a comment to that effect to another, related bug report
at the time. 
(In reply to comment #4)
> When did this regress? 

I discover this bug now that I'm developing under Linux. I first notice this on
1.0.6, and I can confirm this on 1.0.7 and 1.5b1

Thanks for the quick feedback. If this was broken in 1.0.x I think it's too late
for fixing in 1.5.
Flags: blocking1.8rc1? → blocking1.8rc1-
(In reply to comment #7)
> Thanks for the quick feedback. If this was broken in 1.0.x I think it's too late
> for fixing in 1.5.

So I hope this will be fixed soon after 1.5 release. This bug is very annoing
for me. Also when I try to view javascript console clicking on web developer
toolbar, if it's open it remains in background and I need to bring it in
foreground manually. For a developer it's not very good.
Hi today I test this with Firefox 1.5b2 and The window.focus() now work. Can
some one else confirm this? I use Mozilla Firefox 1.5b2 downloaded from mozilla.org.
Resolving as WORKSFORME based on reporter's comment
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → WORKSFORME
I do not believe the reporter who's comment led to the change of status to resolved was using Linux. The problem is specific to the Linux version of Firefox and has not been resolved on Firefox for Debian 1.5.x.2-2
James, the person who created this bug report (Malix) uses Linux and no longer sees the problem, so it's likely that this report will be left as "resolved worksforme".  You can create a new bug report using https://bugzilla.mozilla.org/enter_bug.cgi.  (Please comment here giving the new bug number if you do.)
Hi all,
I switch from Gentoo to Ubuntu and I have to fight with this bug again.
But the problem is not Firefox distributed by Mozilla that work, but is relative
to Firefox packaged by Ubuntu. I noticed that Firefox that come from Mozilla
link different library then the one distributed in Ubuntu. I think the problem
in Debian distribution is the same. I post the bug with the difference between 
the library linked on launchpad https://launchpad.net/distros/ubuntu/+source/firefox/+bug/33840 but I get no answer. 
I can confirm that the bug is still here. Also on Ubuntu 6.10 (Edgy eft) with Firefox 2.0 beta. I don't understand why no one is caring about this.
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
I create a test case You can find it here http://www.massimofidanza.it/firefox . Note that this work with Mozilla.org distributed Firefox package. But doesn't work with Ubuntu and I think Gentoo packaged. I'm interested in knowing of other distribution.
I like to help fixing this bug. I need some one that help me to set a right breakpoint in the firefox code, so I can debug the code and post the result.

Thanks to everyone that will help.
(In reply to comment #16)
> I like to help fixing this bug. I need some one that help me to set a right
> breakpoint in the firefox code, so I can debug the code and post the result.
> 
> Thanks to everyone that will help.
> 

By default firefox 2.0 final will not raise popup windows on subsequent clicks. You must check raise and lower windows in perferences. This is a feature to make unwanted popups less annoying i assume. Seems mozilla is turning into MS, thinking it knows best and changes browser behavior thus breaking pages, forcing devlopers that work on legit sites to recode or change settings on every single browser at my company. Can you guys make this setting to raise and lower popups as default. Theres already a popup blocker in firefox. Dont see any good reason for the non-feature.
Andy, your comment is off-topic for this bug but I'll respond anyway.

The pref is intended to do exactly what it says -- prevent sites from raising themselves and making pop-under windows.  Both are quite common annoyances.  Bug 355482 covers unbreaking sites that use window.focus() to re-focus a legitimate pop-up.
Malix, note that the default for the "Allow scripts to: raise or lower windows" pref (now in the Content panel of Preferences) has changed in Firefox 2.  You might just need to re-check it or wait for bug 355482 to be fixed.
I can confirm the bug on windows and on linux either!
you cannot get the focus again when another windows was open.
This is definitely one annoying way of default focus() handling.

And why is this marked as UNCONFIRMED is beyond me?

Using FF 2.0 on XP pro.

Could not understand why this focus() did not work in my new and old webapplication (I could bet this was working in some earlier FF version by default).

You FF developers are doing really great. My favourite browser it is.

But it is a real bummer to:

Not make it backward compatible by default.
   "Raise or lower windows" should definitely be checked by default when 
   you install FF.

For this one I think it should also be added that it would probably be a good idea to show a warning in the current window that the application tried to set focus but failed. And then a click on a button should then bring the child window (or whatever) in focus (to make it more intuitive for the end-users that is).
Is it not possible to check wether the child window actually was tried focused because the end-user clicked somewhere, and because the end-user clicked somewhere then the focus() should automagically work.


I can just imagine all the frustrasion on the developers with old apps not working (by default) anymore.

Not to forget all the irritated end-users that suddenly find that something is not working anymore.

Please fix this ASAP and set
"Raise or lower windows" to checked for new installations.

I really hope some developer fixes this. It should not be that hard.

And for those that say that popup windows are horrible.
Well that depends what kind of popup you are talking about.
If you are working with a web-application as an enduser and let say want to pick a date for a form-field, then I would say that it greatly enhances the web-application if popups are used, and it definitely makes the life a lot easier for the enduser and the developer if it is possible to set focus to that child window after window.open, especially important when the enduser select another window after opening the popup, and then click on the button or whatever that triggers the popup.... if the focus() are not used the second time then the enduser will very likely produce a few "words" to the developer of the app.
One fact remains though, this feature ( focus() ) is in use on many sites.

I can think of one zillion cases like the one above......
So IMHO this is important to get right.

Any developer care to take this?
Tore, you're looking for bug 355482 (which is fixed in Firefox 2.0.0.1) or something related to it, not this bug.  This is a platform-specific bug and does not involve whether/when sites are "allowed" to use window.focus().
Summary: window.focus() doesn't focus previous opened popup → [Linux] window.focus() doesn't focus previous opened popup, even when allowed
I will strongly CONFIRM this bug that prevents from focusing windows in Firefox (Iceweasel) 2.0.0.1 on Debian Etch. The package is installed from Debian Etch.

This bug almost made me crazy some two years ago and I tried to forget it to preserve my health. I have not followed this thread and I am glad to see that it has got SOME attention. 

I just want to add that I regularly update my system including Firefox but have NOT SEEN ANY CHANGE as regards this problem. Now I use 2.0.0.1 and the dreadful behavior is always the same: window.focus() does NEVER WORK, at least not for me. Apologies.

P.S. I have "Allow scripts to: raise or lower windows" checked in advanced
JavaScript preferences.
I can confirm this issue on Ubuntu Feisty Fawn. It also appears with the Mozilla upstream tarball, so it is no issue of distribution packaging.
now fixed on firefox 2.0 on windows plateform
Maybe the bug is specific to certain Debian-based systems? Actually, I have the same behavior with Opera 9.01 which indicates some interaction with my Debian Etch (but the bug is older than Etch, though). 

Is there any Debian system that behaves correctly in this respect when other browsers are used than the distribution-default browser (for example, Konqueror)?

(Btw, I have never ever seen this bug with any browser on any Windows system!)
No, I also have never seen this bug on a Windows system.

The same bug appears on OpenSuSE 10.2, it may be possible that it is something GTK or Metacity related. It would be interesting how firefox's behavior is running it on KDE or running Opera on KDE.
KDE, yes:

I use FF Debian packaged and Opera outside packaged, both in KDE Debian packaged. Nothing else extra, all standard stuff.
The Debian packaged version of Firefox aka Iceweasel has the same problem. You cannot reuse a once opened window and have focus passed onto it. A code to show this is available here: http://developer.mozilla.org/en/docs/window.open#Examples (openPromoteFFWindow with a reference to window object)
Although it has been mentioned in other threads inspired by this issue, I didn't notice it here: the problem does not appear in Seamonkey, nor did it exist in Mozilla suites concurrent with Firefox versions which exhibit it. 
I definitely CONFIRM this on Windows XP, on MAC and on Windows Vista.
I am working in firefox 3.5.5 on win XP. I have some problems with focusing to a textbox after validating the field for a valid email address
Is anyone seeing window.focus ever fail on Linux these days? (Wondering if this is causing bug 525175)
The page which first brought this to my attention appears to work properly since 3.0.
works properly on Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.6) Gecko/20100107 Fedora/3.5.6-1.fc12 Firefox/3.5.6
I believe the bug only affected Debian variants.
Closing WFM based on comments. I suspect this could be a Linux window manager issue; please reopen and report distro and window manager info if it recurs.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago13 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.