Bug 1789235: Fire a scrolling start event for anchor jump if focus in doc, r=Jamie

This revision modifies NotifyOfAnchorJump in order to ensure that we fire a
scrolling start event for AT clients. Without this, clients might miss anchor
jump updates, since anchor jumps can arrive after getting focus. This revision
also adds a test to verify that the scrolling start event is now being sent.

Differential Revision: https://phabricator.services.mozilla.com/D177419
This commit is contained in:
Nathan LaPre 2023-06-08 00:06:39 +00:00
Родитель 890bfdd80c
Коммит bb0eac529c
2 изменённых файлов: 34 добавлений и 1 удалений

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

@ -486,8 +486,24 @@ nsAccessibilityService::Observe(nsISupports* aSubject, const char* aTopic,
void nsAccessibilityService::NotifyOfAnchorJumpTo(nsIContent* aTargetNode) {
Document* documentNode = aTargetNode->GetUncomposedDoc();
if (documentNode) {
// If the document has focus when we get this notification, ensure that
// we fire a start scrolling event.
DocAccessible* document = GetDocAccessible(documentNode);
if (document) document->SetAnchorJump(aTargetNode);
const Accessible* focusedAcc = FocusedAccessible();
if (focusedAcc && focusedAcc == document) {
LocalAccessible* targetAcc = document->GetAccessible(aTargetNode);
if (targetAcc) {
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
targetAcc);
document->SetAnchorJump(nullptr);
} else {
// We can't find the target accessible in the document yet. Set the
// anchor jump so that we can fire the scrolling start event later.
document->SetAnchorJump(aTargetNode);
}
} else if (document) {
document->SetAnchorJump(aTargetNode);
}
}
}

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

@ -111,3 +111,20 @@ c</textarea>
await onScrolling;
}
);
// Verify that the scrolling start event is fired for an anchor change.
addAccessibleTask(
`
<p>a</p>
<p>b</p>
<p id="c">c</p>
`,
async function (browser, accDoc) {
let onScrollingStart = waitForEvent(EVENT_SCROLLING_START, "c");
await SpecialPowers.spawn(browser, [], () => {
content.location.hash = "#c";
});
await onScrollingStart;
},
{ chrome: true, topLevel: true }
);