Closed Bug 382123 Opened 19 years ago Closed 8 years ago

Add a unit test for nsIException catching

Categories

(Core :: XPConnect, defect)

All
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INACTIVE

People

(Reporter: WeirdAl, Assigned: WeirdAl)

Details

Attachments

(1 file)

We actually don't have any unit tests for nsIException. It took me a little while to realize that's what XPConnect was throwing when returning to my code. This patch adds a simple unit test for nsIException being returned, and the expected result code, to the test_import.js file. Because it's test code, it shouldn't need sr.
Attached patch patchSplinter Review
whoops, forgot the actual patch :)
Assignee: nobody → ajvincent
Status: NEW → ASSIGNED
Attachment #266199 - Flags: review?(sayrer)
looks ok, but is this the right file to include it?
I don't know. I'll take suggestions for better spots (including a new file).
yeah, new file seems right.
I'll try a new file later. I would test the other properties of nsIException, but that would require a JS component file that was pretty much guaranteed to never change. Any suggestions?
the same component you use for the import test?
Wow, this is odd. I dumped the properties of the caught nsIException and its stack trace, expecting to find component_import.js in there. I didn't get it. This leads me to wonder if I have misinterpreted how nsIException objects are created, and what they should have. I expected to get a full stack trace, essentially, from the JS component throwing the exception, on down. exc.result: 2147500034 exc.QueryInterface: function QueryInterface() { [native code] } exc.message: Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsISupports.QueryInterface] exc.name: NS_NOINTERFACE exc.filename: ../../../../_tests/xpcshell-simple/TestXPC/unit/test_nsIException.js exc.lineNumber: 52 exc.columnNumber: 0 exc.location.QueryInterface: function QueryInterface() { [native code] } exc.location.language: 2 exc.location.languageName: JavaScript exc.location.filename: ../../../../_tests/xpcshell-simple/TestXPC/unit/test_nsIException.js exc.location.name: run_test exc.location.lineNumber: 52 exc.location.sourceLine: null exc.location.caller.QueryInterface: function QueryInterface() { [native code] } exc.location.caller.language: 2 exc.location.caller.languageName: JavaScript exc.location.caller.filename: c:/trunk/mozilla/tools/test-harness/xpcshell-simple/tail.js exc.location.caller.name: null exc.location.caller.lineNumber: 41 exc.location.caller.sourceLine: null exc.inner: null exc.data: null exc.initialize: function initialize() { [native code] }
Comment on attachment 266199 [details] [diff] [review] patch needs a new patch, right?
Attachment #266199 - Flags: review?(sayrer)
Yes, it does, but I probably won't submit one unless someone can clarify what the expected behavior of nsIException is - why, in particular, I didn't get what I expected in comment 7.
Re comment 9: Components.Exception leaves the throwing line in there. Throwing a nsresult code leaves one line missing. That's what I missed.
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: