OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>XMLHttpRequest: calling abort() during onloadstart should not fail</title
> |
| 5 <script src="../resources/testharness.js"></script> |
| 6 <script src="../resources/testharnessreport.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <script> |
| 10 var testAsync = async_test("Aborting during onloadstart"); |
| 11 testAsync.step(() => { |
| 12 var xhr = new XMLHttpRequest(); |
| 13 xhr.open("POST", "resources/delay.php?iteration=1&delay=1000"); |
| 14 xhr.onloadstart = testAsync.step_func(() => { |
| 15 assert_equals(xhr.readyState, XMLHttpRequest.OPENED); |
| 16 xhr.abort(); |
| 17 }); |
| 18 xhr.onload = testAsync.step_func(() => { |
| 19 assert_unreached("The aborted send() shouldn't go ahead, and complete.")
; |
| 20 }); |
| 21 xhr.onabort = testAsync.step_func(() => { |
| 22 testAsync.done(); |
| 23 }); |
| 24 xhr.send(); |
| 25 }); |
| 26 |
| 27 var testAsyncUpload = async_test("Aborting during upload.onloadstart"); |
| 28 testAsyncUpload.step(() => { |
| 29 var xhr = new XMLHttpRequest(); |
| 30 xhr.open("POST", "resources/delay.php?iteration=1&delay=1000"); |
| 31 xhr.upload.onloadstart = testAsyncUpload.step_func(() => { |
| 32 assert_equals(xhr.readyState, XMLHttpRequest.OPENED); |
| 33 xhr.abort(); |
| 34 }); |
| 35 xhr.onload = testAsyncUpload.step_func(() => { |
| 36 assert_unreached("The aborted send() shouldn't go ahead, and complete.")
; |
| 37 }); |
| 38 xhr.onabort = testAsyncUpload.step_func(() => { |
| 39 testAsyncUpload.done(); |
| 40 }); |
| 41 xhr.send("Uploaded"); |
| 42 }); |
| 43 |
| 44 var testAsyncResend = async_test("Resending during onloadstart"); |
| 45 testAsyncResend.step(() => { |
| 46 var xhr = new XMLHttpRequest(); |
| 47 xhr.open("POST", "resources/delay.php?iteration=1&delay=1000"); |
| 48 xhr.onloadstart = testAsyncResend.step_func(() => { |
| 49 assert_equals(xhr.readyState, XMLHttpRequest.OPENED); |
| 50 xhr.open("POST", "resources/delay.php?iteration=1&delay=1000"); |
| 51 xhr.send(); |
| 52 }); |
| 53 xhr.onload = testAsyncResend.step_func(() => { |
| 54 assert_equals(xhr.readyState, XMLHttpRequest.DONE); |
| 55 testAsyncResend.done(); |
| 56 }); |
| 57 xhr.send(); |
| 58 }); |
| 59 </script> |
| 60 </body> |
| 61 </html> |
OLD | NEW |