Show human-friendly exceptions/nsresult msgs in necko xpcshell tests

Assigned to



Networking: HTTP
6 years ago
6 months ago


(Reporter: jduell, Assigned: jduell)


Firefox Tracking Flags

(Not tracked)


(Whiteboard: [necko-would-take])


(1 attachment)

Created attachment 617998 [details] [diff] [review]
head_channels.js pretty print changes.

I got sick of trying to map nsresult outputs in integer format back to their corresponding NS_ERROR_XXX codes, so I've taught head_channels how to do it for us.

If there's a better way to convert the nsresults into a string than the big switch statement here, I didn't hear it from biesi or bsmedberg on IRC.  In any case, it works.  (biesi: if you are too busy to review whole patch--it's pretty simple--then at least confirm my stringify approach here is ok with you and pass r? along to Patrick).

xpcshell tests also now print the HTTP status and channel status as info messages, which has already helped me debug some stuff.
Attachment #617998 - Flags: review?(cbiesinger)
BTW: ;)
Comment on attachment 617998 [details] [diff] [review]
head_channels.js pretty print changes.

+++ b/netwerk/test/unit/head_channels.js
+      request.QueryInterface(Components.interfaces.nsIHttpChannel);
+      test_info("HTTP response status=" + request.responseStatus);

this method is not specific to HTTP channels... so it would be nice not to throw for non-http ones. how about:

  if (request instanceof Components.interfaces.nsIHttpChannel) {

+function do_pretty_throw(msg, ex) {

Would be nice to just make do_throw smarter, instead of requiring a separate method!

+    // assume any number of 8 digits or more is an nsresult error code 

ex.result works
Attachment #617998 - Flags: review?(cbiesinger) → review-
Whiteboard: [necko-would-take]
You need to log in before you can comment on or make changes to this bug.