diff --git a/accessible/tests/browser/windows/uia/browser_textPatterns.js b/accessible/tests/browser/windows/uia/browser_textPatterns.js index 252d36606a46..21c9758d6521 100644 --- a/accessible/tests/browser/windows/uia/browser_textPatterns.js +++ b/accessible/tests/browser/windows/uia/browser_textPatterns.js @@ -1856,3 +1856,55 @@ addUiaTask( }, { uiaEnabled: true, uiaDisabled: true, chrome: true } ); + +/** + * Test the TextRange pattern's ScrollIntoView method. + */ +addUiaTask( + ` + +
p1
+p2
+p3
+ `, + async function testTextRangeScrollIntoView(browser, docAcc) { + const [docLeft, docTop, , docBottom] = await runPython(` + global doc + doc = getDocUia() + rect = doc.CurrentBoundingRectangle + return (rect.left, rect.top, rect.right, rect.bottom) + `); + + info("Scrolling p2 to top"); + let scrolled = waitForEvent(EVENT_SCROLLING_END, docAcc); + await runPython(` + global docText, p2, range + docText = getUiaPattern(doc, "Text") + p2 = findUiaByDomId(doc, "p2") + range = docText.RangeFromChild(p2) + range.ScrollIntoView(True) + `); + await scrolled; + let [left, top, , height] = await runPython( + `range.GetBoundingRectangles()` + ); + is(left, docLeft, "range is at left of document"); + is(top, docTop, "range is at top of document"); + + info("Scrolling p2 to bottom"); + scrolled = waitForEvent(EVENT_SCROLLING_END, docAcc); + await runPython(` + range.ScrollIntoView(False) + `); + await scrolled; + [left, top, , height] = await runPython(`range.GetBoundingRectangles()`); + is(left, docLeft, "range is at left of document"); + is(top + height, docBottom, "range is at bottom of document"); + } +); diff --git a/accessible/windows/uia/UiaTextRange.cpp b/accessible/windows/uia/UiaTextRange.cpp index 44855edc3993..ca6cf1ff2273 100644 --- a/accessible/windows/uia/UiaTextRange.cpp +++ b/accessible/windows/uia/UiaTextRange.cpp @@ -7,6 +7,7 @@ #include "UiaTextRange.h" #include "nsAccUtils.h" +#include "nsIAccessibleTypes.h" #include "TextLeafRange.h" #include