Bug 856270 - Update spell checking to use nsIContentPrefService2 (part 3: update other tests). r=ehsan
authorDrew Willcoxon <adw@mozilla.com>
Wed, 05 Jun 2013 17:07:54 -0700
changeset 145665 6b29a5c949555aefa0ee6bcca3b1a45809e513f8
parent 145664 eac7a8c8d5d42d0ca047102422e13a9bb4fec50e
child 145666 3f4ad11d56da4b29ee44fe238ecce312204cdc85
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs856270
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 856270 - Update spell checking to use nsIContentPrefService2 (part 3: update other tests). r=ehsan
browser/base/content/test/test_contextmenu.html
editor/composer/test/test_bug338427.html
editor/composer/test/test_bug678842.html
editor/libeditor/html/tests/test_bug366682.html
editor/libeditor/html/tests/test_bug484181.html
editor/libeditor/text/tests/test_bug596333.html
editor/libeditor/text/tests/test_bug636465.xul
extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul
toolkit/content/tests/chrome/test_textbox_dictionary.xul
--- a/browser/base/content/test/test_contextmenu.html
+++ b/browser/base/content/test/test_contextmenu.html
@@ -16,36 +16,38 @@ Browser context menu tests.
 <pre id="test">
 <script> var perWindowPrivateBrowsing = false; </script>
 <script type="text/javascript" src="privateBrowsingMode.js"></script>
 <script class="testbody" type="text/javascript">
 
 /** 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");
 
     if (lastElement)
       lastElement.blur();
     element.focus();
 
     // Some elements need time to focus and spellcheck before any tests are
     // run on them.
     function actuallyOpenContextMenuFor() {
       lastElement = element;
       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();
 }
 
 function closeContextMenu() {
     contextMenu.hidePopup();
 }
 
@@ -603,17 +605,17 @@ function runTest(testNum) {
                           "spell-check-enabled", true,
                           "spell-dictionaries",  true,
                               ["spell-check-dictionary-en-US", true,
                                "---",                          null,
                                "spell-add-dictionaries",       true], null
                          ].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:
         // Context menu for contenteditable
         checkContextMenu(["spell-no-suggestions", false,
                           "spell-add-to-dictionary", true,
                           "---",                 null,
                           "context-undo",        false,
@@ -628,17 +630,17 @@ function runTest(testNum) {
                           "spell-check-enabled", true,
                           "spell-dictionaries",  true,
                               ["spell-check-dictionary-en-US", true,
                                "---",                          null,
                                "spell-add-dictionaries",       true], null
                          ].concat(inspectItems));
 
         closeContextMenu();
-        openContextMenuFor(inputspell); // Invoke context menu for next test.
+        openContextMenuFor(inputspell, false, true); // Invoke context menu for next test.
         break;
 
     case 19:
         // Context menu for spell-check input
         checkContextMenu(["*prodigality",        true, // spelling suggestion
                           "spell-add-to-dictionary", true,
                           "---",                 null,
                           "context-undo",        false,
--- a/editor/composer/test/test_bug338427.html
+++ b/editor/composer/test/test_bug338427.html
@@ -15,38 +15,41 @@ https://bugzilla.mozilla.org/show_bug.cg
 <textarea id="editor" lang="testing-XX" spellcheck="true"></textarea>
 
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** 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;
+    textarea.focus();
 
-    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);
+    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);
 
-    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 () {
+            try {
+                var dictionary =
+                    spellchecker.spellChecker.GetCurrentDictionary();
+            } catch(e) {}
+            is(dictionary, lang, "Unexpected spell check dictionary");
+            SimpleTest.finish();
+        });
+    });
 }
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(init);
 
 </script>
 </pre>
 </body>
--- a/editor/composer/test/test_bug678842.html
+++ b/editor/composer/test/test_bug678842.html
@@ -22,40 +22,43 @@ var content = document.getElementById('c
 // load a subframe containing an editor with a defined unknown lang. At first
 // load, it will set dictionary to en-US. At second load, it will return current
 // dictionary. So, we can check, dictionary is correctly remembered between
 // loads.
 
 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 (!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();
-  }
+    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);
 
 content.src = 'http://mochi.test:8888/tests/editor/composer/test/bug678842_subframe.html?firstload=true';
 
 </script>
 </pre>
--- a/editor/libeditor/html/tests/test_bug366682.html
+++ b/editor/libeditor/html/tests/test_bug366682.html
@@ -43,17 +43,19 @@ function getSpellCheckSelection() {
   var selcon = editor.selectionController;
   return selcon.getSelection(selcon.SELECTION_SPELLCHECK);
 }
 
 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() {
   is(isSpellingCheckOk(), true, "All misspellings accounted for.");
   SimpleTest.finish();
 }
 
 function isSpellingCheckOk() {
--- a/editor/libeditor/html/tests/test_bug484181.html
+++ b/editor/libeditor/html/tests/test_bug484181.html
@@ -54,27 +54,29 @@ function append(str) {
     synthesizeKey(str[i], {});
   }
 }
 
 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();
-      });
+    });
   });
 }
 
 function isSpellingCheckOk() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
   var sel = getSpellCheckSelection();
   var numWords = sel.rangeCount;
--- a/editor/libeditor/text/tests/test_bug596333.html
+++ b/editor/libeditor/text/tests/test_bug596333.html
@@ -17,17 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 596333 **/
 const Ci = SpecialPowers.Ci;
 
 SimpleTest.waitForExplicitFinish();
-addLoadEvent(function() SimpleTest.executeSoon(runTest));
+addLoadEvent(runTest);
 
 var gMisspeltWords;
 
 function getEditor() {
   return SpecialPowers.wrap(document.getElementById("edit")).editor;
 }
 
 function getSpellCheckSelection() {
@@ -66,63 +66,62 @@ function paste(str) {
   s.data = str;
   trans.setTransferData("text/unicode", s, str.length * 2);
 
   getEditor().pasteTransferable(trans);
 }
 
 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.");
+
+  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.");
 
-      // 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.");
+    // 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
+      // 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();
         });
       });
     });
   });
 }
 
 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() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
   var sel = getSpellCheckSelection();
   var numWords = sel.rangeCount;
 
--- a/editor/libeditor/text/tests/test_bug636465.xul
+++ b/editor/libeditor/text/tests/test_bug636465.xul
@@ -25,48 +25,37 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
   <textbox id="x" value="foobarbaz" spellcheck="true"/>
   <script class="testbody" type="application/javascript">
   <![CDATA[
 
   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>
 </window>
--- a/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul
+++ b/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul
@@ -59,54 +59,60 @@ function RunTest() {
   hunspell.addDirectory(base);
 
   // install map dictionary
   var map = dir.clone();
   map.append("map");
   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");
+
+      // select map dictionary
+      setCurrentDictionary(editor, "maputf");
 
-    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");
+      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");
 
-      // uninstall map dictionary
-      hunspell.removeDirectory(map);
+        // uninstall map dictionary
+        hunspell.removeDirectory(map);
+
+        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");
 
-      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");
+          // 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");
 
-        // 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");
+          // uninstall base dictionary
+          hunspell.removeDirectory(base);
 
-        // uninstall base dictionary
-        hunspell.removeDirectory(base);
-
-        SimpleTest.finish();
+          onSpellCheck(textbox, function () {
+            SimpleTest.finish();
+          });
+        });
       });
     });
   });
 }
   ]]>
   </script>
   <textbox id="textbox" spellcheck="true" value="created imply Frühstück tomorrow qwertyu"/>
 </window>
--- a/toolkit/content/tests/chrome/test_textbox_dictionary.xul
+++ b/toolkit/content/tests/chrome/test_textbox_dictionary.xul
@@ -35,17 +35,20 @@ function leftClickElement(element)
 }
 
 function startTests() 
 {     
   textbox = document.getElementById("t1");
   textbox.focus();
   testNum = 0;
   
-  SimpleTest.executeSoon( function() {  bringUpContextMenu(textbox); });
+  Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
+  onSpellCheck(textbox, function () {
+    bringUpContextMenu(textbox);
+  });
 }
 
 function runContextMenuTest()
 {
   SimpleTest.executeSoon( function() {
     // The textbox has its children in an hbox XUL element, so get that first
     var hbox = document.getAnonymousNodes(textbox).item(0);
     
@@ -60,30 +63,34 @@ function runContextMenuTest()
         var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]");
         ok(!separator.hidden, "Is separator visible?");
 
         addToDict.doCommand();
         
         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
         var undoAddDict = contextMenu.querySelector("[anonid=spell-undo-add-to-dictionary]");
         ok(!undoAddDict.hidden, "Is Undo Add to Dictioanry visible?");
 
         var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]");
         ok(!separator.hidden, "Is separator hidden?");
 
         undoAddDict.doCommand();
         
         contextMenu.hidePopup();
-        SimpleTest.finish();
+        onSpellCheck(textbox, function () {
+          SimpleTest.finish();
+        });
         break;
     }
   });
 }
 
 SimpleTest.waitForFocus(startTests);
 
   ]]></script>