OLD | NEW |
1 <html> | 1 <html> |
2 <head></head> | 2 <head></head> |
3 <body> | 3 <body> |
4 | 4 |
5 <p>Test bug 13141 : XMLHttpRequest should set readyState to 0 after abort() </p> | 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> | 6 <p>Updated for bug 16989: Add send() flag checks in XmlHttpRequest </p> |
7 <p>Should see "PASS" two times:</p> | 7 <p>Should see "PASS" two times:</p> |
8 <div id="ans"></div> | 8 <div id="ans"></div> |
9 | 9 |
10 <script type="text/javascript"> | 10 <script type="text/javascript"> |
(...skipping 19 matching lines...) Expand all Loading... |
30 } catch (ex) { | 30 } catch (ex) { |
31 xhr = new ActiveXObject("Microsoft.XMLHTTP"); | 31 xhr = new ActiveXObject("Microsoft.XMLHTTP"); |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 xhr.onreadystatechange = function () { | 35 xhr.onreadystatechange = function () { |
36 if (this.readyState == num) { | 36 if (this.readyState == num) { |
37 ++finishedTests; | 37 ++finishedTests; |
38 this.onreadystatechange = catchReadystateEventAbort; | 38 this.onreadystatechange = catchReadystateEventAbort; |
39 this.abort(); | 39 this.abort(); |
40 if (this.readyState == 0) | 40 // Following https://github.com/whatwg/xhr/issues/54, abort() should |
| 41 // set readyState to UNSENT only when it (readyState) is DONE. |
| 42 var pass; |
| 43 if (num == XMLHttpRequest.DONE) |
| 44 pass = this.readyState == XMLHttpRequest.UNSENT; |
| 45 else |
| 46 pass = this.readyState == num; |
| 47 |
| 48 if (pass) |
41 log("PASS"); | 49 log("PASS"); |
42 else | 50 else |
43 log("FAILED"); | 51 log("FAILED"); |
44 } | 52 } |
45 | 53 |
46 if (finishedTests == abortToDo.length && window.testRunner) | 54 if (finishedTests == abortToDo.length && window.testRunner) |
47 testRunner.notifyDone(); | 55 testRunner.notifyDone(); |
48 } | 56 } |
49 | 57 |
50 xhr.open("GET", "resources/1251.html", true); | 58 xhr.open("GET", "resources/1251.html", true); |
51 | 59 |
52 // We want to be able to test in the OPENED state with the send() flag to fa
lse | 60 // We want to be able to test in the OPENED state with the send() flag to fa
lse |
53 // so do not call send in that case | 61 // so do not call send in that case |
54 if (num != 1) | 62 if (num != 1) |
55 xhr.send(null); | 63 xhr.send(null); |
56 } | 64 } |
57 | 65 |
58 if (window.testRunner) { | 66 if (window.testRunner) { |
59 testRunner.dumpAsText(); | 67 testRunner.dumpAsText(); |
60 testRunner.waitUntilDone(); | 68 testRunner.waitUntilDone(); |
61 } | 69 } |
62 | 70 |
63 var finishedTests = 0; | 71 var finishedTests = 0; |
64 | 72 |
65 var abortToDo = ['1', '4']; | 73 var abortToDo = ['1', '4']; |
66 | 74 |
67 for (i = 0; i < abortToDo.length; i++) | 75 for (i = 0; i < abortToDo.length; i++) |
68 testAbortDoNotDispatchEvent(abortToDo[i]); | 76 testAbortDoNotDispatchEvent(abortToDo[i]); |
69 | 77 |
70 </script> | 78 </script> |
71 </body> | 79 </body> |
72 </html> | 80 </html> |
OLD | NEW |