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.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=790475 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 790475</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=790475">Mozilla Bug 790475</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <div id="content" style="display: none"></div> |
michael@0 | 16 | <pre id="test"> |
michael@0 | 17 | <script type="application/javascript"> |
michael@0 | 18 | |
michael@0 | 19 | /** |
michael@0 | 20 | * Test for Bug 790475 |
michael@0 | 21 | * |
michael@0 | 22 | * Tests that inline spell checking works properly through adjacent text nodes. |
michael@0 | 23 | */ |
michael@0 | 24 | |
michael@0 | 25 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 26 | addLoadEvent(runTest); |
michael@0 | 27 | |
michael@0 | 28 | var gMisspeltWords; |
michael@0 | 29 | |
michael@0 | 30 | function getEditor() { |
michael@0 | 31 | const Ci = SpecialPowers.Ci; |
michael@0 | 32 | var editingSession = SpecialPowers.wrap(window) |
michael@0 | 33 | .QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 34 | .getInterface(Ci.nsIWebNavigation) |
michael@0 | 35 | .QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 36 | .getInterface(Ci.nsIEditingSession); |
michael@0 | 37 | return editingSession.getEditorForWindow(window); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function getSpellCheckSelection() { |
michael@0 | 41 | var editor = getEditor(); |
michael@0 | 42 | var selcon = editor.selectionController; |
michael@0 | 43 | return selcon.getSelection(selcon.SELECTION_SPELLCHECK); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function runTest() { |
michael@0 | 47 | gMisspeltWords = []; |
michael@0 | 48 | var edit = document.getElementById("edit"); |
michael@0 | 49 | edit.focus(); |
michael@0 | 50 | |
michael@0 | 51 | SimpleTest.executeSoon(function() { |
michael@0 | 52 | gMisspeltWords = []; |
michael@0 | 53 | is(isSpellingCheckOk(), true, "Should not find any misspellings yet."); |
michael@0 | 54 | |
michael@0 | 55 | var newTextNode = document.createTextNode("ing string"); |
michael@0 | 56 | edit.appendChild(newTextNode); |
michael@0 | 57 | var editor = getEditor(); |
michael@0 | 58 | var sel = editor.selection; |
michael@0 | 59 | sel.collapse(newTextNode, newTextNode.textContent.length); |
michael@0 | 60 | synthesizeKey("!", {}); |
michael@0 | 61 | |
michael@0 | 62 | edit.blur(); |
michael@0 | 63 | |
michael@0 | 64 | SimpleTest.executeSoon(function() { |
michael@0 | 65 | is(isSpellingCheckOk(), true, "Should not have found any misspellings. "); |
michael@0 | 66 | SimpleTest.finish(); |
michael@0 | 67 | }); |
michael@0 | 68 | }); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | function isSpellingCheckOk() { |
michael@0 | 72 | var sel = getSpellCheckSelection(); |
michael@0 | 73 | var numWords = sel.rangeCount; |
michael@0 | 74 | |
michael@0 | 75 | is(numWords, gMisspeltWords.length, "Correct number of misspellings and words."); |
michael@0 | 76 | |
michael@0 | 77 | if (numWords != gMisspeltWords.length) |
michael@0 | 78 | return false; |
michael@0 | 79 | |
michael@0 | 80 | for (var i = 0; i < numWords; i++) { |
michael@0 | 81 | var word = sel.getRangeAt(i); |
michael@0 | 82 | is (word, gMisspeltWords[i], "Misspelling is what we think it is."); |
michael@0 | 83 | if (word != gMisspeltWords[i]) |
michael@0 | 84 | return false; |
michael@0 | 85 | } |
michael@0 | 86 | return true; |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | </script> |
michael@0 | 90 | </pre> |
michael@0 | 91 | |
michael@0 | 92 | <div id="edit" contenteditable="true">This is a test</div> |
michael@0 | 93 | |
michael@0 | 94 | </body> |
michael@0 | 95 | </html> |