Bug 1138336 - Adapt nsIScriptError so it can display log messages with filename and line number; r=jst,neil,past

This commit is contained in:
Geoff Lankow 2015-04-28 18:39:47 +12:00
parent 9b0811adbc
commit 0ad055eb8b
7 changed files with 21 additions and 8 deletions

View File

@ -1415,6 +1415,8 @@ WebConsoleFrame.prototype = {
let severity = 'error';
if (aScriptError.warning || aScriptError.strict) {
severity = 'warning';
} else if (aScriptError.info) {
severity = 'log';
}
let category = 'js';

View File

@ -11,7 +11,7 @@
#include "nsISupports.idl"
#include "nsIConsoleMessage.idl"
[scriptable, uuid(d6a8dae2-367f-4939-a843-11e0c48e240c)]
[scriptable, uuid(248b2c94-2736-4d29-bfdf-bc64a2e60d35)]
interface nsIScriptError : nsIConsoleMessage
{
/** pseudo-flag for default case */
@ -27,6 +27,9 @@ interface nsIScriptError : nsIConsoleMessage
/** error or warning is due to strict option */
const unsigned long strictFlag = 0x4;
/** just a log message */
const unsigned long infoFlag = 0x8;
/**
* The error message without any context/line number information.
*

View File

@ -89,8 +89,13 @@ nsScriptError::GetMessageMoz(char16_t** result) {
NS_IMETHODIMP
nsScriptError::GetLogLevel(uint32_t* aLogLevel)
{
*aLogLevel = mFlags & (uint32_t)nsIScriptError::errorFlag ?
nsIConsoleMessage::error : nsIConsoleMessage::warn;
if (mFlags & (uint32_t)nsIScriptError::infoFlag) {
*aLogLevel = nsIConsoleMessage::info;
} else if (mFlags & (uint32_t)nsIScriptError::warningFlag) {
*aLogLevel = nsIConsoleMessage::warn;
} else {
*aLogLevel = nsIConsoleMessage::error;
}
return NS_OK;
}

View File

@ -13,7 +13,8 @@
}
.console-row[type="error"],
.console-row[type="warning"] {
.console-row[type="warning"],
.console-row[type="message"][typetext] {
-moz-binding: url("chrome://global/content/consoleBindings.xml#error");
}

View File

@ -221,12 +221,12 @@
var row = this.createConsoleRow();
var nsIScriptError = Components.interfaces.nsIScriptError;
// Is this error actually just a non-fatal warning?
var warning = aObject.flags & nsIScriptError.warningFlag != 0;
// nsIConsoleMessage constants: debug, info, warn, error
var typetext = ["typeMessage", "typeMessage", "typeWarning", "typeError"][aObject.logLevel];
var type = ["message", "message", "warning", "error"][aObject.logLevel];
var typetext = warning ? "typeWarning" : "typeError";
row.setAttribute("typetext", this.mStrBundle.getString(typetext));
row.setAttribute("type", warning ? "warning" : "error");
row.setAttribute("type", type);
row.setAttribute("msg", aObject.errorMessage);
row.setAttribute("category", aObject.category);
row.setAttribute("time", this.properFormatTime(aObject.timeStamp));

View File

@ -1272,6 +1272,7 @@ WebConsoleActor.prototype =
error: !!(aPageError.flags & aPageError.errorFlag),
exception: !!(aPageError.flags & aPageError.exceptionFlag),
strict: !!(aPageError.flags & aPageError.strictFlag),
info: !!(aPageError.flags & aPageError.infoFlag),
private: aPageError.isFromPrivateWindow,
};
},

View File

@ -4,6 +4,7 @@
typeError=Error:
typeWarning=Warning:
typeMessage=Message:
errFile=Source File: %S
errLine=Line: %S
errLineCol=Line: %S, Column: %S