Closed Bug 1933119 Opened 8 days ago Closed 6 days ago

Parent process document doesn't get a11y focus correctly

Categories

(Core :: Disability Access APIs, defect)

defect

Tracking

()

RESOLVED FIXED
135 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr128 --- wontfix
firefox133 --- wontfix
firefox134 --- wontfix
firefox135 --- fixed

People

(Reporter: Jamie, Assigned: emilio)

References

(Blocks 3 open bugs, Regression)

Details

(Keywords: regression)

Attachments

(3 files, 1 obsolete file)

STR (with NVDA):

  1. Open a new tab.
  2. Ensure the address bar is focused.
  3. Type about:support and press enter.
    • Expected: NVDA should start reading the "Troubleshooting Information" document.
    • Actual: NVDA says just "collapsed" or sometimes reads the title of the document and then says "unknown".
  4. Press the alt key to open the menu bar, then alt again to dismiss it.
    • Expected: NVDA should say "Troubleshooting Information document"
    • Actual: NVDA says just "frame"

Tabbing around or alt+tabbing out and back in again fixes this, but it's still rather annoying.

5:51.15 INFO: Last good revision: 75b3c6c4437624f59fcaff278bb8f5b88358e3a6 (2023-03-23)
5:51.15 INFO: First bad revision: f476897a6e6ac50ecebdf7f8bda821d40aab066c (2023-03-24)
5:51.15 INFO: Pushlog:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=75b3c6c4437624f59fcaff278bb8f5b88358e3a6&tochange=f476897a6e6ac50ecebdf7f8bda821d40aab066c

Only obvious focus related change is bug 1823984. Only a11y change is bug 1823294, but that doesn't touch focus.

Reverting the patch from bug 1823984 "fixes" this. I don't understand why yet.

Regressed by: 1823984

With the patch reverted (when things work as expected), A11YLOG=focus reports this:

A11Y FOCUS: DOM focus; 39:38.010
  {
    Target: 00000208D54A1800; role: document, name: 'Troubleshooting Information';
    Target node: 0x208d89a8a00, #document, idx in parent <Nothing>
    Document: 00000208D54A1800, document node: 00000208D89A8A00
    Document uri: about:support
  }

A11Y FOCUS: DOM focus; 39:38.010
  {
    Target: 00000208D547E000, window
  }

A11Y FOCUS: process DOM focus; 39:38.016
  {
    Target: 0x208d89a8a00, #document, idx in parent <Nothing>
  }
  {
    A11y target: 00000208D54A1800; role: document, name: 'Troubleshooting Information';
    A11y target node: 0x208d89a8a00, #document, idx in parent <Nothing>
    Document: 00000208D54A1800, document node: 00000208D89A8A00
    Document uri: about:support
  }

A11Y FOCUS: fire focus event; 39:38.017
  {
    Target: 00000208D54A1800; role: document, name: 'Troubleshooting Information';
    Target node: 0x208d89a8a00, #document, idx in parent <Nothing>
    Document: 00000208D54A1800, document node: 00000208D89A8A00
    Document uri: about:support
  }

Without the patch reverted (when things break), a11y never seems to get a DOM focus notification for the about:support document at all.

Curiously, this problem only occurs when changing from a remote document to a local (parent process document) in the same tab. If you visit about:support, experience the failure and immediately visit about:about in the same tab, about:about gets focus just fine. Same if you flip those URLs around.

:emilio, since you are the author of the regressor, bug 1823984, could you take a look?

For more information, please visit BugBot documentation.

Flags: needinfo?(emilio)

This seems to be related to the browser element. With this patch against central, the problem goes away:

diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp
index 54cf5e2647a8f..72dad846cc07d 100644
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -5561,7 +5561,7 @@ bool nsFocusManager::CanSkipFocus(nsIContent* aContent) {
     return false;
   }
 
-  if (mFocusedElement == aContent) {
+  if (mFocusedElement == aContent && !aContent->IsXULElement(nsGkAtoms::browser)) {
     return true;
   }
 
  1. For a remote document, the <browser> itself has DOM focus in the parent process.
  2. When we change from remote to non-remote, we use the same <browser> element.
  3. For a non-remote document, the parent process DOM focus needs to be inside the document itself.
  4. I haven't worked out where this happens, but when we focus a <browser> for a non-remote document, DOM bounces focus to the document inside it.
  5. My guess is that we're relying on (4) to set focus correctly, even though the <browser> already had focus in (1). However, because we're skipping focus for this element because it already had focus, focus doesn't get set up correctly and thus remains on the <browser> element. From a11y's perspective, that effectively means we get no focus change. That's also why NVDA reports "frame" (that's the <browser> element) when a11y forces a focus event (based on the current DOM focus) after dismissing the menu bar.

Otherwise, when a <browser> has focus and changes from remote to non-remote, we don't redirect focus to the document within.

Assignee: nobody → jteh
Status: NEW → ASSIGNED
Flags: needinfo?(emilio)

Since bug 1823984, this focus() call has been a no-op on remote frames.

The previous patch also fixes the non-remote frame focus switch.

Attachment #9439619 - Attachment description: Bug 1933119: Do not skip focus for a <browser> element even if it already has focus. → Bug 1933119: Add a11y test for focus when changing a tab from remote to non-remote.
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4162f8eaef34 Fix non-remote frame focus after frameloader change too. r=Jamie,smaug
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/90929265e20e Remove no-op focus() calls. r=tabbrowser-reviewers,dao

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

Blocks: 1933555

Backed out changeset 90929265e20e for causing bc failures @ browser_keyword

TEST-UNEXPECTED-FAIL | browser/components/urlbar/tests/browser/browser_keyword.js | Test timed out -
Flags: needinfo?(jteh)
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ca977cd1cc39 Minor nsFocusManager clean-ups. r=hsivonen,dom-core,edgar
Flags: needinfo?(jteh) → needinfo?(emilio)
Assignee: jteh → emilio
Status: ASSIGNED → RESOLVED
Closed: 6 days ago
Resolution: --- → FIXED
Target Milestone: --- → 135 Branch
Pushed by jteh@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0229729dd998 Add a11y test for focus when changing a tab from remote to non-remote. r=emilio,nlapre
Blocks: 1933769

Moved the other patch to bug 1933769.

Flags: needinfo?(emilio)

Comment on attachment 9439684 [details]
Bug 1933119 - Remove no-op focus() calls. r=#tabbrowser-reviewers

Revision D230098 was moved to bug 1933769. Setting attachment 9439684 [details] to obsolete.

Attachment #9439684 - Attachment is obsolete: true

The patch landed in nightly and beta is affected.
:emilio, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox134 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(emilio)

301 Jamie, but my guess is that this can probably ride the trains :)

Flags: needinfo?(emilio) → needinfo?(jteh)

I'd let it ride the trains. It's an annoying bug, but it's existed for over a year apparently without anyone other than me noticing.

Flags: needinfo?(jteh)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: