Bug 1330912 - Part 4. Update some tests to wait updating dictionary. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 10 Apr 2017 14:44:49 +0900
changeset 560174 8f8a5e5a29ea64bf19dc9e8eb7b8e7652f14de95
parent 560173 78726a55b49859593e6a0beb7c8ec5c743b3b34a
child 623640 c18877c2c33f7bc0907d44abfd682850e8c5e252
push id53359
push userm_kato@ga2.so-net.ne.jp
push dateTue, 11 Apr 2017 08:08:55 +0000
reviewersmasayuki
bugs1330912
milestone55.0a1
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
editor/libeditor/tests/test_bug1100966.html
editor/libeditor/tests/test_bug1154791.html
--- 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>