Bug 1242505 - Part 1 - Handle more rejections in code exercised by browser-chrome tests. r=Mossop draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Thu, 25 May 2017 15:00:22 +0100
changeset 585614 83a77cbfe5629abe99ae575b57592361ea9627b8
parent 585613 498914c84ab69dd484fb5487ad9967073c331fd3
child 585615 de5fa91a5e9769c7ca42fc2c00ea54f169a3e12b
push id61146
push userpaolo.mozmail@amadzone.org
push dateSat, 27 May 2017 08:22:25 +0000
reviewersMossop
bugs1242505
milestone55.0a1
Bug 1242505 - Part 1 - Handle more rejections in code exercised by browser-chrome tests. r=Mossop MozReview-Commit-ID: JTMgC2XwzX2
browser/components/extensions/ExtensionPopups.jsm
browser/components/sessionstore/SessionStore.jsm
browser/extensions/shield-recipe-client/lib/PreferenceExperiments.jsm
browser/modules/ContentCrashHandlers.jsm
devtools/server/actors/webextension-inspected-window.js
--- a/browser/components/extensions/ExtensionPopups.jsm
+++ b/browser/components/extensions/ExtensionPopups.jsm
@@ -111,16 +111,18 @@ class BasePopup {
     this.closePopup();
   }
 
   destroy() {
     this.extension.forgetOnClose(this);
 
     this.destroyed = true;
     this.browserLoadedDeferred.reject(new Error("Popup destroyed"));
+    // Ignore unhandled rejections if the "attach" method is not called.
+    this.browserLoaded.catch(() => {});
 
     BasePopup.instances.get(this.window).delete(this.extension);
 
     return this.browserReady.then(() => {
       if (this.browser) {
         this.destroyBrowser(this.browser, true);
         this.browser.remove();
       }
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -1305,17 +1305,17 @@ var SessionStoreInternal = {
         }
         TelemetryStopwatch.start("FX_SESSION_RESTORE_STARTUP_ONLOAD_INITIAL_WINDOW_MS");
         this.initializeWindow(aWindow, initialState);
         TelemetryStopwatch.finish("FX_SESSION_RESTORE_STARTUP_ONLOAD_INITIAL_WINDOW_MS");
 
         // Let everyone know we're done.
         this._deferredInitialized.resolve();
       }
-    }, console.error);
+    }).catch(console.error);
   },
 
   /**
    * On window close...
    * - remove event listeners from tabs
    * - save all window data
    * @param aWindow
    *        Window reference
--- a/browser/extensions/shield-recipe-client/lib/PreferenceExperiments.jsm
+++ b/browser/extensions/shield-recipe-client/lib/PreferenceExperiments.jsm
@@ -250,17 +250,18 @@ this.PreferenceExperiments = {
         `An observer for the preference experiment ${experimentName} is already active.`
       );
     }
 
     const observerInfo = {
       preferenceName,
       observer(newValue) {
         if (newValue !== preferenceValue) {
-          PreferenceExperiments.stop(experimentName, false);
+          PreferenceExperiments.stop(experimentName, false)
+                               .catch(Cu.reportError);
         }
       },
     };
     experimentObservers.set(experimentName, observerInfo);
     Preferences.observe(preferenceName, observerInfo.observer);
   },
 
   /**
--- a/browser/modules/ContentCrashHandlers.jsm
+++ b/browser/modules/ContentCrashHandlers.jsm
@@ -378,17 +378,17 @@ this.TabCrashHandler = {
     // with the empty string.
     if (!includeURL) {
       extraExtraKeyVals["URL"] = "";
     }
 
     CrashSubmit.submit(dumpID, {
       recordSubmission: true,
       extraExtraKeyVals,
-    }).then(null, Cu.reportError);
+    }).catch(Cu.reportError);
 
     this.prefs.setBoolPref("sendReport", true);
     this.prefs.setBoolPref("includeURL", includeURL);
     this.prefs.setBoolPref("emailMe", emailMe);
     if (emailMe) {
       this.prefs.setCharPref("email", email);
     } else {
       this.prefs.setCharPref("email", "");
@@ -876,17 +876,17 @@ this.UnsubmittedCrashHandler = {
    *        The array of reportIDs to submit.
    */
   submitReports(reportIDs) {
     for (let reportID of reportIDs) {
       CrashSubmit.submit(reportID, {
         extraExtraKeyVals: {
           "SubmittedFromInfobar": true,
         },
-      });
+      }).catch(Cu.reportError);
     }
   },
 };
 
 this.PluginCrashReporter = {
   /**
    * Makes the PluginCrashReporter ready to hear about and
    * submit crash reports.
@@ -990,17 +990,17 @@ this.PluginCrashReporter = {
     let { pluginDumpID, browserDumpID } = this.crashReports.get(runID);
 
     let submissionPromise = CrashSubmit.submit(pluginDumpID, {
       recordSubmission: true,
       extraExtraKeyVals: keyVals,
     });
 
     if (browserDumpID)
-      CrashSubmit.submit(browserDumpID);
+      CrashSubmit.submit(browserDumpID).catch(Cu.reportError);
 
     this.broadcastState(runID, "submitting");
 
     submissionPromise.then(() => {
       this.broadcastState(runID, "success");
     }, () => {
       this.broadcastState(runID, "failed");
     });
--- a/devtools/server/actors/webextension-inspected-window.js
+++ b/devtools/server/actors/webextension-inspected-window.js
@@ -285,17 +285,17 @@ var WebExtensionInspectedWindowActor = p
             });
 
             this.customizedReload.start()
                 .then(() => {
                   delete this.customizedReload;
                 })
                 .catch(err => {
                   delete this.customizedReload;
-                  throw err;
+                  console.error(err);
                 });
           } catch (err) {
             // Cancel the customized reload (if any) on exception during the
             // reload setup.
             if (this.customizedReload) {
               this.customizedReload.stop(err);
             }