gecko-dev/editor/libeditor/tests/spellcheck.js
Ms2ger f1fc41b0e5 Bug 949614 - Use === for SimpleTest.is; r=Waldo
This is more likely to be correct, and a necessary step in case we ever want
to move to Object.is.

This keeps ise as an alias for is, and introduces is_loosely for the old
behaviour.
2015-04-14 15:28:13 +02:00

21 lines
594 B
JavaScript

function isSpellingCheckOk(aEditor, aMisspelledWords) {
var selcon = aEditor.selectionController;
var sel = selcon.getSelection(selcon.SELECTION_SPELLCHECK);
var numWords = sel.rangeCount;
is(numWords, aMisspelledWords.length, "Correct number of misspellings and words.");
if (numWords !== aMisspelledWords.length) {
return false;
}
for (var i = 0; i < numWords; ++i) {
var word = String(sel.getRangeAt(i));
is(word, aMisspelledWords[i], "Misspelling is what we think it is.");
if (word !== aMisspelledWords[i]) {
return false;
}
}
return true;
}