Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / xmlhttprequest-abort-readyState-shouldNotDispatchEvent.html
blobff4b711af0ab4c518597372f7fe4b1d647c01ba9
1 <html>
2 <head></head>
3 <body>
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" two times:</p>
8 <div id="ans"></div>
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("FAILED (readystate event send)");
21 function testAbortDoNotDispatchEvent(num)
23 var xhr;
25 if (window.XMLHttpRequest) {
26 xhr = new XMLHttpRequest();
27 } else {
28 try {
29 xhr = new ActiveXObject("Msxml2.XMLHTTP");
30 } catch (ex) {
31 xhr = new ActiveXObject("Microsoft.XMLHTTP");
35 xhr.onreadystatechange = function () {
36 if (this.readyState == num) {
37 ++finishedTests;
38 this.onreadystatechange = catchReadystateEventAbort;
39 this.abort();
40 if (this.readyState == 0)
41 log("PASS");
42 else
43 log("FAILED");
46 if (finishedTests == abortToDo.length && window.testRunner)
47 testRunner.notifyDone();
50 xhr.open("GET", "resources/1251.html", true);
52 // We want to be able to test in the OPENED state with the send() flag to false
53 // so do not call send in that case
54 if (num != 1)
55 xhr.send(null);
58 if (window.testRunner) {
59 testRunner.dumpAsText();
60 testRunner.waitUntilDone();
63 var finishedTests = 0;
65 var abortToDo = ['1', '4'];
67 for (i = 0; i < abortToDo.length; i++)
68 testAbortDoNotDispatchEvent(abortToDo[i]);
70 </script>
71 </body>
72 </html>