Set the script's filename correctly and don't treat the lack of a filename as a

failure. bug 391470, r+sr=bzbarsky
This commit is contained in:
mrbkap%gmail.com 2007-09-15 16:51:12 +00:00
Родитель d5264338c1
Коммит 03c2c81ac8
2 изменённых файлов: 10 добавлений и 11 удалений

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

@ -68,6 +68,8 @@ public:
virtual const PRUnichar *GetHandlerText() = 0; virtual const PRUnichar *GetHandlerText() = 0;
// Get the location of the script. // Get the location of the script.
// Note: The memory pointed to by aFileName is owned by the
// nsIScriptTimeoutHandler and should not be freed by the caller.
virtual void GetLocation(const char **aFileName, PRUint32 *aLineNo) = 0; virtual void GetLocation(const char **aFileName, PRUint32 *aLineNo) = 0;
// If a script object, get the argv suitable for passing back to the // If a script object, get the argv suitable for passing back to the

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

@ -285,6 +285,12 @@ nsJSScriptTimeoutHandler::Init(nsIScriptContext *aContext, PRBool *aIsInterval,
} }
mExpr = expr; mExpr = expr;
// Get the calling location.
const char *filename;
if (nsJSUtils::GetCallingLocation(cx, &filename, &mLineNo)) {
mFileName.Assign(filename);
}
} else if (funobj) { } else if (funobj) {
if (!::JS_AddNamedRoot(cx, &mFunObj, "timeout.mFunObj")) { if (!::JS_AddNamedRoot(cx, &mFunObj, "timeout.mFunObj")) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -301,10 +307,12 @@ nsJSScriptTimeoutHandler::Init(nsIScriptContext *aContext, PRBool *aIsInterval,
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
PRUint32 dummy; PRUint32 dummy;
jsval *jsargv = nsnull; jsval *jsargv = nsnull;
nsCOMPtr<nsIJSArgArray> jsarray(do_QueryInterface(array)); nsCOMPtr<nsIJSArgArray> jsarray(do_QueryInterface(array));
jsarray->GetArgs(&dummy, reinterpret_cast<void **>(&jsargv)); jsarray->GetArgs(&dummy, reinterpret_cast<void **>(&jsargv));
// must have worked - we own the impl! :) // must have worked - we own the impl! :)
NS_ASSERTION(jsargv, "No argv!"); NS_ASSERTION(jsargv, "No argv!");
for (PRInt32 i = 2; (PRUint32)i < argc; ++i) { for (PRInt32 i = 2; (PRUint32)i < argc; ++i) {
@ -312,17 +320,6 @@ nsJSScriptTimeoutHandler::Init(nsIScriptContext *aContext, PRBool *aIsInterval,
} }
// final arg slot remains null, array has rooted vals. // final arg slot remains null, array has rooted vals.
mArgv = array; mArgv = array;
// Get the calling location.
const char *filename;
if (nsJSUtils::GetCallingLocation(cx, &filename, &mLineNo)) {
mFileName.Assign(filename);
if (mFileName.IsEmpty()) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
} else { } else {
NS_WARNING("No func and no expr - why are we here?"); NS_WARNING("No func and no expr - why are we here?");
} }