add_task(async function basic() {
const tests = [
{ id: "a1", inputmode: "none", desc: "inputmode of input element is none" },
{ id: "a2", inputmode: "text", desc: "inputmode of input element is text" },
{ id: "a3", inputmode: "tel", desc: "inputmode of input element is tel" },
{ id: "a4", inputmode: "url", desc: "inputmode of input element is url" },
{ id: "a5", inputmode: "email", desc: "inputmode of input element is email" },
{ id: "a6", inputmode: "numeric", desc: "inputmode of input element is numeric" },
{ id: "a7", inputmode: "decimal", desc: "inputmode of input element is decimal" },
{ id: "a8", inputmode: "search", desc: "inputmode of input element is search" },
{ id: "a9", inputmode: "", desc: "no inputmode of input element" },
{ id: "a10", inputmode: "numeric", desc: "inputmode of input type=number is numeric" },
{ id: "a11", inputmode: "", desc: "no inputmode due to type=date" },
{ id: "a12", inputmode: "", desc: "no inputmode due to type=time" },
{ id: "b1", inputmode: "none", desc: "inputmode of textarea element is none" },
{ id: "b2", inputmode: "text", desc: "inputmode of textarea element is text" },
{ id: "b3", inputmode: "tel", desc: "inputmode of textarea element is tel" },
{ id: "b4", inputmode: "url", desc: "inputmode of textarea element is url" },
{ id: "b5", inputmode: "email", desc: "inputmode of textarea element is email" },
{ id: "b6", inputmode: "numeric", desc: "inputmode of textarea element is numeric" },
{ id: "b7", inputmode: "decimal", desc: "inputmode of textarea element is decimal" },
{ id: "b8", inputmode: "search", desc: "inputmode of textarea element is search" },
{ id: "b9", inputmode: "", desc: "no inputmode of textarea element" },
{ id: "c1", inputmode: "none", desc: "inputmode of contenteditable is none" },
{ id: "c2", inputmode: "text", desc: "inputmode of contenteditable is text" },
{ id: "c3", inputmode: "tel", desc: "inputmode of contentedtiable is tel" },
{ id: "c4", inputmode: "url", desc: "inputmode of contentedtiable is url" },
{ id: "c5", inputmode: "email", desc: "inputmode of contentedtable is email" },
{ id: "c6", inputmode: "numeric", desc: "inputmode of contenteditable is numeric" },
{ id: "c7", inputmode: "decimal", desc: "inputmode of contenteditable is decimal" },
{ id: "c8", inputmode: "search", desc: "inputmode of contenteditable is search" },
{ id: "c9", inputmode: "", desc: "no inputmode of contentedtiable" },
{ id: "d1", inputmode: "url", desc: "inputmode of input element is URL" },
];
for (let test of tests) {
let element = document.getElementById(test.id);
if (element.tagName == "DIV") {
// Set caret to text node in contenteditable
window.getSelection().removeAllRanges();
let range = document.createRange();
range.setStart(element.firstChild.firstChild, 1);
range.setEnd(element.firstChild.firstChild, 1);
window.getSelection().addRange(range);
} else {
// input and textarea element
element.focus();
}
is(SpecialPowers.DOMWindowUtils.focusedInputMode, test.inputmode, test.desc);
}
});
add_task(async function dynamicChange() {
const tests = ["a3", "b3", "c3"];
for (let test of tests) {
let element = document.getElementById(test);
element.focus();
is(SpecialPowers.DOMWindowUtils.focusedInputMode, "tel", "Initial inputmode");
element.inputMode = "url";
is(SpecialPowers.DOMWindowUtils.focusedInputMode, "url", "inputmode in InputContext has to sync with current inputMode property");
element.setAttribute("inputmode", "decimal");
is(SpecialPowers.DOMWindowUtils.focusedInputMode, "decimal", "inputmode in InputContext has to sync with current inputmode attribute");
// Storing the original value may be safer.
element.inputMode = "tel";
}
let element = document.getElementById("a3");
element.focus();
is(SpecialPowers.DOMWindowUtils.focusedInputMode, "tel", "Initial inputmode");
document.getElementById("a4").inputMode = "email";
is(SpecialPowers.DOMWindowUtils.focusedInputMode, "tel", "inputmode in InputContext keeps focused inputmode value");
// Storing the original value may be safer.
document.getElementById("a4").inputMode = "url";
});
</script>
</pre>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.