Bug 1421387 - Change the error banner for styleditor load errors to warnings; r=pbro
MozReview-Commit-ID: 9zdvMIuGw0P
--- 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);
}
},
/**