Bug 1247089 - Add a mode to `ReportToConsoleNonLocalized` that ignores the calling location. r=bkelly

MozReview-Commit-ID: 3hAP7IgNxYs

--HG--
extra : rebase_source : fa07988a1359863ba12383055a6fbb81722f1363
This commit is contained in:
Kit Cambridge 2016-03-10 20:28:41 -08:00
Родитель 18c5c296ef
Коммит c92c8e5179
3 изменённых файлов: 22 добавлений и 7 удалений

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

@ -3477,7 +3477,8 @@ nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText,
nsIURI* aURI,
const nsAFlatString& aSourceLine,
uint32_t aLineNumber,
uint32_t aColumnNumber)
uint32_t aColumnNumber,
MissingErrorLocationMode aLocationMode)
{
uint64_t innerWindowID = 0;
if (aDocument) {
@ -3494,14 +3495,15 @@ nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText,
}
nsAutoCString spec;
if (!aLineNumber) {
if (!aLineNumber && aLocationMode == eUSE_CALLING_LOCATION) {
JSContext *cx = GetCurrentJSContext();
if (cx) {
nsJSUtils::GetCallingLocation(cx, spec, &aLineNumber, &aColumnNumber);
}
}
if (spec.IsEmpty() && aURI)
if (spec.IsEmpty() && aURI) {
aURI->GetSpec(spec);
}
nsCOMPtr<nsIScriptError> errorObject =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);

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

@ -825,7 +825,15 @@ public:
* @param [aColumnNumber=0] (Optional) Column number within resource
containing error.
If aURI is null, then aDocument->GetDocumentURI() is used.
* @param [aLocationMode] (Optional) Specifies the behavior if
error location information is omitted.
*/
enum MissingErrorLocationMode {
// Don't show location information in the error console.
eOMIT_LOCATION,
// Get location information from the currently executing script.
eUSE_CALLING_LOCATION
};
static nsresult ReportToConsoleNonLocalized(const nsAString& aErrorText,
uint32_t aErrorFlags,
const nsACString& aCategory,
@ -834,7 +842,9 @@ public:
const nsAFlatString& aSourceLine
= EmptyString(),
uint32_t aLineNumber = 0,
uint32_t aColumnNumber = 0);
uint32_t aColumnNumber = 0,
MissingErrorLocationMode aLocationMode
= eUSE_CALLING_LOCATION);
/**
* Report a localized error message to the error console.

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

@ -2740,7 +2740,8 @@ ServiceWorkerManager::ReportToAllClients(const nsCString& aScope,
uri,
aLine,
aLineNumber,
aColumnNumber);
aColumnNumber,
nsContentUtils::eOMIT_LOCATION);
}
// Report to any documents that have called .register() for this scope. They
@ -2772,7 +2773,8 @@ ServiceWorkerManager::ReportToAllClients(const nsCString& aScope,
uri,
aLine,
aLineNumber,
aColumnNumber);
aColumnNumber,
nsContentUtils::eOMIT_LOCATION);
}
if (regList->IsEmpty()) {
@ -2843,7 +2845,8 @@ ServiceWorkerManager::ReportToAllClients(const nsCString& aScope,
uri,
aLine,
aLineNumber,
aColumnNumber);
aColumnNumber,
nsContentUtils::eOMIT_LOCATION);
return;
}
}