|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=790475 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 790475</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=790475">Mozilla Bug 790475</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"></div> |
|
16 <pre id="test"> |
|
17 <script type="application/javascript"> |
|
18 |
|
19 /** |
|
20 * Test for Bug 790475 |
|
21 * |
|
22 * Tests that inline spell checking works properly through adjacent text nodes. |
|
23 */ |
|
24 |
|
25 SimpleTest.waitForExplicitFinish(); |
|
26 addLoadEvent(runTest); |
|
27 |
|
28 var gMisspeltWords; |
|
29 |
|
30 function getEditor() { |
|
31 const Ci = SpecialPowers.Ci; |
|
32 var editingSession = SpecialPowers.wrap(window) |
|
33 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
34 .getInterface(Ci.nsIWebNavigation) |
|
35 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
36 .getInterface(Ci.nsIEditingSession); |
|
37 return editingSession.getEditorForWindow(window); |
|
38 } |
|
39 |
|
40 function getSpellCheckSelection() { |
|
41 var editor = getEditor(); |
|
42 var selcon = editor.selectionController; |
|
43 return selcon.getSelection(selcon.SELECTION_SPELLCHECK); |
|
44 } |
|
45 |
|
46 function runTest() { |
|
47 gMisspeltWords = []; |
|
48 var edit = document.getElementById("edit"); |
|
49 edit.focus(); |
|
50 |
|
51 SimpleTest.executeSoon(function() { |
|
52 gMisspeltWords = []; |
|
53 is(isSpellingCheckOk(), true, "Should not find any misspellings yet."); |
|
54 |
|
55 var newTextNode = document.createTextNode("ing string"); |
|
56 edit.appendChild(newTextNode); |
|
57 var editor = getEditor(); |
|
58 var sel = editor.selection; |
|
59 sel.collapse(newTextNode, newTextNode.textContent.length); |
|
60 synthesizeKey("!", {}); |
|
61 |
|
62 edit.blur(); |
|
63 |
|
64 SimpleTest.executeSoon(function() { |
|
65 is(isSpellingCheckOk(), true, "Should not have found any misspellings. "); |
|
66 SimpleTest.finish(); |
|
67 }); |
|
68 }); |
|
69 } |
|
70 |
|
71 function isSpellingCheckOk() { |
|
72 var sel = getSpellCheckSelection(); |
|
73 var numWords = sel.rangeCount; |
|
74 |
|
75 is(numWords, gMisspeltWords.length, "Correct number of misspellings and words."); |
|
76 |
|
77 if (numWords != gMisspeltWords.length) |
|
78 return false; |
|
79 |
|
80 for (var i = 0; i < numWords; i++) { |
|
81 var word = sel.getRangeAt(i); |
|
82 is (word, gMisspeltWords[i], "Misspelling is what we think it is."); |
|
83 if (word != gMisspeltWords[i]) |
|
84 return false; |
|
85 } |
|
86 return true; |
|
87 } |
|
88 |
|
89 </script> |
|
90 </pre> |
|
91 |
|
92 <div id="edit" contenteditable="true">This is a test</div> |
|
93 |
|
94 </body> |
|
95 </html> |