зеркало из https://github.com/mozilla/gecko-dev.git
Adding url and lineno to script evaluation
This commit is contained in:
Родитель
479b020a61
Коммит
c316d58438
|
@ -1812,7 +1812,16 @@ nsresult HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
}
|
||||
|
||||
jsval val;
|
||||
PRBool result = context->EvaluateString(script, len, &val);
|
||||
nsIURL* mDocURL = mDocument->GetDocumentURL();
|
||||
const char* mURL;
|
||||
if (mDocURL) {
|
||||
mURL = mDocURL->GetSpec();
|
||||
}
|
||||
PRUint32 mLineNo = (PRUint32)aNode.GetSourceLineNumber();
|
||||
|
||||
PRBool result = context->EvaluateString(script, len, mURL, mLineNo, &val);
|
||||
|
||||
NS_IF_RELEASE(mDocURL);
|
||||
|
||||
if (PR_FALSE == result) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
**/
|
||||
virtual PRBool EvaluateString(const char *aScript,
|
||||
PRUint32 aScriptSize,
|
||||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
jsval *aRetValue) = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,8 @@ static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
|||
void PR_CALLBACK
|
||||
NS_ScriptErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
printf("Script error: %s\n", message);
|
||||
printf("JavaScript error: %s\nURL :%s, LineNo :%u\nLine text: '%s', Error text: '%s'\n", message,
|
||||
report->filename, report->lineno, report->linebuf, report->tokenptr);
|
||||
}
|
||||
|
||||
nsJSContext::nsJSContext(JSRuntime *aRuntime)
|
||||
|
@ -57,14 +58,16 @@ NS_IMPL_ISUPPORTS(nsJSContext, kIScriptContextIID);
|
|||
|
||||
PRBool nsJSContext::EvaluateString(const char *aScript,
|
||||
PRUint32 aScriptSize,
|
||||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
jsval *aRetValue)
|
||||
{
|
||||
return ::JS_EvaluateScript(mContext,
|
||||
JS_GetGlobalObject(mContext),
|
||||
aScript,
|
||||
aScriptSize,
|
||||
NULL,
|
||||
0,
|
||||
aURL,
|
||||
aLineNo,
|
||||
aRetValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
|
||||
virtual PRBool EvaluateString(const char *aScript,
|
||||
PRUint32 aScriptSize,
|
||||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
jsval *aRetValue);
|
||||
virtual nsIScriptGlobalObject* GetGlobalObject();
|
||||
virtual void* GetNativeContext();
|
||||
|
|
|
@ -1812,7 +1812,16 @@ nsresult HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
}
|
||||
|
||||
jsval val;
|
||||
PRBool result = context->EvaluateString(script, len, &val);
|
||||
nsIURL* mDocURL = mDocument->GetDocumentURL();
|
||||
const char* mURL;
|
||||
if (mDocURL) {
|
||||
mURL = mDocURL->GetSpec();
|
||||
}
|
||||
PRUint32 mLineNo = (PRUint32)aNode.GetSourceLineNumber();
|
||||
|
||||
PRBool result = context->EvaluateString(script, len, mURL, mLineNo, &val);
|
||||
|
||||
NS_IF_RELEASE(mDocURL);
|
||||
|
||||
if (PR_FALSE == result) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
|
|
@ -866,6 +866,8 @@ void JSConsole::EvaluateText(UINT aStartSel, UINT aEndSel)
|
|||
jsval returnValue;
|
||||
if (mContext->EvaluateString(cleanBuffer,
|
||||
strlen(cleanBuffer),
|
||||
nsnull,
|
||||
0,
|
||||
&returnValue)) {
|
||||
// output the result on the console and on the edit area
|
||||
CHAR result[128];
|
||||
|
|
Загрузка…
Ссылка в новой задаче