laurentj / slimerjs

A scriptable browser like PhantomJS, based on Firefox
http://slimerjs.org
Other
3k stars 258 forks source link

Missing NS_ERROR_DOM_BAD_URI in net-log.js #441

Open wskorodecki opened 8 years ago

wskorodecki commented 8 years ago

I think there is missing NS_ERROR_DOM_BAD_URI (int: 2152924148, hex: 0x805303F4) in getErrorCode() function.

I came across it while testing my application. It may be associated with "Same origin policy". http://stackoverflow.com/questions/7969265/firefox-ajax-call-returning-ns-error-dom-bad-uri-or-jsonp-false-error

This error was displayed after uncommenting dump() function in onStartRequest() method around line 288 in net-log.js. It may be important that I was using changeUrl() method (to add a new parameter tu URL) for every request.

Maybe it is also related to not yet supported "--web-security" switch.

puravida commented 8 years ago

@wskorodecki Hello! I've spent nearly 8 hours trying to figure out a way to pull these kinds of error responses out of slimer, to no avail. Things like NS_ERROR_MALFORMED_URI show with debug=true and will log in the slimer log, but they are not returned by any of the onError or onResourceXX callbacks. What are you referring to by "getErrorCode() function?" That sounds like what I'm looking for but it's not in the documentation for phantom or slimer and Google search comes up with zero on that.

Thanks for any insight!

wskorodecki commented 8 years ago

@puravida Hi! You can find getErrorCode() function in src/modules/slimer-sdk/net-log.js line: ~1165. There is a big switch with known error codes, but it looks like the list is not complete.

puravida commented 8 years ago

Thanks for that super quick response! I had seen that slimer-sdk/net-log.js portion in the slimer debug logs but didn't realize it correlated to the src/modules/slimer-sdk and Google didn't help find that either. lol. Thanks to your comments, I realize that I had already basically built that function in my own code and just didn't realize that more status codes would be passed than were noted in the Qt Network and slimer docs. I discovered that these codes ARE being returned in the onResourceError, after all, but I was ignoring them if they weren't for the current URL. I needed to also check for any pending redirectURL. Now, I've got it. ;)

Thanks a LOT! Ciao.