1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/test_bug432225.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=432225 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 432225</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=432225">Mozilla Bug 432225</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 + 1.20 +</div> 1.21 +<pre id="test"> 1.22 +<script type="application/javascript"> 1.23 + 1.24 +/** Test for Bug 432225 **/ 1.25 + 1.26 +SimpleTest.waitForExplicitFinish(); 1.27 +addLoadEvent(runTest); 1.28 + 1.29 +var gMisspeltWords = []; 1.30 + 1.31 +function getEdit() { 1.32 + return document.getElementById('edit'); 1.33 +} 1.34 + 1.35 +function editDoc() { 1.36 + return getEdit().contentDocument; 1.37 +} 1.38 + 1.39 +function getSpellCheckSelection() { 1.40 + var Ci = SpecialPowers.Ci; 1.41 + var win = editDoc().defaultView; 1.42 + var editingSession = SpecialPowers.wrap(win) 1.43 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.44 + .getInterface(Ci.nsIWebNavigation) 1.45 + .QueryInterface(Ci.nsIInterfaceRequestor) 1.46 + .getInterface(Ci.nsIEditingSession); 1.47 + var editor = editingSession.getEditorForWindow(win); 1.48 + var selcon = editor.selectionController; 1.49 + return selcon.getSelection(selcon.SELECTION_SPELLCHECK); 1.50 +} 1.51 + 1.52 +function runTest() { 1.53 + editDoc().designMode = "on"; 1.54 + setTimeout(function() { addWords(100); }, 0); 1.55 +} 1.56 + 1.57 +function addWords(aLimit) { 1.58 + if (aLimit == 0) { 1.59 + is(isSpellingCheckOk(), true, "All misspellings accounted for."); 1.60 + SimpleTest.finish(); 1.61 + return; 1.62 + } 1.63 + getEdit().focus(); 1.64 + sendString('aa OK '); 1.65 + gMisspeltWords.push("aa"); 1.66 + setTimeout(function() { addWords(aLimit-1); }, 0); 1.67 +} 1.68 + 1.69 +function isSpellingCheckOk() { 1.70 + var sel = getSpellCheckSelection(); 1.71 + var numWords = sel.rangeCount; 1.72 + 1.73 + is(numWords, gMisspeltWords.length, "Correct number of misspellings and words."); 1.74 + 1.75 + if (numWords != gMisspeltWords.length) 1.76 + return false; 1.77 + 1.78 + for (var i=0; i<numWords; i++) { 1.79 + var word = sel.getRangeAt(i); 1.80 + is (word, gMisspeltWords[i], "Misspelling is what we think it is."); 1.81 + if (word != gMisspeltWords[i]) 1.82 + return false; 1.83 + } 1.84 + return true; 1.85 +} 1.86 + 1.87 +</script> 1.88 +</pre> 1.89 + 1.90 +<iframe id="edit" width="200" height="100" src="about:blank"></iframe> 1.91 + 1.92 +</body> 1.93 +</html>