зеркало из https://github.com/mozilla/pjs.git
Bug 743575 - Try to get line number if at all possible when reporting warnings to the error console. r=mrbkap
This commit is contained in:
Родитель
fb2353ee9b
Коммит
ee6a61ca2b
|
@ -3105,7 +3105,19 @@ nsContentUtils::ReportToConsole(PRUint32 aErrorFlags,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString spec;
|
||||
if (aURI)
|
||||
if (!aLineNumber) {
|
||||
JSContext *cx = nsnull;
|
||||
sThreadJSContextStack->Peek(&cx);
|
||||
if (cx) {
|
||||
const char* filename;
|
||||
PRUint32 lineno;
|
||||
if (nsJSUtils::GetCallingLocation(cx, &filename, &lineno)) {
|
||||
spec = filename;
|
||||
aLineNumber = lineno;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (spec.IsEmpty() && aURI)
|
||||
aURI->GetSpec(spec);
|
||||
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
|
|
|
@ -26,8 +26,14 @@ var tests = [
|
|||
"file_bug708620.html"
|
||||
];
|
||||
|
||||
function resolveURL(relative) {
|
||||
var a = document.createElement('a');
|
||||
a.href = relative;
|
||||
return a.href;
|
||||
}
|
||||
|
||||
var expectedErrors = [
|
||||
'[JavaScript Warning: "A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element."]'
|
||||
'[JavaScript Warning: "A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element." {file: "' + resolveURL(tests[0]) + '" line: 1}]'
|
||||
];
|
||||
|
||||
function consoleError(msg) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче