// Two tokens + WebAuthn credential type
["fax url webauthn", {}, ""],
["shipping tel webauthn", {addressType: "shipping", fieldName: "tel", credentialType: "webauthn"}, "shipping tel webauthn"],
// Three tokens
["billing invalid tel", {}, ""],
["___ mobile tel", {}, ""],
["mobile foo tel", {}, ""],
["mobile tel foo", {}, ""],
["tel mobile billing", {}, ""],
["billing mobile tel", {addressType: "billing", contactType: "mobile", fieldName: "tel"}, "billing mobile tel"],
[" BILLing MoBiLE tEl ", {addressType: "billing", contactType: "mobile", fieldName: "tel"}, "billing mobile tel"],
["billing home tel", {addressType: "billing", contactType: "home", fieldName: "tel"}, "billing home tel"],
["home section-blue tel", {}, ""],
["setion-blue work email", {}, ""],
["section-blue home address-level2", {}, ""],
["section-blue shipping name", {section: "section-blue", addressType: "shipping", fieldName: "name"}, "section-blue shipping name"],
["section-blue mobile tel", {section: "section-blue", contactType: "mobile", fieldName: "tel"}, "section-blue mobile tel"],
["shipping webauthn tel", {}, ""],
// Three tokens + WebAuthn credential type
["invalid mobile tel webauthn", {}, ""],
["section-blue shipping name webauthn", {section: "section-blue", addressType: "shipping", fieldName: "name", credentialType: "webauthn"}, "section-blue shipping name webauthn"],
// Four tokens
["billing billing mobile tel", {}, ""],
["name section-blue shipping home", {}, ""],
["secti shipping work address-line1", {}, ""],
["section-blue shipping home name", {}, ""],
["section-blue shipping mobile tel", {section: "section-blue", addressType: "shipping", contactType: "mobile", fieldName: "tel"}, "section-blue shipping mobile tel"],
["section-blue webauthn mobile tel", {}, ""],
// Four tokens + WebAuthn credential type
["section-blue shipping home name webauthn", {}, ""],
["section-blue shipping mobile tel webauthn", {section: "section-blue", addressType: "shipping", contactType: "mobile", fieldName: "tel", credentialType: "webauthn"}, "section-blue shipping mobile tel webauthn"],
// Five tokens (invalid)
["billing billing billing mobile tel", {}, ""],
["section-blue section-blue billing mobile tel", {}, ""],
["section-blue section-blue billing webauthn tel", {}, ""],
// Five tokens + WebAuthn credential type (invalid)
["billing billing billing mobile tel webauthn", {}, ""],
];
var autocompleteInfoFieldIds = ["input", "select"]; var autocompleteEnabledTypes = ["hidden", "text", "search", "url", "tel", "email", "password", "date", "time", "number", "range", "color"]; var autocompleteDisabledTypes = ["reset", "submit", "image", "button", "radio", "checkbox", "file"];
function testInputTypes() {
let field = document.getElementById("input");
for (var type of autocompleteEnabledTypes) {
testAutocomplete(field, type, true);
}
for (var type of autocompleteDisabledTypes) {
testAutocomplete(field, type, false);
}
// Clear input type attribute.
field.removeAttribute("type");
}
function testAutocompleteInfoValue(aEnabled) {
for (var fieldId of autocompleteInfoFieldIds) {
let field = document.getElementById(fieldId);
for (var test of values) {
if (typeof(test[0]) === "undefined")
field.removeAttribute("autocomplete");
else
field.setAttribute("autocomplete", test[0]);
var info = field.getAutocompleteInfo();
if (aEnabled) {
// We need to consider if getAutocompleteInfo() is valid,
// but @autocomplete is invalid case, because @autocomplete
// has smaller set of values.
is(field.autocomplete, test[2], "Checking @autocomplete of: " + test[0]);
}
is(info.section, "section" in test[1] ? test[1].section : "", "Checking autocompleteInfo.section for " + field + ": " + test[0]);
is(info.addressType, "addressType" in test[1] ? test[1].addressType : "", "Checking autocompleteInfo.addressType for " + field + ": " + test[0]);
is(info.contactType, "contactType" in test[1] ? test[1].contactType : "", "Checking autocompleteInfo.contactType for " + field + ": " + test[0]);
is(info.fieldName, "fieldName" in test[1] ? test[1].fieldName : "", "Checking autocompleteInfo.fieldName for " + field + ": " + test[0]);
is(info.credentialType, "credentialType" in test[1] ? test[1].credentialType: "", "Checking autocompleteInfo.credentialType for " + field + ": " + test[0]);
is(info.canAutomaticallyPersist, "canAutomaticallyPersist" in test[1] ? test[1].canAutomaticallyPersist : true, "Checking autocompleteInfo.canAutomaticallyPersist for " + field + ": " + test[0]);
}
}
}
function testAutocomplete(aField, aType, aEnabled) {
aField.type = aType;
if (aEnabled) {
ok(aField.getAutocompleteInfo() !== null, "getAutocompleteInfo shouldn't return null");
} else {
is(aField.getAutocompleteInfo(), null, "getAutocompleteInfo should return null");
}
}
// getAutocompleteInfo() should be able to parse all tokens as defined
// in the spec regardless of whether dom.forms.autocomplete.formautofill pref
// is on or off.
add_task(async function testAutocompletePreferenceEnabled() {
await SpecialPowers.pushPrefEnv({"set": [["dom.forms.autocomplete.formautofill", true]]}, testInputTypes);
testAutocompleteInfoValue(true);
});
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.