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

failure. bug 391470, r+sr=bzbarsky


git-svn-id: svn://10.0.0.236/trunk@236035 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mrbkap%gmail.com 2007-09-15 16:51:12 +00:00
parent cf15fb4cfc
commit cd99d05c53
2 changed files with 10 additions and 11 deletions

View File

@ -68,6 +68,8 @@ public:
virtual const PRUnichar *GetHandlerText() = 0;
// 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;
// If a script object, get the argv suitable for passing back to the

View File

@ -285,6 +285,12 @@ nsJSScriptTimeoutHandler::Init(nsIScriptContext *aContext, PRBool *aIsInterval,
}
mExpr = expr;
// Get the calling location.
const char *filename;
if (nsJSUtils::GetCallingLocation(cx, &filename, &mLineNo)) {
mFileName.Assign(filename);
}
} else if (funobj) {
if (!::JS_AddNamedRoot(cx, &mFunObj, "timeout.mFunObj")) {
return NS_ERROR_OUT_OF_MEMORY;
@ -301,10 +307,12 @@ nsJSScriptTimeoutHandler::Init(nsIScriptContext *aContext, PRBool *aIsInterval,
if (NS_FAILED(rv)) {
return NS_ERROR_OUT_OF_MEMORY;
}
PRUint32 dummy;
jsval *jsargv = nsnull;
nsCOMPtr<nsIJSArgArray> jsarray(do_QueryInterface(array));
jsarray->GetArgs(&dummy, reinterpret_cast<void **>(&jsargv));
// must have worked - we own the impl! :)
NS_ASSERTION(jsargv, "No argv!");
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.
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 {
NS_WARNING("No func and no expr - why are we here?");
}