1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/composer/test/test_bug678842.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=678842 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 678842</title> 1.11 + <script type="text/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 +</head> 1.14 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=678842">Mozilla Bug 678842</a> 1.15 +<p id="display"></p> 1.16 +<iframe id="content"></iframe> 1.17 + 1.18 +</div> 1.19 +<pre id="test"> 1.20 +<script class="testbody" type="text/javascript"> 1.21 + 1.22 +/** Test for Bug 678842 **/ 1.23 +SimpleTest.waitForExplicitFinish(); 1.24 +var content = document.getElementById('content'); 1.25 +// load a subframe containing an editor with a defined unknown lang. At first 1.26 +// load, it will set dictionary to en-US. At second load, it will return current 1.27 +// dictionary. So, we can check, dictionary is correctly remembered between 1.28 +// loads. 1.29 + 1.30 +var firstLoad = true; 1.31 + 1.32 +var loadListener = function(evt) { 1.33 + Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm"); 1.34 + var doc = evt.target.contentDocument; 1.35 + var elem = doc.getElementById('textarea'); 1.36 + var editor = elem.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor; 1.37 + editor.setSpellcheckUserOverride(true); 1.38 + var inlineSpellChecker = editor.getInlineSpellChecker(true); 1.39 + 1.40 + onSpellCheck(elem, function () { 1.41 + var spellchecker = inlineSpellChecker.spellChecker; 1.42 + try { 1.43 + var currentDictonary = spellchecker.GetCurrentDictionary(); 1.44 + } catch(e) {} 1.45 + 1.46 + if (!currentDictonary) { 1.47 + spellchecker.SetCurrentDictionary('en-US'); 1.48 + } 1.49 + 1.50 + if (firstLoad) { 1.51 + firstLoad = false; 1.52 + is (currentDictonary, "", "unexpected lang " + currentDictonary); 1.53 + content.src = 'http://mochi.test:8888/tests/editor/composer/test/bug678842_subframe.html?firstload=false'; 1.54 + } else { 1.55 + is (currentDictonary, "en-US", "unexpected lang " + currentDictonary + " instead of en-US"); 1.56 + content.removeEventListener('load', loadListener, false); 1.57 + SimpleTest.finish(); 1.58 + } 1.59 + }); 1.60 +} 1.61 + 1.62 +content.addEventListener('load', loadListener, false); 1.63 + 1.64 +content.src = 'http://mochi.test:8888/tests/editor/composer/test/bug678842_subframe.html?firstload=true'; 1.65 + 1.66 +</script> 1.67 +</pre> 1.68 +</body> 1.69 +</html>