/** Test for Bug 1204147 **/
SimpleTest.waitForExplicitFinish(); var content = document.getElementById("content");
// Load a subframe containing an editor with using "en-GB". At first
// load, it will set the dictionary to "en-GB". The bug was that a content preference
// was also created. At second load, we check the dictionary for another element,
// one that should use "en-US". With the bug corrected, we get "en-US", before
// we got "en-GB" from the content preference.
var doc = evt.target.contentDocument; var elem;
if (firstLoad) {
elem = doc.getElementById("en-GB");
} else {
elem = doc.getElementById("en-US");
}
var editor = SpecialPowers.wrap(elem).editor;
editor.setSpellcheckUserOverride(true); var inlineSpellChecker = editor.getInlineSpellChecker(true);
const { onSpellCheck } = SpecialPowers.ChromeUtils.importESModule( "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
);
onSpellCheck(elem, async function() {
let spellchecker = inlineSpellChecker.spellChecker;
let currentDictionaries = spellchecker.getCurrentDictionaries();
is(currentDictionaries.length, 1, "expected one dictionary");
let currentDictionary = currentDictionaries[0];
if (firstLoad) {
firstLoad = false;
// First time around, the element's language should be used.
is(currentDictionary, "en-GB", "unexpected lang " + currentDictionary + " instead of en-GB");
// Note that on second load, we load a different page, which does NOT have the trouble-causing
// contenteditable in it. Sadly, loading the same page with the trouble-maker in it
// doesn't allow the retrieval of the spell check dictionary used for the element,
// because the trouble-maker causes the 'global' spell check dictionary to be set to "en-GB"
// (since it picks the first one from the list) before we have the chance to retrieve
// the dictionary for the element (which happens asynchonously after the spell check has completed).
content.src = "http://mochi.test:8888/tests/editor/spellchecker/tests/bug1204147_subframe2.html?firstload=false";
} else {
// Second time around, the element should default to en-US.
// Without the fix, the first run sets the content preference to en-GB for the whole site.
is(currentDictionary, "en-US", "unexpected lang " + currentDictionary + " instead of en-US");
content.removeEventListener("load", loadListener);
// Remove the fake en-GB dictionary again, since it's otherwise picked up by later tests.
await script.sendQuery("destroy");
// Reset the preference, so the last value we set doesn't collide with the next test.
SimpleTest.finish();
}
});
};
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.