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.
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?
(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.
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.
Yeah, if I'm reading the Mozilla code correctly in gtk2/nsWindow.cpp:SetFocus we just call gtk_window_present which is not synchronous.
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).
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.