Closed Bug 1613054 Opened 5 years ago Closed 4 years ago

Figure out what to do if SetFocus ends up being called for an iframe element hosting an out-of-process iframe

Categories

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

task
Not set
normal

Tracking

()

RESOLVED FIXED
82 Branch
Fission Milestone M6b
Tracking Status
firefox82 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

The patch for bug 1556627 doesn't deal with this case. Figure out if more work is needed here.

Tracking for Fission Nightly (M6)

Fission Milestone: --- → M6

As seen in bug 1580618, we need a call to .focus() on an OOP iframe synchronously make the iframe element the focused element of the DOM inner window that the element is in. Then, we can have the process hosting the iframe content do its focus setting asynchronously.

This start going wrong when elementToFocus is set to nullptr in SetFocusInner, because the focus-taking element inside the iframe is not in the current process.

Assignee: nobody → hsivonen
Status: NEW → ASSIGNED

My attempt to eagerly set the iframe as the focused element fails, because it's composed doc doesn't match the expected doc at
https://searchfox.org/mozilla-central/rev/4d2a9d5dc8f0e65807ee66e2b04c64596c643b7a/dom/base/nsGlobalWindowInner.cpp#4079
and
https://searchfox.org/mozilla-central/rev/4d2a9d5dc8f0e65807ee66e2b04c64596c643b7a/dom/base/nsFocusManager.cpp#2333

Neil, what's the significance of these checks? How should I adjust these checks to allow an iframe aElement in these cases without breaking something else?

Flags: needinfo?(enndeakin)

(In reply to Henri Sivonen (:hsivonen) from comment #3)

My attempt to eagerly set the iframe as the focused element fails, because it's composed doc doesn't match the expected doc at
https://searchfox.org/mozilla-central/rev/4d2a9d5dc8f0e65807ee66e2b04c64596c643b7a/dom/base/nsGlobalWindowInner.cpp#4079

You can't set the focused element to an element from a different document. If the documents don't match, then something is calling SetFocusedElement on the wrong window.

https://searchfox.org/mozilla-central/rev/4d2a9d5dc8f0e65807ee66e2b04c64596c643b7a/dom/base/nsFocusManager.cpp#2333

This check can fail some if the element was moved or the focus was adjusted during the focus event that was fired earlier within Focus(). If so, we don't want to continue focusing the element. It isn't perfect but we try to handle some situations where script might try to adjust the focus during a focus/blur event listener.

Flags: needinfo?(enndeakin)

This bug is a Fission Nightly blocker (milestone M6c).

Fission Milestone: M6 → M6c

Bug 1649099 shows that things are OK after the iframe has loaded. The problem with the test here is that the iframe still reports having an inner window at the time of the focus() call. We should probably make the inner window of an iframe that's about to navigate to a different side go away sooner.

Before doing that I should test Chrome some more.

Fission Milestone: M6c → M6b
Attachment #9140330 - Attachment description: Bug 1613054 - Deal with .focus() call on an OOP iframe. → Bug 1613054 part 1 - Synchronously request frame focus when .contentWindow.focus() called on OOP iframe.
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/efecc359f305 part 1 - Synchronously request frame focus when .contentWindow.focus() called on OOP iframe. r=nika

Diagnostic try run to figure out why we can create an initial-looking about:blank when it clearly isn't initial:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=54cdcd82323ab99fd5618926321348662290d039

Try run with release asserting that we don't run the about:blank creation path that fires events:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=26a4bca3366ad159c4c8a4fa695b3e7ec2d3b650

Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/73f6874cb3dd part 2 - On iframe.focus() create the initial about:blank for in-process case and treat the iframe as focusable for OOP case. r=nika

Landing requeued with edit per discussion with Nika.

Flags: needinfo?(hsivonen)
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5194d31bb88d part 2 - On iframe.focus() create the initial about:blank for in-process case and treat the iframe as focusable for OOP case. r=nika

(In reply to Razvan Maries from comment #21)

Log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=315227233&repo=autoland&lineNumber=17482

Sigh. This test was a pre-existing intermittent, which I why I didn't look into in more in the context of a try push.

Flags: needinfo?(hsivonen)
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b80dd69ca213 part 2 - On iframe.focus() create the initial about:blank for in-process case and treat the iframe as focusable for OOP case. r=nika
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: