Bug 1105652 - Handle uncaught promise rejections in the style editor;r=bgrins
☠☠ backed out by 8d3e410aa24a ☠ ☠
authorEddy Bruël <ejpbruel@gmail.com>
Fri, 09 Jan 2015 15:45:33 +0100
changeset 222838 0defe8745bb9f8fe021015377693d919c902ce32
parent 222837 86ac3a19e456adb1f81100e0aba2c58004b6db32
child 222928 e6756043d930ee61206b6927a63642b31df6e8ca
push id10730
push userejpbruel@mozilla.com
push dateFri, 09 Jan 2015 14:46:05 +0000
treeherderfx-team@0defe8745bb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1105652
milestone37.0a1
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);
-      });
+      }).catch(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);
-    })
+    }).catch(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);
         });
       }
-    });
+    }).catch(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))
+          .catch(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);
+            }).catch(Cu.reportError);
+          }).catch(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,18 @@ 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)
+                                 .catch(Cu.reportError);
   }
   this.cssSheet.on("media-rules-changed", this._onMediaRulesChanged);
   this.savedFile = file;
   this.linkCSSFile();
 }
 
 StyleSheetEditor.prototype = {
   /**