xpcshell tests should fail on exceptions thrown from event loop

RESOLVED WONTFIX

Status

--
enhancement
RESOLVED WONTFIX
12 years ago
8 months ago

People

(Reporter: sylvain.pasche, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

12 years ago
Steps to reproduce:

Try calling an undefined function from an onDataAvailable() method called from the event loop. In debug builds, the exception will be printed in the terminal:
************************************************************
* Call to xpconnect wrapped JSObject produced this error:  *
[Exception... "'[JavaScript Error: "foobar is not defined" {file: "[...]test.js" line: 69}]' when calling method: [nsIStreamListener::onDataAvailable]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame :: "[...]test.js :: _do_main :: line 76"  data: yes]
************************************************************

But it won't make the test abort, as the exception does not reach the processNextEvent() method form head.js

That would be definitely better to catch these. Grepping the log file wouldn't be the solution, as in non Debug builds I guess nothing is printed, if I read correctly from: http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp&rev=1.99&mark=880-900#881

Comment 1

12 years ago
It's perfectly reasonable for thrown JS exceptions not to cause a test to fail (consider QueryInterface or nsIClassInfo.getInterfaces).  In this case, I think an exception thrown from ODA causes the request to be canceled (causing onStopRequest to be called).  There's really nothing that can be done about this in the general case -- you just have to be careful to be sure that methods run to completion.
(Reporter)

Comment 2

12 years ago
(In reply to comment #1)
> It's perfectly reasonable for thrown JS exceptions not to cause a test to fail

I'm ok with this, but then there's a little inconsistency depending on where the exception is thrown. If you try to call a non existent method directly from run_test(), the test will fail (the exception being caught in tail.js). However,  that's not the case if that happens in a place reached from the event loop (such as in ODA).
Component: Testing → TUnit
Product: Core → Testing
QA Contact: testing → tunit
Version: Trunk → unspecified

Comment 3

8 months ago
Mass closing bugs with no activity in 2+ years. If this bug is important to you, please re-open.
Status: NEW → RESOLVED
Last Resolved: 8 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.