Bug 452769 - mochitest for nsIAccessibleText, r=surkov, davidb, a=test

This commit is contained in:
Fernando Herrera 2010-11-12 18:05:57 -05:00
Родитель cbca4a2351
Коммит c0372f7cec
4 изменённых файлов: 809 добавлений и 0 удалений

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

@ -51,6 +51,7 @@ DIRS = \
selectable \
states \
table \
text \
tree \
treeupdate \
$(null)
@ -121,6 +122,7 @@ _TEST_FILES =\
test_value.html \
test_value.xul \
testTextboxes.js \
text.js \
treeview.css \
treeview.js \
$(NULL)

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

@ -0,0 +1,180 @@
////////////////////////////////////////////////////////////////////////////////
// Public
const BOUNDARY_CHAR = nsIAccessibleText.BOUNDARY_CHAR;
const BOUNDARY_WORD_START = nsIAccessibleText.BOUNDARY_WORD_START;
const BOUNDARY_WORD_END = nsIAccessibleText.BOUNDARY_WORD_END;
const BOUNDARY_LINE_START = nsIAccessibleText.BOUNDARY_LINE_START;
const BOUNDARY_LINE_END = nsIAccessibleText.BOUNDARY_LINE_END;
const BOUNDARY_ATTRIBUTE_RANGE = nsIAccessibleText.BOUNDARY_ATTRIBUTE_RANGE;
const kTodo = 1;
const kOk = 2;
function testText(aIDs, aStartOffset, aEndOffset, aText)
{
for (var i = 0; i < aIDs.length; i++)
{
var acc = getAccessible(aIDs[i], nsIAccessibleText);
try {
is(acc.getText(aStartOffset, aEndOffset), aText,
"getText: wrong text between start and end offsets '" + aStartOffset +
"', '" + aEndOffset + " for '" + prettyName(aIDs[i]) + "'");
} catch (e) {
ok(false,
"getText fails between start and end offsets '" + aStartOffset +
"', '" + aEndOffset + " for '" + prettyName(aIDs[i]) + "'");
}
}
}
/**
* Test getTextAtOffset function over different elements
*
* @param aOffset [in] the offset to get the text at
* @param aBoundaryType [in] Boundary type for text to be retrieved
* @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:
* 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)
{
for (var i = 5; i < arguments.length; i = i + 4) {
var ID = arguments[i];
var acc = getAccessible(ID, nsIAccessibleText);
var toDoFlag1 = arguments[i + 1];
var toDoFlag2 = arguments[i + 2];
var toDoFlag3 = arguments[i + 3];
testTextHelper(ID, aOffset, aBoundaryType,
aText, aStartOffset, aEndOffset,
toDoFlag1, toDoFlag2, toDoFlag3,
acc.getTextAtOffset, "getTextAtOffset ");
}
}
/**
* Test getTextAfterOffset function over different elements
*
* @param aOffset [in] the offset to get the text after
* @param aBoundaryType [in] Boundary type for text to be retrieved
* @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:
* element identifier
* kTodo or kOk for returned text
* kTodo or kOk for returned start offset
* kTodo or kOk for returned offset result
*
*/
function testTextAfterOffset(aOffset, aBoundaryType,
aText, aStartOffset, aEndOffset)
{
for (var i = 5; i < arguments.length; i = i + 4) {
var ID = arguments[i];
var acc = getAccessible(ID, nsIAccessibleText);
var toDoFlag1 = arguments[i + 1];
var toDoFlag2 = arguments[i + 2];
var toDoFlag3 = arguments[i + 3];
testTextHelper(ID, aOffset, aBoundaryType,
aText, aStartOffset, aEndOffset,
toDoFlag1, toDoFlag2, toDoFlag3,
acc.getTextAfterOffset, "getTextAfterOffset ");
}
}
/**
* Test getTextBeforeOffset function over different elements
*
* @param aOffset [in] the offset to get the text before
* @param aBoundaryType [in] Boundary type for text to be retrieved
* @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:
* 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)
{
for (var i = 5; i < arguments.length; i = i + 4) {
var ID = arguments[i];
var acc = getAccessible(ID, nsIAccessibleText);
var toDoFlag1 = arguments[i + 1];
var toDoFlag2 = arguments[i + 2];
var toDoFlag3 = arguments[i + 3];
testTextHelper(ID, aOffset, aBoundaryType,
aText, aStartOffset, aEndOffset,
toDoFlag1, toDoFlag2, toDoFlag3,
acc.getTextBeforeOffset, "getTextBeforeOffset ");
}
}
////////////////////////////////////////////////////////////////////////////////
// Private
function testTextHelper(aID, aOffset, aBoundaryType,
aText, aStartOffset, aEndOffset,
aToDoFlag1, aToDoFlag2, aToDoFlag3,
aTextFunc, aTextFuncName)
{
var exceptionFlag = aToDoFlag1 == undefined ||
aToDoFlag2 == undefined ||
aToDoFlag3 == undefined;
try {
var startOffsetObj = {}, endOffsetObj = {};
var text = aTextFunc(aOffset, aBoundaryType,
startOffsetObj, endOffsetObj);
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);
}
}
function boundaryToString(aBoundaryType)
{
switch (aBoundaryType) {
case BOUNDARY_CHAR:
return "char";
case BOUNDARY_WORD_START:
return "word start";
case BOUNDARY_WORD_END:
return "word end";
case BOUNDARY_LINE_START:
return "line start";
case BOUNDARY_LINE_END:
return "line end";
case BOUNDARY_ATTRIBUTE_RANGE:
return "attr range";
}
}

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

@ -0,0 +1,53 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Fernando Herrera <fherrera@onirica.com> (original author)
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible/text
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_singleline.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)

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

@ -0,0 +1,574 @@
<!DOCTYPE html>
<html>
<head>
<title>nsIAccessibleText getText related function tests for html:input,html:div and html:textarea</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../text.js"></script>
<script type="application/javascript">
function doTest()
{
var IDs = ["input", "div", "textarea"];
// __h__e__l__l__o__ __m__y__ __f__r__i__e__n__d__
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
////////////////////////////////////////////////////////////////////////
// getText
testText(IDs, 0, 1, "h");
testText(IDs, 1, 3, "el");
testText(IDs, 14, 15, "d");
testText(IDs, 0, 15, "hello my friend");
////////////////////////////////////////////////////////////////////////
// getTextAfterOffset
// BOUNDARY_CHAR
testTextAfterOffset(0, BOUNDARY_CHAR, "e", 1, 2,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(1, BOUNDARY_CHAR, "l", 2, 3,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(14, BOUNDARY_CHAR, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(15, BOUNDARY_CHAR, "", 15, 15,
"input", kOk, kTodo, kTodo,
"div", kOk, kTodo, kTodo,
"editable", kOk, kTodo, kTodo,
"textarea", kTodo, kOk, kTodo);
// BOUNDARY_WORD_START
testTextAfterOffset(0, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(1, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(5, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(6, BOUNDARY_WORD_START, "friend", 9, 15,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(7, BOUNDARY_WORD_START, "friend", 9, 15,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(8, BOUNDARY_WORD_START, "friend", 9, 15,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(9, BOUNDARY_WORD_START, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(11, BOUNDARY_WORD_START, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(14, BOUNDARY_WORD_START, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(15, BOUNDARY_WORD_START, "", 15, 15,
"input", kOk, kTodo, kTodo,
"div", kOk, kTodo, kTodo,
"editable", kOk, kTodo, kTodo,
"textarea", kTodo, kOk, kTodo);
// BOUNDARY_WORD_END
testTextAfterOffset(0, BOUNDARY_WORD_END, " my", 5, 8,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(1, BOUNDARY_WORD_END, " my", 5, 8,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(5, BOUNDARY_WORD_END, " my", 5, 8,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAfterOffset(6, BOUNDARY_WORD_END, " friend", 8, 15,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(7, BOUNDARY_WORD_END, " friend", 8, 15,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(8, BOUNDARY_WORD_END, " friend", 8, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAfterOffset(9, BOUNDARY_WORD_END, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(11, BOUNDARY_WORD_END, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(14, BOUNDARY_WORD_END, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(15, BOUNDARY_WORD_END, "", 15, 15,
"input", kOk, kTodo, kTodo,
"div", kOk, kTodo, kTodo,
"editable", kOk, kTodo, kTodo,
"textarea", kTodo, kOk, kTodo);
// BOUNDARY_LINE_START
testTextAfterOffset(0, BOUNDARY_LINE_START, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(1, BOUNDARY_LINE_START, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(14, BOUNDARY_LINE_START, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kTodo);
testTextAfterOffset(15, BOUNDARY_LINE_START, "", 15, 15,
"input", undefined, undefined, undefined,
"div", undefined, undefined, undefined,
"editable", undefined, undefined, undefined,
"textarea", kTodo, undefined, kTodo);
// BOUNDARY_LINE_END
testTextAfterOffset(0, BOUNDARY_LINE_END, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(1, BOUNDARY_LINE_END, "", 15, 15,
"input", kTodo, kTodo, kOk,
"div", kTodo, kTodo, kOk,
"editable", kTodo, kTodo, kOk,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(14, BOUNDARY_LINE_END, "", 15, 15,
"input", kOk, kTodo, kTodo,
"div", kOk, kTodo, kTodo,
"editable", kOk, kTodo, kTodo,
"textarea", kTodo, kTodo, kOk);
testTextAfterOffset(15, BOUNDARY_LINE_END, "", 15, 15,
"input", kOk, kTodo, kTodo,
"div", kOk, kTodo, kTodo,
"editable", kOk, kTodo, kTodo,
"textarea", kOk, kTodo, kTodo);
////////////////////////////////////////////////////////////////////////
// getTextBeforeOffset
// BOUNDARY_CHAR
testTextBeforeOffset(0, BOUNDARY_CHAR, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(1, BOUNDARY_CHAR, "h", 0, 1,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(14, BOUNDARY_CHAR, "n", 13, 14,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(15, BOUNDARY_CHAR, "d", 14, 15,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kOk, kTodo);
// BOUNDARY_WORD_START
testTextBeforeOffset(0, BOUNDARY_WORD_START, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(1, BOUNDARY_WORD_START, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(5, BOUNDARY_WORD_START, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(6, BOUNDARY_WORD_START, "hello ", 0, 6,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(7, BOUNDARY_WORD_START, "hello ", 0, 6,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(8, BOUNDARY_WORD_START, "hello ", 0, 6,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(9, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(10, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(14, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(15, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
// BOUNDARY_WORD_END
testTextBeforeOffset(0, BOUNDARY_WORD_END, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(1, BOUNDARY_WORD_END, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(5, BOUNDARY_WORD_END, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(6, BOUNDARY_WORD_END, "hello ", 0, 6,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(7, BOUNDARY_WORD_END, "hello ", 0, 6,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(8, BOUNDARY_WORD_END, "hello ", 0, 6,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(9, BOUNDARY_WORD_END, " my", 5, 8,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(10, BOUNDARY_WORD_END, " my", 5, 8,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(14, BOUNDARY_WORD_END, " my", 5, 8,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextBeforeOffset(15, BOUNDARY_WORD_END, " my", 5, 8,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
// BOUNDARY_LINE_START
testTextBeforeOffset(0, BOUNDARY_LINE_START, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(1, BOUNDARY_LINE_START, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(14, BOUNDARY_LINE_START, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(15, BOUNDARY_LINE_START, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
// BOUNDARY_LINE_END
testTextBeforeOffset(0, BOUNDARY_LINE_END, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(1, BOUNDARY_LINE_END, "", 0, 0,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(14, BOUNDARY_LINE_END, "", 0, 0,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kTodo, kOk, kTodo);
testTextBeforeOffset(15, BOUNDARY_LINE_END, "", 0, 0,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
////////////////////////////////////////////////////////////////////////
// getTextAtOffset
// BOUNDARY_CHAR
testTextAtOffset(0, BOUNDARY_CHAR, "h", 0, 1,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(1, BOUNDARY_CHAR, "e", 1, 2,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(14, BOUNDARY_CHAR, "d", 14, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(15, BOUNDARY_CHAR, "", 15, 15,
"input", kOk, kTodo, kTodo,
"div", kOk, kTodo, kTodo,
"editable", kOk, kTodo, kTodo,
"textarea", kTodo, kOk, kTodo);
// BOUNDARY_WORD_START
testTextAtOffset(0, BOUNDARY_WORD_START, "hello ", 0, 6,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(1, BOUNDARY_WORD_START, "hello ", 0, 6,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(5, BOUNDARY_WORD_START, "hello ", 0, 6,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(6, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(7, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(8, BOUNDARY_WORD_START, "my ", 6, 9,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(9, BOUNDARY_WORD_START, "friend", 9, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(10, BOUNDARY_WORD_START, "friend", 9, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(14, BOUNDARY_WORD_START, "friend", 9, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(15, BOUNDARY_WORD_START, "friend", 9, 15,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
// BOUNDARY_WORD_END
testTextAtOffset(0, BOUNDARY_WORD_END, "hello", 0, 5,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(1, BOUNDARY_WORD_END, "hello", 0, 5,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(5, BOUNDARY_WORD_END, "hello", 0, 5,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAtOffset(6, BOUNDARY_WORD_END, " my", 5, 8,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(7, BOUNDARY_WORD_END, " my", 5, 8,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(8, BOUNDARY_WORD_END, " my", 5, 8,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
testTextAtOffset(9, BOUNDARY_WORD_END, " friend", 8, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(10, BOUNDARY_WORD_END, " friend", 8, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(14, BOUNDARY_WORD_END, " friend", 8, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(15, BOUNDARY_WORD_END, " friend", 8, 15,
"input", kTodo, kTodo, kTodo,
"div", kTodo, kTodo, kTodo,
"editable", kTodo, kTodo, kTodo,
"textarea", kTodo, kTodo, kTodo);
// BOUNDARY_LINE_START
testTextAtOffset(0, BOUNDARY_LINE_START, "hello my friend", 0, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kTodo, kOk, kTodo);
testTextAtOffset(1, BOUNDARY_LINE_START, "hello my friend", 0, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kTodo, kOk, kTodo);
testTextAtOffset(14, BOUNDARY_LINE_START, "hello my friend", 0, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kTodo, kOk, kTodo);
testTextAtOffset(15, BOUNDARY_LINE_START, "hello my friend", 0, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kTodo, kOk, kTodo);
// BOUNDARY_LINE_END
testTextAtOffset(0, BOUNDARY_LINE_END, "hello my friend", 0, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(1, BOUNDARY_LINE_END, "hello my friend", 0, 15,
"input", kOk, kOk, kOk,
"div", kOk, kOk, kOk,
"editable", kOk, kOk, kOk,
"textarea", kOk, kOk, kOk);
testTextAtOffset(14, BOUNDARY_LINE_END, "hello my friend", 0, 15,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kOk, kOk, kOk);
testTextAtOffset(15, BOUNDARY_LINE_END, "hello my friend", 0, 15,
"input", kTodo, kOk, kTodo,
"div", kTodo, kOk, kTodo,
"editable", kTodo, kOk, kTodo,
"textarea", kTodo, kOk, kTodo);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="nsIAccessibleText getText related function tests for html:input,html:div and html:textarea"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=452769">Mozilla Bug 452769</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<input id="input" value="hello my friend"/>
<div id="div">hello my friend</div>
<div id="editable" contenteditable="true">hello my friend</div>
<textarea id="textarea">hello my friend</textarea>
</body>
</html>