Bug 1433876 - Wrap earlyformsubmit observer in try…catch to ensure autofill never stops form submission. r=johannh
MozReview-Commit-ID: PO0p8wd9Jw
--- a/browser/extensions/formautofill/FormAutofillContent.jsm
+++ b/browser/extensions/formautofill/FormAutofillContent.jsm
@@ -382,40 +382,44 @@ var FormAutofillContent = {
* 2. Could not map any autofill handler by form element.
* 3. Number of filled fields is less than autofill threshold
*
* @param {HTMLElement} formElement Root element which receives earlyformsubmit event.
* @param {Object} domWin Content window
* @returns {boolean} Should always return true so form submission isn't canceled.
*/
notify(formElement, domWin) {
- this.log.debug("Notifying form early submission");
+ try {
+ this.log.debug("Notifying form early submission");
- if (!FormAutofillUtils.isAutofillEnabled) {
- this.log.debug("Form Autofill is disabled");
- return true;
- }
+ if (!FormAutofillUtils.isAutofillEnabled) {
+ this.log.debug("Form Autofill is disabled");
+ return true;
+ }
- if (domWin && PrivateBrowsingUtils.isContentWindowPrivate(domWin)) {
- this.log.debug("Ignoring submission in a private window");
- return true;
- }
+ if (domWin && PrivateBrowsingUtils.isContentWindowPrivate(domWin)) {
+ this.log.debug("Ignoring submission in a private window");
+ return true;
+ }
- let handler = this._formsDetails.get(formElement);
- if (!handler) {
- this.log.debug("Form element could not map to an existing handler");
- return true;
- }
+ let handler = this._formsDetails.get(formElement);
+ if (!handler) {
+ this.log.debug("Form element could not map to an existing handler");
+ return true;
+ }
- let records = handler.createRecords();
- if (!Object.values(records).some(typeRecords => typeRecords.length)) {
- return true;
+ let records = handler.createRecords();
+ if (!Object.values(records).some(typeRecords => typeRecords.length)) {
+ return true;
+ }
+
+ this._onFormSubmit(records, domWin, handler.timeStartedFillingMS);
+ } catch (ex) {
+ Cu.reportError(ex);
}
-
- this._onFormSubmit(records, domWin, handler.timeStartedFillingMS);
return true;
},
receiveMessage({name, data}) {
switch (name) {
case "FormAutofill:enabledStatus": {
if (data) {
ProfileAutocomplete.ensureRegistered();