tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug338427.html (1945B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=338427
      5 -->
      6 <head>
      7  <title>Test for Bug 338427</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=338427">Mozilla Bug 338427</a>
     13 <p id="display"></p>
     14 <div id="content">
     15 <textarea id="editor" lang="testing-XX" spellcheck="true"></textarea>
     16 
     17 </div>
     18 <pre id="test">
     19 <script class="testbody" type="text/javascript">
     20 
     21 /** Test for Bug 338427 */
     22 function init() {
     23    var { onSpellCheck } = SpecialPowers.ChromeUtils.importESModule(
     24      "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
     25    );
     26    var textarea = document.getElementById("editor");
     27    var editor = SpecialPowers.wrap(textarea).editor;
     28    var spellchecker = editor.getInlineSpellChecker(true);
     29    spellchecker.enableRealTimeSpell = true;
     30    textarea.focus();
     31 
     32    onSpellCheck(textarea, function() {
     33        var list = spellchecker.spellChecker.GetDictionaryList();
     34        ok(!!list.length, "At least one dictionary should be present");
     35 
     36        var lang = list[0];
     37        spellchecker.spellChecker.setCurrentDictionaries([lang]).then(() => {
     38          onSpellCheck(textarea, function() {
     39            try {
     40                var dictionaries =
     41                    spellchecker.spellChecker.getCurrentDictionaries();
     42            } catch (e) {}
     43            is(dictionaries.length, 1, "Expected one dictionary");
     44            is(dictionaries[0], lang, "Unexpected spell check dictionary");
     45 
     46            // This will clear the content preferences and reset "spellchecker.dictionary".
     47            spellchecker.spellChecker.setCurrentDictionaries([]).then(() => {
     48              SimpleTest.finish();
     49            });
     50          });
     51        });
     52    });
     53 }
     54 
     55 SimpleTest.waitForExplicitFinish();
     56 addLoadEvent(init);
     57 
     58 </script>
     59 </pre>
     60 </body>
     61 </html>