calling abort method on XMLHttpRequest instance fires onreadystatechange with readyState 4

Martin Honnen <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xml
Organization Liberty Development
Message-ID <[email protected]>
I was running some tests on how the different implementations of 
XMLHttpRequest in different browsers react on calling the abort method.

This test case
<http://home.arcor.de/martin.honnen/mozillaBugs/XMLHttpRequest/abortChangesReadyState4.html>
has a HTML form allowing you to select a readyState when to call abort 
on an XMLHttpRequest instance and to run the test by clicking the button.

Mozilla (both Firefox 1.5.0.1 and a Firefox trunk nightly (Mozilla/5.0 
(Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060331 
Firefox/1.6a1) behave rather strangely, if you call abort when the 
readyState is 1, 2, or 3 then as a result of that call the 
onreadystatechange event handler is fired with readyState 4, then 
readyState is changed to 0.

Other implementations (Opera 8.5, IE 6 with Microsoft.XMLHTTP) simply 
abort and set readyState to 0, not firing any onreadystatechange 
handler, certainly not one with readyState 4.

I can't find any open bugs on XMLHttpRequest and abort.

I am not good at reading C++ but the abort implementation at
<http://lxr.mozilla.org/seamonkey/source/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp#671>
indeed seems to do

   ChangeState(XML_HTTP_REQUEST_COMPLETED, PR_TRUE, PR_TRUE);

first and only then does

   ChangeState(XML_HTTP_REQUEST_UNINITIALIZED, PR_FALSE);  // IE seems 
to do it

what other implementations do.

For a client script assigned to onreadystatechange it is obviously 
difficult in Mozilla to distinguish between a normal readyState 4 change 
and one that is caused by an abort call.

Should I file a bug on this?


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.