diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /extensions/spellcheck/tests | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'extensions/spellcheck/tests')
9 files changed, 457 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 000000000..493157b30 --- /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 000000000..b2b536d28 --- /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 000000000..cdd20b9cd --- /dev/null +++ b/extensions/spellcheck/tests/chrome/chrome.ini @@ -0,0 +1,9 @@ +[DEFAULT] +skip-if = os == 'android' + +[test_add_remove_dictionaries.xul] +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 000000000..30edb2a78 --- /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 000000000..1c6fa8d05 --- /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.xul b/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul new file mode 100644 index 000000000..661eaccff --- /dev/null +++ b/extensions/spellcheck/tests/chrome/test_add_remove_dictionaries.xul @@ -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" + onload="RunTest();"> + + <script type="application/javascript" + 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(Components.interfaces.nsISelectionController.SELECTION_SPELLCHECK).toString(); +} + +function getDictionaryList(editor) { + var spellchecker = editor.getInlineSpellChecker(true).spellChecker; + var o1 = {}; + spellchecker.GetDictionaryList(o1, {}); + return o1.value; +} + +function getCurrentDictionary(editor) { + var spellchecker = editor.getInlineSpellChecker(true).spellChecker; + return spellchecker.GetCurrentDictionary(); +} + +function setCurrentDictionary(editor, dictionary) { + var spellchecker = editor.getInlineSpellChecker(true).spellChecker; + spellchecker.SetCurrentDictionary(dictionary); +} + +function RunTest() { + var textbox = document.getElementById('textbox'); + textbox.focus(); + var editor = textbox.editor; + + var dir = Components.classes["@mozilla.org/file/directory_service;1"]. + getService(Components.interfaces.nsIProperties). + get("CurWorkD", Components.interfaces.nsIFile); + dir.append("chrome"); + dir.append("extensions"); + dir.append("spellcheck"); + dir.append("tests"); + dir.append("chrome"); + + var hunspell = Components + .classes["@mozilla.org/spellchecker/engine;1"] + .getService(Components.interfaces.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); + + Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm"); + onSpellCheck(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"); + + onSpellCheck(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"); + + // Focus again, so the spelling gets updated. + textbox.blur(); + textbox.focus(); + + onSpellCheck(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(); + + onSpellCheck(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); + + onSpellCheck(textbox, function () { + SimpleTest.finish(); + }); + }); + }); + }); + }); +} + ]]> + </script> + <textbox id="textbox" spellcheck="true" value="created imply Frühstück tomorrow qwertyu"/> +</window> diff --git a/extensions/spellcheck/tests/mochitest/helper_bug1170484.js b/extensions/spellcheck/tests/mochitest/helper_bug1170484.js new file mode 100644 index 000000000..0a26448ee --- /dev/null +++ b/extensions/spellcheck/tests/mochitest/helper_bug1170484.js @@ -0,0 +1,15 @@ +var Cu = Components.utils; +var Ci = Components.interfaces; + +Cu.import("resource://gre/modules/Services.jsm"); + +// Chrome scripts are run with synchronous messages, so make sure we're completely +// decoupled from the content process before doing this work. +Cu.dispatch(function() { + let chromeWin = Services.ww.activeWindow.QueryInterface(Ci.nsIDOMChromeWindow); + contextMenu = chromeWin.document.getElementById("contentAreaContextMenu"); + var suggestion = contextMenu.querySelector(".spell-suggestion"); + suggestion.doCommand(); + contextMenu.hidePopup(); + sendAsyncMessage("spellingCorrected"); +}); diff --git a/extensions/spellcheck/tests/mochitest/mochitest.ini b/extensions/spellcheck/tests/mochitest/mochitest.ini new file mode 100644 index 000000000..4bf02b253 --- /dev/null +++ b/extensions/spellcheck/tests/mochitest/mochitest.ini @@ -0,0 +1,6 @@ +[DEFAULT] +skip-if = os == 'android' + +[test_bug1170484.html] +support-files = helper_bug1170484.js +skip-if = os == 'linux' #Bug 1202570 diff --git a/extensions/spellcheck/tests/mochitest/test_bug1170484.html b/extensions/spellcheck/tests/mochitest/test_bug1170484.html new file mode 100644 index 000000000..bdfb39f18 --- /dev/null +++ b/extensions/spellcheck/tests/mochitest/test_bug1170484.html @@ -0,0 +1,56 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1170484 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1170484</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script type="application/javascript"> + + /** Test for Bug 1170484 **/ + SimpleTest.waitForExplicitFinish(); + SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", window); + + SimpleTest.waitForFocus(doTest, window); + function doTest() { + var mutations = 0; + var observer = new MutationObserver(() => { mutations++; }); + observer.observe($('area'), { childList: true, characterData: true, characterDataOldValue: true, subtree: true }); + var inputEvents = 0; + $('area').addEventListener('input', () => ++inputEvents); + + // Clicking the contentEditable during onload doesn't seem to do anything. + // Not sure why, but postponing through the event loop seems to be enough. + SimpleTest.executeSoon(function() { + synthesizeMouseAtCenter($('misspelled'), {}, window); + onSpellCheck($('area'), function() { + synthesizeMouseAtCenter($('misspelled'), {type: 'contextmenu'}, window); + var mm = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('helper_bug1170484.js')) + info("Loaded chrome script"); + mm.addMessageListener('spellingCorrected', function() { + is($('area').textContent, 'testing spellcheck', "Spelling corrected properly"); + is(mutations, 1, "Got correct number of mutations"); + is(inputEvents, 1, "Got correct number of input events"); + SimpleTest.finish(); + }); + }); + }); + } + + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1170484">Mozilla Bug 1170484</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> + <div id="area" contenteditable="true">testing <span id="misspelled">spellechek</span></div> +</pre> +</body> +</html> |