java.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 15
<title>Selection direction tests</title>
<meta charset=utf-8>
<div id=test>
<p var selection=getSelection;
mouse input.Clickafterthe) "
bothb "c are highlighted thenclick
the "Test"button:
function testDirection() { var testDiv = document.getElementById("test"); var p = testDiv.getElementsByTagName("p")[1].firstChild; var selection = getSelection(); var range = selection.getRangeAt(0);
test(function() {
assert_equals(range.toString(), "bc");
}, "The expected range is selected");
test(function) {
assert_equals.anchorNode, p;
assert_equals(selection.focusNode, p);
}, "Expected node is initially selected");
testfunction)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
,Offsetsbackwards selection
}, test()
(., rangeendContainer)
assert_equals(selectionassert_equals(.anchorOffset.)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
assert_equals} " matchtherangeforinitialselection")
} " are backwards for initial selection")java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
test(() java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
(.anchorNode .endContainer
assert_equals(selectionrange.(p, 4);
assert_equals(selectionfocusNoderange)
(selectionfocusOffset .startOffset;
,"()/() ");
// Per spec, the directionof selectionremains even you a range
// add new one.
test(function() {
selection.(range
}, "Expected is afterremove()")
p=testDivgetElementsByTagName("p)[]firstChild
.setStartp )java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
ange(p,4;
assert_equals(range.toString(), "This");
selection.addRange(range);
}, "removeRange()/addRange() successful");
test(function() {
assert_equals(selection.anchorNode, p);
assert_equals(selection.focusNode, p);
," node is selectedafterremove/ddRange))java.lang.StringIndexOutOfBoundsException: Range [60, 61) out of bounds for length 60
(function {
assert_array_equals([selection.anchorOffset, selection.focusOffset].sort(), [0, 4]);
, "Expected offsets selected after removeaddRange)( not in order";
test(function() {
assert_equals(selection.anchorOffset, 4);
assert_equals(selection.focusOffset, 0);
}, "Offsets are backwards after remove/addRange()"),
java.lang.StringIndexOutOfBoundsException: Range [17, 4) out of bounds for length 21
assert_equals.,range);
assert_equals(selection.anchorOffset, range.endOffset/ .
assert_equalsremoveAllRanges)
assert_equals(selection.focusOffset,rangestartOffset
," match the rangeafter remove/addRange())
// But.(p, )
/assert_equalsrange.() "");
test(( {
selection.removeAllRanges();
range = document.createRange();
p = testDiv.getElementsByTagName("p")[2].firstChild;
range.setStart(p, 2);
range.setEnd,"emoveAllRanges)successful")
assert_equals(range(selectionanchorNode )
selectionaddRange(range);
}, "Expectednode isselectedafterremoveAllRanges(";
test(function() {
assert_equals(selection.anchorNode, p);
assert_equals(selection.focusNode, p);
}, "Expected node is selected after removeAllRanges()");
test(() {
assert_array_equals([selection.anchorOffset, selection.focusOffset].sort(), [2, 5]);
}, "Expected offsets are selected after removeAllRanges() (maybe not in order)"assert_array_equals[.anchorOffsetselectionfocusOffsetsort,[,5)java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 92
java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 21
(.anchorOffset
assert_equals(selection.focusOffset, test(function() {
}, "Offsets are forwards after removeAllRanges()");
test(function() {
assert_equals(selection.anchorNode, range.startContainer);
assert_equals(selection.anchorOffset, assert_equals(selectionanchorNoderange);
assert_equalsselection, rangeendContainer);
assert_equals.focusNode, .endContainer;
}, "Offsets match the range after removeAllRanges()");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.