зеркало из https://github.com/mozilla/gecko-dev.git
Bug 856270 - Update spell checking to use nsIContentPrefService2 (part 3: update other tests). r=ehsan
This commit is contained in:
Родитель
93d9483a6c
Коммит
8966c4d61e
|
@ -21,10 +21,11 @@ Browser context menu tests.
|
|||
/** Test for Login Manager: multiple login autocomplete. **/
|
||||
|
||||
SpecialPowers.Cu.import("resource://gre/modules/InlineSpellChecker.jsm", window);
|
||||
SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", window);
|
||||
|
||||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
function openContextMenuFor(element, shiftkey, shouldWaitForFocus) {
|
||||
function openContextMenuFor(element, shiftkey, waitForSpellCheck) {
|
||||
// Context menu should be closed before we open it again.
|
||||
is(SpecialPowers.wrap(contextMenu).state, "closed", "checking if popup is closed");
|
||||
|
||||
|
@ -39,8 +40,9 @@ function openContextMenuFor(element, shiftkey, shouldWaitForFocus) {
|
|||
var eventDetails = { type : "contextmenu", button : 2, shiftKey : shiftkey };
|
||||
synthesizeMouse(element, 2, 2, eventDetails, element.ownerDocument.defaultView);
|
||||
}
|
||||
if (shouldWaitForFocus)
|
||||
SimpleTest.executeSoon(actuallyOpenContextMenuFor);
|
||||
|
||||
if (waitForSpellCheck)
|
||||
onSpellCheck(element, actuallyOpenContextMenuFor);
|
||||
else
|
||||
actuallyOpenContextMenuFor();
|
||||
}
|
||||
|
@ -608,7 +610,7 @@ function runTest(testNum) {
|
|||
].concat(inspectItems));
|
||||
contextMenu.ownerDocument.getElementById("spell-undo-add-to-dictionary").doCommand(); // Undo add to dictionary
|
||||
closeContextMenu();
|
||||
openContextMenuFor(contenteditable);
|
||||
openContextMenuFor(contenteditable, false, true);
|
||||
break;
|
||||
|
||||
case 18:
|
||||
|
@ -633,7 +635,7 @@ function runTest(testNum) {
|
|||
].concat(inspectItems));
|
||||
|
||||
closeContextMenu();
|
||||
openContextMenuFor(inputspell); // Invoke context menu for next test.
|
||||
openContextMenuFor(inputspell, false, true); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 19:
|
||||
|
|
|
@ -20,28 +20,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=338427
|
|||
|
||||
/** Test for Bug 338427 **/
|
||||
function init() {
|
||||
Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
|
||||
|
||||
var textarea = document.getElementById("editor");
|
||||
var editor = textarea.editor;
|
||||
var spellchecker = editor.getInlineSpellChecker(true);
|
||||
spellchecker.enableRealTimeSpell = true;
|
||||
|
||||
var list = {}, count = {};
|
||||
spellchecker.spellChecker.GetDictionaryList(list, count);
|
||||
if (count.value === 0) {
|
||||
return; // no dictionary, no test possible
|
||||
}
|
||||
var lang = list.value[0];
|
||||
spellchecker.spellChecker.SetCurrentDictionary(lang);
|
||||
|
||||
textarea.addEventListener("focus", function() {
|
||||
var dictionary = "";
|
||||
try {
|
||||
dictionary = spellchecker.spellChecker.GetCurrentDictionary();
|
||||
} catch(e) {}
|
||||
is(dictionary, lang, "Unexpected spell check dictionary");
|
||||
SimpleTest.finish();
|
||||
}, false);
|
||||
textarea.focus();
|
||||
|
||||
onSpellCheck(textarea, function () {
|
||||
var list = {}, count = {};
|
||||
spellchecker.spellChecker.GetDictionaryList(list, count);
|
||||
ok(count.value > 0, "At least one dictionary should be present");
|
||||
|
||||
var lang = list.value[0];
|
||||
spellchecker.spellChecker.SetCurrentDictionary(lang);
|
||||
|
||||
onSpellCheck(textarea, function () {
|
||||
try {
|
||||
var dictionary =
|
||||
spellchecker.spellChecker.GetCurrentDictionary();
|
||||
} catch(e) {}
|
||||
is(dictionary, lang, "Unexpected spell check dictionary");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
|
|
@ -27,30 +27,33 @@ var content = document.getElementById('content');
|
|||
var firstLoad = true;
|
||||
|
||||
var loadListener = function(evt) {
|
||||
Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
|
||||
var doc = evt.target.contentDocument;
|
||||
var elem = doc.getElementById('textarea');
|
||||
var editor = elem.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor;
|
||||
editor.setSpellcheckUserOverride(true);
|
||||
var inlineSpellChecker = editor.getInlineSpellChecker(true);
|
||||
var spellchecker = inlineSpellChecker.spellChecker;
|
||||
var currentDictonary = "";
|
||||
try {
|
||||
currentDictonary = spellchecker.GetCurrentDictionary();
|
||||
} catch(e) {}
|
||||
|
||||
if (!currentDictonary) {
|
||||
spellchecker.SetCurrentDictionary('en-US');
|
||||
}
|
||||
onSpellCheck(elem, function () {
|
||||
var spellchecker = inlineSpellChecker.spellChecker;
|
||||
try {
|
||||
var currentDictonary = spellchecker.GetCurrentDictionary();
|
||||
} catch(e) {}
|
||||
|
||||
if (firstLoad) {
|
||||
firstLoad = false;
|
||||
is (currentDictonary, "", "unexpected lang " + currentDictonary);
|
||||
content.src = 'http://mochi.test:8888/tests/editor/composer/test/bug678842_subframe.html?firstload=false';
|
||||
} else {
|
||||
is (currentDictonary, "en-US", "unexpected lang " + currentDictonary + " instead of en-US");
|
||||
content.removeEventListener('load', loadListener, false);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
if (!currentDictonary) {
|
||||
spellchecker.SetCurrentDictionary('en-US');
|
||||
}
|
||||
|
||||
if (firstLoad) {
|
||||
firstLoad = false;
|
||||
is (currentDictonary, "", "unexpected lang " + currentDictonary);
|
||||
content.src = 'http://mochi.test:8888/tests/editor/composer/test/bug678842_subframe.html?firstload=false';
|
||||
} else {
|
||||
is (currentDictonary, "en-US", "unexpected lang " + currentDictonary + " instead of en-US");
|
||||
content.removeEventListener('load', loadListener, false);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
content.addEventListener('load', loadListener, false);
|
||||
|
|
|
@ -48,7 +48,9 @@ function runTest() {
|
|||
editDoc().body.innerHTML = "<div>errror and an other errror</div>";
|
||||
gMisspeltWords = ["errror", "errror"];
|
||||
editDoc().designMode = "on";
|
||||
setTimeout(function() { evalTest(); }, 0);
|
||||
|
||||
Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
|
||||
onSpellCheck(editDoc().documentElement, evalTest);
|
||||
}
|
||||
|
||||
function evalTest() {
|
||||
|
|
|
@ -59,17 +59,19 @@ function runTest() {
|
|||
gMisspeltWords = ["haz", "cheezburger"];
|
||||
var edit = document.getElementById("edit");
|
||||
edit.focus();
|
||||
SimpleTest.executeSoon(function() {
|
||||
is(isSpellingCheckOk(), true, "All misspellings before editing are accounted for.");
|
||||
|
||||
append(" becaz I'm a lolcat!");
|
||||
SimpleTest.executeSoon(function() {
|
||||
SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", window);
|
||||
onSpellCheck(edit, function () {
|
||||
is(isSpellingCheckOk(), true, "All misspellings before editing are accounted for.");
|
||||
|
||||
append(" becaz I'm a lolcat!");
|
||||
onSpellCheck(edit, function () {
|
||||
gMisspeltWords.push("becaz");
|
||||
gMisspeltWords.push("lolcat");
|
||||
is(isSpellingCheckOk(), true, "All misspellings after typing are accounted for.");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=596333
|
|||
const Ci = SpecialPowers.Ci;
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(function() SimpleTest.executeSoon(runTest));
|
||||
addLoadEvent(runTest);
|
||||
|
||||
var gMisspeltWords;
|
||||
|
||||
|
@ -71,42 +71,39 @@ function paste(str) {
|
|||
|
||||
function runOnFocus() {
|
||||
var edit = document.getElementById("edit");
|
||||
edit.removeEventListener("focus", runOnFocus, false);
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
gMisspeltWords = ["haz", "cheezburger"];
|
||||
is(isSpellingCheckOk(), true, "All misspellings before editing are accounted for.");
|
||||
append(" becaz I'm a lolcat!");
|
||||
SimpleTest.executeSoon(function() {
|
||||
gMisspeltWords.push("becaz");
|
||||
gMisspeltWords.push("lolcat");
|
||||
is(isSpellingCheckOk(), true, "All misspellings after typing are accounted for.");
|
||||
|
||||
// Now, type an invalid word, and instead of hitting "space" at the end, just blur
|
||||
// the textarea and see if the spell check after the blur event catches it.
|
||||
append(" workd");
|
||||
edit.blur();
|
||||
SimpleTest.executeSoon(function() {
|
||||
gMisspeltWords.push("workd");
|
||||
is(isSpellingCheckOk(), true, "All misspellings after blur are accounted for.");
|
||||
gMisspeltWords = ["haz", "cheezburger"];
|
||||
is(isSpellingCheckOk(), true, "All misspellings before editing are accounted for.");
|
||||
append(" becaz I'm a lolcat!");
|
||||
onSpellCheck(edit, function () {
|
||||
gMisspeltWords.push("becaz");
|
||||
gMisspeltWords.push("lolcat");
|
||||
is(isSpellingCheckOk(), true, "All misspellings after typing are accounted for.");
|
||||
|
||||
// Also, test the case when we're entering the first word in a textarea
|
||||
// Now, type an invalid word, and instead of hitting "space" at the end, just blur
|
||||
// the textarea and see if the spell check after the blur event catches it.
|
||||
append(" workd");
|
||||
edit.blur();
|
||||
onSpellCheck(edit, function () {
|
||||
gMisspeltWords.push("workd");
|
||||
is(isSpellingCheckOk(), true, "All misspellings after blur are accounted for.");
|
||||
|
||||
// Also, test the case when we're entering the first word in a textarea
|
||||
gMisspeltWords = ["workd"];
|
||||
edit.value = "";
|
||||
append("workd ");
|
||||
onSpellCheck(edit, function () {
|
||||
is(isSpellingCheckOk(), true, "Misspelling in the first entered word is accounted for.");
|
||||
|
||||
// Make sure that pasting would also trigger spell checking for the previous word
|
||||
gMisspeltWords = ["workd"];
|
||||
edit.value = "";
|
||||
append("workd ");
|
||||
SimpleTest.executeSoon(function() {
|
||||
is(isSpellingCheckOk(), true, "Misspelling in the first entered word is accounted for.");
|
||||
append("workd");
|
||||
paste(" x");
|
||||
onSpellCheck(edit, function () {
|
||||
is(isSpellingCheckOk(), true, "Misspelling is accounted for after pasting.");
|
||||
|
||||
// Make sure that pasting would also trigger spell checking for the previous word
|
||||
gMisspeltWords = ["workd"];
|
||||
edit.value = "";
|
||||
append("workd");
|
||||
paste(" x");
|
||||
SimpleTest.executeSoon(function() {
|
||||
is(isSpellingCheckOk(), true, "Misspelling is accounted for after pasting.");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -116,8 +113,10 @@ function runOnFocus() {
|
|||
function runTest()
|
||||
{
|
||||
var edit = document.getElementById("edit");
|
||||
edit.addEventListener("focus", runOnFocus, false);
|
||||
edit.focus();
|
||||
|
||||
SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", window);
|
||||
onSpellCheck(edit, runOnFocus);
|
||||
}
|
||||
|
||||
function isSpellingCheckOk() {
|
||||
|
|
|
@ -30,42 +30,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=636465
|
|||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
|
||||
var x = document.getElementById("x");
|
||||
x.focus();
|
||||
setTimeout(function(){
|
||||
onSpellCheck(x, function () {
|
||||
x.blur();
|
||||
setTimeout(function(){
|
||||
var spellCheckTrue = snapshotWindow(window);
|
||||
x.setAttribute("spellcheck", "false");
|
||||
setTimeout(function(){
|
||||
setTimeout(function(){
|
||||
var spellCheckFalse = snapshotWindow(window);
|
||||
x.setAttribute("spellcheck", "true");
|
||||
x.focus();
|
||||
setTimeout(function(){
|
||||
x.blur();
|
||||
setTimeout(function(){
|
||||
var spellCheckTrueAgain = snapshotWindow(window);
|
||||
x.removeAttribute("spellcheck");
|
||||
setTimeout(function(){
|
||||
setTimeout(function(){
|
||||
var spellCheckNone = snapshotWindow(window);
|
||||
var after = snapshotWindow(window);
|
||||
ok(compareSnapshots(spellCheckTrue, spellCheckFalse, false)[0],
|
||||
"Setting the spellcheck attribute to false should work");
|
||||
ok(compareSnapshots(spellCheckTrue, spellCheckTrueAgain, true)[0],
|
||||
"Setting the spellcheck attribute back to true should work");
|
||||
ok(compareSnapshots(spellCheckNone, spellCheckFalse, true)[0],
|
||||
"Unsetting the spellcheck attribute should work");
|
||||
SimpleTest.finish();
|
||||
},0);
|
||||
},0);
|
||||
},0);
|
||||
},0);
|
||||
},0);
|
||||
},0);
|
||||
},0);
|
||||
},0);
|
||||
var spellCheckTrue = snapshotWindow(window);
|
||||
x.setAttribute("spellcheck", "false");
|
||||
var spellCheckFalse = snapshotWindow(window);
|
||||
x.setAttribute("spellcheck", "true");
|
||||
x.focus();
|
||||
onSpellCheck(x, function () {
|
||||
x.blur();
|
||||
var spellCheckTrueAgain = snapshotWindow(window);
|
||||
x.removeAttribute("spellcheck");
|
||||
var spellCheckNone = snapshotWindow(window);
|
||||
var after = snapshotWindow(window);
|
||||
ok(compareSnapshots(spellCheckTrue, spellCheckFalse, false)[0],
|
||||
"Setting the spellcheck attribute to false should work");
|
||||
ok(compareSnapshots(spellCheckTrue, spellCheckTrueAgain, true)[0],
|
||||
"Setting the spellcheck attribute back to true should work");
|
||||
ok(compareSnapshots(spellCheckNone, spellCheckFalse, true)[0],
|
||||
"Unsetting the spellcheck attribute should work");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
|
|
@ -64,44 +64,50 @@ function RunTest() {
|
|||
ok(map.exists());
|
||||
hunspell.addDirectory(map);
|
||||
|
||||
// test that base and map dictionaries are available
|
||||
var dicts = getDictionaryList(editor);
|
||||
isnot(dicts.indexOf("base_utf"), -1, "base is available");
|
||||
isnot(dicts.indexOf("maputf"), -1, "map is available");
|
||||
Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
|
||||
onSpellCheck(textbox, function () {
|
||||
|
||||
// select base dictionary
|
||||
setCurrentDictionary(editor, "base_utf");
|
||||
// test that base and map dictionaries are available
|
||||
var dicts = getDictionaryList(editor);
|
||||
isnot(dicts.indexOf("base_utf"), -1, "base is available");
|
||||
isnot(dicts.indexOf("maputf"), -1, "map is available");
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
// test that base dictionary is in use
|
||||
is(getMisspelledWords(editor), "Frühstück" + "qwertyu", "base misspellings");
|
||||
is(getCurrentDictionary(editor), "base_utf", "current dictionary");
|
||||
// select base dictionary
|
||||
setCurrentDictionary(editor, "base_utf");
|
||||
|
||||
// select map dictionary
|
||||
setCurrentDictionary(editor, "maputf");
|
||||
onSpellCheck(textbox, function () {
|
||||
// test that base dictionary is in use
|
||||
is(getMisspelledWords(editor), "Frühstück" + "qwertyu", "base misspellings");
|
||||
is(getCurrentDictionary(editor), "base_utf", "current dictionary");
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
// test that map dictionary is in use
|
||||
is(getMisspelledWords(editor), "created" + "imply" + "tomorrow" + "qwertyu", "map misspellings");
|
||||
is(getCurrentDictionary(editor), "maputf", "current dictionary");
|
||||
// select map dictionary
|
||||
setCurrentDictionary(editor, "maputf");
|
||||
|
||||
// uninstall map dictionary
|
||||
hunspell.removeDirectory(map);
|
||||
onSpellCheck(textbox, function () {
|
||||
// test that map dictionary is in use
|
||||
is(getMisspelledWords(editor), "created" + "imply" + "tomorrow" + "qwertyu", "map misspellings");
|
||||
is(getCurrentDictionary(editor), "maputf", "current dictionary");
|
||||
|
||||
SimpleTest.executeSoon(function() {
|
||||
// test that map dictionary is not in use
|
||||
isnot(getMisspelledWords(editor), "created" + "imply" + "tomorrow" + "qwertyu", "map misspellings");
|
||||
isnot(getCurrentDictionary(editor), "maputf", "current dictionary");
|
||||
// uninstall map dictionary
|
||||
hunspell.removeDirectory(map);
|
||||
|
||||
// test that base dictionary is available and map dictionary is unavailable
|
||||
var dicts = getDictionaryList(editor);
|
||||
isnot(dicts.indexOf("base_utf"), -1, "base is available");
|
||||
is(dicts.indexOf("maputf"), -1, "map is unavailable");
|
||||
onSpellCheck(textbox, function () {
|
||||
// test that map dictionary is not in use
|
||||
isnot(getMisspelledWords(editor), "created" + "imply" + "tomorrow" + "qwertyu", "map misspellings");
|
||||
isnot(getCurrentDictionary(editor), "maputf", "current dictionary");
|
||||
|
||||
// uninstall base dictionary
|
||||
hunspell.removeDirectory(base);
|
||||
// test that base dictionary is available and map dictionary is unavailable
|
||||
var dicts = getDictionaryList(editor);
|
||||
isnot(dicts.indexOf("base_utf"), -1, "base is available");
|
||||
is(dicts.indexOf("maputf"), -1, "map is unavailable");
|
||||
|
||||
SimpleTest.finish();
|
||||
// uninstall base dictionary
|
||||
hunspell.removeDirectory(base);
|
||||
|
||||
onSpellCheck(textbox, function () {
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -40,7 +40,10 @@ function startTests()
|
|||
textbox.focus();
|
||||
testNum = 0;
|
||||
|
||||
SimpleTest.executeSoon( function() { bringUpContextMenu(textbox); });
|
||||
Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
|
||||
onSpellCheck(textbox, function () {
|
||||
bringUpContextMenu(textbox);
|
||||
});
|
||||
}
|
||||
|
||||
function runContextMenuTest()
|
||||
|
@ -65,7 +68,9 @@ function runContextMenuTest()
|
|||
contextMenu.hidePopup();
|
||||
testNum++;
|
||||
|
||||
SimpleTest.executeSoon( function() {bringUpContextMenu(textbox); }); // Bring up the menu again to invoke the next test
|
||||
onSpellCheck(textbox, function () {
|
||||
bringUpContextMenu(textbox);
|
||||
});
|
||||
break;
|
||||
|
||||
case 1: // "Undo Add to Dictionary" button
|
||||
|
@ -78,7 +83,9 @@ function runContextMenuTest()
|
|||
undoAddDict.doCommand();
|
||||
|
||||
contextMenu.hidePopup();
|
||||
SimpleTest.finish();
|
||||
onSpellCheck(textbox, function () {
|
||||
SimpleTest.finish();
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче