Exceptions thrown by XMLHttpRequest.responseXML and XMLHttpRequest.responseText

[ Sorry for the cross-post -- I originally sent this to the wrong  
list. ]

Hi.

The current working draft of the XMLHttpRequest spec says the  
following about responseXML and responseText.

responseText:
If the state is not LOADING or DONE raise an INVALID_STATE_ERR  
exception and terminate these steps.

responseXML:
If the state is not DONE raise an INVALID_STATE_ERR exception and  
terminate these steps.

While implementing this specification in WebKit, we gathered the  
following pieces of data:

1. This specification breaks at least one AJAX library, used by  
greenfieldonline.com.

2. This specification does not match any shipping version of Safari or  
Firefox, which do not throw exceptions.

3. This specification does not match any shipping version of Internet  
Explorer, which throws exceptions in some of these conditions, but not  
all. (The specifics here are a little weird, so I'll leave them out.)

4. Generally speaking, throwing an exception, which aborts a program,  
is a much bigger compatibility risk than not throwing an exception.

Therefore, for WebKit, I've decided that the most compatible and least  
weird behavior is not to throw an exception when accessing  
responseText or responseXML. Rather, for responseText, return the  
empty string, and for responseXML, return null.

Would you be willing to consider editing the XMLHttpRequest spec to  
match this behavior?

Thanks,
Geoff

Received on Friday, 15 February 2008 17:27:17 UTC