|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=366682 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 366682</title> |
|
8 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> |
|
10 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
11 </head> |
|
12 <body> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366682">Mozilla Bug 366682</a> |
|
14 <p id="display"></p> |
|
15 <div id="content" style="display: none"> |
|
16 </div> |
|
17 <pre id="test"> |
|
18 <script type="application/javascript"> |
|
19 |
|
20 /** Test for Bug 366682 **/ |
|
21 |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 addLoadEvent(runTest); |
|
24 |
|
25 var gMisspeltWords; |
|
26 |
|
27 function getEdit() { |
|
28 return document.getElementById('edit'); |
|
29 } |
|
30 |
|
31 function editDoc() { |
|
32 return getEdit().contentDocument; |
|
33 } |
|
34 |
|
35 function getSpellCheckSelection() { |
|
36 var Ci = Components.interfaces; |
|
37 var win = editDoc().defaultView; |
|
38 var editingSession = win.QueryInterface(Ci.nsIInterfaceRequestor) |
|
39 .getInterface(Ci.nsIWebNavigation) |
|
40 .QueryInterface(Ci.nsIInterfaceRequestor) |
|
41 .getInterface(Ci.nsIEditingSession); |
|
42 var editor = editingSession.getEditorForWindow(win); |
|
43 var selcon = editor.selectionController; |
|
44 return selcon.getSelection(selcon.SELECTION_SPELLCHECK); |
|
45 } |
|
46 |
|
47 function runTest() { |
|
48 editDoc().body.innerHTML = "<div>errror and an other errror</div>"; |
|
49 gMisspeltWords = ["errror", "errror"]; |
|
50 editDoc().designMode = "on"; |
|
51 |
|
52 Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm"); |
|
53 onSpellCheck(editDoc().documentElement, evalTest); |
|
54 } |
|
55 |
|
56 function evalTest() { |
|
57 is(isSpellingCheckOk(), true, "All misspellings accounted for."); |
|
58 SimpleTest.finish(); |
|
59 } |
|
60 |
|
61 function isSpellingCheckOk() { |
|
62 var sel = getSpellCheckSelection(); |
|
63 var numWords = sel.rangeCount; |
|
64 |
|
65 is(numWords, gMisspeltWords.length, "Correct number of misspellings and words."); |
|
66 |
|
67 if (numWords != gMisspeltWords.length) |
|
68 return false; |
|
69 |
|
70 for (var i=0; i<numWords; i++) { |
|
71 var word = sel.getRangeAt(i); |
|
72 is (word, gMisspeltWords[i], "Misspelling is what we think it is."); |
|
73 if (word != gMisspeltWords[i]) |
|
74 return false; |
|
75 } |
|
76 return true; |
|
77 } |
|
78 |
|
79 </script> |
|
80 </pre> |
|
81 |
|
82 <iframe id="edit" width="200" height="100" src="about:blank"></iframe> |
|
83 |
|
84 </body> |
|
85 </html> |