Bug 1700362: Don't check whether the parent DocAccessible is loading when determining whether to fire doc load events. r=morgan

This code has been broken in content processes since e10s; i.e. we currently fire doc load complete events for iframes, even if the parent doc is still loading.
Rather than returning to the pre-e10s behaviour, this check has been removed instead for several reasons:

1. Mac wants AXLayoutComplete to be fired on iframes and we map that from doc load complete.
2. We've been doing this since e10s (3+ years) and it doesn't seem to have hurt any screen readers, so presumably, this has been fixed in screen readers.
3. This check can never work for OOP (Fission) iframes, since the parent document is in a different process and we thus can't query its loading state.
4. The behaviour is currently inconsistent between parent process documents and content process documents. Removing this check makes it consistent.

Differential Revision: https://phabricator.services.mozilla.com/D109582
This commit is contained in:
James Teh
2025-04-11 06:23:52 +00:00
parent a1578cd9ca
commit b91f768a81
3 changed files with 6 additions and 35 deletions

View File

@@ -1806,11 +1806,8 @@ void DocAccessible::ProcessLoad() {
#endif
// Do not fire document complete/stop events for root chrome document
// accessibles and for frame/iframe documents because
// a) screen readers start working on focus event in the case of root chrome
// documents
// b) document load event on sub documents causes screen readers to act is if
// entire page is reloaded.
// accessibles because screen readers start working on focus event in the case
// of root chrome documents.
if (!IsLoadEventTarget()) return;
// Fire complete/load stopped if the load event type is given.
@@ -2984,31 +2981,7 @@ void DocAccessible::ShutdownChildrenInSubtree(LocalAccessible* aAccessible) {
}
bool DocAccessible::IsLoadEventTarget() const {
nsCOMPtr<nsIDocShellTreeItem> treeItem = mDocumentNode->GetDocShell();
if (!treeItem) {
return false;
}
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
treeItem->GetInProcessParent(getter_AddRefs(parentTreeItem));
// Not a root document.
if (parentTreeItem) {
// Return true if it's either:
// a) tab document;
nsCOMPtr<nsIDocShellTreeItem> rootTreeItem;
treeItem->GetInProcessRootTreeItem(getter_AddRefs(rootTreeItem));
if (parentTreeItem == rootTreeItem) return true;
// b) frame/iframe document and its parent document is not in loading state
// Note: we can get notifications while document is loading (and thus
// while there's no parent document yet).
DocAccessible* parentDoc = ParentDocument();
return parentDoc && parentDoc->HasLoadState(eCompletelyLoaded);
}
// It's content (not chrome) root document.
return (treeItem->ItemType() == nsIDocShellTreeItem::typeContent);
return mDocumentNode->GetBrowsingContext()->IsContent();
}
void DocAccessible::SetIPCDoc(DocAccessibleChild* aIPCDoc) {

View File

@@ -624,10 +624,8 @@ class DocAccessible : public HyperTextAccessible,
* Return true if the document is a target of document loading events
* (for example, state busy change or document reload events).
*
* Rules: The root chrome document accessible is never an event target
* (for example, Firefox UI window). If the sub document is loaded within its
* parent document then the parent document is a target only (aka events
* coalescence).
* Rule: The root chrome document accessible is never an event target
* (for example, Firefox UI window).
*/
bool IsLoadEventTarget() const;

View File

@@ -121,4 +121,4 @@ async function runTests(browser) {
/**
* Test events when a document loads.
*/
addAccessibleTask("", runTests);
addAccessibleTask("", runTests, { chrome: true, topLevel: true });