XMLHttpRequest - Browser Compatibility
I was curious to see how well latest versions of Firefox (1.5.x), Internet Explorer (6.0.x) and Opera (9.0) support the current working draft of XMLHttpRequest (http://www.w3.org/TR/XMLHttpRequest/), and spent the weekend to write some tests to check conformance. Since the XMLHttpRequest specification is only trying to standardize what was already supported in browsers (and promote interoperability), these tests can not really be used to rate current browser support. I would have liked to see the current draft reflect what is already supported by the current browsers, but it turned out to be not the case. There are some key differences between what is supported in browsers, and what the current draft specifies.
Click here to launch XMLHttpRequest conformance tests.
These tests are JavaScript based, and are by no means complete. I have not included all the conformance requirements into these tests, and I did short-circuit implementations of some tests.
Some observations from the results I got from the browsers I tested with.
- None of the browsers I tested support the
EventTargetinterface forXMLHttpRequest. Here the current XMLHttpRequest draft is ahead of the browsers. - Firefox does not call the onreadystatechange handler when
async = false. Something to note if you are using XMLHttpRequest for blocking requests. - I noticed that browsers return a non-null object for responseXML even when the response XML is malformed. This is counter-intuitive.
- I would expect
getAllResponseHeaders,getResponseHeaderthrow an exception whenreadyState = 1. It does not make sense for these methods to return empty string when called before callingsend. Firefox supports this behavior, and I prefer Firefox’s behavior to the current draft. - It is not clear why the current draft requires
getResponseHeaderto return an empty string when the given header is not present. I would expect anullreturn value. - All browsers handled request and response headers reasonably well for custom headers. However, Internet Explorer excludes some well-known response headers such as Date, Server, Connection.
Comments and corrections are welcome.
The test page is broken:
“Unable to load tests/suite.js”
Thanks. Fixed.