3938 Commits

Author SHA1 Message Date
Joel Maher
ff83b96c22 Bug 1957707 - clean up old a11y conditions and standardize on remaing conditions. r=aryx
Differential Revision: https://phabricator.services.mozilla.com/D244046
2025-04-07 20:51:47 +00:00
James Teh
ba45223d7c Bug 1956415 part 2: Disable native UIA when JAWS, other Vispero products or NVDA are detected. r=morgan
JAWS and NVDA will continue to use IA2 in Firefox.
However, enabling native UIA in Gecko causes them both to try to use UIA, which causes breakage.
The same is presumably true for other Vispero products, as they use components shared with JAWS.
Future versions of these products will handle this correctly themselves.
Until then, disable UIA when these products are detected.

As part of this, the UIA pref has been changed from a bool to a uint32_t.
This will cause existing configurations of this pref to be reset to the default, but this is okay because this pref has never been documented, exposed in the UI or intended for public usage.
This allows for three values: 0 to never enable, 1 to always enable and 2 to enable unless incompatible clients are detected.
This makes it possible for developers to test those clients with Gecko's UIA implementation when necessary.

Differential Revision: https://phabricator.services.mozilla.com/D243245
2025-03-31 01:55:05 +00:00
Emilio Cobos Álvarez
6aa8891f8c Bug 1956626 - Ensure PreferenceSheet and LookAndFeel initialization are in sync. r=dshin
This doesn't fix it per se, but it's clearer, as PreferenceSheet depends on
LookAndFeel.

Differential Revision: https://phabricator.services.mozilla.com/D243340
2025-03-28 15:54:25 +00:00
Tom Schuster
fc52f31d2d Bug 1954448: Adjust several accessibility tests which specify chrome: true to use contentSetup instead of inline script (Part 2). r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D242711
2025-03-26 08:16:55 +00:00
James Teh
0418a783f0 Bug 1956150: Fire the UIA AsyncContentLoaded event. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D242871
2025-03-25 23:41:54 +00:00
James Teh
b2c46f0759 Bug 1954448: Adjust several accessibility tests which specify chrome: true to use contentSetup instead of inline script. r=tschuster,eeejay
Differential Revision: https://phabricator.services.mozilla.com/D242490
2025-03-24 23:28:33 +00:00
James Teh
7e98770397 Bug 1954448: Add a contentSetup argument to addAccessibleTask to facilitate content setup before a test starts. r=tschuster,eeejay
After bug 1953866, it will no longer be possible to have inline `<script>` elements in any document which runs in a chrome context.
Several accessibility tests currently rely on this to set things up which can't be done in pure HTML/CSS, but which need to be done before the content is initially added to the accessibility tree so that we can explicitly test the initial state (vs the state after it is mutated).
To work around this, a content task can be specified using the contentSetup argument to addAccessibleTask.
This causes the following to happen:

1. aria-hidden="true" is set on the body, preventing the initial accessibility tree update from including any content.
2. contentTask is executed in the context of the document.
3. aria-hidden is removed from the body, so that all of the content (including any changes made by contentSetup) is processed by accessibility.
4. A reorder event is awaited on the body, so that we can guarantee that (3) is complete.

Subsequent patches will adjust existing tests as needed.

Differential Revision: https://phabricator.services.mozilla.com/D242489
2025-03-24 23:28:33 +00:00
James Teh
510cf177bc Bug 1951720: Don't exclude 0 width whitespace text nodes from the accessibility tree if they're at the end of a wrapped line. r=morgan
In bug 1951067, I pruned all 0 width whitespace text nodes from the accessibility tree.
However, it turns out that whitespace text nodes at the end of wrapped lines can also be 0 width.
These have semantic importance, since otherwise, words in separate inline nodes can be merged together without a space.
To fix this, explicitly check that the node is before a hard line break, not a soft (wrapped) line break.

Differential Revision: https://phabricator.services.mozilla.com/D242290
2025-03-21 02:15:18 +00:00
Morgan Rae Reschenberg
28883bddda Bug 1894437: Verify selectable containers contain no explicit selection before assigning implicit state r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D240937
2025-03-19 18:56:39 +00:00
Tom Schuster
457abfb126 Bug 1954448 - Remove inline script from browser_aria_activedescendant.js test. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D241956
2025-03-19 09:57:30 +00:00
James Teh
61546d6b1d Bug 1950740 part 2: TextLeafPoint::GetCaret: Don't assume that CaretAssociationHint::Before means the caret is at the end of a line anywhere but the start of a node. r=morgan
I previously thought that CaretAssociationHint::Before was only used either at the start of a node or at the end of a line.
However, it can also be used if the user clicks any character other than the first in a text node.
To fix this, check if we're at the start of a line for all offsets, not just offset 0.
I didn't do this originally in an attempt to reduce the cases where we must search for lines, but it seems this is unavoidable.
If we run into performance problems here, we might be able to restrict this check to cases where we're at the start of a layout frame.
However, that significantly complicates the code, I'm not entirely certain it will work and it is likely premature optimisation, so I opted not to do that in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D241770
2025-03-18 04:17:33 +00:00
Alexandru Marc
e1e7965a9c Backed out changeset 972f3d069f80 (bug 1894437) for causing multiple mochitest failures CLOSED TREE 2025-03-15 03:32:35 +02:00
Morgan Rae Reschenberg
ce292ec9c0 Bug 1894437: Verify selectable containers contain no explicit selection before assigning implicit state r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D240937
2025-03-15 00:41:45 +00:00
Eitan Isaacson
0c1dd7f719 Bug 1954205 - Unify AT-SPI interface generation for local and remote. r=Jamie
Had to get rid of dependency on MustPrune because this happens at
instantiaton. If an accessible loses or gains a child in its lifetime
the interfaces it supports cannot change.

Differential Revision: https://phabricator.services.mozilla.com/D241690
2025-03-14 22:42:22 +00:00
Eitan Isaacson
56efb5388b Bug 1851241 - Prune meter's children. r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D241115
2025-03-14 22:42:22 +00:00
James Teh
e5e9bc657c Bug 1946552: Fix problems and inconsistencies in the calculation of text bounds for a range. r=morgan
There are multiple problems and inconsistencies in the way we previously calculated text bounds in various places:

1. TextLeafRange::WalkLineRects and TextLeafRange::Bounds calculated bounds inclusive of the range end. However, everywhere else, range ends are exclusive.
2. To compensate for this, HyperTextAccessibleBase::TextBounds walked back 1 character from the end before calling TextLeafRange::Bounds. However, other callers (UIA and Mac) didn't do this. Including the range end meant we included the bounds for an additional character or even an entire line in some cases.
3. When lines end with a line feed character, we tried to include this in the bounds calculation. Since line feeds have a 0 rect, this messed up the calculation.
4. Even though WalkLineRects constrained line bounds to the end of the range, the provided sub-ranges were not constrained.

To fix these problems, TextLeafRange::WalkLineRects and TextLeafRange::Bounds now explicitly return bounds and sub-ranges constrained to, but exclusive of, the end of the range.
HyperTextAccessibleBase::TextBounds has been updated accordingly.
The line feed character is ignored when calculating line bounds.

Co-authored-by: Nathan LaPre <nlapre@mozilla.com>

Differential Revision: https://phabricator.services.mozilla.com/D237142
2025-03-14 21:37:47 +00:00
James Teh
b24c675911 Bug 1907225: HyperTextAccessible::DOMPointToOffset: If a text node doesn't have an Accessible, don't use an offset relative to that text node. r=eeejay
This was causing an assertion when firing caret events where the element containing the caret is aria-hidden, since the offset we produced was effectively bogus for the target Accessible.
Doing this is bad authoring, but we need to at least ensure the offset is valid.
Arguably, we shouldn't fire caret events at all in this case, but this is a trickier, riskier fix and I don't think it makes sense to spend time on that to compensate for bad authoring.

Differential Revision: https://phabricator.services.mozilla.com/D240579
2025-03-14 03:13:04 +00:00
Eitan Isaacson
243de2e18c Bug 1952693 - Make stand-in link color #0000ee. r=emilio
This makes it consistent with the fallback in PreferenceSheet.mLink.

This is also consistent with all other browsers.

Differential Revision: https://phabricator.services.mozilla.com/D241116
2025-03-11 23:03:37 +00:00
Sean
0a22de9dd4 Bug 721336 - Block sync XHR with system principal r=valentin,necko-reviewers,extension-reviewers,robwu
Differential Revision: https://phabricator.services.mozilla.com/D239964
2025-03-10 17:22:24 +00:00
James Teh
bcad39a7e4 Bug 1951573 part 5: Add an additional Select() test for UIA which tests setting the caret in content which isn't editable. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D240278
2025-03-05 23:42:52 +00:00
Eitan Isaacson
cf6484047a Bug 1898096 - Replace color settings with "contrast control". r=emilio,fluent-reviewers,settings-reviewers,accessibility-frontend-reviewers,morgan,bolsson,masayuki,mossop,pdfjs-reviewers,calixte
This patch changes the backing prefs by relying on the tristate offered
by browser.display.document_color_use instead of
browser.display.use_system_colors. This simplifies the color
decision tree, and offers a simplified UI.

The tristate preference offered to the user is as follows:
 1. "Use platform's contrast settings" (document_color_use=0)
 2. "Off" - never use HCM, regardless of platform setting (document_color_use=1)
 3. "On" - always use HCM, regardless of platform setting (document_color_use=2)

Option 3 also reveals a colors UI for the user to choose the palette the
browser HCM will use (bg/text/link/visited).

There are three color palettes to choose from in light of the preference
above they are:
 1. WIDGET_COLORS: The OS's configured colors used by its theme.
 2. HARDCODED_COLORS: Colors deemed as standard and are hard coded into
    Firefox (eg. white on black text, blue and purple links).
 3. PREFERENCE_COLORS: Colors that are stored in preferences and are
    configurable from the colors UI (eg. browser.visited_color and
    browser.display.background_color)

The decision over which palette to use is as follows:
 * If we are styling browser UI -> WIDGET_COLORS
 * else, if resist fingerprinting is enabled -> HARDCODED_COLORS
 * else, if document_color_use==0 AND OS HCM is on -> WIDGET_COLORS
 * else, if document_color_use==2 -> PREFERENCE_COLORS
 * else -> HARDCODED_COLORS

Differential Revision: https://phabricator.services.mozilla.com/D211115
2025-03-05 19:18:08 +00:00
Sandor Molnar
728924cf93 Backed out changeset 72987cb97c23 (bug 721336) for causing mochitest failures @ test_markup.html CLOSED TREE 2025-03-05 20:53:39 +02:00
Sean
7b1482c9da Bug 721336 - Block sync XHR with system principal r=valentin,necko-reviewers,extension-reviewers,robwu
Differential Revision: https://phabricator.services.mozilla.com/D239964
2025-03-05 18:00:52 +00:00
Alexandru Marc
a152e016e9 Backed out changeset b03b0ff0e6be (bug 721336) for causing mochitest failures @ test_handlerSpinsEventLoop.html CLOSED TREE 2025-03-05 04:03:40 +02:00
Alexandru Marc
78ef84ae14 Backed out changeset f4d5303f5472 (bug 1898096) for causing ba failures @ browser_attributed_text.js 2025-03-05 03:27:02 +02:00
Eitan Isaacson
e55fdd6ce8 Bug 1898096 - Replace color settings with "contrast control". r=emilio,fluent-reviewers,settings-reviewers,accessibility-frontend-reviewers,morgan,bolsson,masayuki,mossop,pdfjs-reviewers,calixte
This patch changes the backing prefs by relying on the tristate offered
by browser.display.document_color_use instead of
browser.display.use_system_colors. This simplifies the color
decision tree, and offers a simplified UI.

The tristate preference offered to the user is as follows:
 1. "Use platform's contrast settings" (document_color_use=0)
 2. "Off" - never use HCM, regardless of platform setting (document_color_use=1)
 3. "On" - always use HCM, regardless of platform setting (document_color_use=2)

Option 3 also reveals a colors UI for the user to choose the palette the
browser HCM will use (bg/text/link/visited).

There are three color palettes to choose from in light of the preference
above they are:
 1. WIDGET_COLORS: The OS's configured colors used by its theme.
 2. HARDCODED_COLORS: Colors deemed as standard and are hard coded into
    Firefox (eg. white on black text, blue and purple links).
 3. PREFERENCE_COLORS: Colors that are stored in preferences and are
    configurable from the colors UI (eg. browser.visited_color and
    browser.display.background_color)

The decision over which palette to use is as follows:
 * If we are styling browser UI -> WIDGET_COLORS
 * else, if resist fingerprinting is enabled -> HARDCODED_COLORS
 * else, if document_color_use==0 AND OS HCM is on -> WIDGET_COLORS
 * else, if document_color_use==2 -> PREFERENCE_COLORS
 * else -> HARDCODED_COLORS

Differential Revision: https://phabricator.services.mozilla.com/D211115
2025-03-05 00:27:44 +00:00
James Teh
83871fef5f Bug 1950535: Exclude children pruned by MustPrune, as well as single text children of links, for UIA GetEnclosingElement. r=nlapre
Text children of links are (and should be) exposed in the UIA tree, but Narrator misbehaves when we return these from GetEnclosingElement.
Children of Accessibles for which MustPrune() returns true are not exposed in the UIA tree, so they shouldn't be returned by GetEnclosingElement.

Differential Revision: https://phabricator.services.mozilla.com/D239979
2025-03-04 23:47:45 +00:00
Sean
cc99338b50 Bug 721336 - Block sync XHR with system principal r=valentin,necko-reviewers,extension-reviewers,robwu
Differential Revision: https://phabricator.services.mozilla.com/D239964
2025-03-04 22:20:05 +00:00
James Teh
3917728f02 Bug 1950782 part 2: Fix UIA SupportedTextSelection on text leaves. r=nlapre
For now, the core SELECTABLE_TEXT state is only exposed on text containers, not on text leaves.
We may want to reconsider this at some point.
For now, just handle this case in the UIA code, since that's the only place it matters.

Differential Revision: https://phabricator.services.mozilla.com/D239855
2025-03-04 12:17:25 +00:00
James Teh
4fd90edd29 Bug 1950782 part 1: Expose the SELECTABLE_TEXT state on DocAccessibles when appropriate. r=nlapre,devtools-reviewers,nchevobbe
We already had code to expose SELECTABLE_TEXT in HyperTextAccessible, from which DocAccessible inherits.
However, DocAccessible overrides the method and doesn't call the HyperTextAccessible implementation.
We don't want to do that because it does work that isn't necessary for DocAccessible.
In addition, we need to use a different layout frame for the document.
See the code comments for details.
Specific code has been added to DocAccessible to expose this state.

This fixes the UIA Text pattern's SupportedTextSelection property on documents.

Differential Revision: https://phabricator.services.mozilla.com/D239854
2025-03-04 12:17:25 +00:00
James Teh
33f663a00c Bug 1951067: Don't include invisible whitespace text nodes in the accessibility tree. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D240001
2025-03-04 05:19:36 +00:00
Butkovits Atila
ecf6325e8b Backed out 2 changesets (bug 1950782) for causing failures at browser_accessibility_print_to_json.js. CLOSED TREE
Backed out changeset 1c9ee07f74ec (bug 1950782)
Backed out changeset cb94368d2970 (bug 1950782)
2025-03-04 03:09:16 +02:00
James Teh
cd10583b42 Bug 1950782 part 2: Fix UIA SupportedTextSelection on text leaves. r=nlapre
For now, the core SELECTABLE_TEXT state is only exposed on text containers, not on text leaves.
We may want to reconsider this at some point.
For now, just handle this case in the UIA code, since that's the only place it matters.

Differential Revision: https://phabricator.services.mozilla.com/D239855
2025-03-03 21:47:09 +00:00
James Teh
bbe97bd49a Bug 1950782 part 1: Expose the SELECTABLE_TEXT state on DocAccessibles when appropriate. r=nlapre
We already had code to expose SELECTABLE_TEXT in HyperTextAccessible, from which DocAccessible inherits.
However, DocAccessible overrides the method and doesn't call the HyperTextAccessible implementation.
We don't want to do that because it does work that isn't necessary for DocAccessible.
In addition, we need to use a different layout frame for the document.
See the code comments for details.
Specific code has been added to DocAccessible to expose this state.

This fixes the UIA Text pattern's SupportedTextSelection property on documents.

Differential Revision: https://phabricator.services.mozilla.com/D239854
2025-03-03 21:47:08 +00:00
Morgan Rae Reschenberg
769dc36069 Bug 1904263: Adjust RemoteAccessible relations code to handle legend/fieldset label relations explicitly r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D239426
2025-03-03 20:16:16 +00:00
James Teh
ef30c65925 Bug 1949920: Expose the UIA Text pattern on text leaves. Don't expose it on the root. r=nlapre
We need to support the Text pattern on text leaves to fix issues with Narrator.
Removing support on the root isn't strictly necessary, but the Text pattern isn't normally supported on a UIA Window and Chromium doesn't do this, so I think it's best to follow.

This change necessitated moving UiaText so that it is no longer inherited by ia2AccessibleHypertext.
I initially tried to inherit UiaText into uiaRawElmProvider, but that doesn't work because ITextProvider and ISelectionProvider both have a GetSelection method with the same signature.
This meant that the ISelectionProvider implementation of GetSelection in uiaRawElmProvider was overriding the implementation in UiaText.
Instead, UiaText has now been split into a separate object.

Differential Revision: https://phabricator.services.mozilla.com/D239811
2025-03-03 03:18:42 +00:00
Emilio Cobos Álvarez
50fe4bde14 Bug 1947723 - Set correct focused window when swapping frameloaders. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D239761
2025-02-26 21:07:07 +00:00
James Teh
d5ff363a05 Bug 1950275: Implement the UIA TextChild pattern. r=nlapre
Differential Revision: https://phabricator.services.mozilla.com/D239483
2025-02-26 00:12:00 +00:00
James Teh
8d1269f0d1 Bug 1948185: Check for an element which has just become display: contents in DocAccessible::PruneOrInsertSubtree. If so, queue style and bounds cache updates. r=morgan
Our normal computed style and bounds change notifications don't fire in this case.
Previously, we kept the bounds from before the change to display: contents in the cache.
Any new children added to the display: contents element would use their grandparent for parent relative bounds, since display: contents elements have no frame and thus can't be used for parent relative bounds.
When we accumulated bounds for the children in RemoteAccessible using their ancestors, we included the stale bounds for the element that is now display: contents.
This resulted in double counting the distance between the parent and the element before it became display: contents.

PruneOrInsertSubtree gets called for elements which are losing a frame, so we now check for this case here and update the cache appropriately.

Differential Revision: https://phabricator.services.mozilla.com/D239081
2025-02-24 06:33:43 +00:00
Sandor Molnar
656479d570 Backed out changeset 13ea5f5a9912 (bug 1948185) for causing mochitest failures @ browser_test_general.js CLOSED TREE 2025-02-24 00:58:22 +02:00
James Teh
32b09d5248 Bug 1948185: Check for an element which has just become display: contents in DocAccessible::PruneOrInsertSubtree. If so, queue style and bounds cache updates. r=morgan
Our normal computed style and bounds change notifications don't fire in this case.
Previously, we kept the bounds from before the change to display: contents in the cache.
Any new children added to the display: contents element would use their grandparent for parent relative bounds, since display: contents elements have no frame and thus can't be used for parent relative bounds.
When we accumulated bounds for the children in RemoteAccessible using their ancestors, we included the stale bounds for the element that is now display: contents.
This resulted in double counting the distance between the parent and the element before it became display: contents.

PruneOrInsertSubtree gets called for elements which are losing a frame, so we now check for this case here and update the cache appropriately.

Differential Revision: https://phabricator.services.mozilla.com/D239081
2025-02-23 21:44:37 +00:00
James Teh
70691d61c0 Bug 1949641: Port some mitigations for hangs caused by Windows 11 Suggested Actions to MsaaAccessible/ia2AccessibleText. r=nlapre
These mitigations were implemented in AccessibleHandler in bug 1798098.
However, after CtW, AccessibleHandler no longer exists and these mitigations weren't ported across.

Differential Revision: https://phabricator.services.mozilla.com/D202369
2025-02-23 05:22:31 +00:00
James Teh
c260afd33e Bug 1946593 part 2: Add test. r=nlapre
Differential Revision: https://phabricator.services.mozilla.com/D238161
2025-02-14 05:58:42 +00:00
Nathan LaPre
739b849487 Bug 1946912: Properly expose read-only property to UIA for text fields, r=Jamie
It was possible for <input> and <textarea> to incorrectly report the IsReadOnly
property as "true" to UIA, particularly when empty. There is no text leaf in
empty text inputs, so our TextLeafPoint would point to the text field itself.
Code that retrieves attributes for UIA didn't handle this case, which caused AT
issues, such as Narrator failing to switch out of scan mode automatically.

This revision fixes the issue by properly checking for text fields when figuring
out whether a TextLeafPoint's Accessible is read-only. It also adds a test to
verify the same.

Differential Revision: https://phabricator.services.mozilla.com/D237644
2025-02-13 01:45:57 +00:00
Sandor Molnar
8f58d561a2 Backed out changeset 0a39b47ae3c2 (bug 1946552) for causing mochitest failures @ accessible/tests/browser/bounds/browser_test_zoom_text.js & browser_caching_text_bounds.js CLOSED TREE 2025-02-11 08:46:33 +02:00
Nathan LaPre
d6ea45a890 Bug 1946552: Fix WalkLineRects endpoint calculation, r=Jamie
In certain conditions, WalkLineRects uses the incorrect endpoint for
calculating rects for a given TextLeafRange. This revision fixes the problem by
properly walking the endpoint back by one character, if possible. It also adds a
test verifying that character bounds are fixed.

Differential Revision: https://phabricator.services.mozilla.com/D237142
2025-02-10 22:24:34 +00:00
Nathan LaPre
371285f2e3 Bug 1946902: Prevent infinite loop searching backward in UiaTextRange::FindAttribute, r=Jamie
This revision adds a loop condition to ensure we don't hit an infinite loop
while walking backwards in UiaTextRange::FindAttribute. It also adds a test to
verify that we won't hit this loop again.

Differential Revision: https://phabricator.services.mozilla.com/D237300
2025-02-10 22:23:20 +00:00
Eitan Isaacson
90a01b0030 Bug 1946836 - Check for AXARIAControls after combobox is expanded. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D237248
2025-02-10 19:57:05 +00:00
James Teh
4d3a93a0c1 Bug 1909142 part 3: Fix accessibility handling of overlapping custom highlight ranges. r=morgan
Before custom highlights, ranges from a dom::Selection couldn't overlap and thus TextLeafRange didn't handle this.
However, custom highlight ranges can overlap.

Because we can't sort by both start and end offset any more, we can unfortunately no longer binary search the array of ranges for RemoteAccessible.
Hopefully, there won't be so many text offset attribute ranges in a single text leaf that this will be problematic.
Gecko's own spell checker stops at 500 misspelled words in a text node.
If it does cause problems, we could split the ranges into smaller, non-overlapping ranges when we send them from the content process.

Note that overlapping spelling and grammar errors aren't yet supported due to their use of the same "invalid" text attribute, but I expect this should be rare and can be fixed in future if needed.
However, this does handle highlights overlapping with either spelling or grammar errors.

Differential Revision: https://phabricator.services.mozilla.com/D233807
2025-02-10 10:24:16 +00:00
James Teh
a996d42db7 Bug 1909142 part 2: Expose custom highlights via accessibility APIs. r=morgan
Differential Revision: https://phabricator.services.mozilla.com/D233806
2025-02-10 10:24:15 +00:00