Bug 1294392 - consolidate the highlight and counter timers into one iterator timer. r=jaws

This introduces a new NLP (Natural Language Processing) module with only one
method: 'levenstein'. We're using it to allow the highlighter to keep running
when the it starts the iterator with a word that's one edit distance behind the
value in the findField.

MozReview-Commit-ID: K8oeiXoiLUe
This commit is contained in:
Mike de Boer
2016-08-25 20:11:44 +02:00
parent ccee69ac4b
commit 7e1c629660
12 changed files with 302 additions and 133 deletions

View File

@@ -13,26 +13,29 @@ add_task(function* () {
let finder = tab.linkedBrowser.finder;
let listener = {
onFindResult: function () {
ok(false, "callback wasn't replaced");
ok(false, "onFindResult callback wasn't replaced");
},
onHighlightFinished: function () {
ok(false, "onHighlightFinished callback wasn't replaced");
}
};
finder.addResultListener(listener);
function waitForFind() {
function waitForFind(which = "onFindResult") {
return new Promise(resolve => {
listener.onFindResult = resolve;
listener[which] = resolve;
})
}
let promiseFind = waitForFind();
let promiseFind = waitForFind("onHighlightFinished");
finder.highlight(true, "content");
let findResult = yield promiseFind;
is(findResult.result, Ci.nsITypeAheadFind.FIND_FOUND, "should find string");
Assert.ok(findResult.found, "should find string");
promiseFind = waitForFind();
promiseFind = waitForFind("onHighlightFinished");
finder.highlight(true, "Bla");
findResult = yield promiseFind;
is(findResult.result, Ci.nsITypeAheadFind.FIND_NOTFOUND, "should not find string");
Assert.ok(!findResult.found, "should not find string");
// Search only for links and draw outlines.
promiseFind = waitForFind();