Bug 1433876 - Wrap earlyformsubmit observer in try…catch to ensure autofill never stops form submission. r=johannh
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 07 Feb 2018 22:26:15 -0800
changeset 468543 043ccfe81258c1d7da67b7ff4f6b88689e976246
parent 468542 8473057ddc37eee5d6ef9a3a3ddc5bd78442ed29
child 468544 bad9ca5f4c9b9b6092fa6672a9c7269ac58b2204
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1433876
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1433876 - Wrap earlyformsubmit observer in try…catch to ensure autofill never stops form submission. r=johannh MozReview-Commit-ID: PO0p8wd9Jw
browser/extensions/formautofill/FormAutofillContent.jsm
--- 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();