Bug 1849230 - End ShutdownChildrenInSubtree if accessibility was shut down. r=Jamie

Unbinding an accessible from a document can cause accessibility to shut
down if the accessible is the last remaining one with an xpcom wrapper.

In that case we need to return early from ShutdownChildrenInSubtree.

Differential Revision: https://phabricator.services.mozilla.com/D192382
This commit is contained in:
Eitan Isaacson 2023-11-06 23:57:41 +00:00
Родитель 8f18123bd3
Коммит b26b8d8eef
1 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -2644,6 +2644,7 @@ void DocAccessible::UncacheChildrenInSubtree(LocalAccessible* aRoot) {
}
void DocAccessible::ShutdownChildrenInSubtree(LocalAccessible* aAccessible) {
MOZ_ASSERT(!nsAccessibilityService::IsShutdown());
// Traverse through children and shutdown them before this accessible. When
// child gets shutdown then it removes itself from children array of its
// parent. Use jdx index to process the cases if child is not attached to the
@ -2658,7 +2659,16 @@ void DocAccessible::ShutdownChildrenInSubtree(LocalAccessible* aAccessible) {
// Don't cross document boundaries. The outerdoc shutdown takes care about
// its subdocument.
if (!child->IsDoc()) ShutdownChildrenInSubtree(child);
if (!child->IsDoc()) {
ShutdownChildrenInSubtree(child);
if (nsAccessibilityService::IsShutdown()) {
// If XPCOM is the only consumer (devtools & mochitests), shutting down
// the child's subtree can cause a11y to shut down because the last
// xpcom accessibles will be removed. In that case, return early, our
// work is done.
return;
}
}
}
UnbindFromDocument(aAccessible);