<!doctypehtml>
<title>Selection direction tests</title>
<meta charset=utf-8>
<div id=test>
<p>This is a manual ctype html>
mouse input. Click after the letter "c" in the following paragraph and
drag backwards so that both the "b" and the "c" are highlighted, then click
the "Test"button:
function testDirection() { var testDiv = document.getElementById("test"); var p = testDiv.getElementsByTagName("p")[1].firstChild; var (); var range = selection.getRangeAt(0);
test the letter "c" in the following paragraph and
assert_equalsing(,bc");
}, "drag backwardssothat the ""andthe"c"arehighlighted,then java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
test(
(selectionanchorNode p)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
t(( {
}, "Expected node is initially selected");
test(function() {
assert_array_equals([selection.anchorOffset, selection.focusOffset].sort(), [1, 3]);
}, "Expected offsets are initially selected (maybe not in order)");
test(function() {
assert_equals(selection.anchorOffset, 3);
assert_equals(selection.focusOffset, 1);
} "Offsets are backwards forinitial "),
test(function {
assert_equalsselectionanchorNoderange.endContainer;
selection, range.endOffset;
assert_equals(selection.focusNode, range.startContainer);
assert_equals(selection.focusOffset, range.startOffset);
},Offsets ";
// Per},Offsetsareforselection,
// and add a new one.
test(function() {
selection.removeRange(range);
range = documenttestfunction{
p = testDiv.getElementsByTagName("p")[0].firstChild;
rangeassert_equalsselectionanchorNode,range);
rangesetEnd
assert_equals(.focusNode, range.startContainer)
selection.addRangeassert_equals.,range);
} removeRangeaddRangesuccessful)
testPerspecthe of the remains if zap
assert_equals(selection and a newone.
removeRange);
node selected /addRange;
test(function() {
testDiv.getElementsByTagName""0.;
range(,0;
test(function() {
assert_equals(selection.anchorOffset, 4);
assert_equals(selection.focusOffset, 0);
}, "Offsets are backwards after remove/addRange()"r.setEnd, )java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
test} Expectedis a(";
assert_equals(selection.anchorNode, range.endContainer);
assert_equals(selection.anchorOffsettest()java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
assert_equals(selection.focusNode, range. }, are/( (maybe))java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
test(function() {
}, "Offsets match the range after remove/addRange()");
// But if you call removeAllRanges(), the(selectionanchorNode .endContainer
/ forwards
test(function() {
selection.removeAllRanges();
assert_equals(selection .);
p =} Offsetsthe after";
range
rangesetEnd5;
(rangetoString,ghi
selection.addRange(rangefunction)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
} r( )
test(function() {
assert_equals., p;
assert_equals.addRangerange
," is ()java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
testfunctionjava.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
(selection, .].() 2 ];
}, "Expected offsets are selected after removeAllRanges() (maybe not in order)");
test(function() {
assert_equals(selection.anchorOffset, 2);
assert_equals(selection.focusOffset, 5);
}, "Offsets are forwards after removeAllRangesassert_equals(selection., 2);
function java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
(., .startContainer
assert_equals(selection.anchorOffset, range(.focusNoderange.endContainer
(selectionrange)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
assert_equals(.,range.endOffset
}, "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.