зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1333353 - Implement getAutocompleteInfo() for select element. r=smaug
This commit is contained in:
Родитель
3738e5b90a
Коммит
f051812614
|
@ -203,6 +203,15 @@ HTMLSelectElement::GetAutocomplete(DOMString& aValue)
|
|||
mAutocompleteAttrState);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLSelectElement::GetAutocompleteInfo(AutocompleteInfo& aInfo)
|
||||
{
|
||||
const nsAttrValue* attributeVal = GetParsedAttr(nsGkAtoms::autocomplete);
|
||||
mAutocompleteAttrState =
|
||||
nsContentUtils::SerializeAutocompleteAttribute(attributeVal, aInfo,
|
||||
mAutocompleteAttrState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLSelectElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
||||
{
|
||||
|
|
|
@ -177,6 +177,9 @@ public:
|
|||
{
|
||||
SetHTMLAttr(nsGkAtoms::autocomplete, aValue, aRv);
|
||||
}
|
||||
|
||||
void GetAutocompleteInfo(AutocompleteInfo& aInfo);
|
||||
|
||||
bool Disabled() const
|
||||
{
|
||||
return GetBoolAttr(nsGkAtoms::disabled);
|
||||
|
|
|
@ -14,6 +14,7 @@ Test getAutocompleteInfo() on <input>
|
|||
<div id="content" style="display: none">
|
||||
<form>
|
||||
<input id="input"/>
|
||||
<select id="select" />
|
||||
</form>
|
||||
</div>
|
||||
<pre id="test">
|
||||
|
@ -72,26 +73,8 @@ var autocompleteDisabledTypes = ["reset", "submit", "image", "button", "radio",
|
|||
"checkbox", "file"];
|
||||
|
||||
function start() {
|
||||
const fieldid = "input";
|
||||
var 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();
|
||||
|
||||
is(info.section, "section" in test[1] ? test[1].section : "",
|
||||
"Checking autocompleteInfo.section for " + fieldid + ": " + test[0]);
|
||||
is(info.addressType, "addressType" in test[1] ? test[1].addressType : "",
|
||||
"Checking autocompleteInfo.addressType for " + fieldid + ": " + test[0]);
|
||||
is(info.contactType, "contactType" in test[1] ? test[1].contactType : "",
|
||||
"Checking autocompleteInfo.contactType for " + fieldid + ": " + test[0]);
|
||||
is(info.fieldName, "fieldName" in test[1] ? test[1].fieldName : "",
|
||||
"Checking autocompleteInfo.fieldName for " + fieldid + ": " + test[0]);
|
||||
|
||||
}
|
||||
let field = document.getElementById("input");
|
||||
testAutocompleteInfoValue(field, "input");
|
||||
|
||||
for (var type of autocompleteEnabledTypes) {
|
||||
testAutocomplete(field, type, true);
|
||||
|
@ -100,9 +83,33 @@ function start() {
|
|||
for (var type of autocompleteDisabledTypes) {
|
||||
testAutocomplete(field, type, false);
|
||||
}
|
||||
|
||||
field = document.getElementById("select");
|
||||
testAutocompleteInfoValue(field, "select");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function testAutocompleteInfoValue(aField, aFieldId) {
|
||||
for (var test of values) {
|
||||
if (typeof(test[0]) === "undefined")
|
||||
aField.removeAttribute("autocomplete");
|
||||
else
|
||||
aField.setAttribute("autocomplete", test[0]);
|
||||
|
||||
var info = aField.getAutocompleteInfo();
|
||||
|
||||
is(info.section, "section" in test[1] ? test[1].section : "",
|
||||
"Checking autocompleteInfo.section for " + aFieldId + ": " + test[0]);
|
||||
is(info.addressType, "addressType" in test[1] ? test[1].addressType : "",
|
||||
"Checking autocompleteInfo.addressType for " + aFieldId + ": " + test[0]);
|
||||
is(info.contactType, "contactType" in test[1] ? test[1].contactType : "",
|
||||
"Checking autocompleteInfo.contactType for " + aFieldId + ": " + test[0]);
|
||||
is(info.fieldName, "fieldName" in test[1] ? test[1].fieldName : "",
|
||||
"Checking autocompleteInfo.fieldName for " + aFieldId + ": " + test[0]);
|
||||
}
|
||||
}
|
||||
|
||||
function testAutocomplete(aField, aType, aEnabled) {
|
||||
aField.type = aType;
|
||||
if (aEnabled) {
|
||||
|
|
|
@ -60,7 +60,11 @@ interface HTMLSelectElement : HTMLElement {
|
|||
void remove();
|
||||
};
|
||||
|
||||
// Chrome only interface
|
||||
|
||||
partial interface HTMLSelectElement {
|
||||
[ChromeOnly]
|
||||
attribute boolean openInParentProcess;
|
||||
[ChromeOnly]
|
||||
AutocompleteInfo getAutocompleteInfo();
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче