diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js')
-rw-r--r-- | extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js b/extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js new file mode 100644 index 0000000000..3fb4c78b59 --- /dev/null +++ b/extensions/spellcheck/hunspell/tests/unit/test_hunspell_unicode_paths.js @@ -0,0 +1,42 @@ +"use strict"; + +const { XPCOMUtils } = ChromeUtils.importESModule( + "resource://gre/modules/XPCOMUtils.sys.mjs" +); + +XPCOMUtils.defineLazyServiceGetter( + this, + "spellCheck", + "@mozilla.org/spellchecker/engine;1", + "mozISpellCheckingEngine" +); + +const nsFile = Components.Constructor( + "@mozilla.org/file/local;1", + "nsIFile", + "initWithPath" +); + +add_task(async function () { + let prof = do_get_profile(); + + let basePath = PathUtils.join(prof.path, "\u263a", "dictionaries"); + let baseDir = nsFile(basePath); + await IOUtils.makeDirectory(basePath, { createAncestors: true }); + + let dicPath = PathUtils.join(basePath, "dict.dic"); + let affPath = PathUtils.join(basePath, "dict.aff"); + + const WORD = "Flehgragh"; + + await IOUtils.writeUTF8(dicPath, `1\n${WORD}\n`); + await IOUtils.writeUTF8(affPath, ""); + + spellCheck.loadDictionariesFromDir(baseDir); + spellCheck.dictionaries = ["dict"]; + + ok( + spellCheck.check(WORD), + "Dictionary should have been loaded from a unicode path" + ); +}); |