diff --git a/accessible/src/generic/HyperTextAccessible.cpp b/accessible/src/generic/HyperTextAccessible.cpp index 9e01b5c5fb0..241ae15e8dc 100644 --- a/accessible/src/generic/HyperTextAccessible.cpp +++ b/accessible/src/generic/HyperTextAccessible.cpp @@ -287,7 +287,8 @@ HyperTextAccessible::GetPosAndText(int32_t& aStartOffset, int32_t& aEndOffset, // should go away after list bullet rewrite substringEndOffset = nsAccUtils::TextLength(childAcc); } - if (startOffset < substringEndOffset) { + if (startOffset < substringEndOffset || + (startOffset == substringEndOffset && (childIdx == childCount - 1))) { // Our start is within this substring if (startOffset > 0 || endOffset < substringEndOffset) { // We don't want the whole string for this accessible @@ -692,18 +693,14 @@ HyperTextAccessible::GetRelativeOffset(nsIPresShell* aPresShell, Accessible* aFromAccessible, nsSelectionAmount aAmount, nsDirection aDirection, - bool aNeedsStart) + bool aNeedsStart, + EWordMovementType aWordMovementType) { const bool kIsJumpLinesOk = true; // okay to jump lines const bool kIsScrollViewAStop = false; // do not stop at scroll views const bool kIsKeyboardSelect = true; // is keyboard selection const bool kIsVisualBidi = false; // use visual order for bidi text - EWordMovementType wordMovementType = aNeedsStart ? eStartWord : eEndWord; - if (aAmount == eSelectLine) { - aAmount = (aDirection == eDirNext) ? eSelectEndLine : eSelectBeginLine; - } - // Ask layout for the new node and offset, after moving the appropriate amount nsresult rv; @@ -718,7 +715,7 @@ HyperTextAccessible::GetRelativeOffset(nsIPresShell* aPresShell, nsPeekOffsetStruct pos(aAmount, aDirection, contentOffset, 0, kIsJumpLinesOk, kIsScrollViewAStop, kIsKeyboardSelect, kIsVisualBidi, - wordMovementType); + aWordMovementType); rv = aFromFrame->PeekOffset(&pos); if (NS_FAILED(rv)) { if (aDirection == eDirPrevious) { @@ -793,8 +790,10 @@ BOUNDARY_LINE_END From the line end before/at/after the offset to the ne */ nsresult -HyperTextAccessible::GetTextHelper(EGetTextType aType, AccessibleTextBoundary aBoundaryType, - int32_t aOffset, int32_t* aStartOffset, int32_t* aEndOffset, +HyperTextAccessible::GetTextHelper(EGetTextType aType, + AccessibleTextBoundary aBoundaryType, + int32_t aOffset, + int32_t* aStartOffset, int32_t* aEndOffset, nsAString& aText) { aText.Truncate(); @@ -803,45 +802,28 @@ HyperTextAccessible::GetTextHelper(EGetTextType aType, AccessibleTextBoundary aB NS_ENSURE_ARG_POINTER(aEndOffset); *aStartOffset = *aEndOffset = 0; - if (!mDoc) - return NS_ERROR_FAILURE; + int32_t offset = ConvertMagicOffset(aOffset); + if (offset < 0) + return NS_ERROR_INVALID_ARG; - nsIPresShell* presShell = mDoc->PresShell(); - if (!presShell) { - return NS_ERROR_FAILURE; - } - - if (aOffset == nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT) { - aOffset = CharacterCount(); - } - if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET) { - GetCaretOffset(&aOffset); - if (aOffset > 0 && (aBoundaryType == BOUNDARY_LINE_START || - aBoundaryType == BOUNDARY_LINE_END)) { - // It is the same character offset when the caret is visually at the very end of a line - // or the start of a new line. Getting text at the line should provide the line with the visual caret, - // otherwise screen readers will announce the wrong line as the user presses up or down arrow and land - // at the end of a line. - nsRefPtr frameSelection = FrameSelection(); - if (frameSelection && - frameSelection->GetHint() == nsFrameSelection::HINTLEFT) { - -- aOffset; // We are at the start of a line - } + if (aOffset == nsIAccessibleText::TEXT_OFFSET_CARET && offset > 0 && + (aBoundaryType == BOUNDARY_LINE_START || + aBoundaryType == BOUNDARY_LINE_END)) { + // It is the same character offset when the caret is visually at + // the very end of a line or the start of a new line. Getting text at + // the line should provide the line with the visual caret, + // otherwise screen readers will announce the wrong line as the user + // presses up or down arrow and land at the end of a line. + nsRefPtr frameSelection = FrameSelection(); + if (frameSelection && + frameSelection->GetHint() == nsFrameSelection::HINTLEFT) { + -- offset; // We are at the start of a line } } - else if (aOffset < 0) { - return NS_ERROR_FAILURE; - } nsSelectionAmount amount; bool needsStart = false; switch (aBoundaryType) { - case BOUNDARY_CHAR: - amount = eSelectCluster; - if (aType == eGetAt) - aType = eGetAfter; // Avoid returning 2 characters - break; - case BOUNDARY_WORD_START: needsStart = true; amount = eSelectWord; @@ -868,7 +850,7 @@ HyperTextAccessible::GetTextHelper(EGetTextType aType, AccessibleTextBoundary aB case BOUNDARY_ATTRIBUTE_RANGE: { - nsresult rv = GetTextAttributes(false, aOffset, + nsresult rv = GetTextAttributes(false, offset, aStartOffset, aEndOffset, nullptr); NS_ENSURE_SUCCESS(rv, rv); @@ -879,7 +861,7 @@ HyperTextAccessible::GetTextHelper(EGetTextType aType, AccessibleTextBoundary aB return NS_ERROR_INVALID_ARG; } - int32_t startOffset = aOffset + (aBoundaryType == BOUNDARY_LINE_END); // Avoid getting the previous line + int32_t startOffset = offset + (aBoundaryType == BOUNDARY_LINE_END); // Avoid getting the previous line int32_t endOffset = startOffset; // Convert offsets to frame-relative @@ -889,13 +871,13 @@ HyperTextAccessible::GetTextHelper(EGetTextType aType, AccessibleTextBoundary aB if (!startFrame) { int32_t textLength = CharacterCount(); - if (aBoundaryType == BOUNDARY_LINE_START && aOffset > 0 && aOffset == textLength) { + if (aBoundaryType == BOUNDARY_LINE_START && offset > 0 && offset == textLength) { // Asking for start of line, while on last character if (startAcc) startFrame = startAcc->GetFrame(); } if (!startFrame) { - return aOffset > textLength ? NS_ERROR_FAILURE : NS_OK; + return offset > textLength ? NS_ERROR_FAILURE : NS_OK; } else { // We're on the last continuation since we're on the last character @@ -903,22 +885,26 @@ HyperTextAccessible::GetTextHelper(EGetTextType aType, AccessibleTextBoundary aB } } - int32_t finalStartOffset, finalEndOffset; + int32_t finalStartOffset = 0, finalEndOffset = 0; + EWordMovementType wordMovementType = needsStart ? eStartWord : eEndWord; + nsIPresShell* presShell = mDoc->PresShell(); // If aType == eGetAt we'll change both the start and end offset from // the original offset if (aType == eGetAfter) { - finalStartOffset = aOffset; + finalStartOffset = offset; } else { finalStartOffset = GetRelativeOffset(presShell, startFrame, startOffset, - startAcc, amount, eDirPrevious, - needsStart); + startAcc, + (amount == eSelectLine ? eSelectBeginLine : amount), + eDirPrevious, needsStart, + wordMovementType); NS_ENSURE_TRUE(finalStartOffset >= 0, NS_ERROR_FAILURE); } if (aType == eGetBefore) { - finalEndOffset = aOffset; + finalEndOffset = offset; } else { // Start moving forward from the start so that we don't get @@ -943,14 +929,16 @@ HyperTextAccessible::GetTextHelper(EGetTextType aType, AccessibleTextBoundary aB return NS_ERROR_FAILURE; } finalEndOffset = GetRelativeOffset(presShell, endFrame, endOffset, endAcc, - amount, eDirNext, needsStart); + (amount == eSelectLine ? eSelectEndLine : amount), + eDirNext, needsStart, wordMovementType); NS_ENSURE_TRUE(endOffset >= 0, NS_ERROR_FAILURE); - if (finalEndOffset == aOffset) { + if (finalEndOffset == offset) { if (aType == eGetAt && amount == eSelectWord) { // Fix word error for the first character in word: PeekOffset() will return the previous word when - // aOffset points to the first character of the word, but accessibility APIs want the current word + // offset points to the first character of the word, but accessibility APIs want the current word // that the first character is in - return GetTextHelper(eGetAfter, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText); + return GetTextHelper(eGetAfter, aBoundaryType, offset, + aStartOffset, aEndOffset, aText); } int32_t textLength = CharacterCount(); if (finalEndOffset < textLength) { @@ -965,8 +953,8 @@ HyperTextAccessible::GetTextHelper(EGetTextType aType, AccessibleTextBoundary aB *aStartOffset = finalStartOffset; *aEndOffset = finalEndOffset; - NS_ASSERTION((finalStartOffset < aOffset && finalEndOffset >= aOffset) || aType != eGetBefore, "Incorrect results for GetTextHelper"); - NS_ASSERTION((finalStartOffset <= aOffset && finalEndOffset > aOffset) || aType == eGetBefore, "Incorrect results for GetTextHelper"); + NS_ASSERTION((finalStartOffset < offset && finalEndOffset >= offset) || aType != eGetBefore, "Incorrect results for GetTextHelper"); + NS_ASSERTION((finalStartOffset <= offset && finalEndOffset > offset) || aType == eGetBefore, "Incorrect results for GetTextHelper"); GetPosAndText(finalStartOffset, finalEndOffset, &aText); return NS_OK; @@ -981,12 +969,16 @@ HyperTextAccessible::GetTextBeforeOffset(int32_t aOffset, int32_t* aStartOffset, int32_t* aEndOffset, nsAString& aText) { + if (IsDefunct()) + return NS_ERROR_FAILURE; + if (aBoundaryType == BOUNDARY_CHAR) { GetCharAt(aOffset, eGetBefore, aText, aStartOffset, aEndOffset); return NS_OK; } - return GetTextHelper(eGetBefore, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText); + return GetTextHelper(eGetBefore, aBoundaryType, aOffset, + aStartOffset, aEndOffset, aText); } NS_IMETHODIMP @@ -995,24 +987,138 @@ HyperTextAccessible::GetTextAtOffset(int32_t aOffset, int32_t* aStartOffset, int32_t* aEndOffset, nsAString& aText) { - if (aBoundaryType == BOUNDARY_CHAR) { - GetCharAt(aOffset, eGetAt, aText, aStartOffset, aEndOffset); - return NS_OK; + if (IsDefunct()) + return NS_ERROR_FAILURE; + + nsSelectionAmount selectionAmount = eSelectWord; + EWordMovementType wordMovementType = eDefaultBehavior; + bool forwardBack = true; + + switch (aBoundaryType) { + case BOUNDARY_CHAR: + return GetCharAt(aOffset, eGetAt, aText, aStartOffset, aEndOffset) ? + NS_OK : NS_ERROR_INVALID_ARG; + + case BOUNDARY_WORD_START: + wordMovementType = eStartWord; + break; + + case BOUNDARY_WORD_END: + wordMovementType = eEndWord; + forwardBack = false; + break; + + case BOUNDARY_LINE_START: + case BOUNDARY_LINE_END: + return GetTextHelper(eGetAt, aBoundaryType, aOffset, + aStartOffset, aEndOffset, aText); + break; + + case BOUNDARY_ATTRIBUTE_RANGE: + { + nsresult rv = GetTextAttributes(false, aOffset, + aStartOffset, aEndOffset, nullptr); + NS_ENSURE_SUCCESS(rv, rv); + + return GetText(*aStartOffset, *aEndOffset, aText); + } + + default: + return NS_ERROR_INVALID_ARG; } - return GetTextHelper(eGetAt, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText); + int32_t offset = ConvertMagicOffset(aOffset); + if (offset < 0) + return NS_ERROR_INVALID_ARG; + + uint32_t textLen = CharacterCount(); + if (forwardBack) { + if (offset == textLen) { + *aStartOffset = *aEndOffset = textLen; + return NS_OK; + } + } else { + if (offset == 0) { + *aStartOffset = *aEndOffset = 0; + return NS_OK; + } + } + + // Convert offsets to frame-relative + int32_t startOffset = offset, endOffset = offset; + nsRefPtr startAcc; + nsIFrame* startFrame = GetPosAndText(startOffset, endOffset, nullptr, nullptr, + nullptr, getter_AddRefs(startAcc)); + if (!startFrame) { + if (offset == textLen) { + // Asking for start of line, while on last character + if (startAcc) + startFrame = startAcc->GetFrame(); + } + NS_ASSERTION(startFrame, "No start frame for text getting!"); + if (!startFrame) + return NS_ERROR_FAILURE; + + // We're on the last continuation since we're on the last character. + startFrame = startFrame->GetLastContinuation(); + } + + offset = GetRelativeOffset(mDoc->PresShell(), startFrame, startOffset, + startAcc, selectionAmount, + (forwardBack ? eDirNext : eDirPrevious), + forwardBack, wordMovementType); + + if (forwardBack) + *aEndOffset = offset; + else + *aStartOffset = offset; + + startOffset = endOffset = offset; + startFrame = GetPosAndText(startOffset, endOffset, nullptr, nullptr, + nullptr, getter_AddRefs(startAcc)); + if (!startFrame) { + if (offset == textLen) { + // Asking for start of line, while on last character + if (startAcc) + startFrame = startAcc->GetFrame(); + } + NS_ASSERTION(startFrame, "No start frame for text getting!"); + if (!startFrame) + return NS_ERROR_FAILURE; + + // We're on the last continuation since we're on the last character. + startFrame = startFrame->GetLastContinuation(); + } + + offset = GetRelativeOffset(mDoc->PresShell(), startFrame, startOffset, + startAcc, selectionAmount, + (forwardBack ? eDirPrevious : eDirNext), + forwardBack, wordMovementType); + + if (forwardBack) + *aStartOffset = offset; + else + *aEndOffset = offset; + + return GetText(*aStartOffset, *aEndOffset, aText); } NS_IMETHODIMP -HyperTextAccessible::GetTextAfterOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType, - int32_t* aStartOffset, int32_t* aEndOffset, nsAString& aText) +HyperTextAccessible::GetTextAfterOffset(int32_t aOffset, + AccessibleTextBoundary aBoundaryType, + int32_t* aStartOffset, + int32_t* aEndOffset, nsAString& aText) { + if (IsDefunct()) + return NS_ERROR_FAILURE; + if (aBoundaryType == BOUNDARY_CHAR) { GetCharAt(aOffset, eGetAfter, aText, aStartOffset, aEndOffset); return NS_OK; } - return GetTextHelper(eGetAfter, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText); + return GetTextHelper(eGetAfter, aBoundaryType, aOffset, + aStartOffset, aEndOffset, aText); } // nsIPersistentProperties diff --git a/accessible/src/generic/HyperTextAccessible.h b/accessible/src/generic/HyperTextAccessible.h index 6a2d13f65b6..ce8e6b343ba 100644 --- a/accessible/src/generic/HyperTextAccessible.h +++ b/accessible/src/generic/HyperTextAccessible.h @@ -294,7 +294,8 @@ protected: int32_t GetRelativeOffset(nsIPresShell *aPresShell, nsIFrame *aFromFrame, int32_t aFromOffset, Accessible* aFromAccessible, nsSelectionAmount aAmount, nsDirection aDirection, - bool aNeedsStart); + bool aNeedsStart, + EWordMovementType aWordMovementType); /** * Provides information for substring that is defined by the given start diff --git a/accessible/tests/mochitest/text.js b/accessible/tests/mochitest/text.js index f2eb0ff11bf..a3a0897fdc5 100644 --- a/accessible/tests/mochitest/text.js +++ b/accessible/tests/mochitest/text.js @@ -112,16 +112,29 @@ function testCharAtOffset(aIDs, aOffset, aChar, aStartOffset, aEndOffset) * @param aText [in] expected return text for getTextAtOffset * @param aStartOffset [in] expected return start offset for getTextAtOffset * @param aEndOffset [in] expected return end offset for getTextAtOffset - * @param ... [in] list of tuples made of: + * @param ... [in] list of ids or list of tuples made of: * element identifier * kTodo or kOk for returned text * kTodo or kOk for returned start offset * kTodo or kOk for returned offset result - * */ function testTextAtOffset(aOffset, aBoundaryType, aText, aStartOffset, aEndOffset) { + // List of IDs. + if (arguments[5] instanceof Array) { + var ids = arguments[5]; + for (var i = 0; i < ids.length; i++) { + var acc = getAccessible(ids[i], nsIAccessibleText); + testTextHelper(ids[i], aOffset, aBoundaryType, + aText, aStartOffset, aEndOffset, + kOk, kOk, kOk, + acc.getTextAtOffset, "getTextAtOffset "); + } + + return; + } + for (var i = 5; i < arguments.length; i = i + 4) { var ID = arguments[i]; var acc = getAccessible(ID, nsIAccessibleText); @@ -166,7 +179,7 @@ function testCharAfterOffset(aIDs, aOffset, aChar, aStartOffset, aEndOffset) * @param aText [in] expected return text for getTextAfterOffset * @param aStartOffset [in] expected return start offset for getTextAfterOffset * @param aEndOffset [in] expected return end offset for getTextAfterOffset - * @param ... [in] list of tuples made of: + * @param ... [in] list of ids or list of tuples made of: * element identifier * kTodo or kOk for returned text * kTodo or kOk for returned start offset @@ -175,6 +188,21 @@ function testCharAfterOffset(aIDs, aOffset, aChar, aStartOffset, aEndOffset) function testTextAfterOffset(aOffset, aBoundaryType, aText, aStartOffset, aEndOffset) { + // List of IDs. + if (arguments[5] instanceof Array) { + var ids = arguments[5]; + for (var i = 0; i < ids.length; i++) { + var acc = getAccessible(ids[i], nsIAccessibleText); + testTextHelper(ids[i], aOffset, aBoundaryType, + aText, aStartOffset, aEndOffset, + kOk, kOk, kOk, + acc.getTextAfterOffset, "getTextAfterOffset "); + } + + return; + } + + // List of tuples. for (var i = 5; i < arguments.length; i = i + 4) { var ID = arguments[i]; var acc = getAccessible(ID, nsIAccessibleText); @@ -219,16 +247,29 @@ function testCharBeforeOffset(aIDs, aOffset, aChar, aStartOffset, aEndOffset) * @param aText [in] expected return text for getTextBeforeOffset * @param aStartOffset [in] expected return start offset for getTextBeforeOffset * @param aEndOffset [in] expected return end offset for getTextBeforeOffset - * @param ... [in] list of tuples made of: + * @param ... [in] list of ids or list of tuples made of: * element identifier * kTodo or kOk for returned text * kTodo or kOk for returned start offset * kTodo or kOk for returned offset result - * */ function testTextBeforeOffset(aOffset, aBoundaryType, aText, aStartOffset, aEndOffset) { + // List of IDs. + if (arguments[5] instanceof Array) { + var ids = arguments[5]; + for (var i = 0; i < ids.length; i++) { + var acc = getAccessible(ids[i], nsIAccessibleText); + testTextHelper(ids[i], aOffset, aBoundaryType, + aText, aStartOffset, aEndOffset, + kOk, kOk, kOk, + acc.getTextBeforeOffset, "getTextBeforeOffset "); + } + + return; + } + for (var i = 5; i < arguments.length; i = i + 4) { var ID = arguments[i]; var acc = getAccessible(ID, nsIAccessibleText); @@ -267,8 +308,9 @@ function testWordCount(aElement, aCount, aToDoFlag) wordCount++; offset = endOffsetObj.value; } - isFunc(wordCount, aCount, "wrong words count for '" + acc.getText(0, -1) + "': " + - wordCount); + isFunc(wordCount, aCount, + "wrong words count for '" + acc.getText(0, -1) + "': " + wordCount + + " in " + prettyName(aElement)); } /** @@ -283,42 +325,47 @@ function testWordAt(aElement, aWordIndex, aText, aToDoFlag) { var isFunc = (aToDoFlag == kTodo) ? todo_is : is; var acc = getAccessible(aElement, nsIAccessibleText); - var startOffsetObj = {}, endOffsetObj = {}; - var length = acc.characterCount; - var offset = 0; - var wordIndex = -1; - var wordFountAtOffset = -1; - while (true) { - var text = acc.getTextAtOffset(offset, BOUNDARY_WORD_START, - startOffsetObj, endOffsetObj); - if (offset >= length) + + var textLength = acc.characterCount; + var wordIdx = aWordIndex; + var startOffsetObj = { value: 0 }, endOffsetObj = { value: 0 }; + for (offset = 0; offset < textLength; offset = endOffsetObj.value) { + acc.getTextAtOffset(offset, BOUNDARY_WORD_START, + startOffsetObj, endOffsetObj); + + wordIdx--; + if (wordIdx < 0) break; - - wordIndex++; - offset = endOffsetObj.value; - if (wordIndex == aWordIndex) { - wordFountAtOffset = startOffsetObj.value; - break; - } - } - if (wordFountAtOffset >= 0) { - var text = acc.getTextAtOffset(wordFountAtOffset, BOUNDARY_WORD_END, - startOffsetObj, endOffsetObj); - - if (endOffsetObj.value < wordFountAtOffset) { - todo(false, "wrong start and end offset for word '" + aWordIndex + "': " + - " of text '" + acc.getText(0, -1) + "'"); - return; - } - - text = acc.getText(wordFountAtOffset, endOffsetObj.value); - isFunc(text, aText, "wrong text for word at pos '" + aWordIndex + "': " + - " of text '" + acc.getText(0, -1) + "'"); } - else { - isFunc(false, "failed to find word " + aText + " at word pos " + aWordIndex + - " of text '" + acc.getText(0, -1) + "'"); + + if (wordIdx >= 0) { + ok(false, + "the given word index '" + aWordIndex + "' exceeds words amount in " + + prettyName(aElement)); + + return; } + + var startWordOffset = startOffsetObj.value; + var endWordOffset = endOffsetObj.value; + + // Calculate the end word offset. + acc.getTextAtOffset(endOffsetObj.value, BOUNDARY_WORD_END, + startOffsetObj, endOffsetObj); + if (startOffsetObj.value != textLength) + endWordOffset = startOffsetObj.value + + if (endWordOffset <= startWordOffset) { + todo(false, + "wrong start and end offset for word at index '" + aWordIndex + "': " + + " of text '" + acc.getText(0, -1) + "' in " + prettyName(aElement)); + + return; + } + + text = acc.getText(startWordOffset, endWordOffset); + isFunc(text, aText, "wrong text for word at index '" + aWordIndex + "': " + + " of text '" + acc.getText(0, -1) + "' in " + prettyName(aElement)); } /** @@ -463,26 +510,31 @@ function testTextHelper(aID, aOffset, aBoundaryType, var exceptionFlag = aToDoFlag1 == undefined || aToDoFlag2 == undefined || aToDoFlag3 == undefined; + + var startMsg = aTextFuncName + "(" + boundaryToString(aBoundaryType) + "): "; + var endMsg = ", id: " + prettyName(aID) + ";"; + try { var startOffsetObj = {}, endOffsetObj = {}; var text = aTextFunc(aOffset, aBoundaryType, startOffsetObj, endOffsetObj); - + + if (exceptionFlag) { + ok(false, startMsg + "no expected failure at offset " + aOffset + endMsg); + return; + } + var isFunc1 = (aToDoFlag1 == kTodo) ? todo_is : is; var isFunc2 = (aToDoFlag2 == kTodo) ? todo_is : is; var isFunc3 = (aToDoFlag3 == kTodo) ? todo_is : is; - var startMsg = aTextFuncName + "(" + boundaryToString(aBoundaryType) + "): "; - - var endMsg = ", id: '" + prettyName(aID) + "';"; - isFunc1(text, aText, startMsg + "wrong text, offset: " + aOffset + endMsg); isFunc2(startOffsetObj.value, aStartOffset, startMsg + "wrong start offset, offset: " + aOffset + endMsg); isFunc3(endOffsetObj.value, aEndOffset, startMsg + "wrong end offset, offset: " + aOffset + endMsg); - + } catch (e) { var okFunc = exceptionFlag ? todo : ok; okFunc(false, startMsg + "failed at offset " + aOffset + endMsg); diff --git a/accessible/tests/mochitest/text/test_atcaretoffset.html b/accessible/tests/mochitest/text/test_atcaretoffset.html index 09447d6d40f..33ba65e2b16 100644 --- a/accessible/tests/mochitest/text/test_atcaretoffset.html +++ b/accessible/tests/mochitest/text/test_atcaretoffset.html @@ -44,7 +44,7 @@ "textarea", kTodo, kOk, kTodo); testTextAfterOffset(kCaretOffset, BOUNDARY_LINE_END, "", 15, 15, - "textarea", kOk, kTodo, kTodo); + "textarea", kTodo, kOk, kTodo); testTextAtOffset(kCaretOffset, BOUNDARY_LINE_START, "", 15, 15, "textarea", kTodo, kTodo, kTodo); diff --git a/accessible/tests/mochitest/text/test_multiline.html b/accessible/tests/mochitest/text/test_multiline.html index 5137ac66ec9..b09a7f0f823 100644 --- a/accessible/tests/mochitest/text/test_multiline.html +++ b/accessible/tests/mochitest/text/test_multiline.html @@ -16,7 +16,7 @@ function doTest() { - SimpleTest.expectAssertions(52); + SimpleTest.expectAssertions(54); // __o__n__e__w__o__r__d__\n // 0 1 2 3 4 5 6 7 @@ -129,11 +129,11 @@ "editablebr", kTodo, kTodo, kOk, "textarea", kTodo, kTodo, kOk); testTextAfterOffset(19, BOUNDARY_LINE_START, "", 19, 19, - "div", undefined, undefined, undefined, - "divbr", undefined, undefined, undefined, - "editable", undefined, undefined, undefined, - "editablebr", undefined, undefined, undefined, - "textarea", kTodo, undefined, kTodo); + "div", kOk, kOk, kTodo, + "divbr", kOk, kOk, kOk, + "editable", kOk, kOk, kTodo, + "editablebr", kOk, kOk, kOk, + "textarea", kOk, kOk, kOk); // BOUNDARY_LINE_END testTextAfterOffset(0, BOUNDARY_LINE_END, "\n", 7, 8, @@ -161,11 +161,11 @@ "editablebr", kTodo, kTodo, kTodo, "textarea", kTodo, kTodo, kTodo); testTextAfterOffset(18, BOUNDARY_LINE_END, "\n", 18, 19, - "div", kTodo, kTodo, kTodo, - "divbr", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "editablebr", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + "div", kTodo, kOk, kTodo, + "divbr", kOk, kOk, kOk, + "editable", kTodo, kOk, kTodo, + "editablebr", kOk, kOk, kOk, + "textarea", kOk, kOk, kOk); testTextAfterOffset(19, BOUNDARY_LINE_END, "", 19, 19, "div", kOk, kTodo, kTodo, "divbr", kOk, kTodo, kTodo, @@ -391,31 +391,21 @@ "editablebr", kOk, kOk, kOk, "textarea", kTodo, kOk, kTodo); testTextAtOffset(8, BOUNDARY_WORD_START, "oneword\n\n", 0, 9, - "div", kTodo, kTodo, kOk, - "divbr", kOk, kOk, kOk, - "editable", kTodo, kTodo, kOk, - "editablebr", kOk, kOk, kOk, - "textarea", kTodo, kTodo, kOk); - testTextAtOffset(9, BOUNDARY_WORD_START, "two ", 9, 13, - "div", kTodo, kTodo, kTodo, - "divbr", kOk, kOk, kOk, - "editable", kTodo, kTodo, kTodo, - "editablebr", kOk, kOk, kOk, - "textarea", kTodo, kTodo, kTodo); - testTextAtOffset(13, BOUNDARY_WORD_START, "words\n", 13, 19, "div", kOk, kOk, kOk, - "divbr", kOk, kOk, kOk, + "divbr", kTodo, kTodo, kTodo, "editable", kOk, kOk, kOk, - "editablebr", kOk, kOk, kOk, + "editablebr", kTodo, kTodo, kTodo, "textarea", kOk, kOk, kOk); + testTextAtOffset(9, BOUNDARY_WORD_START, "two ", 9, 13, IDs); + testTextAtOffset(13, BOUNDARY_WORD_START, "words\n", 13, 19, IDs); // BOUNDARY_WORD_END testTextAtOffset(0, BOUNDARY_WORD_END, "oneword", 0, 7, - "div", kOk, kOk, kOk, - "divbr", kOk, kOk, kOk, - "editable", kOk, kOk, kOk, - "editablebr", kOk, kOk, kOk, - "textarea", kOk, kOk, kOk); + "div", kTodo, kOk, kTodo, + "divbr", kTodo, kOk, kTodo, + "editable", kTodo, kOk, kTodo, + "editablebr", kTodo, kOk, kTodo, + "textarea", kTodo, kOk, kTodo); testTextAtOffset(8, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, "div", kOk, kOk, kOk, "divbr", kTodo, kTodo, kTodo, @@ -429,11 +419,11 @@ "editablebr", kTodo, kTodo, kTodo, "textarea", kTodo, kTodo, kOk); testTextAtOffset(12, BOUNDARY_WORD_END, "\n\ntwo", 7, 12, - "div", kTodo, kTodo, kTodo, - "divbr", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "editablebr", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + "div", kTodo, kTodo, kOk, + "divbr", kOk, kOk, kOk, + "editable", kTodo, kTodo, kOk, + "editablebr", kOk, kOk, kOk, + "textarea", kTodo, kTodo, kOk); testTextAtOffset(13, BOUNDARY_WORD_END, " words", 12, 18, "div", kOk, kOk, kOk, "divbr", kOk, kOk, kOk, @@ -517,11 +507,11 @@ "editablebr", kOk, kOk, kOk, "textarea", kOk, kOk, kOk); testTextAtOffset(18, BOUNDARY_LINE_END, "\ntwo words", 8, 18, - "div", kTodo, kTodo, kTodo, - "divbr", kTodo, kTodo, kTodo, - "editable", kTodo, kTodo, kTodo, - "editablebr", kTodo, kTodo, kTodo, - "textarea", kTodo, kTodo, kTodo); + "div", kTodo, kOk, kTodo, + "divbr", kTodo, kOk, kTodo, + "editable", kTodo, kOk, kTodo, + "editablebr", kTodo, kOk, kTodo, + "textarea", kTodo, kOk, kTodo); testTextAtOffset(19, BOUNDARY_LINE_END, "\n", 18, 19, "div", kTodo, kTodo, kTodo, "divbr", kTodo, kTodo, kTodo, @@ -546,6 +536,7 @@

+
   
oneword two words diff --git a/accessible/tests/mochitest/text/test_singleline.html b/accessible/tests/mochitest/text/test_singleline.html index cfd6a0dcf35..b8f2cd39e73 100644 --- a/accessible/tests/mochitest/text/test_singleline.html +++ b/accessible/tests/mochitest/text/test_singleline.html @@ -12,9 +12,9 @@ src="../text.js">