Chromium Code Reviews| 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 if ((num != 0 && this.readyState == num) || | |
|
tyoshino (SeeGerritForStatus)
2016/11/22 08:46:54
shouldn't this be
num != XMLHttpRequest.DONE && t
sof
2016/11/22 08:58:33
It would be unnatural & unwanted for there to be a
tyoshino (SeeGerritForStatus)
2016/11/22 09:29:53
Got it. But this would log PASS when num is XMLHtt
sof
2016/11/22 10:14:14
I've teased apart the testing of the pass conditio
tyoshino (SeeGerritForStatus)
2016/11/22 11:18:32
Yes. Thanks!
| |
| 43 (num == XMLHttpRequest.DONE && this.readyState == 0)) | |
| 41 log("PASS"); | 44 log("PASS"); |
| 42 else | 45 else |
| 43 log("FAILED"); | 46 log("FAILED"); |
| 44 } | 47 } |
| 45 | 48 |
| 46 if (finishedTests == abortToDo.length && window.testRunner) | 49 if (finishedTests == abortToDo.length && window.testRunner) |
| 47 testRunner.notifyDone(); | 50 testRunner.notifyDone(); |
| 48 } | 51 } |
| 49 | 52 |
| 50 xhr.open("GET", "resources/1251.html", true); | 53 xhr.open("GET", "resources/1251.html", true); |
| 51 | 54 |
| 52 // We want to be able to test in the OPENED state with the send() flag to fa lse | 55 // 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 | 56 // so do not call send in that case |
| 54 if (num != 1) | 57 if (num != 1) |
| 55 xhr.send(null); | 58 xhr.send(null); |
| 56 } | 59 } |
| 57 | 60 |
| 58 if (window.testRunner) { | 61 if (window.testRunner) { |
| 59 testRunner.dumpAsText(); | 62 testRunner.dumpAsText(); |
| 60 testRunner.waitUntilDone(); | 63 testRunner.waitUntilDone(); |
| 61 } | 64 } |
| 62 | 65 |
| 63 var finishedTests = 0; | 66 var finishedTests = 0; |
| 64 | 67 |
| 65 var abortToDo = ['1', '4']; | 68 var abortToDo = ['1', '4']; |
| 66 | 69 |
| 67 for (i = 0; i < abortToDo.length; i++) | 70 for (i = 0; i < abortToDo.length; i++) |
| 68 testAbortDoNotDispatchEvent(abortToDo[i]); | 71 testAbortDoNotDispatchEvent(abortToDo[i]); |
| 69 | 72 |
| 70 </script> | 73 </script> |
| 71 </body> | 74 </body> |
| 72 </html> | 75 </html> |
| OLD | NEW |