Closed Bug 1733301 Opened 3 years ago Closed 3 years ago

Incorrect content document focus after active toplevel OS window change

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED FIXED
94 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox-esr91 --- wontfix
firefox92 --- wontfix
firefox93 --- wontfix
firefox94 --- fixed

People

(Reporter: karlt, Assigned: karlt)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

Attached file log

STR

  1. Set pref "focusmanager.testmode" to true.
  2. Open a content document b in a new toplevel OS window B from a focused content document a in OS window A.
    (OS window B becomes active.)
  3. Activate OS window A again through script (e.g. testharness) before content document b receives focus.

https://treeherder.mozilla.org/jobs?repo=try&revision=44e51d543efc5fbdd6c76c6545cb9ce9845033d0&selectedJob=353045894

Expected: Content document a gets focus.
Actual: Content document b keeps focus.

Sequence of events:

  1. Toplevel chrome window A [7fbe4cdc5760] is initially active and element focus is moved to its browser element.
  2. The contained content window proxy a [7f173c9a1920] receives focus [actionid 20].
  3. Toplevel chrome window B [7fbe277fb060] is shown and becomes active [actionid 23].
  4. (Actionid 24 is a no-op B -> B toplevel chrome window change.)
  5. focus() is called on toplevel chrome window A [actionid 25] which queues a task to call WindowRaised().
  6. gBrowserInit.onDOMContentLoaded() calls focus() on chrome window B's browser element [actionid 26], which focuses content window proxy b [7f173d1f83e0] in the content process.
  7. The queued WindowRaised() records chrome window A as the active window and attempts to focus content window proxy a, but content process changes are dropped due to stale actionid 25.

Perhaps, there may exist an issue here that element focus changes are taking priority over active OS window changes with stale action IDs.

However, I don't know whether that could occur in practice without "focusmanager.testmode", given that active OS window changes usually GenerateFocusActionId() at the time of the WindowRaised() call.
https://treeherder.mozilla.org/jobs?repo=try&revision=138fd1fb15d3e0513b5a02b203161f1ee27fc1b2

for consistency with OS-triggered calls
https://searchfox.org/mozilla-central/rev/b022ae1fc071ad7a29f64f281bc19b7b093df538/xpfe/appshell/AppWindow.cpp#3005
and so that interleaved element-focus actions don't make the active toplevel
window change notification (and its associated content window focus changes)
stale.

Assignee: nobody → karlt
Status: NEW → ASSIGNED
Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b983111f779f generate action ID for focusmanager.testmode WindowRaised() at time of call r=hsivonen
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 94 Branch
Attachment #9243608 - Attachment mime type: text/x-log → text/plain

Set release status flags based on info from the regressing bug 1618386

Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: