зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1347426 - Implement section-* for autocomplete attribute. r=smaug
--HG-- extra : rebase_source : d32f3391a4094099086ce9c1897196175705acd9
This commit is contained in:
Родитель
35f3699a4e
Коммит
57cad067ba
|
@ -1011,7 +1011,7 @@ nsContentUtils::InternalSerializeAutocompleteAttribute(const nsAttrValue* aAttrV
|
|||
}
|
||||
|
||||
// Normal category
|
||||
if (numTokens > 2) {
|
||||
if (numTokens > 3) {
|
||||
return eAutocompleteAttrState_Invalid;
|
||||
}
|
||||
category = eAutocompleteCategory_NORMAL;
|
||||
|
@ -1022,7 +1022,7 @@ nsContentUtils::InternalSerializeAutocompleteAttribute(const nsAttrValue* aAttrV
|
|||
}
|
||||
|
||||
result = enumValue.ParseEnumValue(tokenString, kAutocompleteContactFieldNameTable, false);
|
||||
if (!result || numTokens > 3) {
|
||||
if (!result || numTokens > 4) {
|
||||
return eAutocompleteAttrState_Invalid;
|
||||
}
|
||||
|
||||
|
@ -1068,9 +1068,21 @@ nsContentUtils::InternalSerializeAutocompleteAttribute(const nsAttrValue* aAttrV
|
|||
return eAutocompleteAttrState_Valid;
|
||||
}
|
||||
--index;
|
||||
tokenString = nsDependentAtomString(aAttrVal->AtomAt(index));
|
||||
}
|
||||
|
||||
// Check for section-* token
|
||||
const nsDependentSubstring& section = Substring(tokenString, 0, 8);
|
||||
if (section.LowerCaseEqualsASCII("section-")) {
|
||||
ASCIIToLower(tokenString);
|
||||
aInfo.mSection.Assign(tokenString);
|
||||
if (index == 0) {
|
||||
return eAutocompleteAttrState_Valid;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the fields as the autocomplete attribute is invalid.
|
||||
aInfo.mSection.Truncate();
|
||||
aInfo.mAddressType.Truncate();
|
||||
aInfo.mContactType.Truncate();
|
||||
aInfo.mFieldName.Truncate();
|
||||
|
|
|
@ -33,6 +33,7 @@ var values = [
|
|||
["username", {fieldName: "username" }],
|
||||
[" username ", {fieldName: "username" }],
|
||||
["foobar", {}],
|
||||
["section-blue", {}],
|
||||
|
||||
// Two tokens
|
||||
["on off", {}],
|
||||
|
@ -48,6 +49,10 @@ var values = [
|
|||
[" MoBiLe TeL ", {contactType: "mobile", fieldName: "tel"}],
|
||||
["XXX tel", {}],
|
||||
["XXX username", {}],
|
||||
["name section-blue", {}],
|
||||
["scetion-blue cc-name", {}],
|
||||
["section-blue name", {section: "section-blue", fieldName: "name"}],
|
||||
["section-blue tel", {section: "section-blue", fieldName: "tel"}],
|
||||
|
||||
// Three tokens
|
||||
["billing invalid tel", {}],
|
||||
|
@ -58,12 +63,22 @@ var values = [
|
|||
["billing mobile tel", {addressType: "billing", contactType: "mobile", fieldName: "tel"}],
|
||||
[" BILLing MoBiLE tEl ", {addressType: "billing", contactType: "mobile", fieldName: "tel"}],
|
||||
["billing home tel", {addressType: "billing", contactType: "home", fieldName: "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 mobile tel", {section: "section-blue", contactType: "mobile", fieldName: "tel"}],
|
||||
|
||||
// Four tokens (invalid)
|
||||
// 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"}],
|
||||
|
||||
// Five tokens (invalid)
|
||||
["billing billing billing mobile tel", {}],
|
||||
["section-blue section-blue billing mobile tel", {}],
|
||||
];
|
||||
|
||||
var autocompleteEnabledTypes = ["hidden", "text", "search", "url", "tel",
|
||||
|
|
|
@ -25,6 +25,7 @@ var values = [
|
|||
["username", "username"],
|
||||
[" username ", "username"],
|
||||
["foobar", ""],
|
||||
["section-blue", ""],
|
||||
|
||||
// Two tokens
|
||||
["on off", ""],
|
||||
|
@ -40,6 +41,10 @@ var values = [
|
|||
[" MoBiLe TeL ", "mobile tel"],
|
||||
["XXX tel", ""],
|
||||
["XXX username", ""],
|
||||
["name section-blue", ""],
|
||||
["scetion-blue cc-name", ""],
|
||||
["section-blue name", "section-blue name"],
|
||||
["section-blue tel", "section-blue tel"],
|
||||
|
||||
// Three tokens
|
||||
["billing invalid tel", ""],
|
||||
|
@ -50,12 +55,22 @@ var values = [
|
|||
["billing mobile tel", "billing mobile tel"],
|
||||
[" BILLing MoBiLE tEl ", "billing mobile tel"],
|
||||
["billing home tel", "billing home tel"],
|
||||
["home section-blue tel", ""],
|
||||
["setion-blue work email", ""],
|
||||
["section-blue home address-level2", ""],
|
||||
["section-blue shipping name", "section-blue shipping name"],
|
||||
["section-blue mobile tel", "section-blue mobile tel"],
|
||||
|
||||
// Four tokens (invalid)
|
||||
// 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-blue shipping mobile tel"],
|
||||
|
||||
// Five tokens (invalid)
|
||||
["billing billing billing mobile tel", ""],
|
||||
["section-blue section-blue billing mobile tel", ""],
|
||||
];
|
||||
|
||||
var types = [undefined, "hidden", "text", "search"]; // Valid types for all non-multiline hints.
|
||||
|
|
Загрузка…
Ссылка в новой задаче