Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / editor / libeditor / tests / test_bug790475.html
blobd30b14b3120f32d03d47eb4d9adcb47af04fac33
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 src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
10 <script 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">
19 /**
20 * Test for Bug 790475
22 * Tests that inline spell checking works properly through adjacent text nodes.
25 SimpleTest.waitForExplicitFinish();
26 addLoadEvent(runTest);
28 var gMisspeltWords;
30 function getEditor() {
31 var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
32 return editingSession.getEditorForWindow(window);
35 function getSpellCheckSelection() {
36 var editor = getEditor();
37 var selcon = editor.selectionController;
38 return selcon.getSelection(selcon.SELECTION_SPELLCHECK);
41 function runTest() {
42 gMisspeltWords = [];
43 var edit = document.getElementById("edit");
44 edit.focus();
46 SimpleTest.executeSoon(function() {
47 gMisspeltWords = [];
48 is(isSpellingCheckOk(), true, "Should not find any misspellings yet.");
50 var newTextNode = document.createTextNode("ing string");
51 edit.appendChild(newTextNode);
52 var editor = getEditor();
53 var sel = editor.selection;
54 sel.collapse(newTextNode, newTextNode.textContent.length);
55 sendString("!");
57 edit.blur();
59 SimpleTest.executeSoon(function() {
60 is(isSpellingCheckOk(), true, "Should not have found any misspellings. ");
61 SimpleTest.finish();
62 });
63 });
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;
81 return true;
84 </script>
85 </pre>
87 <div id="edit" contenteditable="true">This is a test</div>
89 </body>
90 </html>