Closed Bug 1926198 Opened 10 months ago Closed 10 months ago

NotifyOfAnchorJumpTo doesn't fire an event if the element doesn't have an Accessible

Categories

(Core :: Disability Access APIs, defect)

defect

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: Jamie, Assigned: Jamie)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

STR (with NVDA):

  1. Open this test case:
    data:text/html,<p>1</p><p>2 <b>3</b></p><script>setTimeout(() => location.hash = ":~:text=3", 2000);</script>
  2. Before 2 seconds elapses, press control+home to ensure you are at the top of the document. NVDA should say "1".
  3. Wait 2 seconds.
    • Expected: NVDA should say "2 3"
    • Actual: NVDA says nothing.

This happens because we fail to fire a scrolling start event. In turn, this happens because nsAccessibilityService::NotifyOfAnchorJumpTo calls GetAccessible instead of GetAccessibleOrContainer. "3" is inside a <b>, which doesn't get an Accessible, so GetAccessible returns null. We fall back to setting the document's anchor jump, but that won't take effect until the document is next focused.

This test case is somewhat contrived; it's unlikely that location.hash would be set without focusing something first, and if something is focused, setting location.hash will focus the document, triggering the anchor jump in FocusManager. However, it is more problematic if the document gets focus before NotifyOfAnchorJumpTo is called, which seems to happen quite a lot on Android.

Note that DocAccessible::AnchorJump already uses GetAccessibleOrContainer.

Severity: -- → S3

The target might be an element for which we don't create an Accessible; e.g. a <b> element.
Previously, we wouldn't fire an event in NotifyOfAnchorJumpTo and would instead defer the event until the next document focus.
However, the document might already have focus, in which case we won't fire this event when the user expects it (if ever).
Instead, use GetAccessibleOrContainer, which is also consistent with the deferred anchor jump code in FocusManager.
This means we will fire the event on the correct container Accessible immediately.

Pushed by jteh@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fbb2bce6d562 Use GetAccessibleOrContainer in nsAccessibilityService::NotifyOfAnchorJumpTo. r=morgan

Backed out for causing ba failures.

[task 2024-10-28T07:26:51.861Z] 07:26:51     INFO - TEST-START | accessible/tests/browser/windows/ia2/browser_scrolling.js
[task 2024-10-28T07:26:52.179Z] 07:26:52     INFO - GECKO(4256) | must wait for focus in content
[task 2024-10-28T07:27:02.267Z] 07:27:02     INFO - TEST-INFO | started process screenshot
[task 2024-10-28T07:27:02.873Z] 07:27:02     INFO - TEST-INFO | screenshot: exit 0
[task 2024-10-28T07:27:02.873Z] 07:27:02     INFO - Buffered messages logged at 07:26:51
[task 2024-10-28T07:27:02.874Z] 07:27:02     INFO - Entering test bound 
[task 2024-10-28T07:27:02.875Z] 07:27:02     INFO - TEST-PASS | accessible/tests/browser/windows/ia2/browser_scrolling.js | Received document load complete event - 
[task 2024-10-28T07:27:02.876Z] 07:27:02     INFO - Buffered messages logged at 07:26:52
[task 2024-10-28T07:27:02.877Z] 07:27:02     INFO - TEST-PASS | accessible/tests/browser/windows/ia2/browser_scrolling.js | Actually remote browser - 
[task 2024-10-28T07:27:02.877Z] 07:27:02     INFO - Navigating to text fragment: second phrase
[task 2024-10-28T07:27:02.878Z] 07:27:02     INFO - Buffered messages finished
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO - TEST-UNEXPECTED-FAIL | accessible/tests/browser/windows/ia2/browser_scrolling.js | Uncaught exception in test bound  - at chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js:1024 - Error: Traceback (most recent call last):
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO -   File "D:\task_173009891857043\build\tests\mochitest\browser\accessible\tests\browser\windows\a11y_setup.py", line 227, in wait
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO -     ctypes.oledll.ole32.CoWaitForMultipleHandles(
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO -   File "_ctypes/callproc.c", line 1000, in GetResult
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO - OSError: [WinError -2147417835] OLE has sent a request and is waiting for a reply
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO - 
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO - During handling of the above exception, another exception occurred:
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO - 
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO - Traceback (most recent call last):
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO -   File "<string>", line 87, in web_socket_transfer_data
[task 2024-10-28T07:27:02.882Z] 07:27:02     INFO -   File "<string>", line 3, in run
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO -   File "D:\task_173009891857043\build\tests\mochitest\browser\accessible\tests\browser\windows\a11y_setup.py", line 232, in wait
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO -     raise TimeoutError("Timeout before desired event received")
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - TimeoutError: Timeout before desired event received
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - 
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - Stack trace:
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - runPython/</gPythonSocket.onmessage@chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js:1024:16
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - EventHandlerNonNull*runPython/<@chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js:1017:5
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - runPython@chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js:1016:10
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - testTextFragment@chrome://mochitests/content/browser/accessible/tests/browser/windows/ia2/browser_scrolling.js:25:11
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - async*accessibleTask/</<@chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js:602:15
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - async*withNewTab@resource://testing-common/BrowserTestUtils.sys.mjs:121:22
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - async*accessibleTask/<@chrome://mochitests/content/browser/accessible/tests/browser/shared-head.js:521:28
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - handleTask@chrome://mochikit/content/browser-test.js:1145:26
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - _runTaskBasedTest@chrome://mochikit/content/browser-test.js:1217:18
[task 2024-10-28T07:27:02.883Z] 07:27:02     INFO - Tester_execTest@chrome://mochikit/content/browser-test.js:1358:14
[task 2024-10-28T07:27:02.884Z] 07:27:02     INFO - nextTest/<@chrome://mochikit/content/browser-test.js:1134:14
[task 2024-10-28T07:27:02.884Z] 07:27:02     INFO - SimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13
[task 2024-10-28T07:27:02.884Z] 07:27:02     INFO - Leaving test bound 
[task 2024-10-28T07:27:02.885Z] 07:27:02     INFO - GECKO(4256) | MEMORY STAT | vsize 956MB | vsizeMaxContiguous 1293MB | residentFast 236MB | heapAllocated 88MB
[task 2024-10-28T07:27:02.886Z] 07:27:02     INFO - TEST-OK | accessible/tests/browser/windows/ia2/browser_scrolling.js | took 10758ms
Flags: needinfo?(jteh)
Flags: needinfo?(jteh)
Pushed by jteh@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3a2c45c531bb Use GetAccessibleOrContainer in nsAccessibilityService::NotifyOfAnchorJumpTo. r=morgan
Status: NEW → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 134 Branch
Blocks: 1974131
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: