tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ba679fa826debf91a8585a857b46dea7fbb62cfe
parent 648d8bff8033e3a056f0ae2e4d64033d542246c1
Author: Eitan Isaacson <eitan@monotonous.org>
Date:   Mon, 20 Oct 2025 15:05:34 +0000

Bug 1989629 - Don't add accessibles to mInsertedAccessibles in DoInitialUpdate. r=Jamie

Since the initial tree gets pushed to the parent before any relocations,
the contents of mInsertedAccessibles are already shown when we call
DoARIAOwnsRelocation. Therefore, don't use mInsertedAccessibles in the
initial tree build phase.

Differential Revision: https://phabricator.services.mozilla.com/D268971

Diffstat:
Maccessible/generic/DocAccessible.cpp | 13++++++++++---
Maccessible/tests/browser/relations/browser_relations_general_002.js | 19+++++++++++++++++++
2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp @@ -1297,7 +1297,13 @@ void DocAccessible::BindToDocument(LocalAccessible* aAccessible, } } - if (mIPCDoc) { + if (mIPCDoc && HasLoadState(eTreeConstructed)) { + // Child process and not in initial tree construction phase. + // We need to track inserted accessibles so we don't mark them as moved + // before their initial show event. + // If this is the initial tree construction, we will push the tree to the + // parent process before we process moves, so we will always need to mark a + // relocated accessible as moved. mInsertedAccessibles.EnsureInserted(aAccessible); } @@ -1771,13 +1777,14 @@ void DocAccessible::DoInitialUpdate() { } } - mLoadState |= eTreeConstructed; - // Set up a root element and ARIA role mapping. UpdateRootElIfNeeded(); // Build initial tree. CacheChildrenInSubtree(this); + + mLoadState |= eTreeConstructed; + #ifdef A11Y_LOG if (logging::IsEnabled(logging::eVerbose)) { logging::Tree("TREE", "Initial subtree", this); diff --git a/accessible/tests/browser/relations/browser_relations_general_002.js b/accessible/tests/browser/relations/browser_relations_general_002.js @@ -335,3 +335,22 @@ addAccessibleTask( is(combobox.childCount, 1, "combobox has listbox"); } ); + +/* + * Test relocated child preserves relation. + */ +addAccessibleTask( + ` + <div id="relocated">World</div> + <div id="owner" aria-owns="relocated"></div> + <button id="btn" aria-labelledby="relocated">Hello</button> + `, + async function testRelocationRelation(browser, docAcc) { + const btn = findAccessibleChildByID(docAcc, "btn"); + const relocated = findAccessibleChildByID(docAcc, "relocated"); + + await testCachedRelation(btn, RELATION_LABELLED_BY, relocated); + await testCachedRelation(relocated, RELATION_LABEL_FOR, btn); + }, + { chrome: true, topLevel: true } +);