The default bug view has changed. See this FAQ.

make errors in scripts compiled by nsFrameMessageManager::LoadFrameScript more visible

RESOLVED FIXED in mozilla8

Status

()

Core
IPC
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: luke, Assigned: jdm)

Tracking

unspecified
mozilla8
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

6 years ago
Injecting a syntax error in, say, browser.js causes a JS syntax error message to pop out in console spew.  AFAICS, errors in scripts compiled via nsFrameMessageManager::LoadFrameScript issue no such report.  The exception generated by JS does get converted to an error report passed to ContentScriptErrorReporter which passes it on to nsConsoleService::LogMessage.  I'm not sure where in this process useful console output is supposed to be emitted.  Dolske said this has been a common complaint.  I know a visible error report would have personally saved me quite a few hours tracking down a recent bug.
(Assignee)

Comment 1

6 years ago
Ah, the error reporter that I wrote didn't include the console bit from NS_ScriptErrorReporter. Relevant bits of code:
http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsFrameMessageManager.cpp#538
http://mxr.mozilla.org/mozilla-central/source/dom/base/nsJSEnvironment.cpp#493
(Assignee)

Comment 2

6 years ago
Created attachment 544887 [details] [diff] [review]
Spit out content frame script errors to stdout.
Attachment #544887 - Flags: review?(Olli.Pettay)
(Assignee)

Updated

6 years ago
Attachment #544887 - Attachment is obsolete: true
Attachment #544887 - Flags: review?(Olli.Pettay)
(Assignee)

Comment 3

6 years ago
Created attachment 544888 [details] [diff] [review]
Print frame script errors to stdout.
Attachment #544888 - Flags: review?(Olli.Pettay)

Comment 4

6 years ago
Comment on attachment 544888 [details] [diff] [review]
Print frame script errors to stdout.

># HG changeset patch
># User Josh Matthews <josh@joshmatthews.net>
># Date 1310156158 14400
># Node ID f75a8a9a4723475a5d351e149b402fce06f1050d
># Parent  31e88a02c7d5ffe508de9731368190e1ed9b9ecc
>Bug 661035 - Print frame script errors to stdout. r=smaug
>
>diff --git a/content/base/src/nsFrameMessageManager.cpp b/content/base/src/nsFrameMessageManager.cpp
>--- a/content/base/src/nsFrameMessageManager.cpp
>+++ b/content/base/src/nsFrameMessageManager.cpp
>@@ -578,16 +578,42 @@ ContentScriptErrorReporter(JSContext* aC
>     return;
>   }
> 
>   nsCOMPtr<nsIConsoleService> consoleService =
>       do_GetService(NS_CONSOLESERVICE_CONTRACTID);
>   if (consoleService) {
>     (void) consoleService->LogMessage(scriptError);
>   }
>+
>+#ifdef DEBUG
>+  // Print it to stderr as well, for the benefit of those invoking
>+  // mozilla with -console.
>+  nsCAutoString error;
>+  error.Assign("JavaScript ");
>+  if (JSREPORT_IS_STRICT(flags))
>+    error.Append("strict ");
if (expr) {
  stmt;
}

>+  if (JSREPORT_IS_WARNING(flags))
>+    error.Append("warning: ");
>+  else
>+    error.Append("error: ");

if (expr) {
  stmt;
} else {
  stmt;
}
Attachment #544888 - Flags: review?(Olli.Pettay) → review+
(Assignee)

Comment 5

6 years ago
http://hg.mozilla.org/integration/mozilla-inbound/rev/820b80945342
Assignee: nobody → josh
Whiteboard: [inbound]
http://hg.mozilla.org/mozilla-central/rev/820b80945342
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Whiteboard: [inbound]
Target Milestone: --- → mozilla8
You need to log in before you can comment on or make changes to this bug.