Bug 1421387 - Change the error banner for styleditor load errors to warnings; r=pbro draft
authorJesse Cordeiro <jesse.cordeiro@mail.utoronto.ca>
Tue, 06 Mar 2018 09:03:37 +0100
changeset 763597 9cf53d4dd1ae11f576e69b85688d4a08487bbbf9
parent 763557 709eae4e54ffa3f3518745516dd5d27a05255af2
push id101485
push userbmo:pbrosset@mozilla.com
push dateTue, 06 Mar 2018 08:12:13 +0000
reviewerspbro
bugs1421387
milestone60.0a1
Bug 1421387 - Change the error banner for styleditor load errors to warnings; r=pbro MozReview-Commit-ID: 9zdvMIuGw0P
devtools/client/styleeditor/StyleEditorUI.jsm
devtools/client/styleeditor/StyleSheetEditor.jsm
devtools/client/styleeditor/styleeditor-panel.js
--- a/devtools/client/styleeditor/StyleEditorUI.jsm
+++ b/devtools/client/styleeditor/StyleEditorUI.jsm
@@ -236,17 +236,17 @@ StyleEditorUI.prototype = {
     this._clear();
     this._suppressAdd = false;
 
     for (let sheet of styleSheets) {
       try {
         yield this._addStyleSheet(sheet);
       } catch (e) {
         console.error(e);
-        this.emit("error", { key: LOAD_ERROR });
+        this.emit("error", { key: LOAD_ERROR, level: "warning" });
       }
     }
 
     this._root.classList.remove("loading");
 
     this.emit("stylesheets-reset");
   }),
 
@@ -402,17 +402,17 @@ StyleEditorUI.prototype = {
       }
       NetUtil.asyncFetch({
         uri: NetUtil.newURI(selectedFile),
         loadingNode: this._window.document,
         securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
         contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
       }, (stream, status) => {
         if (!Components.isSuccessCode(status)) {
-          this.emit("error", { key: LOAD_ERROR });
+          this.emit("error", { key: LOAD_ERROR, level: "warning" });
           return;
         }
         let source =
             NetUtil.readInputStreamToString(stream, stream.available());
         stream.close();
 
         this._suppressAdd = true;
         this._debuggee.addStyleSheet(source).then((styleSheet) => {
--- a/devtools/client/styleeditor/StyleSheetEditor.jsm
+++ b/devtools/client/styleeditor/StyleSheetEditor.jsm
@@ -288,17 +288,18 @@ StyleSheetEditor.prototype = {
     }).catch(e => {
       if (this._isDestroyed) {
         console.warn("Could not fetch the source for " +
                      this.styleSheet.href +
                      ", the editor was destroyed");
         console.error(e);
       } else {
         console.error(e);
-        this.emit("error", { key: LOAD_ERROR, append: this.styleSheet.href });
+        this.emit("error", { key: LOAD_ERROR, append: this.styleSheet.href,
+                             level: "warning" });
         throw e;
       }
     });
   },
 
   /**
    * Add markup to a region. UNUSED_CLASS is added to specified lines
    * @param region An object shaped like
--- a/devtools/client/styleeditor/styleeditor-panel.js
+++ b/devtools/client/styleeditor/styleeditor-panel.js
@@ -82,19 +82,23 @@ StyleEditorPanel.prototype = {
     let errorMessage = getString(data.key);
     if (data.append) {
       errorMessage += " " + data.append;
     }
 
     let notificationBox = this._toolbox.getNotificationBox();
     let notification =
         notificationBox.getNotificationWithValue("styleeditor-error");
-    let level = (data.level === "info") ?
-                notificationBox.PRIORITY_INFO_LOW :
-                notificationBox.PRIORITY_CRITICAL_LOW;
+
+    let level = notificationBox.PRIORITY_CRITICAL_LOW;
+    if (data.level === "info") {
+      level = notificationBox.PRIORITY_INFO_LOW;
+    } else if (data.level === "warning") {
+      level = notificationBox.PRIORITY_WARNING_LOW;
+    }
 
     if (!notification) {
       notificationBox.appendNotification(errorMessage, "styleeditor-error",
                                          "", level);
     }
   },
 
   /**