XMLHttpRequest – Browser Compatibility

by Subbu Allamaraju on July 31, 2006

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 EventTarget interface for XMLHttpRequest. 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, getResponseHeader throw an exception when readyState = 1. It does not make sense for these methods to return empty string when called before calling send. Firefox supports this behavior, and I prefer Firefox’s behavior to the current draft.
  • It is not clear why the current draft requires getResponseHeader to return an empty string when the given header is not present. I would expect a null return 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.

{ 2 comments… read them below or add one }

1 fearphage April 7, 2008 at 5:03 pm

The test page is broken:

“Unable to load tests/suite.js”

Reply

2 Subbu Allamaraju April 7, 2008 at 6:38 pm

Thanks. Fixed.

Reply

Leave a Comment

Previous post:

Next post: