Bug 1350264 - Allow users to re-enable form autofill feature after all populated fields were cleared manually, r=lchang

MozReview-Commit-ID: DG31YXJuT2t

--HG--
extra : rebase_source : 2a027b4d8ccdf0b385454783901dece914003623
This commit is contained in:
steveck-chung 2017-06-15 16:31:51 +08:00
Родитель 4a3a84f39f
Коммит d309b485e7
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -185,10 +185,11 @@ FormAutofillHandler.prototype = {
hasFilledFields |= (fieldDetail.state == "AUTO_FILLED"); 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) { if (!hasFilledFields) {
this.form.rootElement.removeEventListener("input", onChangeHandler); this.form.rootElement.removeEventListener("input", onChangeHandler);
this.form.rootElement.removeEventListener("reset", onChangeHandler); this.form.rootElement.removeEventListener("reset", onChangeHandler);
this.filledProfileGUID = null;
} }
}; };

Просмотреть файл

@ -164,6 +164,18 @@ add_task(async function check_fallback_after_form_autofill() {
checkMenuEntries(["1-234-567-890"]); 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); registerPopupShownListener(popupShownListener);
</script> </script>