summaryrefslogtreecommitdiffstats
path: root/extensions/spellcheck/tests/chrome
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /extensions/spellcheck/tests/chrome
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'extensions/spellcheck/tests/chrome')
-rw-r--r--extensions/spellcheck/tests/chrome/base/base_utf.aff198
-rw-r--r--extensions/spellcheck/tests/chrome/base/base_utf.dic29
-rw-r--r--extensions/spellcheck/tests/chrome/chrome.ini10
-rw-r--r--extensions/spellcheck/tests/chrome/map/maputf.aff11
-rw-r--r--extensions/spellcheck/tests/chrome/map/maputf.dic4
-rw-r--r--extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xhtml129
6 files changed, 381 insertions, 0 deletions
diff --git a/extensions/spellcheck/tests/chrome/base/base_utf.aff b/extensions/spellcheck/tests/chrome/base/base_utf.aff
new file mode 100644
index 0000000000..493157b301
--- /dev/null
+++ b/extensions/spellcheck/tests/chrome/base/base_utf.aff
@@ -0,0 +1,198 @@
+# OpenOffice.org’s en_US.aff file
+# with Unicode apostrophe: ’
+
+SET UTF-8
+TRY esianrtolcdugmphbyfvkwzESIANRTOLCDUGMPHBYFVKWZ'
+
+MAXNGRAMSUGS 1
+WORDCHARS .'’
+
+PFX A Y 1
+PFX A 0 re .
+
+PFX I Y 1
+PFX I 0 in .
+
+PFX U Y 1
+PFX U 0 un .
+
+PFX C Y 1
+PFX C 0 de .
+
+PFX E Y 1
+PFX E 0 dis .
+
+PFX F Y 1
+PFX F 0 con .
+
+PFX K Y 1
+PFX K 0 pro .
+
+SFX V N 2
+SFX V e ive e
+SFX V 0 ive [^e]
+
+SFX N Y 3
+SFX N e ion e
+SFX N y ication y
+SFX N 0 en [^ey]
+
+SFX X Y 3
+SFX X e ions e
+SFX X y ications y
+SFX X 0 ens [^ey]
+
+SFX H N 2
+SFX H y ieth y
+SFX H 0 th [^y]
+
+SFX Y Y 1
+SFX Y 0 ly .
+
+SFX G Y 2
+SFX G e ing e
+SFX G 0 ing [^e]
+
+SFX J Y 2
+SFX J e ings e
+SFX J 0 ings [^e]
+
+SFX D Y 4
+SFX D 0 d e
+SFX D y ied [^aeiou]y
+SFX D 0 ed [^ey]
+SFX D 0 ed [aeiou]y
+
+SFX T N 4
+SFX T 0 st e
+SFX T y iest [^aeiou]y
+SFX T 0 est [aeiou]y
+SFX T 0 est [^ey]
+
+SFX R Y 4
+SFX R 0 r e
+SFX R y ier [^aeiou]y
+SFX R 0 er [aeiou]y
+SFX R 0 er [^ey]
+
+SFX Z Y 4
+SFX Z 0 rs e
+SFX Z y iers [^aeiou]y
+SFX Z 0 ers [aeiou]y
+SFX Z 0 ers [^ey]
+
+SFX S Y 4
+SFX S y ies [^aeiou]y
+SFX S 0 s [aeiou]y
+SFX S 0 es [sxzh]
+SFX S 0 s [^sxzhy]
+
+SFX P Y 3
+SFX P y iness [^aeiou]y
+SFX P 0 ness [aeiou]y
+SFX P 0 ness [^y]
+
+SFX M Y 1
+SFX M 0 's .
+
+SFX B Y 3
+SFX B 0 able [^aeiou]
+SFX B 0 able ee
+SFX B e able [^aeiou]e
+
+SFX L Y 1
+SFX L 0 ment .
+
+REP 88
+REP a ei
+REP ei a
+REP a ey
+REP ey a
+REP ai ie
+REP ie ai
+REP are air
+REP are ear
+REP are eir
+REP air are
+REP air ere
+REP ere air
+REP ere ear
+REP ere eir
+REP ear are
+REP ear air
+REP ear ere
+REP eir are
+REP eir ere
+REP ch te
+REP te ch
+REP ch ti
+REP ti ch
+REP ch tu
+REP tu ch
+REP ch s
+REP s ch
+REP ch k
+REP k ch
+REP f ph
+REP ph f
+REP gh f
+REP f gh
+REP i igh
+REP igh i
+REP i uy
+REP uy i
+REP i ee
+REP ee i
+REP j di
+REP di j
+REP j gg
+REP gg j
+REP j ge
+REP ge j
+REP s ti
+REP ti s
+REP s ci
+REP ci s
+REP k cc
+REP cc k
+REP k qu
+REP qu k
+REP kw qu
+REP o eau
+REP eau o
+REP o ew
+REP ew o
+REP oo ew
+REP ew oo
+REP ew ui
+REP ui ew
+REP oo ui
+REP ui oo
+REP ew u
+REP u ew
+REP oo u
+REP u oo
+REP u oe
+REP oe u
+REP u ieu
+REP ieu u
+REP ue ew
+REP ew ue
+REP uff ough
+REP oo ieu
+REP ieu oo
+REP ier ear
+REP ear ier
+REP ear air
+REP air ear
+REP w qu
+REP qu w
+REP z ss
+REP ss z
+REP shun tion
+REP shun sion
+REP shun cion
+McDonalds’sá/w
+McDonald’sszá/g3) st:McDonald’s po:noun_prs is:TRANS
+McDonald’sszal/g4) st:McDonald’s po:noun_prs is:INSTR
+McDonald’ssal/w
diff --git a/extensions/spellcheck/tests/chrome/base/base_utf.dic b/extensions/spellcheck/tests/chrome/base/base_utf.dic
new file mode 100644
index 0000000000..b2b536d285
--- /dev/null
+++ b/extensions/spellcheck/tests/chrome/base/base_utf.dic
@@ -0,0 +1,29 @@
+28
+created/U
+create/XKVNGADS
+imply/GNSDX
+natural/PUY
+like/USPBY
+convey/BDGS
+look/GZRDS
+text
+hello
+said
+sawyer
+NASA
+rotten
+day
+tomorrow
+seven
+FAQ/SM
+can’t
+doesn’t
+etc
+won’t
+lip
+text
+horrifying
+speech
+suggest
+uncreate/V
+Hunspell
diff --git a/extensions/spellcheck/tests/chrome/chrome.ini b/extensions/spellcheck/tests/chrome/chrome.ini
new file mode 100644
index 0000000000..4aacb387c2
--- /dev/null
+++ b/extensions/spellcheck/tests/chrome/chrome.ini
@@ -0,0 +1,10 @@
+[DEFAULT]
+skip-if = os == 'android'
+
+[test_add_remove_dictionaries.xhtml]
+skip-if = verify
+support-files =
+ base/base_utf.dic
+ base/base_utf.aff
+ map/maputf.dic
+ map/maputf.aff
diff --git a/extensions/spellcheck/tests/chrome/map/maputf.aff b/extensions/spellcheck/tests/chrome/map/maputf.aff
new file mode 100644
index 0000000000..30edb2a785
--- /dev/null
+++ b/extensions/spellcheck/tests/chrome/map/maputf.aff
@@ -0,0 +1,11 @@
+# With MAP suggestion, Hunspell can add missing accents to a word.
+
+SET UTF-8
+
+# switch off ngram suggestion for testing
+MAXNGRAMSUGS 0
+
+MAP 3
+MAP uúü
+MAP öóo
+MAP ß(ss)
diff --git a/extensions/spellcheck/tests/chrome/map/maputf.dic b/extensions/spellcheck/tests/chrome/map/maputf.dic
new file mode 100644
index 0000000000..1c6fa8d058
--- /dev/null
+++ b/extensions/spellcheck/tests/chrome/map/maputf.dic
@@ -0,0 +1,4 @@
+3
+Frühstück
+tükörfúró
+groß
diff --git a/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xhtml b/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xhtml
new file mode 100644
index 0000000000..ae3f42aa67
--- /dev/null
+++ b/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xhtml
@@ -0,0 +1,129 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+
+<window title="Add and remove dictionaries test"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ onload="RunTest();">
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+ <!-- test results are displayed in the html:body -->
+ <body xmlns="http://www.w3.org/1999/xhtml">
+ </body>
+
+ <script type="application/javascript">
+ <![CDATA[
+SimpleTest.waitForExplicitFinish();
+
+function getMisspelledWords(editor) {
+ return editor.selectionController.getSelection(Ci.nsISelectionController.SELECTION_SPELLCHECK).toString();
+}
+
+function getDictionaryList(editor) {
+ var spellchecker = editor.getInlineSpellChecker(true).spellChecker;
+ return spellchecker.GetDictionaryList();
+}
+
+function getCurrentDictionary(editor) {
+ var spellchecker = editor.getInlineSpellChecker(true).spellChecker;
+ return spellchecker.getCurrentDictionaries()[0];
+}
+
+function setCurrentDictionary(editor, dictionary) {
+ var spellchecker = editor.getInlineSpellChecker(true).spellChecker;
+ return spellchecker.setCurrentDictionaries([dictionary]);
+}
+
+function RunTest() {
+ var textbox = document.getElementById('textbox');
+ textbox.focus();
+ var editor = textbox.editor;
+
+ // 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("chrome");
+ dir.append("extensions");
+ dir.append("spellcheck");
+ dir.append("tests");
+ dir.append("chrome");
+
+ var hunspell = Cc["@mozilla.org/spellchecker/engine;1"]
+ .getService(Ci.mozISpellCheckingEngine);
+
+ // install base dictionary
+ var base = dir.clone();
+ base.append("base");
+ ok(base.exists());
+ hunspell.addDirectory(base);
+
+ // install map dictionary
+ var map = dir.clone();
+ map.append("map");
+ ok(map.exists());
+ hunspell.addDirectory(map);
+
+ const {maybeOnSpellCheck} = ChromeUtils.import(
+ "resource://testing-common/AsyncSpellCheckTestHelper.jsm");
+ maybeOnSpellCheck(textbox, function () {
+
+ // test that base and map dictionaries are available
+ var dicts = getDictionaryList(editor);
+ isnot(dicts.indexOf("base-utf"), -1, "base is available");
+ isnot(dicts.indexOf("maputf"), -1, "map is available");
+
+ // select base dictionary
+ setCurrentDictionary(editor, "base-utf").then(() => {
+ /* eslint-disable no-useless-concat */
+ maybeOnSpellCheck(textbox, function () {
+ // test that base dictionary is in use
+ is(getMisspelledWords(editor), "Frühstück" + "qwertyu", "base misspellings");
+ is(getCurrentDictionary(editor), "base-utf", "current dictionary");
+
+ // select map dictionary
+ setCurrentDictionary(editor, "maputf").then(() => {
+ // Focus again, so the spelling gets updated.
+ textbox.blur();
+ textbox.focus();
+
+ maybeOnSpellCheck(textbox, function () {
+ // test that map dictionary is in use
+ is(getMisspelledWords(editor), "created" + "imply" + "tomorrow" + "qwertyu", "map misspellings (1)");
+ is(getCurrentDictionary(editor), "maputf", "current dictionary");
+
+ // uninstall map dictionary
+ hunspell.removeDirectory(map);
+
+ // Focus again, so the spelling gets updated.
+ textbox.blur();
+ textbox.focus();
+
+ maybeOnSpellCheck(textbox, function () {
+ // test that map dictionary is not in use
+ isnot(getMisspelledWords(editor), "created" + "imply" + "tomorrow" + "qwertyu", "map misspellings (2)");
+ isnot(getCurrentDictionary(editor), "maputf", "current dictionary");
+
+ // test that base dictionary is available and map dictionary is unavailable
+ var dicts = getDictionaryList(editor);
+ isnot(dicts.indexOf("base-utf"), -1, "base is available");
+ is(dicts.indexOf("maputf"), -1, "map is unavailable");
+
+ // uninstall base dictionary
+ hunspell.removeDirectory(base);
+
+ maybeOnSpellCheck(textbox, function () {
+ SimpleTest.finish();
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+}
+ ]]>
+ </script>
+ <html:input id="textbox" spellcheck="true" value="created imply Frühstück tomorrow qwertyu"/>
+</window>