diff --git a/accessible/base/nsAccessiblePivot.cpp b/accessible/base/nsAccessiblePivot.cpp index 9733a0852edc..867c45b8d189 100644 --- a/accessible/base/nsAccessiblePivot.cpp +++ b/accessible/base/nsAccessiblePivot.cpp @@ -825,13 +825,17 @@ nsAccessiblePivot::SearchForText(Accessible* aAccessible, bool aBackward) if (temp == root) break; + // Unlike traditional pre-order traversal we revisit the parent + // nodes when we go up the tree. This is because our starting point + // may be a subtree or a leaf. If it's parent matches, it should + // take precedent over a sibling. if (temp != aAccessible && temp->IsHyperText()) return temp->AsHyperText(); - sibling = aBackward ? temp->PrevSibling() : temp->NextSibling(); - if (sibling) break; + + sibling = aBackward ? temp->PrevSibling() : temp->NextSibling(); } while ((temp = temp->Parent())); if (!sibling) diff --git a/accessible/tests/mochitest/pivot.js b/accessible/tests/mochitest/pivot.js index 776d29664d74..1dc5b7539950 100644 --- a/accessible/tests/mochitest/pivot.js +++ b/accessible/tests/mochitest/pivot.js @@ -104,7 +104,7 @@ function VCChangedChecker(aDocAcc, aIdOrNameOrAcc, aTextOffsets, aPivotMoveMetho var accMatches = position == aIdOrNameOrAcc; SimpleTest.ok(idMatches || nameMatches || accMatches, "id or name matches", - "expecting " + aIdOrNameOrAcc + ", got '" + + "expecting " + prettyName(aIdOrNameOrAcc) + ", got '" + prettyName(position)); SimpleTest.is(aEvent.isFromUserInput, aIsFromUserInput, diff --git a/accessible/tests/mochitest/pivot/doc_virtualcursor_text.html b/accessible/tests/mochitest/pivot/doc_virtualcursor_text.html index aba87bbd8a7d..78df9a7be123 100644 --- a/accessible/tests/mochitest/pivot/doc_virtualcursor_text.html +++ b/accessible/tests/mochitest/pivot/doc_virtualcursor_text.html @@ -24,6 +24,7 @@
Objectsadjacentto eachother should be separate.
+Hello real world