tor-browser

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

test_hunspell_unicode_paths.js (1008B)


      1 "use strict";
      2 
      3 const { XPCOMUtils } = ChromeUtils.importESModule(
      4  "resource://gre/modules/XPCOMUtils.sys.mjs"
      5 );
      6 
      7 XPCOMUtils.defineLazyServiceGetter(
      8  this,
      9  "spellCheck",
     10  "@mozilla.org/spellchecker/engine;1",
     11  Ci.mozISpellCheckingEngine
     12 );
     13 
     14 const nsFile = Components.Constructor(
     15  "@mozilla.org/file/local;1",
     16  "nsIFile",
     17  "initWithPath"
     18 );
     19 
     20 add_task(async function () {
     21  let prof = do_get_profile();
     22 
     23  let basePath = PathUtils.join(prof.path, "\u263a", "dictionaries");
     24  let baseDir = nsFile(basePath);
     25  await IOUtils.makeDirectory(basePath, { createAncestors: true });
     26 
     27  let dicPath = PathUtils.join(basePath, "dict.dic");
     28  let affPath = PathUtils.join(basePath, "dict.aff");
     29 
     30  const WORD = "Flehgragh";
     31 
     32  await IOUtils.writeUTF8(dicPath, `1\n${WORD}\n`);
     33  await IOUtils.writeUTF8(affPath, "");
     34 
     35  spellCheck.loadDictionariesFromDir(baseDir);
     36  spellCheck.dictionaries = ["dict"];
     37 
     38  ok(
     39    spellCheck.check(WORD),
     40    "Dictionary should have been loaded from a unicode path"
     41  );
     42 });