Closed Bug 661035 Opened 14 years ago Closed 14 years ago

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

Categories

(Core :: IPC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla8

People

(Reporter: luke, Assigned: jdm)

Details

Attachments

(1 file, 1 obsolete file)

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.
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
Attachment #544887 - Flags: review?(Olli.Pettay)
Attachment #544887 - Attachment is obsolete: true
Attachment #544887 - Flags: review?(Olli.Pettay)
Attachment #544888 - Flags: review?(Olli.Pettay)
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: nobody → josh
Whiteboard: [inbound]
Status: NEW → RESOLVED
Closed: 14 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.

Attachment

General

Created:
Updated:
Size: