test_bug1100966.html (1875B)
1 <!DOCTYPE> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1100966 5 --> 6 <head> 7 <title>Test for Bug 1100966</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" href="/tests/SimpleTest/test.css"> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 </head> 12 <body> 13 <div id="display"> 14 </div> 15 <div id="content" contenteditable> 16 =====<br> 17 correct<br> 18 fivee sixx<br> 19 ==== 20 </div> 21 <pre id="test"> 22 </pre> 23 24 <script class="testbody" type="application/javascript"> 25 26 let { maybeOnSpellCheck } = SpecialPowers.ChromeUtils.importESModule( 27 "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs" 28 ); 29 30 /** Test for Bug 1100966 */ 31 SimpleTest.waitForExplicitFinish(); 32 SimpleTest.waitForFocus(function() { 33 var div = document.getElementById("content"); 34 div.focus(); 35 synthesizeMouseAtCenter(div, {}); 36 37 getSpellChecker().UpdateCurrentDictionary(() => { 38 sendString(" "); 39 SimpleTest.executeSoon(function() { 40 sendString("a"); 41 SimpleTest.executeSoon(function() { 42 synthesizeKey("KEY_Backspace"); 43 44 maybeOnSpellCheck(div, function() { 45 var sel = getSpellCheckSelection(); 46 is(sel.rangeCount, 2, "We should have two misspelled words"); 47 is(String(sel.getRangeAt(0)), "fivee", "Correct misspelled word"); 48 is(String(sel.getRangeAt(1)), "sixx", "Correct misspelled word"); 49 50 SimpleTest.finish(); 51 }); 52 }); 53 }); 54 }); 55 }); 56 57 function getEditor() { 58 var editingSession = SpecialPowers.wrap(window).docShell.editingSession; 59 return editingSession.getEditorForWindow(window); 60 } 61 62 function getSpellChecker() { 63 return getEditor().getInlineSpellChecker(false).spellChecker; 64 } 65 66 function getSpellCheckSelection() { 67 var selcon = getEditor().selectionController; 68 return selcon.getSelection(selcon.SELECTION_SPELLCHECK); 69 } 70 71 </script> 72 </body> 73 74 </html>