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
This commit is contained in:
James Teh
2025-02-23 05:22:31 +00:00
parent 8085a4be5d
commit 70691d61c0
4 changed files with 31 additions and 5 deletions

View File

@@ -6,6 +6,12 @@ skip-if = [
"artifact",
]
support-files = ["head.js"]
prefs = [
# The browser test harness clears the clipboard after each test. Copying to
# the clipboard activates Windows accessibility suppression by default.
# Disable this so that accessibility isn't suppressed for our tests.
"accessibility.windows.suppress-after-clipboard-copy=0",
]
["browser_groupPosition.js"]

View File

@@ -9,6 +9,12 @@ support-files = [
"head.js",
"!/accessible/tests/mochitest/moz.png",
]
prefs = [
# The browser test harness clears the clipboard after each test. Copying to
# the clipboard activates Windows accessibility suppression by default.
# Disable this so that accessibility isn't suppressed for our tests.
"accessibility.windows.suppress-after-clipboard-copy=0",
]
["browser_controlType.js"]

View File

@@ -11,6 +11,7 @@
#include "AccessibleText_i.c"
#include "mozilla/a11y/Compatibility.h"
#include "mozilla/a11y/HyperTextAccessibleBase.h"
#include "mozilla/ClearOnShutdown.h"
@@ -124,6 +125,19 @@ ia2AccessibleText::get_nSelections(long* aNSelections) {
}
*aNSelections = textAcc->SelectionCount();
if (*aNSelections == 0 &&
(Compatibility::A11ySuppressionReasons() &
SuppressionReasons::Clipboard) &&
static_cast<ia2AccessibleHypertext*>(this)->Acc()->IsDoc()) {
// Bug 1798098: Windows Suggested Actions (introduced in Windows 11
// 22H2) might walk the document a11y tree using UIA whenever anything
// is copied to the clipboard. This causes an unacceptable hang. It walks
// using IAccessibleText/IAccessibleHyperText if the document reports no
// selection, so we lie here and say that there is a selection even though
// there isn't. It will subsequently call get_selection, which will fail,
// but this hack here seems to be enough to avoid further text calls.
*aNSelections = 1;
}
return S_OK;
}

View File

@@ -618,12 +618,12 @@ MsaaAccessible::get_accChildCount(long __RPC_FAR* pcountChildren) {
if ((Compatibility::A11ySuppressionReasons() &
SuppressionReasons::Clipboard) &&
mAcc->IsRoot()) {
mAcc->IsDoc()) {
// Bug 1798098: Windows Suggested Actions (introduced in Windows 11 22H2)
// might walk the entire a11y tree using UIA whenever anything is copied
// to the clipboard. This causes an unacceptable hang, particularly when
// the cache is disabled. We prevent this tree walk by returning a 0 child
// count for the root window, from which Windows might walk.
// might walk the entire a11y tree using UIA whenever anything is copied to
// the clipboard. This causes an unacceptable hang. We prevent this tree
// walk by returning a 0 child count for documents, from which Windows might
// walk.
return S_OK;
}