5 <p>Test bug
13141 : XMLHttpRequest should set readyState to
0 after abort()
</p>
6 <p>Updated for bug
16989: Add send() flag checks in XmlHttpRequest
</p>
7 <p>Should see
"PASS (reasyState event send)" &
"PASS" (in that order) three times:
</p>
10 <script type=
"text/javascript">
11 function log(message
) {
12 document
.getElementById("ans").appendChild(document
.createTextNode(message
));
13 document
.getElementById("ans").appendChild(document
.createElement("br"));
16 // Used to detect if a readystate event is dispatched
17 function catchReadystateEventAbort() {
18 log("PASS (readystate event send)");
21 // Called only for readyState == 1
22 function testAbortWithReadyStateEventLoading()
26 if (window
.XMLHttpRequest
) {
27 xhr
= new XMLHttpRequest();
30 xhr
= new ActiveXObject("Msxml2.XMLHTTP");
32 xhr
= new ActiveXObject("Microsoft.XMLHTTP");
36 // We use a slow page to test the LOADING state with the send() flag
37 // and we do not catch readyState event before send has been called
38 xhr
.open("GET", "resources/endlessxml.php", true);
42 xhr
.onreadystatechange
= catchReadystateEventAbort
;
45 if (xhr
.readyState
== 0)
50 if (finishedTests
== abortToDo
.length
&& window
.testRunner
)
51 testRunner
.notifyDone();
54 // Called with num != 1
55 function testAbortWithReadyStateEvent(num
)
59 if (window
.XMLHttpRequest
) {
60 xhr
= new XMLHttpRequest();
63 xhr
= new ActiveXObject("Msxml2.XMLHTTP");
65 xhr
= new ActiveXObject("Microsoft.XMLHTTP");
69 xhr
.onreadystatechange = function () {
70 if (this.readyState
== num
) {
72 this.onreadystatechange
= catchReadystateEventAbort
;
74 if (this.readyState
== 0)
80 if (finishedTests
== abortToDo
.length
&& window
.testRunner
)
81 testRunner
.notifyDone();
84 xhr
.open("GET", "resources/1251.html", true);
88 if (window
.testRunner
) {
89 testRunner
.dumpAsText();
90 testRunner
.waitUntilDone();
93 var finishedTests
= 0;
95 var abortToDo
= ['2', '3', '1'];
97 for (i
= 0; i
< abortToDo
.length
; i
++)
98 if (abortToDo
[i
] == 1)
99 testAbortWithReadyStateEventLoading();
101 testAbortWithReadyStateEvent(abortToDo
[i
]);