Bug 1105652 - Handle uncaught promise rejections in the style editor;r=bgrins
authorEddy Bruël <ejpbruel@gmail.com>
Tue, 13 Jan 2015 10:50:20 +0100
changeset 223536 b9f37f7ce1f0d378d92015cd63d828240d82e32b
parent 223535 c9ff49636eefb8aaedca8de13b0ff684389d2c13
child 223537 0500f1032ea1f51c42b940cc6b25696cb9064c3e
child 223646 005a7c3f0facd7e0184d8890c884a4d1c349050d
push id28096
push usercbook@mozilla.com
push dateTue, 13 Jan 2015 13:27:54 +0000
treeherdermozilla-central@0500f1032ea1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1105652
milestone38.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 1105652 - Handle uncaught promise rejections in the style editor;r=bgrins
browser/devtools/styleeditor/StyleEditorUI.jsm
browser/devtools/styleeditor/StyleSheetEditor.jsm
--- a/browser/devtools/styleeditor/StyleEditorUI.jsm
+++ b/browser/devtools/styleeditor/StyleEditorUI.jsm
@@ -134,17 +134,17 @@ StyleEditorUI.prototype = {
         }
       }
     }.bind(this)).then(() => {
       this.createUI();
       this._debuggee.getStyleSheets().then((styleSheets) => {
         this._resetStyleSheetList(styleSheets); 
         this._target.on("will-navigate", this._clear);
         this._target.on("navigate", this._onNewDocument);
-      });
+      }, Cu.reportError);
     });
   },
 
   /**
    * Build the initial UI and wire buttons with event handlers.
    */
   createUI: function() {
     let viewRoot = this._root.parentNode.querySelector(".splitview-root");
@@ -202,17 +202,17 @@ StyleEditorUI.prototype = {
    * @param {string} event
    *        Event name
    * @param {StyleSheet} styleSheet
    *        StyleSheet object for new sheet
    */
   _onNewDocument: function() {
     this._debuggee.getStyleSheets().then((styleSheets) => {
       this._resetStyleSheetList(styleSheets);
-    })
+    }, Cu.reportError);
   },
 
   /**
    * Add editors for all the given stylesheets to the UI.
    *
    * @param  {array} styleSheets
    *         Array of StyleSheetFront
    */
@@ -280,17 +280,17 @@ StyleEditorUI.prototype = {
         sources.forEach((source) => {
           // set so the first sheet will be selected, even if it's a source
           source.styleSheetIndex = styleSheet.styleSheetIndex;
           source.relatedStyleSheet = styleSheet;
 
           this._addStyleSheetEditor(source);
         });
       }
-    });
+    }, Cu.reportError);
   },
 
   /**
    * Add a new editor to the UI for a source.
    *
    * @param {StyleSheet}  styleSheet
    *        Object representing stylesheet
    * @param {nsIfile}  file
@@ -312,17 +312,18 @@ StyleEditorUI.prototype = {
     editor.on("property-change", this._summaryChange.bind(this, editor));
     editor.on("media-rules-changed", this._updateMediaList.bind(this, editor));
     editor.on("linked-css-file", this._summaryChange.bind(this, editor));
     editor.on("linked-css-file-error", this._summaryChange.bind(this, editor));
     editor.on("error", this._onError);
 
     this.editors.push(editor);
 
-    editor.fetchSource(this._sourceLoaded.bind(this, editor));
+    editor.fetchSource(this._sourceLoaded.bind(this, editor))
+          .then(null, Cu.reportError);
     return editor;
   },
 
   /**
    * Import a style sheet from file and asynchronously create a
    * new stylesheet on the debuggee for it.
    *
    * @param {mixed} file
@@ -553,18 +554,18 @@ StyleEditorUI.prototype = {
                 let ruleCount = editor.styleSheet.ruleCount;
                 if (lineCount >= ruleCount) {
                   editor.addUnusedRegions(data.reports);
                 }
                 else {
                   this.emit("error", { key: "error-compressed", level: "info" });
                 }
               }
-            });
-          }, console.error);
+            }, Cu.reportError);
+          }, Cu.reportError);
         }.bind(this)).then(null, Cu.reportError);
       }.bind(this)
     });
   },
 
   /**
    * Switch to the editor that has been marked to be selected.
    *
--- a/browser/devtools/styleeditor/StyleSheetEditor.jsm
+++ b/browser/devtools/styleeditor/StyleSheetEditor.jsm
@@ -110,17 +110,17 @@ function StyleSheetEditor(styleSheet, wi
   this.updateStyleSheet = this.updateStyleSheet.bind(this);
   this._onMouseMove = this._onMouseMove.bind(this);
 
   this._focusOnSourceEditorReady = false;
   this.cssSheet.on("property-change", this._onPropertyChange);
   this.styleSheet.on("error", this._onError);
   this.mediaRules = [];
   if (this.cssSheet.getMediaRules) {
-    this.cssSheet.getMediaRules().then(this._onMediaRulesChanged);
+    this.cssSheet.getMediaRules().then(this._onMediaRulesChanged, Cu.reportError);
   }
   this.cssSheet.on("media-rules-changed", this._onMediaRulesChanged);
   this.savedFile = file;
   this.linkCSSFile();
 }
 
 StyleSheetEditor.prototype = {
   /**