Fix to 48299. Distinguish between chrome JS and content JS when reporting errors; this will allow the JS console to hide or otherwise highlight errors in UI javascript.

r=jst, sr=jband.
This commit is contained in:
mccabe%netscape.com 2000-12-07 02:08:21 +00:00
Родитель 1e2d8c81f1
Коммит d514aa2e71
1 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -48,7 +48,9 @@
#include "nsCOMPtr.h"
#include "nsJSUtils.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIPresContext.h"
#include "nsIScriptError.h"
#include "nsIInterfaceRequestor.h"
#include "nsIPrompt.h"
#include "nsIObserverService.h"
@ -70,8 +72,6 @@ static NS_DEFINE_IID(kPrefServiceCID, NS_PREF_CID);
static PRLogModuleInfo* gJSDiagnostics = nsnull;
#endif
#include "nsIScriptError.h"
void PR_CALLBACK
NS_ScriptErrorReporter(JSContext *cx,
const char *message,
@ -123,12 +123,24 @@ NS_ScriptErrorReporter(JSContext *cx,
nsCOMPtr<nsIScriptError>
errorObject(do_CreateInstance("@mozilla.org/scripterror;1"));
// XXX possible here to distinguish between XUL and content js?
// or could just expose setCategory and twiddle it later.
const char *category = "XUL/Content JavaScript";
if (errorObject != nsnull) {
nsresult rv = NS_ERROR_FAILURE;
nsresult rv;
const char *category = nsnull;
// Set category to XUL or content, if possible.
if (docShell) {
nsCOMPtr<nsIDocShellTreeItem> docShellTI(do_QueryInterface(docShell, &rv));
if (NS_SUCCEEDED(rv) && docShellTI) {
PRInt32 docShellType;
rv = docShellTI->GetItemType(&docShellType);
if (NS_SUCCEEDED(rv)) {
category = docShellType == nsIDocShellTreeItem::typeChrome
? "chrome javascript"
: "content javascript";
}
}
}
if (report) {
nsAutoString fileUni;
fileUni.AssignWithConversion(report->filename);