Bug 1350264 - Allow users to re-enable form autofill feature after all populated fields were cleared manually, r=lchang
MozReview-Commit-ID: DG31YXJuT2t
--- a/browser/extensions/formautofill/FormAutofillHandler.jsm
+++ b/browser/extensions/formautofill/FormAutofillHandler.jsm
@@ -171,20 +171,21 @@ FormAutofillHandler.prototype = {
if (e.target == element || (e.target == element.form && e.type == "reset")) {
this.changeFieldState(fieldDetail, "NORMAL");
}
hasFilledFields |= (fieldDetail.state == "AUTO_FILLED");
}
- // Unregister listeners once no field is in AUTO_FILLED state.
+ // Unregister listeners and clear guid once no field is in AUTO_FILLED state.
if (!hasFilledFields) {
this.form.rootElement.removeEventListener("input", onChangeHandler);
this.form.rootElement.removeEventListener("reset", onChangeHandler);
+ this.filledProfileGUID = null;
}
};
this.form.rootElement.addEventListener("input", onChangeHandler);
this.form.rootElement.addEventListener("reset", onChangeHandler);
},
/**
--- a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
+++ b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
@@ -150,16 +150,28 @@ add_task(async function check_fields_aft
// Fallback to history search after autofill address.
add_task(async function check_fallback_after_form_autofill() {
await setInput("#tel", "");
doKey("down");
await expectPopup();
checkMenuEntries(["1-234-567-890"]);
});
+// Resume form autofill once all the autofilled fileds are changed.
+add_task(async function check_form_autofill_resume() {
+ document.querySelector("#tel").blur();
+ document.querySelector("#form1").reset();
+ await setInput("#tel", "");
+ doKey("down");
+ await expectPopup();
+ checkMenuEntries(MOCK_STORAGE.map(address =>
+ JSON.stringify({primary: address.tel, secondary: address["street-address"]})
+ ));
+});
+
registerPopupShownListener(popupShownListener);
</script>
<p id="display"></p>
<div id="content">