Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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">
17 </div>
18 <pre id="test">
19 <script type="application/javascript">
21 /** Test for Bug 432225 **/
23 SimpleTest.waitForExplicitFinish();
24 addLoadEvent(runTest);
26 var gMisspeltWords = [];
28 function getEdit() {
29 return document.getElementById('edit');
30 }
32 function editDoc() {
33 return getEdit().contentDocument;
34 }
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 }
49 function runTest() {
50 editDoc().designMode = "on";
51 setTimeout(function() { addWords(100); }, 0);
52 }
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 }
66 function isSpellingCheckOk() {
67 var sel = getSpellCheckSelection();
68 var numWords = sel.rangeCount;
70 is(numWords, gMisspeltWords.length, "Correct number of misspellings and words.");
72 if (numWords != gMisspeltWords.length)
73 return false;
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 }
84 </script>
85 </pre>
87 <iframe id="edit" width="200" height="100" src="about:blank"></iframe>
89 </body>
90 </html>