Point to the JS Console page from the UI; from tasksOverlay, for now.

Tweak js console javascript, with many added notes

add 'categories I know about so far' to nsIScriptError.idl, as some attempt at documentation.
This commit is contained in:
mccabe%netscape.com 2000-03-31 10:51:13 +00:00
parent d22c963309
commit 817398ee13
5 changed files with 54 additions and 8 deletions

View File

@ -50,6 +50,12 @@ interface nsIScriptError : nsIConsoleMessage
readonly attribute PRUint32 columnNumber;
readonly attribute PRUint32 flags;
/**
* Categories I know about -
* XUL javascript
* content javascript (both of these from nsDocShell, currently)
* component javascript (errors in JS components)
*/
readonly attribute string category;
void init(in wstring message,

View File

@ -99,23 +99,54 @@ function onUnloadJSConsole()
function appendMessage(messageObject)
{
var c = document.getElementById("console");
var e = document.createElement("message");
var el = document.createElement("message");
var msgContent;
var text;
try {
// Try to QI it to a script error to get more info.
var scripterror =
messageObject.QueryInterface(Components.interfaces.nsIScriptError);
var nsIScriptError = Components.interfaces.nsIScriptError;
var scriptError =
messageObject.QueryInterface(nsIScriptError);
text = scripterror.sourceName + " line " + scripterror.lineNumber +
": " + scripterror.message;
// Is this error actually just a non-fatal warning?
var warning = scriptError.flags & nsIScriptError.WARNING != 0;
// Is this error or warning a result of JavaScript's strict mode,
// and therefore something we might decide to be lenient about?
var strict = scriptError.flags & nsIScriptError.STRICT != 0;
// If true, this error led to the creation of a (catchable!) javascript
// exception, and should probably be ignored.
// This is worth checking, as I'm not sure how the behavior falls
// out. Does an uncaught exception result in this flag being raised?
var isexn = scriptError.flags & nsIScriptError.EXCEPTION != 0;
/*
* It'd be nice to do something graphical with our column information,
* like what the old js console did, and the js shell does:
* js> var scooby = "I am an unterminated string!
* 1: unterminated string literal:
* 1: var scooby = "I am an unterminated string!
* 1: .............^
*
* But for now, I'm just pushing it out the door.
*/
text = "JavaScript " + (warning ? "Warning: " : "Error: ");
text += scriptError.sourceName;
text += " line " + scriptError.lineNumber +
", column " + scriptError.columnNumber + ": " + scriptError.message;
text += "Source line: " + scriptError.sourceLine;
msgContent = document.createTextNode(text);
} catch (exn) {
dump(exn + '\n');
// QI failed, just try to treat it as an nsIConsoleMessage
text = messageObject.message;
msgContent = document.createTextNode(text);
}
var t = document.createTextNode(text);
e.appendChild(t);
c.appendChild(e);
el.appendChild(msgContent);
c.appendChild(el);
}
// XXX q: if window is open, does it grow forever? Is that OK?

View File

@ -57,6 +57,11 @@ function toHistory()
}
function toJavaScriptConsole()
{
toOpenWindowByType("global:console", "chrome://global/content/console.xul");
}
function toJavaConsole()
{
try{

View File

@ -75,6 +75,7 @@
<menuitem value="&historyCmd.label;" oncommand="toHistory()"/>
<menuitem value="&importUtilCmd.label;" oncommand="toImport()"/>
<menuitem value="&javaConsoleCmd.label;" oncommand="toJavaConsole()"/>
<menuitem value="&javaScriptConsoleCmd.label;" oncommand="toJavaScriptConsole();"/>
</menupopup>
</menu>
<menuseparator/>

View File

@ -15,6 +15,9 @@
<!ENTITY importUtilCmd.label "Import Utility">
<!ENTITY javaConsoleCmd.label "Java Console">
<!ENTITY javaScriptConsoleCmd.label "JavaScript Console">
<!-- LOCALIZATION NOTE (walletMenu.label): DONT_TRANSLATE -->
<!ENTITY walletMenu.label "Personal Managers">
<!ENTITY walletFormManager.label "Form Manager">