Closed Bug 380169 Opened 18 years ago Closed 11 years ago

nsXPCWrappedJSClass::CheckForException needs a way to silence XPConnect reporting component errors temporarily

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 738119

People

(Reporter: WeirdAl, Assigned: WeirdAl)

Details

Attachments

(1 file)

In one of my test components, I deliberately catch exceptions which I expect, and consider it a failure if I don't have an exception. However, XPConnect unconditionally reports the error every time. I'd like to be able to shut that off during testing, but leave it on under normal circumstances. My current thinking would be a preference - say, "javascript.options.reportXPConnectErrors" - defaulting to true. When the preference is set to false, XPConnect simply doesn't report the error. With the do_load_module() code for xpcshell tests, writing a testcase for this would be easy. Any thoughts? It should be pretty easy to do this.
I've run into a couple problems. Bug 380228 is one (crash bug). The second is that my console listener's observe() method is never called. Somehow the proxiedListener never calls it. I'm not sure if that's a bug or not; if it is, someone please tell me and I'll file a new bug with a testcase.
correction: the proxied listener executes after the main test completes. :(
ref comment 2: thanks to sayrer for pointing out code from http://lxr.mozilla.org/seamonkey/source/netwerk/test/httpserver/httpd.js : var thread = Components.classes["@mozilla.org/thread-manager;1"] .getService() .currentThread; while (thread.hasPendingEvents()) thread.processNextEvent(true);
Attached patch patch, v1Splinter Review
This patch includes a nice xpcshell testcase, and passes said testcase on Windows XP, Fedora Core 6 and Mac OS X 10.4, all trunk. Note also the code which this patch affects is not called unless the JS code fires an exception, so this isn't called all the time.
Attachment #264340 - Flags: review?(timeless)
Comment on attachment 264340 [details] [diff] [review] patch, v1 + nsCOMPtr<nsIConsoleService> consoleService = nsnull; no need for = nsnull; + if (NS_FAILED(rv) || pref) { I'd rather you check pref first. Lastly, this won't work :). It's racy. Back to the drawing board.
Attachment #264340 - Flags: review?(timeless) → review-
(In reply to comment #5) > Lastly, this won't work :). It's racy. Any suggestions on how to fix this? Maybe the approach by preferences isn't the right way to go, and I need some other API path to *temporarily* prevent it from reporting errors. This was the simplest I could come up with. Maybe a settable property in Components.utils? http://lxr.mozilla.org/seamonkey/source/js/src/xpconnect/idl/xpccomponents.idl
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: