test_bug1219928.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=1219928
  5. -->
  6. <head>
  7. <title>Test for Bug 1219928</title>
  8. <script src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" href="/tests/SimpleTest/test.css" />
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1219928">Mozilla Bug 1219928</a>
  13. <p id="display"></p>
  14. <div contenteditable id="en-US" lang="en-US">
  15. <p>And here a missspelled word</p>
  16. <style>
  17. <!-- and here another onnee in a style comment -->
  18. </style>
  19. </div>
  20. <pre id="test">
  21. <script class="testbody" type="text/javascript">
  22. /** Test for Bug 1219928 **/
  23. /* Very simple test to check that <style> blocks are skipped in the spell check */
  24. var spellchecker;
  25. SimpleTest.waitForExplicitFinish();
  26. SimpleTest.waitForFocus(function() {
  27. SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm",
  28. window);
  29. var elem = document.getElementById('en-US');
  30. elem.focus();
  31. onSpellCheck(elem, function () {
  32. var Ci = SpecialPowers.Ci;
  33. var editingSession = SpecialPowers.wrap(window)
  34. .QueryInterface(Ci.nsIInterfaceRequestor)
  35. .getInterface(Ci.nsIWebNavigation)
  36. .QueryInterface(Ci.nsIInterfaceRequestor)
  37. .getInterface(Ci.nsIEditingSession);
  38. var editor = editingSession.getEditorForWindow(window);
  39. var selcon = editor.selectionController;
  40. var sel = selcon.getSelection(selcon.SELECTION_SPELLCHECK);
  41. is(sel.toString(), "missspelled", "one misspelled word expected: missspelled");
  42. spellchecker = SpecialPowers.Cc['@mozilla.org/editor/editorspellchecker;1']
  43. .createInstance(Ci.nsIEditorSpellCheck);
  44. var filterContractId = "@mozilla.org/editor/txtsrvfilter;1";
  45. spellchecker.setFilter(SpecialPowers.Cc[filterContractId]
  46. .createInstance(Ci.nsITextServicesFilter));
  47. spellchecker.InitSpellChecker(editor, false, spellCheckStarted);
  48. });
  49. });
  50. function spellCheckStarted() {
  51. var misspelledWord = spellchecker.GetNextMisspelledWord();
  52. is(misspelledWord, "missspelled", "first misspelled word expected: missspelled");
  53. // Without the fix, the next misspelled word was 'onnee', so we check that we don't get it.
  54. misspelledWord = spellchecker.GetNextMisspelledWord();
  55. isnot(misspelledWord, "onnee", "second misspelled word should not be: onnee");
  56. spellchecker = "";
  57. SimpleTest.finish();
  58. }
  59. </script>
  60. </pre>
  61. </body>
  62. </html>