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