Fix failing PositionIteratorTests.

This commit is contained in:
Jos van den Oever
2012-10-03 15:28:01 +02:00
parent cc00097a5b
commit 3e3de5be29
3 changed files with 10 additions and 14 deletions
+5 -11
View File
@@ -160,18 +160,19 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter,
startNode = walker.currentNode,
n,
text,
prevText = false;
nextText = false;
if (currentPos === 1) {
n = walker.lastChild();
} else {
n = walker.previousSibling();
}
while (n) {
text = n.nodeType === 3;
if (!text || !prevText) { // neighboring texts count as 1 position
// neighboring texts count as 1 position
text = (n.nodeType === 3) ? n : null;
if (text === null || text.nextSibling !== nextText) {
c += 1;
}
prevText = text;
nextText = text;
n = walker.previousSibling();
}
walker.currentNode = startNode;
@@ -243,13 +244,6 @@ core.PositionIterator = function PositionIterator(root, whatToShow, filter,
} else {
currentPos = 0;
}
// jiggle the position to make sure it is at an allowed offset
if (self.nextPosition()) {
self.previousPosition();
}
if (self.previousPosition()) {
self.nextPosition();
}
return true;
};
/**
+1 -1
View File
@@ -216,7 +216,7 @@ core.PositionIteratorTests = function PositionIteratorTests(runner) {
}
function testPositions(count) {
var n = 0, i, it = t.iterator, ok = true;
while (it.nextPosition()) {
while (it.nextPosition() && n <= count) {
t.c1 = it.container();
t.o1 = it.offset();
it.setPosition(t.c1, t.o1);
+4 -2
View File
@@ -62,12 +62,14 @@ if (runtime.type() === "BrowserRuntime") {
// tests.push(core.CursorTests);
// tests.push(gui.XMLEditTests);
}
/*
tests = [];
if (runtime.getDOMImplementation() && runtime.parseXML("<a/>").createRange) {
// tests.push(core.PositionIteratorTests);
// tests.push(gui.SelectionMoverTests);
tests.push(core.PositionIteratorTests);
tests.push(gui.SelectionMoverTests);
tests.push(gui.AvatarTests);
}
*/
var tester = new core.UnitTester();
/**
* @param {!Array.<Function>} tests