diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 25dc580b852..ab779086d6d 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -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 errorObject = diff --git a/content/base/test/test_bug708620.html b/content/base/test/test_bug708620.html index 5ace778b58c..7e15e9cf102 100644 --- a/content/base/test/test_bug708620.html +++ b/content/base/test/test_bug708620.html @@ -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) {