|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=432225 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 432225</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=432225">Mozilla Bug 432225</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script type="application/javascript"> |
|
20 |
|
21 /** Test for Bug 432225 **/ |
|
22 |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 addLoadEvent(runTest); |
|
25 |
|
26 var gMisspeltWords = []; |
|
27 |
|
28 function getEdit() { |
|
29 return document.getElementById('edit'); |
|
30 } |
|
31 |
|
32 function editDoc() { |
|
33 return getEdit().contentDocument; |
|
34 } |
|
35 |
|
36 function getSpellCheckSelection() { |
|
37 var Ci = SpecialPowers.Ci; |
|
38 var win = editDoc().defaultView; |
|
39 var editingSession = SpecialPowers.wrap(win) |
|
40 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
41 .getInterface(Ci.nsIWebNavigation) |
|
42 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
43 .getInterface(Ci.nsIEditingSession); |
|
44 var editor = editingSession.getEditorForWindow(win); |
|
45 var selcon = editor.selectionController; |
|
46 return selcon.getSelection(selcon.SELECTION_SPELLCHECK); |
|
47 } |
|
48 |
|
49 function runTest() { |
|
50 editDoc().designMode = "on"; |
|
51 setTimeout(function() { addWords(100); }, 0); |
|
52 } |
|
53 |
|
54 function addWords(aLimit) { |
|
55 if (aLimit == 0) { |
|
56 is(isSpellingCheckOk(), true, "All misspellings accounted for."); |
|
57 SimpleTest.finish(); |
|
58 return; |
|
59 } |
|
60 getEdit().focus(); |
|
61 sendString('aa OK '); |
|
62 gMisspeltWords.push("aa"); |
|
63 setTimeout(function() { addWords(aLimit-1); }, 0); |
|
64 } |
|
65 |
|
66 function isSpellingCheckOk() { |
|
67 var sel = getSpellCheckSelection(); |
|
68 var numWords = sel.rangeCount; |
|
69 |
|
70 is(numWords, gMisspeltWords.length, "Correct number of misspellings and words."); |
|
71 |
|
72 if (numWords != gMisspeltWords.length) |
|
73 return false; |
|
74 |
|
75 for (var i=0; i<numWords; i++) { |
|
76 var word = sel.getRangeAt(i); |
|
77 is (word, gMisspeltWords[i], "Misspelling is what we think it is."); |
|
78 if (word != gMisspeltWords[i]) |
|
79 return false; |
|
80 } |
|
81 return true; |
|
82 } |
|
83 |
|
84 </script> |
|
85 </pre> |
|
86 |
|
87 <iframe id="edit" width="200" height="100" src="about:blank"></iframe> |
|
88 |
|
89 </body> |
|
90 </html> |