Allow window.focus() to switch tabs at times when popups are allowed
Categories
(Firefox :: Tabbed Browser, defect, P2)
Tracking
()
People
(Reporter: jruderman, Assigned: emilio)
References
Details
(Keywords: regression, testcase, Whiteboard: [platform-rel-Outlook][webcompat:p1])
Attachments
(6 files)
554 bytes,
text/html
|
Details | |
645 bytes,
text/html
|
Details | |
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
|
Details | Review |
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
|
Details | Review |
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
|
Details | Review |
47 bytes,
text/x-phabricator-request
|
jcristau
:
approval-mozilla-beta+
|
Details | Review |
Comment 1•17 years ago
|
||
Reporter | ||
Comment 2•16 years ago
|
||
Comment 3•13 years ago
|
||
Comment 4•13 years ago
|
||
Comment 5•13 years ago
|
||
Comment 6•13 years ago
|
||
Updated•13 years ago
|
Comment 7•13 years ago
|
||
Comment 8•13 years ago
|
||
Comment 9•13 years ago
|
||
Comment 10•8 years ago
|
||
Comment 11•6 years ago
|
||
Comment 12•6 years ago
|
||
Comment 14•6 years ago
|
||
Comment 15•6 years ago
|
||
Updated•6 years ago
|
Comment 16•6 years ago
|
||
Updated•6 years ago
|
Comment 17•6 years ago
|
||
Updated•6 years ago
|
Comment 18•6 years ago
|
||
Comment 19•6 years ago
|
||
Updated•6 years ago
|
Comment 20•6 years ago
|
||
Comment 21•6 years ago
|
||
Comment 22•6 years ago
|
||
Comment 23•6 years ago
|
||
Comment 24•6 years ago
|
||
Any progress on a fix?
Comment 25•6 years ago
|
||
Not yet. Finishing a few other things. If someone else has cycles, feel free to take it. Otherwise, I'll try to get to it within the next 4-8 weeks.
Comment 26•6 years ago
|
||
Unassigning myself for now as I don't want to block someone else from taking it... if no one takes in time, I will come back to it.
Comment 27•6 years ago
|
||
PopupBlocking is already used and it works fine for window.focus():
The problem is elsewhere: the content process sends a request to have the window focused:
https://searchfox.org/mozilla-central/rev/00c0d068ece99717bea7475f7dc07e61f7f35984/dom/base/nsFocusManager.cpp#2168
https://searchfox.org/mozilla-central/rev/00c0d068ece99717bea7475f7dc07e61f7f35984/widget/PuppetWidget.cpp#263
https://searchfox.org/mozilla-central/rev/00c0d068ece99717bea7475f7dc07e61f7f35984/dom/ipc/TabChild.cpp#2755-2758
But, on the parent side, we stop here:
https://searchfox.org/mozilla-central/rev/00c0d068ece99717bea7475f7dc07e61f7f35984/dom/base/nsFocusManager.cpp#1126-1130
https://searchfox.org/mozilla-central/rev/00c0d068ece99717bea7475f7dc07e61f7f35984/dom/base/nsFocusManager.cpp#1462
CheckIfFocusable(Element* aElement, uint32_t aFlags) returns nullptr and we don't set the focus to the tab.
NI enndeakin, the reviewer of bug 902715 which implemented window.focus() in the content process.
Comment 28•6 years ago
|
||
When a window.focus() request is made from the child process, but the window is not frontmost, does the window get raised? That's the part the focus manager would handle.
Some other new code, probably something added to TabParent::RecvRequestFocus, needs to also inform the tabbrowser to switch tabs, before the focus occurs. Tab switching happens asynchronously though, so the focus would need to happen after that.
Updated•6 years ago
|
Comment 29•6 years ago
|
||
See bug 1547409. Migrating webcompat priority whiteboard tags to project flags.
Comment 30•6 years ago
|
||
The previous testcase didn't work because of the use of data: URLs. This test uses blob URLs instead.
Comment 31•6 years ago
|
||
I asked Emilio if he has time to take a look. The issue seems to be in layout. In my debugging I see that tabs and windows have a similar path when window.focus() is called:
BrowserParent::RecvRequestFocus
https://searchfox.org/mozilla-central/rev/94c6b5f06d2464f6780a52f32e917d25ddc30d6b/dom/ipc/BrowserParent.cpp#2122,2143
nsFocusManager::SetFocus -> nsFocusManager::SetFocusInner
https://searchfox.org/mozilla-central/rev/94c6b5f06d2464f6780a52f32e917d25ddc30d6b/dom/base/nsFocusManager.cpp#1130-1137
In here, for tabs, FlushAndCheckIfFocusable() returns null, because the element is not focusable:
https://searchfox.org/mozilla-central/rev/94c6b5f06d2464f6780a52f32e917d25ddc30d6b/layout/generic/nsFrame.cpp#9705,9712
In particular, nsIFrame::IsVisibleConsideringAncestors() return false because of this:
https://searchfox.org/mozilla-central/rev/94c6b5f06d2464f6780a52f32e917d25ddc30d6b/layout/generic/nsFrame.cpp#391,408
Moving the NI to emilio because I'm not familiar with layout code.
Comment 32•6 years ago
|
||
(In reply to Andrea Marchesini [:baku] from comment #31)
In particular, nsIFrame::IsVisibleConsideringAncestors() return false because of this:
https://searchfox.org/mozilla-central/rev/94c6b5f06d2464f6780a52f32e917d25ddc30d6b/layout/generic/nsFrame.cpp#391,408
Yes, as mentioned in comment 28, the focus is occurring but cannot because the tab content is not visible. Some code needs to be added to switch tabs in response to a window focus request.
Assignee | ||
Comment 33•6 years ago
|
||
Ah, I was thinking of just teaching stuff inside <deck>
to be shown and focus it, then the browser would have a chance to react to the focus event and fix up the tab bar.
But I guess that's a no-go if we ever want to move away from <deck>
and such, and just an async message to the browser that switches tabs should work and be a bit simpler.
WDYT Neil, is that correct? If so I'd go for firing an event at the browser element (tabfocused or such maybe?) and make the browser listen to that and react accordingly.
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 34•6 years ago
|
||
OwnerDoc() never returns null.
Assignee | ||
Comment 35•6 years ago
|
||
Depends on D31640
Assignee | ||
Comment 36•6 years ago
|
||
Depends on D31641
Assignee | ||
Comment 37•6 years ago
|
||
I think this should just work as-is, but probably a test would be on point.
Depends on D31642
Assignee | ||
Comment 38•6 years ago
|
||
I think those patches should at least work for Desktop-e10s, it's not clear to me what the setup is for Fennec or non-e10s, haven't investigated that yet.
Assignee | ||
Comment 39•6 years ago
|
||
Made it work for non-e10s as well.
Comment 40•5 years ago
|
||
Assignee | ||
Comment 41•5 years ago
|
||
Landed the first couple patches since they were just cleanups.
Comment 42•5 years ago
|
||
Comment 43•5 years ago
|
||
bugherder |
Assignee | ||
Updated•5 years ago
|
Comment 44•5 years ago
|
||
Comment 45•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 46•5 years ago
|
||
The gecko decision stuff is not related to my patch, so I put it back in the queue.
Comment 47•5 years ago
|
||
Comment 48•5 years ago
|
||
bugherder |
Comment 49•5 years ago
|
||
Would this be appropriate / small enough to uplift to 68 (which AIUI will be next esr)? As per the whiteboard, I think outlook (and probably other sites) are waiting for this fix.
Assignee | ||
Comment 50•5 years ago
|
||
Comment on attachment 9065728 [details]
Bug 416771 - Allow window.focus() to switch tabs. r=NeilDeakin
Yes, I planned to clean up a bit on top and add some automated tests for this, but these patches should be reasonably safe to uplift to 68 I'd think, specially given we're early in the cycle.
Beta/Release Uplift Approval Request
- User impact if declined: Important compat issue.
- Is this code covered by automated tests?: No
- Has the fix been verified in Nightly?: Yes
- Needs manual test from QE?: Yes
- If yes, steps to reproduce: See the test-case in comment 30.
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): It's focus code, so there's always some risk, but these patches are mostly moving code around, and disabling the behavior change in my patch is literally one line, so given we're early in the cycle I think we should try to get this into the next ESR.
- String changes made/needed: none
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Comment 51•5 years ago
|
||
Comment on attachment 9065725 [details]
Bug 416771 - Remove OwnerDoc() null-checks. r=NeilDeakin
webcompat fix, approved for 68.0b4
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 52•5 years ago
|
||
bugherder uplift |
https://hg.mozilla.org/releases/mozilla-beta/rev/37d3185821e9
https://hg.mozilla.org/releases/mozilla-beta/rev/c42e0bb77074
https://hg.mozilla.org/releases/mozilla-beta/rev/b147035a8d92
https://hg.mozilla.org/releases/mozilla-beta/rev/3cc54d1aa9d2
Comment hidden (advocacy) |
Updated•5 years ago
|
Comment 54•5 years ago
|
||
Verified as fixed on Firefox Nightly 69.0a1 (2019-05-23) and on Firefox 68.0b4 on Windows 10 x 64, Mac OS X 10.14 and on Ubuntu 18.04 x64.
Updated•5 years ago
|
Description
•