Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/editor/spellchecker/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

Quellcode-Bibliothek test_bug717433.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/editor/spellchecker/tests/test_bug717433.html


<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=717433
-->

<head>
  <title>Test for Bug 717433</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=717433">Mozilla Bug 717433</a>
<p id="display"></p>
<iframe id="content"></iframe>

</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 717433 **/
SimpleTest.waitForExplicitFinish();
var content = document.getElementById("content");
// Load a subframe containing an editor with language "en". At first
// load, it will set the dictionary to en-GB or en-US. We set the other one.
// At second load, it will return the current dictionary. We can check that the
// dictionary is correctly remembered between loads.

var firstLoad = true;
var expected = "";
var script;

var loadListener = async function(evt) {
  if (firstLoad) {
    script = SpecialPowers.loadChromeScript(function() {
      /* eslint-env mozilla/chrome-script */
      // eslint-disable-next-line mozilla/use-services
      var dir = Cc["@mozilla.org/file/directory_service;1"]
                  .getService(Ci.nsIProperties)
                  .get("CurWorkD", Ci.nsIFile);
      dir.append("tests");
      dir.append("editor");
      dir.append("spellchecker");
      dir.append("tests");

      var hunspell = Cc["@mozilla.org/spellchecker/engine;1"]
                       .getService(Ci.mozISpellCheckingEngine);

      // Install en-GB dictionary.
      var en_GB = dir.clone();
      en_GB.append("en-GB");
      hunspell.addDirectory(en_GB);

      addMessageListener("en_GB-exists", () => en_GB.exists());
      addMessageListener("destroy", () => hunspell.removeDirectory(en_GB));
    });
    is(await script.sendQuery("en_GB-exists"), true,
       "true expected (en-GB directory should exist)");
  }

  var doc = evt.target.contentDocument;
  var elem = doc.getElementById("textarea");
  var editor = SpecialPowers.wrap(elem).editor;
  editor.setSpellcheckUserOverride(true);
  var inlineSpellChecker = editor.getInlineSpellChecker(true);

  const { onSpellCheck } = SpecialPowers.ChromeUtils.importESModule(
    "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
  );
  onSpellCheck(elem, async function() {
    let spellchecker = inlineSpellChecker.spellChecker;
    let currentDictionaries = spellchecker.getCurrentDictionaries();

    is(currentDictionaries.length, 1, "expected one dictionary");
    let currentDictionary = currentDictionaries[0];

    if (firstLoad) {
      firstLoad = false;

      // First time around, we get a random dictionary based on the language "en".
      if (currentDictionary == "en-GB") {
        expected = "en-US";
      } else if (currentDictionary == "en-US") {
        expected = "en-GB";
      } else {
        is(true, false, "Neither en-US nor en-GB are current");
      }
      spellchecker.setCurrentDictionaries([expected]).then(() => {
        content.src = "http://mochi.test:8888/tests/editor/spellchecker/tests/bug717433_subframe.html?firstload=false";});
    } else {
      is(currentDictionary, expected, expected + " expected");
      content.removeEventListener("load", loadListener);

      // Remove the fake en-GB dictionary again, since it's otherwise picked up by later tests.
      await script.sendQuery("destroy");

      // This will clear the content preferences and reset "spellchecker.dictionary".
      spellchecker.setCurrentDictionaries([]).then(() => {
        SimpleTest.finish();
      });
    }
  });
};

content.addEventListener("load", loadListener);

content.src = "http://mochi.test:8888/tests/editor/spellchecker/tests/bug717433_subframe.html?firstload=true";

</script>
</pre>
</body>
</html>

Messung V0.5
C=94 H=100 G=96

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.31Bemerkung:  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.