editor/libeditor/html/tests/test_bug432225.html

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial