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 @@
Endless fun!

Objectsadjacentto eachother should be separate.

+

Hello real world

End!
diff --git a/accessible/tests/mochitest/pivot/test_virtualcursor_text.html b/accessible/tests/mochitest/pivot/test_virtualcursor_text.html index 94545f987ed6..71da1998df56 100644 --- a/accessible/tests/mochitest/pivot/test_virtualcursor_text.html +++ b/accessible/tests/mochitest/pivot/test_virtualcursor_text.html @@ -213,6 +213,21 @@ getAccessible(doc.getElementById("start-block")))); gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, null, false)); + gQueue.push(new setVCPosInvoker(docAcc, null, null, + getAccessible(doc.getElementById("paragraph-3")).firstChild)); + gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 7], + getAccessible(doc.getElementById("paragraph-3"), nsIAccessibleText))); + + gQueue.push(new setVCPosInvoker(docAcc, null, null, + getAccessible(doc.getElementById("s1-link-1")).nextSibling)); + gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [4, 6], + getAccessible(doc.getElementById("section-1"), nsIAccessibleText))); + + gQueue.push(new setVCPosInvoker(docAcc, null, null, + getAccessible(doc.getElementById("paragraph-4")).firstChild.nextSibling)); + gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [6, 10], + getAccessible(doc.getElementById("paragraph-4"), nsIAccessibleText))); + gQueue.invoke(); }