|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=678842 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 678842</title> |
|
8 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
10 </head> |
|
11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=678842">Mozilla Bug 678842</a> |
|
12 <p id="display"></p> |
|
13 <iframe id="content"></iframe> |
|
14 |
|
15 </div> |
|
16 <pre id="test"> |
|
17 <script class="testbody" type="text/javascript"> |
|
18 |
|
19 /** Test for Bug 678842 **/ |
|
20 SimpleTest.waitForExplicitFinish(); |
|
21 var content = document.getElementById('content'); |
|
22 // load a subframe containing an editor with a defined unknown lang. At first |
|
23 // load, it will set dictionary to en-US. At second load, it will return current |
|
24 // dictionary. So, we can check, dictionary is correctly remembered between |
|
25 // loads. |
|
26 |
|
27 var firstLoad = true; |
|
28 |
|
29 var loadListener = function(evt) { |
|
30 Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm"); |
|
31 var doc = evt.target.contentDocument; |
|
32 var elem = doc.getElementById('textarea'); |
|
33 var editor = elem.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor; |
|
34 editor.setSpellcheckUserOverride(true); |
|
35 var inlineSpellChecker = editor.getInlineSpellChecker(true); |
|
36 |
|
37 onSpellCheck(elem, function () { |
|
38 var spellchecker = inlineSpellChecker.spellChecker; |
|
39 try { |
|
40 var currentDictonary = spellchecker.GetCurrentDictionary(); |
|
41 } catch(e) {} |
|
42 |
|
43 if (!currentDictonary) { |
|
44 spellchecker.SetCurrentDictionary('en-US'); |
|
45 } |
|
46 |
|
47 if (firstLoad) { |
|
48 firstLoad = false; |
|
49 is (currentDictonary, "", "unexpected lang " + currentDictonary); |
|
50 content.src = 'http://mochi.test:8888/tests/editor/composer/test/bug678842_subframe.html?firstload=false'; |
|
51 } else { |
|
52 is (currentDictonary, "en-US", "unexpected lang " + currentDictonary + " instead of en-US"); |
|
53 content.removeEventListener('load', loadListener, false); |
|
54 SimpleTest.finish(); |
|
55 } |
|
56 }); |
|
57 } |
|
58 |
|
59 content.addEventListener('load', loadListener, false); |
|
60 |
|
61 content.src = 'http://mochi.test:8888/tests/editor/composer/test/bug678842_subframe.html?firstload=true'; |
|
62 |
|
63 </script> |
|
64 </pre> |
|
65 </body> |
|
66 </html> |