editor/libeditor/html/tests/test_bug366682.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial