Bug 1370652 - Handle more rejections in code exercised by browser-chrome tests. r=Mossop
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 06 Jun 2017 21:15:42 +0100
changeset 410772 985626bc4d9c44f1bb12f808276a256397596d0b
parent 410771 d95970dc9b7d41ed028960c7aeacd3584bdef689
child 410773 eb977b3751ca6084523f35adb88ca49dfab84fe5
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop
bugs1370652
milestone55.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 1370652 - Handle more rejections in code exercised by browser-chrome tests. r=Mossop These fixes are in preparation of making browser-chrome tests fail when there are unhandled Promise rejections. 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
@@ -102,16 +102,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
@@ -341,17 +341,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);
             }