Bug 382917 - "Display script filename and line number in Stop Script dialog" [p=manish@flock.com (Manish Singh) r+sr=mrbkap a1.9=jst]

This commit is contained in:
reed@reedloden.com 2007-12-03 01:17:40 -08:00
Родитель 35e4a80941
Коммит 3a4d5df30f
2 изменённых файлов: 30 добавлений и 0 удалений

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

@ -38,6 +38,7 @@
KillScriptTitle=Warning: Unresponsive script
KillScriptMessage=A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.
KillScriptWithDebugMessage=A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue.
KillScriptLocation=Script: %S
StopScriptButton=Stop script
DebugScriptButton=Debug script
WaitForScriptButton=Continue

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

@ -938,6 +938,35 @@ nsJSContext::DOMBranchCallback(JSContext *cx, JSScript *script)
return JS_TRUE;
}
// Append file and line number information, if available
if (script) {
const char *filename = ::JS_GetScriptFilename(cx, script);
if (filename) {
nsXPIDLString scriptLocation;
NS_ConvertUTF8toUTF16 filenameUTF16(filename);
const PRUnichar *formatParams[] = { filenameUTF16.get() };
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("KillScriptLocation").get(),
formatParams, 1,
getter_Copies(scriptLocation));
if (NS_SUCCEEDED(rv) && scriptLocation) {
msg.AppendLiteral("\n\n");
msg.Append(scriptLocation);
JSStackFrame *fp, *iterator = nsnull;
fp = ::JS_FrameIterator(cx, &iterator);
if (fp) {
jsbytecode *pc = ::JS_GetFramePC(cx, fp);
if (pc) {
PRUint32 lineno = ::JS_PCToLineNumber(cx, script, pc);
msg.Append(':');
msg.AppendInt(lineno);
}
}
}
}
}
PRInt32 buttonPressed = 1; //In case user exits dialog by clicking X
PRBool neverShowDlgChk = PR_FALSE;
PRUint32 buttonFlags = (nsIPrompt::BUTTON_TITLE_IS_STRING *