function getMisspelledWords(editor) {
return editor.selectionController.getSelection(Ci.nsISelectionController.SELECTION_SPELLCHECK).toString();
}
var elem_de; var editor_de; varscript;
/** Test for Bug 1209414 **/
/*
* All we want to do in this test is change the spelling using a right-click and selection from the menu.
* This is necessary since all the other tests use setCurrentDictionaries() which doesn't reflect
* user behaviour.
*/
let { maybeOnSpellCheck, onSpellCheck } = SpecialPowers.ChromeUtils.importESModule( "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
);
var hunspell = Cc["@mozilla.org/spellchecker/engine;1"]
.getService(Ci.mozISpellCheckingEngine);
// Install de-DE dictionary.
let de_DE = dir.clone();
de_DE.append("de-DE");
hunspell.addDirectory(de_DE);
addMessageListener("hidepopup", function() { var state = contextMenu.state;
// Select Language from the menu. Take a look at
// toolkit/modules/InlineSpellChecker.sys.mjs to see how the menu works.
contextMenu.ownerDocument.getElementById("spell-check-dictionary-en-US")
.doCommand();
contextMenu.hidePopup();
return state;
});
addMessageListener("destroy", () => hunspell.removeDirectory(de_DE));
addMessageListener("contextMenu-not-null", () => contextMenu != null);
addMessageListener("de_DE-exists", () => de_DE.exists());
});
is(await script.sendQuery("contextMenu-not-null"), true, "Got context menu XUL");
is(await script.sendQuery("de_DE-exists"), true, "true expected (de_DE directory should exist)"); script.addMessageListener("popupshown", handlePopup);
maybeOnSpellCheck(elem_de, function() { var inlineSpellChecker = editor_de.getInlineSpellChecker(true); var spellchecker = inlineSpellChecker.spellChecker;
let currentDictionaries = spellchecker.getCurrentDictionaries();
// Check that the German dictionary is loaded and that the spell check has worked.
is(currentDictionaries.length, 1, "expected one dictionary");
is(currentDictionaries[0], "de-DE", "expected de-DE");
// eslint-disable-next-line no-useless-concat
is(getMisspelledWords(editor_de), "today" + "is" + "a" + "good" + "day", "some misspelled words expected: today is a good day");
// Focus again, just to be sure that the context-click won't trigger another spell check.
elem_de.focus();
// Make sure all spell checking action is done before right-click to select the en-US dictionary.
maybeOnSpellCheck(elem_de, function() {
synthesizeMouse(elem_de, 2, 2, { type: "contextmenu", button: 2 }, window);
});
});
});
async function handlePopup() { var state = await script.sendQuery("hidepopup");
is(state, "open", "checking if popup is open");
onSpellCheck(elem_de, async function() { var inlineSpellChecker = editor_de.getInlineSpellChecker(true); var spellchecker = inlineSpellChecker.spellChecker;
let currentDictionaries = spellchecker.getCurrentDictionaries();
// Check that the English dictionary is loaded and that the spell check has worked.
is(currentDictionaries.length, 2, "expected two dictionaries");
let dictionaryArray = Array.from(currentDictionaries);
ok(dictionaryArray.includes("de-DE"), "expected de-DE");
ok(dictionaryArray.includes("en-US"), "expected en-US");
is(getMisspelledWords(editor_de), "", "No misspelled words expected");
// Remove the fake de_DE dictionary again.
await script.sendQuery("destroy");
// This will clear the content preferences and reset "spellchecker.dictionary".
spellchecker.setCurrentDictionaries([]).then(() => {
SimpleTest.finish();
});
});
}
</script>
</pre>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.