window.focus() does not update nsIWindowWatcher::activeWindow

RESOLVED WONTFIX

Status

()

Core
Widget: Gtk
RESOLVED WONTFIX
10 years ago
10 years ago

People

(Reporter: sdwilsh, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

10 years ago
Over in bug 437063, I have a browser test that focuses the main browser window to take focus away from the download manager.  I then test the visible attribute on nsIDownloadManagerUI, which tests that the ui is 1) open, and 2) the frontmost window by checking nsIWindowWatcher::activeWindow == nsIWindowMediator::getMostRecentWindow("Download:Manager").  This works, as expected on mac and windows, but does not on Linux.
(Reporter)

Updated

10 years ago
Blocks: 437063

Comment 1

10 years ago
Is the window actually frontmost in the UI and the display doesn't match what the code returns, or that the window is not actually frontmost?
(Reporter)

Comment 2

10 years ago
(In reply to comment #1)
> Is the window actually frontmost in the UI and the display doesn't match what
> the code returns, or that the window is not actually frontmost?
I was just about to post a comment about this :)

I added a throw "foo"; right after I call window.focus() in my test to stop the test from executing.  The main browser window did in fact gain focus and was the front-most window, so the API doesn't appear to return the proper window.
(Reporter)

Comment 3

10 years ago
Created attachment 325816 [details] [diff] [review]
v0.1 test

I think the issue is that window.focus is not synchronous.  This test file doesn't even pass on OS X, but it's essentially the same thing that the download manager test file does (which oddly enough, passes).  Not sure what to do at this point.

Comment 4

10 years ago
Yeah, if I'm reading the Mozilla code correctly in gtk2/nsWindow.cpp:SetFocus we just call gtk_window_present which is not synchronous.

Comment 5

10 years ago
I think probably the right thing to do in your test is to fall back to the main loop, and wait for the focus event and then do your check (or a time out, say 10 seconds).
(Reporter)

Comment 6

10 years ago
Right - looks my code in 437063 needs updating.  Thanks for looking into this.
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.