summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests/browser/browser_InlineSpellChecker.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/modules/tests/browser/browser_InlineSpellChecker.js')
-rw-r--r--toolkit/modules/tests/browser/browser_InlineSpellChecker.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/toolkit/modules/tests/browser/browser_InlineSpellChecker.js b/toolkit/modules/tests/browser/browser_InlineSpellChecker.js
new file mode 100644
index 0000000000..650a03c43e
--- /dev/null
+++ b/toolkit/modules/tests/browser/browser_InlineSpellChecker.js
@@ -0,0 +1,53 @@
+var InlineSpellChecker;
+var SpellCheckHelper;
+
+function test() {
+ let tempScope = ChromeUtils.importESModule(
+ "resource://gre/modules/InlineSpellChecker.sys.mjs"
+ );
+ InlineSpellChecker = tempScope.InlineSpellChecker;
+ SpellCheckHelper = tempScope.SpellCheckHelper;
+
+ ok(InlineSpellChecker, "InlineSpellChecker class exists");
+ for (var fname in tests) {
+ tests[fname]();
+ }
+}
+
+var tests = {
+ testFlagsForInputs() {
+ const HTML_NS = "http://www.w3.org/1999/xhtml";
+ const {
+ INPUT,
+ EDITABLE,
+ TEXTINPUT,
+ NUMERIC,
+ PASSWORD,
+ SPELLCHECKABLE,
+ } = SpellCheckHelper;
+ const kExpectedResults = {
+ text: INPUT | EDITABLE | TEXTINPUT | SPELLCHECKABLE,
+ password: INPUT | EDITABLE | TEXTINPUT | PASSWORD,
+ search: INPUT | EDITABLE | TEXTINPUT | SPELLCHECKABLE,
+ url: INPUT | EDITABLE | TEXTINPUT,
+ tel: INPUT | EDITABLE | TEXTINPUT,
+ email: INPUT | EDITABLE | TEXTINPUT,
+ number: INPUT | EDITABLE | TEXTINPUT | NUMERIC,
+ checkbox: INPUT,
+ radio: INPUT,
+ };
+
+ for (let [type, expectedFlags] of Object.entries(kExpectedResults)) {
+ let input = document.createElementNS(HTML_NS, "input");
+ input.type = type;
+ let actualFlags = SpellCheckHelper.isEditable(input, window);
+ is(
+ actualFlags,
+ expectedFlags,
+ `For input type "${type}" expected flags ${"0x" +
+ expectedFlags.toString(16)}; ` +
+ `got ${"0x" + actualFlags.toString(16)}`
+ );
+ }
+ },
+};