summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/spellcheck.js
blob: 9d36c32544c811119abbc73bdfbcdf5670d69ce1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
}