Bug 1330912 - Part 4. Update some tests to wait updating dictionary. r?masayuki
Since Part 2 improves foucs performance, these tests will be failed because spellchecker works later. So using UpdateCurrentDictionary, dictionary is updated before test.
MozReview-Commit-ID: 69aC1rQd4LY
--- a/editor/libeditor/tests/test_bug1100966.html
+++ b/editor/libeditor/tests/test_bug1100966.html
@@ -25,41 +25,49 @@ fivee sixx<br>
/** Test for Bug 1100966 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("content");
div.focus();
synthesizeMouseAtCenter(div, {});
- synthesizeKey(" ", {});
- setTimeout(function() {
- synthesizeKey("a", {});
+ getSpellChecker().UpdateCurrentDictionary(() => {
+ synthesizeKey(" ", {});
setTimeout(function() {
- synthesizeKey("VK_BACK_SPACE", {});
+ synthesizeKey("a", {});
+ setTimeout(function() {
+ synthesizeKey("VK_BACK_SPACE", {});
- var sel = getSpellCheckSelection();
- is(sel.rangeCount, 2, "We should have two misspelled words");
- is(String(sel.getRangeAt(0)), "fivee", "Correct misspelled word");
- is(String(sel.getRangeAt(1)), "sixx", "Correct misspelled word");
+ var sel = getSpellCheckSelection();
+ is(sel.rangeCount, 2, "We should have two misspelled words");
+ is(String(sel.getRangeAt(0)), "fivee", "Correct misspelled word");
+ is(String(sel.getRangeAt(1)), "sixx", "Correct misspelled word");
- SimpleTest.finish();
+ SimpleTest.finish();
+ },0);
},0);
- },0);
-
+ });
});
-function getSpellCheckSelection() {
+function getEditor() {
var Ci = SpecialPowers.Ci;
var editingSession = SpecialPowers.wrap(window)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession);
- var editor = editingSession.getEditorForWindow(window);
- var selcon = editor.selectionController;
+ return editingSession.getEditorForWindow(window);
+}
+
+function getSpellChecker() {
+ return getEditor().getInlineSpellChecker(false).spellChecker;
+}
+
+function getSpellCheckSelection() {
+ var selcon = getEditor().selectionController;
return selcon.getSelection(selcon.SELECTION_SPELLCHECK);
}
</script>
</body>
</html>
--- a/editor/libeditor/tests/test_bug1154791.html
+++ b/editor/libeditor/tests/test_bug1154791.html
@@ -22,46 +22,54 @@ https://bugzilla.mozilla.org/show_bug.cg
<script class="testbody" type="application/javascript">
/** Test for Bug 1154791 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var div = document.getElementById("content");
div.focus();
- synthesizeMouseAtCenter(div, {});
- synthesizeKey("VK_LEFT", {});
- synthesizeKey("VK_LEFT", {});
+ getSpellChecker().UpdateCurrentDictionary(() => {
+ synthesizeMouseAtCenter(div, {});
+ synthesizeKey("VK_LEFT", {});
+ synthesizeKey("VK_LEFT", {});
- setTimeout(function() {
- synthesizeKey("VK_BACK_SPACE", {});
setTimeout(function() {
- synthesizeKey(" ", {});
-
+ synthesizeKey("VK_BACK_SPACE", {});
setTimeout(function() {
- var sel = getSpellCheckSelection();
- is(sel.rangeCount, 2, "We should have two misspelled words");
- is(String(sel.getRangeAt(0)), "thiss", "Correct misspelled word");
- is(String(sel.getRangeAt(1)), "onee", "Correct misspelled word");
+ synthesizeKey(" ", {});
- SimpleTest.finish();
+ setTimeout(function() {
+ var sel = getSpellCheckSelection();
+ is(sel.rangeCount, 2, "We should have two misspelled words");
+ is(String(sel.getRangeAt(0)), "thiss", "Correct misspelled word");
+ is(String(sel.getRangeAt(1)), "onee", "Correct misspelled word");
+
+ SimpleTest.finish();
+ },0);
},0);
},0);
- },0);
-
+ });
});
-function getSpellCheckSelection() {
+function getEditor() {
var Ci = SpecialPowers.Ci;
var editingSession = SpecialPowers.wrap(window)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIEditingSession);
- var editor = editingSession.getEditorForWindow(window);
- var selcon = editor.selectionController;
+ return editingSession.getEditorForWindow(window);
+}
+
+function getSpellChecker() {
+ return getEditor().getInlineSpellChecker(false).spellChecker;
+}
+
+function getSpellCheckSelection() {
+ var selcon = getEditor().selectionController;
return selcon.getSelection(selcon.SELECTION_SPELLCHECK);
}
</script>
</body>
</html>