| OLD | NEW | 
| (Empty) |  | 
 |   1 <!doctype html> | 
 |   2 <html> | 
 |   3 <head> | 
 |   4 <title>XMLHttpRequest: abort() while sending data</title> | 
 |   5 <script src="../resources/testharness.js"></script> | 
 |   6 <script src="../resources/testharnessreport.js"></script> | 
 |   7 </head> | 
 |   8 <body> | 
 |   9 Correct progress event sequencing on abort(), <a href="http://crbug.com/315488">
    bug 315488</a>. | 
 |  10 <script> | 
 |  11 // Based on http://w3c-test.org/web-platform-tests/master/XMLHttpRequest/abort-d
    uring-upload.htm | 
 |  12  | 
 |  13 var expected = [ | 
 |  14     'upload', 'progress', | 
 |  15     'upload', 'abort', | 
 |  16     'upload', 'loadend', | 
 |  17     'load', 'progress', | 
 |  18     'load', 'abort', | 
 |  19     'load', 'loadend']; | 
 |  20  | 
 |  21 var result = []; | 
 |  22 function recordEvent(e) { | 
 |  23     var kind = e.target instanceof XMLHttpRequest ? 'load' : 'upload'; | 
 |  24     result.push(kind, e.type); | 
 |  25 } | 
 |  26  | 
 |  27 var abortAfterSendLoadend = async_test("Progress event delivery on abort(), post
    -send() (async)"); | 
 |  28 abortAfterSendLoadend.step(function() { | 
 |  29     var xhr = new XMLHttpRequest(); | 
 |  30     xhr.open("POST", "resources/delay.php?iteration=1&delay=1000"); | 
 |  31     xhr.onprogress = recordEvent; | 
 |  32     xhr.onabort = recordEvent; | 
 |  33     xhr.onloadend = abortAfterSendLoadend.step_func(function (e) { | 
 |  34         recordEvent(e); | 
 |  35         assert_equals(xhr.readyState, XMLHttpRequest.DONE); | 
 |  36         assert_array_equals(result, expected); | 
 |  37         // Runs after abort()'s transition of readyState to UNSENT. | 
 |  38         setTimeout(abortAfterSendLoadend.step_func(function () { | 
 |  39             assert_equals(xhr.readyState, XMLHttpRequest.UNSENT); | 
 |  40             abortAfterSendLoadend.done(); | 
 |  41         }), 0); | 
 |  42     }); | 
 |  43     xhr.upload.onprogress = recordEvent; | 
 |  44     xhr.upload.onabort = recordEvent; | 
 |  45     xhr.upload.onloadend = recordEvent; | 
 |  46  | 
 |  47     xhr.send(); | 
 |  48     xhr.abort(); | 
 |  49 }); | 
 |  50  | 
 |  51 var resultSync = []; | 
 |  52 function recordEventSync(e) { | 
 |  53     var kind = e.target instanceof XMLHttpRequest ? 'load' : 'upload'; | 
 |  54     resultSync.push(kind, e.type); | 
 |  55 } | 
 |  56 var abortAfterSendSync = async_test("Progress event delivery on abort(), post-se
    nd() (sync)"); | 
 |  57 abortAfterSendSync.step(function() { | 
 |  58     var xhr = new XMLHttpRequest(); | 
 |  59     xhr.open("POST", "resources/delay.php?iteration=1&delay=10"); | 
 |  60     xhr.onreadystatechange = function () { | 
 |  61         if (xhr.readyState > XMLHttpRequest.OPENED && xhr.readyState != XMLHttpR
    equest.DONE) | 
 |  62             xhr.abort(); | 
 |  63     }; | 
 |  64     xhr.onprogress = recordEventSync; | 
 |  65     xhr.onabort = recordEventSync; | 
 |  66     xhr.onloadend = abortAfterSendSync.step_func(function (e) { | 
 |  67         recordEventSync(e); | 
 |  68         assert_equals(xhr.readyState, XMLHttpRequest.DONE); | 
 |  69         assert_array_equals(resultSync, expected); | 
 |  70         // Runs after abort()'s transition of readyState to UNSENT. | 
 |  71         setTimeout(abortAfterSendSync.step_func(function () { | 
 |  72             assert_equals(xhr.readyState, XMLHttpRequest.UNSENT); | 
 |  73             abortAfterSendSync.done(); | 
 |  74         }), 0); | 
 |  75     }); | 
 |  76     xhr.upload.onprogress = recordEventSync; | 
 |  77     xhr.upload.onabort = recordEventSync; | 
 |  78     xhr.upload.onloadend = recordEventSync; | 
 |  79     xhr.send(); | 
 |  80 }); | 
 |  81 </script> | 
 |  82 </body> | 
 |  83 </html> | 
| OLD | NEW |